/* ==========================================================================
   ALPHABET SAFARI - Children's Arabic & English Alphabet
   Designed specifically for Toddlers & Preschoolers (Ages 2-5)
   ========================================================================== */

:root {
  /* Cheerful Candy & Pastel Color Palette */
  --bg-gradient: linear-gradient(180deg, #FDE2E4 0%, #E2ECE9 50%, #DFE7FD 100%);
  --sky-top: #E0F2FE;
  --sky-bottom: #FFF7ED;
  
  --coral-red: #FF4757;
  --bubble-pink: #FF6B8B;
  --pastel-pink: #FFCCD5;
  --sunny-orange: #FFA502;
  --lemon-yellow: #FFD32A;
  --butter-cream: #FFF9E6;
  --mint-green: #2ED573;
  --sky-blue: #1E90FF;
  --soft-cyan: #70A1FF;
  --grape-purple: #7158E2;
  --cotton-lavender: #E4D8FF;
  --choc-brown: #574B90;

  --text-dark: #2F3542;
  --text-muted: #57606F;
  --pure-white: #FFFFFF;

  /* Tactile 3D Button Shadows (Squishy Toy Feel) */
  --btn-shadow-blue: 0 6px 0 #0C6AD0, 0 10px 16px rgba(30, 144, 255, 0.35);
  --btn-shadow-pink: 0 6px 0 #D63051, 0 10px 16px rgba(255, 71, 87, 0.35);
  --btn-shadow-green: 0 6px 0 #1B9E51, 0 10px 16px rgba(46, 213, 115, 0.35);
  --btn-shadow-orange: 0 6px 0 #CE7D00, 0 10px 16px rgba(255, 165, 2, 0.35);
  --btn-shadow-purple: 0 6px 0 #4B38A8, 0 10px 16px rgba(113, 88, 226, 0.35);
  --card-shadow: 0 12px 30px rgba(87, 75, 144, 0.12), 0 4px 10px rgba(0, 0, 0, 0.04);
  --active-btn-shift: translateY(4px);

  /* Fonts. 'Safari Emoji' only covers a few newer emoji (see assets/fonts/fonts.css). */
  --font-en: 'Safari Emoji', 'Fredoka', 'Quicksand', -apple-system, sans-serif;
  --font-ar: 'Safari Emoji', 'Baloo 2', 'Amiri', 'Tajawal', sans-serif;
  
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-full: 9999px;
}

/* Base Styles & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: var(--font-en);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-dark);
  font-size: 16px;
  touch-action: manipulation;
}

[dir="rtl"] {
  font-family: var(--font-ar);
}

/* Form controls don't inherit the page font by default, so letter cards fell back to the
   system font (a different letter shape from the spotlight) and skipped the emoji font. */
button, input, select, textarea {
  font-family: inherit;
}

/* Text Visibility helper for dual-language */
[dir="ltr"] .ar-text {
  display: none !important;
}

[dir="rtl"] .eng-text {
  display: none !important;
}

[dir="rtl"] .ar-text {
  display: inline !important;
}

/* Sky Background Animations */
.sky-elements {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: 3.5rem;
  opacity: 0.55;
  filter: drop-shadow(0 6px 12px rgba(255, 255, 255, 0.9));
  animation: floatCloud linear infinite;
}
.cloud-1 { top: 8%; left: -100px; animation-duration: 38s; }
.cloud-2 { top: 22%; left: -120px; animation-duration: 48s; animation-delay: 15s; font-size: 4.5rem; }
.cloud-3 { top: 60%; left: -90px; animation-duration: 32s; animation-delay: 7s; font-size: 3rem; }

@keyframes floatCloud {
  0% { transform: translateX(-150px); }
  100% { transform: translateX(calc(100vw + 200px)); }
}

.balloon-bg {
  position: absolute;
  font-size: 2.8rem;
  opacity: 0.35;
  animation: floatUp ease-in-out infinite alternate;
}
.b1 { top: 18%; left: 8%; animation-duration: 6s; }
.b2 { top: 45%; right: 6%; animation-duration: 7.5s; animation-delay: 2s; }
.b3 { top: 75%; left: 14%; animation-duration: 5s; animation-delay: 1s; }

@keyframes floatUp {
  0% { transform: translateY(0) rotate(-6deg); }
  100% { transform: translateY(-30px) rotate(6deg); }
}

.star-bg {
  position: absolute;
  opacity: 0.4;
  animation: starTwinkle 3s ease-in-out infinite alternate;
}
.s1 { top: 12%; right: 18%; font-size: 2.2rem; }
.s2 { top: 38%; left: 24%; font-size: 1.8rem; animation-delay: 1s; }
.s3 { top: 80%; right: 28%; font-size: 2.5rem; animation-delay: 2s; }

@keyframes starTwinkle {
  0% { transform: scale(0.8) rotate(0deg); opacity: 0.2; }
  100% { transform: scale(1.2) rotate(15deg); opacity: 0.6; }
}

/* App Layout Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 24px 16px;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
/* Wraps rather than overflows: between phone and desktop widths (a phone in landscape, a 10"
   tablet in portrait) or with a long child's name, the three groups don't fit on one row,
   and the Parents button used to end up past the right edge. */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 24px rgba(113, 88, 226, 0.12);
  border: 3px solid rgba(255, 255, 255, 0.8);
  margin-bottom: 12px;
}

.header-left {
  display: flex;
  align-items: center;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-mascot-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--lemon-yellow);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #FF4757, #FFA502, #7158E2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Language Switcher */
.header-center {
  display: flex;
  justify-content: center;
}

.lang-toggle-container {
  display: flex;
  background: var(--cotton-lavender);
  padding: 4px;
  border-radius: var(--radius-full);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--choc-brown);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-btn.active {
  background: var(--pure-white);
  color: var(--grape-purple);
  box-shadow: 0 4px 10px rgba(113, 88, 226, 0.25);
  transform: scale(1.04);
}

.lang-btn:active {
  transform: scale(0.96);
}

.lang-flag {
  font-size: 1.25rem;
}

/* Header Right Action & Rewards */
.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-inline-start: auto;
}

.star-badge-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FFF3BF, #FFE066);
  border: 2px solid #F59F00;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 0 #E67700, 0 6px 12px rgba(245, 159, 0, 0.25);
  transition: transform 0.15s ease;
}

.star-badge-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #E67700;
}

.star-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
}

.star-count-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: #D9480F;
}

.star-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #A61E4D;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--pure-white);
  border: 2px solid #E4E7EB;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 0 #CBD5E1;
  transition: all 0.15s ease;
}

.tool-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #CBD5E1;
}

.tool-btn.android-highlight {
  width: auto;
  padding: 0 12px;
  background: linear-gradient(135deg, #A8E6CF, #3EDBF0);
  border-color: #04AA6D;
  color: #064420;
  box-shadow: 0 4px 0 #028A5E;
}

.tool-btn.android-highlight:active {
  box-shadow: 0 1px 0 #028A5E;
}

/* ==========================================================================
   NAVIGATION TABS (LEARNING MODES)
   ========================================================================== */
.mode-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.mode-nav::-webkit-scrollbar {
  display: none;
}

/* Grow to fill the row but never shrink below the label: a squeezed tab let its icon and
   text spill over the next tab. The row scrolls sideways instead (.mode-nav). */
.mode-tab {
  flex: 1 0 auto;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--pure-white);
  color: var(--text-dark);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: 0 5px 0 #CBD5E1, 0 8px 14px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.mode-tab:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #CBD5E1;
}

.mode-tab.active {
  background: linear-gradient(135deg, #FF6B8B, #FF8E53);
  color: var(--pure-white);
  border-color: #FFCCD5;
  box-shadow: 0 5px 0 #D63051, 0 10px 20px rgba(255, 107, 139, 0.35);
  transform: translateY(-2px);
}

.mode-icon {
  font-size: 1.4rem;
}

/* ==========================================================================
   MASCOT SPEECH BAR
   ========================================================================== */
.mascot-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  border: 2px solid rgba(255, 215, 0, 0.6);
  box-shadow: 0 4px 14px rgba(255, 193, 7, 0.15);
  margin-bottom: 14px;
}

.mascot-mascot {
  cursor: pointer;
  flex-shrink: 0;
}

.mascot-img-sm {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 2px solid var(--sunny-orange);
  object-fit: cover;
}

.mascot-bubble {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--choc-brown);
}

.bubble-speaker-btn {
  background: var(--lemon-yellow);
  border: 2px solid #F59F00;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #E67700;
  flex-shrink: 0;
}

.bubble-speaker-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #E67700;
}

/* ==========================================================================
   MAIN CONTENT VIEWS
   ========================================================================== */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.app-view {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s ease-out;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   MODE 1: EXPLORE ALPHABET (SPOTLIGHT CARD & GRID)
   ========================================================================== */
.spotlight-card-wrapper {
  margin-bottom: 20px;
}

.spotlight-card {
  background: var(--pure-white);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--card-shadow);
  border: 4px solid #FFE3E3;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.spotlight-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(90deg, #FF6B8B, #FFA502, #2ED573, #1E90FF, #7158E2);
}

.spotlight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spotlight-index {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #F1F2F6;
  padding: 4px 14px;
  border-radius: var(--radius-full);
}

.spotlight-tags {
  display: flex;
  gap: 8px;
}

.phonics-pill, .translit-pill {
  font-size: 1rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.phonics-pill {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
}

.translit-pill {
  background: #E3F2FD;
  color: #1565C0;
  border: 1px solid #90CAF9;
}

.spotlight-body {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 0;
}

/* Big Letter Box */
.spotlight-letter-box {
  flex: 1;
  min-width: 220px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(135deg, #FFF0F5, #FFE4E6);
  border-radius: var(--radius-xl);
  border: 4px dashed var(--bubble-pink);
  cursor: pointer;
  box-shadow: inset 0 4px 12px rgba(255, 107, 139, 0.15);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.spotlight-letter-box:hover {
  transform: scale(1.03);
}

.spotlight-letter-box:active {
  transform: scale(0.96);
}

.spotlight-big-letter {
  font-size: 6.5rem;
  font-weight: 800;
  color: var(--coral-red);
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(255, 71, 87, 0.3));
}

[dir="rtl"] .spotlight-big-letter {
  font-family: var(--font-ar);
  font-size: 8rem;
}

.sound-wave-icon {
  position: absolute;
  bottom: 12px;
  right: 14px;
  font-size: 1.4rem;
  opacity: 0.8;
  animation: pulseWave 1.5s infinite alternate;
}

/* Arabic Harakat Vowel Bar */
.arabic-vowels-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: #FFF9E6;
  border-radius: var(--radius-lg);
  border: 2px dashed #FFD166;
}

.vowel-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #D97706;
}

.vowel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--pure-white);
  border: 2px solid #F59E0B;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 #D97706;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vowel-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #D97706;
}

.vowel-char {
  font-size: 2.2rem;
  font-weight: 800;
  color: #B45309;
  line-height: 1.1;
}

.vowel-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #92400E;
}

/* Big Object & Illustration Box */
.spotlight-object-box {
  flex: 1;
  min-width: 220px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #E0F7FA, #E1F5FE);
  border-radius: var(--radius-xl);
  border: 4px solid #81D4FA;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(129, 212, 250, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.spotlight-object-box:hover {
  transform: scale(1.03);
}

.spotlight-object-box:active {
  transform: scale(0.96);
}

.spotlight-illustration {
  font-size: 5.5rem;
  line-height: 1;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.12));
}

.spotlight-word-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
}

.spotlight-word {
  font-size: 2rem;
  font-weight: 800;
  color: #0277BD;
}

.spotlight-word-meaning {
  font-size: 0.95rem;
  font-weight: 600;
  color: #00838F;
}

/* Spotlight Card Controls */
.spotlight-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.nav-arrow-btn {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: var(--lemon-yellow);
  color: #B45309;
  border: 3px solid #F59E0B;
  font-size: 1.8rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 #D97706, 0 8px 16px rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.nav-arrow-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #D97706;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:active {
  transform: var(--active-btn-shift);
}

.play-btn {
  background: linear-gradient(135deg, #2ED573, #10AC84);
  color: var(--pure-white);
  box-shadow: var(--btn-shadow-green);
}

.play-btn:active {
  box-shadow: 0 2px 0 #1B9E51;
}

.trace-jump-btn {
  background: linear-gradient(135deg, #1E90FF, #3742FA);
  color: var(--pure-white);
  box-shadow: var(--btn-shadow-blue);
}

.trace-jump-btn:active {
  box-shadow: 0 2px 0 #0C6AD0;
}

.jukebox-btn {
  background: linear-gradient(135deg, #FFA502, #FF7F50);
  color: var(--pure-white);
  box-shadow: var(--btn-shadow-orange);
}

.jukebox-btn:active {
  box-shadow: 0 2px 0 #CE7D00;
}

/* ==========================================================================
   ALPHABET GRID
   ========================================================================== */
.alphabet-grid-section {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 3px solid rgba(255, 255, 255, 0.8);
}

.grid-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.grid-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--choc-brown);
}

.grid-tool-btn {
  background: #EDE9FE;
  color: var(--grape-purple);
  border: 2px solid #C4B5FD;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 3px 0 #A78BFA;
}

.grid-tool-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #A78BFA;
}

.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px;
}

.grid-letter-card {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--pure-white);
  border-radius: var(--radius-lg);
  border: 3px solid #E2E8F0;
  cursor: pointer;
  box-shadow: 0 5px 0 #CBD5E1, 0 8px 12px rgba(0,0,0,0.04);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.grid-letter-card:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 8px 0 #CBD5E1, 0 14px 18px rgba(0,0,0,0.08);
}

.grid-letter-card:active {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 2px 0 #CBD5E1;
}

.grid-letter-card.active {
  border-color: var(--coral-red);
  background: #FFF5F5;
  box-shadow: 0 5px 0 #FF8787, 0 8px 16px rgba(255, 71, 87, 0.25);
  transform: scale(1.05);
}

.grid-char {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

[dir="rtl"] .grid-char {
  font-family: var(--font-ar);
  font-size: 2.6rem;
}

.grid-emoji {
  font-size: 1.1rem;
  margin-top: 4px;
}

/* ==========================================================================
   MODE 2: MAGIC TRACING CANVAS
   ========================================================================== */
.trace-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  border: 4px solid #C7D2FE;
}

.trace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.trace-letter-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--choc-brown);
}

.trace-current-char {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--coral-red);
}

.trace-brush-colors {
  display: flex;
  gap: 8px;
}

.color-dot {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 3px solid var(--pure-white);
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s ease;
}

.color-dot.active {
  transform: scale(1.25);
  border-color: var(--text-dark);
}

.trace-actions {
  display: flex;
  gap: 8px;
}

.btn-sm-fun {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  background: #F1F5F9;
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-full);
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: 0 3px 0 #94A3B8;
  transition: all 0.15s ease;
}

.btn-sm-fun:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #94A3B8;
}

.btn-fun-primary {
  background: linear-gradient(135deg, #10B981, #059669);
  color: var(--pure-white);
  border-color: #047857;
  box-shadow: 0 4px 0 #065F46;
}

.btn-fun-primary:active {
  box-shadow: 0 1px 0 #065F46;
}

/* Canvas Tracing Stack */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 650px;
  height: 440px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 4px dashed #818CF8;
  background: #FAFAFA;
  box-shadow: inset 0 4px 14px rgba(0,0,0,0.06);
  touch-action: none;
}

.trace-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.guide-layer {
  z-index: 1;
}

.user-layer {
  z-index: 2;
  cursor: crosshair;
}

.trace-prompt-overlay {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 18px;
  border-radius: var(--radius-full);
  border: 2px solid #A5B4FC;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4338CA;
  animation: bounceSoft 2s infinite alternate;
}

.prompt-hand-icon {
  font-size: 1.4rem;
}

/* Trace Letter Picker Ribbon */
.trace-letter-ribbon {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px 2px;
  scrollbar-width: thin;
}

.trace-chip {
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--pure-white);
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 3px 0 #94A3B8;
  transition: all 0.15s ease;
}

.trace-chip.active {
  background: var(--coral-red);
  color: var(--pure-white);
  border-color: #B91C1C;
  box-shadow: 0 3px 0 #991B1B;
}

/* ==========================================================================
   MODE 3: POP BALLOONS MINI-GAME
   ========================================================================== */
.balloon-game-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  border: 3px solid #BFDBFE;
}

.target-prompt-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.target-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1E3A8A;
}

.target-big-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #FEF08A, #FDE047);
  border: 3px solid #EAB308;
  padding: 6px 20px;
  border-radius: var(--radius-full);
  font-size: 2.5rem;
  font-weight: 900;
  color: #854D0E;
  box-shadow: 0 5px 0 #CA8A04, 0 8px 16px rgba(234, 179, 8, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.target-big-badge:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #CA8A04;
}

.repeat-sound-chip {
  font-size: 1.2rem;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 3px 0 #CBD5E1;
}

.stat-icon {
  font-size: 1.25rem;
}

.stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: #0F172A;
}

.stat-lbl {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748B;
}

/* Balloon Sky Field */
.balloon-sky {
  position: relative;
  width: 100%;
  height: 480px;
  background: linear-gradient(180deg, #BAE6FD 0%, #E0F2FE 70%, #FEF3C7 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 4px solid #7DD3FC;
  box-shadow: inset 0 6px 20px rgba(0,0,0,0.06);
}

.flying-balloon {
  position: absolute;
  width: 95px;
  height: 125px;
  bottom: -140px;
  z-index: 10;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 900;
  color: var(--pure-white);
  cursor: pointer;
  box-shadow: inset -8px -8px 16px rgba(0,0,0,0.22), 0 10px 18px rgba(0,0,0,0.18);
  user-select: none;
  animation-name: floatUpSky, balloonSway;
  animation-duration: 9s, 2.5s;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
  animation-direction: normal, alternate;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

[dir="rtl"] .flying-balloon {
  font-family: var(--font-ar);
  font-size: 3.4rem;
}

.flying-balloon::after {
  content: "";
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 20px;
  background: rgba(0,0,0,0.3);
  border-radius: 2px;
}

.flying-balloon:active {
  transform: scale(0.9);
}

.flying-balloon.popped {
  transform: scale(1.6) !important;
  opacity: 0 !important;
  pointer-events: none;
}

@keyframes floatUpSky {
  0% {
    translate: 0 0;
  }
  100% {
    translate: 0 -640px;
  }
}

@keyframes balloonSway {
  0% { transform: rotate(-5deg) translateX(-8px); }
  100% { transform: rotate(5deg) translateX(8px); }
}

/* ==========================================================================
   MODE 4: FIND LETTER / PICTURE MATCH
   ========================================================================== */
.match-game-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  border: 4px solid #FED7AA;
}

.match-quest-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
  border: 3px dashed #F97316;
  padding: 20px;
  border-radius: var(--radius-xl);
  box-shadow: inset 0 4px 12px rgba(249, 115, 22, 0.1);
}

.quest-avatar-box {
  position: relative;
}

.quest-illustration {
  font-size: 6.5rem;
  line-height: 1;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.15));
  animation: pulseBouncy 2s infinite alternate;
}

.quest-speaker {
  position: absolute;
  bottom: -4px;
  right: -4px;
}

.quest-text-box {
  display: flex;
  flex-direction: column;
}

.quest-sub {
  font-size: 1.1rem;
  font-weight: 700;
  color: #C2410C;
}

.quest-word {
  font-size: 2.8rem;
  font-weight: 900;
  color: #9A3412;
  line-height: 1.1;
}

.quest-hint {
  font-size: 1.15rem;
  font-weight: 700;
  color: #EA580C;
}

/* Big Touchable Choice Buttons */
.match-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 650px;
  margin: 0 auto;
  width: 100%;
}

.match-choice-btn {
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--pure-white);
  border: 4px solid #CBD5E1;
  border-radius: var(--radius-xl);
  font-size: 3.5rem;
  font-weight: 900;
  color: #1E293B;
  cursor: pointer;
  box-shadow: 0 8px 0 #94A3B8, 0 12px 20px rgba(0,0,0,0.08);
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.match-choice-btn:hover {
  transform: translateY(-4px);
  border-color: #38BDF8;
}

.match-choice-btn:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #94A3B8;
}

.match-choice-btn.correct {
  background: #DCFCE7;
  border-color: #22C55E;
  color: #15803D;
  box-shadow: 0 8px 0 #16A34A;
  animation: popIn 0.3s ease;
}

.match-choice-btn.wrong {
  background: #FEE2E2;
  border-color: #EF4444;
  color: #B91C1C;
  box-shadow: 0 8px 0 #DC2626;
  animation: shakeHoriz 0.4s ease;
}

.match-feedback-bar {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #4338CA;
  min-height: 38px;
}

/* ==========================================================================
   MODE 5: MEMORY CARDS
   ========================================================================== */
.memory-game-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  border: 4px solid #DDD6FE;
}

.memory-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memory-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #5B21B6;
}

.memory-controls {
  display: flex;
  gap: 8px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 14px;
  max-width: 650px;
  margin: 10px auto;
  width: 100%;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 1000px;
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 #CBD5E1, 0 10px 16px rgba(0,0,0,0.06);
}

.memory-card:hover .memory-card-inner {
  transform: translateY(-2px);
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card.flipped:hover .memory-card-inner {
  transform: rotateY(180deg) translateY(-2px);
}

.memory-card.matched .memory-card-inner {
  box-shadow: 0 6px 0 #22C55E, 0 0 16px rgba(34, 197, 94, 0.4);
}

.memory-front, .memory-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.memory-back {
  background: linear-gradient(135deg, #818CF8, #6366F1);
  border: 3px solid #4F46E5;
  color: var(--pure-white);
  font-size: 2.2rem;
}

.memory-front {
  background: var(--pure-white);
  border: 3px solid #E0E7FF;
  transform: rotateY(180deg);
}

.memory-val-letter {
  font-size: 3rem;
  font-weight: 900;
  color: #4F46E5;
}

.memory-val-pic {
  font-size: 3.2rem;
}

/* ==========================================================================
   MODE 6: STICKER PARK
   ========================================================================== */
.stickers-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stickers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  padding: 14px 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  border: 3px solid #FEF08A;
}

.stickers-title-group h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #854D0E;
}

.stickers-title-group p {
  font-size: 0.95rem;
  font-weight: 600;
  color: #A16207;
}

.sticker-tray {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  border: 3px solid #BBF7D0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.sticker-item {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: #F0FDF4;
  border: 2px dashed #4ADE80;
  border-radius: var(--radius-lg);
  cursor: grab;
  box-shadow: 0 4px 0 #22C55E;
  transition: transform 0.15s ease;
  user-select: none;
}

.sticker-item.locked {
  filter: grayscale(1);
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  border-color: #94A3B8;
  position: relative;
}

.sticker-item.locked::after {
  content: "🔒";
  position: absolute;
  font-size: 1rem;
}

.sticker-item:not(.locked):hover {
  transform: scale(1.15) rotate(5deg);
}

.sticker-canvas-playground {
  position: relative;
  width: 100%;
  height: 420px;
  background: linear-gradient(180deg, #BAE6FD 0%, #D9F99D 70%, #86EFAC 100%);
  border-radius: var(--radius-xl);
  border: 4px solid #4ADE80;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: crosshair;
}

.playground-scenery {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scenery-sun {
  position: absolute;
  top: 20px;
  right: 25px;
  font-size: 3.5rem;
  animation: spinWiggle 10s infinite alternate;
}

.scenery-rainbow {
  position: absolute;
  top: 15px;
  left: 20px;
  font-size: 4rem;
  opacity: 0.85;
}

.placed-sticker {
  position: absolute;
  font-size: 3.8rem;
  cursor: grab;
  user-select: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.18));
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   CONFETTI OVERLAY
   ========================================================================== */
.confetti-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================================================
   MODAL WINDOWS & CHILD GATE
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--pure-white);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  border: 4px solid #E0E7FF;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-card-wide {
  max-width: 680px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon-badge {
  font-size: 1.8rem;
}

.modal-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--choc-brown);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #F1F5F9;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Android Install Styles */
.install-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
  border: 2px solid #6EE7B7;
  padding: 14px;
  border-radius: var(--radius-lg);
}

.install-app-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  border: 3px solid #10B981;
}

.install-banner-text h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #065F46;
}

.install-banner-text p {
  font-size: 0.85rem;
  font-weight: 600;
  color: #047857;
}

.install-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.install-option-card {
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  padding: 16px;
  border-radius: var(--radius-lg);
  position: relative;
}

.install-option-card.highlighted-option {
  background: #FFFBEB;
  border-color: #FCD34D;
}

.opt-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  background: #F59E0B;
  color: var(--pure-white);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.install-option-card h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--choc-brown);
  margin-bottom: 6px;
}

.install-option-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.btn-install-now {
  background: linear-gradient(135deg, #10B981, #059669);
  color: var(--pure-white);
  box-shadow: 0 5px 0 #047857;
  width: 100%;
  margin-bottom: 12px;
}

.btn-install-now:active {
  box-shadow: 0 1px 0 #047857;
}

.install-steps-list {
  list-style: none;
  font-size: 0.82rem;
  color: var(--text-dark);
  line-height: 1.6;
}

.code-pill-box {
  background: #1E293B;
  color: #38BDF8;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

/* Parents Child Gate */
.parents-gate-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 10px 0;
}

.gate-icon {
  font-size: 3rem;
}

.gate-buttons {
  display: flex;
  gap: 12px;
}

.gate-btn {
  width: 54px;
  height: 54px;
  font-size: 1.6rem;
  font-weight: 800;
  background: #EEF2FF;
  border: 2px solid #C7D2FE;
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: 0 4px 0 #818CF8;
}

.gate-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #818CF8;
}

/* Settings Rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #F1F5F9;
}

.setting-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--choc-brown);
  display: block;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.setting-select {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 2px solid #CBD5E1;
  font-family: inherit;
  font-weight: 700;
}

.btn-sm-danger {
  background: #FEE2E2;
  color: #B91C1C;
  border: 2px solid #F87171;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
}

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #CBD5E1;
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #10B981;
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Celebration Modal */
.modal-celebrate-card {
  text-align: center;
  align-items: center;
  padding: 30px;
  border-color: #FCD34D;
  background: linear-gradient(180deg, #FFFBEB 0%, #FFFFFF 100%);
}

.celebrate-star-img {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  border: 4px solid var(--lemon-yellow);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.35);
}

.celebrate-title {
  font-size: 2rem;
  font-weight: 900;
  color: #D97706;
}

.celebrate-msg {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
}

.btn-celebrate-ok {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: var(--pure-white);
  box-shadow: 0 6px 0 #B45309;
  padding: 14px 28px;
  font-size: 1.25rem;
}

.modal-dismiss-btn {
  background: #F1F5F9;
  color: var(--text-dark);
  border: 2px solid #CBD5E1;
  box-shadow: 0 4px 0 #94A3B8;
  width: 100%;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
.pulse-anim {
  animation: pulseBouncy 2s infinite alternate;
}

@keyframes pulseBouncy {
  0% { transform: scale(1); }
  100% { transform: scale(1.08) rotate(2deg); }
}

.spin-wiggle {
  animation: spinWiggle 3s infinite ease-in-out;
}

@keyframes spinWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(10deg); }
  75% { transform: rotate(-10deg); }
}

.bouncy {
  animation: bounceSoft 2s infinite alternate;
}

@keyframes bounceSoft {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shakeHoriz {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLETS & PHONES)
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .header-left {
    order: 1;
  }

  /* Full-width, wrapping row: on phones the tool buttons (sound, app, parents) were pushed
     past the right edge and could not be reached at all. */
  .header-right {
    order: 2;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .header-center {
    order: 3;
    width: 100%;
    margin-top: 4px;
  }

  .lang-btn {
    padding: 6px 14px;
    font-size: 0.95rem;
  }

  .brand-title {
    font-size: 1.25rem;
  }

  .spotlight-big-letter {
    font-size: 4.8rem;
  }

  [dir="rtl"] .spotlight-big-letter {
    font-size: 6rem;
  }

  .spotlight-illustration {
    font-size: 4.2rem;
  }

  .spotlight-word {
    font-size: 1.6rem;
  }

  .canvas-wrapper {
    height: 360px;
  }

  .balloon-sky {
    height: 400px;
  }

  .match-options-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .match-choice-btn {
    height: 85px;
    font-size: 2.8rem;
  }

  .quest-illustration {
    font-size: 4.5rem;
  }

  .quest-word {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .brand-subtitle {
    display: none;
  }

  /* The badge title already says boy/girl; give the row room instead. */
  .gender-pill-tag {
    display: none;
  }

  .mode-tab {
    min-width: 95px;
    font-size: 0.9rem;
    padding: 8px 10px;
  }

  .letters-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .grid-letter-card {
    height: 64px;
  }

  .grid-char {
    font-size: 1.8rem;
  }

  .grid-emoji {
    font-size: 0.9rem;
  }
}


/* ==========================================================================
   GENDER CONFIGURATION & INTERACTIVE COMPANION STYLES
   ========================================================================== */

/* Header Gender Badge Button */
.gender-badge-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #38BDF8 0%, #0284C7 100%);
  border: 2px solid #BAE6FD;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 #0369A1, 0 8px 12px rgba(2, 132, 199, 0.35);
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: #FFFFFF;
}

body[data-gender="girl"] .gender-badge-btn {
  background: linear-gradient(135deg, #F472B6 0%, #DB2777 100%);
  border: 2px solid #FBCFE8;
  box-shadow: 0 5px 0 #9D174D, 0 8px 12px rgba(219, 39, 119, 0.35);
}

.gender-badge-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.gender-badge-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0369A1;
}

body[data-gender="girl"] .gender-badge-btn:active {
  box-shadow: 0 2px 0 #9D174D;
}

.gender-avatar-emoji {
  font-size: 22px;
  display: inline-block;
  animation: companion-float 2.5s ease-in-out infinite alternate;
}

.gender-badge-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

[dir="rtl"] .gender-badge-text {
  text-align: right;
}

.gender-title-text {
  font-family: var(--font-en);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.gender-pill-tag {
  background: rgba(255, 255, 255, 0.28);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Companion Avatar in Mascot Bar */
.companion-avatar-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #FFF9E6 0%, #FFEAA7 100%);
  border-radius: 50%;
  border: 3px solid #FFA502;
  box-shadow: 0 4px 10px rgba(255, 165, 2, 0.35);
  cursor: pointer;
}

body[data-gender="boy"] .companion-avatar-wrap {
  background: radial-gradient(circle, #E0F2FE 0%, #BAE6FD 100%);
  border-color: #0284C7;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

body[data-gender="girl"] .companion-avatar-wrap {
  background: radial-gradient(circle, #FDF2F8 0%, #FBCFE8 100%);
  border-color: #DB2777;
  box-shadow: 0 4px 10px rgba(219, 39, 119, 0.35);
}

.companion-emoji {
  font-size: 38px;
  display: block;
  user-select: none;
  animation: companion-jump 2s cubic-bezier(0.28, 0.84, 0.42, 1) infinite;
}

.companion-sparkle {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 16px;
  animation: spin-pulse 2s infinite linear;
}

.companion-meta {
  margin-top: 4px;
}

.companion-tag {
  display: inline-block;
  background: #2F3542;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

body[data-gender="boy"] .companion-tag {
  background: #0369A1;
}

body[data-gender="girl"] .companion-tag {
  background: #9D174D;
}

/* Animations */
@keyframes companion-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-8px) scale(0.96, 1.05); }
  60% { transform: translateY(0) scale(1.04, 0.96); }
  75% { transform: translateY(-3px) scale(0.98, 1.02); }
}

@keyframes companion-float {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-4px) rotate(4deg); }
}

@keyframes spin-pulse {
  0% { transform: scale(0.9) rotate(0deg); opacity: 0.8; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.9) rotate(360deg); opacity: 0.8; }
}

/* ==========================================================================
   GENDER MODAL STYLES
   ========================================================================== */

.modal-card-gender {
  max-width: 580px;
  width: 95%;
  background: #FFFFFF;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(47, 53, 66, 0.25);
  border: 4px solid #FFEAA7;
}

.gender-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-intro-text {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #57606F;
  line-height: 1.4;
}

/* Gender Selection Cards */
.gender-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 520px) {
  .gender-cards-grid {
    grid-template-columns: 1fr;
  }
}

.gender-card-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 14px;
  border-radius: var(--radius-lg);
  border: 3px solid #E2E8F0;
  background: #F8FAFC;
  cursor: pointer;
  box-shadow: 0 6px 0 #CBD5E1;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gender-card-option:hover {
  transform: translateY(-4px);
}

.gender-card-option[data-gender="boy"] {
  border-color: #BAE6FD;
  background: #F0F9FF;
  box-shadow: 0 6px 0 #7DD3FC;
}

.gender-card-option[data-gender="girl"] {
  border-color: #FBCFE8;
  background: #FDF2F8;
  box-shadow: 0 6px 0 #F472B6;
}

.gender-card-option.selected[data-gender="boy"] {
  border-color: #0284C7;
  background: #E0F2FE;
  box-shadow: 0 7px 0 #0369A1, 0 10px 20px rgba(2, 132, 199, 0.25);
}

.gender-card-option.selected[data-gender="girl"] {
  border-color: #DB2777;
  background: #FCE7F3;
  box-shadow: 0 7px 0 #9D174D, 0 10px 20px rgba(219, 39, 119, 0.25);
}

.gender-card-badge {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.gender-card-title {
  font-size: 19px;
  font-weight: 800;
  color: #1E293B;
  margin-bottom: 4px;
}

.gender-card-sub {
  font-size: 12px;
  color: #64748B;
  margin-bottom: 12px;
  line-height: 1.3;
}

.gender-voice-sample {
  margin-top: auto;
}

.btn-voice-preview {
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-voice-preview:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
  transform: scale(1.05);
}

.gender-check-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #94A3B8;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: all 0.2s;
}

[dir="rtl"] .gender-check-icon {
  right: auto;
  left: 10px;
}

.gender-card-option.selected .gender-check-icon {
  opacity: 1;
}

.gender-card-option.selected[data-gender="boy"] .gender-check-icon {
  background: #0284C7;
}

.gender-card-option.selected[data-gender="girl"] .gender-check-icon {
  background: #DB2777;
}

/* Child Name Input Row */
.child-name-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.name-label {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.name-input {
  width: 100%;
  padding: 10px 16px;
  font-size: 16px;
  font-family: var(--font-en);
  font-weight: 600;
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-md);
  outline: none;
  background: #F8FAFC;
  transition: all 0.15s;
}

.name-input:focus {
  border-color: #38BDF8;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

body[data-gender="girl"] .name-input:focus {
  border-color: #F472B6;
  box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.25);
}

/* Avatar Picker Section */
.avatar-picker-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-picker-label {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.avatar-icons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.avatar-choice-btn {
  width: 48px;
  height: 48px;
  font-size: 26px;
  border-radius: 50%;
  border: 3px solid #E2E8F0;
  background: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 4px 0 #CBD5E1;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-choice-btn:hover {
  transform: translateY(-3px) scale(1.08);
}

.avatar-choice-btn.active {
  border-color: #FFA502;
  background: #FFF9E6;
  box-shadow: 0 5px 0 #E18200;
  transform: scale(1.12);
}

/* Save Button */
.btn-save-gender {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 800;
  border-radius: var(--radius-lg);
  cursor: pointer;
}

/* ==========================================================================
   REVIEW CYCLE 2: accessibility, motion, contrast and platform fixes
   ========================================================================== */

/* Closed dialogs must be out of the tab order and the accessibility tree, not just transparent. */
.modal-overlay:not(.open) {
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

/* Letters on light balloons (mint, lemon) were ~1.5:1 contrast; a dark outline keeps them legible. */
.flying-balloon {
  text-shadow:
    -2px -2px 0 rgba(15, 23, 42, 0.55), 2px -2px 0 rgba(15, 23, 42, 0.55),
    -2px 2px 0 rgba(15, 23, 42, 0.55), 2px 2px 0 rgba(15, 23, 42, 0.55),
    0 3px 6px rgba(15, 23, 42, 0.35);
}

/* Toddler-sized touch targets (these were 36-38px). */
.bubble-speaker-btn,
.modal-close-btn {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
}
.color-dot {
  width: 48px;
  height: 48px;
}

/* At 48px, six colours and four buttons no longer fit across a 360px phone: the last colour
   was cut off and "I Did It!" broke onto three lines. Wrap the rows, not the labels. */
.trace-brush-colors,
.trace-actions {
  flex-wrap: wrap;
  justify-content: center;
}
.btn-sm-fun {
  white-space: nowrap;
}

/* In Arabic the row is mirrored, so the arrows must be too, or both point inward. */
[dir="rtl"] .nav-arrow-btn > span {
  display: inline-block;
  transform: scaleX(-1);
}

/* Parent gate: a big, obvious way back out for a child who wandered in. */
.gate-back-btn {
  margin-top: 18px;
  min-height: 56px;
  font-size: 1.15rem;
}
.gate-btn:disabled {
  opacity: 0.4;
}

/* Find Letter: the written hint stays hidden until the child needs help. */
.quest-hint.is-hidden {
  visibility: hidden;
}
.match-choice-btn.eliminated {
  opacity: 0.2;
  pointer-events: none;
}

.privacy-note .setting-desc {
  max-width: none;
}

.privacy-note {
  gap: 12px;
}

.privacy-note .btn-sm-fun {
  flex-shrink: 0;
}

/* privacy.html in a frame, so the dialog and the hosted policy are the same text. */
.privacy-frame {
  width: 100%;
  height: min(65vh, 620px);
  border: 0;
  border-radius: var(--radius-lg);
  background: #FDF2F8;
}

/* Inside the Android and Windows apps there is nothing to install. */
.native-app #btn-android-app {
  display: none !important;
}

/* Blur over a constantly animated background re-renders every frame on low-end Android. */
.platform-android * {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* Focus rings for keyboard, screen-reader and switch-access navigation */
:focus-visible {
  outline: 3px solid #6366F1;
  outline-offset: 3px;
}

.memory-card:focus-visible {
  outline: 4px solid #4F46E5;
  outline-offset: 4px;
}

.flying-balloon:focus-visible {
  outline: 4px solid #F59E0B;
  outline-offset: 4px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
}

.sticker-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.app-brand:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
  border-radius: var(--radius-md);
}

/* Arabic has no upper/lower case, so the Aa toggle did nothing there. */
[dir="rtl"] #btn-case-toggle {
  display: none;
}

/* Toddler-sized touch targets for the game toolbars (these were 41px tall). */
.btn-sm-fun {
  min-height: 48px;
}
.grid-tool-btn {
  min-height: 44px;
}

/* iPhone and iPad: as a home-screen web app (translucent status bar) and in landscape, keep the
   page clear of the notch, the Dynamic Island and the home indicator (viewport-fit=cover).
   Zero everywhere else; the native apps keep their web view inside the safe area already. */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Respect the OS "reduce motion" setting. Balloons keep rising because that is the game. */
@media (prefers-reduced-motion: reduce) {
  *:not(.flying-balloon),
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .flying-balloon {
    animation-name: floatUpSky;
    animation-duration: 14s;
  }
}
