* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(1deg); }
  50% { transform: translateY(-15px) rotate(0deg); }
  75% { transform: translateY(-5px) rotate(-1deg); }
}

@keyframes glow {
  0%, 100% { text-shadow: 0 0 10px rgba(206, 17, 38, 0.5); }
  50% { text-shadow: 0 0 20px rgba(206, 17, 38, 0.8), 0 0 30px rgba(206, 17, 38, 0.6); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(206, 17, 38, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(206, 17, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(206, 17, 38, 0); }
}

@keyframes shimmer {
  0% { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes arabicFloat {
  0% { transform: translateX(-100vw) translateY(0px) rotate(0deg); opacity: 0.3; }
  50% { opacity: 0.1; }
  100% { transform: translateX(100vw) translateY(-50px) rotate(360deg); opacity: 0; }
}

body {
  font-family: 'Tajawal', Arial, sans-serif;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 25%, #2d1b69 50%, #1a1a3e 75%, #0f0f23 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Adjust opacity as needed */
  z-index: -1; /* Place behind content, above background image */
}


.container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  width: 96vw;
  max-width: 1200px;
  height: auto;
  min-height: 60vh;
  margin: 5vh auto 0 auto;
  position: relative;
  z-index: 2;
  background: none;
  box-shadow: none;
}

.word {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.letter {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 5rem;
  font-weight: bold;
  width: 120px;
  height: 120px;
  margin: 10px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  transform-origin: center center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  /* REMOVE ALL CSS animations to let GSAP Flip work properly */
}.letter::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, transparent, rgba(206, 17, 38, 0.4), transparent);
  border-radius: 20px;
  z-index: -1;
  /* Remove shimmer animation that interferes with Flip */
  background-size: 200% 100%;
}

.letter::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  pointer-events: none;
}

.letter:hover {
  transform: translateZ(30px) rotateY(10deg) rotateX(5deg) scale(1.1);
  animation-play-state: paused;
}

.letter:hover::after {
  width: 100px;
  height: 100px;
  animation: sparkle 0.6s ease;
}

.braille {
  font-size: 2.5rem;
  margin-left: 0.3rem;
  /* opacity: 0.8; */
  font-weight: normal;
  text-shadow: 0 0 10px currentColor;
  /* Remove glow animation that interferes with Flip */
}

/* Red letters */
.B, .H, .A2, .N {
  background: linear-gradient(135deg, #ce1126 0%, #ff4757 50%, #ce1126 100%);
  color: #f5e9d9;
  text-shadow: 0 0 20px rgba(245, 233, 217, 0.5);
  box-shadow: 0 8px 32px rgba(206, 17, 38, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* White letters */
.A, .R, .I {
  background: linear-gradient(135deg, rgba(245, 233, 217, 0.95) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(245, 233, 217, 0.95) 100%);
  color: #ce1126;
  text-shadow: 0 0 20px rgba(206, 17, 38, 0.5);
  box-shadow: 0 8px 32px rgba(245, 233, 217, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(206, 17, 38, 0.6);
}

.B:hover, .H:hover, .A2:hover, .N:hover {
  box-shadow: 0 12px 40px rgba(206, 17, 38, 0.5), 0 0 0 8px rgba(206, 17, 38, 0.1);
  animation: pulse 2s infinite;
}

.A:hover, .R:hover, .I:hover {
  box-shadow: 0 12px 40px rgba(245, 233, 217, 0.5), 0 0 0 8px rgba(245, 233, 217, 0.1);
}

/* Layout classes - NO CSS transitions, let GSAP handle everything */
.container.final {
  flex-direction: row;
}

.container.plain {
  flex-direction: row;
  flex-wrap: nowrap;
}

.container.plain .letter {
  border: none;
}

.container.plain .kingdom,
.container.plain .bahrain {
  display: none;
}

.container.columns .letter {
  margin: 8px;
}

.container.rows {
  flex-direction: row;
  width: 100%;
}

.container.rows .letter {
  margin: 8px;
}

.container.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 16px;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 16px;
  position: fixed;
  top: 0;
  left: 0;
}

.container.grid .letter {
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 15px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3), 0 0 50px rgba(206, 17, 38, 0.1);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Word styles */
.word {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 15px;
  /* opacity: 0; */
  transform: translateY(20px);
  display: none;
  text-align: center;
  letter-spacing: 0.5px;
  will-change: transform, opacity;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.container.grid .word {
  display: block;
}

/* Individual card presentation layout */
.container.individual {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 90%;
  height: 90%;
}

.container.individual .letter {
  margin: 15px;
  transition: none; /* Let GSAP handle all animations */
  position: relative;
  z-index: 1;
}

/* Enhanced word reveal in individual presentation */
.container.individual .word {
  display: block !important;
  position: absolute;
  top: 110%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 250px;
  background: linear-gradient(135deg, rgba(206, 17, 38, 0.98), rgba(255, 71, 87, 0.95));
  padding: 20px 35px;
  border-radius: 25px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 100px rgba(206, 17, 38, 0.8);
  backdrop-filter: blur(25px);
  border: 3px solid rgba(255, 255, 255, 0.4);
  z-index: 100;
  text-align: center;
}

.container.individual .word .arabic {
  font-size: 2.2rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
  margin-top: 10px;
  display: block;
  opacity: 1;
}

.word:hover {
  transform: translateY(15px) scale(1.05) !important;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.arabic::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.word:hover .arabic::before {
  transform: scaleX(1);
}

/* Red letters - word color */
.B .word, .H .word, .A2 .word, .N .word {
  color: #f5e9d9; /* Cream color */
}

/* White letters - word color */
.A .word, .R .word, .I .word {
  color: #ce1126; /* Bahrain red */
}

.kingdom, .bahrain {
  position: absolute;
  color: #ce1126;
  background: linear-gradient(135deg, rgba(245, 233, 217, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  padding: 12px 30px;
  border-radius: 15px;
  display: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 50px rgba(206, 17, 38, 0.2);
  font-family: 'Allison', cursive;
  will-change: transform, opacity;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(206, 17, 38, 0.3);
  text-shadow: 0 2px 10px rgba(206, 17, 38, 0.3);
  animation: glow 4s ease-in-out infinite alternate;
  letter-spacing: 2px;
}

/* Handwritten ink style for individual characters */
.kingdom span, .bahrain span {
  display: inline-block;
  position: relative;
  filter: drop-shadow(0 2px 3px rgba(206, 17, 38, 0.3));
}

.kingdom {
  bottom: 60%;
  font-size: 3rem;
  animation-delay: 1s;
}

.bahrain {
  top: 60%;
  font-size: 8rem;
  font-weight: bold;
  animation-delay: 0.5s;
}

.container.final .kingdom,
.container.final .bahrain {
  display: block;
}

.flag-credit {
  position: fixed;
  bottom: 20px;
  right: 30px;
  color: #ce1126;
  font-weight: bold;
  background-color: rgba(245, 233, 217, 0.7);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: 'Allison', cursive;
  font-size: 1.5rem;
}

/* Enhanced Narrative Styles */
.narrative {
  /* opacity: 0; */
  transform: translateY(30px) scale(0.9);
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(206, 17, 38, 0.1), rgba(245, 233, 217, 0.15));
  border-radius: 15px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(206, 17, 38, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  will-change: transform, opacity;
}

.story-title {
  font-size: 1.6rem;
  font-weight: bold;
  margin-bottom: 12px;
  background: linear-gradient(45deg, #ce1126, #d4af37);
  -webkit-background-clip: text;
  /* -webkit-text-fill-color: transparent; */
  background-clip: text;
  text-align: center;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.story-text {
  font-size: 1.1rem;
  line-height: 1.6;
  text-align: justify;
  color: rgba(0, 0, 0, 0.8);
  font-weight: 400;
  letter-spacing: 0.3px;
}

/* Red letters - narrative colors */
.B .story-title, .H .story-title, .A2 .story-title, .N .story-title {
  background: linear-gradient(45deg, #f5e9d9, #ffffff);
  -webkit-background-clip: text;
  /* -webkit-text-fill-color: transparent; */
  background-clip: text;
}

.B .story-text, .H .story-text, .A2 .story-text, .N .story-text {
  color: rgba(245, 233, 217, 0.95);
}

/* Particle System */
.particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(206, 17, 38, 0.8), transparent);
  border-radius: 50%;
  /* opacity: 0; */
  will-change: transform, opacity;
}

.particle.gold {
  background: radial-gradient(circle, rgba(212, 175, 55, 0.8), transparent);
}

.particle.silver {
  background: radial-gradient(circle, rgba(245, 233, 217, 0.8), transparent);
}

/* Magic Sprinkler canvas — overlays each letter card */
.magic-sprinkler {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  border-radius: inherit;
  display: block;
}

/* Enhanced Letter Effects */
.letter.reveal-active {
  transform: scale(1.15) rotateY(10deg);
  box-shadow: 0 20px 40px rgba(206, 17, 38, 0.3);
  z-index: 10;
  position: relative;
}

.letter.reveal-active::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background: linear-gradient(45deg, #ce1126, #d4af37, #ce1126);
  border-radius: inherit;
  z-index: -1;
  /* opacity: 0.6; */
  animation: borderPulse 2s ease-in-out infinite;
}

.letter.reveal-active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  /* background: radial-gradient(circle, rgba(206, 17, 38, 0.1), transparent 70%); */
  transform: translate(-50%, -50%);
  z-index: -2;
  animation: energyPulse 3s ease-in-out infinite;
}

/* Dramatic Reveal Animations */
@keyframes dramaticEntry {
  0% {
    opacity: 0;
    transform: scale(0.3) rotateY(-90deg) translateZ(-200px);
    filter: blur(10px);
  }
  30% {
    opacity: 0.7;
    transform: scale(1.2) rotateY(15deg) translateZ(50px);
    filter: blur(2px);
  }
  70% {
    opacity: 0.9;
    transform: scale(0.95) rotateY(-5deg) translateZ(10px);
    filter: blur(0px);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotateY(0deg) translateZ(0px);
    filter: blur(0px);
  }
}

@keyframes narrativeReveal {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.8) rotateX(-10deg);
    filter: blur(5px);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-10px) scale(1.05) rotateX(2deg);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0px) scale(1) rotateX(0deg);
    filter: blur(0px);
  }
}

@keyframes borderPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes energyPulse {
  0%, 100% { opacity: 0.1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.3; transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0);
  }
  20% {
    opacity: 1;
    transform: translateY(0px) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(-100px) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translateY(-120px) scale(0);
  }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Color Shift Effects */
.letter.color-shift {
  background: linear-gradient(45deg, #ce1126, #d4af37, #ce1126, #f5e9d9);
  background-size: 300% 300%;
  animation: colorWave 4s ease-in-out infinite;
}

@keyframes colorWave {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Enhanced Grid Layout for Narratives */
.container.grid .narrative {
  margin-top: 15px;
  padding: 15px;
  font-size: 0.9rem;
}

.container.grid .story-title {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.container.grid .story-text {
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════
   MOBILE FULL-SCREEN SHOWCASE
   ═══════════════════════════════════════════ */

/* Showcase layout: one card fills the viewport */
.container.showcase {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  /* Use dvh so the showcase fills only the visible viewport,
     not the area hidden behind the mobile browser chrome */
  height: 100dvh;
  margin: 0;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  /* Prevent the pull-to-refresh / bounce from interfering with swipe */
  overscroll-behavior: none;
  /* Allow vertical browser scrolling but let JS handle horizontal swipes */
  touch-action: pan-y;
}

.container.showcase .letter {
  position: absolute;
  width: 85vw;
  height: auto;
  min-height: 75vh;
  max-width: 500px;
  margin: 0;
  padding: 30px 24px 36px;
  border-radius: 28px;
  font-size: 5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  /* Preserve the letter's background gradient */
  background: inherit;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(206, 17, 38, 0.15);
  backdrop-filter: blur(20px);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  overflow: visible;
}

.container.showcase .letter.showcase-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

.container.showcase .braille {
  font-size: 2rem;
  margin-top: 4px;
  margin-left: 0;
  display: block;
}

.container.showcase .word {
  display: block !important;
  position: relative !important;
  opacity: 1;
  transform: none;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 20px;
  text-align: center;
  pointer-events: auto;
  letter-spacing: 1px;
}

.container.showcase .arabic {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 8px;
  display: block;
  opacity: 0.9;
}

.container.showcase .narrative {
  display: block;
  position: relative !important;
  opacity: 1;
  transform: none;
  margin-top: 18px;
  padding: 18px 16px;
  pointer-events: auto;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.08));
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.container.showcase .story-title {
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.container.showcase .story-text {
  font-size: 1rem;
  line-height: 1.6;
  text-align: center;
}

.container.showcase .kingdom,
.container.showcase .bahrain {
  display: none !important;
}

/* Showcase card indicators (dots) */
.showcase-dots {
  position: fixed;
  /* Respect iPhone home indicator / notch safe area */
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 10px;
  z-index: 1001;
  align-items: center;
}

.showcase-dots.visible {
  display: flex;
}

.showcase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(245, 233, 217, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.showcase-dot.active {
  width: 24px;
  border-radius: 6px;
  background: #ce1126;
  box-shadow: 0 0 12px rgba(206, 17, 38, 0.5);
}

/* Showcase swipe hint */
.swipe-hint {
  position: fixed;
  bottom: calc(54px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(245, 233, 217, 0.35);
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  z-index: 1001;
  display: none;
  animation: swipeHintPulse 2.5s ease-in-out infinite;
}

.swipe-hint.visible {
  display: block;
}

@keyframes swipeHintPulse {
  0%, 100% { opacity: 0.35; transform: translateX(-50%) translateY(0); }
  50% { opacity: 0.6; transform: translateX(-50%) translateY(-3px); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE DESIGN — TABLETS (max 768px)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  body {
    /* Prevent elastic overscroll from interfering with swipe gestures */
    overscroll-behavior: none;
  }

  .narrative {
    padding: 15px;
    margin-top: 15px;
  }

  .story-title {
    font-size: 1.3rem;
  }

  .story-text {
    font-size: 1rem;
  }

  .container {
    width: 95vw;
    margin: 3vh auto 0 auto;
    min-height: 50vh;
  }

  .letter {
    width: 80px;
    height: 80px;
    font-size: 3rem;
    margin: 6px;
    border-radius: 16px;
  }

  .braille {
    font-size: 1.5rem;
  }

  .container.grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: 10px;
  }

  .container.grid .letter {
    padding: 12px 8px;
    min-height: auto;
  }

  .container.grid .narrative {
    padding: 10px;
    margin-top: 8px;
  }

  .container.grid .story-title {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .container.grid .story-text {
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .kingdom {
    font-size: 2rem;
    padding: 8px 16px;
  }

  .bahrain {
    font-size: 4rem;
    padding: 8px 20px;
  }

  .flag-credit {
    font-size: 1rem;
    bottom: 10px;
    right: 10px;
    padding: 3px 8px;
  }
}

/* ═══════════════════════════════════════════
   RESPONSIVE DESIGN — PHONES (max 480px)
   Full-screen showcase mode
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
  body {
    overflow: hidden;
    height: 100dvh;
    /* Prevent pull-to-refresh from fighting showcase swipes */
    overscroll-behavior: none;
  }

  .container {
    width: 100vw;
    margin: 2vh auto 0 auto;
  }

  .letter {
    width: 64px;
    height: 64px;
    font-size: 2.5rem;
    margin: 4px;
    border-radius: 14px;
  }

  .braille {
    font-size: 1.2rem;
    margin-left: 0.15rem;
  }

  .container.final .letter,
  .container.plain .letter,
  .container.columns .letter,
  .container.rows .letter {
    width: 56px;
    height: 56px;
    font-size: 2.2rem;
  }

  .container.grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: 6px;
  }

  .container.grid .letter {
    font-size: 2rem;
    padding: 10px 6px;
    min-height: 100px;
  }

  .container.grid .word {
    font-size: 0.8rem;
  }

  .container.grid .narrative {
    padding: 8px;
    margin-top: 6px;
  }

  .container.grid .story-title {
    font-size: 0.85rem;
    margin-bottom: 3px;
  }

  .container.grid .story-text {
    font-size: 0.72rem;
    line-height: 1.3;
  }

  /* Showcase fullscreen card overrides for small phones */
  .container.showcase .letter {
    width: 88vw;
    min-height: 70vh;
    padding: 24px 18px 30px;
    border-radius: 24px;
    font-size: 4.5rem;
  }

  .container.showcase .word {
    font-size: 1.5rem;
  }

  .container.showcase .arabic {
    font-size: 1.7rem;
  }

  .container.showcase .story-title {
    font-size: 1.2rem;
  }

  .container.showcase .story-text {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .kingdom {
    font-size: 1.6rem;
    padding: 6px 12px;
    bottom: 65%;
  }

  .bahrain {
    font-size: 3rem;
    padding: 6px 14px;
    top: 55%;
  }

  .flag-credit {
    font-size: 0.85rem;
    bottom: 6px;
    right: 6px;
    padding: 2px 6px;
  }
}

/* ═══════════════════════════════════════════
   SOLO LETTER REVEAL (one-by-one after grid)
   ═══════════════════════════════════════════ */
.container.solo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  flex-wrap: nowrap;
}

.container.solo .letter {
  position: absolute;
  width: 160px;
  height: 160px;
  font-size: 6rem;
  margin: 0;
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(206, 17, 38, 0.15);
  backdrop-filter: blur(20px);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  opacity: 0;
  pointer-events: none;
}

.container.solo .letter.solo-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

.container.solo .word {
  display: block !important;
  position: absolute !important;
  top: calc(50% + 110px);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  pointer-events: auto;
  letter-spacing: 1px;
  min-width: 280px;
  z-index: 20;
}

.container.solo .arabic {
  font-size: 2.2rem;
  font-weight: 700;
  margin-top: 10px;
  display: block;
}

.container.solo .narrative {
  display: block !important;
  position: absolute !important;
  top: calc(50% + 200px);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  margin-top: 0;
  padding: 22px 28px;
  pointer-events: auto;
  max-width: 480px;
  width: 80vw;
  text-align: center;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.1));
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 20;
}

.container.solo .story-title {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.container.solo .story-text {
  font-size: 1.05rem;
  line-height: 1.7;
  text-align: center;
}

.container.solo .kingdom,
.container.solo .bahrain {
  display: none !important;
}

/* ═══════════════════════════════════════════
   PLAY / PAUSE BUTTON
   ═══════════════════════════════════════════ */
.play-pause-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(206, 17, 38, 0.4);
  background: rgba(15, 15, 35, 0.8);
  color: rgba(245, 233, 217, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
  padding: 0;
}

.play-pause-btn:hover {
  transform: translateX(-50%) scale(1.15);
  border-color: rgba(206, 17, 38, 0.7);
  box-shadow: 0 4px 20px rgba(206, 17, 38, 0.25);
  color: #f5e9d9;
}

.play-pause-btn.paused {
  border-color: rgba(206, 17, 38, 0.6);
  background: rgba(206, 17, 38, 0.15);
}

/* Final Reveal Sequence Styles */
.final-reveal-active {
  animation: finalDramaticReveal 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes finalDramaticReveal {
  0% {
    opacity: 0;
    transform: scale(0.5) rotateY(-180deg) translateZ(-300px);
    filter: blur(20px) brightness(0.3);
  }
  25% {
    opacity: 0.3;
    transform: scale(0.8) rotateY(-90deg) translateZ(-150px);
    filter: blur(10px) brightness(0.6);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.3) rotateY(30deg) translateZ(100px);
    filter: blur(3px) brightness(1.2);
  }
  75% {
    opacity: 0.9;
    transform: scale(0.9) rotateY(-10deg) translateZ(20px);
    filter: blur(1px) brightness(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotateY(0deg) translateZ(0px);
    filter: blur(0px) brightness(1);
  }
}

/* Compositing hints — scoped to animated elements only to avoid
   creating excessive GPU layers on mobile */
.letter,
.word,
.narrative,
.kingdom,
.bahrain {
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.letter {
  /* Prevent any layout shift from content */
  contain: layout style paint;
  /* Remove any implicit transition that fights FLIP */
  transition: none !important;
}

.word,
.narrative,
.kingdom,
.bahrain {
  transition: none !important;
  /* let GSAP/FLIP own everything */
}

/* Make sure words & narratives don't affect FLIP bounding box */
.word,
.narrative {
  position: absolute;
  pointer-events: none;
  /* prevent interaction interference */
}

/* .grid should not fight FLIP */
.container.grid {
  display: grid;
  place-items: center;
  position: fixed;
  top: 0;
  left: 0;
}

/* ═══════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════ */
.search-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(15, 15, 35, 0.85);
  border: 1.5px solid rgba(206, 17, 38, 0.35);
  border-radius: 40px;
  padding: 6px 14px;
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(206, 17, 38, 0.08);
  max-width: 420px;
  width: auto;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}

.search-container.active {
  width: 400px;
  border-color: rgba(206, 17, 38, 0.6);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 80px rgba(206, 17, 38, 0.15);
}

.search-icon {
  color: rgba(206, 17, 38, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
}

.search-icon:hover {
  background: rgba(206, 17, 38, 0.15);
  color: #ff4757;
  transform: scale(1.1);
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: #f5e9d9;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  width: 0;
  padding: 0;
  opacity: 0;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              padding 0.3s ease;
}

.search-container.active .search-input {
  width: 280px;
  opacity: 1;
  padding: 8px 12px;
}

.search-input::placeholder {
  color: rgba(245, 233, 217, 0.4);
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: rgba(15, 15, 35, 0.95);
  border: 1px solid rgba(206, 17, 38, 0.3);
  border-radius: 16px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  backdrop-filter: blur(20px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.3s ease,
              opacity 0.3s ease;
  opacity: 0;
}

.search-results.visible {
  max-height: 320px;
  padding: 10px;
  opacity: 1;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.2s ease;
  color: #f5e9d9;
}

.search-result-item:hover {
  background: rgba(206, 17, 38, 0.15);
  transform: translateX(4px);
}

.search-result-letter {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ce1126;
  min-width: 32px;
  text-align: center;
}

.search-result-text {
  font-size: 0.85rem;
  line-height: 1.4;
}

.search-result-text .result-word {
  font-weight: 600;
  color: #ff4757;
}

.search-result-text .result-story {
  color: rgba(245, 233, 217, 0.6);
  font-size: 0.78rem;
}

.search-highlight {
  background: rgba(206, 17, 38, 0.3);
  color: #ff4757;
  border-radius: 3px;
  padding: 0 2px;
}

/* Letter highlight when search matches */
.letter.search-match {
  z-index: 20;
  box-shadow: 0 0 30px rgba(206, 17, 38, 0.6), 0 0 60px rgba(206, 17, 38, 0.3) !important;
}

.letter.search-dimmed {
  opacity: 0.3 !important;
  filter: grayscale(0.5) !important;
}

/* ═══════════════════════════════════════════
   VOICE CONTROLS
   ═══════════════════════════════════════════ */
.voice-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(30px + env(safe-area-inset-left, 0px));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(206, 17, 38, 0.5);
  background: rgba(15, 15, 35, 0.85);
  color: #f5e9d9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(15px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 40px rgba(206, 17, 38, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.voice-btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(206, 17, 38, 0.4), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: voiceSpin 2s linear infinite;
}

.voice-btn.speaking::before {
  opacity: 1;
}

.voice-btn:hover {
  transform: scale(1.1);
  border-color: rgba(206, 17, 38, 0.8);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 50px rgba(206, 17, 38, 0.2);
}

.voice-btn.speaking {
  border-color: #ce1126;
  background: rgba(206, 17, 38, 0.2);
}

@keyframes voiceSpin {
  to { transform: rotate(360deg); }
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.voice-wave.active {
  opacity: 1;
}

.voice-wave span {
  width: 3px;
  height: 4px;
  background: #ce1126;
  border-radius: 3px;
  transition: height 0.15s ease;
}

.voice-wave.active span {
  animation: voiceBar 0.8s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.15s; }

@keyframes voiceBar {
  0%, 100% { height: 4px; }
  50% { height: 22px; }
}

/* ═══════════════════════════════════════════
   ENHANCED ANIMATIONS
   ═══════════════════════════════════════════ */

/* Interactive ripple on click */
.letter .ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  transform: scale(0);
  pointer-events: none;
  z-index: 5;
}

/* Magnetic hover glow trail */
.letter .glow-trail {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(206, 17, 38, 0.25) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.letter:hover .glow-trail {
  opacity: 1;
}

/* Stardust particles on hover */
@keyframes starDust {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0);
  }
}

/* Letter breathing animation when idle */
@keyframes letterBreathe {
  0%, 100% { transform: translateZ(0) scale(1); }
  50% { transform: translateZ(5px) scale(1.02); }
}

/* Smooth text reveal with typing effect for narratives */
@keyframes typeReveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* Aurora borealis effect for grid layout */
@keyframes aurora {
  0% { background-position: 0% 50%; filter: hue-rotate(0deg); }
  50% { background-position: 100% 50%; filter: hue-rotate(30deg); }
  100% { background-position: 0% 50%; filter: hue-rotate(0deg); }
}

.container.grid .letter::before {
  background: linear-gradient(45deg, rgba(206,17,38,0.3), rgba(212,175,55,0.2), rgba(206,17,38,0.3));
  background-size: 200% 200%;
  animation: aurora 6s ease-in-out infinite;
}

/* Floating label animation for kingdom/bahrain text */
@keyframes floatLabel {
  0%, 100% { transform: translateY(0px); }
  33% { transform: translateY(-6px) rotate(0.5deg); }
  66% { transform: translateY(-3px) rotate(-0.5deg); }
}

.container.final .kingdom,
.container.final .bahrain {
  animation: glow 4s ease-in-out infinite alternate, floatLabel 5s ease-in-out infinite;
}

/* Smooth scroll snap for search result focus */
.letter.search-focus {
  animation: searchPulse 1.5s ease-in-out;
}

@keyframes searchPulse {
  0% { box-shadow: 0 0 0 0 rgba(206, 17, 38, 0.6); }
  50% { box-shadow: 0 0 40px 15px rgba(206, 17, 38, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(206, 17, 38, 0); }
}

/* Mobile responsive for search and voice */
@media (max-width: 768px) {
  .search-container {
    top: 10px;
    max-width: 90vw;
    padding: 4px 10px;
  }

  .search-container.active {
    width: 90vw;
  }

  .search-container.active .search-input {
    width: calc(90vw - 80px);
  }

  .voice-container {
    bottom: 14px;
    left: 14px;
  }

  .voice-btn {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 480px) {
  .search-container {
    top: 8px;
    max-width: 92vw;
    padding: 3px 8px;
    border-radius: 30px;
  }

  .search-container.active {
    width: 92vw;
  }

  .search-container.active .search-input {
    width: calc(92vw - 70px);
    font-size: 0.85rem;
  }

  .search-icon {
    width: 30px;
    height: 30px;
  }

  .search-icon svg {
    width: 18px;
    height: 18px;
  }

  .search-results {
    border-radius: 14px;
  }

  .search-results.visible {
    max-height: 50vh;
  }

  .voice-container {
    bottom: 22px;
    left: 12px;
  }

  .voice-btn {
    width: 38px;
    height: 38px;
  }

  .voice-wave span {
    width: 2.5px;
  }

  /* Move dots and hint up when voice is there */
  .showcase-dots {
    bottom: 24px;
  }

  .swipe-hint {
    bottom: 48px;
    font-size: 0.65rem;
  }

  .play-pause-btn {
    bottom: 66px;
    width: 30px;
    height: 30px;
  }

  .play-pause-btn svg {
    width: 12px;
    height: 12px;
  }

  /* Solo mode on small phones */
  .container.solo .letter {
    width: 120px;
    height: 120px;
    font-size: 4.5rem;
  }

  .container.solo .word {
    top: calc(50% + 85px);
    font-size: 1.5rem;
    min-width: 200px;
  }

  .container.solo .narrative {
    top: calc(50% + 160px);
    width: 88vw;
    padding: 16px 14px;
  }

  .container.solo .story-title {
    font-size: 1.2rem;
  }

  .container.solo .story-text {
    font-size: 0.88rem;
    line-height: 1.5;
  }
}

/* ═══════════════════════════════════════════
   ACCESSIBILITY — Reduced Motion
   Disable non-essential animations for users
   who prefer reduced motion (common on mobile
   accessibility settings).
   ═══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  /* Stop all looping CSS animations */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  /* Keep showcase card transitions readable but instant */
  .container.showcase .letter {
    transition: none !important;
  }

  /* Keep the gradient background static */
  body {
    animation: none;
    background-position: 50% 50%;
  }
}