/* ============================================================
   Kids Planet — styles

   Look: soft-3D illustration style on a warm cream page with
   static pastel "blob" decorations and pastel gradient cards
   (modeled on the provided design mockup). Icons are Microsoft
   Fluent Emoji 3D images rendered via .pic (sized in em so they
   drop in anywhere text-emoji used to be).

   Motion stays research-grounded:
   - Functional animations in the 100–500 ms band (NN/g).
   - Page decorations are fully static — zero competing motion
     during play (NN/g peripheral-motion findings, WCAG 2.2.2).
   - Touch targets ≥ 72 px, generously separated (Sesame ≥ 2 cm).
   ============================================================ */
@font-face {
  font-family: 'Baloo Bhaijaan 2';
  src: url('../assets/fonts/BalooBhaijaan2.ttf') format('truetype-variations');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --font: 'Baloo Bhaijaan 2', 'GeezaPro', 'Chalkboard SE', ui-rounded, 'Trebuchet MS', sans-serif;
  --page: #fbf7ee;
  --ink: #4a3c6e;
  --ink-soft: #8b7fa8;
  --card: #ffffff;
  --accent: #ff8c1a;
  --good: #34c759;
  --bad: #ff6b6b;
  --hint: #ffe14d;
  --shadow: 0 8px 24px rgba(118, 94, 60, .12), 0 2px 6px rgba(118, 94, 60, .06);
  --radius: 28px;

  /* functional motion (NN/g 100–500 ms band) */
  --t-tap: 130ms;
  --t-enter: 340ms;
  --t-screen: 400ms;
  --t-celebrate: 550ms;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button {
  font-family: var(--font);
  color: var(--ink);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; user-select: none; }

/* ---------- Fluent Emoji images ---------- */
.pic {
  width: 1em; height: 1em;
  object-fit: contain;
  display: inline-block;
  vertical-align: -0.12em;
}
.pic-fallback { display: inline-block; }
.tag-star { font-size: .85em; }

.star-ico .pic { filter: drop-shadow(0 2px 2px rgba(118,94,60,.18)); }
.star-ico.off .pic { filter: grayscale(1); opacity: .3; }

/* ---------- background decorations (fully static) ---------- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
body.no-ambient .bg-decor { display: none; }

.blob { position: absolute; opacity: .55; }
.blob-1 { width: 320px; height: 250px; top: -110px; left: -120px; background: #bfe3ff; border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%; }
.blob-2 { width: 260px; height: 220px; top: -90px; right: -90px; background: #cdf2cf; border-radius: 55% 45% 40% 60% / 45% 55% 45% 55%; }
.blob-3 { width: 280px; height: 240px; bottom: -110px; left: -100px; background: #e6d9ff; border-radius: 50% 50% 60% 40% / 60% 40% 50% 50%; }
.blob-4 { width: 330px; height: 260px; bottom: -120px; right: -120px; background: #ffdfdb; border-radius: 60% 40% 50% 50% / 50% 60% 40% 50%; }
.blob-5 { width: 150px; height: 130px; top: 42%; left: -75px; background: #fff0c2; opacity: .45; border-radius: 50% 50% 45% 55% / 55% 45% 55% 45%; }

.dot-cluster { position: absolute; width: 60px; height: 60px; }
.dot-cluster,
.dot-cluster::before {
  background:
    radial-gradient(circle 6px at 12px 12px, #b9e8a5 98%, transparent),
    radial-gradient(circle 4px at 38px 26px, #b9e8a5 98%, transparent),
    radial-gradient(circle 5px at 20px 44px, #b9e8a5 98%, transparent);
}
.dc-1 { top: 12%; right: 14%; }
.dc-2 { bottom: 18%; left: 10%; transform: rotate(120deg); opacity: .8; }

/* ---------- layout / screens ---------- */
#app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 14px 16px 120px; }
.screen { display: none; animation: screen-in var(--t-screen) ease-out both; }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- shared buttons ---------- */
.round-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 30px; display: grid; place-items: center;
  transition: transform var(--t-tap) ease;
}
.round-btn:active { transform: scale(.92); }

.pill-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); box-shadow: var(--shadow);
  border-radius: 999px; padding: 14px 22px; min-height: 64px;
  font-size: 22px; font-weight: 700;
  transition: transform var(--t-tap) ease;
}
.pill-btn:active { transform: scale(.94); }
.pill-num { font-size: 24px; color: var(--ink); }

.link-btn {
  background: none; font-size: 17px; color: var(--ink-soft);
  text-decoration: underline; padding: 12px;
}

.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 72px; padding: 16px 32px;
  border-radius: 22px; font-size: 24px; font-weight: 700;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.12);
  transition: transform var(--t-tap) ease;
}
.big-btn:active { transform: translateY(3px) scale(.97); }
.big-btn.secondary { background: #fff; color: var(--ink); }

.danger-btn {
  margin-top: 10px; padding: 16px 22px; border-radius: 18px;
  background: #ffe1e1; color: #c0392b; font-size: 18px; font-weight: 700;
  min-height: 56px;
}
.reset-bar { height: 12px; border-radius: 8px; background: #f3e9e9; margin-top: 10px; overflow: hidden; }
.reset-fill { height: 100%; width: 0%; background: #ff6b6b; transition: width .1s linear; border-radius: 8px; }

/* ---------- home ---------- */
.home-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 2px 2px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-emoji { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(118,94,60,.2)); }
.logo-text { font-size: clamp(26px, 5vw, 40px); font-weight: 800; letter-spacing: .5px; }
.logo-text em { font-style: normal; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }

.home-tagline {
  text-align: center; font-size: clamp(19px, 3vw, 26px); font-weight: 800;
  color: var(--ink); margin: 12px 0 20px;
}

.game-grid {
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.game-card {
  position: relative;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--c, var(--accent)) 9%, #fff),
    color-mix(in srgb, var(--c, var(--accent)) 24%, #fff));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: transform 180ms ease;
  overflow: hidden;
  animation: pop-in var(--t-enter) ease-out both;
}
.game-card:hover { transform: translateY(-4px); }
.game-card:active { transform: scale(.96); }
.game-name {
  font-size: 23px; font-weight: 800;
  color: color-mix(in srgb, var(--c, var(--accent)) 70%, var(--ink));
}
.game-blurb { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.game-hero { margin: 12px 0 14px; line-height: 0; }
.game-hero .pic {
  width: clamp(76px, 9vw, 104px); height: clamp(76px, 9vw, 104px);
  filter: drop-shadow(0 8px 10px rgba(118, 94, 60, .22));
}
.game-foot { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.game-skill {
  font-size: 15px; color: #fff;
  background: var(--c, var(--accent));
  padding: 6px 24px; border-radius: 999px; font-weight: 800;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
}
.game-stars { font-size: 15px; letter-spacing: 1px; }

.home-footer { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 28px; }
.footer-note { font-size: 14px; color: var(--ink-soft); opacity: .9; }

/* ---------- game screen ---------- */
.game-header { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.game-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.game-h-emoji { font-size: 36px; line-height: 0; }
.game-h-title { font-size: clamp(20px, 4vw, 30px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.hud-dots { display: flex; gap: 6px; }
.hud-dot {
  width: 14px; height: 14px; border-radius: 999px; background: rgba(74,60,110,.16);
  transition: background 200ms ease;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.hud-dot.cur { width: 26px; height: 22px; background: var(--accent); }
.hud-dot.ok { background: var(--good); }
.hud-dot.miss { background: #f6b26b; }
.hud-score {
  background: var(--card); box-shadow: var(--shadow);
  padding: 12px 18px; border-radius: 999px; font-size: 20px; font-weight: 800;
  min-height: 52px; display: flex; align-items: center; gap: 6px;
}

.game-stage {
  background: rgba(255,255,255,.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 64vh;
  padding: 18px;
  display: flex; flex-direction: column;
}

/* ---------- quiz engine ---------- */
.quiz-wrap { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.quiz-prompt {
  background: #fff; border-radius: 22px; padding: 16px 76px;
  text-align: center; box-shadow: 0 4px 14px rgba(118,94,60,.08);
  font-size: clamp(22px, 4.5vw, 34px); font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 110px;
  animation: pop-in var(--t-enter) ease-out both;
}
.quiz-prompt .prompt-sub { font-size: clamp(16px, 3vw, 22px); color: var(--ink-soft); font-weight: 700; }
.quiz-prompt .prompt-big { font-size: clamp(44px, 9vw, 84px); line-height: 1.1; }
.quiz-prompt.nudge { animation: nudge 900ms ease-in-out; }
@keyframes nudge {
  0%,100% { transform: none; }
  25% { transform: translateY(-6px) scale(1.015); }
  60% { transform: translateY(2px); }
}
.speak-again {
  width: 64px; height: 64px; border-radius: 50%; font-size: 28px;
  background: #fff; box-shadow: var(--shadow);
  position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  transition: transform var(--t-tap) ease;
}
.speak-again:active { transform: translateY(-50%) scale(.9); }
.quiz-prompt-holder { position: relative; }

.quiz-options {
  flex: 1;
  display: grid; gap: 20px;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  align-content: center;
}
.opt {
  background: #fff; border-radius: 24px;
  box-shadow: var(--shadow);
  min-height: 120px; padding: 14px;
  font-size: clamp(30px, 7vw, 56px); font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  transition: transform 160ms ease, background 200ms ease, opacity 250ms ease;
  animation: pop-in var(--t-enter) ease-out both;
  position: relative;
}
.opt .pic { width: 1.35em; height: 1.35em; filter: drop-shadow(0 5px 7px rgba(118,94,60,.18)); }
.opt:nth-child(2) { animation-delay: 70ms; }
.opt:nth-child(3) { animation-delay: 140ms; }
.opt:nth-child(4) { animation-delay: 210ms; }
.opt:nth-child(5) { animation-delay: 280ms; }
.opt:nth-child(6) { animation-delay: 350ms; }
.opt:hover { transform: translateY(-3px); }
.opt:active { transform: scale(.94); }
.opt.opt-correct { background: #d9f7e3; outline: 5px solid var(--good); animation: correct-pop var(--t-celebrate) ease; }
.opt.opt-wrong { background: #ffe3e3; animation: shake 450ms ease; opacity: .45; pointer-events: none; }
.opt:disabled { cursor: default; }
.opt svg { width: clamp(64px, 14vw, 120px); height: clamp(64px, 14vw, 120px); }
.opt.opt-hint { animation: hint-glow 1.5s ease-in-out infinite; }
@keyframes hint-glow {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(255, 225, 77, 0); }
  50% { box-shadow: var(--shadow), 0 0 0 12px rgba(255, 225, 77, .85); }
}
.quiz-options.answered .opt:not(.opt-correct) { opacity: .25; }

@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes correct-pop { 0% { transform: scale(1); } 45% { transform: scale(1.09); } 100% { transform: scale(1); } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* counting critter cloud */
.critter-cloud {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  font-size: clamp(34px, 6vw, 52px); max-width: 580px;
}
.critter-cloud span { display: inline-block; animation: pop-in var(--t-enter) ease-out both; line-height: 0; }
.critter-cloud .pic { filter: drop-shadow(0 4px 5px rgba(118,94,60,.18)); }

/* math visuals */
.math-visual { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.math-group { display: flex; flex-wrap: wrap; gap: 5px; max-width: 230px; justify-content: center; font-size: clamp(26px, 4.5vw, 38px); }
.math-group span { display: inline-block; line-height: 0; }
.math-op { font-size: clamp(34px, 6vw, 52px); font-weight: 800; color: var(--accent); }

/* pattern row */
.pattern-row { display: flex; justify-content: center; align-items: center; gap: 9px; flex-wrap: wrap; font-size: clamp(34px, 7vw, 56px); }
.pattern-slot {
  width: 1.5em; height: 1.5em; display: grid; place-items: center;
  background: #f6f1ff; border-radius: 16px;
}
.pattern-slot .pic { width: 1.05em; height: 1.05em; }
.pattern-slot.mystery { border: 4px dashed var(--accent); color: var(--accent); }

/* ---------- memory game ---------- */
.mem-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.mem-status { text-align: center; font-size: 20px; font-weight: 800; color: var(--ink-soft); }
.mem-grid {
  flex: 1; display: grid; gap: 14px; align-content: center; justify-content: center;
  grid-template-columns: repeat(var(--mcols, 4), minmax(72px, 116px));
}
.mem-card { perspective: 700px; aspect-ratio: 3/4; background: none; padding: 0; }
.mem-inner {
  display: block;   /* the element is a span; inline boxes can't size or 3D-flip */
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 420ms ease;
}
.mem-card.flipped .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; border-radius: 16px;
  display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 0 rgba(118,94,60,.12);
  font-size: clamp(28px, 6vw, 52px);
}
.mem-face .pic { width: 62%; height: 62%; }
.mem-back { background: linear-gradient(145deg, #8f74da, #6cb1f2); }
.mem-back .pic { width: 44%; height: 44%; opacity: .92; }
.mem-front { background: #fff; transform: rotateY(180deg); }
.mem-card.matched .mem-front { background: #d9f7e3; outline: 4px solid var(--good); animation: correct-pop var(--t-celebrate) ease; }
.mem-card:active .mem-inner { transform: scale(.95); }
.mem-card.flipped:active .mem-inner, .mem-card.matched:active .mem-inner { transform: rotateY(180deg); }

/* ---------- sorting game ---------- */
.sort-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.sort-item-zone { flex: 1; display: grid; place-items: center; min-height: 150px; }
.sort-item { font-size: clamp(80px, 15vw, 130px); line-height: 0; animation: drop-in var(--t-enter) ease-out both; }
.sort-item .pic { filter: drop-shadow(0 8px 9px rgba(118,94,60,.22)); }
.sort-item.flying { transition: transform 600ms cubic-bezier(.5,-0.1,.6,1.1), opacity 600ms ease; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-40px) scale(.7); } to { opacity: 1; transform: none; } }
.sort-bins { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sort-bin {
  background: #fff; border-radius: 24px; box-shadow: var(--shadow);
  border-top: 10px solid var(--bc, var(--accent));
  padding: 16px; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: 20px; font-weight: 800;
  transition: transform var(--t-tap) ease;
}
.sort-bin:active { transform: scale(.96); }
.sort-bin .bin-emoji { font-size: 48px; line-height: 0; }
.sort-bin .bin-count { font-size: 15px; color: var(--ink-soft); }
.sort-bin.bin-wrong { animation: shake 450ms ease; background: #ffe9e9; }
.sort-bin.bin-right { background: #d9f7e3; animation: correct-pop var(--t-celebrate) ease; }
.sort-bin.bin-hint { animation: hint-glow 1.5s ease-in-out infinite; }

/* ---------- tracing game ---------- */
.trace-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.trace-toolbar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.trace-tool {
  min-width: 64px; height: 64px; border-radius: 18px; font-size: 21px; font-weight: 800;
  background: #fff; box-shadow: var(--shadow); padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform var(--t-tap) ease;
}
.trace-tool:active { transform: scale(.92); }
.trace-tool.sel { outline: 4px solid var(--accent); }
.trace-color { width: 56px; min-width: 56px; height: 56px; border-radius: 50%; padding: 0; border: 4px solid #fff; box-shadow: var(--shadow); }
.trace-color.sel { outline: 4px solid var(--ink); }
.trace-canvas-holder { flex: 1; position: relative; min-height: 320px; }
#traceCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  background: #fff; border-radius: 22px; box-shadow: var(--shadow);
  touch-action: none; cursor: crosshair;
}
.trace-progress {
  position: absolute; inset-inline-start: 14px; top: 12px; background: rgba(255,255,255,.92);
  border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 17px;
  box-shadow: 0 3px 10px rgba(118,94,60,.15); pointer-events: none;
}

/* ---------- sticker book ---------- */
.sub-header { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.sub-title { flex: 1; text-align: center; font-size: clamp(22px, 5vw, 32px); margin: 0; }
.sub-spacer { width: 72px; }
.sticker-hint { text-align: center; color: var(--ink-soft); font-size: 17px; margin: 0 0 14px; }
.sticker-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}
.sticker {
  aspect-ratio: 1; background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  display: grid; place-items: center;
  animation: pop-in var(--t-enter) ease-out both;
}
.sticker span { display: grid; place-items: center; width: 100%; height: 100%; }
.sticker .pic { width: 62%; height: 62%; filter: drop-shadow(0 4px 6px rgba(118,94,60,.18)); }
.sticker.locked { background: rgba(255,255,255,.45); box-shadow: none; }
.sticker.locked .pic { filter: grayscale(1); opacity: .22; }
.sticker.fresh { outline: 5px solid var(--accent); }

/* ---------- settings ---------- */
.settings-main { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.setting-row {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; font-size: 21px; font-weight: 800;
  min-height: 76px;
}
.switch {
  width: 84px; height: 48px; border-radius: 999px; background: #ddd5ec;
  position: relative; transition: background 200ms ease;
}
.switch .knob {
  position: absolute; top: 5px; left: 5px; width: 38px; height: 38px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: left 200ms ease;
}
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"] .knob { left: 41px; }
.settings-card {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 18px 20px; font-size: 16px; line-height: 1.5;
}
.settings-card h3 { margin: 0 0 8px; font-size: 21px; }
.settings-card p { margin: 0 0 10px; color: var(--ink-soft); font-weight: 600; }
.settings-card .muted { font-size: 14px; opacity: .85; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(74, 60, 110, .45);
  display: grid; place-items: center; padding: 18px;
  animation: fade-in 250ms ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  background: #fff; border-radius: 30px; box-shadow: var(--shadow);
  width: min(560px, 94vw); max-height: 90vh; overflow-y: auto;
  padding: 26px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: pop-in var(--t-enter) ease-out both;
}
.overlay-title { font-size: clamp(26px, 5vw, 36px); font-weight: 800; margin: 0; }
.overlay-sub { font-size: 19px; color: var(--ink-soft); margin: 0; font-weight: 700; }
.overlay-big-emoji { font-size: 80px; line-height: 0; }
.overlay-big-emoji .pic { filter: drop-shadow(0 10px 12px rgba(118,94,60,.25)); }

.diff-list { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.diff-btn {
  display: flex; align-items: center; justify-content: space-between;
  background: #f7f3ff; border-radius: 20px; padding: 18px 20px;
  font-size: 23px; font-weight: 800; min-height: 76px;
  border: 4px solid transparent;
  transition: transform var(--t-tap) ease;
}
.diff-btn:active { transform: scale(.96); }
.diff-btn .diff-stars { letter-spacing: 1px; display: flex; align-items: center; gap: 6px; }
.diff-btn.last-played { border-color: var(--accent); }

.end-stars { display: flex; gap: 10px; font-size: 64px; min-height: 76px; }
.end-stars .star { opacity: .18; filter: grayscale(1); transform: scale(.6); line-height: 0; }
.end-stars .star.lit { opacity: 1; filter: none; animation: star-land 600ms ease-out both; }
@keyframes star-land { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.end-score { font-size: 21px; color: var(--ink-soft); font-weight: 800; margin: 0; }
.end-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.new-sticker-box {
  background: #fff8e1; border-radius: 20px; padding: 14px 24px;
  font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 12px;
}
.new-sticker-box .ns-emoji { font-size: 46px; line-height: 0; }

/* ---------- confetti ---------- */
#confetti-root { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -4vh; width: 14px; height: 14px;
  animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  to { transform: translateY(115vh) rotate(360deg); }
}
.burst-emoji {
  position: fixed; z-index: 81; pointer-events: none; font-size: 30px; line-height: 0;
  animation: burst-fly 950ms ease-out both;
}
@keyframes burst-fly {
  from { transform: translate(0, 0) scale(.6); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 18px; font-weight: 700;
  padding: 12px 22px; border-radius: 999px; z-index: 90;
  animation: toast-in 300ms ease-out both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  #app { padding: 10px 10px 22px; }
  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .game-card { padding: 16px 10px 14px; }
  .game-name { font-size: 18px; }
  .game-blurb { font-size: 12px; }
  .game-hero .pic { width: 64px; height: 64px; }
  .game-stage { padding: 12px; min-height: 70vh; }
  .quiz-options { gap: 13px; }
  .opt { min-height: 96px; border-radius: 18px; }
  .quiz-prompt { padding: 14px 64px; }
  .speak-again { width: 56px; height: 56px; font-size: 24px; }
  .hud-dots { display: none; }
  .round-btn { width: 60px; height: 60px; font-size: 26px; }
  .mem-grid { grid-template-columns: repeat(var(--mcols, 4), minmax(58px, 94px)); gap: 10px; }
  .sort-bin { min-height: 120px; }
  .logo-emoji { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  .opt.opt-hint, .sort-bin.bin-hint { animation: none; outline: 6px solid var(--hint); }
}

/* ============================================================
   New app-shell components (Arabic RTL redesign)
   ============================================================ */

/* RTL: flip directional arrow images (back arrows point "forward" = right) */
.flip-rtl { transform: scaleX(-1); }

/* ---------- profile chip (home header) ---------- */
.profile-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); box-shadow: var(--shadow);
  border-radius: 999px; padding: 8px 18px 8px 22px; min-height: 64px;
  transition: transform var(--t-tap) ease;
}
.profile-chip:active { transform: scale(.95); }
.chip-avatar { font-size: 40px; line-height: 0; }
.chip-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.chip-name { font-size: 17px; font-weight: 800; line-height: 1.1; }
.chip-pts { font-size: 15px; font-weight: 800; color: var(--ink-soft); display: flex; align-items: center; gap: 4px; }

/* ---------- home hero / greeting ---------- */
.home-hero {
  position: relative; text-align: center;
  margin: 10px 0 20px; padding: 26px 16px 34px;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 70% at 25% 108%, #b3e59f 0 52%, transparent 53%),
    radial-gradient(130% 75% at 80% 112%, #cdeebb 0 55%, transparent 56%),
    linear-gradient(180deg, #d9f0ff, #f0f9ff 70%);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.greeting { margin: 0 0 4px; font-size: clamp(26px, 5vw, 40px); font-weight: 800; color: var(--ink); }
.greeting-sub { margin: 0; font-size: clamp(16px, 3vw, 21px); font-weight: 700; color: var(--ink-soft); }
.hero-tree { position: absolute; bottom: 6px; width: clamp(44px, 7vw, 72px); filter: drop-shadow(0 4px 4px rgba(0,0,0,.12)); }
.hero-tree.t1 { inset-inline-start: 4%; }
.hero-tree.t2 { inset-inline-end: 5%; bottom: 10px; transform: scale(.7); }

/* ---------- level select ---------- */
.levels-hint { text-align: center; color: var(--ink-soft); font-size: 19px; font-weight: 700; margin: 0 0 16px; }
.levels-emoji { font-size: 34px; line-height: 0; }
.levels-grid {
  display: grid; gap: 20px; max-width: 760px; margin: 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.level-card {
  position: relative;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--c, var(--accent)) 8%, #fff),
    color-mix(in srgb, var(--c, var(--accent)) 20%, #fff));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 170px; padding: 18px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform var(--t-tap) ease;
  animation: pop-in var(--t-enter) ease-out both;
}
.level-card:active { transform: scale(.96); }
.level-name { font-size: 24px; font-weight: 800; color: color-mix(in srgb, var(--c, var(--accent)) 70%, var(--ink)); }
.level-desc { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.level-stars { margin-top: 2px; font-size: 17px; }
.level-ico { font-size: 56px; line-height: 0; margin-top: 8px; filter: drop-shadow(0 6px 8px rgba(118,94,60,.2)); }
.level-card.locked { filter: saturate(.35); opacity: .75; }
.level-card.locked .level-ico { filter: grayscale(.8); }
.level-lock {
  position: absolute; top: 12px; inset-inline-end: 12px;
  font-size: 26px; line-height: 0;
  background: rgba(255,255,255,.85); border-radius: 12px; padding: 7px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.shake-now { animation: shake 450ms ease; }

/* ---------- bottom navigation ---------- */
.bottom-nav {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 40;
  display: flex; gap: 6px;
  background: rgba(255,255,255,.95);
  border-radius: 999px; padding: 8px;
  box-shadow: 0 10px 30px rgba(118,94,60,.2);
  backdrop-filter: blur(6px);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 86px; padding: 8px 14px; border-radius: 999px;
  background: none; font-size: 14px; font-weight: 800; color: var(--ink-soft);
  transition: background 200ms ease, transform var(--t-tap) ease;
}
.nav-btn .pic, .nav-avatar { font-size: 24px; line-height: 1; }
.nav-avatar { display: inline-block; }
.nav-btn:active { transform: scale(.93); }
.nav-btn.active { background: color-mix(in srgb, var(--accent) 16%, #fff); color: var(--ink); }

/* ---------- daily tasks ---------- */
.tasks-list { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.task-row {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border-radius: 22px; box-shadow: var(--shadow);
  padding: 16px 18px;
  animation: pop-in var(--t-enter) ease-out both;
}
.task-ico { font-size: 42px; line-height: 0; }
.task-mid { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.task-text { font-size: 18px; font-weight: 800; }
.task-bar { height: 12px; border-radius: 8px; background: #efe9f8; overflow: hidden; }
.task-fill { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #69db7c, #38d9a9); transition: width 400ms ease; }
.task-count { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.task-reward {
  display: flex; align-items: center; gap: 4px;
  background: #fff8e1; border-radius: 14px; padding: 10px 14px;
  font-size: 16px; font-weight: 800; white-space: nowrap;
}
.task-row.done { opacity: .82; }
.task-row.done .task-reward { background: #d9f7e3; color: #2b8a3e; }

/* ---------- progress & profile stats ---------- */
.progress-main, .profile-main { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.progress-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 14px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--ink); }
.stat-label { font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.progress-games { display: flex; flex-direction: column; gap: 10px; }
.progress-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px 16px;
  border-inline-start: 8px solid var(--c, var(--accent));
}
.pr-ico { font-size: 34px; line-height: 0; }
.pr-name { flex: 1; font-size: 18px; font-weight: 800; }
.pr-stars { font-size: 15px; }

/* ---------- profile ---------- */
.profile-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-big-avatar { font-size: 84px; line-height: 0; filter: drop-shadow(0 8px 10px rgba(118,94,60,.22)); }
.profile-label { margin: 4px 0 0; font-size: 18px; font-weight: 800; color: var(--ink-soft); }
.name-input {
  font-family: var(--font); font-size: 22px; font-weight: 800; color: var(--ink);
  text-align: center; background: #f7f3ff; border: 3px solid #e3d9f7; border-radius: 16px;
  padding: 12px 18px; width: min(320px, 90%); outline: none;
}
.name-input:focus { border-color: var(--accent); }
.avatar-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.avatar-btn {
  width: 72px; height: 72px; border-radius: 20px; font-size: 44px; line-height: 0;
  background: #f7f3ff; display: grid; place-items: center;
  transition: transform var(--t-tap) ease;
}
.avatar-btn:active { transform: scale(.9); }
.avatar-btn.sel { outline: 4px solid var(--accent); background: #fff; }

/* ---------- celebration chest ---------- */
.chest-box {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #f7f3ff; border-radius: 22px; padding: 16px 34px;
}
.chest-emoji { font-size: 70px; line-height: 0; filter: drop-shadow(0 8px 10px rgba(118,94,60,.25)); }
.chest-pts { font-size: 26px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.big-btn.next-btn { background: #845ef7; }

@media (max-width: 640px) {
  .nav-btn { min-width: 64px; padding: 8px 8px; font-size: 12px; }
  .progress-stats { gap: 8px; }
  .stat-num { font-size: 24px; }
  .home-hero { padding: 18px 12px 26px; }
}

/* ---------- canvas / WebGL game stages ---------- */
.gl-wrap { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.gl-canvas-holder {
  flex: 1; position: relative; min-height: 340px;
  border-radius: 22px; overflow: hidden;
  background: linear-gradient(180deg, #eef6ff, #f8f4ff);
  box-shadow: var(--shadow);
}
.gl-canvas-holder canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none;
}

/* ---------- who is playing? (profile picker) ---------- */
.who-grid {
  display: grid; gap: 22px; max-width: 760px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.who-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 14px 20px; min-height: 190px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform var(--t-tap) ease;
  animation: pop-in var(--t-enter) ease-out both;
}
.who-card:active { transform: scale(.94); }
.who-card.active-kid { outline: 4px solid var(--accent); }
.who-avatar { font-size: 72px; line-height: 0; filter: drop-shadow(0 7px 9px rgba(118,94,60,.22)); }
.who-name { font-size: 22px; font-weight: 800; }
.who-meta { font-size: 16px; font-weight: 800; color: var(--ink-soft); display: flex; align-items: center; gap: 5px; }
.who-add { background: #f7f3ff; border: 3px dashed #cbb9f2; box-shadow: none; }
.who-plus { font-size: 58px; line-height: 1; color: #9775fa; font-weight: 800; }

/* ---------- first-letter game (الحرف الأول) ---------- */
.fl-img { line-height: 0; }
.fl-img .pic { width: clamp(64px, 11vw, 92px); height: clamp(64px, 11vw, 92px); filter: drop-shadow(0 6px 8px rgba(118,94,60,.2)); }
.fl-word { font-size: clamp(34px, 7vw, 52px); font-weight: 800; color: #845ef7; line-height: 1.15; }
.fl-hint { font-size: clamp(14px, 2.6vw, 18px); color: var(--ink-soft); font-weight: 700; }
.fl-q { margin-top: 4px; }
.fl-q b { color: #f06595; }

/* ---------- voice "coming soon" ---------- */
.soon-badge {
  display: inline-block; vertical-align: middle;
  background: #ffe9b3; color: #9a6b00;
  font-size: 13px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px; margin-inline-start: 6px;
}
.switch[disabled] { opacity: .45; cursor: default; }
body.no-voice .speak-again { display: none; }

/* ---------- engine games (Phaser canvas) ---------- */
.engine-stage {
  flex: 1; min-height: 64vh;
  display: grid; place-items: center;
}
.engine-stage canvas {
  border-radius: 20px;
  max-width: 100%;
  touch-action: none;
}

