/* Spellsail: tokens from brand/BRAND.md (light theme only). Kid screens use Andika, grown-ups use Geist. */
:root {
  --bg: #f3f8fb;
  --panel: #ffffff;
  --text: #14212b;
  --dim: #4a5d6b;
  --accent: #0a7aa0;
  --accent-ink: #075a75;
  --correct: #1a7a45;
  --try-again: #9a4600;
  --highlight: #ffd84d;
  --trace-guide: #6d8ba0;
  --box-line: #757f87;
  --accent-soft: #e2f4f9;
  --correct-soft: #e6f6ed;
  --try-again-soft: #fff1dc;
  --keelwork-dim: #545960;
  --kid: Andika, "Comic Neue", system-ui, sans-serif;
  --grown: Geist, system-ui, -apple-system, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--kid);
  font-size: 24px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
body[data-area="grown"] { font-family: var(--grown); font-size: 16px; }
h1, h2, p { margin: 0; }
h1:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.dim { color: var(--dim); }
.small { font-size: 14px; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }

:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }

.top { max-width: 1120px; margin: 0 auto; padding: 16px 24px 4px; display: flex; align-items: center; }
.wordmark { height: 44px; width: auto; display: block; }
.main { max-width: 1120px; margin: 0 auto; padding: 0 24px 40px; }
.screen { display: flex; flex-direction: column; gap: 20px; padding-top: 12px; }

/* buttons: kid (>= 64 px tall, Andika Bold 24) */
.btn {
  appearance: none; -webkit-appearance: none;
  min-height: 64px; padding: 0 28px; border-radius: 16px;
  font: 700 24px/1 var(--kid); cursor: pointer; touch-action: manipulation;
  border: 2px solid transparent; white-space: nowrap;
  transition: transform .08s ease, filter .08s ease;
}
.btn:active { transform: translateY(1px); filter: brightness(.94); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--box-line); }
.btn.ghost { padding: 0 8px; background: transparent; color: var(--dim); border-color: transparent; font-size: 20px; font-weight: 400; }
.btn.link { background: transparent; color: var(--dim); border-color: transparent; font-size: 20px; font-weight: 400; text-decoration: underline; text-underline-offset: 4px; }
.btn:disabled { opacity: .5; cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.foot { margin-top: 8px; }
.meta { display: flex; justify-content: space-between; align-items: baseline; color: var(--dim); font-size: 22px; }
.meta .progress:only-child { margin-left: auto; }
.meta { gap: 16px; }
.prompt { font-size: 32px; font-weight: 400; line-height: 1.25; }
.sentence { font-size: 28px; color: var(--accent-ink); }
.msg { min-height: 1.4em; font-size: 24px; color: var(--accent-ink); }
.msg:empty { min-height: 0; }
.voice-note { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--accent-soft); border-radius: 16px; padding: 16px 20px; }

/* the one writing pad (class writepad; .pad is the PIN keypad) (lines are drawn inside the canvas; nothing here depends on the word) */
.writepad {
  position: relative; width: 100%; height: clamp(180px, 30dvh, 240px); flex: 0 0 auto;
  background: var(--panel); border-radius: 18px; box-shadow: inset 0 0 0 2px var(--box-line);
}
.writepad { user-select: none; -webkit-user-select: none; }
.writepad canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 18px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.writepad.locked canvas { cursor: default; }
.writepad.is-miss { background: var(--try-again-soft); box-shadow: inset 0 0 0 3px var(--try-again); }
.writepad.is-ok { box-shadow: inset 0 0 0 3px var(--correct); }
.writepad.is-unreadable { background: var(--accent-soft); box-shadow: inset 0 0 0 3px var(--accent-ink); }
.tick { position: absolute; top: 8px; right: 14px; color: var(--correct); font: 700 28px/1 var(--kid); pointer-events: none; }

/* outcomes */
.outcome { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.word-display { font-size: clamp(30px, 6.5vw, 52px); font-weight: 700; line-height: 1.2; letter-spacing: .02em; max-width: 100%; overflow-wrap: anywhere; }
.compare { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 20px; row-gap: 6px; align-items: baseline; width: 100%; }
.cmp-label { color: var(--dim); font-size: 22px; }
.word-display.written { font-weight: 400; }
.sweep, .hl {
  background-image: linear-gradient(var(--highlight), var(--highlight));
  background-repeat: no-repeat; background-position: 0 78%; background-size: 100% 58%; padding: 0 4px;
}
.hl { margin: 0 1px; }
.sweep { animation: sweep .3s ease-out both; }
@keyframes sweep { from { background-size: 0% 58%; } to { background-size: 100% 58%; } }
.fix { font-size: 28px; font-weight: 700; color: var(--try-again); }
.note { color: var(--text); }
.praise { font-size: 30px; font-weight: 700; color: var(--correct); }
.is-correct .praise::before { content: "\2713\00a0"; }
.sail { position: fixed; top: 20px; left: -48px; pointer-events: none; z-index: 5; }
.sail.glide { animation: glide .6s ease-in-out forwards; }
.sail.glide.long { animation-duration: 1.4s; }
@keyframes glide { to { transform: translateX(calc(100vw + 96px)); } }
.checking { display: flex; align-items: center; gap: 14px; color: var(--dim); min-height: 64px; }
.bar { position: relative; width: 160px; height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; display: inline-block; }
.bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--accent); border-radius: 4px; animation: slide 1s ease-in-out infinite alternate; }
@keyframes slide { to { transform: translateX(150%); } }

.sailfill-wrap { display: inline-flex; }
.sailfill { transform-box: fill-box; transform-origin: bottom; animation: sailfill 1.1s ease-in-out infinite; }
@keyframes sailfill { 0% { transform: scaleY(0); } 70%, 100% { transform: scaleY(1); } }

/* home */
.home-main { display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center; padding-top: 24px; }
.home-copy { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.home .prompt { font-size: 44px; font-weight: 700; }
.home .tag { font-size: 28px; color: var(--accent-ink); }
.home-art { width: 220px; height: 220px; border-radius: 48px; }
.score { font-size: 56px; font-weight: 700; }
.missed-list { margin: 0; padding-left: 28px; font-size: 28px; }

/* practice */
.wordgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.btn.word { font-size: 28px; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; padding: 12px 16px; min-width: 0; }
.btn.word.done { border-color: var(--correct); }
.tick-inline { color: var(--correct); }

/* overlay */
.overlay { position: fixed; inset: 0; background: rgba(20, 33, 43, .45); display: grid; place-items: center; padding: 24px; z-index: 20; }
.sheet { background: var(--panel); border-radius: 20px; padding: 28px; max-width: 520px; display: flex; flex-direction: column; gap: 20px; }

/* grown-ups: Geist, calmer, 44 px controls */
.grown { gap: 16px; }
.grown h1 { font-size: 28px; font-weight: 500; }
.grown h2 { font-size: 18px; font-weight: 500; }
.gtop { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-s {
  appearance: none; -webkit-appearance: none; min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--box-line); background: var(--panel); color: var(--text);
  font: 500 15px/1 var(--grown); cursor: pointer; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-s:active { transform: translateY(1px); }
.btn-s.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-s.big { min-height: 48px; padding: 0 20px; font-size: 16px; }
.btn-s:disabled { opacity: .5; }
.filebtn { position: relative; overflow: hidden; }
.file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.filebtn:focus-within { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #e6eef3; border-radius: 12px; align-self: flex-start; }
.tab { min-height: 44px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; color: var(--dim); font: 500 15px var(--grown); cursor: pointer; }
.tab.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(20, 33, 43, .12); }
.gcontent { display: flex; flex-direction: column; gap: 16px; }
.lead { font-size: 18px; }
.found { font-size: 17px; }
.notice { background: var(--correct-soft); color: var(--correct); border-radius: 10px; padding: 12px 14px; font-weight: 500; }
.error { color: var(--try-again); background: var(--try-again-soft); border-radius: 10px; padding: 12px 14px; }
.empty { color: var(--dim); background: var(--panel); border-radius: 12px; padding: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.field label, .addrow label { font-weight: 500; }
.input { min-height: 44px; padding: 8px 12px; border: 1px solid var(--box-line); border-radius: 8px; font: 400 16px var(--grown); background: var(--panel); color: var(--text); width: 100%; }
textarea.input { resize: vertical; line-height: 1.4; }
.table { display: flex; flex-direction: column; background: var(--panel); border-radius: 12px; overflow: hidden; border: 1px solid #d7e2e9; }
.thead, .trow { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(0, 2fr) auto; gap: 12px; padding: 10px 14px; align-items: start; }
.thead { color: var(--dim); font-size: 14px; background: #eef4f8; }
.trow + .trow, .thead + .trow { border-top: 1px solid #e3ebf0; }
.trow .cell.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 14px; color: var(--try-again); margin-top: 4px; }
.addrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.addrow .input { width: 240px; }
.reading { display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--panel); border-radius: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid #d7e2e9; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chip { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.words { color: var(--dim); font-size: 14px; }
.hist { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid #d7e2e9; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.missed { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.missed li { display: flex; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.missed .w, .words, .card h2, .trow .cell, .trow span { overflow-wrap: anywhere; min-width: 0; }
.missed .w { font-weight: 500; }
.hist-table .thead, .hist-table .trow { grid-template-columns: minmax(130px, 1fr) 80px minmax(0, 1.2fr); }
.hist-table { border: 0; }
.about { margin-top: 24px; padding-top: 16px; border-top: 1px solid #d7e2e9; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; color: var(--dim); font-size: 14px; }
.about .by { color: var(--keelwork-dim); font-size: 14px; }

/* pin pad */
.pinscreen { align-items: center; text-align: center; gap: 14px; padding-top: 24px; }
.pin-dots { display: flex; gap: 12px; min-height: 28px; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--box-line); background: var(--panel); }
.dot.on { background: var(--accent); border-color: var(--accent); }
.pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; margin-top: 6px; }
.key { height: 64px; border-radius: 14px; border: 2px solid var(--box-line); background: var(--panel); color: var(--text); font: 500 24px var(--grown); cursor: pointer; touch-action: manipulation; }
.key:active { transform: translateY(1px); }
.key[data-key=delete], .key.enter { font-size: 15px; }
.key.enter { background: var(--accent); border-color: var(--accent); color: #fff; }
.key:disabled { opacity: .45; }
.pinscreen .msg { font-size: 16px; min-height: 1.4em; }

@media (max-width: 767px) {
  .main { padding: 0 16px 32px; }
  .top { padding: 12px 16px 0; }
  .wordmark { height: 36px; }
  .prompt { font-size: 26px; }
  .home .prompt { font-size: 34px; }
  .home-main { grid-template-columns: 1fr; }
  .home-art { width: 120px; height: 120px; border-radius: 28px; order: -1; }
  .btn { padding: 0 20px; font-size: 22px; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .sentence { font-size: 18px; line-height: 1.3; }
  .meta { font-size: 20px; }
  .screen { gap: 14px; }
  .hist { grid-template-columns: 1fr; }
  .thead { display: none; }
  .trow { grid-template-columns: 1fr; }
  .hist-table .trow { grid-template-columns: 1fr; gap: 4px; }
  .pad { grid-template-columns: repeat(3, 64px); }
}
@media (max-width: 400px) {
  .write .actions, .trace .actions { gap: 8px; }
  .write .actions .btn, .trace .actions .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 20px; }
  .write .actions .btn[data-act=hear], .trace .actions .btn[data-act=hear] { flex: 1 1 100%; }
  .prompt { font-size: 22px; }
  .msg { font-size: 20px; }
  .writepad { height: clamp(180px, 25dvh, 240px); }
}
@media (prefers-reduced-motion: reduce) {
  .sweep { animation: none; }
  .bar::after { animation: none; width: 100%; }
  .sailfill { animation: none; }
  .btn, .btn-s, .key { transition: none; }
}

/* tablets and narrower: the editor row stacks the sentence under the word so long words fit */
@media (max-width: 1000px) {
  .thead { display: none; }
  .trow { grid-template-columns: minmax(0, 1fr) auto; }
  .trow .cell.sentence { grid-column: 1 / -1; grid-row: 2; }
}
/* short screens (Fire 7 on its side): tighten so the pad and Done are on screen together */
@media (max-height: 700px) {
  .top { padding-top: 8px; }
  .wordmark { height: 34px; }
  .screen { gap: 10px; padding-top: 6px; }
  .prompt { font-size: 26px; }
  .sentence { font-size: 22px; line-height: 1.3; }
  .meta { font-size: 20px; }
  .msg { font-size: 22px; }
  .writepad { height: 180px; }
}
@media (max-width: 600px) {
  .trow { grid-template-columns: minmax(0, 1fr); }
  .trow .cell.sentence { grid-column: auto; grid-row: auto; }
}

/* ======================================================================================================
   N6: the voyage. Each week's list is a sail from Home Harbor to Treasure Island. Everything below is
   decoration or surface for the fun modules in js/fx/*; text always sits on a solid white card.
   Motion rules: transform/opacity only, quiet while the pen is down (body.writing), calm when reduced.
   ====================================================================================================== */
:root { --wood: #c58a3f; --wood-dark: #8a521d; --press: #075a75; }

/* header: wordmark pill, the sailing band (quiz progress) in the middle, sound toggle at the right */
.top { gap: 12px 14px; flex-wrap: wrap; padding-bottom: 8px; }
.brand { flex: none; display: flex; align-items: center; background: #fff; border-radius: 18px; padding: 6px 14px; box-shadow: 0 3px 0 rgba(7, 90, 117, .22); }
.top .wordmark { height: 44px; }
.stage { flex: 1 1 260px; min-width: 0; height: 84px; border-radius: 18px; overflow: hidden; box-shadow: 0 3px 0 rgba(7, 90, 117, .28); isolation: isolate; }
.stage .sx-scene.sx-band { height: 100%; border-radius: 0; }
.stage[data-mode="strip"] { height: 52px; flex-basis: 200px; }
.tools { flex: none; margin-left: auto; }
.stage:not([hidden]) ~ .tools { margin-left: 0; }

/* an empty status line takes no space (it stays in the page for screen readers) */
.msg:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.write .sentence, .trace .sentence { font-size: clamp(20px, 2.3vw, 24px); line-height: 1.25; }
.screen { gap: 14px; }

/* the page */
body[data-area="kid"] { background: linear-gradient(#d3eef8, var(--bg) 360px) no-repeat, var(--bg); }
body[data-area="kid"][data-screen="home"], body[data-area="kid"][data-screen="summary"], body[data-area="kid"][data-screen="practice"] { background: var(--sky-bottom, #dff4fb); }
body[data-area="grown"] { background: linear-gradient(#dff0f7, var(--bg) 220px) no-repeat, var(--bg); }

.card-kid {
  background: #fff; border-radius: 26px; padding: 20px 26px;
  box-shadow: 0 6px 0 rgba(7, 90, 117, .2), 0 16px 26px -14px rgba(20, 33, 43, .35);
}

/* buttons: tactile, a hard bottom edge that squishes down when pressed */
.btn { transition: transform .09s ease-out, box-shadow .09s ease-out; margin-bottom: 5px; }
.btn.primary { box-shadow: 0 5px 0 var(--press); }
.btn.secondary { box-shadow: 0 5px 0 #a9bac4; }
.btn.ghost, .btn.link { box-shadow: none; }
.btn:active { filter: none; }
.btn.primary:active, .btn.secondary:active { transform: translateY(4px) scale(1.02, .95); box-shadow: 0 1px 0 var(--press); }
.btn.secondary:active { box-shadow: 0 1px 0 #a9bac4; }
.btn:focus-visible { outline-offset: 3px; }
.fxb-sound { background: #fff; }

/* Home */
.home-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding-top: 22px; }
.home .home-main.card-kid { padding: 22px 28px; }
.home-copy { gap: 10px; }
.home .prompt { font-size: 40px; line-height: 1.15; }
.home .tag { font-size: 26px; }
.home-mate, .practice-mate, .summary-mate { display: flex; justify-content: flex-end; align-items: flex-end; }
.home-mate .pip-bubble, .summary-mate .pip-bubble { max-width: 300px; font-size: 22px; }
.home-map { margin-top: 4px; }
.home .foot, .summary .foot { margin-top: 0; }
.home .btn.link { background: #fff; border-radius: 14px; padding: 0 18px; color: var(--accent-ink); text-decoration: none; font-weight: 700; font-size: 20px; box-shadow: 0 3px 0 rgba(7, 90, 117, .2); }

/* the question screens: prompt on the left, Pip beside it, then the lined paper pad */
.meta { align-items: center; }
.streak { background: var(--highlight); color: #14212b; border-radius: 999px; padding: 0 14px; line-height: 1.25; font-weight: 700; font-size: 22px; box-shadow: 0 3px 0 rgba(138, 98, 0, .45); animation: chip-in .4s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes chip-in { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.headrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.headcopy { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mate { width: 60px; display: flex; justify-content: flex-end; align-self: start; min-width: 0; }
.mate .pip { max-width: 100%; }
.mate .pip-bubble { font-size: 20px; line-height: 1.2; max-width: 260px; padding: 5px 12px; }
@media (min-width: 900px) {
  .mate { width: 340px; }
  .mate .pip { width: 100%; justify-content: flex-start; }
}
.outcome-mate { display: flex; align-self: stretch; min-height: 0; }
.outcome-mate:empty { display: none; }
.outcome-mate .pip-bubble { font-size: 22px; max-width: min(24em, 70vw); }
.outcome { gap: 12px; }

/* lined paper in a wooden frame; a gold shimmer after each stroke lands */
.writepad { --trim: 0 0 0 6px var(--wood), 0 0 0 8px var(--wood-dark), 0 14px 18px -6px rgba(20, 33, 43, .4); --ring: inset 0 0 0 2px var(--box-line); width: calc(100% - 16px); margin: 8px; background: #fffef8; box-shadow: var(--trim); }
.writepad::after { content: ""; position: absolute; inset: 0; border-radius: 18px; box-shadow: var(--ring); pointer-events: none; z-index: 1; }
.writepad.is-miss { --ring: inset 0 0 0 3px var(--try-again); box-shadow: var(--trim); }
.writepad.is-ok { --ring: inset 0 0 0 3px var(--correct); box-shadow: var(--trim); }
.writepad.is-unreadable { --ring: inset 0 0 0 3px var(--accent-ink); box-shadow: var(--trim); }
.writepad::before { content: ""; position: absolute; inset: 0; border-radius: 18px; background: linear-gradient(105deg, rgba(255, 216, 77, 0) 28%, rgba(255, 216, 77, .42) 50%, rgba(255, 216, 77, 0) 72%); opacity: 0; pointer-events: none; z-index: 1; }
.writepad.shimmer::before { animation: shimmer .7s ease-out; }
@keyframes shimmer { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
.tick { z-index: 2; }

/* nothing moves in or next to the pad while the pen is down */
body.writing .pip *, body.writing .sx-scene *, body.writing .sx-boat * { animation-play-state: paused !important; }

/* tracing: the gold star */
.goldstar { width: 64px; height: 64px; display: block; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 5l8.2 17.6 19.2 2.3-14.2 13.1 3.8 19L32 47.2 15 57l3.8-19L4.6 24.9l19.2-2.3z' fill='%23ffd84d' stroke='%238a6200' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M32 14l5 11 12 1.4-8.9 8.2' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' opacity='.7'/%3E%3C/svg%3E") center / contain no-repeat; animation: star-land .8s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes star-land { from { transform: translateY(-70px) scale(.3) rotate(-50deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Practice picker */
.practice-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 24px; }
.practice-mate .pip-bubble { font-size: 20px; max-width: 260px; }
.practice .card-kid .wordgrid { padding: 2px; }

/* Summary */
.summary-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.summary-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.chest-card { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; background: #fff3c8; overflow: visible; }
.chest-host { flex: 0 1 190px; min-width: 130px; min-height: 140px; display: flex; align-items: flex-end; }
.chest-host .fxb-chest { width: 100%; }
.summary-mate .pip { max-width: 100%; }
.summary-mate .pip-bubble { font-size: 20px; max-width: 220px; }
.summary-map { margin: 0; }
.log-title { font-size: 30px; font-weight: 700; margin-bottom: 8px; color: var(--accent-ink); }
.log { padding: 18px 26px; }
.missed-list { display: flex; flex-wrap: wrap; gap: 8px 12px; list-style: none; padding: 0; margin: 0; font-size: 28px; }
.missed-list li { background: var(--accent-soft); border-radius: 14px; padding: 4px 16px; overflow-wrap: anywhere; }
.summary .tip { font-size: 30px; font-weight: 700; color: var(--accent-ink); }
.summary .score { font-size: 52px; line-height: 1.1; }

/* Grown-ups: calm, a little sea in the header, Pip waves once */
.pipbar { display: flex; align-items: center; gap: 8px; }
.pipbar .pip-bubble { font-size: 20px; }

@media (max-width: 899px) {
  .summary-top { grid-template-columns: minmax(0, 1fr); }
  .chest-card { justify-content: flex-start; }
}
@media (max-width: 767px) {
  .stage { flex: 1 1 110px; height: 56px; }
  .screen { gap: 8px; }
  .top { padding: 8px 16px 6px; }
  .write .sentence { font-size: 18px; line-height: 1.15; }
  .writepad { margin: 6px; width: calc(100% - 12px); }
  .stage[data-mode="strip"] { height: 44px; }
  .top { flex-wrap: nowrap; }
  .fxb-sound-label { display: none; }
  .fxb-sound { padding: 0; width: 56px; justify-content: center; }
  .brand { padding: 4px 10px; }
  .top .wordmark { height: 30px; }
  .home-main { grid-template-columns: minmax(0, 1fr); }
  .home .home-main.card-kid { padding: 16px 18px; }
  .home .prompt { font-size: 30px; }
  .home .tag { font-size: 22px; }
  .home-mate { justify-content: flex-start; }
  .card-kid { padding: 14px 16px; border-radius: 22px; }
  .summary .score { font-size: 40px; }
  .practice-head { grid-template-columns: minmax(0, 1fr); }
  .practice-mate { justify-content: flex-start; }
  .log-title { font-size: 26px; }
  .missed-list { font-size: 24px; }
}
@media (max-width: 400px) {
  .mate { width: 52px; }
  .headrow { gap: 8px; }
  .writepad { height: 180px; }
  .write .prompt, .trace .prompt { font-size: 20px; }
}
/* short screens: the band gets thinner so the pad and Done stay on screen together */
@media (max-height: 700px) {
  .stage { height: 68px; }
  .writepad { margin: 6px; width: calc(100% - 12px); }
  .write .sentence, .trace .sentence { font-size: 20px; }
  .stage[data-mode="strip"] { height: 44px; }
  .top { padding-top: 6px; padding-bottom: 6px; }
  .brand { padding: 3px 12px; }
  .top .wordmark { height: 34px; }
  .home .prompt { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .streak, .goldstar { animation: none; }
  .writepad.shimmer::before { animation: none; }
  .btn.primary:active, .btn.secondary:active { transform: translateY(2px); }
}

/* question screens: the pad and the controls share ONE centred column, so on a wide monitor the buttons are not stranded at
   the far left under a wide pad */
.screen.write, .screen.trace { max-width: 920px; margin-inline: auto; width: 100%; }
.screen.write .actions, .screen.trace .actions { justify-content: center; }
.screen.write .foot, .screen.trace .foot { align-self: center; }

/* N8 math */
body[data-area="kid"][data-screen="math"] { background: var(--sky-bottom, #dff4fb); }
.msea { max-width: 1100px; margin-inline: auto; width: 100%; }
.msea-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 26px; }
.msea-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msea .prompt { font-size: 40px; font-weight: 700; line-height: 1.15; }
.msea .tag { font-size: 24px; color: var(--accent-ink); margin: 0; }
.msea-mate { display: flex; justify-content: flex-end; align-items: flex-end; }
.msea-mate .pip-bubble { max-width: 300px; font-size: 22px; }
.msea-title { font-size: 24px; font-weight: 700; margin: 0 0 12px; line-height: 1.25; color: var(--accent-ink); }
.msea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; }
.isle-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 148px; padding: 12px 10px 14px;
  font-family: var(--kid); color: var(--text); background: #fff; border: 3px solid var(--box-line); border-radius: 22px; cursor: pointer;
  box-shadow: 0 5px 0 #a9bac4; transition: transform .09s ease-out, box-shadow .09s ease-out;
}
.isle-tile:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #a9bac4; }
.isle-tile.is-done { border-color: var(--correct); background: var(--correct-soft); }
.isle-tile.is-locked { background: #eef3f6; border-style: dashed; cursor: default; box-shadow: none; color: var(--dim); }
.msea-art { display: block; height: 44px; }
.isle-label { font-size: 30px; font-weight: 700; line-height: 1.1; }
.isle-count { font-size: 18px; line-height: 1.25; text-align: center; color: var(--dim); }
.isle-bar { display: block; width: 86%; height: 10px; border-radius: 6px; background: #d6e4ec; overflow: hidden; margin-top: auto; }
.isle-bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.is-done .isle-bar i { background: var(--correct); }
.isle-star { position: absolute; top: 6px; right: 10px; font-size: 24px; color: #d99a00; line-height: 1; }
.math-round .prompt { font-size: clamp(46px, 9vw, 72px); font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.math-star { margin-left: .4em; color: #d99a00; }
@media (max-width: 767px) {
  .msea .prompt { font-size: 32px; }
  .msea .tag { font-size: 20px; }
  .msea-head { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; }
  .msea-mate { justify-content: flex-start; }
  .msea-title { font-size: 20px; }
  .math-round .prompt { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) { .isle-tile { transition: none; } }
/* N9: test day, treasures, My ship */
body[data-area="kid"][data-screen="testscore"], body[data-area="kid"][data-screen="reveal"], body[data-area="kid"][data-screen="ship"] { background: var(--sky-bottom, #dff4fb); }
.home .actions { gap: 12px; }
.treasure-card { display: flex; flex-direction: column; gap: 12px; background: #fff3c8; opacity: 1; }
.treasure-card.is-in { animation: tr-pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.treasure-title { font-size: 28px; margin: 0; color: var(--accent-ink); }
.treasure-new { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; }
.treasure-item { display: grid; justify-items: center; gap: 2px; min-width: 130px; padding: 8px 12px; border-radius: 20px; background: #fff; border: 4px solid #9fd0e0; font-size: 20px; text-align: center; color: var(--accent-ink); }
.treasure-item.tier-special { border-color: #ffd84d; }
.treasure-item.tier-legendary { border-color: #ff7a5c; }
.treasure-name { font-weight: 700; font-size: 20px; }
.treasure-tier { font-size: 18px; }
.treasure-art svg { display: block; }
@keyframes tr-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .treasure-card.is-in { animation: tr-fade .3s ease-out; }
  @keyframes tr-fade { from { opacity: 0; } to { opacity: 1; } }
}
.testscore .missed-list { font-size: 28px; }
.ship-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ship-head .dim { margin: 4px 0 0; font-size: 20px; }
.ship-mate { display: flex; justify-content: flex-end; }
.ship-card { padding: 12px; background: #dff4fb; }
.ship-stage { max-width: 820px; margin-inline: auto; }
.ship-stage > svg { width: 100%; height: auto; display: block; }
.locker { display: grid; gap: 14px; }
.locker-card .log-title { margin: 0 0 10px; }
.locker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.locker-item { display: grid; justify-items: center; align-content: start; gap: 2px; padding: 8px 6px; min-height: 56px; border-radius: 20px; border: 4px solid #9fd0e0; background: #fff; font-size: 18px; line-height: 1.15; text-align: center; color: var(--accent-ink); height: auto; }
.locker-item.tier-special { border-color: #ffd84d; }
.locker-item.tier-legendary { border-color: #ff7a5c; }
.locker-item.locked { background: #eef3f6; border-style: dashed; border-color: #b9c9d2; }
.locker-item.on { background: #fff3c8; box-shadow: 0 0 0 4px var(--accent-ink); }
.locker-name { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 480px) { .locker-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); } .treasure-item { min-width: 110px; } }
.locker-item.btn { white-space: normal; min-width: 0; width: 100%; padding: 8px 4px; font-weight: 600; }
.locker-name { display: block; max-width: 100%; white-space: normal; }

/* N10 */
/* Home: Set sail is the primary button on its own row; the four other places form one tidy secondary group (2 x 2 on phones) */
.home-actions { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; width: 100%; }
.home-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 520px; }
.home-more .btn { min-width: 0; line-height: 1.1; padding: 0 12px; white-space: normal; }
@media (max-width: 900px) { .home-more .btn { font-size: 22px; } }
@media (max-width: 600px) {
  .home-actions .btn.primary { width: 100%; }
  .home-more .btn { padding: 0 8px; font-size: 20px; }
}
.treasure-all { margin: 0; font-size: 24px; font-weight: 700; color: var(--accent-ink); }
/* long hints wrap without a stranded last word */
.hint, [data-role=hint] { text-wrap: pretty; }
.msea-shared { margin: 0; padding: 0 6px; font-size: 20px; color: var(--accent-ink); text-wrap: balance; }

/* N11: the exit control at the top-left of every screen but Home */
.topbar { display: flex; justify-content: flex-start; }
.btn.topexit { min-height: 56px; padding: 0 22px; font-size: 22px; background: var(--panel); color: var(--accent-ink); border: 2px solid var(--accent-ink); box-shadow: 0 2px 0 rgba(7, 90, 117, .25); }
.btn-s.topexit { min-height: 48px; padding: 0 18px; font-size: 16px; font-weight: 600; color: var(--accent-ink); border: 2px solid var(--accent-ink); }
/* a footer "Home" that used to be a faint ghost is now a plain secondary button (see .btn.secondary) */
@media (max-width: 480px) { .btn.topexit { min-height: 56px; padding: 0 18px; font-size: 20px; } }
.pinscreen .topbar { align-self: flex-start; }
.meta { flex-wrap: wrap; gap: 6px 12px; align-items: center; } .meta .topbar { margin-right: auto; }
@media (max-width: 480px) { .meta .btn.topexit { min-height: 48px; padding: 0 14px; font-size: 20px; } .screen.write, .screen.trace { padding-top: 0; } .write .msg, .trace .msg { min-height: 1.1em; } }

/* N13: welcome / log in / new family screens and the account box (grown-up area) */
.welcome-actions { display: flex; flex-direction: column; gap: 14px; width: min(100%, 320px); margin-top: 8px; }
.welcome-actions .btn-s.big { min-height: 64px; font-size: 20px; justify-content: center; }
.pinscreen .field { display: flex; flex-direction: column; gap: 6px; width: min(100%, 320px); text-align: left; }
.pinscreen .field-label { font-size: 14px; color: var(--dim); }
.pinscreen .textin { height: 52px; border-radius: 12px; border: 2px solid var(--box-line); background: var(--panel); color: var(--text); font: 500 20px var(--grown); padding: 0 14px; width: 100%; box-sizing: border-box; }
.pinscreen .textin:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pinscreen .btn-s.big { min-width: 200px; justify-content: center; }
.pinscreen h1 { overflow-wrap: anywhere; }
.account { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.account p { margin: 0; }

/* Change list (lists screen) + the Home link to it */
.home-listrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.home-listrow p { margin: 0; }
.home .home-listrow .btn.link { min-height: 56px; }
.lists { display: flex; flex-direction: column; gap: 16px; max-width: 920px; margin: 0 auto; width: 100%; }
.lists-head { padding: 16px 24px; }
.lists-card h2 { margin: 0 0 6px; font-size: 30px; color: var(--accent-ink); }
.lists-card h3 { margin: 14px 0 8px; font-size: 22px; color: var(--accent-ink); }
.lists-note { margin: 0 0 14px; font-size: 22px; line-height: 1.3; }
.lists-now { margin: 0; font-size: 22px; font-weight: 700; color: var(--accent-ink); background: var(--panel); border-radius: 14px; padding: 10px 16px; align-self: flex-start; }
.lists-toggles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.lists-toggle { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; padding-top: 8px; padding-bottom: 8px; }
.lists-toggle[aria-pressed="true"] { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
.lists-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lists-pick.current { border-color: var(--accent); border-width: 3px; }
.lists-count { font-size: 18px; font-weight: 400; color: var(--dim); }
.lists-pick.current .lists-count { color: var(--accent-ink); font-weight: 700; }
@media (max-width: 600px) {
  .lists-card h2 { font-size: 24px; }
  .lists-note { font-size: 19px; }
}
