/* ============================================================
   ABC Island — Kids Alphabet Game
   Designed for iPad (1024 x 768 landscape). Big, chunky, candy.
   ============================================================ */

:root {
  /* ── Lingo Kids-quality vibrant palette ── */
  --coral:    #FF6B6B;  --coral-d:   #D94040;
  --sun:      #FFB830;  --sun-d:     #D4920A;
  --lime:     #4CD964;  --lime-d:    #2EAB47;
  --sky:      #38C6F4;  --sky-d:     #1AA5D4;
  --violet:   #A78BFA;  --violet-d:  #7C5FD0;
  --rose:     #FF6FAE;  --rose-d:    #D4437E;
  --teal:     #00C9B1;  --teal-d:    #009B88;
  --orange:   #FF9A3C;  --orange-d:  #D4720A;
  --jade:     #3ECFAE;  --jade-d:    #1F9E83;
  --navy:     #4A70C8;  --navy-d:    #2A50A8;
  --indigo:   #7B6CF6;  --indigo-d:  #5248CC;
  --forest:   #52B85A;  --forest-d:  #2E8E38;
  --purple:   #A78BFA;

  /* Legacy aliases so existing code keeps working */
  --pink:     var(--rose);     --pink-d:    var(--rose-d);
  --blue:     var(--sky);      --blue-d:    var(--sky-d);
  --green:    var(--lime);     --green-d:   var(--lime-d);
  --yellow:   var(--sun);      --yellow-d:  var(--sun-d);

  /* Deep ink (replaces flat dark) */
  --ink: #2D1B6B;
  --white: #ffffff;

  /* Character signature colors */
  --pip:    #38C6F4;   /* Captain Pip — Penguin   */
  --goldie: #FFB830;   /* Queen Goldie — Duck      */
  --ziggy:  #4CD964;   /* Ziggy — Squirrel         */
  --kenji:  #A78BFA;   /* Kenji — Shiba Inu        */
  --coco:   #FF6B6B;   /* Coco — Crocodile         */

  /* Typography */
  --font-display: 'Fredoka One', 'Baloo 2', system-ui, sans-serif;
  --font-fun:     'Baloo 2', 'Fredoka One', system-ui, sans-serif;

  /* Fluid type scale */
  --text-hero:   clamp(46px, 9vw, 100px);
  --text-title:  clamp(22px, 3.6vw, 42px);
  --text-btn:    clamp(13px, 1.7vw, 21px);
  --text-label:  clamp(11px, 1.35vw, 16px);
  --text-number: clamp(44px, 8.5vw, 96px);

  /* Shadows */
  --card-shadow:  0 10px 0 rgba(45,27,107,0.14), 0 20px 36px rgba(45,27,107,0.16);
  --btn-shadow:   0 8px 0 rgba(0,0,0,0.20);
  --shadow-sm:    0 4px 0 rgba(0,0,0,0.14);

  /* Radii */
  --radius-xl: 40px;
  --radius-lg: 32px;
  --radius-md: 24px;
  --radius-sm: 16px;

  /* Animation */
  --ease-pop:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:  150ms;
  --dur-mid:   300ms;

  /* Sky gradient colours (home screen) */
  --sky-top: #7ecef5;
  --sky-bot: #c8eeff;
  --sand:    #ffe9b3;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: var(--font-fun);
  color: var(--ink);
  /* Rich 4-layer Lingo Kids-quality background */
  background:
    radial-gradient(ellipse at 12% 8%,  #ffc8e8 0%, transparent 38%),
    radial-gradient(ellipse at 88% 6%,  #bbe8ff 0%, transparent 42%),
    radial-gradient(ellipse at 50% 95%, #d4c2ff 0%, transparent 40%),
    linear-gradient(160deg, #ffe4f4 0%, #e8f6ff 45%, #f0e8ff 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Reduced motion override */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------- iPad stage: locks the playfield to a 4:3 landscape frame ------- */
.stage {
  position: relative;
  width: min(100vw, 133.33vh);   /* 4:3 ratio cap */
  height: min(75vw, 100vh);
  margin: auto;
  inset: 0;
  position: absolute;
}

.screen-wrap {
  position: absolute;
  inset: 0;
  border-radius: 0;
  overflow: hidden;
}

/* ------- Screens / navigation ------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  animation: screen-in 0.4s var(--ease-pop) both;
}
.screen.active { display: flex; }

@keyframes screen-in {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   HOME
   ============================================================ */
.home {
  background:
    radial-gradient(ellipse at 22% 0%, rgba(255,222,60,.60) 0%, transparent 26%),
    radial-gradient(ellipse at 80% 5%, rgba(100,215,255,.55) 0%, transparent 30%),
    radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.18) 0%, transparent 22%),
    linear-gradient(180deg,
      #0a5ca8 0%,
      #1878cc 8%,
      #3aa0ec 20%,
      #62bcf8 34%,
      #96d8ff 46%,
      #c0eaff 50%,
      #5ec256 50.2%,     /* lush tropical tree-line */
      #3ea848 60%,
      #28883a 70%,
      #c89848 80%,       /* warm sand */
      #e8c878 90%,
      #f5e098 100%);
  align-items: center;
  justify-content: center;
  text-align: center;
}
.home-inner { position: relative; z-index: 2; padding: 2vh 4vw; }

.mascot {
  font-size: clamp(60px, 11vw, 130px);
  filter: drop-shadow(0 10px 12px rgba(0,0,0,0.18));
  line-height: 1;
}
.bounce { animation: bounce 2.2s var(--ease-pop) infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-18px) rotate(2deg); }
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(44px, 9.5vw, 108px);
  line-height: 0.9;
  letter-spacing: 2px;
  margin-top: -4px;
  text-shadow: 0 6px 0 rgba(0,0,0,0.14), 0 12px 24px rgba(45,27,107,0.16);
}
.logo-line { display: inline-block; color: var(--white); -webkit-text-stroke: 3px rgba(255,107,174,0.8); paint-order: stroke fill; }
.logo-line.accent {
  color: var(--sun);
  -webkit-text-stroke: 3px var(--sun-d);
  paint-order: stroke fill;
}

.tagline {
  font-size: clamp(16px, 2.4vw, 26px);
  color: var(--ink);
  background: rgba(255,255,255,0.7);
  display: inline-block;
  padding: 6px 18px;
  border-radius: 999px;
  margin-top: 10px;
  font-weight: 600;
}

.menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 22px);
  margin-top: clamp(18px, 3.5vh, 36px);
}

.big-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: clamp(14px, 2.4vh, 26px) clamp(18px, 3vw, 34px);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(18px, 2.6vw, 30px);
  font-weight: 800;
  box-shadow: var(--card-shadow);
  transition: transform 0.12s var(--ease-pop), box-shadow 0.12s;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.big-btn:active { transform: translateY(8px) scale(0.97); box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.big-btn-emoji { font-size: 1.5em; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2)); }
.b-pink   { background: linear-gradient(180deg, #ff8cc2, var(--pink)); border-bottom: 8px solid var(--pink-d); }
.b-blue   { background: linear-gradient(180deg, #79c2ff, var(--blue)); border-bottom: 8px solid var(--blue-d); }
.b-green  { background: linear-gradient(180deg, #88e695, var(--green)); border-bottom: 8px solid var(--green-d); }
.b-yellow { background: linear-gradient(180deg, #ffe07a, var(--yellow)); border-bottom: 8px solid var(--yellow-d); color: #8a5a00; text-shadow: none; }

/* clouds */
.clouds { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.cloud { position: absolute; font-size: clamp(40px, 8vw, 90px); opacity: 0.95; }
.c1 { top: 8%;  left: -12%; animation: drift 26s linear infinite; }
.c2 { top: 20%; left: -30%; animation: drift 38s linear infinite; font-size: 60px; }
.c3 { top: 4%;  left: -55%; animation: drift 32s linear infinite; }
@keyframes drift { to { transform: translateX(180vw); } }

.sound-toggle {
  position: absolute; top: 16px; right: 16px; z-index: 5;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.85);
  font-size: 26px; cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
}
.sound-toggle:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.sound-toggle.off { opacity: 0.55; }

/* ============================================================
   Shared top bar — premium frosted glass
   ============================================================ */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 4px 24px rgba(45,27,107,0.10);
  z-index: 3;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 60px;
}
.back-btn {
  border: none; cursor: pointer; font-family: inherit;
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f0f0ff);
  font-size: 22px;
  box-shadow: 0 5px 0 rgba(45,27,107,0.16), 0 8px 16px rgba(45,27,107,0.10);
  flex-shrink: 0;
}
.back-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(45,27,107,0.16); }
.bar-title {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.6vw, 30px);
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.bar-spacer { flex: 1 1 auto; min-width: 4px; }
.score-pill {
  background: linear-gradient(180deg, #ffe07a, var(--sun));
  color: #7a4a00;
  font-weight: 900;
  font-size: clamp(15px, 2.2vw, 22px);
  padding: 6px 16px;
  border-radius: 999px;
  border-bottom: 5px solid var(--sun-d);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============================================================
   LEARN
   ============================================================ */
.learn { background: linear-gradient(180deg, #fff4fb, #e7f6ff); }
.learn-body {
  flex: 1; display: flex; gap: clamp(12px, 2vw, 26px);
  padding: clamp(12px, 2.2vw, 26px); overflow: hidden;
  min-height: 0;
}

.feature-card {
  flex: 0 0 34%;
  min-width: 0;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(14px, 2.5vh, 28px);
  position: relative;
  border: 6px solid #fff;
  background-image: linear-gradient(180deg, #ffffff, #fff7fc);
}
.feature-letter {
  font-size: clamp(90px, 18vh, 200px);
  font-weight: 900; line-height: 0.9;
  color: var(--pink);
  -webkit-text-stroke: 5px var(--pink-d); paint-order: stroke fill;
  text-shadow: 0 8px 0 rgba(224,66,127,0.18);
}
.feature-pic { font-size: clamp(50px, 9vh, 96px); margin: 6px 0; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.15)); }
.feature-word { font-size: clamp(24px, 4vh, 46px); font-weight: 800; color: var(--ink); }
.feature-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.round-btn {
  border: none; cursor: pointer; font-family: inherit;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 22px;
  box-shadow: 0 6px 0 var(--blue-d);
}
.round-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--blue-d); }
.say-btn {
  border: none; cursor: pointer; font-family: inherit;
  background: linear-gradient(180deg, #88e695, var(--green));
  color: #fff; font-weight: 800; font-size: clamp(16px, 2.4vw, 24px);
  padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 7px 0 var(--green-d);
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.say-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-d); }

.alpha-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(6px, 1vw, 12px);
  overflow-y: auto;
  padding: 4px;
  align-content: center;
  justify-content: stretch;
}
.alpha-cell {
  border: none; cursor: pointer; font-family: inherit;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  font-size: clamp(20px, 3.4vw, 40px);
  font-weight: 900;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.14);
  transition: transform 0.1s var(--ease-pop);
}
.alpha-cell:active { transform: scale(0.9); }
.alpha-cell.active { outline: 5px solid #fff; transform: translateY(-3px) scale(1.04); }

/* ============================================================
   LETTER HUNT
   ============================================================ */
.hunt { background: linear-gradient(180deg, #e7f9ff, #dff5e6); }
.hunt-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vh, 22px); padding: 2vh 4vw; }
.prompt { font-size: clamp(24px, 4.4vw, 48px); font-weight: 800; text-align: center; }
.prompt .big-target { color: var(--pink); -webkit-text-stroke: 2px var(--pink-d); paint-order: stroke fill; }
.hear-again, .hear-mini {
  border: none; cursor: pointer; font-family: inherit;
  background: var(--white); font-weight: 800;
  font-size: clamp(15px, 2.2vw, 22px);
  padding: 10px 20px; border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12); color: var(--ink);
}
.hear-again:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 2vw, 22px);
  width: 100%; max-width: 760px;
}
.choice {
  border: none; cursor: pointer; font-family: inherit;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  font-size: clamp(40px, 8vw, 88px);
  font-weight: 900; color: #fff;
  box-shadow: 0 8px 0 rgba(0,0,0,0.16);
  transition: transform 0.12s var(--ease-pop);
}
.choice:active { transform: scale(0.92); }
.choice.correct { animation: pop-correct 0.5s var(--ease-pop); }
.choice.wrong   { animation: shake 0.4s; }
@keyframes pop-correct { 0%{transform:scale(1);} 50%{transform:scale(1.18);} 100%{transform:scale(1);} }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-10px);} 75%{transform:translateX(10px);} }

/* ============================================================
   POP THE LETTER
   ============================================================ */
.pop { background: linear-gradient(180deg, #d9f0ff, #ffe6f5); }
.pop-target {
  text-align: center; font-size: clamp(18px, 3vw, 30px); font-weight: 800;
  padding: 10px; z-index: 2;
}
.pop-target-letter {
  display: inline-block; color: var(--purple);
  font-size: 1.4em; -webkit-text-stroke: 2px #7a55d6; paint-order: stroke fill;
}
.hear-mini { padding: 4px 12px; font-size: 18px; box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.pop-field { position: relative; flex: 1; overflow: hidden; }
.bubble {
  position: absolute;
  width: clamp(56px, 9vw, 92px); height: clamp(56px, 9vw, 92px);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(26px, 4.6vw, 46px); font-weight: 900; color: #fff;
  cursor: pointer;
  box-shadow: inset 0 -8px 12px rgba(0,0,0,0.18), 0 6px 12px rgba(0,0,0,0.15);
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.bubble::after {
  content: ""; position: absolute; top: 14%; left: 20%;
  width: 26%; height: 26%; border-radius: 50%;
  background: rgba(255,255,255,0.7);
}
.bubble.burst { animation: burst 0.3s forwards; }
@keyframes burst { to { transform: scale(1.6); opacity: 0; } }

/* ============================================================
   ABC SONG
   ============================================================ */
.song { background: linear-gradient(180deg, #fff0d6, #ffe1ef); }
.song-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 2vh 4vw; }
.song-parade {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: clamp(4px, 0.8vw, 10px);
  width: 100%; max-width: 900px;
}
.song-letter {
  aspect-ratio: 1;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(16px, 2.6vw, 30px); font-weight: 900; color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,0.14);
  transition: transform 0.2s var(--ease-pop), filter 0.2s;
  filter: saturate(0.6) brightness(0.92);
}
.song-letter.lit { transform: translateY(-10px) scale(1.18); filter: saturate(1.3) brightness(1.1); outline: 4px solid #fff; z-index: 2; }
.big-sing { font-size: clamp(20px, 3.4vw, 34px); padding: 16px 34px; }
.song-hint { font-weight: 700; opacity: 0.8; }

/* ============================================================
   FX / Rewards
   ============================================================ */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetti {
  position: absolute; width: 14px; height: 14px; top: -20px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(120%) rotate(720deg); opacity: 0.9; }
}

.reward-pop {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
}
.reward-pop.show { animation: reward 1.1s var(--ease-pop); }
.reward-inner { text-align: center; }
.reward-emoji { font-size: clamp(80px, 16vw, 180px); filter: drop-shadow(0 8px 10px rgba(0,0,0,0.25)); }
.reward-text {
  font-size: clamp(28px, 5vw, 56px); font-weight: 900; color: #fff;
  -webkit-text-stroke: 3px var(--pink-d); paint-order: stroke fill;
}
@keyframes reward {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.1); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* Rotate hint only shows on portrait phones */
.rotate-hint {
  position: fixed; bottom: 10px; left: 0; right: 0; text-align: center;
  font-weight: 700; color: var(--ink); display: none; z-index: 50;
  background: rgba(255,255,255,0.8); padding: 8px; font-size: 15px;
}
@media (max-aspect-ratio: 1/1) {
  .rotate-hint { display: block; }
}


/* ============================================================
   ============  v2: Xin Lin upgrade additions  ==============
   ============================================================ */

/* ---- extra button colours ---- */
.b-purple { background: linear-gradient(180deg, #c4a6ff, var(--purple)); border-bottom: 8px solid #7a55d6; }
.b-red    { background: linear-gradient(180deg, #ff8a8a, #ff5a5a); border-bottom: 8px solid #d63a3a; }
.b-teal   { background: linear-gradient(180deg, #6ff0dd, #2fc9b3); border-bottom: 8px solid #1f9e8c; color:#08514a; text-shadow:none; }
.b-orange { background: linear-gradient(180deg, #ffb46b, #ff8c3b); border-bottom: 8px solid #d96a1a; }

/* ============================================================
   HOME (redesigned: top bar + tiles + cartoon friends)
   ============================================================ */
.home { justify-content: flex-start; padding: 0; }
.home-top {
  position: relative; z-index: 4;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 18px; gap: 10px;
}
.hi-chip {
  background: rgba(255,255,255,0.9); border-radius: 999px;
  padding: 8px 18px; font-size: clamp(15px, 2.2vw, 22px); font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,0.10); color: var(--ink);
}
.hi-chip b { color: var(--pink-d); }
.top-tools { display: flex; gap: 10px; }
.tool-btn {
  border: none; cursor: pointer; font-family: inherit;
  min-width: 52px; height: 52px; border-radius: 999px; padding: 0 14px;
  background: rgba(255,255,255,0.92); font-size: 22px; font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.tool-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.12); }
.tool-btn.off { opacity: 0.55; }
#star-count { color: #d99a00; }

.home-inner {
  position: relative; z-index: 3;
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 0 3vw; width: 100%;
}
.fox-wrap { position: relative; display: inline-block; }
.speech-bubble {
  position: absolute; top: -6px; left: 100%;
  background: #fff; border-radius: 18px; padding: 8px 14px;
  font-weight: 800; font-size: clamp(13px, 1.9vw, 19px);
  /* Fix overflow on narrow viewports */
  white-space: nowrap; max-width: 50vw; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 6px 14px rgba(0,0,0,0.15); color: var(--ink);
  transform: translateX(-6px);
}
.speech-bubble::after {
  content: ""; position: absolute; left: -8px; bottom: 14px;
  border: 8px solid transparent; border-right-color: #fff;
}
.mascot { font-size: clamp(54px, 9vw, 96px); }
.logo { font-size: clamp(34px, 7vw, 78px); margin: -2px 0 2px; }

/* ── Lingo Kids-quality icon card grid ── */
.menu {
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(7px, 1.2vw, 14px);
  margin-top: clamp(6px, 1.2vh, 14px);
  width: min(96%, 960px);
}
.big-btn {
  flex-direction: column;
  align-items: center;
  gap: clamp(3px, 0.5vh, 6px);
  text-align: center;
  padding: clamp(10px, 1.8vh, 18px) 6px clamp(8px, 1.4vh, 14px);
  border-radius: var(--radius-lg);
  font-size: var(--text-label);
  font-family: var(--font-fun);
  font-weight: 800;
  /* Deeper 3D shadow for Lingo Kids tactile feel */
  box-shadow:
    0 10px 0 rgba(0,0,0,0.22),
    0 14px 28px rgba(45,27,107,0.18);
  transition: transform 0.12s var(--ease-pop), box-shadow 0.1s;
  will-change: transform;
  letter-spacing: 0.01em;
}
.big-btn:active {
  transform: translateY(8px) scale(0.97);
  box-shadow: 0 2px 0 rgba(0,0,0,0.18), 0 4px 8px rgba(45,27,107,0.12);
}
.big-btn-emoji {
  font-size: clamp(24px, 3.8vw, 42px);
  line-height: 1.1;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.20));
}
.big-btn-text {
  font-size: var(--text-label);
  line-height: 1.2;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0,0,0,0.18);
}

/* cartoon sky + friends */
.sky-deco { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.sun { position: absolute; top: 60px; left: 22px; font-size: clamp(48px, 8vw, 86px); animation: spin 24s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rainbow { position: absolute; top: 40px; right: 30px; font-size: clamp(46px, 8vw, 84px); transform: rotate(-8deg); }
.balloon { position: absolute; font-size: clamp(34px, 6vw, 60px); animation: floaty 6s ease-in-out infinite; }
.bl1 { top: 30%; left: 4%; animation-delay: .4s; }
.bl2 { top: 42%; right: 5%; animation-delay: 1.2s; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-3deg);} 50% { transform: translateY(-18px) rotate(3deg);} }

.friends {
  position: relative; z-index: 3;
  display: flex; justify-content: center; gap: clamp(14px, 4vw, 46px);
  padding-bottom: 10px;
}
.friend { font-size: clamp(34px, 5.5vw, 56px); animation: bob 2.4s ease-in-out infinite; }
.friend.f2 { animation-delay: .2s; } .friend.f3 { animation-delay: .4s; }
.friend.f4 { animation-delay: .6s; } .friend.f5 { animation-delay: .8s; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-12px);} }

/* ============================================================
   LEARN — capital + small letters
   ============================================================ */
.feature-cases { display: flex; align-items: baseline; gap: 10px; line-height: 0.9; }
.case-big {
  font-size: clamp(80px, 16vh, 170px); font-weight: 900; color: var(--pink);
  -webkit-text-stroke: 5px var(--pink-d); paint-order: stroke fill;
}
.case-small {
  font-size: clamp(54px, 11vh, 120px); font-weight: 900; color: var(--blue);
  -webkit-text-stroke: 4px var(--blue-d); paint-order: stroke fill;
}
.alpha-cell { flex-direction: column; gap: 0; line-height: 1; }
.ac-big { font-size: clamp(18px, 3vw, 34px); }
.ac-small { font-size: clamp(13px, 2.1vw, 24px); opacity: 0.92; }

/* ============================================================
   BIG & SMALL match
   ============================================================ */
.match { background: linear-gradient(180deg, #f3e8ff, #e7f6ff); }
.match-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 1.8vh, 18px); padding: 1.5vh 4vw; }
.match-target {
  font-size: clamp(80px, 16vh, 160px); font-weight: 900; line-height: 1;
  -webkit-text-stroke: 4px rgba(0,0,0,0.18); paint-order: stroke fill;
  filter: drop-shadow(0 8px 6px rgba(0,0,0,0.12));
}
.match-choices { grid-template-columns: repeat(3, 1fr); max-width: 580px; }

/* ============================================================
   COUNT 1-10
   ============================================================ */
.numbers { background: linear-gradient(180deg, #e7fff1, #dff0ff); }
.numbers-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vh, 22px); padding: 2vh 4vw; }
.num-big { font-size: clamp(90px, 22vh, 220px); font-weight: 900; line-height: 0.9; -webkit-text-stroke: 5px rgba(0,0,0,0.15); paint-order: stroke fill; }
.num-things { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 80%; min-height: 70px; }
.num-thing { font-size: clamp(30px, 5vw, 52px); animation: pop-in .4s var(--ease-pop) both; }
.num-thing.pop { animation: thing-pop .5s var(--ease-pop); }
@keyframes pop-in { from { transform: scale(0);} to { transform: scale(1);} }
@keyframes thing-pop { 0%{transform:scale(1);} 45%{transform:scale(1.5);} 100%{transform:scale(1);} }
.num-actions { display: flex; align-items: center; gap: 14px; }

/* ============================================================
   珠心算 ABACUS
   ============================================================ */
.abacus { background: linear-gradient(180deg, #fff3e0, #ffe7ef); }
.abacus-readout {
  margin-left: auto; background: #fff; border-radius: 999px; padding: 6px 20px;
  font-size: clamp(18px, 3vw, 28px); font-weight: 800; box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.abacus-readout b { color: var(--pink-d); font-size: 1.2em; }
.abacus-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 1.4vh 2vw 2vh; }

.abacus-frame {
  --bd: clamp(28px, 5vw, 52px);
  display: flex; gap: clamp(10px, 2.5vw, 30px); justify-content: center;
  padding: 18px clamp(18px, 4vw, 40px);
  background: linear-gradient(180deg, #d99a5b, #b9783c);
  border-radius: 26px;
  box-shadow: inset 0 4px 10px rgba(255,255,255,0.35), inset 0 -8px 14px rgba(0,0,0,0.25), 0 14px 26px rgba(80,40,10,0.3);
  border: 6px solid #8a5626;
}
.rod {
  position: relative; width: calc(var(--bd) + 12px);
  height: calc(var(--bd) * 7 + 14px);
}
.rod-line {
  position: absolute; top: 4px; bottom: 4px; left: 50%;
  width: 5px; transform: translateX(-50%); background: #6d4322; border-radius: 4px; z-index: 0;
}
.units-rod .rod-line { background: #ffcf4d; box-shadow: 0 0 10px #ffcf4d; }
.heaven { position: absolute; top: 0; left: 0; right: 0; height: calc(var(--bd) * 2); z-index: 1; }
.beam { position: absolute; top: calc(var(--bd) * 2); left: -6px; right: -6px; height: 10px; background: #5a3417; border-radius: 4px; z-index: 2; }
.earth { position: absolute; top: calc(var(--bd) * 2 + 12px); left: 0; right: 0; height: calc(var(--bd) * 5); z-index: 1; }

.bead {
  position: absolute; left: 50%; width: var(--bd); height: var(--bd);
  border: none; cursor: pointer; padding: 0; z-index: 1;
  border-radius: 50%;
  transform: translate(-50%, 0);
  transition: transform 0.16s var(--ease-pop);
  box-shadow: inset 0 -5px 8px rgba(0,0,0,0.3), inset 0 4px 6px rgba(255,255,255,0.5), 0 3px 5px rgba(0,0,0,0.25);
}
.heaven-bead { top: 0; background: radial-gradient(circle at 35% 30%, #ff9ec4, #e0427f); }
.heaven-bead.active { transform: translate(-50%, var(--bd)); }
.earth-bead { background: radial-gradient(circle at 35% 30%, #79c2ff, #2a7fd6); }
.earth-bead:nth-child(1) { top: calc(var(--bd) * 1); }
.earth-bead:nth-child(2) { top: calc(var(--bd) * 2); }
.earth-bead:nth-child(3) { top: calc(var(--bd) * 3); }
.earth-bead:nth-child(4) { top: calc(var(--bd) * 4); }
.earth-bead.active { transform: translate(-50%, calc(var(--bd) * -1)); }
.units-rod .earth-bead { background: radial-gradient(circle at 35% 30%, #8af0a0, #2fae50); }

.abacus-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.abacus-say {
  font-size: clamp(15px, 2.4vw, 24px); font-weight: 800; text-align: center;
  background: rgba(255,255,255,0.8); padding: 8px 18px; border-radius: 16px; min-height: 1.4em;
}
.abacus-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.small-say { font-size: clamp(14px, 2vw, 20px); padding: 10px 18px; }
.small-say.alt { background: linear-gradient(180deg, #c4a6ff, var(--purple)); box-shadow: 0 6px 0 #7a55d6; }
.small-say.go { background: linear-gradient(180deg, #ffd66b, #ffbe2e); box-shadow: 0 6px 0 #d99a00; color:#7a5300; text-shadow:none; }

/* ============================================================
   DRAW & COLOUR
   ============================================================ */
.draw { background: linear-gradient(180deg, #eef3ff, #ffeef6); }
.draw-body { flex: 1; display: flex; gap: 12px; padding: 12px; min-height: 0; }
.palette {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
  align-content: start; flex: 0 0 auto;
}
.swatch {
  width: clamp(30px, 4.2vw, 44px); height: clamp(30px, 4.2vw, 44px); border-radius: 50%;
  border: 3px solid #fff; cursor: pointer; box-shadow: 0 3px 5px rgba(0,0,0,0.18);
  transition: transform 120ms var(--ease-pop);
}
.swatch.sel { outline: 3px solid var(--ink); transform: scale(1.15); }
.brush-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.brush-btn {
  width: 44px; height: 40px; border: none; border-radius: 10px; cursor: pointer;
  background: #fff; font-size: 20px; box-shadow: 0 3px 5px rgba(0,0,0,0.14);
  transition: transform 100ms var(--ease-pop);
}
.brush-btn:active { transform: scale(0.93); }
.brush-btn.sel { outline: 3px solid var(--purple); background: #f3ecff; transform: scale(1.08); }
.canvas-wrap {
  flex: 1; min-width: 0; background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: inset 0 0 0 5px #fff, 0 10px 24px rgba(0,0,0,0.15); position: relative;
  touch-action: none;
}
#draw-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.draw-tools { flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.sizes { display: flex; flex-direction: column; gap: 8px; }
.size-dot {
  width: 48px; height: 40px; border: none; border-radius: 12px; cursor: pointer;
  background: #fff; box-shadow: 0 4px 6px rgba(0,0,0,0.14);
  display: flex; align-items: center; justify-content: center;
}
.size-dot span { display: block; background: var(--ink); border-radius: 50%; }
.size-dot.sel { outline: 3px solid var(--pink); }
.tool-chip {
  width: 56px; height: 50px; border: none; border-radius: 14px; cursor: pointer;
  background: #fff; font-size: 26px; box-shadow: 0 4px 6px rgba(0,0,0,0.14);
}
.tool-chip.on { outline: 4px solid var(--pink); background: #ffe7f1; }
.stickers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.sticker-btn {
  width: 44px; height: 44px; border: none; border-radius: 12px; cursor: pointer;
  background: #fff; font-size: 24px; box-shadow: 0 3px 5px rgba(0,0,0,0.14);
}
.sticker-btn.sel { outline: 4px solid var(--purple); background: #f1e7ff; }

/* ============================================================
   TROPHIES
   ============================================================ */
.trophies { background: linear-gradient(180deg, #fff6d6, #ffe9f3); }
.trophies-body { flex: 1; overflow-y: auto; padding: clamp(12px, 2.5vw, 26px); }
.trophy-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 2vw, 20px);
  max-width: 900px; margin: 0 auto;
}
.trophy-card {
  background: #fff; border-radius: 22px; padding: 16px 12px; text-align: center;
  box-shadow: var(--card-shadow); border: 4px solid #fff;
}
.trophy-card.locked { filter: grayscale(0.9); opacity: 0.6; }
.trophy-card.got { animation: pop-in .4s var(--ease-pop) both; border-color: var(--yellow); }
.trophy-icon { font-size: clamp(40px, 6vw, 64px); }
.trophy-name { font-size: clamp(15px, 2.1vw, 22px); font-weight: 900; color: var(--ink); margin-top: 4px; }
.trophy-desc { font-size: clamp(11px, 1.6vw, 15px); opacity: 0.75; margin-top: 2px; }

/* ============================================================
   Achievement toast
   ============================================================ */
.ach-toast {
  position: absolute; top: 16px; left: 50%; transform: translate(-50%, -160%);
  z-index: 30; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #fff, #fff3c4);
  border: 4px solid var(--yellow); border-radius: 20px; padding: 12px 22px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.22); opacity: 0; pointer-events: none;
  max-width: 86%;
}
.ach-toast.show { animation: toast-in 3.2s var(--ease-pop); }
@keyframes toast-in {
  0% { transform: translate(-50%, -160%); opacity: 0; }
  12% { transform: translate(-50%, 0); opacity: 1; }
  88% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -160%); opacity: 0; }
}
.ach-toast-emoji { font-size: 40px; }
.ach-toast-text { display: flex; flex-direction: column; line-height: 1.15; }
.ach-toast-text b { font-size: clamp(16px, 2.3vw, 22px); color: var(--ink); }
.ach-toast-text small { font-size: clamp(12px, 1.7vw, 16px); color: var(--pink-d); font-weight: 700; }

/* song letters now show small case too */
.song-letter small { display: block; font-size: 0.6em; opacity: 0.85; margin-top: -2px; }

/* ============================================================
   =========  v3: profiles, language, music, colouring  ======
   ============================================================ */

/* ---- PROFILES (first page) ---- */
.profiles {
  background: linear-gradient(180deg, var(--sky-top) 0%, #e7d3ff 70%, #ffe9b3 100%);
  align-items: center; justify-content: center; text-align: center;
}
.profiles-inner { position: relative; z-index: 3; padding: 2vh 4vw; width: 100%; }
.course-badge {
  display: inline-block; background: rgba(255,255,255,0.9); border-radius: 999px;
  padding: 6px 18px; font-weight: 800; font-size: clamp(14px, 2vw, 20px);
  box-shadow: 0 5px 0 rgba(0,0,0,0.1); margin-bottom: 8px;
}
.course-title {
  font-size: clamp(26px, 5.2vw, 56px); color: #fff; line-height: 1.05;
  -webkit-text-stroke: 3px var(--purple); paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.course-sub { font-size: clamp(16px, 2.6vw, 26px); font-weight: 800; color: var(--ink); margin-top: 6px; }
.course-foot { margin-top: 14px; font-weight: 700; color: var(--ink); opacity: 0.85; font-size: clamp(13px, 1.9vw, 19px); }

.profile-cards { display: flex; gap: clamp(16px, 4vw, 46px); justify-content: center; margin-top: clamp(14px, 3vh, 30px); flex-wrap: wrap; }
.profile-card {
  border: none; cursor: pointer; font-family: inherit;
  width: clamp(190px, 30vw, 270px);
  background: #fff; border-radius: 30px; padding: clamp(16px, 2.5vh, 28px) 18px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: var(--card-shadow); border: 6px solid #fff;
  transition: transform 0.14s var(--ease-pop);
}
.profile-card:active { transform: translateY(8px) scale(0.97); }
.profile-card.pc-girl { border-color: #ffc2dd; }
.profile-card.pc-boy { border-color: #bcdcff; }
.pc-avatar {
  font-size: clamp(56px, 10vw, 96px); line-height: 1;
  width: clamp(96px, 17vw, 150px); height: clamp(96px, 17vw, 150px);
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,0.08);
}
.pc-girl .pc-avatar { background: radial-gradient(circle at 50% 40%, #ffe3ef, #ffc2dd); }
.pc-boy  .pc-avatar { background: radial-gradient(circle at 50% 40%, #e3f1ff, #bcdcff); }
.pc-name { font-size: clamp(24px, 4vw, 38px); font-weight: 900; color: var(--ink); }
.pc-pinyin { font-size: clamp(14px, 2.1vw, 20px); font-weight: 700; color: var(--pink-d); }
.pc-girl .pc-pinyin { color: var(--pink-d); }
.pc-boy .pc-pinyin { color: var(--blue-d); }
.pc-age {
  margin-top: 6px; font-size: clamp(13px, 1.9vw, 18px); font-weight: 800; color: #fff;
  background: var(--purple); padding: 4px 14px; border-radius: 999px;
}
.pc-girl .pc-age { background: var(--pink); }
.pc-boy .pc-age { background: var(--blue); }

/* ---- LANGUAGE ---- */
.language { background: linear-gradient(180deg, #eafff4, #e7f1ff); }
.language-inner { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(16px, 4vh, 40px); padding: 2vh 4vw; }
.lang-hello { font-size: clamp(20px, 3.4vw, 34px); font-weight: 900; color: var(--ink); background: #fff; padding: 10px 24px; border-radius: 999px; box-shadow: 0 6px 0 rgba(0,0,0,0.1); }
.lang-cards { display: flex; gap: clamp(14px, 3vw, 32px); flex-wrap: wrap; justify-content: center; }
.lang-card {
  border: none; cursor: pointer; font-family: inherit;
  width: clamp(150px, 22vw, 220px); background: #fff; border-radius: 26px;
  padding: clamp(16px, 3vh, 30px) 16px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: var(--card-shadow); border: 6px solid #fff;
  transition: transform 0.14s var(--ease-pop);
}
.lang-card:active { transform: translateY(8px) scale(0.97); }
.lang-card span { font-size: clamp(44px, 8vw, 72px); }
.lang-card b { font-size: clamp(18px, 2.8vw, 26px); color: var(--ink); }

/* ---- LEARN: capital/small labels + music badge ---- */
.case-labels { display: flex; gap: 18px; margin-top: 2px; }
.cl-big { font-weight: 800; color: var(--pink-d); font-size: clamp(12px, 1.8vw, 18px); }
.cl-small { font-weight: 800; color: var(--blue-d); font-size: clamp(12px, 1.8vw, 18px); }
.music-badge {
  border: none; cursor: default; font-family: inherit;
  background: rgba(255,255,255,0.85); border-radius: 999px; padding: 6px 14px;
  font-weight: 800; font-size: clamp(12px, 1.7vw, 16px); color: var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.1); max-width: 40%;
}

/* ---- DRAW: tip, two-canvas stack, templates ---- */
.draw-tip {
  text-align: center; font-weight: 800; color: var(--ink);
  background: rgba(255,255,255,0.7); padding: 6px; font-size: clamp(13px, 2vw, 19px);
}
.canvas-wrap { position: relative; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#color-canvas { touch-action: none; cursor: crosshair; }
#outline-canvas { pointer-events: none; }
.templates { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 4px; }
.template-btn {
  width: 46px; height: 46px; border: none; border-radius: 12px; cursor: pointer;
  background: #fff; font-size: 26px; box-shadow: 0 3px 5px rgba(0,0,0,0.14);
}
.template-btn.sel { outline: 4px solid var(--green); background: #e7ffe9; }

/* ---- Abacus levels ---- */
.abacus-levels { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 2px; }
.level-chip {
  border: none; cursor: pointer; font-family: inherit;
  padding: 7px 16px; border-radius: 999px; background: #fff;
  font-weight: 800; font-size: clamp(13px, 1.8vw, 18px); color: var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.level-chip:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.12); }
.level-chip.sel { background: var(--purple); color: #fff; box-shadow: 0 4px 0 #7a55d6; transform: translateY(-1px); }
.small-say.alt2 { background: linear-gradient(180deg, #6ff0dd, #2fc9b3); box-shadow: 0 6px 0 #1f9e8c; color: #08514a; text-shadow: none; }

/* ============================================================
   =========  v4: more games + music + bigger menu  ==========
   ============================================================ */

/* extra tile colours */
.b-indigo { background: linear-gradient(180deg, #9aa8ff, #6a78f0); border-bottom: 8px solid #4a55c8; }
.b-rose   { background: linear-gradient(180deg, #ff9ec4, #ff6fae); border-bottom: 8px solid #e0427f; }
.b-sky    { background: linear-gradient(180deg, #7fd4ff, #39b4f0); border-bottom: 8px solid #1f8ec8; }

/* fit up to 12 tiles (4 × 3) on the home page */
.home .home-inner { gap: 5px; }
.home .mascot { font-size: clamp(42px, 6.5vw, 74px); }
.home .logo { font-size: clamp(34px, 6.5vw, 80px); margin: 0 0 2px; letter-spacing: 2px; }
.menu-grid { grid-template-columns: repeat(6, 1fr); gap: clamp(6px, 1vw, 11px); width: min(98%, 990px); margin-top: clamp(5px, 1vh, 12px); }
.menu-grid .big-btn { padding: clamp(7px, 1.3vh, 13px) 6px; font-size: clamp(12px, 1.5vw, 17px); border-radius: 22px; }
.menu-grid .big-btn-emoji { font-size: 1.7em; }

/* ============================================================
   MEMORY MATCH
   ============================================================ */
.memory { background: linear-gradient(180deg, #eef0ff, #ffe9f4); }
.memory-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: clamp(10px, 2vh, 22px); min-height: 0; }
.memory-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 1.6vw, 18px);
  width: min(96%, 760px); height: 100%; max-height: 100%; align-content: center;
}
.mem-card { aspect-ratio: 1; border: none; background: none; cursor: pointer; padding: 0; perspective: 700px; }
.mem-inner { position: relative; width: 100%; height: 100%; transition: transform 0.35s var(--ease-pop); transform-style: preserve-3d; }
.mem-card.up .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-back, .mem-front {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 6px 0 rgba(0,0,0,0.14); font-weight: 900;
}
.mem-back { background: linear-gradient(180deg, #8aa6ff, #5a6ff0); font-size: clamp(28px, 5vw, 52px); }
.mem-front { background: #fff; transform: rotateY(180deg); font-size: clamp(34px, 6vw, 64px); }
.mem-card.matched .mem-front { outline: 5px solid var(--green); }
.mem-card.matched { animation: thing-pop 0.5s var(--ease-pop); }

/* ============================================================
   TRACE THE LETTERS
   ============================================================ */
.trace { background: linear-gradient(180deg, #f3fbe7, #e7f1ff); }
.trace-body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px clamp(10px, 3vw, 40px); min-height: 0; }
.trace-pick { display: flex; align-items: center; justify-content: center; gap: 18px; }
.trace-current { font-size: clamp(28px, 5vw, 48px); font-weight: 900; color: var(--purple); }
.trace-wrap { flex: 1; min-height: 0; }
#trace-canvas { touch-action: none; cursor: crosshair; }
.trace-colors { display: flex; gap: 10px; justify-content: center; }
.trace-swatch { width: clamp(38px, 5vw, 50px); height: clamp(38px, 5vw, 50px); border-radius: 50%; border: 4px solid #fff; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.18); }
.trace-swatch.sel { outline: 4px solid var(--ink); transform: scale(1.12); }

/* ============================================================
   MUSIC (YouTube)
   ============================================================ */
.music { background: linear-gradient(180deg, #ffe9f0, #e7eeff); }
.music-body { flex: 1; display: flex; gap: 14px; padding: 14px; min-height: 0; }
.music-player { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.music-frame {
  flex: 1; background: #1a1320; border-radius: 18px; overflow: hidden; min-height: 0;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--card-shadow);
}
.music-frame iframe { width: 100%; height: 100%; border: 0; }
.music-frame:empty::before { content: '🎶'; font-size: clamp(50px, 10vw, 90px); }
.music-hint { text-align: center; font-weight: 800; color: var(--ink); }
.music-list { flex: 0 0 36%; max-width: 340px; overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.song-card { display: flex; align-items: stretch; background: #fff; border-radius: 16px; box-shadow: 0 5px 0 rgba(0,0,0,0.1); overflow: hidden; }
.song-play { flex: 1; display: flex; align-items: center; gap: 10px; border: none; background: none; cursor: pointer; font-family: inherit; padding: 12px 14px; font-weight: 800; font-size: clamp(13px, 1.8vw, 18px); color: var(--ink); text-align: left; }
.song-play:active { background: #fff0f6; }
.song-emoji { font-size: 1.6em; }
.song-yt { flex: 0 0 auto; padding: 0 16px; display: flex; align-items: center; text-decoration: none; font-size: 20px; background: #ffeef4; }

/* ============================================================
   v5 — Malay, custom names, free music, logic, words, story
   ============================================================ */

/* ---- New tile colours ---- */
.b-lime { background: linear-gradient(135deg, #7ecb20, #5aad00); }
.b-jade { background: linear-gradient(135deg, #20b09c, #1a7f71); }
.b-navy { background: linear-gradient(135deg, #3a5fc8, #2840a0); }

/* ---- Profile slots & edit button ---- */
.profile-slot { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.edit-name-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.9); border: 2px solid #e0c8ff;
  border-radius: 50%; width: 34px; height: 34px; font-size: 1rem;
  cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.edit-name-btn:hover { background: #fff0f6; }

/* ---- Name edit modal ---- */
.name-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 900;
}
.name-modal[hidden] { display: none; }
.name-modal-inner {
  background: #fff; border-radius: 24px; padding: 2rem 2.5rem;
  display: flex; flex-direction: column; gap: 1rem; align-items: center;
  min-width: 300px; max-width: 420px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);
}
.name-modal-label { font-size: 1.15rem; font-weight: 800; color: #333; text-align: center; margin: 0; }
.name-input {
  font-size: 1.4rem; border: 3px solid #a884ff; border-radius: 14px;
  padding: 0.5rem 1rem; width: 100%; text-align: center;
  font-family: inherit; outline: none; box-sizing: border-box;
}
.name-input:focus { border-color: #ff6fae; }
.name-modal-btns { display: flex; gap: 1rem; }

/* ---- Logic screen ---- */
.logic-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; padding: 1rem 1.5rem; height: calc(100% - 70px); overflow-y: auto;
}
.logic-sequence { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin: 0.25rem 0; }
.logic-item {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  background: #fff; border-radius: 14px; padding: 0.3rem 0.6rem;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.logic-q { background: linear-gradient(135deg, #a884ff, #7a5ce0); color: #fff; }
.logic-choices { display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: center; margin-top: 0.5rem; }
.logic-choices .choice { font-size: clamp(1.8rem, 4vw, 2.4rem); min-width: 80px; }

/* ---- 生字 Word screen ---- */
.word-char {
  font-size: clamp(4rem, 10vw, 7rem); font-weight: 800; line-height: 1;
  color: #2d2d6b; text-shadow: 3px 3px 0 rgba(168,132,255,0.3);
  text-align: center;
}
.word-pinyin { font-size: 1.3rem; color: #a884ff; font-weight: 700; text-align: center; }
.word-char-sm { font-size: 1.5rem; font-weight: 800; }
.word-cell { min-height: 58px; }

/* ---- Story screen ---- */
.story-body { display: flex; flex-direction: column; height: calc(100% - 70px); overflow: hidden; }
.story-menu {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 1rem; padding: 1.2rem; overflow-y: auto;
}
.story-card {
  background: linear-gradient(135deg, #f3eeff, #e8f4ff);
  border: 2px solid #c4b0ff; border-radius: 18px; padding: 1.2rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  cursor: pointer; transition: transform 0.15s; font-family: inherit; font-size: 1rem;
}
.story-card:active { transform: scale(0.97); }
.story-card-emoji { font-size: 2.2rem; }
.story-card-title { font-weight: 700; font-size: 0.95rem; color: #333; text-align: center; }
.story-reader {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.8rem; padding: 1rem 1.5rem; overflow-y: auto;
}
.story-reader[hidden], .story-menu[hidden] { display: none !important; }
.story-scene { font-size: clamp(2.4rem, 7vw, 4.5rem); line-height: 1.3; text-align: center; }
.story-text {
  font-size: clamp(1rem, 2.2vw, 1.25rem); text-align: center; color: #333;
  max-width: 600px; line-height: 1.7;
}
.story-nav { display: flex; align-items: center; gap: 1.2rem; }
.story-page { font-size: 0.9rem; color: #888; }

/* ── Story end modal ── */
.story-end-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(20, 10, 50, 0.72);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease;
}
.story-end-overlay[hidden] { display: none !important; }
.story-end-card {
  background: linear-gradient(160deg, #fffde7 0%, #e8f4ff 100%);
  border-radius: 32px; padding: clamp(24px, 4vh, 44px) clamp(24px, 5vw, 52px);
  max-width: min(520px, 88vw); width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 0 0 3px rgba(255,220,80,0.5);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: popIn 0.5s var(--ease-pop);
  text-align: center;
}
.story-end-emoji { font-size: clamp(52px, 10vw, 88px); line-height: 1; }
.story-end-the-end {
  font-family: var(--font-display); font-size: clamp(26px, 5vw, 42px);
  color: #2d1b6b; margin: 0;
}
.story-end-divider { color: #f59e0b; font-size: 1.1rem; letter-spacing: 4px; }
.story-end-lesson-label {
  font-size: clamp(13px, 2vw, 16px); font-weight: 700;
  color: #7c3aed; text-transform: uppercase; letter-spacing: 1px; margin: 0;
}
.story-end-lesson {
  font-size: clamp(15px, 2.4vw, 20px); line-height: 1.65;
  color: #1a1040; max-width: 400px; margin: 0; font-weight: 600;
}
.story-end-stars { font-size: 1.8rem; letter-spacing: 6px; }
.story-end-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.story-end-btn {
  font-family: inherit; font-size: clamp(14px, 2vw, 17px); font-weight: 800;
  border: none; border-radius: 999px; padding: 12px 24px; cursor: pointer;
  background: #e8e0ff; color: #4c1d95;
  box-shadow: 0 5px 0 #c4b5fd; transition: transform 0.1s, box-shadow 0.1s;
}
.story-end-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c4b5fd; }
.story-end-btn-primary {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff; box-shadow: 0 5px 0 #c2410c;
}
.story-end-btn-primary:active { box-shadow: 0 2px 0 #c2410c; }

/* ---- Music player (v5 — Web Audio, no YouTube) ---- */
.music-now {
  font-size: 1.1rem; font-weight: 700; color: #2d2d6b;
  padding: 0.4rem 1rem; text-align: center; min-height: 2.2rem;
}
.music-lyric {
  font-family: inherit; font-size: 0.9rem; line-height: 1.8; color: #555;
  white-space: pre-wrap; text-align: center;
  max-height: 130px; overflow-y: auto;
  background: #f7f0ff; border-radius: 12px; padding: 0.7rem 1rem; margin: 0;
}
/* Override old song-card style for the new list-only layout */
#music-list .song-card {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 1rem;
  border-radius: 14px; background: #fff; border: 2px solid #e0d0ff;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
  text-align: left; font-family: inherit; font-size: 0.95rem; box-shadow: none;
}
#music-list .song-card.sel { background: #f0e6ff; border-color: #a884ff; }
#music-list .song-card .song-emoji { font-size: 1.5rem; }
#music-list .song-card .song-title { font-weight: 600; color: #333; }
#music-list { flex-direction: column; gap: 0.5rem; display: flex; }
.music-play-btn.active { background: #ff6fae !important; color: #fff !important; border-color: #ff6fae !important; }

/* ---- Lang card 4-column on larger screens ---- */
.lang-cards { flex-wrap: wrap; gap: 0.8rem; justify-content: center; }

/* ============================================================
   GAMIFICATION & INTERACTION v5 — bgmusic, streaks, trilingual
   ============================================================ */

/* ---- Word trilingual strip --------------------------------- */
.word-tri {
  display: flex; align-items: center; justify-content: center;
  gap: 0.3rem; flex-wrap: wrap;
  font-size: 1.05rem; font-weight: 600; color: #555;
  min-height: 1.6em;
}
.word-tri-en  { color: #2b7fff; }
.word-tri-ms  { color: #10a86e; }
.word-tri-dot { color: #bbb; font-weight: 400; }

/* ---- Streak badge (used by reward() overlay) --------------- */
.streak-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: linear-gradient(135deg, #ff6b00, #ffaa00);
  color: #fff; font-weight: 800; font-size: 1.1rem;
  padding: 0.3em 0.8em; border-radius: 999px;
  box-shadow: 0 3px 12px rgba(255,106,0,.4);
  animation: streak-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes streak-pop {
  from { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

/* ---- Home tile bounce-in entrance ------------------------- */
@keyframes tile-bounce-in {
  0%   { transform: scale(0.55) translateY(18px); opacity: 0; }
  70%  { transform: scale(1.07) translateY(-4px); }
  100% { transform: scale(1)    translateY(0);    opacity: 1; }
}
.big-btn {
  animation: tile-bounce-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* Staggered delays for up to 10 tiles */
.big-btn:nth-child(1)  { animation-delay: 0.04s; }
.big-btn:nth-child(2)  { animation-delay: 0.09s; }
.big-btn:nth-child(3)  { animation-delay: 0.14s; }
.big-btn:nth-child(4)  { animation-delay: 0.19s; }
.big-btn:nth-child(5)  { animation-delay: 0.24s; }
.big-btn:nth-child(6)  { animation-delay: 0.29s; }
.big-btn:nth-child(7)  { animation-delay: 0.34s; }
.big-btn:nth-child(8)  { animation-delay: 0.39s; }
.big-btn:nth-child(9)  { animation-delay: 0.44s; }
.big-btn:nth-child(10) { animation-delay: 0.49s; }

/* ---- Tile tap scale ---------------------------------------- */
.big-btn:active { transform: scale(0.93); transition: transform 0.08s; }

/* ---- Word cell flip on click ------------------------------- */
.word-cell {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.word-cell:active { transform: scale(0.88) rotate(-3deg); }
.word-cell.active {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(255,255,255,.35), 0 4px 16px rgba(0,0,0,.18);
  transform: scale(1.1);
}

/* ---- Shake on wrong (play.js Letter Hunt) ------------------ */
@keyframes shake-wrong {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-10px) rotate(-3deg); }
  40%       { transform: translateX(10px)  rotate(3deg); }
  60%       { transform: translateX(-8px)  rotate(-2deg); }
  80%       { transform: translateX(6px)   rotate(2deg); }
}
.shake { animation: shake-wrong 0.45s ease both; }

/* ============================================================
   WORD PLAY QUIZ — wq-* styles
   ============================================================ */

.wordquiz .wq-body {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: calc(100% - 64px);
  padding: 0.8rem 1rem; gap: 0.8rem;
}

/* ---- Mode picker ----------------------------------------- */
.wq-modes { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.wq-modes-hint { font-size: 1.1rem; font-weight: 700; color: #555; margin: 0; }
.wq-mode-row { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; }

.wq-mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  width: 150px; padding: 1.2rem 0.8rem;
  border-radius: 24px; border: 3px solid transparent;
  background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.10);
  cursor: pointer; font-family: inherit; transition: transform .18s, box-shadow .18s;
}
.wq-mode-btn:hover  { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.14); }
.wq-mode-btn:active { transform: scale(.93); }
.wq-mode-btn[data-mode="zh"] { border-color: #ff6b6b; }
.wq-mode-btn[data-mode="en"] { border-color: #4dabf7; }
.wq-mode-btn[data-mode="ms"] { border-color: #51cf66; }
.wq-mode-flag { font-size: 2.2rem; }
.wq-mode-btn strong { font-size: 1.25rem; color: #222; }
.wq-mode-btn small  { font-size: 0.8rem; color: #888; }

/* ---- Quiz layout ----------------------------------------- */
.wq-quiz {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.7rem; width: 100%; max-width: 680px;
}

.wq-top {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%; justify-content: center;
}

.wq-lang-chip {
  font-size: 0.9rem; font-weight: 700; padding: 0.35em 1em;
  border-radius: 999px; border: 2px solid #ddd;
  background: #f5f5f5; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.wq-lang-chip:hover { background: #ebebeb; }

.wq-streak-badge {
  display: inline-flex; align-items: center; gap: 0.2rem;
  background: linear-gradient(135deg,#ff6b00,#ffaa00);
  color:#fff; font-weight:800; font-size:0.95rem;
  padding:.25em .75em; border-radius:999px;
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* ---- Word card (emoji + prompt) -------------------------- */
.wq-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  background: #fff; border-radius: 28px;
  padding: 1rem 2rem; min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,.10);
}
.wq-emoji  { font-size: 4.5rem; line-height: 1; }
.wq-prompt { font-size: 0.95rem; font-weight: 700; color: #555; margin: 0; text-align: center; }

@keyframes wq-card-pop {
  from { transform: scale(.85) translateY(8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}
.wq-pop { animation: wq-card-pop .3s cubic-bezier(.34,1.56,.64,1) both; }

/* ---- Choice buttons -------------------------------------- */
.wq-choices {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.7rem; width: 100%;
}

.wq-choice {
  padding: 0.8em 0.5em; border-radius: 18px; border: none;
  font-size: 1.3rem; font-weight: 800; color: #fff;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 12px rgba(0,0,0,.14);
  transition: transform .15s, box-shadow .15s;
  min-height: 64px;
}
.wq-choice:hover  { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.wq-choice:active { transform: scale(.93); }

.wq-choice.wq-correct {
  outline: 4px solid #2dcc70; box-shadow: 0 0 0 6px rgba(45,204,112,.25);
  animation: wq-correct-pop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes wq-correct-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.wq-choice.wq-wrong {
  animation: shake-wrong .45s ease both;
  outline: 3px solid #e74c3c;
}

/* ---- Reveal strip (all 3 languages) ---------------------- */
.wq-reveal {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; flex-wrap: wrap;
  background: linear-gradient(135deg, #fff8e1, #fff);
  border-radius: 16px; padding: 0.6rem 1.2rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  width: 100%;
  animation: wq-card-pop .3s cubic-bezier(.34,1.56,.64,1) both;
}
.wq-rv-zh  { font-size: 1.4rem; font-weight: 900; color: #e74c3c; }
.wq-rv-en  { font-size: 1.1rem; font-weight: 700; color: #2b7fff; }
.wq-rv-ms  { font-size: 1.1rem; font-weight: 700; color: #10a86e; }
.wq-rv-sep { color: #bbb; font-weight: 400; font-size: 1rem; }
/* Fix: hidden attribute must override flex/block display in wq */
.wq-quiz[hidden], .wq-modes[hidden], .wq-reveal[hidden], .wq-streak-badge[hidden] { display: none !important; }

/* ============================================================
   SVG VECTOR DECORATION — Home screen + Word Art cards
   ============================================================ */

/* ── Home screen SVG scene layer ─────────────────────────── */
.sky-deco { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

/* Sun */
.deco-sun {
  position: absolute; top: -10px; right: 60px;
  width: 110px; height: 110px;
  animation: sun-spin 18s linear infinite;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 0 18px #fbbf24aa);
}
@keyframes sun-spin {
  to { transform: rotate(360deg); }
}

/* Clouds drift left */
.deco-cloud {
  position: absolute;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.08));
  animation: cloud-drift linear infinite;
}
.deco-cloud.dc1 { top: 18px; width: 210px; animation-duration: 28s; animation-delay: -8s; }
.deco-cloud.dc2 { top: 48px; width: 160px; animation-duration: 36s; animation-delay: -18s; opacity: .8; }
.deco-cloud.dc3 { top: 5px; width: 130px; animation-duration: 44s; animation-delay: -30s; opacity: .6; }
@keyframes cloud-drift {
  from { transform: translateX(1120px); }
  to   { transform: translateX(-260px); }
}

/* Birds flying across */
.deco-bird {
  position: absolute;
  animation: bird-fly linear infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.15));
}
.deco-bird.db1 { top: 65px; width: 58px; animation-duration: 16s; animation-delay: -4s; }
.deco-bird.db2 { top: 38px; width: 42px; animation-duration: 22s; animation-delay: -14s; opacity: .7; }
.deco-bird.db3 { top: 80px; width: 36px; animation-duration: 30s; animation-delay: -24s; opacity: .5; }
@keyframes bird-fly {
  from { transform: translateX(-80px); }
  to   { transform: translateX(1120px); }
}

/* Twinkling stars */
.deco-star {
  position: absolute; pointer-events: none;
  animation: star-twinkle ease-in-out infinite;
}
@keyframes star-twinkle {
  0%,100% { opacity: .9; transform: scale(1); }
  50%      { opacity: .2; transform: scale(.6); }
}

/* Balloons sway + float */
.deco-balloon {
  position: absolute;
  animation: balloon-float ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.15));
}
.deco-balloon.dbl1 { bottom: 10px; left: 38px; width: 44px; animation-duration: 4.2s; animation-delay: 0s; }
.deco-balloon.dbl2 { bottom: 10px; left: 72px; width: 38px; animation-duration: 3.8s; animation-delay: -.9s; }
@keyframes balloon-float {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-14px) rotate(4deg); }
}

/* ── SVG Fox mascot ──────────────────────────────────────── */
.svg-fox {
  width: 120px; height: 150px;
  display: block; overflow: visible;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.18));
}
/* Eye blink */
.fox-eyelid {
  transform-origin: center;
  animation: fox-blink 5s ease-in-out infinite;
}
@keyframes fox-blink {
  0%,90%,100% { transform: scaleY(0); }
  95%         { transform: scaleY(1); }
}
/* Tail wag */
.fox-tail {
  transform-origin: 72px 108px;
  animation: tail-wag 2.4s ease-in-out infinite;
}
@keyframes tail-wag {
  0%,100% { transform: rotate(0deg); }
  30%     { transform: rotate(14deg); }
  70%     { transform: rotate(-10deg); }
}

/* ── Word Art illustrated cards ──────────────────────────── */
.wq-emoji {
  width: 160px; height: 160px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.25);
  font-size: 4.5rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.3s ease;
}
.wq-emoji svg { width: 100%; height: 100%; display: block; }

/* Emoji fallback (no SVG art available) */
.wq-emoji.wq-emoji-text { background: #f9fafb; }


/* ============================================================
   ANIMAL GUESS — Screen styles
   ============================================================ */
.animalguess { background: linear-gradient(160deg,#ecfdf5,#d1fae5,#a7f3d0); }

.ag-body {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1.2rem;
  flex: 1; padding: 0.5rem 1rem;
}

.ag-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  background: white; border-radius: 28px;
  padding: 1.4rem 2.4rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.10);
}

/* The blurred animal emoji */
.ag-animal {
  font-size: 8rem; line-height: 1;
  filter: blur(14px) brightness(.6) saturate(.4);
  transition: filter 0.55s cubic-bezier(.34,1.56,.64,1),
              transform 0.55s cubic-bezier(.34,1.56,.64,1);
  transform: scale(1);
}
.ag-animal.ag-revealed {
  filter: blur(0) brightness(1) saturate(1);
  transform: scale(1.18);
}

.ag-hint {
  font-size: 1rem; font-weight: 700; color: #065f46;
  margin: 0; text-align: center; max-width: 260px;
}

.ag-choices {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.7rem; width: 100%; max-width: 480px;
}

.ag-choice {
  padding: 0.75em 0.5em; border-radius: 18px; border: none;
  font-size: 1.25rem; font-weight: 800; color: #fff;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 12px rgba(0,0,0,.14);
  transition: transform .12s, box-shadow .12s;
}
.ag-choice:active { transform: scale(.94); box-shadow: none; }
.ag-choice.ag-correct { box-shadow: 0 0 0 4px #10b981; animation: ag-correct-flash .4s; }
.ag-choice.ag-wrong   { animation: shake-wrong .45s; }

@keyframes ag-correct-flash {
  0%,100% { filter: brightness(1); }
  50%      { filter: brightness(1.3); }
}

.ag-streak {
  font-size: 1.6rem; font-weight: 900; color: #f97316;
  text-shadow: 0 2px 8px rgba(0,0,0,.15);
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes ag-card-pop {
  from { transform: scale(.85) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.ag-pop { animation: ag-card-pop .3s cubic-bezier(.34,1.56,.64,1) both; }

.ag-streak[hidden], .ag-choice[hidden] { display: none !important; }

/* ============================================================
   COLOR QUEST — Screen styles
   ============================================================ */
.colorquest { background: linear-gradient(160deg,#fdf4ff,#ede9fe,#ddd6fe); }

.cq-body {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1.2rem;
  flex: 1; padding: 0.5rem 1rem;
}

.cq-prompt {
  font-size: 1.3rem; font-weight: 800; color: #5b21b6;
  margin: 0; text-align: center;
}

/* The colorful shape display */
.cq-shape {
  width: 180px; height: 180px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.22));
  transition: transform 0.3s ease;
}
.cq-shape svg { width: 100%; height: 100%; display: block; }

@keyframes cq-shape-pop {
  from { transform: scale(.7) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1)  rotate(0deg);  opacity: 1; }
}
.cq-pop { animation: cq-shape-pop .38s cubic-bezier(.34,1.56,.64,1) both; }

@keyframes cq-burst {
  0%,100% { transform: scale(1) rotate(0deg); }
  25%     { transform: scale(1.18) rotate(8deg); }
  50%     { transform: scale(1.22) rotate(-6deg); }
  75%     { transform: scale(1.15) rotate(4deg); }
}
.cq-burst { animation: cq-burst .6s ease-in-out; }

.cq-choices {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.7rem; width: 100%; max-width: 480px;
}

.cq-choice {
  padding: 0.75em 0.5em; border-radius: 18px; border: none;
  font-size: 1.3rem; font-weight: 900;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 16px rgba(0,0,0,.16);
  transition: transform .12s, box-shadow .12s;
  text-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.cq-choice:active { transform: scale(.94); box-shadow: none; }
.cq-choice.cq-correct { animation: ag-correct-flash .4s; outline: 4px solid white; }
.cq-choice.cq-wrong   { animation: shake-wrong .45s; }

.cq-streak {
  font-size: 1.6rem; font-weight: 900; color: #7c3aed;
  text-shadow: 0 2px 8px rgba(0,0,0,.15);
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}
.cq-streak[hidden] { display: none !important; }

/* ============================================================
   BUTTON COLORS — new tiles
   ============================================================ */
.b-coral  { background: linear-gradient(135deg,#fb7185,#e11d48); box-shadow: 0 6px 0 #be123c; }
.b-sky    { background: linear-gradient(135deg,#38bdf8,#0284c7); box-shadow: 0 6px 0 #0369a1; }
.b-forest { background: linear-gradient(135deg,#34d399,#059669); box-shadow: 0 6px 0 #047857; }

/* ============================================================
   SPELL IT!
   ============================================================ */
.spellit { background: linear-gradient(160deg,#e0f2fe 0%,#bae6fd 100%); }

.si-body {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 12px 20px;
  flex: 1; min-height: 0;
}

.si-picture {
  font-size: 88px; line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.18));
}
@keyframes si-pop {
  0%   { transform: scale(.4) rotate(-8deg); opacity: 0; }
  70%  { transform: scale(1.18) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.si-pop { animation: si-pop .42s cubic-bezier(.34,1.56,.64,1) both; }

.si-blanks {
  display: flex; gap: 14px;
}
.si-slot {
  width: 72px; height: 80px; border-radius: 18px;
  background: white; border: 4px solid #94a3b8;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 900; color: #1e293b;
  transition: border-color .2s, background .2s, transform .15s;
  box-shadow: 0 4px 10px rgba(0,0,0,.1);
}
.si-slot-active {
  border-color: #f59e0b;
  box-shadow: 0 0 0 5px #fde68a, 0 4px 10px rgba(0,0,0,.1);
  animation: slot-pulse .75s ease-in-out infinite;
}
.si-slot-filled {
  border-color: #22c55e; background: #dcfce7;
  transform: scale(1.06);
}
@keyframes slot-pulse {
  0%,100% { box-shadow: 0 0 0 4px #fde68a; }
  50%      { box-shadow: 0 0 0 9px #fbbf24; }
}

.si-letters {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
}
.si-letter {
  width: 78px; height: 78px; border-radius: 18px; border: none;
  font-size: 36px; font-weight: 900; color: white; cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,.22);
  transition: transform .1s, box-shadow .1s;
}
.si-letter:active { transform: scale(.92); box-shadow: 0 2px 0 rgba(0,0,0,.22); }
.si-used  { opacity: .35; pointer-events: none; }
.si-shake { animation: shake-wrong .4s; }

.si-streak[hidden] { display: none !important; }
.si-streak {
  font-size: 1.5rem; font-weight: 900; color: #0284c7;
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* ============================================================
   COUNT & ADD
   ============================================================ */
.countadd { background: linear-gradient(160deg,#fef9c3 0%,#fde68a 100%); }

.ca-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 14px 20px; flex: 1; min-height: 0;
  justify-content: center;
}

.ca-tabs {
  display: flex; gap: 10px;
}
.ca-tab {
  padding: 9px 28px; border-radius: 50px; border: none;
  font-size: 17px; font-weight: 700; font-family: inherit;
  background: rgba(255,255,255,.45); cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
.ca-tab.active {
  background: white;
  box-shadow: 0 4px 14px rgba(0,0,0,.16);
}

.ca-prompt {
  font-size: 22px; font-weight: 800; color: #78350f;
  margin: 0;
}

.ca-objects {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: center;
  max-width: 540px; min-height: 90px;
}
@keyframes ca-pop {
  0%   { transform: scale(.6); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.ca-pop { animation: ca-pop .38s cubic-bezier(.34,1.56,.64,1) both; }

.ca-obj {
  font-size: 40px; display: inline-block;
  animation: ca-obj-in .25s ease-out both;
}
@keyframes ca-obj-in {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.ca-group {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; max-width: 220px;
}
.ca-plus {
  font-size: 52px; font-weight: 900; color: #b45309;
  align-self: center; line-height: 1;
}

.ca-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: min(340px, 90vw);
}
.ca-choice {
  border-radius: 22px; border: none; padding: 14px 10px;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
  transition: transform .1s, box-shadow .1s;
}
.ca-choice:active { transform: scale(.94); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.ca-choice-num { font-size: 44px; font-weight: 900; color: white; line-height: 1; }
.ca-choice-sub { font-size: 17px; color: rgba(255,255,255,.82); font-weight: 700; }
.ca-correct { animation: ag-correct-flash .4s; outline: 4px solid white; }
.ca-wrong   { animation: shake-wrong .45s; }

.ca-streak[hidden] { display: none !important; }
.ca-streak {
  font-size: 1.5rem; font-weight: 900; color: #b45309;
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* ============================================================
   SORT IT!
   ============================================================ */
.sortit { background: linear-gradient(160deg,#f0fdf4 0%,#bbf7d0 100%); }

.sg-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 16px 20px; flex: 1; min-height: 0;
  justify-content: center;
}

.sg-item-area {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sg-item-emoji {
  font-size: 96px; line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.2));
}
@keyframes sg-pop {
  0%   { transform: scale(.5) rotate(-10deg); opacity: 0; }
  70%  { transform: scale(1.2) rotate(3deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.sg-pop { animation: sg-pop .4s cubic-bezier(.34,1.56,.64,1) both; }

.sg-item-name {
  font-size: 24px; font-weight: 800; color: #166534;
}

.sg-progress-bar {
  width: min(320px, 88vw); height: 12px;
  background: rgba(0,0,0,.1); border-radius: 6px; overflow: hidden;
}
.sg-progress-fill {
  height: 100%; background: #22c55e; border-radius: 6px;
  transition: width .4s ease;
  width: 0%;
}

.sg-buckets {
  display: flex; gap: clamp(10px, 2vw, 20px); flex-wrap: wrap; justify-content: center;
}
.sg-bucket {
  width: clamp(140px, 42vw, 210px); height: 110px; border-radius: 24px;
  border: 4px solid #10b981;
  background: rgba(16,185,129,.12);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center;
  transition: transform .12s, background .2s;
}
.sg-bucket:hover  { transform: scale(1.05); background: rgba(255,255,255,.6); }
.sg-bucket:active { transform: scale(.95); }
.sg-bucket-label {
  font-size: 18px; font-weight: 800; color: #065f46;
  pointer-events: none;
}
@keyframes sg-bucket-correct {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.sg-bucket-correct { animation: sg-bucket-correct .45s ease-out; }
.sg-shake  { animation: shake-wrong .4s; }

.sg-streak[hidden] { display: none !important; }
.sg-streak {
  font-size: 1.5rem; font-weight: 900; color: #059669;
  animation: streak-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* ============================================================
   PROGRESS STRIP — home screen
   ============================================================ */
.prog-strip {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.62);
  backdrop-filter: blur(8px);
  border-radius: 20px; padding: 10px 18px;
  box-shadow: 0 3px 16px rgba(0,0,0,.10);
  width: 100%; max-width: 600px;
  font-family: inherit;
}
.prog-streak {
  font-size: 15px; font-weight: 800; color: #92400e;
  white-space: nowrap; padding: 4px 10px;
  background: #fef9c3; border-radius: 50px;
  border: 2px solid #fde68a;
  transition: transform .2s;
}
.prog-streak-hot {
  background: #fff7ed; border-color: #fb923c; color: #c2410c;
  animation: streak-pop .4s cubic-bezier(.34,1.56,.64,1);
}
.prog-goal-wrap {
  flex: 1; display: flex; flex-direction: column; gap: 3px;
}
.prog-bar {
  height: 10px; background: rgba(0,0,0,.08);
  border-radius: 5px; overflow: hidden;
}
.prog-bar-fill {
  height: 100%; width: 0%; border-radius: 5px;
  background: linear-gradient(90deg, #4ade80, #22d3ee 35%, #a78bfa 65%, #f472b6 100%);
  background-size: 200% auto;
  animation: hue-shift 2.8s linear infinite;
  transition: width .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes hue-shift {
  from { background-position: 0% center; }
  to   { background-position: 200% center; }
}
.prog-nums {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-align: center;
}
.prog-level {
  font-size: 13px; font-weight: 800; color: #4338ca;
  white-space: nowrap; padding: 4px 10px;
  background: #eef2ff; border-radius: 50px;
  border: 2px solid #c7d2fe;
}

/* ============================================================
   HINT BUTTON
   ============================================================ */
.hint-btn {
  padding: 6px 14px; border-radius: 50px; border: none;
  font-size: 14px; font-weight: 800; font-family: inherit;
  background: #fef9c3; color: #92400e;
  border: 2px solid #fde68a;
  cursor: pointer; white-space: nowrap;
  transition: background .2s, transform .1s, opacity .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.hint-btn:hover  { background: #fef08a; transform: scale(1.05); }
.hint-btn:active { transform: scale(.94); }
.hint-btn.hint-used {
  opacity: .4; pointer-events: none;
}

/* ============================================================
   HINT GLOW — applied to the correct answer element
   ============================================================ */
@keyframes hint-glow-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(251,191,36,.9), 0 0 20px rgba(251,191,36,.5); }
  50%      { box-shadow: 0 0 0 10px rgba(251,191,36,.3), 0 0 30px rgba(251,191,36,.8); }
}
.hint-glow {
  animation: hint-glow-pulse .6s ease-in-out 3 !important;
  outline: 4px solid #f59e0b !important;
  outline-offset: 2px;
  transform: scale(1.08) !important;
}

/* Sort It hint — arrow pulse on correct bucket */
@keyframes sg-hint-pulse-anim {
  0%,100% { box-shadow: 0 0 0 0 rgba(251,191,36,.8); transform: scale(1); }
  50%      { box-shadow: 0 0 0 14px rgba(251,191,36,.2); transform: scale(1.06); }
}
.sg-hint-pulse {
  animation: sg-hint-pulse-anim .7s ease-in-out 3;
  border-color: #f59e0b !important;
}

/* Count badge (hint counting labels) */
.ca-count-badge {
  position: absolute; top: -8px; right: -6px;
  background: #1e293b; color: white;
  font-size: 11px; font-weight: 900;
  border-radius: 50%; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.ca-obj { position: relative; }

/* ============================================================
   LEVEL-UP OVERLAY
   ============================================================ */
.levelup-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  opacity: 0; transition: opacity .4s;
  pointer-events: none;
}
.levelup-overlay.lu-in {
  opacity: 1; pointer-events: auto;
}
.levelup-overlay[hidden] { display: none !important; }

.lu-card {
  background: white; border-radius: 32px;
  padding: 40px 48px; text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
  transform: scale(.7);
  transition: transform .45s cubic-bezier(.34,1.56,.64,1);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.levelup-overlay.lu-in .lu-card { transform: scale(1); }

.lu-icon  { font-size: 80px; line-height: 1; }
.lu-title {
  font-size: 36px; font-weight: 900; color: #f59e0b;
  text-shadow: 0 2px 0 #fde68a;
}
.lu-label {
  font-size: 22px; font-weight: 700; color: #475569;
}

/* ============================================================
   CARTOON CHARACTER COMPANIONS
   ============================================================ */
.sky-char {
  position: absolute;
  pointer-events: none;
}

/* Penguin — bottom-left of sky */
.sc-penguin {
  width: clamp(80px, 10vw, 130px);
  bottom: 0; left: 2%;
  animation: char-bob 3.2s ease-in-out infinite;
  transform-origin: bottom center;
  z-index: 2;
}

/* Gold Duck — bottom-right of sky */
.sc-duck {
  width: clamp(72px, 9vw, 118px);
  bottom: 0; right: 3%;
  animation: char-bob 2.8s ease-in-out infinite;
  animation-delay: -1.1s;
  transform-origin: bottom center;
  z-index: 2;
}

/* Squirrel — left, higher up (peeks around edge) */
.sc-squirrel {
  width: clamp(64px, 8vw, 104px);
  bottom: 8%; left: 14%;
  animation: char-peek 4s ease-in-out infinite;
  transform-origin: bottom left;
  z-index: 2;
}

/* Shiba Inu — hidden on home, shown in spellit via class */
.sc-shiba  { display: none; }
.sc-croc   { display: none; }

@keyframes char-bob {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-14px) rotate(2deg); }
}
@keyframes char-peek {
  0%,100% { transform: translateY(0) scaleX(1); }
  40%      { transform: translateY(-10px) scaleX(1); }
  70%      { transform: translateY(-10px) scaleX(1) rotate(4deg); }
}

/* Small companion shown inside game screens */
.game-companion {
  position: absolute;
  bottom: 12px; right: 12px;
  width: clamp(56px, 8vw, 88px);
  opacity: .92;
  pointer-events: none;
  animation: char-bob 3s ease-in-out infinite;
  z-index: 5;
}
.game-companion.left { right: auto; left: 12px; }
.game-companion.top-right { bottom: auto; top: 60px; right: 8px; }

/* ============================================================
   PORTRAIT MODE — iPad (768 × 1024)
   ============================================================ */
@media (orientation: portrait) {
  /* Unlock the 4:3 lock — fill the full screen */
  .stage {
    width: 100vw;
    height: 100dvh;
  }

  /* Remove rotate hint in portrait because we now support it */
  .rotate-hint { display: none !important; }

  /* Home: tighter top bar */
  .home-top { padding: 10px 14px; }
  .hi-chip  { font-size: clamp(13px, 4vw, 18px); padding: 6px 14px; }
  .tool-btn { min-width: 44px; height: 44px; font-size: 18px; padding: 0 10px; }

  /* Menu: 3 columns in portrait */
  .menu { grid-template-columns: repeat(3, 1fr); }
  .big-btn { font-size: clamp(11px, 3.5vw, 16px); padding: clamp(8px, 2vh, 14px) 6px; }
  .big-btn-emoji { font-size: 1.7em; }

  /* Fox mascot: smaller in portrait */
  .mascot  { font-size: clamp(44px, 12vw, 72px); }
  .logo    { font-size: clamp(28px, 9vw, 56px); }

  /* Progress strip: narrower */
  .prog-strip { max-width: 90vw; padding: 8px 14px; gap: 10px; }
  .prog-streak, .prog-level { font-size: 13px; padding: 4px 8px; }

  /* Characters: reposition for portrait */
  .sc-penguin { width: clamp(60px, 12vw, 90px); left: 1%; }
  .sc-duck    { width: clamp(56px, 11vw, 86px); right: 1%; }
  .sc-squirrel{ display: none; } /* too crowded in portrait */

  /* Game screen bars */
  .bar { padding: 8px 12px; min-height: 52px; }
  .bar-title { font-size: clamp(15px, 4.5vw, 22px); }
  .back-btn  { width: 44px; height: 44px; font-size: 20px; }

  /* Game screens — full height, scrollable if needed */
  .screen { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* Spell It: bigger slots in portrait */
  .si-body  { gap: 16px; padding: 14px; }
  .si-slot  { width: clamp(54px, 16vw, 80px); height: clamp(54px, 16vw, 80px); font-size: clamp(20px, 6vw, 36px); }
  .si-picture { font-size: clamp(64px, 22vw, 110px); }
  .si-choices { gap: 10px; }
  .si-letter  { width: clamp(54px, 16vw, 80px); height: clamp(54px, 16vw, 80px); font-size: clamp(20px, 6vw, 34px); }

  /* Count & Add: 2-col choices */
  .ca-choices { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ca-choice  { padding: 14px 10px; }
  .ca-choice-num { font-size: clamp(28px, 9vw, 50px); }

  /* Sort It: stack buckets vertically in portrait */
  .sg-buckets { flex-direction: column; gap: 12px; align-items: center; }
  .sg-bucket  { width: 85vw; max-width: 360px; min-height: 90px; }

  /* Animal Guess: bigger picture */
  .ag-card  { max-width: 90vw; }

  /* Color Quest: 2-col choices */
  .cq-choices { grid-template-columns: 1fr 1fr; }
}

/* ── Spell It extra hint animations ───────────────────── */
@keyframes si-hint-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
  50%       { transform: scale(1.12); box-shadow: 0 0 0 12px rgba(251, 191, 36, 0); }
}
.si-hint-pulse {
  animation: si-hint-pulse .7s ease-in-out 3;
  border-color: #fbbf24 !important;
}

/* ============================================================
   DESIGN OVERHAUL v2 — Lingo Kids quality
   ============================================================ */

/* ── Fredoka One for all display text ── */
.logo, .bar-title, .course-title, .num-big, .feature-letter,
.case-big, .case-small, .match-target, .prompt .big-target {
  font-family: var(--font-display);
}

/* ── Lingo Kids-quality menu tile color system ── */
/* All tiles get the deep 3D shadow treatment */
.b-pink   { background: linear-gradient(145deg, #ff9dc8 0%, #ff4fa8 100%); border-bottom: 9px solid #c9286c; box-shadow: 0 9px 0 #c9286c, 0 14px 24px rgba(201,40,108,.22); }
.b-blue   { background: linear-gradient(145deg, #6bc9ff 0%, #2196f3 100%); border-bottom: 9px solid #1360b8; box-shadow: 0 9px 0 #1360b8, 0 14px 24px rgba(19,96,184,.22); }
.b-green  { background: linear-gradient(145deg, #6de98a 0%, #1ec95f 100%); border-bottom: 9px solid #0d8c3c; box-shadow: 0 9px 0 #0d8c3c, 0 14px 24px rgba(13,140,60,.22); }
.b-yellow { background: linear-gradient(145deg, #ffe06a 0%, #ffa500 100%); border-bottom: 9px solid #c07000; box-shadow: 0 9px 0 #c07000, 0 14px 24px rgba(192,112,0,.22); color: #5a3200; text-shadow: none; }
.b-purple { background: linear-gradient(145deg, #c8a8ff 0%, #9b59f5 100%); border-bottom: 9px solid #6930cc; box-shadow: 0 9px 0 #6930cc, 0 14px 24px rgba(105,48,204,.22); }
.b-rose   { background: linear-gradient(145deg, #ffadd4 0%, #f43f8e 100%); border-bottom: 9px solid #b52066; box-shadow: 0 9px 0 #b52066, 0 14px 24px rgba(181,32,102,.22); }
.b-teal   { background: linear-gradient(145deg, #5efad7 0%, #00bfa5 100%); border-bottom: 9px solid #00897b; box-shadow: 0 9px 0 #00897b, 0 14px 24px rgba(0,137,123,.22); }
.b-orange { background: linear-gradient(145deg, #ffba6e 0%, #f96322 100%); border-bottom: 9px solid #c74000; box-shadow: 0 9px 0 #c74000, 0 14px 24px rgba(199,64,0,.22); }
.b-jade   { background: linear-gradient(145deg, #56ebc7 0%, #17b898 100%); border-bottom: 9px solid #0e8870; box-shadow: 0 9px 0 #0e8870, 0 14px 24px rgba(14,136,112,.22); }
.b-navy   { background: linear-gradient(145deg, #7b9ef8 0%, #3d5fce 100%); border-bottom: 9px solid #2440a0; box-shadow: 0 9px 0 #2440a0, 0 14px 24px rgba(36,64,160,.22); }
.b-indigo { background: linear-gradient(145deg, #a89fff 0%, #6c4ef2 100%); border-bottom: 9px solid #4520c8; box-shadow: 0 9px 0 #4520c8, 0 14px 24px rgba(69,32,200,.22); }
.b-coral  { background: linear-gradient(145deg, #ff8f8f 0%, #f02020 100%); border-bottom: 9px solid #b80000; box-shadow: 0 9px 0 #b80000, 0 14px 24px rgba(184,0,0,.22); }
.b-sky    { background: linear-gradient(145deg, #52d7f8 0%, #0ea5e9 100%); border-bottom: 9px solid #0872b0; box-shadow: 0 9px 0 #0872b0, 0 14px 24px rgba(8,114,176,.22); }
.b-forest { background: linear-gradient(145deg, #6ee87c 0%, #16a34a 100%); border-bottom: 9px solid #0a6e30; box-shadow: 0 9px 0 #0a6e30, 0 14px 24px rgba(10,110,48,.22); }
.b-lime   { background: linear-gradient(145deg, #b8fc6a 0%, #72c800 100%); border-bottom: 9px solid #4e9000; box-shadow: 0 9px 0 #4e9000, 0 14px 24px rgba(78,144,0,.22); color: #2a4800; text-shadow: none; }

/* Active press: collapse the 3D shadow  */
.big-btn:active {
  transform: translateY(9px) scale(0.97);
  border-bottom-width: 1px !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.18) !important;
}

/* ── Game screen backgrounds — richer than before ── */
.spellit    { background: linear-gradient(150deg, #e0f2fe 0%, #bae6fd 50%, #e8f4fe 100%); }
.countadd   { background: linear-gradient(150deg, #fef9c3 0%, #fde68a 50%, #fff3c0 100%); }
.sortit     { background: linear-gradient(150deg, #dcfce7 0%, #bbf7d0 50%, #e8fdf0 100%); }
.animalguess{ background: linear-gradient(150deg, #fce7f3 0%, #fbcfe8 50%, #fde8f4 100%); }
.colorquest { background: linear-gradient(150deg, #f3e8ff 0%, #e9d5ff 50%, #f5eeff 100%); }

/* ── Character name tags on home companions ── */
.char-name-tag {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: clamp(9px, 1.2vw, 13px);
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(0,0,0,.18);
  white-space: nowrap;
  pointer-events: none;
}

/* ── Character wrappers with name tags ── */
.sky-char-wrap {
  position: absolute;
  pointer-events: none;
}
.sky-char-wrap.pip-wrap    { bottom: 0; left: 2%; }
.sky-char-wrap.goldie-wrap { bottom: 0; right: 3%; }
.sky-char-wrap.ziggy-wrap  { bottom: 8%; left: 14%; }

/* ── Companion character in game screens ── */
.game-companion {
  position: absolute;
  bottom: 14px; right: 14px;
  width: clamp(60px, 8.5vw, 92px);
  pointer-events: none;
  animation: char-bob 3.2s ease-in-out infinite;
  z-index: 5;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.2));
}
.game-companion.left  { right: auto; left: 14px; }
.game-companion svg { width: 100%; height: auto; display: block; }

/* Companion speech bubble */
.companion-bubble {
  position: absolute;
  bottom: calc(clamp(60px, 8.5vw, 92px) + 14px + 6px);
  right: 14px;
  background: white;
  border-radius: 16px 16px 4px 16px;
  padding: 7px 14px;
  font-size: clamp(11px, 1.4vw, 14px);
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(45,27,107,.16);
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transform: scale(0.8) translateY(8px);
  transition: opacity .3s var(--ease-pop), transform .3s var(--ease-pop);
}
.companion-bubble.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* ── Profiles screen premium upgrade ── */
.course-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 56px);
  letter-spacing: 0.02em;
  text-shadow: 0 4px 0 rgba(45,27,107,.12);
}
.profile-card {
  border: 4px solid rgba(255,255,255,.8);
  box-shadow: 0 12px 0 rgba(45,27,107,.16), 0 18px 36px rgba(45,27,107,.14);
  transition: transform .15s var(--ease-pop), box-shadow .15s;
}
.profile-card:active {
  transform: translateY(8px) scale(.97);
  box-shadow: 0 4px 0 rgba(45,27,107,.16), 0 6px 12px rgba(45,27,107,.10);
}

/* ── Hint button upgrade ── */
.hint-btn {
  background: linear-gradient(145deg, #fff27a, #ffd000) !important;
  border-bottom: 5px solid #c8a000 !important;
  box-shadow: 0 5px 0 #c8a000, 0 8px 16px rgba(200,160,0,.22) !important;
  color: #6b4a00 !important;
  font-weight: 900 !important;
}
.hint-btn.hint-used {
  background: linear-gradient(145deg, #e8e8e8, #d0d0d0) !important;
  border-bottom: 5px solid #aaaaaa !important;
  box-shadow: 0 5px 0 #aaaaaa !important;
  color: #888 !important;
}

/* ── Spell It upgrade — bigger letters, better slots ── */
.si-letter {
  width: clamp(68px, 9.5vw, 84px);
  height: clamp(68px, 9.5vw, 84px);
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 40px);
  border-radius: 20px;
  box-shadow: 0 7px 0 rgba(0,0,0,.24), 0 10px 20px rgba(45,27,107,.16);
  transition: transform .1s var(--ease-pop), box-shadow .1s;
}
.si-slot {
  width: clamp(68px, 9.5vw, 84px);
  height: clamp(76px, 10.5vw, 92px);
  font-family: var(--font-display);
  font-size: clamp(30px, 4.8vw, 44px);
  border-radius: 20px;
  border: 4px dashed #94a3b8;
}
.si-slot-active {
  border-style: solid;
  border-color: var(--sun);
  background: linear-gradient(180deg, #fff9e6, #fff3c0);
  box-shadow: 0 0 0 5px rgba(255,184,48,.30), 0 4px 12px rgba(255,184,48,.20);
}
.si-slot-filled {
  border-style: solid;
  border-color: var(--lime);
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
}

/* ── Count & Add upgrade ── */
.ca-choice {
  border-radius: 24px;
  box-shadow: 0 7px 0 rgba(0,0,0,.20), 0 10px 20px rgba(45,27,107,.14);
  font-family: var(--font-display);
}
.ca-choice-num { font-family: var(--font-display); }

/* ── Sort It upgrade ── */
.sg-bucket {
  border-radius: 28px;
  border: 4px solid rgba(16,185,129,.5);
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.6), 0 6px 20px rgba(45,27,107,.12);
}

/* ── Progress strip upgrade ── */
.prog-strip {
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 4px 20px rgba(45,27,107,.14);
}

/* ── Story/Logic/Words body fix ── */
.story-body, .logic-body, .words-body, .wq-body, .memory-body, .music-body {
  flex: 1; min-height: 0;
}

/* ============================================================
   FULLSCREEN MODE — browser Fullscreen API
   (:fullscreen) fills the whole display, lifts 4:3 cap,
   scales up fonts, and adds more menu columns on wide screens.
   ============================================================ */

/* Stage: fill the entire display */
:fullscreen .stage,
:-webkit-full-screen .stage {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Lift 4:3 cap for the body background so no letterbox bars show */
:fullscreen body,
:-webkit-full-screen body {
  background: #1a0a3a;
}

/* Scale up design tokens proportionally */
:fullscreen,
:-webkit-full-screen {
  --text-hero:   clamp(60px, 10vw, 140px);
  --text-title:  clamp(26px, 4vw, 54px);
  --text-btn:    clamp(15px, 2vw, 26px);
  --text-label:  clamp(13px, 1.5vw, 20px);
  --text-number: clamp(54px, 10vw, 120px);
}

/* Home screen: bigger mascot, logo, and greeting */
:fullscreen .mascot,
:-webkit-full-screen .mascot { font-size: clamp(80px, 12vw, 160px); }

:fullscreen .logo,
:-webkit-full-screen .logo   { font-size: clamp(56px, 9vw, 110px); }

:fullscreen .hi-chip,
:-webkit-full-screen .hi-chip { font-size: clamp(16px, 2.2vw, 26px); padding: 10px 22px; }

:fullscreen .tool-btn,
:-webkit-full-screen .tool-btn { min-width: 54px; height: 54px; font-size: 22px; }

/* Menu: 5 cols by default; 6 on very wide screens */
:fullscreen .menu,
:-webkit-full-screen .menu {
  grid-template-columns: repeat(5, 1fr);
  width: min(96%, 1200px);
  gap: clamp(12px, 2vw, 28px);
}

:fullscreen .big-btn,
:-webkit-full-screen .big-btn {
  padding: clamp(18px, 3vh, 32px) 10px clamp(14px, 2.5vh, 26px);
  border-radius: 28px;
  font-size: clamp(13px, 1.6vw, 20px);
  border-bottom-width: 10px;
}

:fullscreen .big-btn-emoji,
:-webkit-full-screen .big-btn-emoji { font-size: 2.6em; }

/* Progress strip */
:fullscreen .prog-strip,
:-webkit-full-screen .prog-strip { max-width: 900px; padding: 12px 24px; gap: 18px; }

:fullscreen .prog-streak,
:fullscreen .prog-level,
:-webkit-full-screen .prog-streak,
:-webkit-full-screen .prog-level { font-size: 16px; padding: 6px 14px; }

/* Scene characters: larger on big screen */
:fullscreen .sc-penguin,
:-webkit-full-screen .sc-penguin { width: clamp(80px, 9vw, 140px); }

:fullscreen .sc-duck,
:-webkit-full-screen .sc-duck    { width: clamp(76px, 8.5vw, 136px); }

:fullscreen .sc-squirrel,
:-webkit-full-screen .sc-squirrel { width: clamp(72px, 8vw, 130px); }

/* Game bar */
:fullscreen .bar,
:-webkit-full-screen .bar { padding: 14px 24px; min-height: 68px; }

:fullscreen .bar-title,
:-webkit-full-screen .bar-title { font-size: clamp(20px, 3vw, 36px); }

:fullscreen .back-btn,
:-webkit-full-screen .back-btn { width: 56px; height: 56px; font-size: 26px; }

:fullscreen .score-pill,
:-webkit-full-screen .score-pill { font-size: clamp(16px, 2vw, 24px); padding: 8px 18px; }

/* Learn / Feature card */
:fullscreen .feature-letter,
:-webkit-full-screen .feature-letter { font-size: clamp(110px, 22vh, 260px); }

:fullscreen .feature-pic,
:-webkit-full-screen .feature-pic    { font-size: clamp(64px, 12vh, 130px); }

:fullscreen .feature-word,
:-webkit-full-screen .feature-word   { font-size: clamp(30px, 5vh, 60px); }

/* Spell It */
:fullscreen .si-slot,
:-webkit-full-screen .si-slot {
  width: clamp(66px, 8vw, 110px);
  height: clamp(70px, 8.5vw, 116px);
  font-size: clamp(28px, 4vw, 54px);
}
:fullscreen .si-letter,
:-webkit-full-screen .si-letter {
  width: clamp(66px, 8vw, 110px);
  height: clamp(66px, 8vw, 110px);
  font-size: clamp(26px, 3.8vw, 50px);
}
:fullscreen .si-picture,
:-webkit-full-screen .si-picture { font-size: clamp(80px, 16vw, 160px); }

/* Hunt / Word quiz choices */
:fullscreen .hunt-option,
:-webkit-full-screen .hunt-option { font-size: clamp(50px, 9vw, 110px); }

/* Numbers */
:fullscreen .num-big,
:-webkit-full-screen .num-big { font-size: clamp(110px, 26vh, 300px); }

:fullscreen .num-thing,
:-webkit-full-screen .num-thing { font-size: clamp(38px, 6vw, 70px); }

/* Abacus */
:fullscreen .abacus-frame,
:-webkit-full-screen .abacus-frame { --bd: clamp(34px, 6vw, 66px); }

/* Story reader */
:fullscreen .story-scene,
:-webkit-full-screen .story-scene { font-size: clamp(90px, 18vh, 180px); }

:fullscreen .story-text,
:-webkit-full-screen .story-text  { font-size: clamp(20px, 3vw, 36px); max-width: min(820px, 80%); }

:fullscreen .story-end-card,
:-webkit-full-screen .story-end-card { max-width: min(640px, 80vw); }

/* Reward screen */
:fullscreen .reward-emoji,
:-webkit-full-screen .reward-emoji { font-size: clamp(100px, 20vw, 220px); }

/* Extra wide (≥ 1600px in fullscreen): 6-column menu */
@media (min-width: 1600px) {
  :fullscreen .menu,
  :-webkit-full-screen .menu { grid-template-columns: repeat(6, 1fr); width: min(96%, 1440px); }
}

/* ============================================================
   MOBILE BREAKPOINT — 480px and below (iPhone support)
   ============================================================ */
@media (max-width: 480px) {
  /* Stage fills full screen — no 4:3 letterbox */
  .stage {
    width: 100vw !important;
    height: 100dvh !important;
    position: fixed;
    inset: 0;
  }

  /* 3-column menu on small phones */
  .menu { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .big-btn {
    padding: 10px 4px 8px;
    border-radius: 20px;
    font-size: 10px;
    border-bottom-width: 6px;
  }
  .big-btn-emoji { font-size: clamp(22px, 7.5vw, 34px); }

  /* Logo shrinks */
  .logo   { font-size: clamp(28px, 9vw, 48px); }
  .mascot { font-size: clamp(40px, 11vw, 60px); }

  /* Hide companions and floating deco on tiny screens */
  .sc-squirrel, .sc-penguin, .sc-duck { display: none !important; }
  .deco-balloon { display: none !important; }
  .game-companion { width: 52px; bottom: 8px; right: 8px; }
  .companion-bubble { display: none; }

  /* Home top bar compact */
  .home-top { padding: 8px 10px; gap: 6px; }
  .hi-chip { font-size: 13px; padding: 6px 12px; white-space: nowrap; }
  .top-tools { gap: 6px; }
  .tool-btn { min-width: 40px; height: 40px; font-size: 15px; }
  #fs-btn { display: none; } /* fullscreen redundant on mobile */

  /* Bar compact */
  .bar { padding: 6px 10px; gap: 8px; min-height: 50px; }
  .back-btn { width: 44px; height: 44px; font-size: 18px; }
  .bar-title { font-size: clamp(14px, 4.5vw, 20px); }

  /* Fix bar overflow on small screens */
  .score-pill { padding: 5px 10px; font-size: 14px; }
  .hint-btn   { padding: 5px 10px !important; font-size: 13px !important; }

  /* Spell It */
  .si-body { gap: 12px; padding: 10px 12px; }
  .si-picture { font-size: clamp(60px, 18vw, 88px); }
  .si-slot  { width: clamp(52px, 15vw, 68px); height: clamp(58px, 16vw, 74px); font-size: clamp(22px, 6.5vw, 34px); }
  .si-letter { width: clamp(52px, 15vw, 68px); height: clamp(52px, 15vw, 68px); font-size: clamp(20px, 6vw, 30px); }

  /* Count & Add */
  .ca-choices { width: min(300px, 92vw); }
  .ca-choice-num { font-size: clamp(28px, 9vw, 40px); }
  .ca-objects { max-width: 92vw; }

  /* Sort It */
  .sg-buckets { flex-direction: column; align-items: center; gap: 10px; }
  .sg-bucket  { width: min(88vw, 300px); height: 90px; }
  .sg-progress-bar { width: min(280px, 86vw); }
  .sg-item-emoji { font-size: clamp(60px, 18vw, 88px); }

  /* Progress strip */
  .prog-strip { gap: 8px; padding: 7px 12px; max-width: 96vw; }
  .prog-streak, .prog-level { font-size: 11px; padding: 3px 7px; }
}

/* ─── Finish button ─── */
.draw-finish-btn {
  background: linear-gradient(135deg, #00c9a7, #3aa0ff);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  transition: transform .15s, box-shadow .15s;
  white-space: nowrap;
}
.draw-finish-btn:active { transform: scale(.94); box-shadow: none; }

/* ─── Finish overlay ─── */
.screen.draw { position: relative; }

.finish-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #fff8f0 0%, #ffd6e8 45%, #c3e8ff 100%);
  gap: 20px;
  padding: 20px;
}
.finish-overlay.hidden { display: none; }

.finish-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

/* Speech bubble */
.finish-bubble {
  position: relative;
  background: #fff;
  border: 3px solid #ffb347;
  border-radius: 22px;
  padding: 10px 22px;
  font-size: 22px;
  font-weight: 800;
  color: #ff5c8d;
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
  white-space: nowrap;
}
.finish-bubble::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-top-color: #ffb347;
}
.finish-bubble::before {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
  z-index: 1;
}
.finish-bubble.hidden { display: none; }

/* Character + hand wrap */
.finish-char-wrap {
  position: relative;
  display: inline-block;
}
.finish-char {
  display: block;
  width: min(55vw, 340px);
  height: min(55vw, 340px);
  object-fit: contain;
  transform-origin: bottom center;
  border-radius: 14px;
  box-shadow: 0 10px 36px rgba(0,0,0,.28), 0 3px 10px rgba(0,0,0,.15);
}
.finish-hand {
  position: absolute;
  top: 18%;
  right: -12px;
  font-size: clamp(28px, 7vw, 44px);
  transform-origin: bottom center;
  pointer-events: none;
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,.2));
}

/* Action buttons */
.finish-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.big-btn {
  border: none;
  border-radius: 22px;
  padding: 14px 28px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0,0,0,.22);
  transition: transform .15s, box-shadow .15s;
}
.big-btn:active { transform: scale(.93); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.b-orange { background: linear-gradient(135deg,#ff8c3b,#ff5cc4); color:#fff; }
.b-blue   { background: linear-gradient(135deg,#3aa0ff,#7a5cff); color:#fff; }

/* ─── Finish animations ─── */
@keyframes char-enter {
  0%   { opacity:0; transform: scale(.3) translateY(40px) rotate(-6deg); }
  70%  { transform: scale(1.1) translateY(-10px) rotate(2deg); }
  100% { opacity:1; transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes char-float {
  0%,100% { transform: translateY(0)    rotate(-1deg); }
  50%      { transform: translateY(-14px) rotate(1deg); }
}
@keyframes hand-wave {
  0%,100% { transform: rotate(0deg); }
  20%     { transform: rotate(30deg); }
  40%     { transform: rotate(-10deg); }
  60%     { transform: rotate(28deg); }
  80%     { transform: rotate(-6deg); }
}
@keyframes bubble-pop {
  0%   { opacity:0; transform: scale(.4); }
  70%  { transform: scale(1.12); }
  100% { opacity:1; transform: scale(1); }
}
@keyframes bubble-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

.finish-char.fc-entering {
  animation: char-enter .85s cubic-bezier(.34,1.56,.64,1) both;
}
.finish-char.fc-floating {
  animation: char-float 3s ease-in-out infinite;
}
.finish-hand.fh-waving {
  animation: hand-wave 1.2s ease-in-out 3;
}
.finish-bubble.fb-popping {
  animation: bubble-pop .6s cubic-bezier(.34,1.56,.64,1) both;
}
.finish-bubble.fb-floating {
  animation: bubble-float 2.4s ease-in-out infinite;
}

/* ── Celebration video background ── */
.finish-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.32;
  z-index: 0;
  pointer-events: none;
}
.finish-stage, .finish-actions { position: relative; z-index: 1; }

/* ── Gallery button colour ── */
.b-purple { background: linear-gradient(135deg,#a855f7,#7c3aed); color:#fff; }
.b-gallery { background: linear-gradient(135deg,#f472b6,#a855f7); color:#fff; }
#finish-gallery.hidden { display: none; }

/* ════════════════════════════════════════════
   MY GALLERY SCREEN
════════════════════════════════════════════ */
.screen.gallery {
  background: linear-gradient(160deg, #fff8f0 0%, #fce7f3 55%, #ede9fe 100%);
  flex-direction: column;
}
.gallery-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gallery-empty {
  margin-top: 60px;
  font-size: 22px;
  color: #a78bfa;
  font-weight: 700;
  text-align: center;
  line-height: 1.6;
}
.gallery-empty.hidden { display: none; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 900px;
}
.gallery-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,.14);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}
.gallery-card:hover { transform: translateY(-4px); box-shadow: 0 8px 28px rgba(0,0,0,.2); }
.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.gallery-card-footer {
  padding: 8px 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-card-name { font-size: 13px; font-weight: 800; color: #7c3aed; }
.gallery-card-date { font-size: 11px; color: #9ca3af; }
.gallery-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(239,68,68,.85);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: transform .15s;
}
.gallery-delete:active { transform: scale(.88); }

/* ── Full-screen artwork viewer ── */
.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gv-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  width: 100%;
}
.gv-img {
  width: 100%;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,.5);
}
.gv-label {
  color: #ffd700;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}
.gv-btns {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.gv-download { text-decoration: none; display: inline-flex; align-items: center; }

/* ============================================================
   HOME REDESIGN — BENTO GRID + TROPICAL SCENE (2026-06)
   ============================================================ */

/* Wide tiles: landscape orientation, span 2 columns */
.menu-grid .btn-wide {
  grid-column: span 2;
  flex-direction: row;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 16px);
  padding: clamp(8px, 1.5vh, 16px) clamp(12px, 1.8vw, 24px);
}
.menu-grid .btn-wide .big-btn-emoji {
  font-size: clamp(28px, 4.2vw, 50px);
  line-height: 1;
}
.menu-grid .btn-wide .big-btn-text {
  font-size: clamp(14px, 1.9vw, 22px);
  text-align: left;
  line-height: 1.2;
}

/* Flagship gradients for wide tiles */
.menu-grid .btn-wide.b-pink {
  background: linear-gradient(135deg, #ff9bd0 0%, #e0288e 55%, #b01060 100%);
  border-bottom-color: #880048;
}
.menu-grid .btn-wide.b-orange {
  background: linear-gradient(135deg, #ffd04a 0%, #ff7c18 50%, #d44a00 100%);
  border-bottom-color: #962000;
}
.menu-grid .btn-wide.b-gallery {
  background: linear-gradient(135deg, #f478c0 0%, #c026d3 50%, #7c1cce 100%);
  border-bottom-color: #4a0a8a;
}

/* Palm tree island decorations — positioned in the sky area, visible above the grid */
.deco-palm {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(3px 6px 10px rgba(0,0,0,.28));
}
/* Palm tops sit in the sky, trunks extend down */
.palm-l {
  left: 0%;
  top: 5%;
  width: clamp(70px, 9vw, 128px);
}
.palm-r {
  right: 0%;
  top: 10%;
  width: clamp(62px, 8vw, 114px);
  transform: scaleX(-1);
  transform-origin: right center;
}

/* Prog bar improvements */
.prog-bar { height: 12px !important; border-radius: 8px !important; }
.prog-strip {
  background: rgba(255,255,255,.85) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.9) !important;
}

/* ============================================================
   FINISH — DANCE ANIMATIONS (2026-06)
   ============================================================ */

/* Phase 2 — energetic bounce dance */
@keyframes char-dance {
  0%   { transform: translateY(0)     rotate(-4deg)  scale(1);    }
  12%  { transform: translateY(-30px) rotate( 6deg)  scale(1.10); }
  22%  { transform: translateY(-6px)  rotate(-7deg)  scale(0.94); }
  35%  { transform: translateY(-26px) rotate( 7deg)  scale(1.09); }
  47%  { transform: translateY(-4px)  rotate(-6deg)  scale(0.96); }
  60%  { transform: translateY(-28px) rotate( 5deg)  scale(1.10); }
  72%  { transform: translateY(-5px)  rotate(-6deg)  scale(0.95); }
  85%  { transform: translateY(-22px) rotate( 5deg)  scale(1.07); }
  100% { transform: translateY(0)     rotate(-4deg)  scale(1);    }
}

/* Phase 3 — twirl / spin */
@keyframes char-twirl {
  0%   { transform: scale(1)    rotate(0deg);   }
  18%  { transform: scale(1.15) rotate(-30deg); }
  42%  { transform: scale(0.88) rotate(360deg); }
  65%  { transform: scale(1.14) rotate(700deg); }
  82%  { transform: scale(1.06) rotate(710deg); }
  100% { transform: scale(1)    rotate(720deg); }
}

/* Big wave — used during dance + twirl phases */
@keyframes hand-wave-big {
  0%,100% { transform: rotate(0deg)   scale(1);    }
  8%      { transform: rotate(48deg)  scale(1.35); }
  22%     { transform: rotate(-22deg) scale(1.15); }
  38%     { transform: rotate(52deg)  scale(1.35); }
  54%     { transform: rotate(-28deg) scale(1.18); }
  70%     { transform: rotate(46deg)  scale(1.32); }
  85%     { transform: rotate(-14deg) scale(1.12); }
}

/* Gallery button bounce-in */
@keyframes gallery-btn-appear {
  0%   { opacity:0; transform: scale(0.35) translateY(24px) rotate(-12deg); }
  55%  { transform: scale(1.18) translateY(-6px) rotate(3deg);  }
  75%  { transform: scale(0.94) translateY(3px)  rotate(-1deg); }
  90%  { transform: scale(1.05) translateY(-2px) rotate(1deg);  }
  100% { opacity:1; transform: scale(1)    translateY(0)   rotate(0deg);  }
}

/* Apply classes */
.finish-char.fc-dancing  { animation: char-dance  3.1s ease-in-out infinite; }
.finish-char.fc-twirling { animation: char-twirl  3s   cubic-bezier(.34,1.2,.64,1) forwards; }
.finish-hand.fh-waving-big { animation: hand-wave-big 0.9s ease-in-out infinite; }

#finish-gallery.fc-btn-appear {
  animation: gallery-btn-appear 0.75s cubic-bezier(.34,1.56,.64,1) both;
}
