/* ============ Math Galaxy — styles ============ */
/* Baloo 2 (SIL Open Font License, see fonts/OFL.txt), bundled so the app works offline */
@font-face {
  font-family: "Baloo 2";
  src: url("../fonts/baloo2-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #0b1033;
  --bg2: #1d2470;
  --card: #fff8ec;
  --card2: #ffffff;
  --ink: #1f2340;
  --muted: #5d6286;
  --line: #e8dcc6;
  --add: #ff9f1c;
  --sub: #9b5de5;
  --mul: #f15bb5;
  --div: #00b4e6;
  --ones: #22c55e;
  --tens: #3b82f6;
  --hund: #ef4444;
  --gold: #ffd23f;
  --good: #16a34a;
  --bad: #e11d48;
  --op: var(--add);
  --radius: 20px;
  --top-h: 56px;
  --font: "Baloo 2", "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(120% 80% at 50% 0%, #2a2f8f 0%, var(--bg) 60%) fixed, var(--bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

.op-add { --op: var(--add); }
.op-sub { --op: var(--sub); }
.op-mul { --op: var(--mul); }
.op-div { --op: var(--div); }

/* ---------- top bar ---------- */
#topbar {
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0;
  display: flex; align-items: center; gap: 8px;
  background: rgba(11, 16, 51, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0; z-index: 20;
}
#title { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; border: 0;
  background: rgba(255,255,255,.12); color: #fff; font-size: 1.1rem;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.off { opacity: .45; }
#backBtn.hidden { visibility: hidden; width: 0; padding: 0; margin-right: -8px; }
.star-pill {
  display: flex; align-items: center; gap: 4px; text-decoration: none;
  background: linear-gradient(180deg, #ffe066, #ffb703); color: #4a2b00;
  font-weight: 800; padding: 4px 12px 4px 8px; border-radius: 999px; font-size: 1.05rem;
  box-shadow: 0 3px 0 #c47f00;
}
.star-pill.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.3) rotate(-6deg); } 60% { transform: scale(.95); } }

#view { flex: 1; min-height: 0; position: relative; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#view.no-scroll { overflow: hidden; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
#toast {
  /* top of the screen, and never blocks taps on the buttons underneath */
  position: fixed; left: 50%; top: calc(var(--top-h) + env(safe-area-inset-top) + 10px); transform: translate(-50%, calc(-100% - 80px));
  background: #fff; color: var(--ink); padding: 10px 18px; border-radius: 16px; font-weight: 700; pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); transition: transform .35s cubic-bezier(.2,1.4,.4,1); z-index: 60;
  max-width: calc(100% - 32px); text-align: center; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- generic ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); }
.btn {
  border: 0; border-radius: 16px; padding: 10px 16px; font-size: 1.05rem; font-weight: 800;
  background: #fff; color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.18);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px;
  text-decoration: none; transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--op); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--op) 60%, #000); }
.btn.ghost { background: rgba(31,35,64,.07); box-shadow: none; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .95rem; border-radius: 12px; }
.btn.big { font-size: 1.3rem; min-height: 58px; padding: 10px 22px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.grow { flex: 1; }
.panel { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.muted { color: var(--muted); }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }
.pop-in { animation: popin .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popin { from { transform: scale(.3); opacity: 0; } }
.pulse { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); box-shadow: 0 0 0 8px color-mix(in srgb, var(--op) 25%, transparent); } }
.d-o { color: var(--ones); } .d-t { color: var(--tens); } .d-h { color: var(--hund); }
.num { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- hub ---------- */
.hub-stage { position: relative; height: min(58vh, 520px); min-height: 300px; }
.hub-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.hub-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(255,255,255,.14); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .95rem; white-space: nowrap;
  animation: floaty 2.4s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translate(-50%, -6px); } }
.hub-hello { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.mascot { font-size: 2.6rem; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); animation: wobble 3s ease-in-out infinite; flex-shrink: 0; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.bubble { background: #fff; color: var(--ink); border-radius: 18px; padding: 10px 14px; font-weight: 600; position: relative; line-height: 1.3; }
.bubble::before { content: ""; position: absolute; left: -8px; top: 18px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
.planet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.planet-btn {
  border-radius: 20px; padding: 12px; text-decoration: none; color: #fff; display: flex; flex-direction: column; gap: 2px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--op) 92%, #fff), color-mix(in srgb, var(--op) 70%, #000));
  box-shadow: 0 5px 0 color-mix(in srgb, var(--op) 50%, #000);
}
.planet-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--op) 50%, #000); }
.planet-btn .sym { font-size: 2rem; line-height: 1; font-weight: 800; }
.planet-btn .nm { font-weight: 800; font-size: 1.1rem; }
.planet-btn .meta { font-size: .85rem; opacity: .9; }
.meter { height: 8px; background: rgba(0,0,0,.25); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.section-title { font-size: 1.15rem; font-weight: 800; margin: 18px 2px 8px; }
.card-list { display: grid; gap: 10px; }
.act-card {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 12px 14px; box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.act-card:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.act-card .ico {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 1.8rem; flex-shrink: 0;
  background: color-mix(in srgb, var(--op) 22%, #fff);
}
.act-card h3 { margin: 0; font-size: 1.12rem; line-height: 1.15; }
.act-card p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.2; }
.act-card .go { margin-left: auto; font-size: 1.3rem; color: var(--op); font-weight: 800; }
.tag { display: inline-block; font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 99px; background: var(--op); color: #fff; vertical-align: middle; margin-left: 4px; }

/* ---------- world ---------- */
.world-hero {
  border-radius: 24px; padding: 16px; margin-bottom: 12px; position: relative; overflow: hidden;
  background: radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--op) 85%, #fff) 0%, var(--op) 40%, color-mix(in srgb, var(--op) 55%, #000) 100%);
}
.world-hero .big-sym { position: absolute; right: -6px; top: -26px; font-size: 9rem; font-weight: 800; opacity: .18; line-height: 1; }
.world-hero h2 { margin: 0; font-size: 1.6rem; }
.world-hero p { margin: 4px 0 0; font-weight: 600; max-width: 85%; line-height: 1.3; }
.levels { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.level-btn { border: 0; border-radius: 12px; padding: 6px 12px; font-weight: 800; background: rgba(255,255,255,.25); color: #fff; font-size: .95rem; }
.level-btn.on { background: #fff; color: var(--ink); }
.connect {
  display: flex; gap: 10px; align-items: center; text-decoration: none; margin-top: 12px;
  background: rgba(255,255,255,.08); border: 2px dashed rgba(255,255,255,.3); border-radius: 18px; padding: 10px 12px; color: #fff;
}
.connect b { color: var(--gold); }

/* ---------- activity layout (stage + panel) ---------- */
.activity { display: flex; flex-direction: column; height: 100%; }
.stage { position: relative; flex: 1 1 auto; min-height: 220px; background: #bfe3ff; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage .stage-tip { position: absolute; left: 8px; top: 8px; background: rgba(255,255,255,.85); color: var(--ink); font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; pointer-events: none; }
.stage .stage-btns { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.stage .stage-btns .icon-btn { background: rgba(255,255,255,.9); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.dock {
  flex: 0 0 auto; background: var(--card); color: var(--ink); border-radius: 22px 22px 0 0; margin-top: -18px; position: relative; z-index: 2;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(0,0,0,.2);
  max-height: 56%; overflow-y: auto;
}
.dock .grab { width: 44px; height: 5px; background: #d9ccb4; border-radius: 9px; margin: 0 auto 8px; }
.op-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.op-tab { flex: 1; border: 0; border-radius: 12px; padding: 4px 0; font-size: 1.35rem; font-weight: 800; background: rgba(31,35,64,.07); color: var(--muted); min-height: 40px; }
.op-tab.on { background: var(--op); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--op) 60%, #000); }
.eq { font-size: 2rem; font-weight: 800; text-align: center; line-height: 1.1; letter-spacing: 1px; }
.eq .op-sym { color: var(--op); margin: 0 6px; }
.eq .q { color: var(--op); }
.say { font-size: 1.08rem; font-weight: 600; line-height: 1.3; min-height: 2.6em; margin: 6px 0; text-align: center; }
.say b { color: var(--op); }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 4px 0 6px; }
.chip { background: #fff; border-radius: 12px; padding: 2px 10px; font-weight: 800; border: 2px solid var(--line); font-size: 1rem; }
.chip.h { border-color: var(--hund); color: var(--hund); }
.chip.t { border-color: var(--tens); color: var(--tens); }
.chip.o { border-color: var(--ones); color: var(--ones); }
.chip.warn { animation: pulse 1s infinite; background: #fff1f2; }
.controls { display: flex; gap: 8px; margin-top: 6px; }
.controls .next { flex: 1; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.choices .btn { font-size: 1.5rem; min-height: 56px; border: 3px solid var(--line); }
.choices .btn.right { background: var(--good); color: #fff; border-color: var(--good); }
.choices .btn.right:disabled { opacity: 1; }
.choices .btn.wrong { background: #ffe4e6; color: var(--bad); border-color: #fda4af; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.links .btn { flex: 1 1 45%; font-size: .95rem; min-height: 44px; padding: 6px 10px; background: color-mix(in srgb, var(--op) 14%, #fff); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(5,8,30,.6); display: grid; place-items: end center; z-index: 40; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); color: var(--ink); width: min(520px, 100%); border-radius: 26px 26px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .3s cubic-bezier(.2,1.2,.4,1); }
@keyframes up { from { transform: translateY(100%); } }
.modal h3 { margin: 0 0 8px; text-align: center; font-size: 1.3rem; }
.stepper { display: flex; align-items: center; gap: 6px; justify-content: center; margin: 10px 0; }
.stepper .val { font-size: 2.4rem; font-weight: 800; min-width: 86px; text-align: center; }
.stepper .btn { min-width: 48px; padding: 6px 8px; }
.stepper label { font-weight: 800; color: var(--muted); width: 100%; text-align: center; }

/* ---------- keypad ---------- */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.keypad .btn { font-size: 1.5rem; min-height: 50px; padding: 0; border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.keypad .btn.ok { background: var(--good); color: #fff; border-color: var(--good); box-shadow: 0 3px 0 #0d6b32; grid-row: span 2; }
.keypad .btn.del { background: #fff1f2; }

/* ---------- column magic ---------- */
.col-wrap { padding: 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.col-board { background: #fffdf7; color: var(--ink); border-radius: 22px; padding: 12px 18px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); position: relative;
  background-image: linear-gradient(#e8f1ff 1px, transparent 1px), linear-gradient(90deg, #e8f1ff 1px, transparent 1px); background-size: 22px 22px; }
.col-grid { display: grid; gap: 2px 4px; justify-content: center; }
.col-cell { width: 54px; height: 58px; display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; position: relative; border-radius: 12px; line-height: 1; }
.col-cell.hdr { height: 30px; font-size: 1rem; border-radius: 8px; color: #fff; }
.col-cell.hdr.o { background: var(--ones); } .col-cell.hdr.t { background: var(--tens); } .col-cell.hdr.h { background: var(--hund); }
.col-cell.carry { height: 30px; font-size: 1.3rem; color: var(--bad); }
.col-cell.sign { color: var(--op); }
.col-cell.line { height: 6px; background: var(--ink); border-radius: 3px; }
.col-cell.ans { background: color-mix(in srgb, var(--op) 10%, #fff); border: 2px dashed color-mix(in srgb, var(--op) 45%, #fff); }
.col-cell.focus { background: #fff6c2; box-shadow: 0 0 0 3px var(--gold); }
.col-cell.tap { animation: pulse 1s infinite; background: #fff6c2; cursor: pointer; }
.col-cell .struck { position: relative; color: #9aa; }
.col-cell .struck::after { content: ""; position: absolute; left: -6px; right: -6px; top: 50%; height: 4px; background: var(--bad); transform: rotate(-20deg); border-radius: 3px; }
.col-cell sup { font-size: 1.2rem; color: var(--bad); margin-right: 1px; align-self: start; margin-top: 6px; }
.col-cell .new { position: absolute; top: -18px; right: -2px; font-size: 1.3rem; color: var(--bad); }
.col-cell.done { color: var(--op); }
.prompt-bar { background: var(--card); color: var(--ink); border-radius: 18px; padding: 10px 14px; width: 100%; max-width: 520px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.prompt-bar .q { font-size: 1.2rem; font-weight: 700; text-align: center; line-height: 1.25; }
.prompt-bar .inbox { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 6px; font-size: 1.8rem; font-weight: 800; }
.prompt-bar .slot { min-width: 84px; height: 54px; border-radius: 14px; border: 3px solid var(--op); display: grid; place-items: center; background: #fff; }
.prompt-bar .slot.empty::after { content: "?"; color: #c8bfae; }
.hint-box { margin-top: 8px; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.tenframe { display: grid; grid-template-columns: repeat(5, 16px); gap: 3px; padding: 4px; border: 2px solid #c9bda6; border-radius: 6px; background: #fff; }
.tenframe i { width: 16px; height: 16px; border-radius: 50%; background: #eee5d3; }
.tenframe i.a { background: var(--tens); } .tenframe i.b { background: var(--add); } .tenframe i.x { background: #fda4af; position: relative; }
.tenframe i.x::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--bad); font-weight: 900; }
.dot-array { display: grid; gap: 3px; }
.dot-array i { width: 12px; height: 12px; border-radius: 50%; background: var(--mul); }
.skip-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.skip-row span { background: color-mix(in srgb, var(--div) 18%, #fff); border-radius: 10px; padding: 0 8px; font-weight: 800; }
.flyer { position: fixed; z-index: 45; font-weight: 800; pointer-events: none; color: var(--bad); }

/* bus stop */
.bus { display: grid; gap: 0 2px; justify-content: center; }
.bus .col-cell.div-l { border-right: 5px solid var(--ink); border-radius: 0; }
.bus .col-cell.div-top { border-top: 5px solid var(--ink); border-radius: 0; }
.bus .rem { font-size: 1.6rem; color: var(--div); }

/* ---------- family ---------- */
.house { width: 100%; max-width: 420px; margin: 0 auto; display: block; }
.fam-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.fam-eq .w { background: #1d2470; color: #fff; border-radius: 14px; padding: 8px 4px; text-align: center; font-size: 1.2rem; white-space: nowrap; font-weight: 800; border: 3px solid #3a43a8; transition: background .3s; }
.fam-eq .w.lit { background: #fff6c2; color: var(--ink); border-color: var(--gold); box-shadow: 0 0 18px rgba(255,210,63,.7); }
.fam-eq .blank { display: inline-block; min-width: 38px; border-radius: 10px; background: rgba(255,255,255,.2); border: 2px dashed #9aa3ff; padding: 0 6px; cursor: pointer; }
.fam-eq .blank.sel { border-color: var(--gold); background: rgba(255,210,63,.35); animation: pulse 1s infinite; }
.fam-chips { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.fam-chips .btn { font-size: 1.5rem; min-width: 76px; }
.bar-model { margin-top: 12px; }
.bar-model .bar { height: 40px; border-radius: 10px; display: flex; overflow: hidden; font-weight: 800; color: #fff; }
.bar-model .bar > div { display: grid; place-items: center; border-right: 3px solid #fff8ec; transition: flex-grow .6s; min-width: 0; font-size: 1.05rem; }
.bar-model .bar > div:last-child { border-right: 0; }
.bar-model .lbl { font-size: .85rem; font-weight: 800; color: var(--muted); margin: 4px 2px; }

/* ---------- stickers ---------- */
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sticker { aspect-ratio: 1; border-radius: 20px; background: var(--card); display: grid; place-items: center; font-size: 2.3rem; position: relative; box-shadow: 0 4px 0 rgba(0,0,0,.25); border: 0; }
.sticker.locked { background: rgba(255,255,255,.08); box-shadow: none; filter: grayscale(1); }
.sticker.locked > span { opacity: .18; }
.sticker .need { position: absolute; bottom: 4px; font-size: .75rem; font-weight: 800; color: #fff; }
.sticker.spin { animation: spin .8s; }
@keyframes spin { to { transform: rotate(360deg) scale(1.1); } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.stat { border-radius: 16px; padding: 8px; text-align: center; background: var(--op); font-weight: 800; }
.stat b { display: block; font-size: 1.6rem; }

/* ---------- game overlay ---------- */
.game-hud { position: absolute; left: 0; right: 0; top: 0; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.game-q { background: rgba(255,255,255,.95); color: var(--ink); border-radius: 18px; padding: 4px 20px; font-size: 2rem; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.game-stats { display: flex; gap: 10px; font-weight: 800; font-size: 1.1rem; }
.game-stats span { background: rgba(0,0,0,.35); border-radius: 12px; padding: 2px 10px; }
.overlay-card { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(5,8,30,.55); }
.overlay-card .panel { width: min(440px, 100%); text-align: center; }
.overlay-card h2 { margin: 0 0 4px; font-size: 1.8rem; }
.miss-list { text-align: left; display: grid; gap: 6px; margin: 10px 0; max-height: 34vh; overflow: auto; }
.miss-list a { display: flex; justify-content: space-between; align-items: center; text-decoration: none; background: #fff; border-radius: 12px; padding: 6px 10px; font-weight: 700; border: 2px solid var(--line); }

/* larger screens */
@media (min-width: 820px) {
  .activity { flex-direction: row; }
  .dock { width: 380px; max-height: none; margin-top: 0; border-radius: 0; flex: 0 0 380px; }
  .dock .grab { display: none; }
  .planet-grid { grid-template-columns: repeat(4, 1fr); }
  .hub-stage { height: 52vh; }
}
@media (max-height: 640px) and (max-width: 819px) {
  .eq { font-size: 1.6rem; }
  .say { font-size: 1rem; min-height: 2.4em; }
  .col-cell { width: 46px; height: 50px; font-size: 2.2rem; }
}

/* ---------- story quest ---------- */
.story-count { text-align: center; font-weight: 800; color: var(--gold); min-height: 1.2em; margin-bottom: 6px; }
.story-card { position: relative; }
.story-emoji { font-size: 2.6rem; line-height: 1; }
.story-card .listen { background: color-mix(in srgb, var(--op) 18%, #fff); color: var(--ink); }
.story-text { font-size: 1.3rem; font-weight: 600; line-height: 1.45; margin: 8px 0 10px; }
.story-text .num { color: var(--op); font-size: 1.45rem; }
.story-card .kw { border-radius: 8px; transition: background .4s, box-shadow .4s; }
.story-card.clues-on .kw, .say .kw { background: #fff2a8; box-shadow: 0 0 0 2px var(--gold); font-weight: 800; }
.story-pic { display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; background: color-mix(in srgb, var(--op) 8%, #fff); border-radius: 16px; padding: 10px; }
.pv-pic { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end; max-width: 100%; position: relative; padding-bottom: 20px; }
.pv-pic .pack { display: grid; grid-template-columns: repeat(2, 1fr); border: 2px solid var(--tens); border-radius: 6px; padding: 1px; background: #eff6ff; font-size: 9px; line-height: 1.15; }
.pv-pic .ones { display: grid; grid-template-columns: repeat(5, auto); gap: 1px; font-size: 15px; line-height: 1.1; padding: 2px; border: 2px solid var(--ones); border-radius: 6px; background: #f0fdf4; }
.pv-pic .pv-num { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-weight: 800; color: var(--muted); }
.pv-pic.gone { opacity: .55; filter: grayscale(.6); }
.pic-op { font-size: 2rem; font-weight: 800; color: var(--op); line-height: 1; }
.pv-pic { justify-content: center; }
.groups { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.group { background: #fff; border: 2px solid color-mix(in srgb, var(--op) 45%, #fff); border-radius: 12px; padding: 2px 8px; display: flex; align-items: center; gap: 4px; font-size: 1.2rem; }
.group b { color: var(--op); }
.story-step { margin-top: 12px; }
.step-title { font-weight: 800; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .6px; text-align: center; }
.op-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.op-pick .btn { flex-direction: column; gap: 0; min-height: 76px; background: var(--op); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--op) 55%, #000); font-size: 1rem; }
.op-pick .btn .sym { font-size: 2rem; line-height: 1; }

/* Docks under drag/tap canvases keep a steady height so the play area
   doesn't shrink under the child's finger when the text changes. */
.dock.steady .say { min-height: 4em; }
.dock.steady .chips { flex-wrap: nowrap; overflow: hidden; height: 2.1em; }
.dock.steady .chip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.dock.steady .choices:empty, .dock.steady .links:empty { display: none; }

/* typed answers */
.typed-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 8px 0 2px; flex-wrap: wrap; font-weight: 800; }
.typed-row .slot { min-width: 84px; height: 54px; border-radius: 14px; border: 3px solid #d9ccb4; display: grid; place-items: center; background: #fff; font-size: 1.8rem; font-weight: 800; font-family: inherit; color: var(--ink); }
.typed-row .slot.cur { border-color: var(--op); box-shadow: 0 0 0 4px color-mix(in srgb, var(--op) 25%, transparent); }
.typed-row .slot.empty::after { content: "?"; color: #c8bfae; }
.typed-row.right .slot { background: var(--good); border-color: var(--good); color: #fff; }
.typed-lbl { color: var(--muted); }
.mode-toggle { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.mode-toggle button { border: 0; border-radius: 999px; padding: 4px 12px; font-weight: 800; background: rgba(31,35,64,.07); color: var(--muted); font-family: inherit; }
.mode-toggle button.on { background: var(--op); color: #fff; }
.part-done { text-align: center; font-weight: 800; color: var(--good); margin: 4px 0; }

/* ---------- daily challenge ---------- */
.daily-hero .streak-big { font-size: 3.2rem; font-weight: 800; text-align: center; line-height: 1.1; color: var(--op); }
.daily-dots { display: flex; justify-content: center; gap: 6px; margin: 2px 0 10px; }
.daily-dots i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.2); }
.daily-dots i.cur { background: var(--gold); transform: scale(1.3); }
.daily-dots i.ok { background: var(--good); }
.daily-dots i.bad { background: var(--bad); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 12px; text-align: center; }
.cal b { font-size: .8rem; color: var(--muted); }
.cal span { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: .9rem; background: rgba(31,35,64,.06); color: var(--muted); }
.cal span.done { background: #fff2a8; color: var(--ink); font-size: 1.1rem; }
.cal span.today { box-shadow: 0 0 0 3px var(--op); }
.cal span.future { background: transparent; }

/* ---------- grown-ups ---------- */
.grownup-link { display: block; text-align: center; margin: 18px 0 4px; color: #c7cbe8; font-weight: 700; font-size: .95rem; }
.gu-sec { margin-bottom: 12px; }
.gu-sec h3 { margin: 0 0 8px; font-size: 1.15rem; }
.gu-op { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.gu-op:first-of-type { border-top: 0; }
.gu-sym { width: 40px; height: 40px; border-radius: 12px; background: var(--op); color: #fff; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; flex-shrink: 0; }
.gu-levels { display: flex; gap: 4px; }
.gu-levels button { border: 0; border-radius: 10px; padding: 4px 8px; font-weight: 800; font-family: inherit; background: rgba(31,35,64,.07); color: var(--muted); }
.gu-levels button.on { background: var(--op); color: #fff; }
.gu-skills { display: grid; gap: 6px; }
.gu-skill { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: #fff; border: 2px solid var(--line); }
.gu-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; background: #cbd5e1; }
.gu-skill.good .gu-dot { background: var(--good); }
.gu-skill.ok .gu-dot { background: #f59e0b; }
.gu-skill.hard .gu-dot { background: var(--bad); }
.gu-skill.hard { border-color: #fda4af; }
.gu-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gu-stat { background: #fff; border-radius: 12px; padding: 6px; text-align: center; border: 2px solid var(--line); }
.gu-stat b { display: block; font-size: 1.1rem; }
.gu-stat span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.gu-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-weight: 700; }
.grownups .slot { min-width: 110px; height: 54px; border-radius: 14px; border: 3px solid var(--op); display: grid; place-items: center; background: #fff; font-size: 1.8rem; font-weight: 800; }
.grownups .slot.empty::after { content: "?"; color: #c8bfae; }

/* ---------- players ---------- */
.player-chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: rgba(255,255,255,.1); border-radius: 999px; padding: 4px 14px 4px 4px; margin-bottom: 10px; color: #fff; }
.player-chip .pf-ava { width: 36px; height: 36px; font-size: 1.5rem; background: #fff; }
.player-chip span:last-child { color: #c7cbe8; font-size: .9rem; font-weight: 700; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pf-cell { position: relative; }
.pf-card { width: 100%; border: 0; border-radius: 22px; background: var(--card); color: var(--ink); padding: 16px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: inherit; font-size: 1.05rem; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.pf-card.me { box-shadow: 0 0 0 4px var(--gold), 0 5px 0 rgba(0,0,0,.25); }
.pf-card:active { transform: translateY(3px); }
.pf-ava { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 2.8rem; background: #fff2d6; }
.pf-ava.big { width: 96px; height: 96px; font-size: 3.6rem; margin: 0 auto 10px; }
.pf-stars { color: var(--muted); font-weight: 800; font-size: .9rem; }
.pf-add { background: rgba(255,255,255,.1); color: #fff; box-shadow: none; border: 3px dashed rgba(255,255,255,.35); }
.pf-add .pf-ava { background: rgba(255,255,255,.12); }
.pf-edit { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border-radius: 12px; border: 0; background: rgba(31,35,64,.08); font-size: 1rem; }
.pf-name { width: 100%; font-family: inherit; font-size: 1.4rem; font-weight: 800; text-align: center; padding: 10px; border-radius: 14px; border: 3px solid var(--line); background: #fff; color: var(--ink); }
.pf-name:focus { outline: none; border-color: var(--op); }
.pf-avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 10px; }
.pf-avatars button { aspect-ratio: 1; border: 0; border-radius: 12px; background: rgba(31,35,64,.06); font-size: 1.5rem; padding: 0; }
.pf-avatars button.on { background: #fff2a8; box-shadow: 0 0 0 3px var(--gold); }
.gu-who { display: flex; align-items: center; gap: 10px; background: var(--card); color: var(--ink); border-radius: 18px; padding: 8px 12px; margin-bottom: 10px; }
.gu-ava { font-size: 2rem; }

/* ---------- duel ---------- */
.chipbtn { border: 0; border-radius: 999px; padding: 6px 12px; font-family: inherit; font-weight: 800; font-size: 1rem; background: rgba(31,35,64,.07); color: var(--ink); }
.chipbtn.on { background: var(--op); color: #fff; }
.duel-pick { margin-bottom: 8px; }
.duel-root.arena { height: 100%; display: flex; flex-direction: column; padding: 6px; gap: 0; }
.duel-half { flex: 1; min-height: 0; border-radius: 22px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: #1d2470; transition: background .25s; position: relative; }
.duel-half.p1 { transform: rotate(180deg); background: #3b1d70; }
.duel-half.won { background: #14532d; }
.duel-half.lost { background: #4a1d2f; }
.duel-half.locked .duel-grid { opacity: .4; }
.duel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.duel-round { color: #c7cbe8; font-size: .85rem; }
.duel-score { background: var(--gold); color: #4a2b00; border-radius: 12px; padding: 0 12px; font-size: 1.3rem; }
.duel-q { text-align: center; font-size: clamp(1.8rem, 7vh, 3rem); font-weight: 800; line-height: 1.1; }
.duel-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 0; }
.duel-grid .btn { font-size: clamp(1.3rem, 4.5vh, 2rem); min-height: 0; height: 100%; touch-action: manipulation; }
.duel-grid .btn.right { background: var(--good); color: #fff; }
.duel-grid .btn.wrong { background: #ffe4e6; color: var(--bad); }
.duel-msg { text-align: center; font-weight: 800; min-height: 1.3em; }
.duel-mid { text-align: center; font-size: 1.2rem; line-height: 1.4; }
.duel-again { display: flex; gap: 8px; justify-content: center; }
.col-cell.hdr.th { background: #a855f7; }
.d-th { color: #a855f7; }
.pv-pic .crate { display: grid; place-items: center; width: 46px; height: 46px; border: 3px solid var(--hund); border-radius: 8px; background: #fef2f2; font-size: 15px; line-height: 1; }
.pv-pic .crate b { color: var(--hund); font-size: .8rem; }

/* ---------- coming soon ---------- */
.act-card.soon { opacity: .6; filter: grayscale(.7); box-shadow: none; cursor: not-allowed; }
.act-card.soon:active { transform: none; }
.tag.soon { background: #64748b; }
.soon-page { text-align: center; padding-top: 48px; }
.soon-ico { font-size: 4rem; animation: wobble 3s ease-in-out infinite; }
.soon-page p { color: #c7cbe8; font-weight: 600; margin-bottom: 20px; }
.gu-select { font-family: inherit; font-size: .95rem; font-weight: 700; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--line); background: #fff; color: var(--ink); max-width: 60%; }
.gu-tip { font-size: .85rem; background: #fff6c2; border-radius: 10px; padding: 6px 10px; margin: 8px 0 0; }
