/* =====================================================================
   SanSil English World — Design System v1
   Mobile-first · 3D cartoon · Sky Blue / Yellow / Orange / Mint / Purple / Pink
   ===================================================================== */

/* ---------- Fonts (self-hosted, OFL — no external calls) ---------- */
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("../fonts/nunito-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url("../fonts/nunito-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Baloo Bhaijaan 2"; font-weight: 500; font-display: swap; src: url("../fonts/baloo-bhaijaan-2-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Baloo Bhaijaan 2"; font-weight: 700; font-display: swap; src: url("../fonts/baloo-bhaijaan-2-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Baloo Bhaijaan 2"; font-weight: 800; font-display: swap; src: url("../fonts/baloo-bhaijaan-2-arabic-800-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }

/* ---------- Brand tokens (SanSil English World identity) ---------- */
:root {
  /* Official brand colors */
  --brand-blue: #0D6EFD;    --brand-yellow: #FFC107;  --brand-red: #E53935;
  --brand-green: #43A047;   --brand-purple: #8E24AA;  --brand-sky: #29B6F6;
  --brand-navy: #0B2A6F;

  /* Component scales (light / base / dark for 3D depth) */
  --blue: var(--brand-blue); --blue-l: #6EA8FE; --blue-d: #0A4FC0;
  --sky: var(--brand-sky);   --sky-l: #81D4FA;  --sky-d: #0288D1;  --sky-dd: var(--brand-navy);
  --sun: var(--brand-yellow); --sun-l: #FFE082; --sun-d: #E0A100;
  --orange: #FB8C00;  --orange-l: #FFCC80; --orange-d: #E65100;
  --red: var(--brand-red);   --red-l: #EF9A9A;  --red-d: #B71C1C;
  --mint: var(--brand-green); --mint-l: #A5D6A7; --mint-d: #2E7D32;
  --grape: var(--brand-purple); --grape-l: #CE93D8; --grape-d: #6A1B9A;
  --pink: #F48FB1;   --pink-l: #FCE4EC;   --pink-d: #D81B60;
  --ink: #10204A;    --ink-2: #4A5A7A;    --ink-3: #94A3B8;
  --paper: #FFFFFF;  --cream: #FFFBEB;    --cloud: #EEF6FF;

  --r-sm: 14px; --r: 22px; --r-lg: 30px; --r-pill: 999px;
  --depth: 6px;
  --shadow-soft: 0 10px 24px rgba(11, 42, 111, .14);
  --shadow-card: 0 var(--depth) 0 rgba(13, 110, 253, .16), 0 16px 32px rgba(11, 42, 111, .12);

  --font: "Nunito", "Baloo Bhaijaan 2", "Segoe UI", system-ui, sans-serif;
  --font-head: "Fredoka", "Baloo Bhaijaan 2", "Nunito", system-ui, sans-serif;
  --font-ar: "Baloo Bhaijaan 2", "Nunito", Tahoma, sans-serif;

  --gap: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-weight: 700; color: var(--ink); line-height: 1.35;
  background: #D6F2FF;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .btn, .btn-start, .brand-logo, .section-title, .card-title, .lc-title, .node, .stat, .topbar-title { font-family: var(--font-head); font-weight: 600; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] .btn { font-family: var(--font-head); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; border-radius: 12px; }
[lang="ar"], .ar { font-family: var(--font-ar); }
[hidden] { display: none !important; }

/* Arabic helper text — toggled by the "ع" button */
.ar { display: none; }
body.show-ar .ar { display: block; }
body.show-ar small.ar, body.show-ar span.ar { display: inline; }
body.show-ar .lc-ar.ar { display: block; }

/* ---------- Background sky ---------- */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background: linear-gradient(180deg, #8EDBFF 0%, #BDEBFF 38%, #E6F7FF 70%, #FFF7D6 100%); }
.cloud { position: absolute; width: 180px; height: 56px; background: #fff; border-radius: 60px; opacity: .85;
  box-shadow: 0 8px 0 rgba(125, 211, 252, .35); animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 80px; height: 80px; top: -40px; left: 28px; }
.cloud::after  { width: 100px; height: 100px; top: -52px; left: 76px; }
.c1 { top: 12%; left: -200px; }
.c2 { top: 46%; left: -200px; transform: scale(.7); animation-duration: 85s; animation-delay: -30s; }
.c3 { top: 78%; left: -200px; transform: scale(.9); animation-duration: 72s; animation-delay: -55s; }
.sun-glow { position: absolute; top: -120px; right: -120px; width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(253, 230, 138, .9), rgba(253, 230, 138, 0) 70%); }
@keyframes drift { to { translate: calc(100vw + 420px) 0; } }

/* ---------- Layout ---------- */
.app { width: 100%; max-width: 1240px; margin: 0 auto; padding: calc(10px + var(--safe-top)) 12px calc(24px + var(--safe-bottom)); }
.app-narrow { max-width: 560px; }
.layout { display: grid; gap: var(--gap); margin-top: var(--gap); }
.main-col, .side-col { display: grid; gap: var(--gap); align-content: start; min-width: 0; }
.main-col > *, .side-col > * { min-width: 0; }

/* ---------- 3D primitives ---------- */
.card-3d { background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow-card); border: 3px solid rgba(255, 255, 255, .9); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 8px 22px;
  border-radius: var(--r-pill); font-weight: 800; font-size: 1.15rem; color: #fff; letter-spacing: .2px;
  --b: var(--sky); --bl: var(--sky-l); --bd: var(--sky-d);
  background: linear-gradient(180deg, var(--bl) 0%, var(--b) 55%);
  box-shadow: 0 var(--depth) 0 var(--bd), 0 12px 18px rgba(0, 0, 0, .14), inset 0 2px 0 rgba(255, 255, 255, .55);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .16); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--bd), 0 6px 10px rgba(0, 0, 0, .12), inset 0 2px 0 rgba(255, 255, 255, .55); }
.btn-sun    { --b: var(--sun);    --bl: var(--sun-l);    --bd: var(--sun-d);    color: #6B3B00; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.btn-orange { --b: var(--orange); --bl: var(--orange-l); --bd: var(--orange-d); }
.btn-mint   { --b: var(--mint);   --bl: var(--mint-l);   --bd: var(--mint-d); }
.btn-grape  { --b: var(--grape);  --bl: var(--grape-l);  --bd: var(--grape-d); }
.btn-sky    { --b: var(--sky);    --bl: var(--sky-l);    --bd: var(--sky-d); }
.btn-xl { min-height: 64px; font-size: 1.35rem; padding: 10px 32px; width: 100%; margin-top: 14px; }
.btn.done { pointer-events: none; }

.icon-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; font-weight: 800;
  background: linear-gradient(180deg, #fff, #E3F2FD); color: var(--sky-d);
  box-shadow: 0 4px 0 #90CAF9, 0 8px 14px rgba(2, 62, 99, .14); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #93C5FD; }
.icon-btn[aria-pressed="false"] { opacity: .55; }
.icon-btn.ghost { visibility: hidden; }

.bar { position: relative; height: 14px; border-radius: var(--r-pill); background: #E2E8F0; overflow: hidden;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .12); flex: 1; }
.bar > span { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(180deg, #86EFAC, var(--mint) 60%, var(--mint-d)); box-shadow: inset 0 3px 0 rgba(255,255,255,.45);
  transition: width .8s cubic-bezier(.2, .9, .3, 1.2); }
.bar-sun > span { background: linear-gradient(180deg, var(--sun-l), var(--sun) 60%, var(--sun-d)); }

.coin { display: inline-block; width: 1.05em; height: 1.05em; border-radius: 50%; vertical-align: -.16em;
  background: radial-gradient(circle at 35% 30%, #FFF7C2 0 18%, #FCD34D 40%, #F59E0B 75%, #B45309 100%);
  box-shadow: inset 0 -2px 0 rgba(146, 64, 14, .45), 0 1px 0 rgba(0,0,0,.15); position: relative; }
.coin::after { content: "S"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .62em; font-weight: 800; color: #92400E; font-style: normal; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.topbar-title { font-weight: 800; font-size: 1.3rem; color: var(--sky-dd); }
.profile-chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .92); box-shadow: 0 4px 0 #90CAF9, var(--shadow-soft); min-width: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; flex: none;
  background: radial-gradient(circle at 35% 30%, #FFF, var(--sun-l) 55%, var(--sun)); box-shadow: inset 0 -3px 0 rgba(202, 138, 4, .4); }
.profile-text { display: grid; line-height: 1.05; min-width: 0; }
.profile-text strong { font-size: 1.05rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-text small { font-size: .78rem; color: var(--ink-2); }
.stats { display: flex; gap: 6px; order: 3; width: 100%; justify-content: center; }
.stat { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px 4px 6px; border-radius: var(--r-pill);
  background: #fff; box-shadow: 0 4px 0 #CBD5E1; font-weight: 800; font-size: 1.05rem; }
.stat i { font-style: normal; font-size: 1.2rem; }
.top-actions { display: flex; gap: 8px; flex: none; }


/* ---------- Hero ---------- */
.hero { margin-top: 12px; padding: 14px 14px 18px; position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 85% 0%, #FFF4C2 0%, rgba(255, 244, 194, 0) 55%),
              linear-gradient(160deg, #FFFFFF 0%, #EAF8FF 60%, #DDF3FF 100%); }
.hero::after { content: ""; position: absolute; inset: auto -40px -60px -40px; height: 120px; border-radius: 50%;
  background: linear-gradient(180deg, #86EFAC, #4ADE80); opacity: .35; z-index: 0; }
.hero-brand { text-align: center; position: relative; z-index: 1; }
.brand-logo { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1; letter-spacing: .3px;
  background: linear-gradient(90deg, var(--orange-d), var(--orange) 25%, var(--sky-d) 55%, var(--grape-d));
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(255,255,255,.9)); }
.brand-logo em { font-style: normal; }
.brand-tag { display: block; color: var(--ink-2); font-size: .95rem; margin-top: 2px; }
.hero-body { display: grid; grid-template-columns: 1fr; justify-items: center; gap: 6px; position: relative; z-index: 1; margin-top: 4px; }
@keyframes bob { 50% { transform: translateY(-7px); } }
@keyframes shadow { 50% { transform: scaleX(.86); opacity: .14; } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 15%, 45% { transform: rotate(-18deg); } 30% { transform: rotate(12deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes twinkle { 50% { transform: rotate(14deg) scale(1.12); } }
@keyframes talk { to { transform: scaleY(.55); } }
@keyframes jump { 30% { transform: translateY(-26px) scale(1.04, .96); } 60% { transform: translateY(0) scale(1.06, .92); } }

.hero-copy { display: grid; gap: 12px; width: 100%; justify-items: center; }
.bubble { position: relative; background: #fff; border-radius: 22px; padding: 10px 16px; text-align: center;
  box-shadow: 0 4px 0 #BBDEFB, var(--shadow-soft); border: 3px solid #E3F2FD; max-width: 420px; }
.bubble::before { content: ""; position: absolute; top: -14px; left: 50%; translate: -50% 0; border: 10px solid transparent;
  border-bottom: 12px solid #fff; filter: drop-shadow(0 -3px 0 #E3F2FD); }
.bubble .en { font-size: 1.25rem; font-weight: 800; color: var(--sky-dd); }
.bubble .ar { font-size: 1.05rem; color: var(--ink-2); margin-top: 2px; }

.btn-start { display: inline-flex; align-items: center; gap: 14px; padding: 12px 30px 12px 14px; border-radius: var(--r-pill);
  color: #fff; text-align: start; width: min(100%, 380px); min-height: 78px;
  background: linear-gradient(180deg, #FDBA74 0%, var(--orange) 45%, #F97316 100%);
  box-shadow: 0 8px 0 #C2410C, 0 18px 26px rgba(194, 65, 12, .35), inset 0 3px 0 rgba(255, 255, 255, .55);
  animation: pulse 2.2s ease-in-out infinite; transition: transform .08s; }
.btn-start:active { transform: translateY(6px); box-shadow: 0 2px 0 #C2410C, inset 0 3px 0 rgba(255,255,255,.5); animation: none; }
.btn-start b { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1; text-shadow: 0 3px 0 rgba(154, 52, 18, .45); }
.btn-start small { font-size: 1rem; opacity: .95; }
.play-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; flex: none; padding-left: 4px;
  background: radial-gradient(circle at 35% 30%, #FFFBEB, var(--sun) 60%, var(--sun-d)); color: #9A3412;
  box-shadow: inset 0 -4px 0 rgba(161, 98, 7, .45), 0 3px 0 rgba(0,0,0,.12); }
@keyframes pulse { 50% { transform: scale(1.035); } }

.xp-row { display: flex; align-items: center; gap: 8px; width: min(100%, 380px); }
.xp-row small { font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.xp-badge { padding: 2px 10px; border-radius: var(--r-pill); background: var(--grape); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--grape-d); }
.demo-note { position: relative; z-index: 2; width: max-content; margin: 10px auto 0; font-size: .8rem; padding: 2px 12px; border-radius: var(--r-pill);
  background: var(--pink-l); color: var(--pink-d); }

/* ---------- Section headings ---------- */
.section-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 1.35rem; font-weight: 800; color: var(--sky-dd);
  margin: 4px 4px 10px; text-shadow: 0 2px 0 rgba(255, 255, 255, .9); }
.section-title small { font-size: 1rem; color: var(--ink-2); }
.st-ico { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #fff; box-shadow: 0 3px 0 #BBDEFB; font-size: 1.2rem; }
.card-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 1.2rem; font-weight: 800; margin-bottom: 10px; }
.card-title small { color: var(--ink-2); font-size: .95rem; }
.count-pill { margin-inline-start: auto; padding: 0 12px; border-radius: var(--r-pill); background: var(--cloud); color: var(--sky-d); font-size: 1rem; box-shadow: inset 0 -2px 0 #BBDEFB; }
.coin-pill { background: #FEF3C7; color: #92400E; box-shadow: inset 0 -2px 0 #FCD34D; }

/* ---------- Level cards ---------- */
.levels { display: grid; grid-auto-flow: column; grid-auto-columns: 74%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 4px 14px; margin: 0 -4px; scrollbar-width: none; }
.levels::-webkit-scrollbar { display: none; }
.level-card { scroll-snap-align: start; position: relative; display: grid; gap: 2px; text-align: start; padding: 14px 14px 12px; min-height: 172px;
  border-radius: var(--r); color: #fff; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--lc) 55%, #fff) 0%, var(--lc) 60%);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--lc) 70%, #000), 0 14px 22px rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255,255,255,.45);
  transition: transform .15s; border: 4px solid transparent; }
.level-card::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.16); }
.level-card.active { border-color: #fff; transform: translateY(-3px); box-shadow: 0 9px 0 color-mix(in srgb, var(--lc) 70%, #000), 0 0 0 5px var(--sun), 0 18px 26px rgba(0,0,0,.18); }
.level-card:active { transform: translateY(3px); }
.level-card.locked { filter: grayscale(.85) brightness(1.05); opacity: .8; }
.lc-icon { position: absolute; top: 8px; right: 10px; font-size: 2.6rem; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); z-index: 1; }
.lc-num { display: inline-block; width: max-content; padding: 0 10px; border-radius: var(--r-pill); background: rgba(255,255,255,.3); font-size: .85rem; font-weight: 800; }
.lc-title { font-size: 1.35rem; font-weight: 800; line-height: 1.1; text-shadow: 0 2px 0 rgba(0,0,0,.18); margin-top: 6px; }
.lc-ar { font-size: 1rem; opacity: .95; }
.lc-age { font-size: .9rem; opacity: .95; }
.lc-progress { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; position: relative; z-index: 1; }
.lc-progress .bar { height: 10px; background: rgba(255,255,255,.35); }
.lc-progress small { font-weight: 800; white-space: nowrap; }

/* ---------- Stage map ---------- */
.map { position: relative; overflow: hidden; padding: 0; min-height: 420px; }
.map-inner { position: relative; width: 100%; }
.map.theme-meadow { background: linear-gradient(180deg, #DCFCE7 0%, #BBF7D0 45%, #A7F3D0 100%); }
.map.theme-ocean  { background: linear-gradient(180deg, #E3F2FD 0%, #93DBFB 50%, #5CC4F2 100%); }
.map.theme-jungle { background: linear-gradient(180deg, #ECFCCB 0%, #A3E635 45%, #65A30D 100%); }
.map.theme-space  { background: radial-gradient(circle at 20% 10%, #6D28D9 0, #3B0764 45%, #1E1B4B 100%); }
.map.theme-space .unit-sign { background: rgba(255,255,255,.95); }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-path-base { fill: none; stroke: rgba(255,255,255,.9); stroke-width: 22; stroke-linecap: round; }
.map-path-dash { fill: none; stroke: rgba(15, 23, 42, .14); stroke-width: 5; stroke-dasharray: 2 16; stroke-linecap: round; }
.map-path-done { fill: none; stroke: var(--sun); stroke-width: 10; stroke-linecap: round; filter: drop-shadow(0 2px 0 var(--sun-d)); }
.prop { position: absolute; font-size: 2rem; translate: -50% -50%; pointer-events: none; opacity: .9; filter: drop-shadow(0 4px 0 rgba(0,0,0,.1)); }

.unit-sign { position: absolute; left: 50%; translate: -50% 0; display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 8px;
  border-radius: var(--r-pill); background: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--uc) 60%, #000), var(--shadow-soft);
  white-space: nowrap; z-index: 2; max-width: calc(100% - 24px); }
.unit-sign .u-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--uc); font-size: 1.1rem; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.unit-sign b { font-weight: 800; color: var(--ink); }
.unit-sign small { color: var(--ink-2); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }

.node { position: absolute; translate: -50% -50%; width: 72px; height: 72px; border-radius: 50%; z-index: 3;
  display: grid; place-items: center; font-weight: 800; font-size: 1.6rem; color: #fff;
  background: radial-gradient(circle at 35% 28%, #fff 0 8%, var(--nl) 30%, var(--n) 70%);
  box-shadow: 0 7px 0 var(--nd), 0 14px 18px rgba(0,0,0,.2), inset 0 -4px 0 rgba(0,0,0,.08);
  text-shadow: 0 2px 0 rgba(0,0,0,.2); transition: transform .1s;
  --n: var(--sky); --nl: var(--sky-l); --nd: var(--sky-d); }
.node:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--nd); }
.node.completed { --n: var(--mint); --nl: var(--mint-l); --nd: var(--mint-d); }
.node.open      { --n: var(--sky); --nl: var(--sky-l); --nd: var(--sky-d); }
.node.current   { --n: var(--orange); --nl: var(--orange-l); --nd: var(--orange-d); width: 86px; height: 86px; font-size: 1.9rem; animation: nodePulse 1.6s ease-in-out infinite; }
.node.locked    { --n: #CBD5E1; --nl: #F1F5F9; --nd: #94A3B8; color: #64748B; text-shadow: none; font-size: 1.4rem; }
.node.boss { width: 84px; height: 84px; border-radius: 26px; }
.node.boss.current { width: 92px; height: 92px; }
.node.boss.completed { --n: var(--grape); --nl: var(--grape-l); --nd: var(--grape-d); }
@keyframes nodePulse { 0%, 100% { box-shadow: 0 7px 0 var(--nd), 0 0 0 0 rgba(251, 146, 60, .55); } 50% { box-shadow: 0 7px 0 var(--nd), 0 0 0 16px rgba(251, 146, 60, 0); } }
.node .stars { position: absolute; bottom: -20px; left: 50%; translate: -50% 0; display: flex; gap: 1px; font-size: .95rem; filter: drop-shadow(0 2px 0 rgba(0,0,0,.15)); }
.node .stars .off { filter: grayscale(1) opacity(.45); }
.node .boss-crown { position: absolute; top: -20px; font-size: 1.5rem; }
.you-marker { position: absolute; z-index: 4; translate: -50% -100%; display: grid; justify-items: center; pointer-events: none; animation: bob 1.8s ease-in-out infinite; }
.you-marker .avatar { width: 48px; height: 48px; border: 4px solid #fff; box-shadow: 0 4px 0 var(--orange-d); }
.you-marker .you-label { margin-top: -4px; padding: 0 10px; border-radius: var(--r-pill); background: var(--orange-d); color: #fff; font-size: .8rem; font-weight: 800; }
.node-label { position: absolute; translate: 0 -50%; z-index: 3; padding: 4px 12px; border-radius: 14px; background: rgba(255,255,255,.95);
  font-size: .95rem; font-weight: 800; box-shadow: 0 3px 0 rgba(0,0,0,.1); max-width: 40%; line-height: 1.15; }
.node-label small, body.show-ar .node-label small.ar { display: block; color: var(--ink-2); font-weight: 700; }
.map-empty { padding: 60px 20px; text-align: center; font-size: 1.2rem; }
.map-finish { position: absolute; left: 50%; translate: -50% 0; font-size: 2.6rem; z-index: 2; }

/* ---------- Daily challenge ---------- */
.daily { padding: 16px; background: linear-gradient(150deg, #FFF7D6 0%, #FFE8A3 60%, #FFD66B 100%); border-color: #FFF3C4; }
.daily-head { display: flex; align-items: center; gap: 12px; }
.daily-head h2 { font-size: 1.3rem; font-weight: 800; color: #92400E; line-height: 1.1; }
.daily-head h2 small { display: block; font-size: 1rem; }
.daily-trophy { width: 60px; height: 60px; flex: none; display: grid; place-items: center; font-size: 2.1rem; border-radius: 20px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--sun-l)); box-shadow: 0 5px 0 var(--sun-d); animation: twinkleBox 3s ease-in-out infinite; }
@keyframes twinkleBox { 50% { transform: rotate(-6deg) scale(1.05); } }
.daily-timer { font-size: .9rem; color: #B45309; }
.daily-body { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; padding: 10px; border-radius: var(--r-sm); background: rgba(255,255,255,.7); }
.daily-game { font-size: 2rem; }
.daily-text { font-weight: 800; }
.daily-progress { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #92400E; }
.daily-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.bonus { font-weight: 800; color: #92400E; }

/* ---------- Achievements ---------- */
.trophies, .rewards { padding: 16px; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.badge { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; padding: 4px 2px; border-radius: 16px; cursor: pointer; }
.badge-medal { width: 58px; height: 58px; display: grid; place-items: center; font-size: 1.7rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 10%, color-mix(in srgb, var(--bc) 45%, #fff) 40%, var(--bc) 85%);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--bc) 65%, #000), inset 0 -3px 0 rgba(0,0,0,.1); }
.badge:not(.earned) .badge-medal { filter: grayscale(1); opacity: .5; }
.badge-name { font-size: .78rem; font-weight: 800; line-height: 1.05; color: var(--ink-2); }
.badge.earned .badge-name { color: var(--ink); }
.mini-bar { width: 80%; height: 6px; border-radius: 6px; background: #E2E8F0; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--sky); }
.new-tag { position: absolute; top: -4px; right: 2px; padding: 0 6px; border-radius: 8px; background: var(--pink-d); color: #fff; font-size: .65rem; font-weight: 800; animation: pulse 1.4s infinite; }
.badge.is-new .badge-medal { animation: shine 2s ease-in-out infinite; }
@keyframes shine { 50% { transform: rotate(-8deg) scale(1.08); } }

/* ---------- Rewards ---------- */
.reward-row { display: grid; grid-auto-flow: column; grid-auto-columns: 92px; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.reward { display: grid; justify-items: center; gap: 2px; padding: 10px 4px 8px; border-radius: 18px; background: var(--cloud);
  box-shadow: inset 0 -4px 0 #BBDEFB; text-align: center; }
.reward.owned { background: #ECFDF5; box-shadow: inset 0 -4px 0 var(--mint-l); }
.reward.equipped { outline: 3px solid var(--mint); }
.reward-ico { font-size: 2rem; }
.reward:not(.owned) .reward-ico { filter: saturate(.6); }
.reward-name { font-size: .8rem; font-weight: 800; line-height: 1.05; }
.reward-tag { font-size: .78rem; font-weight: 800; padding: 0 8px; border-radius: var(--r-pill); background: #fff; color: #92400E; }
.tag-own { color: var(--mint-d); }
.tag-ready { background: var(--sun); }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88dvh; overflow-y: auto;
  background: #fff; border-radius: 32px 32px 0 0; padding: 22px 18px calc(22px + var(--safe-bottom));
  box-shadow: 0 -10px 30px rgba(0,0,0,.2); animation: up .28s cubic-bezier(.2, .9, .3, 1.15); }
.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; translate: -50% 0; width: 54px; height: 6px; border-radius: 6px; background: #E2E8F0; }
.sheet-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%; background: #F1F5F9; font-size: 1.1rem; font-weight: 800; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-hero { display: grid; justify-items: center; text-align: center; gap: 4px; }
.sheet-ico { width: 92px; height: 92px; border-radius: 28px; display: grid; place-items: center; font-size: 3rem;
  background: radial-gradient(circle at 35% 30%, #fff, var(--sky-l)); box-shadow: 0 6px 0 var(--sky-d); margin-bottom: 6px; }
.sheet-hero h3 { font-size: 1.7rem; font-weight: 800; line-height: 1.1; display: flex; align-items: center; gap: 8px; justify-content: center; }
.sheet-hero .ar { font-size: 1.2rem; color: var(--ink-2); }
.sheet-meta { color: var(--ink-2); }
.sheet-stars { font-size: 1.8rem; letter-spacing: 2px; }
.sheet-stars .off { filter: grayscale(1) opacity(.35); }
.how { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 12px; border-radius: var(--r-sm); background: var(--cloud); text-align: start; }
.how p { font-weight: 700; }
.say-btn { flex: none; width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem; background: var(--sky); color: #fff; box-shadow: 0 4px 0 var(--sky-d); }
.say-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--sky-d); }
.say-btn.mini { width: 38px; height: 38px; font-size: 1rem; }
.stage-rewards { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stage-rewards span { padding: 4px 12px; border-radius: var(--r-pill); background: #FEF3C7; font-weight: 800; color: #92400E; }
.notice { margin-top: 14px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--pink-l); color: #9D174D; font-weight: 700; text-align: center; }
.notice .ar { margin-top: 2px; }

/* Stage intro page */
.stage-intro { margin-top: 16px; padding: 20px; display: grid; justify-items: center; text-align: center; gap: 6px; }
.stage-intro h1 { font-size: 1.9rem; font-weight: 800; color: var(--sky-dd); line-height: 1.1; }
.stage-game-ico { font-size: 2.6rem; }
.big { font-size: 1.3rem; }
.muted { color: var(--ink-2); }
.back { font-size: 1.5rem; }
.debug { white-space: pre-wrap; text-align: start; font-size: .8rem; background: #F8FAFC; padding: 8px; border-radius: 8px; max-width: 100%; overflow: auto; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); translate: -50% 150%; z-index: 60; max-width: 92vw;
  padding: 12px 20px; border-radius: var(--r-pill); background: var(--ink); color: #fff; font-weight: 800; text-align: center;
  box-shadow: 0 6px 0 #0F172A; visibility: hidden; transition: translate .3s cubic-bezier(.2, .9, .3, 1.2), visibility .3s; }
.toast.show { translate: -50% 0; visibility: visible; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.foot { text-align: center; color: var(--ink-2); font-size: .9rem; padding: 22px 0 6px; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 379px) {
  .icon-btn { width: 42px; height: 42px; }
  .brand-logo { font-size: 1.6rem; }
  .btn-start b { font-size: 1.45rem; }
  .levels { grid-auto-columns: 82%; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
  .node { width: 64px; height: 64px; }
  .node.current { width: 76px; height: 76px; }
}

@media (min-width: 560px) {
  .stats { order: 0; width: auto; }
  .topbar { flex-wrap: nowrap; }
  .levels { grid-auto-columns: 46%; }
}

@media (min-width: 768px) {
  .app { padding-left: 20px; padding-right: 20px; }
  .hero { padding: 18px 26px 22px; }
  .hero-brand { text-align: start; }
  .brand-logo { font-size: 2.3rem; }
  .hero-body { grid-template-columns: auto 1fr; justify-items: start; align-items: center; gap: 18px; }
  .hero-copy { justify-items: start; }
  .bubble { text-align: start; }
  .bubble::before { top: 50%; left: -18px; translate: 0 -50%; border: 10px solid transparent; border-right: 14px solid #fff; filter: drop-shadow(-3px 0 0 #E3F2FD); }
  .levels { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-auto-columns: auto; overflow: visible; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: min(520px, 92vw); translate: -50% 50%; border-radius: 32px; animation: pop .25s cubic-bezier(.2, .9, .3, 1.3); }
  .sheet::before { display: none; }
  @keyframes pop { from { transform: scale(.85); opacity: 0; } }
}

@media (min-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .side-col { position: sticky; top: 12px; }
  .hero { padding: 20px 34px 24px; }
  .bubble .en { font-size: 1.5rem; }
}

@media (min-width: 1366px) {
  .layout { grid-template-columns: minmax(0, 1fr) 390px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .hero-body { grid-template-columns: auto 1fr; justify-items: start; }
}

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

/* =====================================================================
   San & Sil characters (shared component)
   ===================================================================== */
.duo { display: flex; align-items: flex-end; justify-content: center; position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
.duo-char { display: block; position: relative; }
.duo-char img { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 14px rgba(11, 42, 111, .25)); transform-origin: bottom center; }
.duo-san { width: 46%; z-index: 2; margin-inline-end: -8%; }
.duo-sil { width: 54%; }
.duo-san img { animation: duoSway 4.6s ease-in-out infinite; }
.duo-sil img { animation: duoSway 5.2s ease-in-out infinite reverse; }
.duo-lg { width: 250px; }
.duo-sm { width: 190px; margin: 0 auto; cursor: default; }
.duo.talk .duo-sil img, .duo.talk.san-talks .duo-san img { animation: duoTalk .35s ease-in-out infinite alternate; }
.duo.talk.san-talks .duo-sil img { animation: duoSway 5.2s ease-in-out infinite reverse; }
.duo.jump .duo-char img { animation: duoJump .6s ease-out; }
@keyframes duoSway { 50% { transform: rotate(-1.5deg) translateY(-4px); } }
@keyframes duoTalk { to { transform: translateY(-5px) scale(1.02); } }
@keyframes duoJump { 30% { transform: translateY(-22px) scale(1.03, .97); } 60% { transform: none; } }

.hero-logo { display: block; width: 116px; margin: -4px auto -6px; filter: drop-shadow(0 8px 10px rgba(11,42,111,.22)); }
.hero-logo img { width: 100%; height: auto; display: block; }
.hero-brand .hero-logo { position: relative; z-index: 2; }
.flash { position: relative; z-index: 5; margin: 10px auto; width: min(720px, 100% - 24px); padding: 12px 16px; border-radius: 16px; font-weight: 800; text-align: center; }
.flash-ok { background: #E8F5E9; color: var(--mint-d); box-shadow: inset 0 -3px 0 var(--mint-l); }

@media (min-width: 768px) {
  .duo-lg { width: 300px; }
  .hero-logo { width: 130px; margin: 0; }
}
@media (min-width: 1024px) {
  .duo-lg { width: 330px; }
  .hero-body { grid-template-columns: 330px 1fr; }
}

/* =====================================================================
   Game engine (quiz family)
   ===================================================================== */
.notice-ok { background: #E8F5E9; color: var(--mint-d); }
#btnPlay small { font-size: 1rem; opacity: .9; }
body.in-game .topbar { display: none; }
.game { margin-top: 6px; min-height: calc(100dvh - 30px); display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.game.anim-in .g-options, .game.anim-in .g-prompt { animation: popIn .35s cubic-bezier(.2, .9, .3, 1.25); }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }

.g-top { display: flex; align-items: center; gap: 10px; }
.g-bar { height: 18px; }
.g-count { font-family: var(--font-head); font-weight: 600; color: var(--sky-dd); min-width: 46px; text-align: end; }
.g-close { flex: none; }

.g-host { display: flex; align-items: flex-end; gap: 8px; }
.g-char { width: 78px; height: auto; flex: none; filter: drop-shadow(0 6px 8px rgba(11,42,111,.25)); transform-origin: bottom center; }
.g-host.talking .g-char { animation: duoTalk .3s ease-in-out infinite alternate; }
.g-bubble { flex: 1; position: relative; background: #fff; border-radius: 22px; padding: 12px 16px; box-shadow: 0 4px 0 #BBDEFB, var(--shadow-soft); }
.g-bubble::before { content: ""; position: absolute; left: -12px; bottom: 18px; border: 8px solid transparent; border-right: 12px solid #fff; }
.g-q { font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; color: var(--sky-dd); line-height: 1.15; }
.g-q-ar { color: var(--ink-2); margin-top: 2px; }
.g-say { flex: none; align-self: center; }

.g-prompt { display: grid; place-items: center; min-height: 120px; }
.g-display { font-size: 5.5rem; line-height: 1; width: 160px; height: 160px; display: grid; place-items: center; border-radius: 40px;
  background: radial-gradient(circle at 35% 25%, #fff, #E3F2FD); box-shadow: 0 7px 0 #90CAF9, var(--shadow-soft); animation: bob 3s ease-in-out infinite; }
.g-display.is-text { font-family: var(--font-head); font-weight: 700; font-size: 6rem; color: var(--blue); }
.g-listen { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; align-content: center; gap: 2px; color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--sky-l), var(--blue) 70%); box-shadow: 0 8px 0 var(--blue-d), 0 0 0 0 rgba(13,110,253,.4);
  animation: listenPulse 1.8s ease-in-out infinite; }
.g-listen span { font-size: 4rem; line-height: 1; }
.g-listen small { font-family: var(--font-head); font-size: 1.1rem; }
@keyframes listenPulse { 50% { box-shadow: 0 8px 0 var(--blue-d), 0 0 0 18px rgba(13,110,253,0); } }
.g-count-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 360px; padding: 14px; border-radius: 28px; background: #fff; box-shadow: var(--shadow-card); }
.g-count-grid span { font-size: 2.6rem; animation: popIn .4s calc(var(--i) * 70ms) both; }

.g-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g-opt { position: relative; min-height: 110px; display: grid; place-items: center; align-content: center; gap: 4px; padding: 10px; border-radius: 26px;
  background: #fff; box-shadow: 0 7px 0 #BBDEFB, 0 12px 18px rgba(11,42,111,.12); border: 4px solid transparent; transition: transform .1s; }
.g-opt:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 #BBDEFB; }
.g-opt .glyph { font-size: 3.4rem; line-height: 1; }
.g-opt .glyph-text { font-family: var(--font-head); font-weight: 700; font-size: 3.2rem; color: var(--blue); }
.g-opt .swatch { width: 78px; height: 78px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 -6px 0 rgba(0,0,0,.15), 0 0 0 4px #fff, 0 0 0 6px #E2E8F0; }
.g-opt .opt-label { font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; color: var(--ink); line-height: 1.1; }
.g-opt .opt-ar { font-size: .95rem; color: var(--ink-2); }
.g-options.words .g-opt { min-height: 86px; }
.g-opt.picked { border-color: var(--sky); }
.g-opt.correct { border-color: var(--mint); background: #E8F5E9; box-shadow: 0 7px 0 var(--mint-d); animation: yay .5s; }
.g-opt.correct::after { content: "✔"; position: absolute; top: -10px; right: -8px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--mint); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--mint-d); }
.g-opt.wrong { border-color: #FFCDD2; background: #FFF5F5; animation: shake .4s; opacity: .8; }
.g-opt.reveal { animation: yay .6s .3s both; }
.g-opt:disabled { cursor: default; }
@keyframes yay { 40% { transform: scale(1.08) rotate(-2deg); } }

.g-feedback { min-height: 64px; display: grid; justify-items: center; text-align: center; gap: 2px; border-radius: 22px; padding: 10px; opacity: 0; transform: translateY(10px); transition: .25s; }
.g-feedback.show { opacity: 1; transform: none; }
.g-feedback b { font-family: var(--font-head); font-size: 1.5rem; }
.g-feedback.good { background: #E8F5E9; color: var(--mint-d); }
.g-feedback.try { background: #FFF8E1; color: #B45309; }
.g-feedback em { font-style: normal; font-weight: 800; color: var(--blue); }

.burst { position: fixed; z-index: 70; pointer-events: none; }
.burst i { position: absolute; width: 10px; height: 10px; border-radius: 3px; background: var(--c); animation: burst .8s ease-out forwards; }
@keyframes burst { to { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(180deg); opacity: 0; } }

/* Results */
.results { padding: 20px 16px; display: grid; justify-items: center; text-align: center; gap: 6px; margin-top: 8px; }
.r-chars { display: flex; align-items: flex-end; justify-content: center; }
.r-chars img { width: 110px; height: auto; filter: drop-shadow(0 8px 10px rgba(11,42,111,.25)); animation: duoJump .7s ease-out 2; }
.r-chars .r-sil { animation-delay: .15s; margin-inline-start: -14px; }
.results h2 { font-size: 1.8rem; color: var(--sky-dd); line-height: 1.1; }
.r-stars { display: flex; gap: 8px; margin: 6px 0; }
.r-star { font-size: 3.4rem; filter: grayscale(1) opacity(.3); transform: scale(.6); }
.r-star.on { filter: drop-shadow(0 4px 0 rgba(202,138,4,.5)); animation: starIn .5s calc(var(--n) * .25s) cubic-bezier(.2, .9, .3, 1.5) forwards; }
@keyframes starIn { to { transform: scale(1); } }
.r-star:not(.on) { transform: scale(.8); }
.r-score { font-family: var(--font-head); font-size: 1.4rem; color: var(--ink-2); }
.r-gains { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.r-gains span { padding: 4px 14px; border-radius: var(--r-pill); background: #FEF3C7; font-weight: 800; color: #92400E; font-size: 1.1rem; }
.r-new { margin-top: 8px; color: var(--grape-d); }
.r-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.r-badge { display: grid; justify-items: center; gap: 2px; width: 120px; animation: popIn .5s .6s both; }
.r-badge small { color: var(--ink-2); }
.r-actions { width: 100%; display: grid; gap: 0; }

@media (min-width: 560px) {
  .g-opt { min-height: 140px; }
  .g-opt .glyph { font-size: 4.2rem; }
  .g-char { width: 96px; }
}
@media (min-width: 900px) {
  .app-narrow:has(.game:not([hidden])) { max-width: 860px; }
  .g-options.n4 { grid-template-columns: repeat(4, 1fr); }
  .g-options.words.n4 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Phase 5 game types ---------- */
.g-body { display: grid; gap: 12px; }
.game.anim-in .g-body > * { animation: popIn .35s cubic-bezier(.2, .9, .3, 1.25); }
.g-display.small { width: 110px; height: 110px; font-size: 3.8rem; border-radius: 30px; }
.hint-ar { text-align: center; color: var(--ink-2); font-weight: 700; }

/* fill in the blank */
.sentence-card { text-align: center; font-family: var(--font-head); font-weight: 600; font-size: clamp(1.5rem, 6vw, 2.2rem); color: var(--sky-dd);
  padding: 18px 14px; border-radius: 26px; background: #fff; box-shadow: var(--shadow-card); line-height: 1.3; }
.blank { display: inline-block; min-width: 86px; margin: 0 6px; padding: 0 10px; border-radius: 14px; background: var(--sun-l); color: #92400E;
  border-bottom: 4px dashed var(--sun-d); animation: pulse 1.6s ease-in-out infinite; }

/* stories */
.story-card { width: 100%; padding: 14px 16px; border-radius: 26px; background: #FFFDF5; box-shadow: 0 6px 0 #FDE68A, var(--shadow-soft); text-align: start; }
.story-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.story-card header b, .story-card.listen b { font-family: var(--font-head); font-weight: 600; font-size: 1.25rem; color: var(--grape-d); flex: 1; }
.story-art { font-size: 2.2rem; }
.story-card p { font-size: 1.15rem; line-height: 1.6; color: var(--ink); }
.story-card.listen { display: grid; justify-items: center; gap: 8px; text-align: center; }
.story-card.listen .story-art { font-size: 3.4rem; }

/* spelling + sentence builder */
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px; border-radius: 24px; background: #fff; box-shadow: var(--shadow-card); min-height: 78px; }
.slot { min-width: 50px; height: 58px; padding: 0 10px; border-radius: 14px; border: 3px dashed #BBDEFB; background: #F7FBFF;
  font-family: var(--font-head); font-weight: 600; font-size: 1.7rem; color: var(--blue); }
.slots.order .slot { min-width: 64px; font-size: 1.25rem; }
.slot.full { border-style: solid; border-color: var(--blue); background: #E3F2FD; animation: popIn .2s; }
.slots.solved .slot { border-color: var(--mint); background: #E8F5E9; color: var(--mint-d); }
.slots.wrong { animation: shake .4s; }
.slots.wrong .slot { border-color: #FFCDD2; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tile { min-width: 56px; height: 60px; padding: 0 14px; border-radius: 18px; font-family: var(--font-head); font-weight: 600; font-size: 1.7rem; color: #fff;
  background: linear-gradient(180deg, #FFB74D, var(--orange)); box-shadow: 0 5px 0 var(--orange-d); transition: transform .08s, opacity .15s; }
.tiles.order .tile { font-size: 1.25rem; background: linear-gradient(180deg, #CE93D8, var(--grape)); box-shadow: 0 5px 0 var(--grape-d); }
.tile:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--orange-d); }
.tile:disabled { opacity: .25; transform: scale(.9); }
.tile-actions { display: flex; justify-content: center; gap: 10px; }
.tile-actions .btn { min-width: 130px; }
.tile-actions .btn:disabled { opacity: .45; }

/* speak */
.speak-card { display: grid; justify-items: center; gap: 6px; padding: 18px; border-radius: 28px; background: #fff; box-shadow: var(--shadow-card); text-align: center; }
.speak-emoji { font-size: 4.6rem; line-height: 1; }
.speak-word { font-family: var(--font-head); font-weight: 700; font-size: clamp(2rem, 9vw, 3rem); color: var(--blue); }
.speak-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px; }
.mic-btn { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; align-content: center; font-size: 2.8rem; color: #fff;
  background: radial-gradient(circle at 35% 30%, #EF9A9A, var(--red) 70%); box-shadow: 0 7px 0 var(--red-d); }
.mic-btn small { font-family: var(--font-head); font-size: 1rem; }
.mic-btn.on { animation: listenPulse 1s infinite; background: radial-gradient(circle at 35% 30%, #A5D6A7, var(--mint) 70%); box-shadow: 0 7px 0 var(--mint-d); }
.speak-heard { text-align: center; color: var(--ink-2); font-weight: 700; min-height: 1.4em; }

/* match pairs */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.m-card { min-height: 72px; border-radius: 20px; background: #fff; box-shadow: 0 5px 0 #BBDEFB, var(--shadow-soft); border: 4px solid transparent;
  font-family: var(--font-head); font-weight: 600; font-size: 1.3rem; color: var(--ink); transition: transform .1s; }
.m-pic { font-size: 2.6rem; }
.m-card.sel { border-color: var(--sun); transform: scale(1.04); }
.m-card.done { border-color: var(--mint); background: #E8F5E9; box-shadow: 0 5px 0 var(--mint-d); opacity: .85; }
.m-card.wrong { border-color: #FFCDD2; animation: shake .4s; }

/* memory */
.memory { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 10px; perspective: 800px; }
.mem-card { position: relative; aspect-ratio: 3 / 4; border-radius: 20px; transform-style: preserve-3d; transition: transform .35s; }
.mem-card > span { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 2px; border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.mem-back { background: linear-gradient(160deg, var(--blue-l), var(--blue)); box-shadow: 0 5px 0 var(--blue-d); font-size: 2rem; color: #fff; }
.mem-front { background: #fff; box-shadow: 0 5px 0 #BBDEFB; transform: rotateY(180deg); }
.mem-front i { font-style: normal; font-size: 2.6rem; line-height: 1; }
.mem-front small { font-family: var(--font-head); font-weight: 600; font-size: 1rem; color: var(--ink); }
.mem-card.flip { transform: rotateY(180deg); }
.mem-card.done .mem-front { background: #E8F5E9; box-shadow: 0 5px 0 var(--mint-d); }

@media (min-width: 560px) {
  .m-card { min-height: 84px; font-size: 1.5rem; }
  .mem-front i { font-size: 3.2rem; }
  .tile { min-width: 64px; height: 68px; }
}
@media (min-width: 900px) {
  .memory { grid-template-columns: repeat(calc(var(--cols) + 1), 1fr); }
}

/* ---------- Phase 6: pictures & audio controls ---------- */
.g-img { display: block; max-width: 100%; height: auto; object-fit: contain; pointer-events: none; user-select: none; }
.g-opt .g-img { width: 96px; height: 96px; }
.g-display.has-img { padding: 10px; background: #fff; }
.g-display.has-img .g-img { width: 100%; height: 100%; }
.speak-emoji .g-img { width: 120px; height: 120px; }
.m-pic .g-img { width: 64px; height: 64px; margin: 0 auto; }
.mem-front .g-img { width: 70%; height: auto; max-height: 64%; }
.g-say-group { display: grid; gap: 6px; justify-items: center; align-self: center; }
.s-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.s-btns .btn { min-height: 44px; font-size: 1rem; padding: 4px 16px; }
@media (min-width: 560px) { .g-opt .g-img { width: 120px; height: 120px; } }
.r-levelup, .r-weekly { width: 100%; padding: 12px; border-radius: 18px; font-weight: 800; text-align: center; animation: popIn .5s .5s both; }
.r-levelup { background: linear-gradient(135deg, #EDE7F6, #D1C4E9); color: var(--grape-d); font-size: 1.15rem; }
.r-weekly { background: #E8F5E9; color: var(--mint-d); }
.r-levelup .ar, .r-weekly .ar { display: none; } body.show-ar .r-levelup .ar, body.show-ar .r-weekly .ar { display: block; }
