/* Layout: one-screen app. A winding island map (levels as islands, stories as stops) leads into a big-type reader, then a quiz, then a reward screen. */
:root {
  --bg: #e6f2fa;
  --paper: #ffffff;
  --ink: #16314b;
  --muted: #587087;
  --line: #c9dcea;
  --sea: #1667bd;
  --sea-soft: #d6e8f8;
  --sun: #f5b400;
  --sun-soft: #fff1bf;
  --leaf: #23935f;
  --leaf-soft: #d8f2e4;
  --coral: #e2574c;
  --coral-soft: #fde2df;
  --isle1: #ffd66b;
  --isle2: #8fd6a4;
  --isle3: #f4a28c;
  --shadow: 0 3px 0 rgba(22, 49, 75, .14);
  --f-display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --f-read: "Andika", "Verdana", "Segoe UI", sans-serif;
  --f-ui: "Andika", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1a28; --paper: #15273a; --ink: #e7f0f8; --muted: #9db2c6; --line: #2a4058;
    --sea: #63aef6; --sea-soft: #1b3550; --sun: #ffcf4d; --sun-soft: #3a3115;
    --leaf: #4cc68b; --leaf-soft: #173a2a; --coral: #ff8a7e; --coral-soft: #44221f;
    --isle1: #8a6d1f; --isle2: #2f6a45; --isle3: #81463a; --shadow: 0 3px 0 rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1a28; --paper: #15273a; --ink: #e7f0f8; --muted: #9db2c6; --line: #2a4058;
  --sea: #63aef6; --sea-soft: #1b3550; --sun: #ffcf4d; --sun-soft: #3a3115;
  --leaf: #4cc68b; --leaf-soft: #173a2a; --coral: #ff8a7e; --coral-soft: #44221f;
  --isle1: #8a6d1f; --isle2: #2f6a45; --isle3: #81463a; --shadow: 0 3px 0 rgba(0,0,0,.35);
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--f-ui); font-size: 17px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; }

.wrap { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); border-bottom: 2px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 10px; padding-block: 10px; }
.logo { font-family: var(--f-display); font-weight: 800; font-size: 24px; color: var(--sea); letter-spacing: -.01em; background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
.logo svg { width: 30px; height: 30px; flex: none; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--bg); border: 2px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.star { background: var(--sun-soft); border-color: transparent; }
.chip.fire { background: var(--coral-soft); border-color: transparent; }
button.chip:hover { border-color: var(--sea); }
.avatar-btn { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); font-size: 24px; display: grid; place-items: center; padding: 0; flex: none; }

main { padding-block: 20px 120px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px; padding: 12px 20px; font-family: var(--f-display); font-weight: 700; font-size: 19px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line), var(--shadow); transition: transform .08s; }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--sea); color: #fff; box-shadow: var(--shadow); }
:root[data-theme="dark"] .btn.primary { color: #08223d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #08223d; } }
.btn.go { background: var(--leaf); color: #fff; box-shadow: var(--shadow); }
.btn.big { font-size: 22px; padding: 16px 26px; border-radius: 20px; }
.btn.small { font-size: 16px; padding: 8px 14px; border-radius: 12px; }
.btn[aria-pressed="true"] { background: var(--sea-soft); box-shadow: inset 0 0 0 2px var(--sea); }
.btn:disabled { opacity: .5; cursor: default; }

/* welcome / profiles */
.hero { display: grid; gap: 14px; padding-block: 10px 24px; }
.hero h1 { font-size: clamp(32px, 7vw, 46px); color: var(--ink); }
.hero p { margin: 0; color: var(--muted); max-width: 52ch; font-size: 18px; }
.readers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.reader-card { background: var(--paper); border: 0; border-radius: 22px; padding: 18px 12px; display: grid; justify-items: center; gap: 6px; box-shadow: inset 0 0 0 2px var(--line), var(--shadow); }
.reader-card:hover { box-shadow: inset 0 0 0 3px var(--sea), var(--shadow); }
.reader-card .face { font-size: 54px; line-height: 1; }
.reader-card .nm { font-family: var(--f-display); font-weight: 700; font-size: 22px; }
.reader-card .meta { color: var(--muted); font-size: 14px; }
.reader-card.add { background: transparent; box-shadow: inset 0 0 0 2px var(--line); border: 2px dashed transparent; }
.reader-card.add .face { font-size: 40px; color: var(--sea); font-family: var(--f-display); }

.panel { background: var(--paper); border-radius: 22px; padding: 22px; box-shadow: inset 0 0 0 2px var(--line); display: grid; gap: 18px; }
.panel h2 { font-size: 26px; }
.field { display: grid; gap: 8px; }
.field > label, .field > .lbl { font-weight: 700; }
.field input[type=text] { font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { border: 0; border-radius: 14px; padding: 10px 14px; background: var(--bg); box-shadow: inset 0 0 0 2px var(--line); display: grid; gap: 2px; text-align: left; }
.choice.emoji { font-size: 30px; padding: 8px 12px; line-height: 1.1; }
.choice[aria-checked="true"] { background: var(--sea-soft); box-shadow: inset 0 0 0 3px var(--sea); }
.choice small { color: var(--muted); font-size: 14px; }
.choice b { font-family: var(--f-display); font-size: 18px; }
.parents { color: var(--muted); font-size: 15px; max-width: 62ch; margin-top: 26px; }
.parents b { color: var(--ink); }

/* map */
.greet { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.greet h1 { font-size: clamp(26px, 6vw, 34px); }
.greet p { margin: 2px 0 0; color: var(--muted); }
.map { position: relative; display: grid; gap: 26px; }
.map svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.trail path { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 14; }
.island { position: relative; border-radius: 34px; padding: 16px 12px 22px; background: color-mix(in srgb, var(--isle) 38%, var(--bg)); }
.isle-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 0 8px 4px; }
.isle-head h2 { font-size: 24px; }
.isle-head .lvl { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); display: block; }
.isle-head .cnt { font-weight: 700; font-variant-numeric: tabular-nums; }
.stops { display: grid; gap: 6px; position: relative; z-index: 2; }
.stop { display: flex; }
.stop.l { justify-content: flex-start; padding-left: 6%; }
.stop.c { justify-content: center; }
.stop.r { justify-content: flex-end; padding-right: 6%; }
.node { background: none; border: 0; padding: 4px; display: grid; justify-items: center; gap: 4px; width: 140px; }
.node .disc { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 40px; background: var(--paper); box-shadow: inset 0 0 0 4px var(--line), 0 5px 0 rgba(22,49,75,.16); position: relative; }
.node.done .disc { box-shadow: inset 0 0 0 4px var(--leaf), 0 5px 0 rgba(22,49,75,.16); }
.node.next .disc { box-shadow: inset 0 0 0 5px var(--sea), 0 5px 0 rgba(22,49,75,.16); animation: bob 1.6s ease-in-out infinite; }
.node.locked { cursor: default; }
.node.locked .disc { background: var(--bg); filter: grayscale(1); opacity: .55; }
.node .lock { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-size: 16px; box-shadow: inset 0 0 0 2px var(--line); filter: none; }
.node .t { font-family: var(--f-display); font-weight: 700; font-size: 16px; line-height: 1.15; text-align: center; }
.node.locked .t { color: var(--muted); }
.node .go-tag { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); background: var(--sea); color: #fff; font-family: var(--f-display); font-size: 13px; font-weight: 700; padding: 1px 10px; border-radius: 999px; white-space: nowrap; }
.stars { display: inline-flex; gap: 1px; font-size: 16px; line-height: 1; }
.stars .off { opacity: .22; filter: grayscale(1); }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }

/* reader */
.rbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.story { background: var(--paper); border-radius: 26px; padding: 26px clamp(18px, 4vw, 40px) 30px; box-shadow: inset 0 0 0 2px var(--line); }
.story .cover { font-size: 64px; line-height: 1; }
.story h1 { font-size: clamp(28px, 6vw, 38px); margin: 8px 0 4px; }
.story .hint { color: var(--muted); font-size: 15px; margin: 0 0 18px; }
.text { font-family: var(--f-read); font-size: var(--rs, 24px); line-height: 1.85; max-width: 34em; word-spacing: .08em; }
.sent { border-radius: 8px; transition: background .2s; padding: 2px 0; }
.sent.on { background: var(--sun-soft); box-shadow: 0 0 0 4px var(--sun-soft); }
.w { font: inherit; background: none; border: 0; padding: 0 1px; margin: 0; border-radius: 6px; color: inherit; line-height: inherit; }
.w.known { text-decoration: underline dotted var(--sea); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.w:hover { background: var(--sea-soft); }
.w.picked { background: var(--sea-soft); }
.rfoot { display: flex; justify-content: center; margin-top: 22px; }

/* word sheet */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; padding: 0 max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.sheet-card { pointer-events: auto; width: min(560px, 100%); background: var(--paper); border-radius: 24px; padding: 18px 20px; box-shadow: 0 0 0 2px var(--line), 0 14px 40px rgba(0,0,0,.25); display: grid; gap: 10px; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet-top { display: flex; align-items: flex-start; gap: 12px; }
.sheet-word { font-family: var(--f-read); font-size: 34px; font-weight: 700; line-height: 1.1; }
.sheet-base { color: var(--muted); font-size: 16px; }
.sheet-mean { font-size: 20px; }
.sheet-mean b { color: var(--sea); }
.sheet-new { color: var(--leaf); font-weight: 700; font-size: 15px; }
.sheet-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.x { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg); font-size: 20px; flex: none; }

/* quiz */
.qwrap { display: grid; gap: 18px; }
.dots { display: flex; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dot.ok { background: var(--leaf); }
.dot.meh { background: var(--sun); }
.dot.cur { box-shadow: 0 0 0 3px var(--sea); background: var(--paper); }
.qcard { background: var(--paper); border-radius: 26px; padding: 24px clamp(18px, 4vw, 34px); box-shadow: inset 0 0 0 2px var(--line); display: grid; gap: 18px; }
.qhead { display: flex; gap: 12px; align-items: flex-start; }
.qtext { font-family: var(--f-read); font-size: 26px; font-weight: 700; line-height: 1.3; flex: 1; min-width: 0; }
.qkind { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; font-family: var(--f-read); font-size: 22px; padding: 14px 18px; border-radius: 18px; border: 0; background: var(--bg); box-shadow: inset 0 0 0 2px var(--line); }
.opt:hover:not(:disabled) { box-shadow: inset 0 0 0 3px var(--sea); }
.opt.right { background: var(--leaf-soft); box-shadow: inset 0 0 0 3px var(--leaf); }
.opt.wrong { background: var(--coral-soft); box-shadow: inset 0 0 0 2px var(--coral); opacity: .7; animation: shake .35s; }
.opt:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
.feedback { min-height: 1.6em; font-weight: 700; font-size: 18px; }
.feedback.good { color: var(--leaf); }
.feedback.try { color: var(--coral); }
.slot { min-height: 64px; border-radius: 18px; border: 3px dashed var(--line); padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.slot.right { border-style: solid; border-color: var(--leaf); background: var(--leaf-soft); }
.pool { display: flex; flex-wrap: wrap; gap: 10px; }
.tile { font-family: var(--f-read); font-size: 22px; padding: 8px 14px; border-radius: 14px; border: 0; background: var(--sun-soft); box-shadow: inset 0 0 0 2px var(--sun), 0 3px 0 rgba(22,49,75,.12); }
.slot .tile { background: var(--paper); box-shadow: inset 0 0 0 2px var(--sea); }
.qfoot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* done */
.done { text-align: center; display: grid; gap: 16px; justify-items: center; padding-top: 10px; }
.done h1 { font-size: clamp(30px, 7vw, 44px); }
.bigstars { display: flex; gap: 10px; font-size: 64px; line-height: 1; }
.bigstars span { display: inline-block; animation: pop .5s cubic-bezier(.3,1.6,.5,1) both; }
.bigstars span.off { opacity: .2; filter: grayscale(1); }
.bigstars span:nth-child(2) { animation-delay: .25s } .bigstars span:nth-child(3) { animation-delay: .5s }
@keyframes pop { from { transform: scale(0) rotate(-30deg) } to { transform: none } }
.done > * { max-width: 100%; }
.done p { margin: 0; color: var(--muted); font-size: 18px; max-width: 44ch; }
.tally { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; width: 100%; }
.badge { background: var(--paper); border-radius: 20px; padding: 16px 10px; text-align: center; box-shadow: inset 0 0 0 2px var(--line); display: grid; gap: 4px; justify-items: center; }
.badge .ic { font-size: 40px; line-height: 1; }
.badge b { font-family: var(--f-display); font-size: 17px; line-height: 1.2; }
.badge small { color: var(--muted); font-size: 14px; line-height: 1.3; }
.badge.off .ic { filter: grayscale(1); opacity: .3; }
.badge.off b { color: var(--muted); }
.badge.new { box-shadow: inset 0 0 0 3px var(--sun); background: var(--sun-soft); }
.acts { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* my stuff */
.sec { display: grid; gap: 14px; margin-top: 26px; }
.sec h2 { font-size: 24px; }
.wordlist { display: flex; flex-wrap: wrap; gap: 8px; }
.wpill { border: 0; border-radius: 999px; padding: 6px 14px; background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); font-family: var(--f-read); font-size: 18px; }
.wpill small { color: var(--muted); font-family: var(--f-ui); font-size: 14px; }
.muted { color: var(--muted); }
.danger { color: var(--coral); }
.note { background: var(--sun-soft); border-radius: 14px; padding: 10px 14px; font-size: 15px; }

canvas#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

@media (max-width: 480px) {
  .node { width: 112px; }
  .node .disc { width: 72px; height: 72px; font-size: 34px; }
  .stop.l { padding-left: 0; } .stop.r { padding-right: 0; }
  .top .chip { padding: 4px 9px; }
  .logo span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- v2 additions ---- */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.m0 { margin: 0; }
.center { align-self: center; }
.page-h { font-size: 34px; }
.tally.left { justify-content: flex-start; margin-top: 12px; }
.sec h2 .muted { font-size: 18px; }
.badges.narrow { max-width: 520px; }
.dotend { box-shadow: none !important; background: none !important; padding-left: 0 !important; }
.errbar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; margin: 0; }
.scene-wrap { border-radius: 18px; overflow: hidden; margin: -6px 0 6px; max-width: 520px; }
.scene { display: block; width: 100%; height: auto; }
.scene text { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.w.say { background: var(--sun); color: #16314b; }
.narrow-panel { max-width: 460px; }
.pcard { background: var(--paper); border-radius: 22px; padding: 20px; box-shadow: inset 0 0 0 2px var(--line); display: grid; gap: 12px; margin-top: 18px; min-width: 0; }
.pcard h3 { font-size: 18px; margin-top: 6px; }
.phead { display: flex; gap: 12px; align-items: center; }
.phead .face { font-size: 44px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kpis div { background: var(--bg); border-radius: 14px; padding: 10px 12px; display: grid; }
.kpis b { font-family: var(--f-display); font-size: 26px; font-variant-numeric: tabular-nums; }
.kpis span { color: var(--muted); font-size: 14px; }
.chart-wrap { overflow-x: auto; }
.chart { width: 100%; min-width: 380px; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--f-ui); }
.chart .bar { fill: var(--sea); opacity: .55; }
.chart .bar.today { opacity: 1; }
.tricky { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- family accounts ---- */
.field input[type=email], .field input[type=password] { font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.reader-card.boy { box-shadow: inset 0 0 0 2px var(--line), inset 0 -6px 0 var(--sea-soft), var(--shadow); }
.reader-card.girl { box-shadow: inset 0 0 0 2px var(--line), inset 0 -6px 0 var(--coral-soft), var(--shadow); }
.code-screen { display: grid; justify-items: center; gap: 14px; text-align: center; }
.code-screen h1 { font-size: clamp(28px, 6vw, 38px); }
.code-screen p { margin: 0; color: var(--muted); font-size: 18px; }
.big-face { font-size: 72px; line-height: 1; }
.center-row { justify-content: center; }

/* ---- PIN login and history ---- */
.pin-dots { display: flex; gap: 16px; }
.pin-dots.shake { animation: shake .35s; }
.pindot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--sea); background: transparent; }
.pindot.on { background: var(--sea); }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.key { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--paper); font-family: var(--f-display); font-size: 32px; font-weight: 700; box-shadow: inset 0 0 0 2px var(--line), var(--shadow); }
.key:active { transform: translateY(2px); }
.small-key { font-size: 24px; background: transparent; box-shadow: none; }
.pin-input { letter-spacing: .5em; font-variant-numeric: tabular-nums; max-width: 200px; }
.table-wrap { overflow-x: auto; }
.hist { width: 100%; border-collapse: collapse; font-size: 15px; }
.hist th { text-align: left; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; padding: 4px 8px 6px 0; border-bottom: 2px solid var(--line); }
.hist td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* bookshelf and chapter books */
.shelf-h { font-size: 24px; margin: 8px 0 6px; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 12px 0 4px; }
.book-card { display: flex; gap: 14px; align-items: stretch; text-align: left; background: var(--paper); border: 0; border-radius: 22px; padding: 14px; box-shadow: inset 0 0 0 3px var(--line), var(--shadow); color: var(--ink); font: inherit; }
.book-card.started { box-shadow: inset 0 0 0 4px var(--sea), var(--shadow); }
.book-card.finished { box-shadow: inset 0 0 0 4px var(--leaf), var(--shadow); }
.book-cover { flex: none; width: 76px; min-height: 100px; border-radius: 8px 16px 16px 8px; display: grid; place-items: center; font-size: 42px; background: linear-gradient(90deg, rgba(22,49,75,.18) 0 8px, transparent 8px), var(--sun-soft); }
.book-info { display: grid; gap: 4px; align-content: start; min-width: 0; }
.book-info b { font-family: var(--f-display); font-size: 20px; line-height: 1.15; }
.book-info small { color: var(--muted); font-size: 14px; line-height: 1.35; }
.book-prog { display: block; height: 10px; border-radius: 999px; background: var(--sea-soft); overflow: hidden; margin-top: 6px; }
.book-prog span { display: block; height: 100%; background: var(--leaf); border-radius: 999px; }
.book-cnt { font-weight: 700; font-size: 14px; }
.kicker { margin: 10px 0 0; color: var(--muted); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.linkbtn { background: none; border: 0; padding: 4px 0; margin-top: 10px; color: var(--sea); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* 3D emoji pictures (src/emoji.js): sized by the surrounding font size, like the emoji they replace */
img.emo { height: 1.15em; width: 1.15em; object-fit: contain; vertical-align: -0.22em; display: inline-block; pointer-events: none; user-select: none; }
.off img.emo, .locked img.emo { filter: grayscale(1); opacity: .5; }

/* Eli the owl: a speech bubble that guides the children */
.eli { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 16px; text-align: left; }
.eli-owl { flex: none; font-size: 64px; line-height: 1; animation: eli-bob 3s ease-in-out infinite; transform-origin: bottom center; }
.eli .bubble { position: relative; background: var(--paper); border-radius: 20px 20px 20px 6px; padding: 12px 16px; font-size: 17px; line-height: 1.4; box-shadow: inset 0 0 0 3px var(--line), var(--shadow); max-width: 52ch; margin-bottom: 18px; }
.eli .bubble::before { content: ""; position: absolute; left: -9px; bottom: 6px; width: 16px; height: 16px; background: var(--paper); box-shadow: inset 3px -3px 0 0 var(--line); transform: rotate(45deg) skew(10deg, 10deg); border-radius: 0 0 0 4px; }
@keyframes eli-bob { 0%, 100% { transform: translateY(0) rotate(0) } 50% { transform: translateY(-4px) rotate(-3deg) } }

/* book covers: each book in its own colours, with a big 3D picture */
.book-cover { width: 92px; min-height: 124px; border-radius: 6px 18px 18px 6px; background: radial-gradient(circle at 70% 25%, rgba(255,255,255,.45), transparent 55%), linear-gradient(160deg, var(--c1), var(--c2)); box-shadow: inset 8px 0 0 rgba(0,0,0,.14), inset 10px 0 0 rgba(255,255,255,.25), 0 4px 0 rgba(22,49,75,.18); font-size: 54px; }
.book-card { transition: transform .15s ease, box-shadow .15s ease; }
.book-card:hover, .book-card:focus-visible { transform: translateY(-3px) rotate(-.4deg); }
.book-card .book-art { display: inline-block; transition: transform .2s ease; filter: drop-shadow(0 4px 6px rgba(0,0,0,.25)); }
.book-card:hover .book-art { transform: scale(1.08) rotate(-4deg); }
.book-hero { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 28px; margin: 4px 0 14px; color: #fff; background: radial-gradient(circle at 85% 10%, rgba(255,255,255,.35), transparent 50%), linear-gradient(150deg, var(--c1), var(--c2)); box-shadow: var(--shadow); }
.book-hero .book-art { flex: none; font-size: 76px; line-height: 1; filter: drop-shadow(0 6px 8px rgba(0,0,0,.25)); }
.book-hero h1 { font-size: clamp(24px, 6vw, 32px); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.book-hero p { margin: 4px 0 0; font-size: 15px; line-height: 1.4; color: rgba(255,255,255,.95); }
@media (prefers-reduced-motion: reduce) { .eli-owl { animation: none; } .book-card, .book-card .book-art { transition: none; } }

/* game map: islands in a moving sea, with a boat, plants and an unlock animation */
:root { --sea1: #7cc8f2; --sea2: #3a9ad9; --sand: #f6dfa4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sea1: #1d4f7a; --sea2: #123657; --sand: #8a7442; } }
:root[data-theme="dark"] { --sea1: #1d4f7a; --sea2: #123657; --sand: #8a7442; }
.map { padding: 26px 14px 30px; border-radius: 34px; gap: 40px; overflow: hidden; isolation: isolate;
  background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.25), transparent 40%), linear-gradient(180deg, var(--sea1), var(--sea2)); }
.map::before { content: ""; position: absolute; inset: -40px; z-index: -1; opacity: .35; pointer-events: none;
  background: radial-gradient(ellipse 18px 6px at 50% 50%, rgba(255,255,255,.9) 40%, transparent 42%) 0 0 / 90px 60px,
              radial-gradient(ellipse 14px 5px at 50% 50%, rgba(255,255,255,.7) 40%, transparent 42%) 45px 30px / 90px 60px;
  animation: waves 9s linear infinite; }
@keyframes waves { to { transform: translate(90px, 60px); } }
.trail path { stroke: rgba(255,255,255,.85); stroke-width: 7; stroke-dasharray: 3 15; }
.island { border-radius: 46% 54% 48% 52% / 22% 26% 74% 78%; padding: 22px 14px 34px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--isle) 85%, #fff), var(--isle) 70%);
  box-shadow: 0 0 0 10px var(--sand), 0 0 0 20px rgba(255,255,255,.35), 0 18px 0 12px rgba(0,40,80,.18); }
.isle-head { justify-content: center; text-align: center; flex-direction: column; align-items: center; }
.isle-head h2 { font-size: 26px; color: #17324d; text-shadow: 0 2px 0 rgba(255,255,255,.5); }
.isle-head .lvl { color: rgba(23,50,77,.75); }
.isle-head .cnt { background: rgba(255,255,255,.75); color: #17324d; border-radius: 999px; padding: 0 12px; font-size: 15px; }
.island .isle-head { margin-bottom: 22px; }
.island .isle-head, .island .node { position: relative; z-index: 2; }
.island .node .t { color: #17324d; }
.island .node.locked .t { color: rgba(23,50,77,.55); }
.deco { position: absolute; font-size: 38px; line-height: 1; pointer-events: none; z-index: 1; filter: drop-shadow(0 4px 3px rgba(0,0,0,.18)); }
.deco.d1 { left: 4%; top: 8%; } .deco.d2 { right: 6%; bottom: 10%; font-size: 30px; } .deco.d3 { right: 8%; top: 30%; font-size: 30px; }
.boat { position: absolute; z-index: 3; top: 6px; right: 14px; font-size: 44px; animation: sail 6s ease-in-out infinite; pointer-events: none; }
@keyframes sail { 0%, 100% { transform: translate(0, 0) rotate(-4deg); } 50% { transform: translate(-30px, 6px) rotate(4deg); } }
.node .disc { background: radial-gradient(circle at 35% 30%, #fff, #e9f3fb 70%); box-shadow: inset 0 0 0 4px #fff, 0 6px 0 rgba(22,49,75,.25), 0 10px 18px rgba(22,49,75,.18); }
.node.done .disc { box-shadow: inset 0 0 0 5px var(--leaf), 0 6px 0 rgba(22,49,75,.25); }
.node.next .disc { box-shadow: inset 0 0 0 6px var(--sea), 0 0 0 8px rgba(255,255,255,.6), 0 6px 0 rgba(22,49,75,.25); }
.node.locked .disc { background: color-mix(in srgb, var(--isle) 55%, #fff); opacity: 1; filter: none; }
.node .check { position: absolute; right: -4px; bottom: -4px; width: 30px; height: 30px; border-radius: 50%; background: var(--leaf); color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 800; box-shadow: 0 0 0 3px #fff; }
.node.fresh .disc { animation: unlock 1.1s cubic-bezier(.3,1.6,.5,1) both, bob 1.6s 1.1s ease-in-out infinite; }
.node.fresh .disc::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 4px solid var(--sun); animation: ring 1.2s ease-out .2s both; }
@keyframes unlock { 0% { transform: scale(.4) rotate(-20deg); filter: grayscale(1); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; filter: none; } }
@keyframes ring { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .map::before, .boat, .node.fresh .disc, .node.fresh .disc::after { animation: none; } }

/* ---------- reader: a real book page ---------- */
:root { --page: #fffaf0; --page-edge: #efe2c6; --page-line: rgba(120,90,40,.10); --ribbon: #e2574c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --page: #1d2a38; --page-edge: #2c3d50; --page-line: rgba(255,255,255,.05); } }
:root[data-theme="dark"] { --page: #1d2a38; --page-edge: #2c3d50; --page-line: rgba(255,255,255,.05); }
.rbar:has(.rprog) { position: sticky; top: calc(var(--toph, 64px) + env(safe-area-inset-top, 0px)); z-index: 4; margin: -6px -8px 18px; padding: 10px 8px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-radius: 0 0 18px 18px; }
.btn.small.icon { padding: 8px 12px; min-width: 44px; }
.btn[aria-pressed="true"] { background: var(--sea-soft); box-shadow: inset 0 0 0 2px var(--sea), var(--shadow); }
.rprog { flex: 1 0 100%; display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 14px; color: var(--muted); }
.rprog-label { white-space: nowrap; }
.pips { display: flex; gap: 4px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.pips i.done { background: var(--leaf); }
.pips i.cur { background: var(--sea); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sea) 30%, transparent); }
.rprog-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.rprog-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffd36b, #f0913a); transition: width .3s ease; }
.rprog-bar.full i { background: linear-gradient(90deg, #4cc38a, #1f9a63); }
.story.page { position: relative; background:
    linear-gradient(90deg, rgba(0,0,0,.07), transparent 18px),
    radial-gradient(120% 80% at 70% 10%, transparent 60%, var(--page-line)),
    var(--page);
  border-radius: 8px 22px 22px 8px; padding-left: clamp(26px, 5vw, 48px);
  box-shadow: inset 4px 0 0 var(--page-edge), 4px 4px 0 -1px var(--page), 4px 4px 0 0 var(--page-edge), 8px 8px 0 -1px var(--page), 8px 8px 0 0 var(--page-edge), 0 14px 26px rgba(40,30,10,.14); }
.story.page .scene-wrap { border-radius: 14px; box-shadow: 0 0 0 6px #fff, 0 4px 12px rgba(0,0,0,.12); transform: rotate(-1deg); margin: 6px 4px 14px; }
.ribbon { position: absolute; top: -6px; right: 26px; width: 34px; padding: 12px 0 16px; text-align: center; background: var(--ribbon); color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 16px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); box-shadow: 0 3px 6px rgba(0,0,0,.2); z-index: 2; }
.folio { text-align: center; color: var(--muted); font-family: var(--f-display); font-weight: 700; margin: 24px 0 0; letter-spacing: .2em; }
@media (prefers-reduced-motion: reduce) { .rprog-bar i { transition: none; } }

/* ---------- star shop ---------- */
.ava { position: relative; display: inline-grid; place-items: center; line-height: 1; }
.ava-hat { position: absolute; left: 50%; top: -.42em; transform: translateX(-50%) rotate(-8deg); font-size: .62em; }
.ava-pet { position: absolute; right: -.38em; bottom: -.12em; font-size: .5em; }
.avatar-btn { overflow: visible; }
button.chip { border: 0; font: inherit; cursor: pointer; }
.chip.star { font-family: var(--f-display); font-weight: 700; color: var(--ink); }
.shop-hero { display: flex; align-items: center; gap: 22px; padding: 22px 22px 18px; border-radius: 26px; background: linear-gradient(135deg, #ffd36b, #f0913a); color: #3b2300; box-shadow: 0 5px 0 rgba(160,80,0,.25); margin-bottom: 14px; }
.shop-hero h1 { margin: 0; font-size: clamp(28px, 7vw, 38px); }
.shop-hero .ava.big { font-size: 64px; margin: 14px 10px 0 4px; }
.wallet { margin: 4px 0 0; font-family: var(--f-display); font-size: 19px; }
.wallet b { font-size: 26px; }
.tabs { display: flex; gap: 8px; margin: 16px 0 14px; overflow-x: auto; }
.tab { border: 0; border-radius: 999px; padding: 8px 16px; font-family: var(--f-display); font-weight: 700; font-size: 16px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--sea); color: #fff; box-shadow: none; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.shop-item { border: 0; border-radius: 22px; padding: 16px 10px 12px; display: grid; justify-items: center; gap: 6px; background: var(--paper); color: var(--ink); font-family: var(--f-display); font-size: 17px; box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 rgba(22,49,75,.12); transition: transform .1s; }
.shop-item:active { transform: translateY(2px); }
.shop-item .si-ic { font-size: 54px; line-height: 1.1; }
.shop-item .price { font-size: 15px; font-weight: 700; padding: 2px 12px; border-radius: 999px; background: var(--sun-soft); }
.shop-item.can { box-shadow: inset 0 0 0 3px var(--sun), 0 4px 0 rgba(160,110,0,.25); }
.shop-item.far .si-ic { filter: grayscale(.8); opacity: .55; }
.shop-item.far .price { background: var(--line); color: var(--muted); }
.shop-item.own .price { background: var(--leaf-soft); color: var(--leaf); }
.shop-item.worn { box-shadow: inset 0 0 0 3px var(--leaf), 0 4px 0 rgba(20,100,60,.2); }
.shop-sheet { text-align: center; }
.si-big { font-size: 96px; line-height: 1.2; margin: 6px 0 14px; }
.shop-cta { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; border: 0; border-radius: 22px; padding: 14px 18px; margin: 10px 0 4px; background: linear-gradient(135deg, #fff1bf, #ffd9a8); color: #3b2300; font-family: var(--f-display); box-shadow: 0 4px 0 rgba(160,80,0,.18); }
.shop-cta-ic { font-size: 40px; }
.shop-cta b { display: block; font-size: 20px; }
.shop-cta small { font-size: 15px; }
.shop-cta .muted { margin-left: auto; }
.sea-deco { position: absolute; z-index: 3; font-size: 42px; line-height: 1; pointer-events: none; filter: drop-shadow(0 4px 3px rgba(0,0,0,.2)); animation: drift 4s ease-in-out infinite; }
.sea-deco.sd0 { left: 3%; top: 27%; } .sea-deco.sd1 { right: 3%; top: 29.5%; } .sea-deco.sd2 { left: 3%; top: 61%; } .sea-deco.sd3 { right: 3%; top: 64%; }
.sea-deco.sd4 { right: 4%; top: 94%; } .sea-deco.sd5 { left: 6%; top: 31.5%; animation-delay: -2s; } .sea-deco.sd6 { right: 8%; top: 59%; animation-delay: -1s; } .sea-deco.sd7 { left: 40%; top: 97%; }
@keyframes drift { 50% { transform: translateY(-6px) rotate(3deg); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--paper); font-family: var(--f-display); font-weight: 700; font-size: 18px; padding: 12px 22px; border-radius: 999px; box-shadow: 0 8px 20px rgba(0,0,0,.25); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .sea-deco { animation: none; } }
