/* Layout: one centered column (max 1080px). Each game plays inside a fixed-height "stage" scene
   where pieces are placed in % so the scene scales from phones to classroom screens. */
:root {
  /* Surfaces & text */
  --bg: #E8F2E2;
  --surface: #FFFFFF;
  --surface-2: #F2F8EE;
  --fg: #163124;
  --fg-muted: #496453;
  --line: rgba(22, 49, 36, 0.12);
  --topbar-bg: rgba(240, 247, 236, 0.7);

  /* Accent (mango) and states */
  --accent: #E07B00;
  --accent-strong: #C76C00;
  --accent-ink: #231300;
  --focus: #0B6E99;
  --focus-tv: #FFB300;
  --good: #1F7F4A;
  --bad: #C0264E;
  --star: #F2B51C;
  --star-empty: rgba(22, 49, 36, 0.24);
  --sheen: rgba(255, 255, 255, 0.10);
  --sheen-strong: rgba(255, 255, 255, 0.32);
  --shade: rgba(10, 30, 20, 0.18);

  /* Premium layer: glass, gold, hero banner, deeper shadows */
  --accent-hi: #FFA63D;
  --accent-glow: rgba(224, 123, 0, 0.55);
  --accent-soft: rgba(224, 123, 0, 0.14);
  --accent-deep: #8F4700;
  --glass: rgba(255, 255, 255, 0.66);
  --glass-line: rgba(255, 255, 255, 0.9);
  --gold-1: #FFE07A;
  --gold-2: #F5A70F;
  --gold-soft-1: #FFF7DB;
  --gold-soft-2: #FFEBB0;
  --gold-line: rgba(214, 150, 20, 0.32);
  --gold-ink: #5A3A00;
  --hero-1: #1F7D45;
  --hero-2: #0A3B22;
  --hero-leaf-1: rgba(130, 210, 100, 0.26);
  --hero-leaf-2: rgba(30, 120, 60, 0.5);
  --hero-ink: #FFFFFF;
  --hero-muted: rgba(255, 255, 255, 0.84);
  --bg-glow-1: rgba(255, 205, 110, 0.38);
  --bg-glow-2: rgba(95, 190, 120, 0.32);
  --bg-glow-3: rgba(80, 170, 200, 0.18);

  /* Scenes */
  --sky-top: #BFE4F0;
  --sky-bottom: #DCF0D0;
  --canopy-1: #4E9F57;
  --canopy-2: #2F7C44;
  --canopy-3: #6DBA5E;
  --trunk: #7A5232;
  --leaf-1: #3E964C;
  --leaf-2: #58AE58;
  --leaf-ink: #2C7A3C;
  --leaf-found: #F6C343;
  --water-1: #5BC0C6;
  --water-2: #2F98A3;
  --bank: #8BC867;
  --savanna-1: #F1DC9E;
  --savanna-2: #E0BF78;
  --stone: #CCC6B9;
  --stone-2: #ADA696;
  --stone-ink: #2F2A22;
  --wood: #B9773D;
  --wood-2: #8E5728;
  --wood-ink: #FFF7EA;
  --lily-1: #4FA144;
  --lily-2: #367C2F;
  --lily-ink: #FFFFFF;

  /* Characters (same in both themes: they are illustrations) */
  --art-ink: #1C1C1C;
  --art-white: #FFFFFF;
  --parrot-red: #E5383B;
  --parrot-blue: #2D7DD2;
  --parrot-yellow: #F7C548;
  --beak: #F4A259;
  --monkey: #8E5A2E;
  --monkey-face: #EFC99B;
  --frog: #5DBB4A;
  --frog-dark: #2F7D32;
  --frog-belly: #CDEB9F;
  --blush: rgba(242, 110, 140, 0.45);
  --lion: #E3A43E;
  --mane: #A85D1C;
  --cham-start: #46B05A;
  --cham-end: #F2812B;
  --cham-color: var(--cham-start);
  --tongue: #F0708E;
  --croc: #5E9E3A;
  --croc-dark: #3D6E24;
  --croc-belly: #D9E59A;
  --iris: #EBDD8A;
  --beak-ivory: #EFE6D2;
  --beak-dark: #2E2B2A;
  --parrot-deep: #173E8C;
  --parrot-green: #4E9B45;
  --fog: #B9CCD6;
  --sky-gain: 0.42;
  --water-deep: #1E4A3E;
  --exposure: 0.7;
  --env-intensity: 0.55;
  --grass-dark: #2B4418;
  --grass-light: #8FA845;
  --soil: #5A4630;
  --foliage-dark: #1E4519;
  --foliage-light: #78A23C;
  --mouth: #5A1F12;
  --night: 0;

  /* 3D lighting (numbers are read by js/3d/engine.js) */
  --sun-color: #FFF1D6;
  --sun-intensity: 4.2;
  --ambient-intensity: 0.25;
  /* Fill light colours for the 3D scenes (kept apart from the UI colours so night can stay bright) */
  --hemi-sky: #BFE4F0;
  --hemi-ground: #8BC867;
  --fruit-1: #FF9F1C;
  --fruit-2: #FFC67A;
  --fruit-ink: #3A1F00;

  /* Type */
  --font-display: "Baloo 2", "Baloo Bhaijaan 2", -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --text-sm: 15px;
  --text-base: 17px;
  --text-lg: 20px;
  --text-title: clamp(22px, 4vw, 30px);
  --text-hero: clamp(36px, 7vw, 56px);

  /* Shape, depth, motion */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --radius-control: 12px;
  --radius-card: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(10, 30, 20, 0.06), 0 2px 8px rgba(10, 30, 20, 0.06);
  --shadow-2: 0 1px 2px rgba(10, 30, 20, 0.05), 0 8px 20px -6px rgba(10, 30, 20, 0.14), 0 24px 48px -24px rgba(10, 30, 20, 0.2);
  --shadow-3: 0 2px 4px rgba(10, 30, 20, 0.06), 0 18px 40px -12px rgba(10, 30, 20, 0.28), 0 44px 80px -32px rgba(10, 30, 20, 0.32);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-flight: 700ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1B14; --surface: #14271D; --surface-2: #1A3125; --fg: #E4F1E6; --fg-muted: #9CB8A6;
    --line: rgba(228, 241, 230, 0.12); --topbar-bg: rgba(13, 27, 20, 0.72);
    --accent: #F29A2E; --accent-strong: #FFB04D; --focus: #5CB8E6; --good: #4CC27E; --bad: #F0708A;
    --star: #F5C04A; --star-empty: rgba(228, 241, 230, 0.3); --sheen: rgba(255, 255, 255, 0.05);
    --sky-top: #0E2236; --sky-bottom: #143424; --canopy-1: #2C6B3A; --canopy-2: #1C4F2B; --canopy-3: #3B824A;
    --trunk: #4E341F; --leaf-1: #2B7039; --leaf-2: #378547; --leaf-ink: #20592C; --leaf-found: #F2B53A;
    --water-1: #1F6E78; --water-2: #154E57; --bank: #2E5C30; --savanna-1: #3A3320; --savanna-2: #2D2817;
    --stone: #6E685C; --stone-2: #57524A; --stone-ink: #F6F1E8; --wood: #8A5A2E; --wood-2: #6B4321;
    --lily-1: #3F8A37; --lily-2: #2C6627;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
    --sun-color: #E2EAFF; --sun-intensity: 4.4; --ambient-intensity: 2.6; --night: 1; --fog: #2C4258; --exposure: 1.45; --env-intensity: 1.35; --hemi-sky: #9DB6E6; --hemi-ground: #4E7D52;
    --accent-hi: #FFB75C; --accent-glow: rgba(242, 154, 46, 0.45); --accent-soft: rgba(242, 154, 46, 0.16); --accent-deep: #FFC883;
    --glass: rgba(22, 42, 31, 0.62); --glass-line: rgba(255, 255, 255, 0.08);
    --gold-soft-1: rgba(245, 192, 74, 0.2); --gold-soft-2: rgba(245, 192, 74, 0.1); --gold-line: rgba(245, 192, 74, 0.3); --gold-ink: #FFE2A0;
    --hero-1: #17532F; --hero-2: #06180E; --hero-leaf-1: rgba(90, 170, 90, 0.16); --hero-leaf-2: rgba(25, 100, 55, 0.4);
    --bg-glow-1: rgba(255, 190, 80, 0.09); --bg-glow-2: rgba(60, 160, 100, 0.14); --bg-glow-3: rgba(60, 120, 200, 0.1);
    --shadow-3: 0 2px 4px rgba(0, 0, 0, 0.3), 0 20px 44px -12px rgba(0, 0, 0, 0.6), 0 44px 80px -32px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1B14; --surface: #14271D; --surface-2: #1A3125; --fg: #E4F1E6; --fg-muted: #9CB8A6;
  --line: rgba(228, 241, 230, 0.12); --topbar-bg: rgba(13, 27, 20, 0.72);
  --accent: #F29A2E; --accent-strong: #FFB04D; --focus: #5CB8E6; --good: #4CC27E; --bad: #F0708A;
  --star: #F5C04A; --star-empty: rgba(228, 241, 230, 0.3); --sheen: rgba(255, 255, 255, 0.05);
  --sky-top: #0E2236; --sky-bottom: #143424; --canopy-1: #2C6B3A; --canopy-2: #1C4F2B; --canopy-3: #3B824A;
  --trunk: #4E341F; --leaf-1: #2B7039; --leaf-2: #378547; --leaf-ink: #20592C; --leaf-found: #F2B53A;
  --water-1: #1F6E78; --water-2: #154E57; --bank: #2E5C30; --savanna-1: #3A3320; --savanna-2: #2D2817;
  --stone: #6E685C; --stone-2: #57524A; --stone-ink: #F6F1E8; --wood: #8A5A2E; --wood-2: #6B4321;
  --lily-1: #3F8A37; --lily-2: #2C6627;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  --sun-color: #E2EAFF; --sun-intensity: 4.4; --ambient-intensity: 2.6; --night: 1; --fog: #2C4258; --exposure: 1.45; --env-intensity: 1.35; --hemi-sky: #9DB6E6; --hemi-ground: #4E7D52;
  --accent-hi: #FFB75C; --accent-glow: rgba(242, 154, 46, 0.45); --accent-soft: rgba(242, 154, 46, 0.16); --accent-deep: #FFC883;
  --glass: rgba(22, 42, 31, 0.62); --glass-line: rgba(255, 255, 255, 0.08);
  --gold-soft-1: rgba(245, 192, 74, 0.2); --gold-soft-2: rgba(245, 192, 74, 0.1); --gold-line: rgba(245, 192, 74, 0.3); --gold-ink: #FFE2A0;
  --hero-1: #17532F; --hero-2: #06180E; --hero-leaf-1: rgba(90, 170, 90, 0.16); --hero-leaf-2: rgba(25, 100, 55, 0.4);
  --bg-glow-1: rgba(255, 190, 80, 0.09); --bg-glow-2: rgba(60, 160, 100, 0.14); --bg-glow-3: rgba(60, 120, 200, 0.1);
  --shadow-3: 0 2px 4px rgba(0, 0, 0, 0.3), 0 20px 44px -12px rgba(0, 0, 0, 0.6), 0 44px 80px -32px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(900px 600px at 100% -5%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 700px at -10% 30%, var(--bg-glow-2), transparent 60%),
    radial-gradient(900px 700px at 60% 110%, var(--bg-glow-3), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
:root[lang="ar"] body, :root[lang="ary"] body { font-family: "Baloo Bhaijaan 2", var(--font-body); }
button, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus { outline: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.wrap {
  width: 100%;
  max-width: none; /* full screen: the app uses the whole window width */
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) {
  .wrap {
    padding-left: max(clamp(24px, 3vw, 56px), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(24px, 3vw, 56px), env(safe-area-inset-right, 0px));
  }
}

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 46px; padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 16px; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 1px 2px rgba(120, 60, 0, 0.25), 0 10px 24px -8px var(--accent-glow);
}
.btn-secondary { background: var(--glass); color: var(--fg); border-color: var(--glass-line); box-shadow: var(--shadow-1); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-sm { min-height: 40px; padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn-lg { min-height: 56px; padding: 0 var(--space-6); font-size: 18px; }
.btn svg { flex: none; }
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.05) saturate(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(120, 60, 0, 0.25), 0 16px 32px -10px var(--accent-glow); transform: translateY(-1px); }
  .btn-secondary:hover, .btn-ghost:hover { background: var(--surface-2); }
}

.icon-btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--glass-line); border-radius: 14px;
  background: var(--glass); color: var(--fg); cursor: pointer; box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface); } }

.select-wrap { position: relative; }
.select {
  appearance: none; -webkit-appearance: none;
  height: 44px; padding-inline: var(--space-4) 36px;
  border: 1px solid var(--glass-line); border-radius: 14px;
  background: var(--glass); box-shadow: var(--shadow-1); font-size: var(--text-sm); font-weight: 600; cursor: pointer;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.select-icon {
  position: absolute; inset-inline-end: 12px; top: 50%; translate: 0 -50%;
  display: grid; pointer-events: none; color: var(--fg-muted);
}

.pill {
  display: inline-flex; align-items: center; margin-inline-start: var(--space-2);
  height: 22px; padding: 0 10px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent-deep);
  font-size: 12px; font-weight: 800; letter-spacing: 0.02em;
}

.stars { display: inline-flex; gap: 3px; }
.star { width: 20px; height: 20px; fill: var(--star-empty); }
.star.is-on { fill: var(--star); filter: drop-shadow(0 1px 2px rgba(180, 110, 0, 0.35)); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  backdrop-filter: saturate(1.8) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 68px; }
.brand {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px; min-width: 0;
  padding: 0; border: 0; border-radius: var(--radius-control); background: none; cursor: pointer;
  font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.015em;
}
.brand-mark {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(150deg, var(--hero-1), var(--hero-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 14px -6px rgba(10, 50, 25, 0.6);
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.star-total {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--gold-soft-1), var(--gold-soft-2));
  border: 1px solid var(--gold-line); color: var(--gold-ink);
  font-weight: 800; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-1);
}
.star-total svg { width: 22px; height: 22px; fill: var(--star); filter: drop-shadow(0 1px 1px rgba(150, 90, 0, 0.35)); }
@media (max-width: 560px) {
  .brand-name { display: none; }
  .topbar-actions { gap: 6px; }
}
/* Small phones: the fullscreen toggle stays available inside each game. */
@media (max-width: 440px) {
  .topbar-inner { gap: var(--space-2); }
  .topbar-actions { gap: 4px; min-width: 0; flex: 0 1 auto; }
  .topbar .icon-btn[data-fs] { display: none; }
  .star-total { padding: 0 10px 0 8px; }
  .select { padding-inline: 12px 30px; }
  .select-icon { inset-inline-end: 9px; }
}

:root.is-fullscreen .topbar-inner { min-height: 72px; }

/* ---------- Home ---------- */

.home { display: grid; gap: clamp(18px, 3vh, 32px); padding-block: clamp(14px, 2.4vh, 24px) var(--space-7); }

/* Hero: a deep jungle banner with the macaw, the child's overall progress and one big "play next" button */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: var(--space-5);
  min-height: clamp(260px, 36vh, 420px); padding: clamp(22px, 3.4vw, 48px);
  border-radius: var(--radius-xl); color: var(--hero-ink);
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(255, 214, 120, 0.28), transparent 55%),
    radial-gradient(60% 70% at 100% 100%, var(--hero-leaf-2) 0 38%, transparent 38.5%),
    radial-gradient(45% 55% at 92% 110%, var(--hero-leaf-1) 0 40%, transparent 40.5%),
    radial-gradient(40% 50% at -6% 108%, var(--hero-leaf-1) 0 42%, transparent 42.5%),
    radial-gradient(28% 40% at 8% -10%, var(--hero-leaf-2) 0 45%, transparent 45.5%),
    linear-gradient(150deg, var(--hero-1), var(--hero-2));
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.hero::after { /* fine grain + top light, so the banner doesn't look flat */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%);
}
.hero-copy { position: relative; display: grid; justify-items: start; gap: var(--space-3); min-width: 0; }
.kicker {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
:root[lang="ar"] .kicker, :root[lang="ary"] .kicker { text-transform: none; letter-spacing: 0; }
.hero h1 {
  margin: 0; font-family: var(--font-display); font-size: var(--text-hero); font-weight: 700;
  line-height: 0.98; letter-spacing: -0.03em; text-wrap: balance;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.18);
}
.lede { margin: 0; max-width: 30em; color: var(--hero-muted); font-size: clamp(16px, 1.6vw, 19px); line-height: 1.45; }
.hero-progress { display: grid; gap: 8px; width: min(100%, 400px); margin-top: var(--space-2); }
.hero-progress-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: 14px; font-weight: 700; }
.hero-progress-count { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; color: var(--hero-muted); }
.hero-progress-count svg { width: 18px; height: 18px; fill: var(--star); }
.meter { position: relative; display: block; height: 12px; border-radius: var(--radius-pill); background: rgba(0, 0, 0, 0.22); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); overflow: hidden; }
.meter-fill {
  position: absolute; inset-block: 0; inset-inline-start: 0; width: max(var(--value), 12px); border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 0 12px rgba(255, 200, 80, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: meter-grow 1.1s var(--ease) both 200ms;
}
@keyframes meter-grow { from { width: 0; } }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.hero-actions .btn-primary span { overflow: hidden; text-overflow: ellipsis; max-width: 20em; }

.hero-art { position: relative; display: grid; place-items: center; min-height: 240px; height: 100%; }
.hero-orb {
  position: absolute; width: min(100%, 340px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 236, 170, 0.55), rgba(255, 190, 80, 0.18) 45%, transparent 70%);
  filter: blur(2px);
}
.hero-figure { position: relative; width: clamp(150px, 22vw, 260px); filter: drop-shadow(0 24px 24px rgba(0, 0, 0, 0.35)); animation: float 5s ease-in-out infinite; }
.hero-figure svg { display: block; width: 100%; height: auto; }
[dir="rtl"] .hero-figure svg { transform: scaleX(-1); }
.hero-chip {
  position: absolute; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--fruit-2), var(--fruit-1) 70%);
  color: var(--fruit-ink); font-family: var(--font-display); font-size: 26px; font-weight: 700;
  box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.08);
  animation: float 6s ease-in-out infinite;
}
.hero-chip--a { top: 12%; inset-inline-start: 6%; animation-delay: -1s; }
.hero-chip--b { bottom: 14%; inset-inline-start: 14%; width: 46px; height: 46px; font-size: 21px; animation-delay: -3s; }
.hero-chip--c { top: 22%; inset-inline-end: 4%; width: 52px; height: 52px; font-size: 20px; animation-delay: -2s; }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; text-align: start; }
  .hero-art { order: -1; min-height: 170px; margin-block: -8px -16px; }
  .hero-figure { width: 150px; }
  .hero-orb { width: 220px; }
}

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.section-head h2 { margin: 0; font-family: var(--font-display); font-size: clamp(24px, 2.6vw, 30px); font-weight: 700; letter-spacing: -0.02em; }

.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 5px; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-1); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.segment {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 50px; min-width: 96px; padding: 6px var(--space-3);
  border: 0; border-radius: 13px; background: transparent; color: var(--fg-muted); cursor: pointer;
  font-size: var(--text-sm); font-weight: 700; line-height: 1.2;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segment small { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0.85; }
.segment[aria-checked="true"] {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 14px -6px var(--accent-glow);
}
@media (hover: hover) { .segment[aria-checked="false"]:hover { color: var(--fg); background: var(--surface-2); } }
@media (max-width: 560px) {
  .segmented { display: grid; width: 100%; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 4px; }
  .segment { min-width: 0; padding: 6px 2px; font-size: 13px; }
  .segment small { font-size: 10px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* Game cards: one colour world per game, the character floating above a lit scene */
.game-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: clamp(16px, 2vw, 24px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
/* Five games: one row on wide screens and TVs, 3 + 2 on tablets, then 2 and 1 */
@media (min-width: 1180px) { .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 761px) and (max-width: 1179px) { .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 480px) and (max-width: 760px) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.game-grid > li { animation: rise 600ms var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.game-card {
  --c1: var(--accent-hi); --c2: var(--accent);
  position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; padding: 6px;
  text-align: start; cursor: pointer; overflow: hidden;
  border: 1px solid var(--glass-line); border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform 400ms var(--ease), box-shadow 400ms var(--ease);
}
.game-card[data-game="parrot"] { --c1: #FF8A5B; --c2: #E5383B; }
.game-card[data-game="chameleon"] { --c1: #6BD58A; --c2: #1F9459; }
.game-card[data-game="monkey"] { --c1: #F2B868; --c2: #B8702E; }
.game-card[data-game="frog"] { --c1: #4FD1C1; --c2: #1A8D93; }
.game-card[data-game="lions"] { --c1: #FFD060; --c2: #E0901E; }
.game-card[data-game="count"] { --c1: #B79BFF; --c2: #6A48D8; }
.game-card[data-game="croc"] { --c1: #9BD45C; --c2: #4E8A26; }
.game-card[data-game="sum"] { --c1: #FF8DB8; --c2: #D6427E; }
.game-card:active { transform: scale(0.98); }
@media (hover: hover) {
  .game-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-3); }
  .game-card:hover .card-figure { transform: translateY(-8px) scale(1.06) rotate(-3deg); }
  .game-card:hover .chip-play { transform: translateX(2px); }
}
.card-art {
  position: relative; isolation: isolate; display: grid; place-items: center; aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius-xl) - 6px); overflow: hidden;
}
.card-art::before { /* the game's colour washed over the scene */
  content: ""; position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(70% 60% at 50% 55%, rgba(255, 255, 255, 0.42), transparent 70%),
    linear-gradient(160deg, color-mix(in srgb, var(--c1) 55%, transparent), color-mix(in srgb, var(--c2) 65%, transparent));
  mix-blend-mode: soft-light;
}
.card-art::after { /* top highlight and bottom shade, like a glossy app icon */
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 35%, transparent 70%, rgba(0, 0, 0, 0.16));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  border-radius: inherit;
}
.card-figure { position: relative; z-index: 1; display: grid; place-items: center; width: 52%; transition: transform 500ms var(--ease); }
.card-figure svg { width: 100%; height: auto; max-height: 170px; filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.28)); }
.card-num {
  position: absolute; z-index: 1; top: 12px; inset-inline-start: 12px;
  display: grid; place-items: center; min-width: 38px; height: 28px; padding: 0 10px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.78); color: var(--c2);
  font-family: var(--font-display); font-size: 14px; font-weight: 800; letter-spacing: 0.04em;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.25);
}
.card-body { display: grid; gap: 4px; padding: var(--space-4) var(--space-4) var(--space-3); }
.card-skill {
  justify-self: start; display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--c2) 14%, transparent); color: color-mix(in srgb, var(--c2) 80%, var(--fg));
  font-size: 13.5px; font-weight: 800; letter-spacing: 0.02em;
}
.card-title { font-family: var(--font-display); font-size: clamp(21px, 1.9vw, 24px); font-weight: 700; line-height: 1.15; letter-spacing: -0.015em; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-3); }
.chip-play {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 18px 0 16px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--c1), var(--c2)); color: #fff;
  font-size: var(--text-sm); font-weight: 800; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 8px 16px -8px var(--c2);
  transition: transform var(--dur) var(--ease);
}
.chip-play svg { width: 13px; height: 13px; }

/* ---------- Scenes (shared by cards, stages and results) ---------- */

.scene--tree {
  background:
    radial-gradient(circle at 20% 28%, var(--canopy-3) 0 17%, transparent 17.5%),
    radial-gradient(circle at 80% 26%, var(--canopy-3) 0 18%, transparent 18.5%),
    radial-gradient(circle at 50% 16%, var(--canopy-1) 0 30%, transparent 30.5%),
    radial-gradient(circle at 28% 46%, var(--canopy-1) 0 26%, transparent 26.5%),
    radial-gradient(circle at 74% 48%, var(--canopy-2) 0 28%, transparent 28.5%),
    linear-gradient(to bottom, transparent 90%, var(--bank) 90%),
    linear-gradient(to right, transparent 46%, var(--trunk) 46% 54%, transparent 54%),
    linear-gradient(var(--sky-top), var(--sky-bottom));
}
.scene--leaves {
  background:
    radial-gradient(ellipse at 10% 10%, var(--canopy-3) 0 20%, transparent 21%),
    radial-gradient(ellipse at 90% 90%, var(--canopy-3) 0 22%, transparent 23%),
    radial-gradient(ellipse at 85% 15%, var(--canopy-1) 0 25%, transparent 26%),
    linear-gradient(160deg, var(--canopy-2), var(--canopy-1));
}
.scene--branch {
  background:
    linear-gradient(to bottom, transparent 9%, var(--wood-2) 9% 12%, transparent 12%),
    radial-gradient(circle at 8% 100%, var(--canopy-1) 0 22%, transparent 22.5%),
    radial-gradient(circle at 94% 100%, var(--canopy-3) 0 20%, transparent 20.5%),
    linear-gradient(var(--sky-top), var(--sky-bottom));
}
.scene--river {
  background:
    repeating-linear-gradient(170deg, transparent 0 46px, var(--sheen) 46px 50px),
    linear-gradient(to bottom, var(--bank) 0 20%, var(--water-1) 20%, var(--water-2) 80%, var(--bank) 80%);
}
.scene--savanna {
  background:
    radial-gradient(circle at 50% 5%, var(--leaf-found) 0 5%, transparent 5.5%),
    linear-gradient(to bottom, var(--sky-top), var(--sky-bottom) 30%, var(--savanna-1) 30%, var(--savanna-2));
}

/* ---------- Game screen ---------- */
/* The game always fills the window: header, prompt, then the stage takes every remaining pixel (no page scroll). */

.game { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: var(--space-3); padding-block: var(--space-3) var(--space-4); }
body[data-screen="game"] { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body[data-screen="game"] #main { flex: 1; min-height: 0; }
body[data-screen="game"] .game { height: 100%; }
.game-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); }
.game-title { min-width: 0; }
.game-title h1 {
  margin: 0; font-family: var(--font-display); font-size: var(--text-title); font-weight: 700;
  line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-title p { display: flex; align-items: center; flex-wrap: wrap; margin: 2px 0 0; color: var(--fg-muted); font-size: 14px; font-weight: 600; }

.progress { display: flex; gap: 6px; margin: 0; padding: 6px 8px; list-style: none; border-radius: var(--radius-pill); background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow-1); }
.progress li {
  width: 22px; height: 8px; border-radius: var(--radius-pill); background: var(--star-empty);
  transition: width var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.progress .is-current { width: 34px; background: linear-gradient(90deg, var(--accent-hi), var(--accent)); box-shadow: 0 0 10px var(--accent-glow); }
.progress .is-clean { background: var(--good); }
.progress .is-retry { background: var(--star); }
.progress .is-missed { background: var(--bad); }

.prompt-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: var(--space-3); padding: 12px 12px 12px 24px;
  border: 1px solid var(--glass-line); border-radius: 22px; box-shadow: var(--shadow-2);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--accent)) 0%, var(--surface) 55%);
  transition: box-shadow .35s, border-color .35s;
}
.prompt-card.is-speaking { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--shadow-2), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), 0 0 34px color-mix(in srgb, var(--accent) 35%, transparent); }
.prompt-card.is-speaking::before { animation: prompt-beam .8s ease-in-out infinite alternate; }
@keyframes prompt-beam { from { opacity: .55; transform: scaleY(.75); } to { opacity: 1; transform: scaleY(1); } }
.prompt-text.is-new { animation: prompt-in .55s cubic-bezier(.2,1.2,.4,1); }
.prompt-text.is-new .num { animation: num-pop .6s cubic-bezier(.3,1.8,.5,1) .12s both; }
@keyframes prompt-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .prompt-text.is-new { animation-name: prompt-in-rtl; }
@keyframes prompt-in-rtl { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes num-pop { 0% { transform: scale(.4) rotate(-8deg); } 100% { transform: scale(1) rotate(0); } }
.prompt-langs { display: inline-flex; flex: none; }
.lang-pills { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.lang-pill { height: 36px; min-width: 40px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--fg-muted);
  font-family: var(--font-display); font-weight: 700; font-size: 15px; cursor: pointer; transition: background .2s, color .2s, transform .15s; }
.lang-pill:hover { color: var(--fg); transform: translateY(-1px); }
.lang-pill[aria-pressed="true"] { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 2px 0 var(--accent-deep); }
.lang-pill:focus-visible { outline: 3px solid var(--focus-tv); outline-offset: 2px; }
@media (max-width: 760px) { .prompt-card { flex-wrap: wrap; } .prompt-text { flex-basis: 100%; } }
.prompt-card::before { content: ""; position: absolute; inset-block: 10px; inset-inline-start: 0; width: 5px; border-radius: 0 6px 6px 0; background: linear-gradient(180deg, var(--accent-hi), var(--accent)); }
[dir="rtl"] .prompt-card::before { border-radius: 6px 0 0 6px; }
.prompt-text {
  flex: 1; min-width: 0; margin: 0;
  font-family: var(--font-display); font-size: clamp(22px, 2.8vw, 32px); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em;
}
.prompt-text .num {
  display: inline-block; min-width: 1.7em; padding: 0.02em 0.4em; margin: 0 .08em; border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); text-align: center;
  font-weight: 800; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 10px -4px var(--accent-glow);
}

.stage {
  position: relative; height: clamp(440px, 68vh, 660px);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-3), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden; isolation: isolate; user-select: none; -webkit-user-select: none;
}
body[data-screen="game"] .stage { height: auto; min-height: 0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.is-shaking { animation: shake 360ms var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Parrot */
.fruit {
  position: absolute; translate: -50% -50%; z-index: 1;
  width: clamp(54px, 9vw, 70px); aspect-ratio: 1; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--fruit-2), var(--fruit-1) 70%);
  color: var(--fruit-ink); font-family: var(--font-display); font-size: clamp(22px, 3.6vw, 28px); font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
  box-shadow: 0 4px 10px var(--shade), inset 0 -4px 0 rgba(0, 0, 0, 0.08);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.fruit::before {
  content: ""; position: absolute; top: -9px; left: 50%; translate: -50% 0;
  width: 16px; height: 11px; border-radius: 0 100% 0 100%; background: var(--leaf-2);
}
.fruit:active { transform: scale(0.94); }
@media (hover: hover) { .fruit:hover { transform: scale(1.07); } }
.fruit.is-picked { box-shadow: 0 0 0 4px var(--art-white), 0 0 0 8px var(--good), 0 4px 10px var(--shade); }
.parrot {
  position: absolute; translate: -50% -60%; z-index: 2; width: clamp(68px, 12vw, 100px); pointer-events: none;
  transition: transform var(--dur-flight) var(--ease);
  filter: drop-shadow(0 6px 6px var(--shade));
}
[dir="rtl"] .parrot svg { transform: scaleX(-1); }

/* Chameleon */
.cham-layout { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--space-3); padding: var(--space-4); }
.cham-status {
  --mix: 0%;
  --cham-color: color-mix(in oklch, var(--cham-end) var(--mix), var(--cham-start));
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-1);
}
.chameleon-art { flex: none; width: 72px; }
.chameleon-art svg { display: block; }
.timer { flex: 1; min-width: 0; height: 10px; border-radius: var(--radius-pill); background: var(--star-empty); overflow: hidden; }
.timer-fill { height: 100%; border-radius: inherit; background: var(--cham-color); transform-origin: left center; }
[dir="rtl"] .timer-fill { transform-origin: right center; }
.found-chip { flex: none; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.leaf-grid {
  display: grid; gap: var(--space-2);
  grid-template-columns: repeat(var(--cols-sm), minmax(0, 1fr));
  grid-auto-rows: minmax(52px, 1fr);
}
@media (min-width: 720px) { .leaf-grid { grid-template-columns: repeat(var(--cols-lg), minmax(0, 1fr)); } }
.leaf { position: relative; display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer; }
.leaf::before {
  content: ""; position: absolute; inset: 4%;
  border-radius: 0 72% 0 72%; transform: rotate(var(--tilt, 0deg));
  background: linear-gradient(135deg, var(--leaf-2), var(--leaf-1));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.leaf span {
  position: relative; font-family: var(--font-display); font-size: clamp(20px, 3.4vw, 28px); font-weight: 700;
  color: var(--leaf-ink); font-variant-numeric: tabular-nums; line-height: 1;
}
.leaf:active::before { transform: rotate(var(--tilt, 0deg)) scale(0.94); }
.leaf.is-found::before { background: var(--leaf-found); animation: fade-in var(--dur) var(--ease); }
.leaf.is-found span { color: var(--accent-ink); }
.leaf.is-revealed::before { box-shadow: inset 0 0 0 3px var(--leaf-found); }
.leaf.is-revealed span { color: var(--art-white); }

/* Monkey */
.monkey-deco { position: absolute; top: 3%; left: 50%; translate: -50% 0; width: clamp(56px, 9vw, 76px); pointer-events: none; }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.match-lines path { fill: none; stroke: var(--good); stroke-width: 5; stroke-linecap: round; }
.match-lines path:last-child { animation: fade-in var(--dur) var(--ease); }
.match-board {
  position: absolute; inset: 0; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: center;
  column-gap: clamp(56px, 18vw, 220px); row-gap: var(--space-3);
  padding: clamp(84px, 16%, 110px) var(--space-4) var(--space-5);
}
.coconut, .sign {
  cursor: pointer; border: 0;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.coconut {
  justify-self: end; width: clamp(56px, 10vw, 68px); aspect-ratio: 1; padding: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--monkey-face), var(--monkey) 72%);
  color: var(--art-white); font-family: var(--font-display); font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow: 0 4px 10px var(--shade);
}
.sign {
  justify-self: start; min-height: 56px; min-width: min(100%, 132px); max-width: 100%; padding: 6px var(--space-4);
  border-radius: 10px; background: linear-gradient(var(--wood), var(--wood-2)); color: var(--wood-ink);
  font-family: var(--font-display); font-size: clamp(17px, 3vw, 22px); font-weight: 700; line-height: 1.15;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15), 0 4px 10px var(--shade);
  overflow-wrap: anywhere;
}
.coconut:active, .sign:active { transform: scale(0.95); }
.coconut.is-selected, .sign.is-selected { box-shadow: 0 0 0 4px var(--art-white), 0 0 0 8px var(--accent); }
.coconut.is-done, .sign.is-done { box-shadow: 0 0 0 4px var(--art-white), 0 0 0 8px var(--good); cursor: default; }

/* Frog */
.pad { position: absolute; translate: -50% -50%; display: grid; place-items: center; width: clamp(64px, 14vw, 108px); aspect-ratio: 1.15; }
.pad::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--lily-1), var(--lily-2));
  -webkit-mask: conic-gradient(from -18deg, transparent 0 36deg, #000 36deg);
  mask: conic-gradient(from -18deg, transparent 0 36deg, #000 36deg);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
}
.pad span {
  position: relative; margin-top: 24%;
  font-family: var(--font-display); font-size: clamp(20px, 3.6vw, 28px); font-weight: 700;
  color: var(--lily-ink); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.pad.is-unknown span { opacity: 0.7; }
.pad:not(.is-unknown) span { animation: pop-in var(--dur) var(--ease); }
.pad.is-next::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 3px dashed var(--lily-ink); opacity: 0.7;
}
.frog {
  position: absolute; translate: -50% -82%; z-index: 2; width: clamp(56px, 11vw, 86px); pointer-events: none;
  transition: transform 450ms var(--ease);
  filter: drop-shadow(0 6px 6px var(--shade));
}
@keyframes hop {
  0% { transform: translateY(0); }
  45% { transform: translateY(-38px) scale(1.06); }
  100% { transform: translateY(0); }
}
.frog.is-hopping .frog-body { animation: hop 450ms var(--ease); }
.choices {
  position: absolute; left: 0; right: 0; bottom: 3%; z-index: 3;
  display: flex; justify-content: center; gap: var(--space-3); padding-inline: var(--space-4);
}
.stone-btn, .number-stone {
  border: 0; cursor: pointer;
  background: linear-gradient(160deg, var(--stone), var(--stone-2)); color: var(--stone-ink);
  font-family: var(--font-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 4px 10px var(--shade);
  transition: transform var(--dur-fast) var(--ease);
}
.stone-btn { min-width: 76px; min-height: 58px; padding: 6px var(--space-4); border-radius: 44% 50% 42% 48% / 55% 50% 48% 45%; }
.stone-btn:active, .number-stone:active { transform: scale(0.94); }
@media (hover: hover) { .stone-btn:hover { transform: translateY(-2px); } }

/* Lions */
.savanna { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--space-2); padding: var(--space-4); }
.lions-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-2); }
.lion { width: clamp(92px, 22vw, 168px); transform-origin: 50% 100%; }
.lion svg { display: block; }
.lion.is-flipped svg { transform: scaleX(-1); }
.lion .eyes-open { opacity: 0; }
.lion.is-awake .eyes-open { opacity: 1; }
.lion.is-awake .eyes-closed, .lion.is-awake .zzz { opacity: 0; }
@keyframes stir {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-3deg) translateY(-3px); }
  60% { transform: rotate(2deg); }
}
.lion.is-awake { animation: stir 600ms var(--ease); }
.range-chip {
  display: flex; align-items: center; gap: 6px; margin-bottom: var(--space-2); padding: 6px var(--space-3);
  border-radius: var(--radius-pill); background: var(--surface); box-shadow: var(--shadow-1);
  font-family: var(--font-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fg-muted);
}
.range-chip b { color: var(--fg); }
.range-gap {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  border: 2px dashed var(--line); color: var(--fg-muted);
}
.stone-field {
  display: grid; align-content: center; justify-items: center; gap: var(--space-3);
  grid-template-columns: repeat(var(--cols-sm), minmax(0, 1fr));
}
@media (min-width: 720px) { .stone-field { grid-template-columns: repeat(var(--cols-lg), minmax(0, 1fr)); } }
.number-stone {
  position: relative; width: clamp(56px, 13vw, 88px); aspect-ratio: 1.15; padding: 0;
  border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; rotate: var(--tilt, 0deg);
}
.number-stone.is-circled::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 4px solid var(--good); animation: pop-in var(--dur) var(--ease);
}

/* ---------- Results ---------- */

.result { display: grid; place-items: center; min-height: calc(100dvh - 68px - env(safe-area-inset-top, 0px)); padding-block: var(--space-6); }
.result-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; justify-items: center; gap: var(--space-3); width: min(100%, 520px); text-align: center;
  padding: 8px 8px var(--space-6);
  border: 1px solid var(--glass-line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-3);
  animation: rise 500ms var(--ease) both;
}
.result-art { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 8; border-radius: calc(var(--radius-xl) - 6px); overflow: hidden; }
.result-art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 70% at 50% 60%, rgba(255, 230, 150, 0.45), transparent 70%), linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 40%, rgba(0, 0, 0, 0.12)); }
.result-art svg { position: relative; z-index: 1; width: 30%; max-height: 80%; filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.3)); animation: float 4s ease-in-out infinite; }
.result-card h1 { margin: var(--space-3) 0 0; font-family: var(--font-display); font-size: clamp(30px, 4vw, 40px); line-height: 1.05; letter-spacing: -0.025em; }
.stars--big { gap: 10px; padding: 12px 22px; border-radius: var(--radius-pill); background: linear-gradient(180deg, var(--gold-soft-1), var(--gold-soft-2)); border: 1px solid var(--gold-line); }
.stars--big .star { width: 48px; height: 48px; }
.stars--big .star.is-on { animation: star-pop 600ms var(--spring) both; filter: drop-shadow(0 4px 8px rgba(220, 150, 0, 0.5)); }
.stars--big .star:nth-child(2) { animation-delay: 160ms; translate: 0 -6px; }
.stars--big .star:nth-child(3) { animation-delay: 320ms; }
@keyframes star-pop { from { opacity: 0; transform: scale(0.2) rotate(-40deg); } 70% { transform: scale(1.18) rotate(6deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.result-score { margin: 0; color: var(--fg-muted); font-weight: 600; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-3); padding-inline: var(--space-4); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; top: calc(84px + env(safe-area-inset-top, 0px)); z-index: 30;
  display: inline-flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px); padding: 12px 22px;
  border: 1px solid var(--glass-line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-3);
  font-family: var(--font-display); font-size: 19px; font-weight: 700; text-align: center; pointer-events: none;
  opacity: 0; transform: translate(-50%, -14px) scale(0.96);
  transition: opacity var(--dur) var(--ease), transform 400ms var(--spring);
}
.toast::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 20%, transparent); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast[data-tone="good"] { color: var(--good); }
.toast[data-tone="echo"] { color: var(--accent-deep); font-family: var(--font-display); font-size: clamp(20px, 2.4vw, 30px); font-weight: 700; }
.toast[data-tone="bad"] { color: var(--bad); }

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

/* ---------- 3D stage ---------- */

.stage--3d { background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
.stage-canvas {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.stage-canvas:focus { outline: none; }
.stage-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: var(--radius-card); }
.focus-ring {
  position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none;
  border: 3px solid var(--focus); border-radius: 50%;
  box-shadow: 0 0 0 3px var(--art-white);
  transition: transform var(--dur-fast) var(--ease), width var(--dur-fast) var(--ease), height var(--dur-fast) var(--ease);
}
.hud {
  position: absolute; left: var(--space-4); right: var(--space-4); z-index: 3;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud--top { top: var(--space-4); }
.hud--bottom { bottom: var(--space-4); }
.hud--center { display: flex; justify-content: center; }
.hud.choices { display: flex; justify-content: center; gap: var(--space-3); padding-inline: 0; }
.hud.cham-status { box-shadow: var(--shadow-2); }
.stage--3d .stone-btn { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), var(--shadow-2); }
/* Answer pebbles (3D scenes and 2D games): big white pebbles with dark digits, readable day and night and from a TV */
.stage--3d .stone-btn, .stage .choices .stone-btn, .croc-stone {
  min-width: clamp(84px, 9vw, 120px); min-height: clamp(66px, 7vw, 88px); padding: 6px 22px;
  background: linear-gradient(180deg, #FFFFFF, #ECEFE8); color: #1B2A1F;
  border: 3px solid rgba(27, 42, 31, 0.85);
  font-size: clamp(30px, 3.4vw, 42px); font-weight: 800;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 10px 22px -8px rgba(0, 0, 0, 0.55);
}
:root.is-keyboard .stage--3d .stone-btn:focus-visible { box-shadow: 0 0 0 5px var(--focus-tv), 0 0 0 11px color-mix(in srgb, var(--focus-tv) 30%, transparent); }
.stage--3d .hud.choices { gap: clamp(12px, 2vw, 24px); }

/* ---------- Kid hand cursor (js/tv.js) ---------- */
/* A big cartoon hand instead of the mouse arrow; it leans in over things you can tap and presses down on a click. */

:root.has-kid-cursor, :root.has-kid-cursor * { cursor: none !important; }
.kid-cursor {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none;
  width: 64px; height: 72px; margin: -5px 0 0 -20px; /* the fingertip is the hot spot */
  opacity: 0; will-change: transform;
  transition: opacity 150ms var(--ease);
}
.kid-cursor.is-visible { opacity: 1; }
.kid-cursor svg {
  display: block; width: 100%; height: 100%;
  transform-origin: 34% 10%;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.28));
  transition: transform 220ms var(--spring), filter 220ms var(--ease);
}
.kid-cursor.is-over svg { transform: scale(1.14) rotate(-8deg); filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.3)); }
.kid-cursor.is-down svg { transform: scale(0.9) rotate(-2deg) translateY(4px); transition-duration: 90ms; }
.kid-cursor.is-over .hand-fill { fill: #FFC88F; }
.tap-sparkle {
  position: fixed; z-index: 999; pointer-events: none;
  width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  border: 4px solid var(--gold-2);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold-1) 40%, transparent), 0 0 24px var(--gold-1);
  animation: tap-sparkle 520ms var(--ease) forwards;
}
@keyframes tap-sparkle { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* ---------- TV remote focus (10-foot UI) ---------- */
/* With the arrow keys / D-pad, the focused thing glows and lifts so a child sees it from the sofa. */

:root.is-keyboard :focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 4px; }
:root.is-keyboard .game-card:focus-visible {
  outline: none; transform: translateY(-8px) scale(1.035);
  box-shadow: 0 0 0 5px var(--focus-tv), 0 0 0 11px color-mix(in srgb, var(--focus-tv) 30%, transparent), var(--shadow-3);
}
:root.is-keyboard .game-card:focus-visible .card-figure { transform: translateY(-8px) scale(1.08) rotate(-3deg); }
:root.is-keyboard .btn:focus-visible, :root.is-keyboard .segment:focus-visible, :root.is-keyboard .icon-btn:focus-visible, :root.is-keyboard .select:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--focus-tv), 0 0 0 9px color-mix(in srgb, var(--focus-tv) 30%, transparent);
  transform: scale(1.05);
}
:root.is-keyboard .stage-canvas:focus-visible { outline: 5px solid var(--focus-tv); outline-offset: -5px; }
.focus-ring { border-width: 4px; border-color: var(--focus-tv); box-shadow: 0 0 0 4px #fff, 0 0 24px var(--focus-tv); }

/* TV mode (10-foot UI): detected TV browsers (js/tv.js) and very wide screens get bigger text and controls,
   so a child reads everything from across the room. */
:root.is-tv { --text-base: 20px; --text-sm: 17px; }
  :root.is-tv .topbar-inner { min-height: 84px; }
  :root.is-tv .brand { font-size: 26px; }
  :root.is-tv .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
  :root.is-tv .icon-btn, :root.is-tv .select, :root.is-tv .star-total { height: 56px; min-width: 56px; }
  :root.is-tv .star-total { font-size: 20px; }
  :root.is-tv .kicker { height: 36px; font-size: 16px; }
  :root.is-tv .lede { font-size: 22px; }
  :root.is-tv .btn { min-height: 56px; font-size: 19px; }
  :root.is-tv .btn-lg { min-height: 68px; font-size: 22px; padding: 0 40px; }
  :root.is-tv .segment { min-height: 62px; min-width: 120px; font-size: 18px; }
  :root.is-tv .segment small { font-size: 15px; }
  :root.is-tv .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  :root.is-tv .card-title { font-size: 26px; }
  :root.is-tv .card-skill { height: 30px; font-size: 15px; padding: 0 12px; }
  :root.is-tv .chip-play { height: 48px; font-size: 18px; }
  :root.is-tv .star { width: 26px; height: 26px; }
  :root.is-tv .game-title h1 { font-size: 36px; }
  :root.is-tv .game-title p { font-size: 17px; }
  :root.is-tv .prompt-card { padding: 16px 16px 16px 28px; }
  :root.is-tv .prompt-text { font-size: clamp(30px, 3vw, 44px); }
  :root.is-tv .progress li { width: 30px; height: 12px; }
  :root.is-tv .progress .is-current { width: 46px; }
  :root.is-tv .toast { font-size: 26px; padding: 16px 30px; }
@media (min-width: 1700px) {
  :root { --text-base: 19px; --text-sm: 17px; }
  .topbar-inner { min-height: 84px; }
  .brand { font-size: 26px; }
  .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
  .icon-btn, .select, .star-total { height: 56px; min-width: 56px; }
  .star-total { font-size: 20px; }
  .kicker { height: 36px; font-size: 16px; }
  .lede { font-size: 22px; }
  .btn { min-height: 56px; font-size: 19px; }
  .btn-lg { min-height: 68px; font-size: 22px; padding: 0 40px; }
  .segment { min-height: 62px; min-width: 120px; font-size: 18px; }
  .segment small { font-size: 15px; }
  .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-title { font-size: 26px; }
  .card-skill { height: 30px; font-size: 15px; padding: 0 12px; }
  .chip-play { height: 48px; font-size: 18px; }
  .star { width: 26px; height: 26px; }
  .game-title h1 { font-size: 36px; }
  .game-title p { font-size: 17px; }
  .prompt-card { padding: 16px 16px 16px 28px; }
  .prompt-text { font-size: clamp(30px, 3vw, 44px); }
  .progress li { width: 30px; height: 12px; }
  .progress .is-current { width: 46px; }
  .toast { font-size: 26px; padding: 16px 30px; }
}
:root.is-keyboard h1:focus-visible { outline: none; } /* headings receive focus for screen readers only */

/* TV mode home: a compact hero so the five games are on screen without scrolling */
:root.is-tv .hero { min-height: 0; padding: 22px 32px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
:root.is-tv .hero h1 { font-size: 46px; }
:root.is-tv .hero .lede { display: none; }
:root.is-tv .hero-copy { gap: 10px; }
:root.is-tv .hero-progress { margin-top: 0; }
:root.is-tv .hero-actions { margin-top: 6px; }
:root.is-tv .hero-art { min-height: 0; height: 170px; }
:root.is-tv .hero-figure { width: 130px; }
:root.is-tv .hero-orb { width: 190px; }
:root.is-tv .hero-chip { width: 48px; height: 48px; font-size: 22px; }
:root.is-tv .home { gap: 18px; padding-block: 16px 24px; }
:root.is-tv .card-art { aspect-ratio: 5 / 4; }
:root.is-tv .card-body { padding: 12px 12px 10px; }
:root.is-tv .card-title { font-size: 22px; }
:root.is-tv .card-foot { margin-top: 8px; }
:root.is-tv .card-num { display: none; }
:root.is-tv .game-card .chip-play span { display: none; } /* icon-only play button keeps the card title roomy */
:root.is-tv .chip-play { width: 48px; padding: 0; justify-content: center; }
:root.is-tv .chip-play svg { width: 18px; height: 18px; }
.card-skill { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root.is-tv .card-skill { height: 28px; font-size: 14px; padding: 0 10px; line-height: 28px; display: block; }

/* ---------- Immersive game (full-screen button) ---------- */
/* The app's top bar disappears and the 3D scene runs edge to edge; header and question stay in one slim strip. */

.game-head-end { display: flex; align-items: center; gap: var(--space-2); }
:root.is-immersive body[data-screen="game"] .topbar { display: none; }
:root.is-immersive body[data-screen="game"] .game {
  padding: max(10px, env(safe-area-inset-top, 0px)) 0 0; gap: 10px;
}
:root.is-immersive body[data-screen="game"] .game-head,
:root.is-immersive body[data-screen="game"] .prompt-card {
  margin-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
}
:root.is-immersive body[data-screen="game"] .stage {
  border-radius: 0; box-shadow: none;
}
:root.is-immersive body[data-screen="game"] .toast { top: calc(16px + env(safe-area-inset-top, 0px)); }
/* Wide screens: title, question and progress share one row so the scene gets the most height */
@media (min-width: 1100px) {
  :root.is-immersive body[data-screen="game"] .game { grid-template-columns: minmax(0, auto) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); column-gap: 12px; }
  :root.is-immersive body[data-screen="game"] .game-head { grid-column: 1; grid-row: 1; margin-inline-end: 0; }
  :root.is-immersive body[data-screen="game"] .prompt-card { grid-column: 2; grid-row: 1; margin-inline-start: 0; }
  :root.is-immersive body[data-screen="game"] .stage { grid-column: 1 / -1; grid-row: 2; }
  :root.is-immersive body[data-screen="game"] .game-head { grid-template-columns: auto minmax(0, auto) auto; }
}

/* Lions: the "between" reminder, bigger and brighter over the 3D savanna */
.stage--3d .range-chip {
  gap: 12px; padding: 10px 24px; margin-bottom: 0;
  font-size: clamp(30px, 3.2vw, 42px); font-weight: 800;
  background: rgba(255, 255, 255, 0.95); color: #4A5A4E;
  border: 3px solid rgba(27, 42, 31, 0.85);
  box-shadow: 0 12px 26px -10px rgba(0, 0, 0, 0.55);
}
.stage--3d .range-chip b { color: #1B2A1F; }
.stage--3d .range-gap {
  width: clamp(44px, 4.4vw, 58px); height: clamp(44px, 4.4vw, 58px); border-radius: 14px;
  border: 3px dashed var(--accent); color: var(--accent-deep); background: var(--accent-soft);
}

/* ---------- New games: 2D versions (devices without 3D) ---------- */

.count-grid {
  position: absolute; inset: 8% 8% 24%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: center; justify-items: center; gap: clamp(6px, 1.4vw, 14px);
}
.coco { position: relative; width: clamp(44px, 8vw, 76px); animation: pop-in 360ms var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
.coco svg { display: block; width: 100%; filter: drop-shadow(0 4px 6px var(--shade)); }
.coco.is-counted::after {
  content: attr(data-n); position: absolute; inset: auto 0 -6px auto; display: grid; place-items: center;
  min-width: 30px; height: 30px; border-radius: 15px; background: #fff; color: #1B2A1F;
  border: 2px solid #1B2A1F; font-family: var(--font-display); font-weight: 800; font-size: 16px;
}
.croc-deco { position: absolute; left: 50%; bottom: 8%; translate: -50% 0; width: clamp(140px, 26vw, 240px); transition: transform 300ms var(--spring); }
.croc-deco.is-chomping { transform: scale(1.12) rotate(-4deg); }
.croc-row { position: absolute; inset: 14% 6% auto; display: flex; justify-content: center; gap: clamp(16px, 4vw, 48px); }
.croc-stone { min-width: clamp(96px, 16vw, 150px); min-height: clamp(80px, 12vw, 110px); font-size: clamp(32px, 5vw, 48px); }
.croc-stone.is-eaten { transform: scale(0); opacity: 0; transition: transform 400ms var(--ease), opacity 400ms; }
.sum-board { position: absolute; inset: 10% 5% 26%; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 40px); }
.sum-group { display: grid; justify-items: center; gap: 10px; padding: 14px; border-radius: 24px; background: color-mix(in srgb, var(--leaf-2) 70%, transparent); }
.sum-n { display: grid; place-items: center; min-width: 52px; height: 52px; border-radius: 26px; background: #fff; color: #1B2A1F; border: 3px solid #1B2A1F; font-family: var(--font-display); font-size: 28px; }
.sum-fruits { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.fruit-dot { width: clamp(20px, 3.6vw, 32px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--fruit-2), var(--fruit-1) 70%); box-shadow: 0 2px 4px var(--shade); }
.sum-plus { font-family: var(--font-display); font-size: clamp(40px, 7vw, 64px); font-weight: 800; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.sum-board.is-solved .sum-group { box-shadow: 0 0 0 4px var(--good); }
/* Listen button: glows and its sound waves pulse while the teacher voice is speaking */
.btn-listen.is-speaking { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-listen.is-speaking svg path:last-child { animation: speak-wave 0.9s ease-in-out infinite; transform-origin: 40% 50%; }
@keyframes speak-wave { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }

/* ---------- Games shelf: one row that slides, big arrows left and right ---------- */

.shelf { position: relative; }
.game-grid.is-shelf {
  --per: 4;
  grid-template-columns: none; grid-auto-flow: column;
  grid-auto-columns: calc((100% - (var(--per) - 1) * clamp(16px, 2vw, 24px)) / var(--per));
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  /* room for the lift, shadow and focus glow of the cards inside the scroll area */
  padding: 14px 10px 34px; margin: -14px -10px -34px;
  scroll-padding-inline: 10px;
}
.game-grid.is-shelf::-webkit-scrollbar { display: none; }
.game-grid.is-shelf > li { scroll-snap-align: start; }
@media (max-width: 1179px) { .game-grid.is-shelf { --per: 3; } }
@media (max-width: 760px) { .game-grid.is-shelf { --per: 2; } }
@media (max-width: 479px) { .game-grid.is-shelf { --per: 1.25; } }

.shelf-arrow {
  position: absolute; z-index: 4; top: calc(50% - 20px); translate: 0 -50%;
  display: grid; place-items: center; width: 60px; height: 60px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--glass-line); background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-3);
  transition: transform 250ms var(--spring), background-color var(--dur-fast) var(--ease), opacity var(--dur) var(--ease);
}
.shelf-arrow[hidden] { display: none; }
.shelf-arrow--prev { inset-inline-start: -26px; }
.shelf-arrow--next { inset-inline-end: -26px; }
.shelf-arrow:active { transform: scale(0.92); }
@media (hover: hover) { .shelf-arrow:hover { transform: scale(1.1); background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); } }
@media (max-width: 760px) { .shelf-arrow { width: 48px; height: 48px; } .shelf-arrow--prev { inset-inline-start: -6px; } .shelf-arrow--next { inset-inline-end: -6px; } }

/* ---------- Page arrows (up / down) at the side of the screen ---------- */

.page-nav {
  position: fixed; z-index: 25; inset-inline-end: max(14px, env(safe-area-inset-right, 0px)); bottom: max(18px, env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px; padding: 6px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.page-nav[hidden] { display: none; }
.page-arrow {
  display: grid; place-items: center; width: 50px; height: 50px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--fg); transition: transform 200ms var(--spring), opacity var(--dur) var(--ease), background-color var(--dur-fast);
}
.page-arrow:disabled { opacity: 0.3; cursor: default; }
.page-arrow:not(:disabled):active { transform: scale(0.9); }
@media (hover: hover) { .page-arrow:not(:disabled):hover { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); } }

/* Music button shows when the tune is on */
.icon-btn[data-toggle="music"].is-on { color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

/* TV remote: arrows glow like the other buttons; a bit bigger in TV mode */
:root.is-keyboard .shelf-arrow:focus-visible, :root.is-keyboard .page-arrow:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--focus-tv), 0 0 0 9px color-mix(in srgb, var(--focus-tv) 30%, transparent);
}
:root.is-tv .shelf-arrow { width: 72px; height: 72px; }
:root.is-tv .page-arrow { width: 60px; height: 60px; }
/* The shelf scrolls inside the page: never let it widen the home column */
.home { grid-template-columns: minmax(0, 1fr); }
.home > *, .shelf { min-width: 0; }
/* Leave room under the games for the up/down pill, so it never covers a card */
.page-arrow { width: 44px; height: 44px; }
.home { padding-bottom: 140px; }
:root.is-tv .home { padding-bottom: 150px; }

/* ---------- Realistic photo cut-outs (cards, banner, results) ---------- */

.card-figure:has(.photo) { position: absolute; inset: 8% 6% 4%; width: auto; display: grid; place-items: end center; }
.photo { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 18px 16px rgba(0, 0, 0, 0.38)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.card-figure .photo--croc, .card-figure .photo--lion-sleep { max-width: 96%; margin-bottom: 8%; }
.card-figure .photo--chameleon { max-width: 92%; margin-bottom: 10%; }
.card-figure .photo--monkey { max-height: 100%; align-self: center; }
.card-figure .photo--macaw { max-height: 98%; }
.card-figure .photo--frog, .card-figure .photo--coconuts, .card-figure .photo--basket { max-height: 86%; }
.hero-figure:has(.photo) { width: clamp(170px, 20vw, 270px); }
.hero-figure .photo { width: 100%; filter: drop-shadow(0 26px 24px rgba(0, 0, 0, 0.45)); }
[dir="rtl"] .hero-figure .photo, [dir="rtl"] .card-figure .photo { transform: scaleX(-1); }
.result-art .photo { position: relative; z-index: 1; max-width: 60%; max-height: 86%; animation: float 4s ease-in-out infinite; }
.page-nav { display: none !important; } /* removed on request */
.home { padding-bottom: var(--space-7); }

/* ---------- Clean answers (all games) ---------- */
/* One clean style for every answer: white rounded discs with a soft shadow and a thin edge, big dark digits. */
.stage--3d .stone-btn, .stage .choices .stone-btn, .croc-stone {
  border-radius: 999px;
  border: 2px solid rgba(27, 42, 31, 0.14);
  background: radial-gradient(120% 90% at 50% 0%, #FFFFFF 55%, #F1F3EE);
  color: #17241B;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 -3px 0 rgba(0, 0, 0, 0.06) inset, 0 14px 26px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.18);
}
@media (hover: hover) { .stage .stone-btn:hover { transform: translateY(-3px) scale(1.03); } }
.stage .stone-btn:disabled { opacity: 0.45; }

/* Photo answers (What comes next?) and shape answers (2D toucan game). */
.stage .choices .photo-btn, .stage--3d .photo-btn { min-width: clamp(96px, 11vw, 140px); min-height: clamp(96px, 11vw, 140px); padding: 12px; }
.photo-btn img { width: clamp(64px, 7.5vw, 104px); height: clamp(64px, 7.5vw, 104px); object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25)); pointer-events: none; }
.shape-choices { flex-wrap: wrap; bottom: auto; top: 50%; transform: translateY(-50%); }
.shape-btn { padding: 14px; }
.shape-btn svg { width: clamp(64px, 8vw, 104px); height: clamp(64px, 8vw, 104px); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.25)); }

/* 2D pattern row and the eaten fruit of the 2D hungry parrot. */
.pattern-row { position: absolute; top: 22%; left: 0; right: 0; display: flex; justify-content: center; gap: clamp(6px, 1.4vw, 16px); flex-wrap: wrap; padding-inline: 16px; }
.pattern-item { display: grid; place-items: center; width: clamp(52px, 8vw, 96px); height: clamp(52px, 8vw, 96px); border-radius: 22px; background: rgba(255, 255, 255, 0.82); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.5); }
.pattern-item img { width: 80%; height: 80%; object-fit: contain; }
.pattern-item.is-gap { border: 3px dashed rgba(27, 42, 31, 0.45); background: rgba(255, 255, 255, 0.55); font: 800 clamp(28px, 4vw, 44px) var(--font-display); color: #17241B; }
.fruit-dot.is-eaten { opacity: 0.25; }

/* ---------- Game layer (js/gamify.js): coins, combo, shouts, player card, badges, stickers ---------- */
.gm-fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.gm-confetti { position: absolute; inset: 0; width: 100%; height: 100%; }

.gm-hud { display: inline-flex; align-items: center; gap: 8px; }
.gm-pill { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 8px; border-radius: 999px;
  background: linear-gradient(180deg, #FFFFFF, #FFF4D6); border: 2px solid rgba(214, 150, 20, 0.45);
  box-shadow: 0 4px 0 rgba(150, 95, 0, 0.25), 0 8px 18px rgba(0, 0, 0, 0.12); color: #5A3A00;
  font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1; }
.gm-pill svg { width: 30px; height: 30px; flex: none; }
.gm-pill--coins b { min-width: 2.2ch; text-align: end; }
.gm-pill--combo { padding-inline: 8px 12px; transition: background .3s, color .3s, box-shadow .3s; }
.gm-pill--combo[data-level="0"] { filter: grayscale(1); opacity: .7; }
.gm-pill--combo[data-level="2"] { background: linear-gradient(180deg, #FFB347, #FF7A1A); color: #fff; border-color: #FFD27A; }
.gm-pill--combo[data-level="3"] { background: linear-gradient(180deg, #FF6A3D, #D9342B); color: #fff; border-color: #FFC65A;
  box-shadow: 0 4px 0 rgba(120, 20, 0, 0.35), 0 0 22px rgba(255, 110, 30, 0.85); animation: gm-glow 0.9s ease-in-out infinite alternate; }
.gm-pill--combo[data-level="2"] svg, .gm-pill--combo[data-level="3"] svg { animation: gm-flicker .35s ease-in-out infinite alternate; transform-origin: 50% 90%; }
.is-bump { animation: gm-bump .35s cubic-bezier(.3,1.8,.5,1); }
.gm-hud.is-broken .gm-pill--combo { animation: gm-shake .4s; }
@keyframes gm-bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes gm-flicker { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.12) rotate(4deg); } }
@keyframes gm-glow { from { box-shadow: 0 4px 0 rgba(120,20,0,.35), 0 0 12px rgba(255,110,30,.6); } to { box-shadow: 0 4px 0 rgba(120,20,0,.35), 0 0 30px rgba(255,150,30,1); } }
@keyframes gm-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px) rotate(-4deg); } 40% { transform: translateX(6px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

.gm-coin-fly { position: fixed; width: 38px; height: 38px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
.gm-coin-fly svg { width: 100%; height: 100%; animation: gm-spin .5s linear infinite; }
@keyframes gm-spin { from { transform: scaleX(1); } 50% { transform: scaleX(.25); } to { transform: scaleX(1); } }

.gm-float { position: fixed; transform: translate(-50%, -50%); font-family: var(--font-display); font-weight: 700; font-size: clamp(34px, 4.5vw, 56px);
  color: #FFD23F; -webkit-text-stroke: 2px #7A4A00; paint-order: stroke fill; text-shadow: 0 4px 0 #7A4A00, 0 10px 24px rgba(0,0,0,.35);
  animation: gm-float 1.3s cubic-bezier(.2,.8,.3,1) forwards; }
@keyframes gm-float { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }

.gm-shout { position: absolute; left: 50%; top: 30%; display: inline-flex; align-items: center; gap: 14px; padding: 14px 30px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 4.6vw, 60px); line-height: 1; white-space: nowrap; color: #fff;
  background: linear-gradient(180deg, #FFC93C, #F08A00); border: 4px solid #FFF3C4; box-shadow: 0 8px 0 #A85A00, 0 20px 50px rgba(0,0,0,.35);
  text-shadow: 0 3px 0 rgba(120, 60, 0, .55); animation: gm-shout 1.5s cubic-bezier(.2,1.4,.4,1) forwards; }
.gm-shout svg { width: 1.2em; height: 1.2em; flex: none; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
.gm-shout--fire { background: linear-gradient(180deg, #FF8A3D, #D9342B); border-color: #FFD27A; box-shadow: 0 8px 0 #8A1C12, 0 0 60px rgba(255, 120, 30, .8); }
.gm-shout--fire svg { filter: brightness(1.3) drop-shadow(0 0 8px #FFE27A); }
.gm-shout.is-big { top: 38%; font-size: clamp(42px, 7vw, 92px); padding: 20px 44px; animation-duration: 2.2s; }
@keyframes gm-shout { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  28% { transform: translate(-50%, -50%) scale(1) rotate(0); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(.9); } }

.gm-daily-ribbon { position: absolute; top: 12px; inset-inline-start: 12px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px;
  border-radius: 999px; background: linear-gradient(180deg, #FFD54A, #F5A70F); color: #4A2E00; font-family: var(--font-display); font-weight: 700; font-size: 15px;
  box-shadow: 0 3px 0 #A86A00, 0 6px 14px rgba(0,0,0,.2); animation: gm-wiggle 2.4s ease-in-out infinite; }
.gm-daily-ribbon svg { width: 24px; height: 24px; }
@keyframes gm-wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-5deg); } 90% { transform: rotate(5deg); } 95% { transform: rotate(-3deg); } }

.gm-player { display: flex; align-items: center; gap: 14px; width: min(100%, 460px); margin-top: var(--space-3); padding: 12px 16px 12px 12px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.28); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--hero-ink); }
.gm-avatar { position: relative; flex: none; width: 66px; height: 66px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFF4C2, #F5A70F); border: 3px solid #FFE07A;
  box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.gm-avatar img { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); object-fit: contain; }
.gm-avatar-lvl { position: absolute; bottom: -6px; inset-inline-end: -6px; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  background: #D9342B; color: #fff; border: 2px solid #fff; font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 1; }
.gm-player-main { flex: 1; min-width: 0; display: grid; gap: 7px; }
.gm-player-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gm-player-head b { font-family: var(--font-display); font-size: 21px; line-height: 1; }
.gm-player-head span { font-size: 14px; font-weight: 700; color: var(--hero-muted); }
.gm-xp-bar { position: relative; display: block; height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); overflow: hidden; box-shadow: inset 0 2px 3px rgba(0,0,0,.25); }
.gm-xp-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--v, 0%); border-radius: inherit;
  background: linear-gradient(180deg, #FFE98A, #F5A70F); box-shadow: inset 0 -3px 0 rgba(160, 90, 0, .35); transition: width .7s cubic-bezier(.3,.9,.3,1); }
.gm-xp-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.6) 50%, transparent 70%); background-size: 200% 100%; animation: gm-sheen 2.2s linear infinite; }
@keyframes gm-sheen { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.gm-player-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-stat { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 11px 0 6px; border-radius: 999px; background: rgba(0,0,0,.22); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 17px; border: 0; }
.gm-stat svg { width: 24px; height: 24px; }
.gm-stat-btn { cursor: pointer; background: rgba(255,255,255,.2); transition: transform .15s, background .15s; }
.gm-stat-btn:hover { background: rgba(255,255,255,.32); transform: translateY(-1px); }
.gm-stat-btn:focus-visible { outline: 3px solid var(--focus-tv); outline-offset: 2px; }

.gm-results { display: grid; gap: 14px; width: min(100%, 440px); margin: var(--space-3) auto 0; }
.gm-earned { display: flex; align-items: center; justify-content: center; gap: 12px; }
.gm-earned-coin svg { width: 58px; height: 58px; animation: gm-spin 1.4s linear infinite; filter: drop-shadow(0 4px 6px rgba(0,0,0,.25)); }
.gm-earned-copy { display: grid; text-align: start; }
.gm-earned-copy small { font-size: 14px; font-weight: 700; color: var(--fg-muted); }
.gm-earned-copy > span { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; color: #C77700; font-variant-numeric: tabular-nums; }
.gm-xp { display: grid; gap: 6px; }
.gm-xp .gm-xp-level { justify-self: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--fg); }
.gm-results .gm-xp-bar { height: 18px; background: var(--surface-2); box-shadow: inset 0 2px 4px rgba(0,0,0,.15); }
.gm-rewards { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.gm-reward { display: grid; justify-items: center; gap: 2px; width: 118px; padding: 12px 8px; border-radius: 18px; background: linear-gradient(180deg, #FFF9E6, #FFEBB0);
  border: 2px solid rgba(214,150,20,.4); animation: gm-pop-in .6s cubic-bezier(.3,1.7,.5,1) both; }
.gm-reward small { font-size: 12px; font-weight: 700; color: #9A6200; }
.gm-reward b { font-family: var(--font-display); font-size: 16px; line-height: 1.1; color: #4A2E00; text-align: center; }
.gm-reward-art { display: grid; place-items: center; width: 76px; height: 76px; }
@keyframes gm-pop-in { 0% { opacity: 0; transform: scale(.2) rotate(-25deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.gm-sticker { display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #E8F5E0); border: 4px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.2); overflow: hidden; aspect-ratio: 1; }
.gm-sticker img { width: 86%; height: 86%; object-fit: contain; }

.gm-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(5, 25, 14, 0.62); backdrop-filter: blur(6px); animation: gm-fade .25s; }
.gm-modal-card { width: min(100%, 860px); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; border-radius: 28px; background: var(--surface); color: var(--fg);
  box-shadow: 0 30px 80px rgba(0,0,0,.4); display: grid; gap: 18px; animation: gm-pop-in .4s cubic-bezier(.3,1.5,.5,1); }
.gm-modal-card h2 { margin: 0; font-family: var(--font-display); font-size: 30px; text-align: center; }
.gm-modal-close { justify-self: center; }
@keyframes gm-fade { from { opacity: 0; } }
.gm-badge-grid, .gm-album { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.gm-badge { display: grid; justify-items: center; gap: 4px; padding: 14px 8px; border-radius: 18px; background: var(--surface-2); text-align: center; }
.gm-badge b { font-family: var(--font-display); font-size: 17px; line-height: 1.1; }
.gm-badge small { font-size: 13px; color: var(--fg-muted); line-height: 1.25; }
.gm-badge:not(.is-on) .gm-badge-art { filter: grayscale(1) opacity(.35); }
.gm-badge.is-on { background: linear-gradient(180deg, #FFF9E6, #FFEBB0); }
.gm-badge.is-on b { color: #4A2E00; }
.gm-badge.is-on small { color: #7A5A20; }
.gm-sticker-slot { display: grid; justify-items: center; gap: 6px; text-align: center; }
.gm-sticker-slot .gm-sticker { width: 100%; max-width: 120px; }
.gm-sticker-slot:not(.is-on) .gm-sticker { background: var(--surface-2); border-style: dashed; border-color: var(--line); box-shadow: none; }
.gm-sticker-slot:not(.is-on) img { filter: brightness(0) opacity(.18); }
.gm-sticker-slot small { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.gm-sticker-slot.is-on .gm-sticker { transform: rotate(-3deg); }
.gm-sticker-slot.is-on:nth-child(2n) .gm-sticker { transform: rotate(3deg); }

@media (max-width: 640px) {
  .gm-pill { height: 36px; font-size: 18px; padding-inline-end: 10px; }
  .gm-pill svg { width: 24px; height: 24px; }
  .gm-hud { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .gm-shout, .gm-float, .gm-reward, .gm-daily-ribbon, .gm-xp-fill::after, .gm-pill svg, .gm-earned-coin svg { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

/* 2D fallbacks for Turtle's eggs, Fill the crate and Giraffe's trees */
.order-row { display: flex; justify-content: center; gap: 10px; margin: var(--space-4) auto; }
.order-slot { display: grid; place-items: center; min-width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.55); border: 2px dashed rgba(23,36,27,.3);
  font-family: var(--font-display); font-weight: 700; font-size: 26px; color: #17241B; }
.order-slot.is-on { background: #fff; border-style: solid; border-color: #F2B51C; }
.egg-btn { border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; min-height: 84px; background: #F6EEDC; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 52px); gap: 8px; justify-content: center; margin: var(--space-4) auto; padding: 12px; width: max-content;
  border-radius: 14px; background: #B07A45; box-shadow: inset 0 0 0 4px #8E5728; }
.ten-frame .fruit-dot { width: 52px; height: 52px; }
.tree-row { display: flex; align-items: flex-end; justify-content: center; gap: 18px; height: 70%; padding-top: 8%; }
.tree-bar { width: 54px; height: var(--h); border: 0; border-radius: 26px 26px 6px 6px; cursor: pointer; background: linear-gradient(180deg, #3E964C 0 22%, #8E5728 22% 100%);
  box-shadow: 0 6px 14px rgba(0,0,0,.2); }
.tree-bar:focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 4px; }
.pick-row { flex-wrap: wrap; }
.pick-btn { min-width: 110px; min-height: 110px; display: grid; place-items: center; }
.pick-letter { font-family: var(--font-display); font-weight: 700; font-size: 64px; line-height: 1; }
.pick-color { width: 70px; height: 70px; border-radius: 50%; box-shadow: inset 0 -6px 0 rgba(0,0,0,.15), 0 0 0 3px #fff; }
.pick-photo { width: 120px; height: 100px; object-fit: contain; }

/* Home: category tabs (All / Maths / Letters & words / Shapes & colours) */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--space-3); }
.cat-tab { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface);
  color: var(--fg); font-family: var(--font-display); font-weight: 700; font-size: 17px; cursor: pointer; transition: transform .15s, background .15s; }
.cat-tab:hover { transform: translateY(-1px); }
.cat-tab[aria-selected="true"] { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); border-color: transparent; box-shadow: 0 4px 0 var(--accent-deep); }
.cat-tab:focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 2px; }
.cat-tab .cat-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .5; }
.stone-btn--time { font-variant-numeric: tabular-nums; min-width: 120px; font-size: 30px; }
.clock-face { width: min(60vw, 260px); margin: var(--space-3) auto; filter: drop-shadow(0 10px 20px rgba(0,0,0,.3)); }
.coin-pile { display: inline-block; max-width: 150px; font-size: 26px; line-height: 1.1; word-break: break-all; }

/* ---------- Motion: every screen glides in, cards breathe, buttons bounce ---------- */
.screen { animation: screen-in .55s cubic-bezier(.2,.9,.3,1) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
.game-grid > li { animation: card-in .6s cubic-bezier(.2,1.1,.35,1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(.94); } to { opacity: 1; transform: none; } }
.game-card { transition: transform .28s cubic-bezier(.2,.9,.3,1.3), box-shadow .28s; will-change: transform; }
@media (hover: hover) { .game-card:hover { transform: translateY(-8px) scale(1.025) rotate(-.4deg); } .game-card:hover .card-figure { transform: translateY(-6px) scale(1.06); } }
.game-card:focus-visible { transform: translateY(-8px) scale(1.025); }
.card-figure { transition: transform .4s cubic-bezier(.2,.9,.3,1.2); animation: figure-float 4.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -600ms); }
@keyframes figure-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
.stone-btn, .btn, .lang-pill, .cat-tab, .segment { transition: transform .16s cubic-bezier(.3,1.6,.5,1), box-shadow .16s, background .2s, color .2s; }
.stone-btn:active, .btn:active, .cat-tab:active, .segment:active { transform: scale(.94); }
@media (hover: hover) { .stone-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.05); } }
.hud.choices .stone-btn { animation: btn-in .5s cubic-bezier(.3,1.6,.5,1) both; }
.hud.choices .stone-btn:nth-child(2) { animation-delay: 70ms; } .hud.choices .stone-btn:nth-child(3) { animation-delay: 140ms; } .hud.choices .stone-btn:nth-child(4) { animation-delay: 210ms; }
@keyframes btn-in { from { opacity: 0; transform: translateY(30px) scale(.6); } to { opacity: 1; transform: none; } }
.result-card { animation: result-in .7s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes result-in { from { opacity: 0; transform: translateY(40px) scale(.9) rotate(-1deg); } to { opacity: 1; transform: none; } }
.stars--big .star.is-on { animation: star-in .6s cubic-bezier(.3,1.8,.5,1) both; }
.stars--big .star:nth-child(1) { animation-delay: .5s; } .stars--big .star:nth-child(2) { animation-delay: .85s; } .stars--big .star:nth-child(3) { animation-delay: 1.2s; }
@keyframes star-in { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 60% { transform: scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.hero-figure { animation: hero-sway 6s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes hero-sway { 0%, 100% { transform: rotate(-1.2deg) translateY(0); } 50% { transform: rotate(1.2deg) translateY(-8px); } }
.hero-chip { animation: chip-bob 3.4s ease-in-out infinite; }
.hero-chip--b { animation-delay: -1.1s; } .hero-chip--c { animation-delay: -2.3s; }
@keyframes chip-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
.progress li.is-current { animation: dot-pulse 1.2s ease-in-out infinite; }
@keyframes dot-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.toast.is-visible { animation: toast-in .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes toast-in { from { transform: translate(-50%, 14px) scale(.7); opacity: 0; } }
.stage-canvas { animation: stage-in .8s ease-out both; }
@keyframes stage-in { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: blur(0); } }
@media (prefers-reduced-motion: reduce) { .screen, .game-grid > li, .card-figure, .hud.choices .stone-btn, .result-card, .stars--big .star, .hero-figure, .hero-chip, .progress li, .stage-canvas { animation: none !important; } }

/* ---------- Picture dictionary ---------- */
.dict { display: grid; gap: var(--space-3); }
.dict-intro { margin: 0; color: var(--fg-muted); font-size: 17px; }
.dict-title { margin: var(--space-3) 0 0; font-family: var(--font-display); font-size: clamp(24px, 3vw, 32px); }
.dict-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.dict-card { position: relative; display: grid; gap: 8px; padding: 12px; border-radius: 22px; background: var(--surface); border: 1px solid var(--glass-line); box-shadow: var(--shadow-2);
  animation: card-in .5s cubic-bezier(.2,1.1,.35,1) both; animation-delay: min(calc(var(--i, 0) * 25ms), 500ms); }
.dict-art { display: grid; place-items: center; height: 150px; border: 0; border-radius: 16px; cursor: pointer; background: radial-gradient(circle at 50% 40%, var(--surface-2), color-mix(in srgb, var(--surface-2) 70%, var(--bg))); transition: transform .2s; }
.dict-art:hover { transform: scale(1.04); }
.dict-art:focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 2px; }
.dict-art img { width: auto; height: auto; max-width: 200px; max-height: 128px; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0,0,0,.25)); }
.dict-color { width: 100px; height: 100px; border-radius: 50%; box-shadow: inset 0 -10px 0 rgba(0,0,0,.15), 0 0 0 5px #fff; }
.dict-shape { width: 110px; height: 110px; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }
.dict-number { font-family: var(--font-display); font-weight: 800; font-size: 84px; line-height: 1; color: #17241B; background: #fff; border-radius: 50%; width: 120px; height: 120px; display: grid; place-items: center; box-shadow: 0 6px 14px rgba(0,0,0,.2); }
.dict-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dict-row { display: grid; grid-template-columns: 44px 1fr 40px; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 12px; transition: background .2s; }
.dict-row.is-on { background: var(--accent-soft); }
.dict-lang { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--fg-muted); text-align: center; }
.dict-word { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.2; }
.dict-say { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--fg); display: grid; place-items: center; cursor: pointer; transition: transform .15s, background .2s; }
.dict-say:hover { transform: scale(1.1); } .dict-say.is-on { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); }
.dict-say:focus-visible { outline: 3px solid var(--focus-tv); }
.dict-all { position: absolute; top: 18px; inset-inline-end: 18px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.25); transition: transform .15s; }
.dict-all:hover { transform: scale(1.12) rotate(10deg); }
.dict-scene { justify-self: center; }
.dict-modal-card { width: min(100%, 980px); display: grid; gap: 12px; padding: 16px; border-radius: 28px; background: var(--surface); color: var(--fg); box-shadow: 0 30px 80px rgba(0,0,0,.4); animation: gm-pop-in .4s cubic-bezier(.3,1.5,.5,1); }
.dict-stage { height: min(58vh, 520px); border-radius: 20px; overflow: hidden; position: relative; }
.dict-caption { margin: 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 3.6vw, 44px); line-height: 1.2; }
.dict-caption.is-new { animation: num-pop .5s cubic-bezier(.3,1.6,.5,1); }
.dict-modal-foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; }
.dict-flat { display: grid; place-items: center; height: 100%; background: var(--surface-2); }
.dict-flat img { max-height: 80%; animation: figure-float 2s ease-in-out infinite; }
.word-btn { min-width: 0; padding: 10px 18px; font-size: clamp(20px, 2.4vw, 28px); white-space: nowrap; }
.pick-photo-wrap .pick-photo { width: 160px; height: 130px; }
.segmented .segment small { white-space: nowrap; }

/* ---------- Phone game mode (portrait and landscape) ----------
   On phones a game looks like a real mobile game: the 3D scene runs edge to edge and the header + question shrink
   into one slim HUD strip that keeps clear of the notch / Dynamic Island in both orientations. */
.is-native-app [data-fs] { display: none !important; } /* the app is always full screen */
.stage .hud { left: max(var(--space-4), env(safe-area-inset-left, 0px)); right: max(var(--space-4), env(safe-area-inset-right, 0px)); }
.stage .hud--bottom { bottom: max(var(--space-4), env(safe-area-inset-bottom, 0px)); }

@media (max-width: 760px), (max-height: 560px) {
  :root.is-immersive body[data-screen="game"] .game {
    gap: 6px; padding: max(6px, env(safe-area-inset-top, 0px)) 0 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 70%, #0A3B22) 0%, var(--bg) 100%);
  }
  :root.is-immersive body[data-screen="game"] .game-head,
  :root.is-immersive body[data-screen="game"] .prompt-card {
    margin-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px));
  }
  :root.is-immersive body[data-screen="game"] .game-head { gap: 8px; }
  :root.is-immersive body[data-screen="game"] .game-head .icon-btn { width: 40px; height: 40px; min-width: 40px; }
  :root.is-immersive body[data-screen="game"] .game-title h1 { font-size: 18px; }
  :root.is-immersive body[data-screen="game"] .game-title p { display: none; }
  :root.is-immersive body[data-screen="game"] .game-head-end { gap: 6px; }
  :root.is-immersive body[data-screen="game"] .gm-pill { height: 36px; padding: 0 10px 0 6px; font-size: 15px; }
  :root.is-immersive body[data-screen="game"] .gm-pill svg { width: 24px; height: 24px; }
  :root.is-immersive body[data-screen="game"] .progress { padding: 5px 6px; gap: 4px; }
  :root.is-immersive body[data-screen="game"] .progress li { width: 12px; height: 7px; }
  :root.is-immersive body[data-screen="game"] .progress .is-current { width: 20px; }
  /* The question: one compact speech strip with an icon-only Listen button */
  :root.is-immersive body[data-screen="game"] .prompt-card { flex-wrap: nowrap; gap: 8px; padding: 8px 8px 8px 18px; border-radius: 18px; }
  :root.is-immersive body[data-screen="game"] .prompt-text { flex-basis: auto; font-size: clamp(17px, 4.6vw, 21px); line-height: 1.2; }
  :root.is-immersive body[data-screen="game"] .prompt-text .num { border-radius: 9px; }
  :root.is-immersive body[data-screen="game"] .prompt-langs { display: none; }
  :root.is-immersive body[data-screen="game"] .btn-listen { flex: none; width: 48px; height: 48px; min-height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
  :root.is-immersive body[data-screen="game"] .btn-listen span { display: none; }
  :root.is-immersive body[data-screen="game"] .stage { border-radius: 0; box-shadow: none; }
  /* Answer pebbles a bit smaller so a row fits a phone */
  :root.is-immersive body[data-screen="game"] .stage--3d .stone-btn { min-width: 64px; min-height: 56px; padding: 4px 14px; font-size: 28px; }
}

/* Landscape phones: title, question, Listen and progress share ONE row so the scene gets almost the whole height */
@media (max-height: 560px) and (orientation: landscape) {
  :root.is-immersive body[data-screen="game"] .game {
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr);
    column-gap: 8px; row-gap: 6px; padding-top: 6px;
  }
  :root.is-immersive body[data-screen="game"] .game-head { display: contents; }
  :root.is-immersive body[data-screen="game"] .game-head > .icon-btn { grid-column: 1; grid-row: 1; margin-inline-start: max(10px, env(safe-area-inset-left, 0px)); }
  :root.is-immersive body[data-screen="game"] .game-title { display: none; }
  :root.is-immersive body[data-screen="game"] .prompt-card { grid-column: 2; grid-row: 1; margin: 0; padding-block: 6px; }
  :root.is-immersive body[data-screen="game"] .game-head-end { grid-column: 3; grid-row: 1; margin-inline-end: max(10px, env(safe-area-inset-right, 0px)); }
  :root.is-immersive body[data-screen="game"] .prompt-text { font-size: clamp(16px, 2.4vw, 20px); white-space: normal; }
  :root.is-immersive body[data-screen="game"] .btn-listen { width: 42px; height: 42px; min-height: 42px; }
  :root.is-immersive body[data-screen="game"] .stage { grid-column: 1 / -1; grid-row: 2; }
  :root.is-immersive body[data-screen="game"] .toast { top: 60px; }
}

/* =====================================================================================================
   Game menu (home + result): one green jungle world edge to edge, a game HUD in the corners, one giant
   toy PLAY button, picture tiles. Portrait scrolls down to the tiles; landscape is two panes (no page scroll).
   ===================================================================================================== */
:root {
  --ledge-h: 6px;
  --ledge: 0 var(--ledge-h) 0 var(--accent-deep);
  --ledge-world: 0 6px 0 rgba(4, 28, 14, 0.55);
  --hud-h: 56px;
  --hud-top: max(8px, env(safe-area-inset-top, 0px));
  --hud-side-l: max(12px, env(safe-area-inset-left, 0px));
  --hud-side-r: max(12px, env(safe-area-inset-right, 0px));
  --world-1: #1F7D45;
  --world-2: #0A3B22;
  --world: radial-gradient(120% 70% at 50% 0%, rgba(130, 210, 100, 0.22), transparent 60%), linear-gradient(180deg, var(--world-1), var(--world-2));
  --play-h: clamp(80px, 11vh, 104px);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ledge: 0 var(--ledge-h) 0 #8F4700; --world-1: #17532F; --world-2: #06180E; } }
:root[data-theme="dark"] { --ledge: 0 var(--ledge-h) 0 #8F4700; --world-1: #17532F; --world-2: #06180E; }
@property --hold { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

:root body[data-screen="home"], :root body[data-screen="result"] { background: var(--world-2); background-image: var(--world); background-attachment: fixed; color: var(--hero-ink); }
:root body[data-screen="home"]::before, :root body[data-screen="home"]::after,
:root body[data-screen="result"]::before, :root body[data-screen="result"]::after { display: none; }

/* ---------- HUD (top bar on menu and result) ---------- */
:root body[data-screen="home"] .topbar, :root body[data-screen="result"] .topbar {
  position: sticky; top: 0; padding-top: 0; border-bottom: 0;
  background: color-mix(in srgb, var(--world-1) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.hud-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: calc(var(--hud-top) + var(--hud-h)); padding: var(--hud-top) var(--hud-side-r) 0 var(--hud-side-l);
  padding-inline: var(--hud-side-l) var(--hud-side-r); max-width: none; margin: 0;
}
.hud-start, .hud-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-pill, .hud-player, .hud-gear, .hud-corner, .round-face {
  background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); color: #fff;
}
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 8px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.hud-pill svg { width: 26px; height: 26px; flex: none; }
.hud-stars svg { fill: var(--star); filter: drop-shadow(0 1px 1px rgba(150, 90, 0, 0.35)); }
.hud-pill b { font-weight: 800; }
.hud-player {
  display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 4px 14px 4px 4px; min-width: 0;
  border: 0; border-radius: var(--radius-pill); cursor: pointer; font: inherit;
  transition: transform var(--dur-fast) var(--spring);
}
.hud-player:active { transform: scale(0.94); }
.hud-player .gm-avatar { width: 44px; height: 44px; }
.hud-player .gm-avatar-lvl { min-width: 22px; height: 22px; bottom: -3px; inset-inline-end: -5px; font-size: 13px; padding: 0 4px; }
.hud-player-main { display: grid; gap: 4px; min-width: 0; }
.hud-player-rank { font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.hud-player .gm-xp-bar { width: 64px; height: 8px; }
@media (max-width: 719px) { .hud-player-rank { display: none; } .hud-player { padding-inline-end: 12px; } }
.hud-gear { position: relative; width: 48px; height: 48px; border: 0; border-radius: 50%; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.hud-gear svg { width: 26px; height: 26px; }
.hud-gear::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: conic-gradient(var(--accent-hi) var(--hold), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
}
.hud-gear.is-holding::after { opacity: 1; animation: gear-hold 1s linear forwards; }
.hud-gear.is-holding svg { animation: gear-spin 1s linear; }
.hud-gear.is-wiggle svg { animation: gear-wiggle .32s ease; }
@keyframes gear-hold { to { --hold: 100%; } }
@keyframes gear-spin { to { transform: rotate(120deg); } }
@keyframes gear-wiggle { 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }

/* ---------- Menu stage ---------- */
:root body[data-screen="home"] .home { display: block; padding: 0; gap: 0; }
:root body[data-screen="home"] .menu-stage {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vh, 18px);
  min-height: calc(76svh - var(--hud-h)); padding: 8px var(--hud-side-r) 84px var(--hud-side-l);
  grid-template-columns: none; border-radius: 0; background: none; box-shadow: none; overflow: visible; text-align: center;
}
:root body[data-screen="home"] .menu-stage::after { display: none; }
.stage-logo { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(30px, 8vw, 44px); line-height: 1; letter-spacing: -0.01em; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.stage-logo:focus { outline: none; }
.stage-logo-mark { display: grid; width: 1.15em; height: 1.15em; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); }
.stage-logo-mark svg { width: 100%; height: 100%; }
:root body[data-screen="home"] .hero-art { width: min(100%, 420px); height: clamp(150px, 30svh, 280px); min-height: 0; }
:root body[data-screen="home"] .hero-figure { width: clamp(120px, 26svh, 230px); }
:root body[data-screen="home"] .hero-orb { width: clamp(170px, 34svh, 300px); }

/* The one toy PLAY button */
.btn-play {
  position: relative; display: inline-flex; align-items: center; gap: 14px; width: min(100%, 420px); min-height: var(--play-h);
  padding: 10px 28px 10px 10px; border: 0; border-radius: var(--radius-pill); cursor: pointer; text-align: start;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink);
  box-shadow: var(--ledge), 0 18px 36px -12px var(--accent-glow), inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  animation: play-breathe 1.8s ease-in-out infinite; touch-action: manipulation;
}
.btn-play:hover, .btn-play:focus-visible { animation-play-state: paused; }
.btn-play:active { transform: translateY(var(--ledge-h)); box-shadow: 0 0 0 var(--accent-deep), 0 8px 18px -10px var(--accent-glow), inset 0 2px 0 rgba(255, 255, 255, 0.45); animation: none; }
.btn-play:focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 4px; }
.play-thumb { position: relative; flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 3px #fff, 0 4px 10px rgba(0, 0, 0, 0.25); }
.play-thumb svg, .play-thumb .photo, .play-thumb img { width: 86%; height: 86%; object-fit: contain; }
.play-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-ink); color: #fff; }
.play-icon svg { width: 20px; height: 20px; margin-inline-start: 3px; }
.play-copy { display: grid; min-width: 0; line-height: 1.05; }
.play-copy b { font-family: var(--font-display); font-size: clamp(28px, 7vw, 40px); font-weight: 800; letter-spacing: 0.02em; }
.play-copy b:lang(en), .play-copy b:lang(fr), .play-copy b:lang(es) { text-transform: uppercase; }
.play-copy small { font-family: var(--font-display); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
@keyframes play-breathe { 0%, 100% { scale: 1; } 50% { scale: 1.035; } }
.btn-play.is-hint::after { content: "👆"; position: absolute; inset-inline-end: 18px; bottom: -26px; font-size: 40px; pointer-events: none; animation: play-hint 3s 4s ease-in-out infinite both; }
@keyframes play-hint { 0%, 60%, 100% { opacity: 0; transform: translateY(14px); } 70%, 90% { opacity: 1; transform: translateY(0); } 80% { transform: translateY(-8px) scale(.92); } }

/* Treasure corners + "more games" chevron */
.stage-corners { position: absolute; bottom: 14px; inset-inline: var(--hud-side-l) var(--hud-side-r); display: flex; justify-content: space-between; pointer-events: none; }
.hud-corner {
  pointer-events: auto; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 60px; height: 60px; padding: 4px 8px; border: 0; border-radius: var(--radius-card); cursor: pointer;
  box-shadow: var(--ledge-world), inset 0 0 0 1px rgba(255, 255, 255, 0.14); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast);
}
.hud-corner svg { width: 28px; height: 28px; }
.hud-corner b { font-size: 13px; font-weight: 800; line-height: 1; }
.hud-corner:active, .round-btn:active .round-face { transform: translateY(6px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.more-games { position: absolute; bottom: 18px; left: 50%; translate: -50% 0; width: 48px; height: 48px; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; animation: more-bounce 1.6s ease-in-out infinite; }
@keyframes more-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ---------- Tray: level staircase, category chips, tiles ---------- */
.menu-tray { padding: 0 0 max(24px, env(safe-area-inset-bottom, 0px)); scroll-margin-top: calc(var(--hud-top) + var(--hud-h)); }
.tray-bar {
  position: sticky; top: calc(var(--hud-top) + var(--hud-h)); z-index: 5; display: grid; gap: 10px;
  padding: 10px var(--hud-side-r) 12px var(--hud-side-l);
  background: color-mix(in srgb, color-mix(in srgb, var(--world-1) 55%, var(--world-2)) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.level-stairs { display: flex; align-items: flex-end; gap: 12px; }
.stairs-label { flex: none; align-self: center; font-size: 13px; font-weight: 700; color: var(--hero-muted); }
:root body[data-screen="home"] .segmented {
  display: flex; align-items: flex-end; gap: 8px; width: auto; padding: 0 0 18px; margin: 0;
  background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
:root body[data-screen="home"] .segment {
  --step: 1; position: relative; flex: none; width: 54px; min-width: 0; height: calc(40px + var(--step) * 5px); min-height: 0; padding: 0;
  border-radius: 16px; background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: var(--ledge-world);
}
:root body[data-screen="home"] .segment:nth-child(2) { --step: 2; }
:root body[data-screen="home"] .segment:nth-child(3) { --step: 3; }
:root body[data-screen="home"] .segment:nth-child(4) { --step: 4; }
:root body[data-screen="home"] .segment:nth-child(5) { --step: 5; }
.segment-face { font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1; }
:root body[data-screen="home"] .segment small {
  position: absolute; top: calc(100% + 8px); left: 50%; translate: -50% 0; max-width: none;
  font-size: 11px; font-weight: 600; color: var(--hero-muted); opacity: 1; white-space: nowrap; letter-spacing: 0;
}
:root body[data-screen="home"] .segment[aria-checked="true"] { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: var(--ledge), inset 0 2px 0 rgba(255, 255, 255, 0.4); }
:root body[data-screen="home"] .segment[aria-checked="true"] small { color: #fff; font-weight: 800; }
:root body[data-screen="home"] .segment:active { transform: translateY(5px); box-shadow: none; }

:root body[data-screen="home"] .cat-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0; padding: 2px 0 6px; scrollbar-width: none; scroll-snap-type: x proximity; }
:root body[data-screen="home"] .cat-tabs::-webkit-scrollbar { display: none; }
:root body[data-screen="home"] .cat-tab { flex: none; height: 48px; padding: 0 16px 0 6px; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; font-family: var(--font-display); font-size: 15px; font-weight: 700; scroll-snap-align: start; }
:root body[data-screen="home"] .cat-tab[aria-selected="true"] { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-deep); }
:root body[data-screen="home"] .cat-dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); opacity: 1; font-size: 13px; font-weight: 800; }
:root body[data-screen="home"] .cat-tab[aria-selected="true"] .cat-dot { background: rgba(255, 255, 255, 0.45); }

:root body[data-screen="home"] .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px var(--hud-side-r) 0 var(--hud-side-l); margin: 0; }
@media (min-width: 600px) { :root body[data-screen="home"] .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { :root body[data-screen="home"] .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
:root body[data-screen="home"] .game-card { padding: 0; border: 0; border-radius: var(--radius-card); box-shadow: var(--ledge-world), var(--shadow-2); }
:root body[data-screen="home"] .game-card:active { transform: translateY(6px); box-shadow: var(--shadow-1); }
:root body[data-screen="home"] .card-art { border-radius: var(--radius-card) var(--radius-card) 0 0; aspect-ratio: 4 / 3; }
:root body[data-screen="home"] .card-num { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 13px; font-weight: 800; }
:root body[data-screen="home"] .card-body { padding: 10px 12px 12px; gap: 2px; }
:root body[data-screen="home"] .card-title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root body[data-screen="home"] .card-foot { margin-top: 6px; gap: 6px; }
:root body[data-screen="home"] .card-foot .stars .star { width: 20px; height: 20px; }
:root body[data-screen="home"] .chip-play { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; margin-inline-start: auto; background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-deep); }
:root body[data-screen="home"] .chip-play span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:root body[data-screen="home"] .chip-play svg { width: 18px; height: 18px; margin-inline-start: 2px; }
.card-lvl { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold-soft-2); color: var(--gold-ink); font-size: 12px; font-weight: 800; }
@media (max-width: 759px) { :root body[data-screen="home"] .card-skill { display: none; } }

/* Landscape: two panes, the menu on the start side, the tiles scroll on the end side; no page scroll */
@media (orientation: landscape) and (min-width: 640px) {
  :root body[data-screen="home"] { overflow: hidden; height: 100dvh; }
  :root body[data-screen="home"] #main { height: calc(100dvh - var(--hud-top) - var(--hud-h)); }
  :root body[data-screen="home"] .home {
    display: grid; grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); gap: 16px; height: 100%;
    padding: 0 var(--hud-side-r) max(12px, env(safe-area-inset-bottom, 0px)) var(--hud-side-l);
  }
  :root body[data-screen="home"] .menu-stage { min-height: 0; height: 100%; padding: 4px 4px 76px; }
  :root body[data-screen="home"] .stage-corners { inset-inline: 4px; bottom: 8px; }
  :root body[data-screen="home"] .more-games { display: none; }
  :root body[data-screen="home"] .hero-art { height: clamp(90px, 26svh, 240px); }
  :root body[data-screen="home"] .hero-figure { width: clamp(80px, 22svh, 200px); }
  .menu-tray { min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-xl); background: rgba(0, 0, 0, 0.18); padding: 0 0 12px; }
  .tray-bar { top: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-inline: 12px; }
  :root body[data-screen="home"] .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-inline: 12px; }
}
@media (orientation: landscape) and (min-width: 1300px) { :root body[data-screen="home"] .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (orientation: landscape) and (max-height: 430px) {
  :root { --hud-h: 48px; --play-h: 64px; }
  .stage-logo { display: none; }
  .hud-pill { height: 38px; font-size: 16px; } .hud-pill svg { width: 22px; height: 22px; }
  .hud-player { height: 44px; } .hud-player .gm-avatar { width: 36px; height: 36px; } .hud-gear { width: 42px; height: 42px; }
  .play-thumb { width: 46px; height: 46px; } .play-icon { width: 36px; height: 36px; } .play-copy b { font-size: 26px; } .play-copy small { font-size: 14px; }
  .btn-play { padding-inline-end: 18px; gap: 10px; }
  .hud-corner { min-width: 52px; height: 52px; }
  :root body[data-screen="home"] .segment { width: 46px; height: calc(34px + var(--step) * 4px); }
  .stairs-label { display: none; }
}

/* ---------- Settings sheet (grown-ups) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(5, 25, 14, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity 250ms var(--ease); }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: absolute; bottom: 0; left: 0; right: 0; margin-inline: auto; width: min(100%, 560px); max-height: 88dvh; overflow-y: auto;
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-3);
  transform: translateY(100%); transition: transform 300ms var(--spring);
}
.sheet-backdrop.is-open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-family: var(--font-display); font-size: var(--text-title); }
.sheet-close { width: 48px; height: 48px; font-size: 20px; }
.sheet-group { margin: 10px 0 6px; padding: 0; border: 0; }
.sheet-group legend { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0; font-size: 16px; font-weight: 700; color: var(--fg-muted); }
.lang-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lang-option {
  display: grid; place-items: center; gap: 2px; min-height: 74px; padding: 8px 4px; border: 0; border-radius: var(--radius-card); cursor: pointer;
  background: var(--surface-2); color: var(--fg); box-shadow: 0 4px 0 var(--line), var(--shadow-1); transition: transform var(--dur-fast) var(--spring);
}
.lang-option b { font-family: var(--font-display); font-size: 22px; font-weight: 800; line-height: 1; }
.lang-option small { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.lang-option[aria-checked="true"] { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 5px 0 #8F4700; }
.lang-option[aria-checked="true"] small { color: var(--accent-ink); }
.lang-option:active { transform: translateY(4px); }
.lang-option:focus-visible, .switch:focus-visible, .sheet-close:focus-visible, .sheet-done:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting-icon { display: grid; color: var(--fg-muted); }
.setting-icon svg { width: 26px; height: 26px; }
.setting-label { flex: 1; font-size: 17px; font-weight: 700; }
.switch { position: relative; flex: none; width: 78px; height: 42px; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; transition: background var(--dur) var(--ease); }
.switch::after { content: ""; position: absolute; top: 5px; inset-inline-start: 5px; width: 32px; height: 32px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform var(--dur) var(--spring); }
.switch[aria-checked="true"] { background: var(--good); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(36px); }
[dir="rtl"] .switch[aria-checked="true"]::after { transform: translateX(-36px); }
.switch-text { position: absolute; top: 50%; translate: 0 -50%; inset-inline-end: 10px; font-size: 12px; font-weight: 800; color: var(--fg-muted); }
.switch[aria-checked="true"] .switch-text { inset-inline: 10px auto; color: #fff; }
[dir="rtl"] .switch[aria-checked="true"] .switch-text { inset-inline: 10px auto; }
.sheet-done { width: 100%; min-height: 52px; margin-top: 14px; }
@media (orientation: landscape) and (max-height: 560px) {
  .sheet { top: 0; bottom: 0; left: auto; right: 0; margin: 0; width: min(440px, 58vw); max-height: none; border-radius: var(--radius-xl) 0 0 var(--radius-xl); transform: translateX(100%); padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  [dir="rtl"] .sheet { right: auto; left: 0; border-radius: 0 var(--radius-xl) var(--radius-xl) 0; transform: translateX(-100%); }
  .lang-option { min-height: 62px; }
}

/* ---------- Result ---------- */
:root body[data-screen="result"] .result { min-height: calc(100dvh - var(--hud-top) - var(--hud-h)); padding: 12px var(--hud-side-r) max(20px, env(safe-area-inset-bottom, 0px)) var(--hud-side-l); }
:root body[data-screen="result"] .result-card { display: grid; gap: 16px; width: min(100%, 520px); padding: 0; border: 0; background: none; box-shadow: none; overflow: visible; color: #fff; }
.result-hero, .result-side { display: grid; justify-items: center; gap: 12px; }
:root body[data-screen="result"] .result-art { width: 160px; height: 160px; aspect-ratio: 1; border-radius: var(--radius-xl); box-shadow: var(--ledge-world), var(--shadow-2); }
:root body[data-screen="result"] .result-card h1 { margin: 0; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
:root body[data-screen="result"] .stars--big { background: rgba(0, 0, 0, 0.24); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
:root body[data-screen="result"] .stars--big .star { width: 60px; height: 60px; }
:root body[data-screen="result"] .result-score { color: #fff; font-family: var(--font-display); font-size: 28px; font-weight: 800; }
:root body[data-screen="result"] .gm-results { width: 100%; padding: 14px; border-radius: var(--radius-card); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-2); }
:root body[data-screen="result"] .result-actions { display: grid; justify-items: center; gap: 16px; width: 100%; margin: 0; padding: 0; }
.btn-play--result { justify-content: center; padding-inline: 24px; }
.btn-play--result .play-copy b { font-size: clamp(22px, 6vw, 30px); }
.result-round { display: flex; justify-content: center; gap: 28px; }
.round-btn { display: grid; justify-items: center; gap: 6px; padding: 0; border: 0; background: none; color: #fff; cursor: pointer; font: inherit; }
.round-face { position: relative; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; box-shadow: var(--ledge-world), inset 0 0 0 1px rgba(255, 255, 255, 0.14); transition: transform var(--dur-fast) var(--ease); }
.round-face svg { width: 28px; height: 28px; }
.round-face b { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; display: grid; place-items: center; }
.round-btn small { font-size: 13px; font-weight: 700; color: var(--hero-muted); max-width: 110px; text-align: center; }
.round-btn:focus-visible .round-face, .hud-corner:focus-visible, .hud-player:focus-visible, .hud-gear:focus-visible { outline: 4px solid var(--focus-tv); outline-offset: 3px; }
@media (orientation: landscape) and (max-height: 560px) {
  :root body[data-screen="result"] .result-card { grid-template-columns: 1fr 1fr; align-items: center; width: min(100%, 900px); }
  :root body[data-screen="result"] .result-art { width: 110px; height: 110px; }
  :root body[data-screen="result"] .stars--big .star { width: 44px; height: 44px; }
}

/* Player sheet (avatar chip) */
.gm-player-sheet { display: grid; gap: 12px; }
.gm-player-sheet h3 { margin: 6px 0 0; font-family: var(--font-display); font-size: 20px; }
.gm-player-sheet .gm-player { width: 100%; margin: 0; background: linear-gradient(150deg, var(--hero-1), var(--hero-2)); border: 0; }

@media (prefers-reduced-motion: reduce) {
  .btn-play, .more-games, .btn-play.is-hint::after, .hud-gear.is-holding svg { animation: none !important; }
  .sheet { transition: none; }
}
:root body[data-screen="home"] .menu-stage .hero-art { order: 0; margin: 0; }
:root body[data-screen="home"] .menu-stage .hero-figure,
:root body[data-screen="home"] .menu-stage .hero-figure:has(.photo) { width: auto; height: 100%; max-width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
:root body[data-screen="home"] .menu-stage .hero-figure .photo { width: auto; height: 100%; max-width: 100%; object-fit: contain; }
:root body[data-screen="home"] .menu-stage .hero-art { overflow: visible; }
:root body[data-screen="home"] .menu-stage .hero-figure .photo { max-height: clamp(150px, 30svh, 280px); }
@media (orientation: landscape) and (min-width: 640px) { :root body[data-screen="home"] .menu-stage .hero-figure .photo { max-height: clamp(90px, 26svh, 240px); } }
@media (orientation: landscape) and (max-height: 560px) {
  :root body[data-screen="result"] .result { padding-top: 4px; padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); min-height: 0; }
  :root body[data-screen="result"] .result-card { gap: 8px 24px; }
  :root body[data-screen="result"] .result-hero, :root body[data-screen="result"] .result-side { gap: 8px; }
  :root body[data-screen="result"] .result-art { width: 92px; height: 92px; }
  :root body[data-screen="result"] .result-card h1 { font-size: 26px; }
  :root body[data-screen="result"] .stars--big { padding: 6px 16px; }
  :root body[data-screen="result"] .stars--big .star { width: 36px; height: 36px; }
  :root body[data-screen="result"] .result-score { font-size: 22px; }
  :root body[data-screen="result"] .gm-results { padding: 10px; gap: 8px; }
  :root body[data-screen="result"] .result-actions { gap: 10px; }
  :root body[data-screen="result"] .btn-play--result { min-height: 60px; }
  .round-face { width: 52px; height: 52px; }
  .round-btn small { display: none; }
}
