:root {
  --bg: #f6f7fb;
  --ink: #1f2340;
  --brand: #4f46e5;
  --soft: #e7e9f7;
  --card: #ffffff;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --warm: #f59e0b;
  --warm-bg: #fef3c7;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", Nunito, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* header */
header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
header h1 { flex: 1; margin: 0; text-align: center; font-size: clamp(1.1rem, 5vw, 1.5rem); white-space: nowrap; }
#back, #spacer { min-width: 88px; }
#back {
  min-height: 48px; border: 0; border-radius: 12px; padding: 0 14px;
  background: rgba(255,255,255,.2); color: #fff; font-size: 1.1rem; font-weight: 700;
}
#back[hidden] { display: block; visibility: hidden; }

main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 16px; }
.note { text-align: center; font-size: 1.15rem; padding: 32px 12px; }
.small { font-size: .95rem; opacity: .75; }

/* menu */
.listname { text-align: center; font-size: 1.15rem; margin: 4px 0 14px; opacity: .8; }
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.mcard {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 12px; min-height: 130px;
  background: var(--card); border: 2px solid var(--soft); border-radius: var(--radius);
  box-shadow: 0 2px 0 var(--soft);
}
.mcard:active { transform: translateY(2px); box-shadow: none; }
.mcard .icon { font-size: 2.4rem; }
.mcard .name { font-size: 1.25rem; font-weight: 800; text-align: center; }
.mcard .blurb { font-size: 1rem; opacity: .7; text-align: center; }
/* deep link (#robot): one big card; the tap mounts the game so iOS allows speech */
.start-gate { display: flex; justify-content: center; padding-top: 40px; }
.start-gate .mcard { width: min(420px, 100%); gap: 10px; padding: 28px 16px; }
.start-gate .mcard .icon { font-size: 4rem; }
.start-gate .btn { display: inline-flex; align-items: center; margin-top: 8px; }

/* shared game bits */
.game { display: flex; flex-direction: column; align-items: center; gap: 14px; position: relative; }
.prompt { margin: 0; font-size: 1.25rem; font-weight: 700; text-align: center; }
.label { margin: 4px 0 0; font-size: 1rem; opacity: .7; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hear { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  min-height: 52px; padding: 0 20px; border-radius: 14px;
  border: 2px solid var(--soft); background: var(--card); font-size: 1.1rem; font-weight: 700;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.speaker { background: #eef2ff; border-color: #c7d2fe; }
.btn.big { min-height: 60px; padding: 0 28px; font-size: 1.25rem; }
.btn:active { transform: translateY(1px); }
.btn[hidden], .reveal[hidden] { display: none; }
.msg { min-height: 1.6em; font-size: 1.3rem; font-weight: 800; color: var(--brand); text-align: center; }
.finish { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 30px; }
.big-emoji { font-size: 4rem; }

/* tiles (jumble + fill) */
.slots, .tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile {
  width: 56px; height: 64px; display: grid; place-items: center;
  font-size: 2rem; font-weight: 800; border-radius: 12px;
  background: #eef2ff; border: 2px solid #c7d2fe; padding: 0;
}
.tray .tile { background: #fff7ed; border-color: #fed7aa; }
.tile.slot { background: #fff; border: 2px dashed #a5b4fc; }
.tile.slot.filled { border-style: solid; background: #eef2ff; }
.tile.slot.sel { border-color: var(--brand); box-shadow: 0 0 0 3px #c7d2fe; }
.tile.slot.hint { background: var(--warm-bg); border-color: var(--warm); }
.tile.fixed { background: transparent; border-color: transparent; }
.good .tile { background: var(--good-bg); border-color: var(--good); color: #14532d; }

/* typing */
.typed {
  min-width: 260px; min-height: 76px; padding: 6px 22px; text-align: center;
  font-size: 2.6rem; font-weight: 800; letter-spacing: .08em; word-break: break-all;
  background: #fff; border: 3px solid #c7d2fe; border-radius: var(--radius);
}
.typed.good { background: var(--good-bg); border-color: var(--good); }
.reveal, .bigword { font-size: 2.8rem; font-weight: 800; letter-spacing: .06em; color: var(--brand); text-align: center; }
.reveal { padding: 6px 18px; background: var(--warm-bg); border-radius: 12px; color: #92400e; }
.compare { display: flex; gap: 4px; justify-content: center; font-size: 2.4rem; font-weight: 800; min-height: 1.2em; }
.compare .ok { color: var(--good); }
.compare .off { color: var(--warm); text-decoration: underline wavy; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }

/* on-screen keyboard */
.kb { position: relative; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 760px; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1 1 0; max-width: 68px; min-height: 56px; padding: 0;
  font-size: 1.6rem; font-weight: 700; background: var(--card);
  border: 2px solid var(--soft); border-radius: 10px; box-shadow: 0 2px 0 var(--soft);
}
.key.wide { flex: 1.6 1 0; max-width: 110px; }
/* letter pop-up while a finger is on a key (util.js keyboard) */
.kb-preview { position: absolute; z-index: 4; height: 64px; display: grid; place-items: center; pointer-events: none;
  font-size: 2.4rem; font-weight: 800; color: var(--ink); background: #fff; border: 2px solid #c7d2fe; border-radius: 14px;
  box-shadow: 0 6px 16px rgba(20, 22, 50, .2); }
.kb-preview[hidden] { display: none; }
/* ABC | QWERTY switch (only when a grown-up allows it) */
.kb-switch { display: flex; justify-content: center; gap: 6px; }
.kb-pick { min-height: 44px; min-width: 96px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--soft); background: var(--card);
  font-size: .95rem; font-weight: 800; letter-spacing: .04em; color: #475569; }
.kb-pick[aria-pressed="true"] { background: #334155; border-color: #334155; color: #fff; }
/* ABC layout: a-z in a grid, 9 across (7 on a phone, where the keys come out about 46 px wide) */
.kb-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 760px; margin: 0 auto; }
.kb-grid .key { max-width: none; }
/* vowels: a very light rose, a colour no typing game uses for feedback (Wordal: green/amber/grey; selection: indigo) */
.kb-grid .key.vow:not([data-s]) { background: #fff4f8; border-color: #f5d0de; }
.key:active { background: #eef2ff; transform: translateY(2px); box-shadow: none; }

/* memory match */
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; width: 100%; max-width: 720px; }
.card {
  aspect-ratio: 3 / 4; min-height: 110px; padding: 6px;
  border: 3px solid #c7d2fe; border-radius: var(--radius); background: #eef2ff;
  display: grid; place-items: center;
}
.card .back { display: none; font-size: 1.5rem; font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.card.long .back { font-size: 1.2rem; }
.card .front { font-size: 2.2rem; }
.card.open { background: #fff; border-color: var(--brand); animation: flip .35s ease; }
.card.open .front { display: none; }
.card.open .back { display: block; }
.card.matched { background: var(--good-bg); border-color: var(--good); }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

/* word search */
.ws { display: flex; gap: 18px; align-items: flex-start; justify-content: center; flex-wrap: wrap; width: 100%; }
.ws-grid {
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px;
  width: min(92vw, 62vh, 560px); touch-action: none; background: var(--soft); padding: 4px; border-radius: 12px;
}
.cell {
  aspect-ratio: 1; display: grid; place-items: center; background: #fff; border-radius: 6px;
  font-weight: 800; font-size: clamp(.8rem, 3.6vw, 1.5rem);
}
.cell.sel { background: #c7d2fe; }
.cell.miss:not(.found) { animation: ws-miss .6s ease-out; } /* fades out the letters a missed drag checked */
@keyframes ws-miss { from { background: #c7d2fe; } to { background: #fff; } }
.cell.found { color: #14532d; }
.cell.found[data-f="0"] { background: #bbf7d0; }
.cell.found[data-f="1"] { background: #fde68a; }
.cell.found[data-f="2"] { background: #fbcfe8; }
.cell.found[data-f="3"] { background: #bae6fd; }
.cell.found[data-f="4"] { background: #ddd6fe; }
.cell.found[data-f="5"] { background: #fed7aa; }
.ws-list { display: flex; flex-wrap: wrap; gap: 8px; max-width: 320px; }
.chip { min-height: 44px; padding: 0 14px; font-size: 1.15rem; font-weight: 700; background: #fff; border: 2px solid var(--soft); border-radius: 999px; }
.chip.found { background: var(--good-bg); border-color: var(--good); text-decoration: line-through; }

/* baffle */
.bf { display: flex; gap: 20px; align-items: flex-start; justify-content: center; flex-wrap: wrap; width: 100%; }
.bf-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 8px;
  width: min(92vw, 58vh, 460px); touch-action: none; background: var(--soft); border-radius: var(--radius);
}
.bf-tile {
  aspect-ratio: 1; display: grid; place-items: center; background: #fff; border-radius: 14px;
  box-shadow: 0 3px 0 #c9cde8; font-weight: 800; font-size: clamp(1.4rem, 7vw, 2.6rem); transition: background .12s;
}
.bf-tile.next { background: #fef9c3; box-shadow: 0 3px 0 #c9cde8, inset 0 0 0 3px #facc15; }
.bf-tile.blink { background: #fde68a; box-shadow: 0 3px 0 #c9cde8, inset 0 0 0 4px #f59e0b; animation: bf-blink .6s ease-in-out 4; }
@keyframes bf-blink { 50% { background: #fff; box-shadow: 0 3px 0 #c9cde8; transform: scale(1.08); } }
.bf-tile.sel { background: #c7d2fe; }
.bf-tile.last { background: #a5b4fc; }
.bf-tile.good { background: var(--good-bg); }
.bf-tile.bonus { background: var(--warm-bg); }
.bf-side { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(92vw, 380px); }
.bf-current { min-height: 1.2em; font-size: 2rem; font-weight: 800; letter-spacing: .08em; color: var(--brand); }
.bf-list, .bf-list .chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bf-list:has(.bf-slots) { gap: 10px 26px; }
.bf-now { align-items: center; min-height: 52px; }
.bf-list h3 { width: 100%; margin: 6px 0 0; text-align: center; font-size: 1.1rem; }
.bf-slots { display: flex; gap: 3px; padding: 2px; border: 0; background: none; }
.bf-slots span { width: 28px; height: 32px; display: grid; place-items: center; border-radius: 6px; background: #fff; border: 2px solid var(--soft); font-weight: 800; font-size: 1.1rem; }
.bf-slots.done span { background: var(--good-bg); border-color: var(--good); }
.bf-slots.now span { border-color: #f59e0b; background: #fef9c3; }
.bf-current.word { color: var(--good); }
.finish .chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; }
.chip.got { background: var(--good-bg); border-color: var(--good); }
.chip.bonus { background: var(--warm-bg); border-color: var(--warm); }
.chips[hidden] { display: none; }
.bf-break { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246,247,251,.85); z-index: 5; }
.bf-break-card { background: #fff; border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: 0 6px 24px rgba(20,22,50,.15); max-width: 92vw; }
.bf-break-card h2 { margin: 8px 0 16px; }

/* study list */
.study { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; width: 100%; }
.study-word {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px;
  background: #fff; border: 2px solid var(--soft); border-radius: 14px; text-align: left;
}
.study-word .w { font-size: 1.5rem; font-weight: 800; }
.study-word .s { flex: 1; font-size: .95rem; opacity: .65; }
.study-word .w + span[aria-hidden] { margin-left: auto; }

/* parent panel */
.overlay { position: fixed; inset: 0; background: rgba(20,22,50,.55); display: grid; place-items: center; padding: 16px; z-index: 10; -webkit-user-select: text; user-select: text; }
.panel { background: #fff; border-radius: var(--radius); padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.panel h2 { margin-top: 0; }
.panel h3 { margin: 18px 0 6px; }
.panel table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.panel th, .panel td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--soft); }
.panel .flag { color: #b45309; font-weight: 800; }
.panel .pick { display: flex; align-items: center; gap: 6px; font-size: .95rem; }
.game-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.game-sect { margin: 0; padding: 6px 10px; border: 1px solid var(--soft); border-radius: 10px; }
.game-sect legend { font-weight: 800; padding: 0 4px; }
.panel .game-toggle { min-height: 40px; }
.game-toggle input { width: 22px; height: 22px; flex: none; }
.panel .pick select { min-height: 44px; font: inherit; padding: 0 8px; border-radius: 10px; border: 2px solid var(--soft); background: #fff; }
/* grown-ups passcode screens (js/parent-lock.js) */
.panel.lock { width: min(400px, 100%); text-align: center; }
.panel.lock .text-in { display: block; margin: 8px auto; text-transform: uppercase; letter-spacing: .08em; }
.pin-prompt { font-weight: 700; margin: 8px 0 0; }
.pin-dots { display: flex; justify-content: center; gap: 12px; min-height: 22px; margin: 4px 0 14px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; justify-content: center; margin-bottom: 14px; }
.pin-key { min-height: 60px; padding: 0; font-size: 1.5rem; }
.pin.busy .pin-pad { opacity: .5; }
.recovery-code { font: 800 2rem/1.3 ui-monospace, Menlo, monospace; letter-spacing: .12em; color: var(--brand); margin: 8px 0; -webkit-user-select: all; user-select: all; }

/* feedback motion */
.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.confetti span { position: absolute; top: -2rem; font-size: 1.8rem; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: .2; } }

@media (max-width: 560px) {
  .memory { grid-template-columns: repeat(3, 1fr); }
  .kb-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .kb-grid .key.wide { grid-column: span 2; }
  .tile { width: 44px; height: 54px; font-size: 1.6rem; }
  .typed { font-size: 2rem; min-width: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Zombie Trail ---------- */
.zt-setup { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; max-width: 560px; margin: 0 auto; }
.zt-setup h2 { margin: 0; font-size: 2rem; }
.seg { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.opt-summary { margin: 2px 0 0; font-size: .9rem; opacity: .7; }
.zt-options { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.zt-options h2 { margin: 0; }
.btn.opt-gear { position: absolute; top: 0; right: 0; min-width: 48px; padding: 0 10px; font-size: 1.3rem; z-index: 2; }
.zt { display: flex; gap: 18px; justify-content: center; align-items: flex-start; flex-wrap: wrap; width: 100%; }
.zt-board { position: relative; flex: none; width: min(92vw, 66vh, 600px); aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 2px 0 var(--soft); }
.zt-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); }
.sq { position: relative; border: 2px solid #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.sq.c0 { background: #fecaca; } .sq.c1 { background: #fde68a; } .sq.c2 { background: #bbf7d0; } .sq.c3 { background: #bfdbfe; }
.sq.start, .sq.end { background: #ddd6fe; }
.sq.short { background: #86efac; }
.sq.zomb { background: #bef264; box-shadow: inset 0 0 0 3px #dc2626; }
.sq.zomb .ic, .sq.zomb .tg, .zt-lines line { transition: opacity .8s; }
.sq.zomb.gone .ic, .sq.zomb.gone .tg, .zt-lines line.gone { opacity: 0; }
.sq { transition: background-color .6s, box-shadow .6s; }
.sq.zomb.gone { box-shadow: none; }
.sq .n { position: absolute; top: 2px; left: 5px; font-size: .7rem; font-weight: 800; opacity: .55; }
.sq .ic { font-size: clamp(1.1rem, 4.2vw, 2rem); }
.sq .tg { font-size: clamp(.6rem, 1.8vw, .8rem); font-weight: 800; }
.zt-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pawn {
  position: absolute; width: 9%; aspect-ratio: 1; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%; border: 3px solid #fff; z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); font-size: clamp(.9rem, 3vw, 1.6rem);
  transition: left .25s linear, top .25s linear;
}
.pawn.jump { transition: left .8s ease-in-out, top .8s ease-in-out; }
.pawn.p0 { background: #4f46e5; } .pawn.p1 { background: #f97316; }
.zt-panel { width: min(94vw, 520px); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.zt-status { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 800; }
.dot { width: 16px; height: 16px; border-radius: 50%; }
.dot.p0 { background: #4f46e5; } .dot.p1 { background: #f97316; }
.zt-die { display: flex; align-items: center; gap: 14px; }
.die {
  width: 72px; height: 72px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); animation: roll .4s;
}
.die .pip.on { background: var(--ink); border-radius: 50%; }
.die .q { grid-area: 2 / 2; text-align: center; font-size: 1.8rem; font-weight: 800; }
@keyframes roll { from { transform: rotate(-200deg) scale(.6); } to { transform: none; } }
.zt-q { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.zt-panel .typed { width: 100%; min-width: 0; font-size: 2.2rem; }
.numpad .key { max-width: 90px; }

@media (min-width: 880px) {
  .zt { flex-wrap: nowrap; }
  .zt-board { width: min(60vh, 560px); }
  .zt-panel { flex: 1 1 0; width: auto; min-width: 340px; max-width: 520px; }
}
.zt-panel { gap: 8px; }
.zt-q { gap: 8px; }
.zt-panel .key { min-height: 50px; }
.zt-panel .kb { gap: 6px; }
.zt-panel .typed { min-height: 60px; font-size: 2rem; padding: 2px 14px; }
.zt-panel .die { width: 60px; height: 60px; padding: 6px; }
.zt-panel .btn.big { min-height: 52px; }
.zt-panel .msg { min-height: 1.3em; font-size: 1.15rem; }
.zt-panel .prompt { font-size: 1.1rem; }

/* ---------- Menu sections ---------- */
.sect { margin: 0 0 22px; }
.sect h2 { margin: 0 0 10px; font-size: 1.25rem; }

/* ---------- Shared bits for new games ---------- */
.setup { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.setup h2 { margin: 0; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; width: min(520px, 100%); }
.mq { font-size: 3rem; font-weight: 800; color: var(--brand); text-align: center; letter-spacing: .04em; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 12px; width: min(420px, 100%); }
.btn.ans { font-size: 1.8rem; min-height: 68px; }
.btn.ans.right, .cc.right { background: var(--good-bg); border-color: var(--good); }
.btn:disabled { opacity: .45; }
.glow { box-shadow: 0 0 0 4px #fde047, 0 0 18px #facc15; }
.no { opacity: .35; }

/* ---------- Spell Catcher ---------- */
.sc-sky {
  --skyh: min(46vh, 380px);
  position: relative; width: min(94vw, 640px); height: var(--skyh); overflow: hidden;
  border-radius: var(--radius); background: linear-gradient(#bfdbfe, #eff6ff);
}
.sc-letter {
  position: absolute; top: 0; width: 58px; height: 58px; border-radius: 50%; border: 2px solid #fff;
  font-size: 1.9rem; font-weight: 800; color: var(--ink); box-shadow: 0 2px 0 rgba(0,0,0,.12);
  animation: fall var(--d) linear var(--dl) infinite;
}
@keyframes fall { from { transform: translateY(-64px); } to { transform: translateY(var(--skyh)); } }

/* ---------- Word Volcano ---------- */
.vo-mountain {
  position: relative; width: min(94vw, 560px); height: min(46vh, 380px); border-radius: var(--radius);
  background: linear-gradient(#fef3c7, #fde68a 55%, #a8a29e 55%); overflow: hidden;
}
.vo-mountain::before {
  content: ''; position: absolute; inset: 18% 4% 0; background: #78716c;
  clip-path: polygon(50% 0, 100% 100%, 0 100%); opacity: .55;
}
.vo-lava { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(#fb923c, #ef4444); transition: height .8s; }
.vo-rock {
  position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 42% 58% 50% 50%;
  border: 2px solid #57534e; font-size: 1.8rem; font-weight: 800; color: var(--ink);
}
/* eruption (win screen): crater sits at the cone's peak (50%, 18%) */
.vo-mountain.erupt { overflow: visible; animation: vo-rumble .12s linear 6; }
.vo-mountain.erupt .vo-lava { z-index: 2; border-radius: 0 0 var(--radius) var(--radius); } /* rivers pour into the lake */
@keyframes vo-rumble { 25% { transform: translate(-3px, 1px); } 75% { transform: translate(3px, -1px); } }
.vo-crater { position: absolute; left: 50%; top: 18%; width: 0; height: 0; z-index: 3; pointer-events: none; }
.vo-crater::before {
  content: ''; position: absolute; left: -46px; top: -30px; width: 92px; height: 60px; border-radius: 50%;
  background: radial-gradient(#fef08a, #f97316 45%, transparent 70%); animation: vo-glow .5s ease-in-out infinite alternate;
}
@keyframes vo-glow { from { transform: scale(.85); opacity: .75; } to { transform: scale(1.15); opacity: 1; } }
.vo-blob {
  position: absolute; left: calc(var(--s) / -2); top: calc(var(--s) / -2); width: var(--s); height: var(--s);
  border-radius: 50% 50% 45% 55%; box-shadow: 0 0 10px #fb923c; opacity: 0;
  animation: vo-spew var(--d) var(--dl) infinite;
}
/* rise fast and slow down, then fall faster and faster: a rough parabola */
@keyframes vo-spew {
  0% { transform: translate(0, 0) scale(.4); opacity: 1; animation-timing-function: cubic-bezier(.25, .8, .5, 1); }
  42% { transform: translate(calc(var(--dx) * .45), calc(var(--up) * -1)) scale(1); animation-timing-function: cubic-bezier(.5, 0, .9, .5); }
  100% { transform: translate(var(--dx), var(--down)) scale(.6); opacity: .25; }
}
.vo-smoke {
  position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%;
  background: #a8a29e; filter: blur(4px); opacity: 0; animation: vo-puff 2.7s var(--dl) ease-out infinite;
}
@keyframes vo-puff {
  0% { transform: translate(0, 0) scale(.5); opacity: .7; }
  100% { transform: translate(var(--dx), calc(var(--up) * -1)) scale(2.6); opacity: 0; }
}
/* lava pouring down the cone: same triangle as .vo-mountain::before, filled from the top with drippy edge */
.vo-flow { position: absolute; inset: 18% 4% 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); z-index: 1; pointer-events: none; }
.vo-flow-fill {
  position: absolute; left: 0; top: 0; width: 100%; height: 40%; background: linear-gradient(#fde047, #f97316 40%, #dc2626);
  transform-origin: top; animation: vo-pour 2.4s cubic-bezier(.3, .6, .4, 1) both;
  --drip: radial-gradient(circle 9px at 50% 0, #000 96%, transparent);
  -webkit-mask: linear-gradient(#000, #000) top / 100% calc(100% - 14px) no-repeat, var(--drip) bottom / 22px 14px repeat-x;
  mask: linear-gradient(#000, #000) top / 100% calc(100% - 14px) no-repeat, var(--drip) bottom / 22px 14px repeat-x;
}
@keyframes vo-pour { from { transform: scaleY(0); } }
.vo-stream { height: 100%; -webkit-mask: none; mask: none; animation-duration: 3s; }
.vo-slots { position: relative; z-index: 4; } /* her finished word stays readable in front of the eruption */

/* ---------- Wordal ---------- */
.wd-grid { display: flex; flex-direction: column; gap: 6px; }
.wd-row { display: grid; grid-template-columns: repeat(var(--n), var(--sz, 48px)); gap: 6px; --sz: min(48px, calc((92vw - 6px * var(--n)) / var(--n))); }
.wd-cell {
  height: var(--sz, 48px); display: grid; place-items: center; border: 2px solid #c7d2fe; border-radius: 8px;
  background: #fff; font-size: 1.6rem; font-weight: 800; text-transform: uppercase;
}
.wd-cell.filled { border-color: var(--brand); }
.wd-cell.flip { animation: flip .35s; color: #fff; border-color: transparent; }
.wd-cell.correct { background: #16a34a; }
.wd-cell.present { background: #d97706; }
.wd-cell.absent { background: #9ca3af; }
.kb .key[data-s="correct"] { background: #16a34a; color: #fff; }
.kb .key[data-s="present"] { background: #d97706; color: #fff; }
.kb .key[data-s="absent"] { background: #d1d5db; color: #6b7280; }

/* ---------- Math: Mountain, Maze, Bubbles, Cascade ---------- */
.mt { position: relative; width: min(92vw, 420px); height: 120px; background: linear-gradient(#bae6fd, #f0f9ff); border-radius: var(--radius); overflow: hidden; }
.mt-peak { position: absolute; right: 8px; top: 8px; font-size: 3rem; }
.mt-flag { position: absolute; right: 52px; top: 4px; font-size: 1.6rem; }
.mt-hiker { position: absolute; left: calc(var(--p, 0%) * .8 + 4%); bottom: calc(var(--p, 0%) * .5 + 6px); font-size: 2.2rem; transition: all .8s; }
.doors { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.door { width: 110px; height: 150px; border-radius: 14px 14px 4px 4px; border: 3px solid #92400e; background: #fde68a; font-size: 3rem; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.door-n { font-size: 1.8rem; font-weight: 800; }
.door.open { background: var(--good-bg); border-color: var(--good); }
.door.closed { opacity: .4; }
.bb-sea { --seah: min(44vh, 360px); position: relative; width: min(94vw, 620px); height: var(--seah); overflow: hidden; border-radius: var(--radius); background: linear-gradient(#e0f2fe, #7dd3fc); }
.bb {
  position: absolute; bottom: 0; width: 66px; height: 66px; border-radius: 50%; border: 2px solid #fff; background: rgba(255,255,255,.55);
  font-size: 1.6rem; font-weight: 800; color: var(--ink); animation: rise var(--d) linear var(--dl) infinite;
}
.bb.pop { transform: scale(1.4); opacity: 0; transition: all .25s; animation: none; }
@keyframes rise { from { transform: translateY(70px); } to { transform: translateY(calc(var(--seah) * -1)); } }
.cc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(92vw, 380px); }
.cc { height: 70px; font-size: 1.5rem; font-weight: 800; background: #fff; border: 2px solid var(--soft); border-radius: 12px; }
.cc.ripple { background: #e0e7ff; transition: background .3s; }

/* ---------- Puzzle Pieces + Explorer ---------- */
.pz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: min(86vw, 330px); }
.pz-piece { aspect-ratio: 1; font-size: 2.6rem; background: #eef2ff; border: 3px solid #c7d2fe; border-radius: 12px; }
.pz-piece.shown { background: #fff; animation: flip .35s; }
.pz-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 40px; }
.ex-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; width: min(96vw, 620px); }
.ex-cell { aspect-ratio: 1; font-size: clamp(.6rem, 2.4vw, 1rem); font-weight: 700; background: #fff; border: 1px solid var(--soft); border-radius: 4px; padding: 0; }
.ex-cell.lit { background: #fde68a; }
.ex-cell.hide { background: #e0e7ff; color: var(--brand); }
.ex-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ---------- Spot Match + Simon ---------- */
.sm-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.sm-card { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-content: center; width: min(44vw, 240px); min-height: 200px; padding: 12px; background: #fff; border: 3px solid #c7d2fe; border-radius: 50%; }
.sm-sym { min-width: 56px; min-height: 56px; background: transparent; border: 0; line-height: 1; }
.sm-sym.right { background: var(--good-bg); border-radius: 50%; }
.simon { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: min(80vw, 320px); }
.simon-pad { aspect-ratio: 1; border-radius: 20px; border: 0; opacity: .6; }
.simon-pad.red { background: #f87171; } .simon-pad.green { background: #34d399; }
.simon-pad.blue { background: #60a5fa; } .simon-pad.yellow { background: #fbbf24; }
.simon-pad.lit { opacity: 1; transform: scale(1.05); box-shadow: 0 0 0 5px rgba(0,0,0,.18); }

/* ---------- My Garden ---------- */
.gd-field { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: min(94vw, 520px); padding: 12px; background: linear-gradient(#bbf7d0, #86efac); border-radius: var(--radius); }
.gd-plot { aspect-ratio: 1; font-size: clamp(1.6rem, 7vw, 2.6rem); background: rgba(120, 53, 15, .25); border: 0; border-radius: 12px; }
.gd-plot.young { background: rgba(120, 53, 15, .35); }
.gd-plot.boing { animation: flip .5s; }
.gd-special { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: min(94vw, 520px); padding: 8px; background: #fef9c3; border: 2px solid #fde68a; border-radius: 14px; }
.gd-rare { display: flex; flex-direction: column; align-items: center; font-weight: 700; font-size: .9rem; }
.gd-rare-icon { font-size: 2rem; }
.gd-sky { min-height: 2.2rem; font-size: 2rem; display: flex; gap: 14px; justify-content: center; }
.gd-critter { animation: bob 3s ease-in-out infinite; animation-delay: calc(var(--i) * -.6s); }
@keyframes bob { 50% { transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  .sc-letter, .bb, .gd-critter { animation: none; }
  .vo-blob, .vo-smoke { display: none; }
  .sc-letter { top: var(--y); }
  .bb { bottom: var(--y); }
}

/* ---------- layout tuning (iPad landscape / short screens) ---------- */
.wd-cols { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wd-left, .wd-right { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wd-left .msg { max-width: 330px; min-height: 2.6em; }
@media (min-width: 880px) {
  .wd-cols { flex-direction: row; align-items: flex-start; gap: 32px; }
}
.ex-grid { width: min(96vw, 64vh, 620px); }
.pz-grid { width: min(86vw, 40vh, 330px); }

/* ---------- Lily Pad River ---------- */
.lp-river {
  position: relative; width: min(96vw, 760px); border-radius: var(--radius); overflow: hidden;
  background:
    repeating-linear-gradient(95deg, transparent 0 46px, rgba(255,255,255,.22) 48px 51px, transparent 53px 110px),
    linear-gradient(#7dd3fc, #0ea5e9 45%, #0284c7);
  background-size: 220px 100%, 100% 100%;
  animation: lp-flow 7s linear infinite;
}
@keyframes lp-flow { to { background-position: 220px 0, 0 0; } }
.lp-bank { position: relative; height: 46px; background: linear-gradient(#86efac, #4ade80); border-bottom: 5px solid #a16207;
  display: flex; align-items: center; justify-content: flex-end; padding: 0 16px; font-size: 1.4rem; letter-spacing: .25em; }
.lp-bank.low { height: 32px; border-bottom: 0; border-top: 5px solid #a16207; justify-content: center; font-size: 1.1rem; }
.lp-home { position: absolute; left: 18px; bottom: -4px; z-index: 2; }
.lp-frog { font-size: 2.5rem; line-height: 1; letter-spacing: 0; }
.lp-lane { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 10px; min-height: 98px; }
.lp-lane.moving { display: block; padding: 0; height: 98px; }
.lp-lane.moving .lp-slot { position: absolute; top: 13px; }
.lp-pad {
  position: relative; min-width: 108px; height: 72px; padding: 0 30px 0 20px; border-radius: 50%; border: 3px solid #15803d;
  background: radial-gradient(circle at 38% 32%, #dcfce7, #86efac 35%, #22c55e 80%);
  box-shadow: 0 5px 0 rgba(7, 89, 133, .45); font-size: 1.9rem; font-weight: 800; color: #14532d; white-space: nowrap;
  transition: opacity .4s, transform .4s;
}
.lp-pad.word { font-size: 1.5rem; letter-spacing: .02em; }
/* the notch that makes it read as a lily pad */
.lp-pad::after { content: ''; position: absolute; right: -3px; top: 50%; width: 24px; height: 14px; margin-top: -7px;
  background: #0ea5e9; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.lp-pad.sunk { opacity: .35; transform: scale(.85); }
.lp-pad.glow { animation: lp-glow 1s ease-in-out infinite alternate; }
@keyframes lp-glow { from { box-shadow: 0 0 0 3px #fde047; } to { box-shadow: 0 0 0 9px #fde047; } }
.lp-pad.right { background: radial-gradient(circle at 38% 32%, #fefce8, #fde047 40%, #4ade80 85%); border-color: var(--good); }
.lp-pad .lp-frog { position: absolute; top: -34px; left: 50%; margin-left: -1.25rem; }
.lp-frog.hop { animation: lp-hop .55s ease-out; }
@keyframes lp-hop { 0% { transform: translate(-30px, -70px) scale(1.25); } 60% { transform: translate(0, -18px) scale(1.1); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .lp-river, .lp-frog.hop, .lp-pad.glow { animation: none; }
  .lp-pad.glow { box-shadow: 0 0 0 6px #fde047; }
}

/* ---------- Coding: shared step-chip strip (js/code/chips.js) ---------- */
.code-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-content: flex-start; width: min(96vw, 900px);
  min-height: 70px; max-height: 154px; overflow-y: auto; padding: 6px; background: #fff; border: 2px dashed var(--soft); border-radius: var(--radius); }
.code-empty { align-self: center; opacity: .6; font-size: 1rem; }
.code-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 70px; min-height: 58px; padding: 2px;
  border-radius: 12px; border: 3px solid var(--cc, #94a3b8); background: var(--cb, #f1f5f9); color: var(--ink); transition: transform .2s, opacity .2s; }
.code-chip .ci { font-size: 1.5rem; line-height: 1.1; font-weight: 800; }
.code-chip .cw { font-size: .68rem; font-weight: 700; line-height: 1.05; text-align: center; }
.code-chip.now { transform: translateY(-3px) scale(1.06); box-shadow: 0 0 0 4px #fde047; }
.code-chip.pulse { animation: code-pulse .7s ease-in-out 4 alternate; }
@keyframes code-pulse { from { box-shadow: 0 0 0 2px #fde047; } to { box-shadow: 0 0 0 9px #fde047; } }
.code-chip.poof { transform: scale(.2); opacity: 0; }
.c-green { --cc: #16a34a; --cb: #dcfce7; }
.c-red { --cc: #dc2626; --cb: #fee2e2; }
.c-blue { --cc: #2563eb; --cb: #dbeafe; }
.c-purple { --cc: #9333ea; --cb: #f3e8ff; }

/* ---------- Robot Course ---------- */
.rb-pick, .rb-play, .rb-edit { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.rb-tabs { display: flex; gap: 8px; }
.rb-tab { min-height: 52px; padding: 0 20px; border-radius: 14px; border: 2px solid var(--soft); background: var(--card); font-size: 1.15rem; font-weight: 800; }
.rb-tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.rb-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; width: min(900px, 100%); }
.rb-level { position: relative; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 6px 10px; text-align: left;
  background: var(--card); border: 2px solid var(--soft); border-radius: 14px; box-shadow: 0 2px 0 var(--soft); }
.rb-level .rb-n { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #ccfbf1; font-weight: 800; }
.rb-level .rb-nm { font-weight: 700; font-size: 1rem; }
.rb-level .rb-star { position: absolute; top: -8px; right: -6px; font-size: 1.3rem; }
.rb-level.done { border-color: #fde047; }
.rb-rename { min-height: 44px; font-size: .95rem; }
.rb-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: min(900px, 100%); flex-wrap: wrap; }
.rb-top .prompt { flex: 1; }
.rb-ready { font-weight: 700; color: #0f766e; }
.rb-stage { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
.rb-board-wrap { flex: none; width: min(92vw, 46vh, 420px); display: flex; justify-content: center; }
.rb-board { position: relative; width: 100%; max-height: min(92vw, 46vh, 420px); display: grid;
  grid-template-columns: repeat(var(--w), 1fr); grid-template-rows: repeat(var(--h), 1fr);
  background: #f0fdf4; border: 4px solid #86efac; border-radius: 12px; overflow: hidden; }
.rb-cell { position: relative; display: grid; place-items: center; box-shadow: inset 0 0 0 1px #bbf7d0; padding: 0; border: 0; background: transparent; border-radius: 0; }
button.rb-cell:active { background: #dcfce7; }
.rb-cell.k-path { background: #dbeafe; box-shadow: inset 0 0 0 1px #bfdbfe; }
.rb-cell.k-wall { background: repeating-linear-gradient(0deg, #b45309 0 9px, #fcd9b6 9px 11px), #b45309; box-shadow: inset 0 0 0 2px #92400e; }
.rb-piece { font-size: clamp(1.1rem, 6vw, 2rem); line-height: 1; }
.k-gem.got .rb-piece { animation: rb-sparkle .5s ease-out forwards; }
@keyframes rb-sparkle { to { transform: scale(1.8) translateY(-30%); opacity: 0; } }
.rb-bot { position: absolute; left: 0; top: 0; width: calc(100% / var(--w)); height: calc(100% / var(--h)); z-index: 2; pointer-events: none;
  transition: transform .5s ease-in-out, opacity .25s; }
.rb-bot.snap, .rb-bot.snap .rb-turn { transition: none; }
.rb-bot.fade { opacity: 0; }
.rb-turn { width: 100%; height: 100%; transition: transform .45s ease-in-out; }
.rb-body, .rb-mini { width: 100%; height: 100%; padding: 6%; }
.rb-body svg, .rb-mini svg { width: 100%; height: 100%; display: block; overflow: visible; }
.rb-mini { position: absolute; inset: 0; }
.rb-mini.big { position: static; width: 110px; height: 110px; }
.rb-shell { fill: #14b8a6; stroke: #0f766e; stroke-width: 3; }
.rb-wheel { fill: #334155; }
.rb-nose { fill: #facc15; stroke: #a16207; stroke-width: 2; }
.rb-screen { fill: #ecfeff; stroke: #0f766e; stroke-width: 2; }
.rb-eye { fill: #0f172a; }
.rb-m { fill: none; stroke: #0f172a; stroke-width: 3.5; stroke-linecap: round; display: none; }
.rb-m.m-oops { fill: #0f172a; stroke: none; }
.rb-body:not(.happy):not(.oops) .m-norm, .rb-mini .m-norm, .rb-body.happy .m-happy, .rb-body.oops:not(.happy) .m-oops { display: inline; }
.rb-stalk { stroke: #0f766e; stroke-width: 3; }
.rb-ant { fill: #f97316; }
.rb-body.blink .rb-ant { fill: #fde047; }
.rb-body.bonk-f { animation: rb-bonk-f .6s ease-in-out; }
.rb-body.bonk-b { animation: rb-bonk-b .6s ease-in-out; }
@keyframes rb-bonk-f { 25% { transform: translateY(-16%); } 45% { transform: rotate(-9deg); } 65% { transform: rotate(9deg); } 85% { transform: rotate(-4deg); } }
@keyframes rb-bonk-b { 25% { transform: translateY(16%); } 45% { transform: rotate(-9deg); } 65% { transform: rotate(9deg); } 85% { transform: rotate(-4deg); } }
.rb-body.dance { animation: rb-dance .5s ease-in-out 4 alternate; }
@keyframes rb-dance { from { transform: rotate(-14deg) scale(1.05); } to { transform: rotate(14deg) scale(1.15); } }

/* the robot's head: drawn from scratch, same key positions and colours as the toy */
.rb-head { flex: none; width: 270px; padding: 14px 16px 18px; background: #fff7ed; border: 4px solid #fdba74; border-radius: 40px 40px 28px 28px; box-shadow: 0 4px 0 #fed7aa; }
.rb-lights { display: flex; justify-content: space-between; gap: 3px; margin-bottom: 14px; padding: 6px 8px; background: #1e293b; border-radius: 999px; }
.rb-light { width: 16px; height: 16px; border-radius: 50%; background: #475569; opacity: .9; }
.rb-light[class*="c-"] { background: var(--cc); opacity: .45; }
.rb-light.on { opacity: 1; box-shadow: 0 0 8px 3px var(--cc); transform: scale(1.15); }
.rb-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rb-key, .rb-centre { aspect-ratio: 1; min-height: 66px; border-radius: 22px; }
.rb-key { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; border: 0;
  color: #fff; font-size: 2rem; font-weight: 800; box-shadow: 0 5px 0 rgba(0,0,0,.25); text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.rb-key:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.rb-key .ki { line-height: 1; }
.rb-key .kw { font-size: .62rem; line-height: 1.05; text-shadow: none; }
.rb-key.k-green { background: #22c55e; }
.rb-key.k-red { background: #ef4444; }
.rb-key.k-blue { background: #3b82f6; }
.rb-key.k-purple { background: #a855f7; }
.rb-key.k-yellow { background: #facc15; color: #713f12; text-shadow: none; }
.rb-key.k-orange { background: #f97316; }
.rb-centre { background: #fff; border: 3px solid #e2e8f0; }
.rb-head.running .rb-key:not(.k-orange) { opacity: .5; }
.rb-tools .btn { min-height: 48px; }
.rb-after:empty { display: none; }
.rb-ask { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.rb-ask h2 { margin: 0; }

/* builder */
.rb-palette { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.rb-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 72px; min-height: 60px; border-radius: 12px;
  border: 3px solid var(--soft); background: var(--card); }
.rb-tool .ci { font-size: 1.5rem; line-height: 1.1; }
.rb-tool .cw { font-size: .8rem; font-weight: 700; }
.rb-tool[aria-pressed="true"] { border-color: var(--brand); background: #eef2ff; box-shadow: 0 0 0 3px #c7d2fe; }
.rb-tool[data-tool="wall"] .ci { display: inline-block; width: 1.3em; height: 1em; background: repeating-linear-gradient(0deg, #b45309 0 6px, #fcd9b6 6px 8px); border-radius: 3px; font-size: 1.4rem; color: transparent; }
.rb-edit .rb-board-wrap { width: min(92vw, 50vh, 420px); }
.rb-edit .rb-board { touch-action: none; } /* dragging builds walls instead of scrolling */
/* util.js textInput(): free text with the device keyboard (>= 16px so iOS doesn't zoom in on focus) */
.text-in { width: min(320px, 100%); min-height: 56px; padding: 0 16px; font: inherit; font-size: 1.4rem; font-weight: 700;
  text-align: center; color: var(--ink); background: #fff; border: 3px solid #c7d2fe; border-radius: var(--radius);
  -webkit-user-select: text; user-select: text; }
.text-in:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #c7d2fe; }
.rb-name-input { min-height: 60px; font-size: 1.8rem; font-weight: 800; color: var(--brand); }
.st-form { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.st-saved-as { font-size: 1.3rem; font-weight: 800; }

@media (max-width: 560px) {
  .rb-head { width: 240px; padding: 10px 12px 14px; }
  .rb-key, .rb-centre { min-height: 58px; }
  .code-chip { width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .k-gem.got .rb-piece { opacity: 0; }
}

/* Robot Course: start marker, breadcrumbs, ghost (all share the robot's one-cell box) */
.rb-start, .rb-crumb, .rb-ghost { position: absolute; left: 0; top: 0; width: calc(100% / var(--w)); height: calc(100% / var(--h)); pointer-events: none; }
.rb-start { z-index: 1; display: grid; place-items: center; border: 3px dashed #0d9488; border-radius: 10px; background: rgba(204, 251, 241, .55); }
.rb-start-arrow { font-size: clamp(.9rem, 4vw, 1.4rem); font-weight: 800; color: #0d9488; opacity: .7; }
.rb-trail { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.rb-crumb { display: grid; place-items: center; }
.rb-crumb span { width: 34%; height: 34%; display: block; background: #f97316; opacity: .75;
  clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); } /* small arrow pointing the way it went */
.rb-ghost { opacity: .4; filter: grayscale(.4); }
.rb-ghost .rb-turn { width: 100%; height: 100%; }
.rb-cone svg { width: 100%; height: 100%; display: block; }
.rb-piece.rb-cone { width: 70%; height: 70%; }
.rb-tool .ci.rb-cone { width: 1.6rem; height: 1.6rem; }
.rb-mine-wrap { position: relative; display: flex; }
.rb-mine-wrap .rb-level { flex: 1; padding-right: 52px; }
.rb-del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border-radius: 12px; border: 2px solid var(--soft); background: #fff; font-size: 1.2rem; }

/* ---------- Coding: chip extras (repeat boxes, swatches, pencil up) ---------- */
.c-grey { --cc: #64748b; --cb: #f1f5f9; }
.c-orange { --cc: #ea580c; --cb: #ffedd5; }
.c-yellow { --cc: #ca8a04; --cb: #fef9c3; }
.code-chip { position: relative; }
.code-chip .csw { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.ci.pen-up { display: inline-block; transform: rotate(180deg); }
.code-box { display: flex; align-items: stretch; gap: 4px; padding: 4px; border: 3px solid #ea580c; border-radius: 14px; background: #fff7ed; }
.code-box.open { border-style: dashed; box-shadow: 0 0 0 3px #fed7aa; }
.code-box.now { background: #ffedd5; }
.code-box.poof { transform: scale(.2); opacity: 0; transition: transform .2s, opacity .2s; }
.code-box-body { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 70px; }
.code-box-body .code-empty { font-size: .8rem; padding: 0 6px; max-width: 150px; }
.code-box .code-box { border-color: #f59e0b; background: #fffbeb; }

/* ---------- Turtle Draw ---------- */
.tt-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.tt-work { display: flex; gap: 16px; justify-content: center; align-items: flex-start; flex-wrap: wrap; width: 100%; }
.tt-stage { position: relative; flex: none; width: min(92vw, 44vh, 420px); aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  border: 3px solid #c7d2fe; background: #fff; }
.tt-canvas { display: block; width: 100%; height: 100%; }
.tt-turtle { position: absolute; width: 13%; aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; }
.tt-body { width: 100%; height: 100%; }
.tt-body svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tt-ink { fill: var(--pc, #1f2340); }
.tt-turtle[data-pen="up"] .tt-tail-down, .tt-turtle[data-pen="down"] .tt-tail-up { display: none; }
.tt-keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; width: 270px; }
.tt-key { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 2px 8px; border-radius: 12px;
  border: 3px solid var(--cc, #94a3b8); background: var(--cb, #f1f5f9); font-weight: 700; font-size: .85rem; text-align: left; }
.tt-key .ci { font-size: 1.35rem; flex: none; width: 1.6rem; text-align: center; }
.tt-key:disabled { opacity: .35; }
.tt-key[hidden] { display: none; }
.tt-close { grid-column: 1 / -1; justify-content: center; border-color: var(--good); background: var(--good-bg); font-size: 1rem; }
.tt-work.running .tt-key { opacity: .5; }
.tt-controls .btn { min-height: 48px; padding: 0 14px; }
.tt-controls .btn[aria-pressed="true"] { background: #eef2ff; border-color: #c7d2fe; }
.tt-play { min-width: 130px; }
.tt-logo { margin: 0; width: min(96vw, 900px); padding: 10px 14px; background: #1e293b; color: #e2e8f0; border-radius: 12px;
  font: 600 .95rem/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; -webkit-user-select: text; user-select: text; }
.tt-logo[hidden] { display: none; }
.tt-pop { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.tt-pop h2 { margin: 0; }
.tt-nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: min(100%, 360px); }
.tt-num { min-height: 48px; padding: 0; font-size: 1.15rem; }
.tt-num.on, .tt-swatch.on { box-shadow: 0 0 0 4px #fde047; }
.tt-swatch { aspect-ratio: 1; min-height: 48px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.tt-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; width: min(900px, 100%); }
.tt-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 8px;
  background: var(--card); border: 2px solid var(--soft); border-radius: 14px; box-shadow: 0 2px 0 var(--soft); }
.tt-tile img { width: 100%; max-width: 120px; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--soft); }
.tt-tile.done { border-color: #fde047; }
.tt-tile .rb-star { position: absolute; top: -8px; right: -6px; font-size: 1.3rem; }
.tt-gal .rb-del { top: 8px; right: 8px; transform: none; }
@media (max-width: 560px) {
  .tt-keys { width: 100%; grid-template-columns: repeat(2, 1fr); }
}

/* Coding: drag a chip to reorder (chips.js) */
.code-chips { position: relative; }
.code-chips.can-drag .code-chip { touch-action: none; }
.code-chip.dragging, .code-box.dragging { opacity: .3; }
.code-ghost { position: fixed; left: 0; top: 0; z-index: 20; margin: 0; pointer-events: none; opacity: .92;
  box-shadow: 0 8px 20px rgba(20, 22, 50, .25); }
.code-drop { position: absolute; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--brand); pointer-events: none; }
.code-drop[hidden] { display: none; }

/* ---------- Code Studio ---------- */
.c-pink { --cc: #db2777; --cb: #fce7f3; }
.st-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.st-top { display: flex; align-items: center; gap: 8px; width: min(100%, 900px); flex-wrap: wrap; }
.st-top .btn { min-height: 48px; padding: 0 14px; }
.st-flag { min-width: 96px; background: var(--good); border-color: var(--good); font-size: 1.3rem; }
.st-stop { min-width: 56px; font-size: 1.3rem; }
.st-stop.on { background: #fee2e2; border-color: #dc2626; }
.st-title { flex: 1; text-align: center; font-weight: 800; font-size: 1.15rem; min-width: 120px; }
.st-main { display: flex; gap: 14px; justify-content: center; align-items: flex-start; flex-wrap: wrap; width: 100%; }
.st-left { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.st-stage { position: relative; width: min(92vw, 56vh, 470px); aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  border: 3px solid #c7d2fe; touch-action: none; container-type: inline-size; background: #fff; }
.st-sprite { position: absolute; transform: translate(-50%, -50%); width: 9%; aspect-ratio: 1; display: grid; place-items: center;
  font-size: 2rem; font-size: 7.5cqw; line-height: 1; cursor: pointer; }
.st-sprite.sel::after { content: ''; position: absolute; inset: -6%; border: 2px dashed rgba(79, 70, 229, .55); border-radius: 50%; pointer-events: none; }
.st-sprite.hidden { opacity: 0; pointer-events: none; }
.st-body { display: block; transition: opacity .25s; }
.st-bubble { position: absolute; bottom: 92%; left: 55%; z-index: 3; padding: 4px 10px; background: #fff; border: 2px solid var(--ink);
  border-radius: 14px 14px 14px 2px; font-size: clamp(.75rem, 3.2cqw, 1rem); font-weight: 700; white-space: nowrap; pointer-events: none; }
.st-bubble[hidden] { display: none; }
.st-spritebar { display: flex; gap: 6px; }
.st-pick { width: 52px; height: 52px; border-radius: 14px; border: 3px solid var(--soft); background: var(--card); font-size: 1.7rem; padding: 0; }
.st-pick.sel { border-color: var(--brand); box-shadow: 0 0 0 3px #c7d2fe; }
.st-palette { display: flex; flex-direction: column; gap: 6px; width: 290px; }
.st-cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.st-cat { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; border-radius: 12px;
  border: 2px solid var(--soft); background: var(--card); font-weight: 700; font-size: .78rem; padding: 2px; }
.st-cat .ci { font-size: 1.25rem; }
.st-cat[aria-selected="true"] { background: #eef2ff; border-color: var(--brand); box-shadow: 0 0 0 2px #c7d2fe; }
.st-keys { width: 100%; }
.st-scripts { display: flex; flex-direction: column; gap: 6px; width: min(100%, 900px); max-height: 188px; overflow-y: auto; }
.st-script { display: flex; gap: 6px; align-items: stretch; padding: 4px; border-radius: 16px; border: 2px solid transparent; }
.st-script.sel { border-color: #c7d2fe; background: #f5f7ff; }
.st-script .code-chips { flex: 1; width: auto; min-height: 66px; max-height: none; justify-content: flex-start; }
.st-event { flex: none; width: 60px; min-height: 60px; border-radius: 14px; border: 3px solid #ca8a04; background: #fef9c3; font-size: 1.7rem; }
.st-newscript { align-self: flex-start; min-height: 44px; font-size: .95rem; }
.st-wrap.running .st-keys .tt-key { opacity: .5; }
.st-notes, .st-phrases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(100%, 420px); }
.st-phrases .tt-num { font-size: .95rem; padding: 0 4px; }
.st-emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: min(100%, 360px); }
.st-emojis .tt-num { font-size: 1.6rem; }
.st-backdrops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(100%, 440px); }
.st-bd { aspect-ratio: 4 / 3; min-height: 60px; border-radius: 10px; border: 3px solid var(--soft); display: flex; align-items: flex-end;
  justify-content: center; padding: 2px; font-weight: 700; font-size: .8rem; }
.st-bd span { background: rgba(255,255,255,.85); border-radius: 6px; padding: 0 4px; }
.st-bd.on { border-color: var(--brand); box-shadow: 0 0 0 3px #c7d2fe; }
.st-tile, .st-proj, .st-new { min-height: 120px; justify-content: center; }
.st-icon { font-size: 2.6rem; }
.st-cast { font-size: 1rem; }
/* backdrops: CSS only */
.bd-plain { background: #fff; }
.bd-sky { background: linear-gradient(#7dd3fc, #e0f2fe); }
.bd-grass { background: linear-gradient(#bae6fd 0 62%, #86efac 62% 100%); }
.bd-space { background: radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 2px), radial-gradient(circle at 70% 20%, #fff 0 1px, transparent 2px),
  radial-gradient(circle at 45% 70%, #fff 0 1px, transparent 2px), radial-gradient(circle at 85% 65%, #fde68a 0 2px, transparent 3px),
  radial-gradient(circle at 12% 80%, #fff 0 1px, transparent 2px), linear-gradient(#0f172a, #312e81); }
.bd-ocean { background: linear-gradient(#7dd3fc 0 22%, #0ea5e9 22% 70%, #0369a1 70% 92%, #fde68a 92%); }
.bd-city { background: linear-gradient(to top, #64748b 0 12%, transparent 12%),
  linear-gradient(90deg, transparent 0 8%, #94a3b8 8% 20%, transparent 20% 30%, #a1a1aa 30% 38%, transparent 38% 55%, #94a3b8 55% 70%, transparent 70% 78%, #a1a1aa 78% 92%, transparent 92%) bottom / 100% 55% no-repeat,
  linear-gradient(#fef3c7, #fbcfe8); }
.bd-sunset { background: linear-gradient(#f97316, #fb7185 45%, #7c3aed); }
.bd-night { background: radial-gradient(circle at 80% 22%, #fef9c3 0 7%, transparent 7.5%), linear-gradient(#1e1b4b, #0f172a 70%, #14532d 70%); }
@media (max-width: 560px) {
  .st-palette { width: 100%; }
  .st-scripts { max-height: none; }
}

/* chip tap-menu title: the chip itself, bigger (chips.js chipTitle) */
.code-menu-title { margin: 0; display: flex; justify-content: center; }
.code-face { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 104px; min-height: 86px; padding: 6px 10px; border-radius: 16px; border: 4px solid var(--cc, #94a3b8);
  background: var(--cb, #f1f5f9); color: var(--ink); }
.code-face .ci { font-size: 2.3rem; line-height: 1.1; font-weight: 800; }
.code-face .cw { font-size: .95rem; font-weight: 700; line-height: 1.1; text-align: center; }
.code-face .csw { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }

/* ---------- shared question box (js/challenge.js: Battle Buddies, Dragon Egg Quest) ---------- */
.ch-q { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.ch-q .typed { width: 100%; min-width: 0; min-height: 60px; font-size: 2rem; padding: 2px 14px; }
.ch-q .bigword { font-size: 2.4rem; }
.ch-q .kb { gap: 6px; }
.ch-q .key { min-height: 50px; }

/* ---------- Battle Buddies ---------- */
.bt-picks { gap: 8px; }
.btn.bt-pick { font-size: 1.8rem; min-width: 60px; padding: 0 10px; }
.bt { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.bt-arena {
  position: relative; width: min(100%, 640px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px 8px; border-radius: 18px; background: linear-gradient(#e0f2fe, #f0fdf4 70%, #dcfce7); box-shadow: 0 2px 0 var(--soft);
}
.bt-side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 14px; border: 3px solid transparent; }
.bt-side.on { border-color: #fde047; background: rgba(255,255,255,.55); }
.bt-hearts { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; font-size: clamp(1rem, 4vw, 1.5rem); min-height: 1.6em; }
.bt-heart.pop { animation: bt-pop .5s; }
@keyframes bt-pop { 0% { transform: scale(1.6); } 100% { transform: scale(1); } }
.bt-ava { font-size: clamp(3rem, 14vw, 5rem); line-height: 1.1; }
.bt-side.s1 .bt-face { transform: scaleX(-1); }
.bt-face { display: inline-block; }
.bt-face.hit { animation: bt-hit .5s; }
.bt-side.s1 .bt-face.hit { animation-name: bt-hit-flip; }
@keyframes bt-hit { 0%,100% { transform: none; } 25% { transform: translateX(-10px) rotate(-8deg); } 75% { transform: translateX(10px) rotate(8deg); } }
@keyframes bt-hit-flip { 0%,100% { transform: scaleX(-1); } 25% { transform: scaleX(-1) translateX(-10px) rotate(-8deg); } 75% { transform: scaleX(-1) translateX(10px) rotate(8deg); } }
.bt-name { font-weight: 800; font-size: 1.1rem; }
.bt-vs { font-weight: 900; font-size: 1.3rem; opacity: .45; }
.bt-zap { position: absolute; left: 0; top: 0; margin: -1rem 0 0 -1rem; font-size: 2rem; pointer-events: none; z-index: 4; }
.bt-panel { width: min(94vw, 520px); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bt-status { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 800; }
.bt-mini { font-size: 1.6rem; }
.bt-panel .typed { width: 100%; min-width: 0; min-height: 60px; font-size: 2rem; padding: 2px 14px; }
.typed.bt-oops { background: var(--warm-bg); border-color: var(--warm); }
.typed.bt-oops .ok { color: var(--ink); }
.typed.bt-oops .off { color: #b45309; text-decoration: underline wavy; }
.bt-panel .msg { font-size: 1.15rem; }
.bt-finish { padding-top: 6px; }
.bt-pair { gap: 18px; align-items: flex-start; }
.bt { position: relative; }
.bt-arena.love { background: linear-gradient(#fff1f5, #fde7ef); }
.bt-meter .bt-heart.pop { animation: bt-pop .5s; }
.bt-shared { width: min(94vw, 520px); padding: 6px 10px; border-radius: 14px; background: #fff1f5; border: 2px solid #fbcfe8; }
.bt-face.happy { animation: bt-happy .6s; }
.bt-side.s1 .bt-face.happy { animation-name: bt-happy-flip; }
@keyframes bt-happy { 0%,100% { transform: none; } 40% { transform: translateY(-14px) scale(1.08); } }
@keyframes bt-happy-flip { 0%,100% { transform: scaleX(-1); } 40% { transform: scaleX(-1) translateY(-14px) scale(1.08); } }

/* ---------- Dragon Egg Quest ---------- */
.qt-picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; width: min(100%, 760px); }
.qt-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px; min-height: 120px; background: var(--card); border: 2px solid var(--soft); border-radius: var(--radius); box-shadow: 0 2px 0 var(--soft); }
.qt-pick:active { transform: translateY(2px); box-shadow: none; }
.qt-pick-icon { font-size: 2.2rem; }
.qt-pick-name { font-size: 1.15rem; font-weight: 800; }
.qt-pick-blurb { font-size: .95rem; opacity: .7; }
.qt-badge { font-size: .85rem; font-weight: 800; color: var(--brand); background: #eef2ff; border-radius: 999px; padding: 2px 10px; }
.qt-badge.done { color: #166534; background: var(--good-bg); }
.qt-all { margin-top: 4px; }
.qt-shelf { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.qt-pet { display: flex; flex-direction: column; align-items: center; font-weight: 700; font-size: .95rem; }
.qt-pet .qt-found { font-size: 2rem; }
.qt-found { display: inline-block; }
.qt-found.hatched { animation: qt-hatch .8s; }
@keyframes qt-hatch { 0% { transform: scale(.2) rotate(-20deg); } 70% { transform: scale(1.2); } 100% { transform: none; } }
.qt { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.qt-map { display: flex; align-items: center; width: min(100%, 760px); padding: 8px; background: #fefce8; border: 2px solid #fde68a; border-radius: 14px; }
.qt-stop { position: relative; flex: none; width: clamp(30px, 8vw, 46px); aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(1rem, 4vw, 1.6rem); border-radius: 50%; background: #fff; border: 2px solid #fde68a; opacity: .75; }
.qt-stop.done { opacity: 1; background: #dcfce7; border-color: #86efac; }
.qt-stop.here { opacity: 1; border-color: var(--brand); box-shadow: 0 0 0 3px #c7d2fe; }
.qt-pony { position: absolute; top: -1.1em; font-size: 1rem; }
.qt-legs { flex: 1; display: flex; justify-content: space-evenly; align-items: center; min-width: 8px; border-top: 3px dotted #d6b98c; margin: 0 2px; height: 0; }
.qt-dot { position: relative; width: 0; height: 0; font-size: 1rem; }
.qt-dot::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #e7d3ae; }
.qt-dot.done::before { background: #16a34a; }
.qt-dot:not(:empty) { transform: translate(-50%, -150%); width: auto; height: auto; }
.qt-dot:not(:empty)::before { display: none; }
.qt-bag { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: 1.2rem; font-weight: 800; }
.qt-eggnote { font-size: 1rem; font-weight: 700; opacity: .8; }
.qt-egg { display: inline-block; }
.qt-egg.wiggle { animation: qt-wiggle 1.6s infinite; }
.qt-egg.big { font-size: 1em; }
@keyframes qt-wiggle { 0%,80%,100% { transform: none; } 85% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-6deg); } }
.qt-scene { width: min(100%, 620px); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px; background: var(--card); border: 2px solid var(--soft); border-radius: var(--radius); text-align: center; }
.qt-art { font-size: clamp(3rem, 12vw, 4.5rem); line-height: 1.1; }
.qt-title { margin: 0; font-size: 1.5rem; }
.qt-text { margin: 0; font-size: 1.2rem; line-height: 1.4; }
.qt-act { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; margin-top: 4px; }
.btn.qt-way { width: min(100%, 440px); }
.qt-act .text-in { width: min(100%, 320px); text-align: center; }
.qt-end .big-emoji { font-size: 4rem; }
@media (max-width: 560px) {
  .qt-pony { display: none; }
  .qt-scene { padding: 10px; }
}

/* Guess What (issue #57) */
.gw { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.gw-top { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 0; }
.gw-top:empty { display: none; }
.btn.gw-mine { background: var(--warm-bg); border-color: var(--warm); }
.gw-bot { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.gw-bot-face { font-size: 1.6rem; margin-right: 4px; }
.gw-bot-tile { width: 14px; height: 20px; border-radius: 4px; background: var(--brand); transition: opacity .3s; }
.gw-bot-tile.down { opacity: .18; }
.gw-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; width: 100%; }
.gw-card {
  min-height: 58px; padding: 6px 8px; border-radius: 14px; border: 3px solid var(--soft); background: var(--card);
  font-size: 1.35rem; font-weight: 800; transition: opacity .25s, transform .25s, background .25s;
}
.gw-card.down { opacity: .32; background: #e5e7eb; transform: scale(.94); text-decoration: line-through; }
.gw-card.mine { border-color: var(--warm); }
.gw-card.found { background: var(--good-bg); border-color: var(--good); opacity: 1; transform: scale(1.05); text-decoration: none; }
.gw-card.nudge { animation: gw-nudge .8s; }
@keyframes gw-nudge { 0%,100% { transform: none; } 25% { transform: rotate(-4deg) scale(1.05); } 75% { transform: rotate(4deg) scale(1.05); } }
.gw-history { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.gw-history:empty { display: none; }
.gw-chip { padding: 4px 10px; border-radius: 999px; background: var(--soft); font-weight: 700; font-size: .95rem; }
.gw-chip.bot { background: #eef2ff; }
.gw-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.gw-q { min-width: 88px; font-size: 1.3rem; }
.gw-q mark, .gw-chip mark { background: var(--warm-bg); color: inherit; border-radius: 4px; padding: 0 1px; text-decoration: underline; }
.gw-hint { margin: 0; font-size: 1rem; opacity: .8; text-align: center; }
.gw-botq { max-width: 560px; }
@media (max-width: 560px) {
  .gw-board { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .gw-card { font-size: 1.1rem; min-height: 50px; }
  .gw-tab { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { .gw-card.nudge { animation: none; outline: 3px solid var(--warm); } }

/* ---------- Crystal Cave (js/games/cave.js) ---------- */
.zt-setup.cv-setup { max-width: 940px; }
.cv-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; width: 100%; }
.cv-seat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; background: var(--card); border: 2px solid var(--soft); border-radius: var(--radius); }
.cv-seat.off { background: transparent; border-style: dashed; }
.cv-seat-n { margin: 0; font-size: .85rem; font-weight: 800; opacity: .6; }
.cv-seat-title { margin: 0; font-size: 1.2rem; font-weight: 800; }
.cv-types { gap: 6px; }
.cv-types .btn { min-height: 44px; padding: 0 10px; font-size: .95rem; }
.cv-heroes { gap: 4px; }
.cv-heroes { flex-wrap: nowrap; }
.btn.cv-heropick { min-width: 0; min-height: 56px; padding: 2px; }
.cv-pick-art svg { width: 42px; height: 42px; display: block; }
.cv-seat .text-in { width: 100%; text-align: center; }
.cv-levels { gap: 6px; }
.cv-pick { display: flex; align-items: center; gap: 6px; font-size: .95rem; font-weight: 700; }
.cv-pick select { min-height: 44px; max-width: 150px; font: inherit; font-size: .95rem; padding: 0 6px; border-radius: 10px; border: 2px solid var(--soft); background: #fff; }
.cv-botname { margin: 0; font-weight: 700; opacity: .75; }
.cv-mode { margin: 0; font-weight: 800; }
.cv { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.cv-top { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; align-items: center; font-weight: 800; font-size: 1.1rem; }
.cv-team { display: inline-flex; align-items: center; gap: 4px; }
.cv-main { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: flex-start; width: 100%; }
.cv-board-wrap { flex: none; }
.cv-board { width: min(92vw, calc(54vh * var(--cols, 4) / var(--rows, 4)), 560px); }
.cv-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); padding: 6px; background: #3b2f4a; border-radius: 16px 16px 16px 0; }
.cv-tile { position: relative; aspect-ratio: 1; padding: 3px; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.08); border-radius: 0; background: #fde7c8; }
.cv-tile.room1 { background: #fde7c8; } .cv-tile.room2 { background: #ede9fe; } .cv-tile.room3 { background: #fed7aa; } .cv-tile.room4 { background: #cffafe; }
.cv-tile.room5 { background: #fecaca; } .cv-tile.room6 { background: #fbcfe8; } .cv-tile.room7 { background: #fde68a; }
.cv-tile.wt { border-top: 5px solid #1e1b2e; } .cv-tile.wr { border-right: 5px solid #1e1b2e; } .cv-tile.wb { border-bottom: 5px solid #1e1b2e; } .cv-tile.wl { border-left: 5px solid #1e1b2e; }
.cv-crystal { width: 86%; height: 86%; border-radius: 10%; position: relative;
  background: repeating-linear-gradient(0deg, transparent 0 22%, rgba(0,0,0,.18) 22% 25%), var(--stone, #78716c); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.cv-crystal::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%) rotate(45deg); border-radius: 3px; background: #fde047; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.cv-tile.green .cv-crystal { --stone: #16a34a; } .cv-tile.gray .cv-crystal { --stone: #78716c; } .cv-tile.red .cv-crystal { --stone: #b91c1c; }
.cv-tile.can { cursor: pointer; z-index: 1; }
.cv-tile.can.down .cv-crystal { animation: cv-glow 1.4s ease-in-out infinite; }
.cv-tile.can.up { box-shadow: inset 0 0 0 4px #fde047; }
@keyframes cv-glow { 0%,100% { box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 0 0 0 #fde047; } 50% { box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 0 0 5px #fde047; } }
.cv-face { width: 78%; height: 78%; } .cv-face svg { width: 100%; height: 100%; display: block; }
.cv-tile .cv-needs { position: absolute; bottom: 2px; left: 0; right: 0; display: flex; justify-content: center; gap: 1px; }
.cv-tile .cv-need svg { width: clamp(9px, 2.4vw, 15px); height: clamp(9px, 2.4vw, 15px); display: block; }
.cv-tokens { position: absolute; top: 1px; left: 1px; display: flex; gap: 0; }
.cv-token svg { width: clamp(16px, 4.5vw, 28px); height: clamp(16px, 4.5vw, 28px); display: block; background: rgba(255,255,255,.7); border-radius: 50%; }
.cv-token.on svg { box-shadow: 0 0 0 2px #4f46e5; }
.cv-entry { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; background: #3b2f4a; color: #fde68a; font-weight: 800; border-radius: 0 0 12px 12px; }
.cv-side { flex: 1 1 340px; max-width: 520px; display: flex; flex-direction: column; gap: 8px; }
.cv-players { display: flex; flex-direction: column; gap: 6px; }
.cv-player { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--card); border: 2px solid var(--soft); border-radius: 12px; }
.cv-player.on { border-color: #facc15; background: #fefce8; }
.cv-ava svg { width: 46px; height: 46px; display: block; }
.cv-pinfo { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cv-pname { font-weight: 800; }
.cv-stats { display: flex; gap: 10px; flex-wrap: wrap; font-weight: 800; }
.cv-stats > span { display: inline-flex; align-items: center; gap: 2px; }
.cv-ic-w svg { width: 20px; height: 20px; display: block; }
.cv-quest { font-size: .85rem; opacity: .8; }
.cv-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; background: var(--card); border: 2px solid var(--soft); border-radius: var(--radius); }
.cv-status { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; font-weight: 800; }
.cv-mini svg { width: 36px; height: 36px; display: block; }
.cv-msg { font-size: 1.1rem; min-height: 1.3em; }
.cv-work { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.cv-work .prompt { font-size: 1.1rem; }
.cv-qtitle { margin: 0; font-weight: 800; color: #6d28d9; }
.cv-card { display: flex; align-items: center; gap: 10px; }
.cv-big svg { width: 96px; height: 96px; display: block; }
.cv-big.gone svg { animation: cv-poof .9s forwards; }
@keyframes cv-poof { to { transform: scale(.2) rotate(30deg); opacity: 0; } }
.cv-card-text { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 1.05rem; }
.cv-card-text strong { width: 100%; font-size: 1.2rem; }
.cv-card .cv-needs { display: inline-flex; gap: 2px; }
.cv-card .cv-need svg { width: 22px; height: 22px; display: block; }
.cv-choices { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.cv-choices .btn { width: min(100%, 380px); }
.cv-anypicks .btn { display: inline-flex; align-items: center; gap: 4px; }
.cv-found { display: flex; gap: 14px; font-size: 2.4rem; }
.cv-treasure { display: flex; flex-direction: column; align-items: center; }
.cv-treasure small { font-size: 1rem; font-weight: 800; }
.cv-typed { width: 100%; min-width: 0; min-height: 60px; font-size: 2rem; padding: 2px 14px; }
.typed.bt-oops .ok { color: var(--ink); }
.cv-results { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cv-result { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 6px 10px; padding: 6px 10px; background: #f8fafc; border-radius: 12px; text-align: left; }
.cv-result small { grid-column: 1 / -1; opacity: .7; }
.cv-place { font-size: 1.4rem; }
.cv-total { font-weight: 800; }
.cv-finish { padding-top: 4px; gap: 10px; }
.cv.asking .cv-players { display: none; }
@media (max-width: 879px) {
  .cv.asking .cv-board-wrap { display: none; }
  .cv-side { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .cv-tile.can.down .cv-crystal { animation: none; box-shadow: 0 0 0 4px #fde047; }
  .cv-big.gone svg { animation: none; opacity: .3; }
}

/* ---------- Monster Parade (js/games/parade.js; art in js/games/parade/art.js) ---------- */
.pd-setup .opt-summary { margin: 2px 0 0; font-size: .9rem; opacity: .7; }
.pd { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.pd-line { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pd-spot { width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; border-radius: 12px; border: 2px dashed var(--soft); background: var(--card); }
.pd-spot.done { border-style: solid; border-color: #fde68a; background: #fffbeb; }
.pd-spot.now { border-color: var(--warm); }
.pd-mini svg { width: 50px; height: auto; display: block; }
.pd-empty { font-size: 1.3rem; opacity: .5; }
.pd-name { font-size: .8rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-main { display: flex; gap: 16px; align-items: flex-start; justify-content: center; flex-wrap: wrap; width: 100%; }
/* As big as fits: ~58% of an iPad's height, nearly full width on a phone (art.js VIEWBOX is 240 x 290). */
.pd-stage { width: min(92vw, 50vh, 520px); aspect-ratio: 240 / 290; flex: none; border-radius: 18px; background: linear-gradient(#e0f2fe, #fef9c3); box-shadow: 0 2px 0 var(--soft); }
.pd-stage svg { width: 100%; height: auto; display: block; }
.pd-stage.pop { animation: pd-pop .5s; }
@keyframes pd-pop { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: none; } }
.pd-panel { flex: 1 1 340px; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pd-panel .text-in { width: min(100%, 300px); text-align: center; }
.pd-hint { margin: 0; opacity: .75; }
.pd-choices { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.btn.pd-choice { flex: 1 1 0; max-width: 184px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; min-width: 0; }
.pd-preview { width: 100%; }
.pd-preview svg { width: 100%; height: auto; display: block; }
.pd-label { font-weight: 800; }
.pd-parade { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.pd-parade h2 { margin: 0; }
.pd-crowd { font-size: 1.6rem; letter-spacing: .1em; white-space: nowrap; overflow: hidden; max-width: 100%; }
.pd-road { position: relative; width: 100%; overflow: hidden; padding: 8px 0 18px; border-radius: 18px; background: linear-gradient(#bae6fd 0 62%, #9ca3af 62% 100%); }
.pd-row { display: flex; gap: 14px; width: max-content; align-items: flex-end; }
.pd-road.still .pd-row { width: auto; flex-wrap: wrap; justify-content: center; }
.pd-marcher { display: flex; flex-direction: column; align-items: center; }
.pd-big svg { height: min(250px, 34vh); width: auto; display: block; }
.pd-marcher .pd-name { font-size: 1rem; background: #fff; padding: 0 8px; border-radius: 999px; }
@media (max-width: 560px) {
  .btn.pd-choice { padding: 4px; }
  .pd-big svg { height: 200px; }
  .pd-spot { width: 52px; min-height: 52px; }
  .pd-mini svg { width: 40px; }
}
@media (prefers-reduced-motion: reduce) { .pd-stage.pop { animation: none; } }
