/* Layout: one phone-width column, one problem per screen; big tap targets; the problem is the hero. (Base shared with Sight Words.) */
@font-face { font-family: 'Andika'; font-weight: 400; font-display: swap; src: url('fonts/andika-400.woff2') format('woff2'); }
@font-face { font-family: 'Andika'; font-weight: 700; font-display: swap; src: url('fonts/andika-700.woff2') format('woff2'); }

:root {
  --sky: #e6f1ff;        /* page ground */
  --paper: #ffffff;      /* cards and tiles */
  --ink: #1b2a4a;        /* text */
  --ink-soft: #55658a;   /* secondary text */
  --line: #c9d8f0;       /* borders */
  --blue: #2f6fdb;       /* primary action */
  --blue-ink: #ffffff;
  --sun: #ffc83d;        /* progress, stars */
  --sun-deep: #e8a500;
  --leaf: #2fa866;       /* right answer */
  --leaf-soft: #dff5e8;
  --coral: #e2614f;      /* delete only */
  --mark: #fff0b3;       /* word highlight in sentences */
  --shadow: 0 3px 0 #c3d3ec;
  --font: 'Andika', 'Comic Neue', 'Trebuchet MS', system-ui, sans-serif;
  --r: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #111b33; --paper: #1c2a4d; --ink: #eef3ff; --ink-soft: #a9b8d9; --line: #2f4170;
    --blue: #5b93f2; --blue-ink: #0d1530; --sun: #ffcf4d; --sun-deep: #ffb300; --leaf: #49c483;
    --leaf-soft: #17402c; --coral: #ff7d6b; --mark: #5a4a10; --shadow: 0 3px 0 #0a1124; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky: #111b33; --paper: #1c2a4d; --ink: #eef3ff; --ink-soft: #a9b8d9; --line: #2f4170;
  --blue: #5b93f2; --blue-ink: #0d1530; --sun: #ffcf4d; --sun-deep: #ffb300; --leaf: #49c483;
  --leaf-soft: #17402c; --coral: #ff7d6b; --mark: #5a4a10; --shadow: 0 3px 0 #0a1124; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--sky); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }

.app {
  height: 100%; max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.screen { min-height: 100%; display: flex; flex-direction: column; gap: 18px; padding-block: 16px 24px; }
.loading { margin: auto; color: var(--ink-soft); }

/* ---------- shared buttons ---------- */
.big-btn {
  min-height: 72px; border: 0; border-radius: var(--r); background: var(--blue); color: var(--blue-ink);
  font-size: 30px; font-weight: 700; padding: 0 28px; box-shadow: 0 5px 0 color-mix(in srgb, var(--blue) 60%, #000);
  transition: transform .08s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--blue) 60%, #000); }
.mid-btn {
  min-height: 64px; border: 3px solid var(--line); border-radius: var(--r); background: var(--paper);
  font-size: 24px; font-weight: 700; padding: 0 18px; box-shadow: var(--shadow);
}
.round-btn {
  width: 60px; height: 60px; flex: none; border: 3px solid var(--line); border-radius: 50%;
  background: var(--paper); font-size: 26px; display: grid; place-items: center; box-shadow: var(--shadow);
}
.round-spacer { width: 60px; flex: none; }
.pill-btn {
  min-height: 44px; border: 2px solid var(--line); border-radius: 999px; background: var(--paper);
  padding: 6px 16px; font-size: 16px; font-weight: 700;
}
.pill-btn.primary { background: var(--blue); color: var(--blue-ink); border-color: var(--blue); }
.pill-btn.danger { background: var(--coral); color: #fff; border-color: var(--coral); }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { margin: 0; font-size: 34px; letter-spacing: .5px; }
.brand::first-letter { color: var(--blue); }
.speak-chip { width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--line); background: var(--paper); font-size: 26px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 8px 16px;
  background: var(--paper); border: 3px solid var(--line); border-radius: 28px; box-shadow: 0 6px 0 var(--line);
  min-height: 180px; justify-content: center;
}
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.tile-icon { font-size: 68px; line-height: 1; }
.tile-name { font-size: 26px; font-weight: 700; overflow-wrap: anywhere; text-align: center; }
.tile-level { font-size: 17px; font-weight: 700; color: var(--ink); background: var(--sun); border-radius: 999px; padding: 2px 12px; }
.empty { margin: auto 0; text-align: center; display: grid; gap: 10px; }
.empty-big { font-size: 30px; font-weight: 700; margin: 0; }
.empty-small { color: var(--ink-soft); margin: 0; }
.home-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gate { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); font-size: 22px; display: grid; place-items: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.gate-ring { position: absolute; inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); transform: rotate(-90deg); pointer-events: none; }
.gate-ring circle { fill: none; stroke: var(--blue); stroke-width: 4; stroke-dasharray: 120; stroke-dashoffset: 120; }
.gate.holding .gate-ring circle { transition: stroke-dashoffset 3s linear; stroke-dashoffset: 0; }
.gate-hint { font-size: 14px; color: var(--ink-soft); }
.warn { color: var(--coral); font-size: 15px; margin: 0; flex-basis: 100%; }
.ok { color: var(--leaf); font-weight: 700; }

/* ---------- child start ---------- */
.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-icon { font-size: 40px; }
.who-name { font-size: 28px; font-weight: 700; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 10px 6px; display: grid; justify-items: center; }
.stat-n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 15px; color: var(--ink-soft); }
.map { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px 4px; }
.stop { display: grid; justify-items: center; gap: 1px; }
.stop-dot {
  width: 100%; max-width: 42px; aspect-ratio: 1; border-radius: 50%; border: 2px dashed var(--line);
  display: grid; place-items: center; font-size: 22px; background: transparent;
}
.stop.done .stop-dot { border: 2px solid var(--sun-deep); background: var(--sun); }
.stop.next .stop-dot { border: 3px solid var(--blue); background: var(--paper); animation: bob 1.6s ease-in-out infinite; }
.stop-lv { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.today-line { margin: 0; text-align: center; color: var(--ink-soft); font-weight: 700; }
.start-btn { margin-top: auto; min-height: 96px; font-size: 40px; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- play ---------- */
.play-top { display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; height: 26px; border-radius: 999px; background: var(--paper); border: 2px solid var(--line); overflow: hidden; }
.progress-fill { height: 100%; background: var(--sun); border-radius: 999px; transition: width .4s ease; }
.progress.full .progress-fill { background: linear-gradient(90deg, var(--sun), var(--sun-deep)); }
.counter { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 64px; text-align: right; }

.listen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; }
.speaker {
  width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--blue); color: var(--blue-ink);
  font-size: 56px; box-shadow: 0 6px 0 color-mix(in srgb, var(--blue) 60%, #000);
}
.speaker:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--blue) 60%, #000); }
.cards { width: 100%; display: grid; gap: 18px; }
.card {
  min-height: 120px; border-radius: 28px; border: 4px solid var(--line); background: var(--paper);
  font-size: clamp(48px, 15vw, 64px); font-weight: 700; box-shadow: 0 6px 0 var(--line);
  transition: transform .1s, opacity .3s, background .2s;
}
.card:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.card:disabled { cursor: default; }
.card.right { background: var(--leaf-soft); border-color: var(--leaf); box-shadow: 0 6px 0 var(--leaf); animation: pop .35s ease; }
.card.dim { opacity: .35; }
@keyframes pop { 40% { transform: scale(1.06); } }

.explore { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.tag { margin: 0; font-weight: 700; padding: 4px 14px; border-radius: 999px; font-size: 17px; }
.new-tag { background: var(--sun); color: #1b2a4a; }
.ok-tag { background: var(--leaf-soft); color: var(--leaf); }
.try-tag { background: var(--paper); color: var(--ink-soft); border: 2px solid var(--line); }
.pic { font-size: 72px; line-height: 1; }
.word-big {
  border: 0; background: none; font-size: clamp(64px, 22vw, 104px); font-weight: 700; line-height: 1.1;
  padding: 8px 16px; border-radius: var(--r); overflow-wrap: anywhere;
}
.word-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(100%, 280px); }
.step { height: 18px; border-radius: 999px; background: var(--paper); border: 2px solid var(--line); }
.step.on { background: var(--leaf); border-color: var(--leaf); }
.step.just { animation: fill .5s ease; }
.word-steps.full .step { background: var(--sun); border-color: var(--sun-deep); }
@keyframes fill { from { transform: scaleX(.2); opacity: .3; } }
.explain {
  width: 100%; background: var(--paper); border: 3px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; font-size: 26px; line-height: 1.35;
}
.explain mark { background: var(--mark); color: inherit; font-weight: 700; padding: 0 4px; border-radius: 6px; }
.explore-btns { width: 100%; margin-top: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.explore-btns .next-btn { grid-column: 1 / -1; }
.explore-btns .mid-btn:only-child, .explore-btns > :first-child:nth-last-child(2) { grid-column: auto; }

/* ---------- celebration ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: color-mix(in srgb, var(--sky) 70%, transparent); backdrop-filter: blur(3px);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.celebrate-card {
  position: relative; width: min(100%, 420px); background: var(--paper); border: 4px solid var(--sun);
  border-radius: 32px; padding: 28px 22px; text-align: center; display: grid; gap: 10px; animation: rise .4s ease;
}
.celebrate-card h2 { margin: 0; font-size: 40px; }
.celebrate-card p { margin: 0 0 8px; font-size: 22px; }
.celebrate-art { font-size: 72px; line-height: 1.1; letter-spacing: 4px; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; left: calc(var(--i) * 4.2%); width: 10px; height: 16px; border-radius: 3px;
  background: var(--sun); animation: fall 2.6s linear calc(var(--i) * -0.11s) infinite;
}
.confetti i:nth-child(3n) { background: var(--blue); }
.confetti i:nth-child(3n+1) { background: var(--leaf); }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes rise { from { transform: translateY(30px) scale(.9); opacity: 0; } }

/* ---------- parent ---------- */
.parent { gap: 14px; font-size: 16px; }
.parent-head { display: flex; align-items: center; justify-content: space-between; }
.parent-head h1 { margin: 0; font-size: 26px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { flex: none; min-height: 44px; border: 2px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 16px; }
.tab.on { background: var(--ink); color: var(--sky); border-color: var(--ink); }
.parent-body { display: grid; gap: 14px; }
.panel { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 10px; min-width: 0; }
.panel h2 { margin: 0; font-size: 20px; }
.note { margin: 0; color: var(--ink-soft); font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 14px; font-weight: 700; }
.chip.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 15%, var(--paper)); }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { display: grid; }
.kpi-n { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 14px; color: var(--ink-soft); }
.boxes { display: grid; gap: 6px; }
.box-row { display: grid; grid-template-columns: 80px 1fr 40px; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.box-l { font-size: 14px; color: var(--ink-soft); }
.box-bar { height: 14px; background: var(--sky); border-radius: 999px; overflow: hidden; }
.box-bar span { display: block; height: 100%; background: var(--sun); border-radius: 999px; }
.box-row.known .box-bar span { background: var(--leaf); }
.box-n { text-align: right; font-weight: 700; }
.word-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.word-chips li { border: 2px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.word-chips li:not(:has(button)) { padding-right: 12px; }
.word-chips small { font-weight: 400; color: var(--ink-soft); }
.x-btn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--sky); font-size: 18px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-soft); font-weight: 700; }
.child-list, .lookup { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.child-list li, .lookup li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.cl-icon { font-size: 34px; }
.cl-main { flex: 1; min-width: 0; display: grid; }
.cl-main small, .lookup small { color: var(--ink-soft); }
.cl-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.child-list { gap: 0; }
.child-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.child-list .cl-btns, .reset-note { grid-column: 1 / -1; }
.reset-note { color: var(--coral); }
.child-form label, .inline-form label, .label { font-weight: 700; font-size: 15px; }
.child-form input[type="text"], .child-form #cf-name, .inline-form input, textarea {
  width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--sky);
}
.inline-form { display: grid; gap: 6px; }
.inline-form .pill-btn { justify-self: start; margin-top: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.icon-opt { aspect-ratio: 1; border: 2px solid var(--line); border-radius: 14px; background: var(--sky); font-size: 28px; padding: 0; }
.icon-opt.on { border: 3px solid var(--blue); background: color-mix(in srgb, var(--blue) 18%, var(--paper)); }
.stepper { display: grid; gap: 4px; }
.stepper-ctl { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 80px; min-height: 48px; text-align: center; border: 2px solid var(--line); border-radius: 12px; background: var(--sky); font-weight: 700; font-size: 20px; }
.step-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); font-size: 24px; font-weight: 700; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.switch input { width: 24px; height: 24px; }
.seg { display: flex; gap: 6px; }
.seg-btn { min-height: 44px; flex: 1; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; text-transform: capitalize; }
.seg-btn.on { background: var(--blue); color: var(--blue-ink); border-color: var(--blue); }
.file-btn { position: relative; display: inline-flex; align-items: center; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.about p { margin: 0; }

/* ---------- print (flashcards) ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .app > *:not(.screen), .screen > *:not(.parent-body), .parent-body > *:not(#print-area) { display: none !important; }
  #print-area { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0; }
  .flash { border: 2px dashed #999; height: 3.2in; display: grid; place-items: center; font: 700 72px var(--font); color: #000; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}
@media (max-height: 640px) {
  .speaker { width: 96px; height: 96px; font-size: 44px; }
  .card { min-height: 96px; }
  .listen { gap: 20px; }
}

/* ---------- reward games ---------- */
.game-btn { animation: bob 1.4s ease-in-out infinite; border-color: var(--sun-deep); background: var(--sun); }
.game-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.game-tile {
  min-height: 120px; border: 3px solid var(--line); border-radius: var(--r); background: var(--sky);
  display: grid; place-items: center; gap: 2px; font-size: 22px; font-weight: 700; box-shadow: var(--shadow);
}
.game-tile span { font-size: 48px; line-height: 1; }
.switch-menu { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.switch-menu[hidden] { display: none; }
.switch-menu span { font-size: 22px; }
.shell-stage { --swap: 500ms; position: relative; flex: 1; min-height: 260px; max-height: 60vh; border-radius: var(--r); background: linear-gradient(#bfe6ff, #f6e7c8 62%, #ecd3a4); border: 3px solid var(--line); overflow: hidden; }
.shell { position: absolute; bottom: 18%; left: calc(var(--slot) * 33.333% + 16.667%); width: 30%; height: 46%; transform: translateX(-50%);
  border: 0; background: none; padding: 0; cursor: pointer; transition: left var(--swap) ease-in-out; -webkit-tap-highlight-color: transparent; }
.shell-cup { position: absolute; inset: 0; display: grid; place-items: end center; font-size: clamp(64px, 20vw, 110px); line-height: 1; transition: transform .35s ease-out; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .12)); }
.shell-gem { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: clamp(30px, 9vw, 48px); opacity: 0; transition: opacity .2s; }
.shell.lifted .shell-cup { transform: translateY(-58%); }
.shell.lifted.has-gem .shell-gem { opacity: 1; }
.shell.wrong .shell-cup { filter: drop-shadow(0 0 10px rgba(229, 80, 57, .7)); }
.shell.right .shell-cup { filter: drop-shadow(0 0 12px rgba(255, 210, 63, .95)); }
.shell.arc-up { animation: shell-up var(--swap) ease-in-out; }
.shell.arc-down { animation: shell-down var(--swap) ease-in-out; }
@keyframes shell-up { 50% { transform: translateX(-50%) translateY(-22%) scale(.92); } }
@keyframes shell-down { 50% { transform: translateX(-50%) translateY(12%) scale(1.06); } }
.game-frame { flex: 1; width: 100%; min-height: 72vh; border: 3px solid var(--line); border-radius: var(--r); background: #fff; }
.game { position: relative; gap: 12px; }
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.switch-btn { min-height: 56px; font-size: 18px; padding: 6px 16px; white-space: nowrap; }
.switch-btn span { font-size: 24px; }
.game-timer { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--paper); border: 2px solid var(--line); border-radius: 999px; padding: 4px 14px; }
.game-area { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.game-hint, .game-score { margin: 0; text-align: center; font-size: 22px; font-weight: 700; }
.game-end { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: color-mix(in srgb, var(--sky) 75%, transparent); backdrop-filter: blur(3px); }
.game-next { color: var(--ink-soft); font-size: 18px !important; }

.match-grid { flex: 1; display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 4), minmax(60px, 1fr)); gap: 8px; max-height: 72vh; }
.mcard { border: 0; padding: 0; background: none; perspective: 600px; min-height: 60px; }
.mcard-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.mcard.up .mcard-inner { transform: rotateY(180deg); }
.mcard-back, .mcard-front { position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; }
.mcard-back {
  background: var(--blue); border: 3px solid color-mix(in srgb, var(--blue) 70%, #000);
  background-image: radial-gradient(circle at 50% 50%, var(--sun) 0 14%, transparent 15%);
  background-size: 34px 34px;
}
.mcard-front { transform: rotateY(180deg); background: var(--paper); border: 3px solid var(--line); font-size: clamp(30px, calc(46px - (var(--rows, 4) - 4) * 6px), 46px); }
.mcard.done .mcard-front { border-color: var(--leaf); background: var(--leaf-soft); }

.pong-score { display: flex; justify-content: space-between; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pong-score b { font-size: 30px; }
.pong-wrap { position: relative; flex: 1; min-height: 360px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.pong-wrap canvas { position: absolute; inset: 0; display: block; }
.pong-msg { margin: 0; min-height: 1.4em; text-align: center; font-weight: 700; font-size: 20px; }
.game-area { position: relative; }
.board-done {
  position: absolute; inset: 30% 8% auto; z-index: 3; display: grid; justify-items: center; gap: 4px;
  background: var(--paper); border: 4px solid var(--sun); border-radius: 28px; padding: 22px 16px;
  font-size: 28px; font-weight: 700; text-align: center; animation: rise .35s ease;
}
.board-done span { font-size: 56px; line-height: 1; }
.board-done small { font-size: 20px; color: var(--ink-soft); }

/* ======================================================================
   Math Quest
   ====================================================================== */
:root { --sun-soft: #fff4cc; --pic-1: #2f6fdb; --pic-2: #e2614f; --pic-3: #2fa866; --pic-4: #b06fd8; --copper: #d08a4e; --copper-deep: #9c5a26; --silver: #d9dee8; --silver-deep: #8d97aa; --bill: #cfe6c8; --bill-deep: #3f7a4a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sun-soft: #4a3d10; --pic-1: #5b93f2; --pic-2: #ff7d6b; --pic-3: #49c483; --pic-4: #c99af0; --copper: #c98552; --copper-deep: #f0b27a; --silver: #b8c0d0; --silver-deep: #e6ebf5; --bill: #2b4a33; --bill-deep: #9fd6a8; } }
:root[data-theme="dark"] { --sun-soft: #4a3d10; --pic-1: #5b93f2; --pic-2: #ff7d6b; --pic-3: #49c483; --pic-4: #c99af0; --copper: #c98552; --copper-deep: #f0b27a; --silver: #b8c0d0; --silver-deep: #e6ebf5; --bill: #2b4a33; --bill-deep: #9fd6a8; }

/* home */
.hero-card { background: var(--paper); border: 3px solid var(--line); border-radius: 28px; padding: 16px; display: grid; gap: 14px; box-shadow: 0 6px 0 var(--line); }
.areas { display: grid; gap: 10px; }
.area-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 10px; font-weight: 700; }
.area-ic { font-size: 26px; text-align: center; }
.area-name { font-size: 17px; }
.area-bar { height: 18px; border-radius: 999px; background: var(--paper); border: 2px solid var(--line); overflow: hidden; }
.area-bar span { display: block; height: 100%; background: var(--leaf); border-radius: 999px; }
.home .start-btn { margin-top: auto; }

/* play */
.play { gap: 14px; }
.q { display: grid; gap: 12px; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-tag { font-size: 15px; font-weight: 700; color: var(--ink-soft); min-width: 0; }
.lvl { color: var(--sun-deep); letter-spacing: 1px; white-space: nowrap; }
.speak-btn { width: 56px; height: 56px; flex: none; border-radius: 50%; border: 0; background: var(--blue); color: var(--blue-ink); font-size: 24px; box-shadow: 0 4px 0 color-mix(in srgb, var(--blue) 60%, #000); }
.speak-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--blue) 60%, #000); }
.prompt { font-size: clamp(30px, 8vw, 40px); font-weight: 700; line-height: 1.25; text-align: center; text-wrap: balance; font-variant-numeric: tabular-nums; }
.prompt.story { font-size: clamp(21px, 5.4vw, 25px); font-weight: 400; text-align: left; line-height: 1.45; background: var(--paper); border: 3px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.prompt small { font-size: .85em; color: var(--ink-soft); font-weight: 700; }
.prompt .eq { display: inline-block; margin-top: 6px; font-size: 1.15em; }
.blank { display: inline-block; min-width: 1.4em; border-bottom: 4px solid var(--blue); color: var(--blue); }
.eq.sm { font-size: 24px; font-weight: 700; }
.visual { display: grid; justify-items: center; gap: 8px; min-width: 0; }
.answer { display: grid; gap: 12px; margin-top: auto; min-width: 0; }

/* number pad */
.answer-box { justify-self: center; display: flex; align-items: center; gap: 6px; min-width: 160px; min-height: 76px; padding: 4px 18px; background: var(--paper); border: 4px solid var(--blue); border-radius: var(--r); font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.answer-box.shown { border-color: var(--leaf); background: var(--leaf-soft); }
.ab-val { min-width: 1.2ch; text-align: center; }
.ab-val.empty::after { content: '\2009'; }
.ab-fix { color: var(--ink-soft); font-size: 30px; }
.ab-fix:empty { display: none; }
.pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(100%, 360px); justify-self: center; }
.key { min-height: 62px; border: 3px solid var(--line); border-radius: 18px; background: var(--paper); font-size: 30px; font-weight: 700; box-shadow: var(--shadow); }
.key:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.key.soft { color: var(--ink-soft); }
.key.go { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.key:disabled { opacity: .45; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* choices */
.choices { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 12px; }
.choice { min-height: 72px; border: 4px solid var(--line); border-radius: var(--r); background: var(--paper); font-size: 28px; font-weight: 700; padding: 8px; box-shadow: 0 5px 0 var(--line); display: grid; place-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.choices.pics .choice { min-height: 120px; font-size: 18px; }
.choice .pic-svg { width: 100%; max-width: 110px; max-height: 96px; }
.choice.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 16%, var(--paper)); box-shadow: 0 5px 0 var(--blue); }
.choice.right { border-color: var(--leaf); background: var(--leaf-soft); box-shadow: 0 5px 0 var(--leaf); animation: pop .35s ease; }
.choice.wrong { opacity: .35; text-decoration: line-through; }
.check-btn { width: 100%; }
.check-btn:disabled { opacity: .45; }

/* equation builder */
.eq-build { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.slot { width: 68px; height: 72px; border: 4px dashed var(--line); border-radius: 18px; background: var(--paper); font-size: 34px; font-weight: 700; }
.slot.filled { border-style: solid; border-color: var(--blue); }
.slot.op { border: 4px solid var(--sun-deep); background: var(--sun-soft); width: 56px; }
.eq-eq { font-size: 36px; font-weight: 700; }
.tile-bank { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tile-n { width: 66px; height: 66px; border: 3px solid var(--line); border-radius: 16px; background: var(--paper); font-size: 30px; font-weight: 700; box-shadow: var(--shadow); }
.tile-n.used { visibility: hidden; }

/* hundreds chart */
.hchart { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.hc-cell { aspect-ratio: 1; min-height: 32px; border: 2px solid var(--line); border-radius: 8px; background: var(--paper); font-size: clamp(13px, 3.8vw, 18px); font-weight: 700; padding: 0; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.hc-cell.mark { background: var(--sun); border-color: var(--sun-deep); color: #1b2a4a; }
.hc-cell.on { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
.hc-cell.right { background: var(--leaf); border-color: var(--leaf); color: #fff; }

/* coins */
.tray { min-height: 92px; border: 3px dashed var(--line); border-radius: var(--r); background: var(--paper); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; padding: 8px; }
.tray-empty { color: var(--ink-soft); font-size: 16px; }
.tray-coin, .coin-btn { border: 0; background: none; padding: 2px; }
.tray-total { margin: 0; text-align: center; font-size: 26px; font-weight: 700; }
.coin-bank { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.coin-btn { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 96px; border: 3px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); font-size: 15px; font-weight: 700; }
.coin-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.coin-row.big .pic-svg { transform: scale(1.8); margin: 30px; }
.pic-svg.coin { height: auto; max-width: 100%; }
.coin.copper { fill: var(--copper); stroke: var(--copper-deep); stroke-width: 1.5; }
.coin.silver { fill: var(--silver); stroke: var(--silver-deep); stroke-width: 1.5; }
.coin-rim { fill: none; stroke: rgba(0,0,0,.18); stroke-width: 1; }
.coin-t { fill: #3a2a18; font-family: var(--font); font-weight: 700; text-anchor: middle; }
.bill-svg { width: 140px; max-width: 46%; }
.bill { fill: var(--bill); stroke: var(--bill-deep); stroke-width: 2; }
.bill-in { fill: none; stroke: var(--bill-deep); stroke-width: 1; }
.bill-oval { fill: none; stroke: var(--bill-deep); stroke-width: 1.5; }
.bill-n { fill: var(--bill-deep); font: 700 20px var(--font); }
.bill-w { fill: var(--bill-deep); font: 700 9px var(--font); text-anchor: middle; letter-spacing: .5px; }

/* drawn pictures */
.pic-svg { display: block; max-width: 100%; height: auto; }
.one-shape { display: grid; place-items: center; }
.one-shape .pic-svg { width: min(240px, 70vw); }
.shp { fill: color-mix(in srgb, var(--blue) 22%, var(--paper)); stroke: var(--blue); stroke-width: 3; stroke-linejoin: round; }
.split line { stroke: var(--blue); stroke-width: 2.5; }
.solid-face { fill: color-mix(in srgb, var(--leaf) 22%, var(--paper)); stroke: none; }
.solid-face.top { fill: color-mix(in srgb, var(--leaf) 12%, var(--paper)); }
.solid-face.side { fill: color-mix(in srgb, var(--leaf) 32%, var(--paper)); }
path.solid-face { stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
ellipse.solid-face, circle.solid-face { stroke: var(--ink); stroke-width: 2.5; }
.edge { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; fill: none; }
.edge.hid { stroke-dasharray: 5 5; stroke-width: 2; opacity: .7; }
.cell { fill: color-mix(in srgb, var(--sun) 55%, var(--paper)); stroke: var(--sun-deep); stroke-width: 2; }
.side-l { fill: var(--ink); font: 700 19px var(--font); text-anchor: middle; }
.perim { width: min(320px, 86vw); }
.clock { width: min(220px, 60vw); }
.clock-face { fill: var(--paper); stroke: var(--ink); stroke-width: 5; }
.tick { stroke: var(--ink-soft); stroke-width: 1.5; }
.tick.big { stroke: var(--ink); stroke-width: 3; }
.clock-n { fill: var(--ink); font: 700 20px var(--font); text-anchor: middle; }
.hand { stroke-linecap: round; }
.hand.hour { stroke: var(--ink); stroke-width: 8; }
.hand.min { stroke: var(--blue); stroke-width: 5; }
.hub { fill: var(--ink); }
.two-clocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.two-clocks div { display: grid; justify-items: center; gap: 4px; font-weight: 700; }
.two-clocks .clock { width: 100%; max-width: 170px; }
.part { fill: var(--paper); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.part.on { fill: var(--sun); }
.frac { width: min(200px, 56vw); }
.frac.bar { width: min(260px, 72vw); }
.choice .frac, .choice .frac.bar { width: 100%; }
.shade-wrap .frac { width: min(240px, 66vw); }
[data-part] { cursor: pointer; }
.fr { display: inline-grid; grid-template-rows: auto auto; line-height: 1; vertical-align: middle; text-align: center; font-size: .9em; }
.fr sup { border-bottom: 3px solid currentColor; padding: 0 .15em 2px; font-size: 1em; vertical-align: baseline; }
.fr sub { padding-top: 2px; font-size: 1em; vertical-align: baseline; }
.bt { fill: color-mix(in srgb, var(--blue) 30%, var(--paper)); stroke: var(--blue); stroke-width: .8; }
.bt.one { fill: var(--sun); stroke: var(--sun-deep); }
.base-ten { width: auto; max-width: 100%; height: 120px; }
.tal { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.tally { height: 64px; width: auto; max-width: 100%; }
.tally-box { min-height: 92px; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--line); border-radius: var(--r); padding: 10px; }
.center { justify-content: center; }
.ruler-svg { min-width: 360px; }
.ruler { fill: var(--sun-soft); stroke: var(--sun-deep); stroke-width: 2; }
.rtick { stroke: var(--ink); stroke-width: 2; }
.rnum { fill: var(--ink); font: 700 13px var(--font); text-anchor: middle; }
.rod { fill: color-mix(in srgb, var(--pic-4) 35%, var(--paper)); stroke: var(--pic-4); stroke-width: 2; }
.rguide { stroke: var(--pic-4); stroke-width: 1.5; stroke-dasharray: 3 3; }
.rod-e { font-size: 16px; text-anchor: middle; }
.hscroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.nl { stroke: var(--ink); stroke-width: 3; }
.nl-arrow { fill: var(--ink); }
.nl-t { stroke: var(--ink); stroke-width: 2.5; }
.nl-n { fill: var(--ink); font: 700 16px var(--font); text-anchor: middle; }
.nl-pt { fill: var(--coral); stroke: var(--paper); stroke-width: 2; }
.nl-hit { fill: transparent; cursor: pointer; }
.nl-hit:focus-visible { outline: none; fill: color-mix(in srgb, var(--sun) 40%, transparent); }
.nl-pick { fill: var(--blue); stroke: var(--paper); stroke-width: 3; }
.nl-pick.shown { fill: var(--leaf); }
.jump { fill: none; stroke: var(--leaf); stroke-width: 3; }
.jump-h { fill: var(--leaf); }
.picked { margin: 0; text-align: center; color: var(--ink-soft); font-weight: 700; }

/* objects, ten frames, arrays, vertical sums */
.objs { display: grid; gap: 4px; justify-items: center; font-size: 30px; line-height: 1.15; }
.objs-wrap { display: flex; flex-wrap: wrap; justify-content: center; max-width: 340px; }
.obj-row { display: flex; gap: 4px; }
.objs .gone { opacity: .35; position: relative; }
.objs .gone::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--coral); font-weight: 700; font-size: 34px; }
.objs-two { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 30px; }
.array .objs { font-size: 34px; gap: 8px; }
.array .obj-row { gap: 10px; }
.tenframes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.tenframe { display: grid; grid-template-columns: repeat(5, 36px); grid-auto-rows: 36px; border: 3px solid var(--ink); background: var(--ink); gap: 3px; border-radius: 6px; }
.tenframe .dot { background: var(--paper); display: grid; place-items: center; }
.tenframe .dot.a::after, .tenframe .dot.b::after { content: ''; width: 24px; height: 24px; border-radius: 50%; background: var(--coral); }
.tenframe .dot.b::after { background: var(--blue); }
.vertical { display: grid; justify-items: end; font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: pre; line-height: 1.1; }
.v-row { display: flex; gap: 14px; }
.v-op { min-width: 1ch; }
.v-line { width: 100%; height: 0; border-top: 5px solid var(--ink); margin-top: 4px; }

/* graphs and tables */
.graph { margin: 0; width: 100%; display: grid; gap: 6px; justify-items: center; }
.graph figcaption { font-weight: 700; font-size: 19px; }
.bars { width: auto; max-width: 100%; height: 220px; }
.grid-l { stroke: var(--line); stroke-width: 1.5; }
.ax-n { fill: var(--ink-soft); font: 700 13px var(--font); text-anchor: end; }
.bar { stroke-width: 0; }
.bar.b0 { fill: var(--pic-1); } .bar.b1 { fill: var(--pic-2); } .bar.b2 { fill: var(--pic-3); } .bar.b3 { fill: var(--pic-4); }
.bar-e { font-size: 24px; text-anchor: middle; }
.bar-key { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.pgraph, .dtable { border-collapse: collapse; font-size: 20px; }
.pgraph th { text-align: left; padding: 6px 10px 6px 0; font-size: 17px; white-space: nowrap; }
.pgraph td { padding: 4px 0; letter-spacing: 2px; white-space: normal; font-size: 24px; border-bottom: 1px solid var(--line); }
.pgraph th { border-bottom: 1px solid var(--line); }
.pg-key { margin: 0; font-weight: 700; color: var(--ink-soft); font-size: 16px; }
.dtable th, .dtable td { border: 2px solid var(--line); padding: 8px 18px; text-align: center; font-size: 20px; white-space: nowrap; }
.dtable th { background: var(--sky); color: var(--ink); }

/* clock setter */
.clockset { display: grid; justify-items: center; gap: 4px; }
.cs-digital { margin: 0; font-size: 26px; font-weight: 700; min-height: 1em; color: var(--leaf); }
.cs-ctl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cs-grp { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 8px; flex-wrap: wrap; font-weight: 700; }
.cs-grp .step-btn { width: 56px; height: 56px; font-size: 20px; }

/* feedback */
.feedback { position: sticky; bottom: max(8px, env(safe-area-inset-bottom, 0px)); z-index: 4; display: grid; gap: 10px; border-radius: var(--r); padding: 14px 16px; border: 4px solid var(--line); background: var(--paper); animation: rise .25s ease; box-shadow: 0 6px 0 var(--line); }
.feedback p { margin: 0; font-size: 19px; }
.feedback .fb-big { font-size: 26px; font-weight: 700; }
.feedback.good { border-color: var(--leaf); background: var(--leaf-soft); box-shadow: 0 6px 0 var(--leaf); }
.feedback.hint { border-color: var(--sun-deep); background: var(--sun-soft); box-shadow: 0 6px 0 var(--sun-deep); }
.feedback.show { border-color: var(--blue); }
.fb-body { display: grid; gap: 6px; }
.fb-answer { font-size: 24px; font-weight: 700; display: grid; justify-items: start; gap: 6px; }
.fb-answer .pic-svg { max-width: 160px; }
.lvl-up { font-weight: 700; color: var(--leaf); }

/* grown-ups */
.rit { font-size: 15px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; }
.skill-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.skill-list li:last-child { border-bottom: 0; }
.sk-main { display: grid; gap: 2px; min-width: 0; }
.sk-main small { color: var(--ink-soft); font-size: 13px; }
.sk-meta { display: grid; justify-items: end; align-content: start; gap: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.sk-acc { color: var(--ink-soft); }
.table-wrap td small { color: var(--ink-soft); }
.feedback[hidden] { display: none; }
