/* Lamplight. The palette and fonts match the study apps, so the platform and the apps look like one place. */
:root {
  color-scheme: dark;
  --night: #10142e; --deep: #181e44; --raise: #242b5c; --rim: rgba(196, 202, 255, .14);
  --text: #f2efe7; --soft: #b2b5d8; --faint: #8b8fba;
  --gold: #ffd86b; --good: #5fd88e; --bad: #ff8a6e;
  --display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --gap: clamp(.75rem, 1.4vw, 1.25rem);
  --pad: clamp(1rem, 2.6vw, 2.5rem);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}

/* The light theme (theme.js sets data-theme). The same names, with day colours.
   Text colours have their own tokens (--gold-ink, --good-ink, --bad-ink), because a fill colour is often too light for text. */
:root {
  --gold-ink: var(--gold); --good-ink: var(--good); --bad-ink: var(--bad); --on-gold: #14183a;
  --ink-mix: 100%; /* How much of a child or scene colour a text uses. The rest is --text. */
  --hover: rgba(196, 202, 255, .08); --outline: rgba(255, 255, 255, .08);
  --glow: #1d2452; --backdrop: rgba(6, 8, 22, .7); --art-base: #10142e; --star: 1;
  --shade: rgba(0, 0, 0, .25); --shade-far: rgba(0, 0, 0, .55);
}
:root[data-theme="light"] {
  color-scheme: light;
  --night: #f7f2e8; --deep: #ffffff; --raise: #ede6d6; --rim: rgba(40, 44, 90, .13);
  --text: #1d2142; --soft: #4a4e72; --faint: #676b8c;
  --gold: #ffc93d; --good: #2fa565; --bad: #e2553a;
  --gold-ink: #8a5a00; --good-ink: #17773f; --bad-ink: #b83a22;
  --ink-mix: 58%;
  --hover: rgba(40, 44, 90, .06); --outline: rgba(20, 24, 58, .08);
  --glow: #fff1cf; --backdrop: rgba(40, 36, 60, .35); --art-base: #fff6e0; --star: 0;
  --shade: rgba(40, 36, 70, .07); --shade-far: rgba(40, 36, 70, .2);
}
/* The town pictures stay at night in both themes, so their text keeps the night colours. */
:root[data-theme="light"] :is(.hero, .preview) {
  --night: #10142e; --deep: #181e44; --raise: #242b5c; --rim: rgba(196, 202, 255, .14);
  --text: #f2efe7; --soft: #b2b5d8; --faint: #8b8fba;
  --gold-ink: #ffd86b; --good-ink: #5fd88e; --bad-ink: #ff8a6e; --ink-mix: 100%; --hover: rgba(196, 202, 255, .08);
  color: var(--text);
}
/* The new theme grows as a circle from the switch (theme.js). No other movement during the change. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-swap *, .theme-swap *::before, .theme-swap *::after { transition: none !important; }

/* The theme switch: the sun and the moon change with opacity, scale and blur. */
.theme-icons { position: relative; display: grid; width: 1.25rem; height: 1.25rem; flex: none; }
.nav-item .theme-icons { width: 1.3rem; height: 1.3rem; }
.theme-ico { grid-area: 1 / 1; width: 100%; height: 100%; transition-property: opacity, transform, filter; transition-duration: .3s; transition-timing-function: cubic-bezier(.2, 0, 0, 1); }
.theme-ico.moon, [data-theme="light"] .theme-ico.sun { opacity: 0; transform: scale(.25) rotate(-45deg); filter: blur(4px); }
.theme-ico.sun, [data-theme="light"] .theme-ico.moon { opacity: 1; transform: none; filter: none; }
.theme-btn:active { transform: scale(.96); }
*, *::before, *::after { box-sizing: border-box; }
/* Text gets larger on large screens, so a wall monitor reads as well as a phone. */
html { height: 100%; font-size: clamp(16px, .5vw + 9.5px, 24px); -webkit-text-size-adjust: 100%; }
body { height: 100%; margin: 0; overflow: hidden; background: var(--night); color: var(--text); font-family: var(--body); line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.75rem); }
h2 { font-size: 1.35rem; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--gold-ink); outline-offset: 2px; }

/* ---------- Page frame ---------- */
.shell { height: 100dvh; display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.main { overflow-y: auto; overscroll-behavior: contain; outline: none; padding: calc(var(--pad) + var(--sat)) calc(var(--pad) + var(--sar)) calc(var(--pad) + var(--sab)) var(--pad); display: flex; flex-direction: column; gap: var(--gap);
  background: radial-gradient(90% 60% at 80% -10%, var(--glow) 0%, transparent 70%); }
.main > * { flex-shrink: 0; }

.nav { display: flex; flex-direction: column; gap: .25rem; padding: calc(1.25rem + var(--sat)) .75rem calc(.75rem + var(--sab)) calc(.75rem + var(--sal)); background: var(--deep); border-right: 1px solid var(--rim); overflow-y: auto; }
.brand { display: grid; grid-template-columns: .55rem .55rem 1fr; grid-template-rows: .55rem .55rem; gap: .14rem; padding: .25rem .6rem 1.1rem; align-items: center; }
.brand i { height: .55rem; background: var(--gold); border-radius: 2px; box-shadow: 0 0 8px rgba(255, 216, 107, .7); }
.brand i.off { background: var(--raise); box-shadow: none; }
.brand i:nth-child(3) { grid-area: 2 / 1; } .brand i:nth-child(4) { grid-area: 2 / 2; }
.brand b { grid-area: 1 / 3 / 3 / 4; font-family: var(--display); font-size: 1.3rem; font-weight: 800; padding-left: .5rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; min-height: 2.75rem; padding: .5rem .7rem; border: 0; border-radius: .7rem; background: none; color: var(--soft); font-weight: 700; text-align: left; transition: background .15s, color .15s; width: 100%; }
.nav-item svg { width: 1.3rem; height: 1.3rem; flex: none; }
.nav-item:hover { background: var(--raise); color: var(--text); }
.nav-item[aria-current] { background: var(--raise); color: var(--gold-ink); }
.nav-subs { display: flex; flex-direction: column; margin: 0 0 .35rem 1.3rem; padding-left: .5rem; border-left: 1px solid var(--rim); }
.nav-sub { display: flex; align-items: center; gap: .55rem; min-height: 2.2rem; padding: .2rem .5rem; border-radius: .5rem; color: var(--soft); font-size: .92rem; }
.nav-sub i { width: .6rem; height: .6rem; border-radius: 2px; background: var(--c); flex: none; }
.nav-sub:hover, .nav-sub[aria-current] { color: var(--text); background: var(--hover); }
.nav-full { margin-top: auto; font-weight: 400; }
/* The theme switch, Full screen and Grown-ups go at the bottom of the side menu. */
.nav-theme { margin-top: auto; font-weight: 400; }
.nav-theme ~ .nav-full, .nav-theme ~ .nav-grown { margin-top: 0; }
.gate { position: relative; }
.gate-tools { position: absolute; top: calc(.9rem + var(--sat)); right: calc(.9rem + var(--sar)); }
.nav-grown { margin-top: auto; font-weight: 400; }
.nav-full ~ .nav-grown { margin-top: 0; }
.nav-dot { position: absolute; top: .45rem; left: 1.75rem; width: .6rem; height: .6rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--night); }

/* ---------- Shared parts ---------- */
.card { display: block; background: var(--deep); border: 1px solid var(--rim); border-radius: 1rem; padding: 1rem 1.1rem; }
.eyebrow { display: block; font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: color-mix(in srgb, var(--c, var(--soft)) var(--ink-mix), var(--text)); text-transform: uppercase; }
.meter { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, .8rem); gap: .18rem; max-width: 100%; }
.meter i { height: .62rem; border-radius: 2px; background: color-mix(in srgb, var(--raise) calc((1 - var(--on)) * 100%), var(--c)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.75rem; padding: .5rem 1.2rem; border: 0; border-radius: .7rem; background: var(--gold); color: #14183a; font-weight: 700; transition: transform .12s var(--ease); }
.btn svg { width: 1.1rem; height: 1.1rem; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--raise); color: var(--text); }
.icon-btn { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border: 0; border-radius: .6rem; background: var(--raise); color: var(--text); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 2.5rem; padding: .3rem .9rem; border-radius: 99px; border: 1px solid var(--rim); color: var(--soft); font-weight: 700; font-size: .92rem; }
.chip:hover { color: var(--text); }
.chip[aria-current] { background: var(--c); border-color: var(--c); color: #14183a; }

/* Activity cards */
.cards { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.cards.split { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.act { position: relative; display: flex; gap: .9rem; align-items: flex-start; transition: transform .16s var(--ease), border-color .16s; }
@media (hover: hover) { .act:hover { transform: translateY(-2px); border-color: var(--c); } }
.act:active { transform: scale(.985); }
.act.locked { opacity: .55; }
.tile { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: .8rem; color: #14183a; background: var(--c); }
.tile svg { width: 1.6rem; height: 1.6rem; }
.act-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.act-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; line-height: 1.2; }
.act-blurb { color: var(--soft); font-size: .94rem; }
.act-body .meter { margin-top: .5rem; }
.act-stat { color: var(--faint); font-size: .8rem; }
.tick { position: absolute; top: .8rem; right: .8rem; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--raise); color: var(--good-ink); }
.tick svg { width: 1rem; height: 1rem; }

/* ---------- Today ---------- */
.hero { position: relative; border-radius: 1.25rem; overflow: hidden; border: 1px solid var(--rim); background: linear-gradient(#0e1230, #1a2150 80%); }
.hero-text { position: absolute; left: clamp(1rem, 2.4vw, 2rem); top: clamp(.8rem, 2vw, 1.6rem); right: 1rem; z-index: 1; pointer-events: none; }
.hero-text p { color: var(--soft); margin-top: .2rem; }
.town-sky { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.town { position: relative; z-index: 1; }
.town-spot { position: absolute; bottom: 0; display: flex; align-items: flex-end; justify-content: center; border-radius: .5rem; color: color-mix(in srgb, var(--c) var(--ink-mix), var(--text)); }
.town-spot span { display: flex; align-items: center; height: var(--foot); font-weight: 700; font-size: clamp(.68rem, 1.1vw, .95rem); white-space: nowrap; }
.town-spot:focus-visible { outline: 2px solid var(--c); outline-offset: -2px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.stat { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--deep); border: 1px solid var(--rim); border-radius: 1rem; min-width: 0; }
.stat-ico { flex: none; color: color-mix(in srgb, var(--c) var(--ink-mix), var(--text)); }
.stat-ico svg { width: 1.6rem; height: 1.6rem; }
.stat b { display: block; font-family: var(--mono); font-size: 1.3rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat small { color: var(--soft); font-size: .8rem; display: block; }
.stat .meter { margin-top: .3rem; }

.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: var(--gap); align-items: start; }
.today-main { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.today-main h2 { margin-top: .4rem; }
.plan { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.warm { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--gold); border-color: var(--gold); color: #14183a; transition: transform .16s var(--ease); --c: #6b5310; }
@media (hover: hover) { .warm:hover { transform: translateY(-2px); } }
.warm b { display: block; font-family: var(--display); font-size: 1.45rem; font-weight: 800; line-height: 1.15; }
.warm-note { font-size: .95rem; }
.warm-go { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: #14183a; color: var(--gold-ink); }
.warm-go svg { width: 1.5rem; height: 1.5rem; }
/* The note for grown-ups about drafts that wait. */
.drafts-note { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; border-color: var(--gold); color: var(--text); text-align: left; font: inherit; cursor: pointer; --c: var(--gold); }
.drafts-note b { display: block; font-family: var(--display); font-size: 1.2rem; font-weight: 800; }
.drafts-note .warm-go { background: var(--raise); }
.warm.is-done { background: var(--deep); border-color: var(--rim); color: var(--text); --c: var(--good); }
.warm.is-done .warm-note { color: var(--soft); }
.warm.is-done .warm-go { background: var(--raise); color: var(--good-ink); }
.fact { border-left: .3rem solid var(--c); }
.fact b { display: block; font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1.25; margin: .35rem 0 .5rem; text-wrap: pretty; }
.fact p { color: var(--soft); font-size: .95rem; }

/* ---------- Topics ---------- */
.topic { display: flex; flex-direction: column; gap: var(--gap); margin-top: .6rem; }
.topic-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .4rem 1.5rem; padding-bottom: .5rem; border-bottom: 2px solid var(--c); }
.topic-head h2 { color: color-mix(in srgb, var(--c) var(--ink-mix), var(--text)); font-size: 1.6rem; }
.topic-head p { color: var(--soft); }
.groups { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .3rem 2rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); }
.groups li { display: grid; grid-template-columns: minmax(0, 1fr) auto 3rem; gap: .7rem; align-items: center; font-size: .94rem; }
.groups li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groups small { font-family: var(--mono); color: var(--faint); text-align: right; }

/* ---------- Arcade ---------- */
.bank { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 2rem; --c: #36c4a9; }
.bank-time { display: block; font-family: var(--mono); font-size: 2.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: color-mix(in srgb, #36c4a9 var(--ink-mix), var(--text)); }
.bank.empty .bank-time { color: var(--bad-ink); }
.bank p { flex: 1 1 16rem; color: var(--soft); max-width: 46ch; }

/* ---------- Progress ---------- */
.prog-grid { display: grid; grid-template-columns: minmax(18rem, 2fr) minmax(0, 3fr); gap: var(--gap); align-items: start; }
.note { color: var(--soft); font-size: .92rem; margin-top: .75rem; }
.week { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; height: 12rem; margin-top: 1.2rem; padding-bottom: 1.5rem; }
.week-goal { position: absolute; left: 0; right: 0; margin-bottom: 1.5rem; border-top: 1px dashed var(--faint); pointer-events: none; }
.week-goal span { position: absolute; right: 0; top: -1.15rem; font-size: .72rem; color: var(--faint); }
.week-col { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .15rem; height: 100%; min-width: 0; }
.week-col span { width: 100%; max-width: 2.4rem; min-height: 2px; border-radius: .3rem .3rem 0 0; background: var(--raise); }
.week-col span.met { background: var(--gold); }
.week-col small { font-size: .74rem; color: var(--soft); font-family: var(--mono); min-height: 1.1em; }
.week-col small:last-child { position: absolute; bottom: -1.5rem; }
.prog-list { display: flex; flex-direction: column; gap: 1.1rem; }
.prog-sub h3 { display: flex; justify-content: space-between; color: color-mix(in srgb, var(--c) var(--ink-mix), var(--text)); font-size: 1.1rem; margin-bottom: .35rem; }
.prog-sub h3 small { font-family: var(--mono); font-weight: 500; font-size: .9rem; }
.prog-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .2rem 1rem; padding: .3rem 0; }
.prog-row small { display: block; color: var(--faint); font-size: .8rem; }

/* ---------- Warm-up ---------- */
.warmup { width: 100%; max-width: 46rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.2rem; flex: 1; }
.warm-head { display: flex; align-items: center; gap: 1rem; }
.warm-dots { display: flex; gap: .35rem; flex: 1; }
.warm-dots i { flex: 1; height: .6rem; border-radius: 2px; background: var(--raise); }
.warm-dots i.past { background: var(--gold); }
.warm-dots i.now { background: #8c7a45; }
.warm-card { display: flex; flex-direction: column; gap: 1rem; }
.warm-card h1 { font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.2; }
.choices { display: grid; gap: .6rem; }
.choice { display: flex; align-items: center; gap: .8rem; min-height: 3.2rem; padding: .6rem .9rem; text-align: left; border: 1px solid var(--rim); border-radius: .8rem; background: var(--deep); transition: border-color .12s, background .12s; }
.choice:not(:disabled):hover { border-color: var(--gold); }
.choice kbd { flex: none; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: .4rem; background: var(--raise); font-family: var(--mono); font-size: .85rem; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 18%, var(--deep)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--deep)); }
.choice:disabled { cursor: default; color: var(--text); }
.warm-why { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; animation: rise .25s var(--ease); }
.warm-why small { color: var(--faint); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.warm-end { align-items: center; text-align: center; padding-top: 12vh; }
.warm-end h1 { font-size: clamp(3rem, 8vw, 5rem); color: var(--gold-ink); font-family: var(--mono); }

/* Warm-up uses the whole screen on a phone. */
@media (max-width: 700px) { .focus-mode .nav { display: none; } }

/* ---------- Player ---------- */
.player { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--night); }
.player-bar { flex: none; display: flex; align-items: center; gap: .6rem; padding: calc(.3rem + var(--sat)) calc(.6rem + var(--sar)) .3rem calc(.6rem + var(--sal)); background: var(--deep); border-bottom: 1px solid var(--rim); }
.player-title { flex: 1; min-width: 0; font-family: var(--display); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; padding: .2rem .7rem; border-radius: 99px; background: var(--raise); color: var(--soft); font-family: var(--mono); font-size: .82rem; font-variant-numeric: tabular-nums; }
.pill.warn { background: var(--bad); color: #14183a; }
.player-stage { flex: 1; min-height: 0; padding-bottom: var(--sab); }
.player-stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.time-up { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: 1.5rem; text-align: center; }
.time-up p { color: var(--soft); }

/* ---------- Dialog and toast ---------- */
.dialog { width: min(26rem, calc(100vw - 2rem)); padding: 1.3rem; border: 1px solid var(--rim); border-radius: 1rem; background: var(--deep); color: var(--text); }
.dialog::backdrop { background: var(--backdrop); }
.dialog form { display: flex; flex-direction: column; gap: .8rem; }
.dialog input:not([type="checkbox"]) { width: 100%; min-height: 2.75rem; padding: .4rem .7rem; border: 1px solid var(--rim); border-radius: .6rem; background: var(--night); font-size: 1rem; margin-top: .2rem; }
.settings label { display: block; color: var(--soft); font-size: .92rem; }
.settings label.check { display: flex; flex-direction: row; align-items: center; gap: .6rem; color: var(--text); min-height: 2.75rem; }
.settings label.check input { width: 1.3rem; height: 1.3rem; accent-color: var(--gold); }
.dialog-row { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.toast { position: fixed; left: 50%; bottom: calc(5.5rem + var(--sab)); z-index: 20; transform: translate(-50%, 1rem); padding: .55rem 1rem; border-radius: .7rem; background: var(--raise); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); max-width: calc(100vw - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* The town needs its own space below the greeting on all but wide screens. */
@media (max-width: 1300px) {
  .hero-text { position: relative; left: auto; top: auto; right: auto; padding: 1rem 1rem .4rem; }
}

/* ---------- Tablet: a narrow rail ---------- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 5.2rem minmax(0, 1fr); }
  .nav { padding-inline: .4rem; align-items: stretch; }
  .brand { grid-template-columns: .55rem .55rem; justify-content: center; padding-inline: 0; }
  .brand b, .nav-subs { display: none; }
  .nav-item { flex-direction: column; gap: .15rem; padding: .5rem .1rem; font-size: .76rem; text-align: center; }
  .nav-dot { left: calc(50% + .45rem); }
  .today-grid, .prog-grid, .cards.split { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Phone: a bottom bar ---------- */
@media (max-width: 700px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .main { order: 1; padding-bottom: 1rem; }
  .nav { order: 2; flex-direction: row; justify-content: space-around; padding: .25rem calc(.25rem + var(--sar)) calc(.25rem + var(--sab)) calc(.25rem + var(--sal)); border-right: 0; border-top: 1px solid var(--rim); overflow: visible; }
  .brand, .nav-full { display: none; }
  .nav-grown { margin-top: 0; }
  .nav-item { flex: 1; min-height: 3.2rem; justify-content: center; }
  .nav-item[aria-current] { background: none; }
  .nav-item { white-space: nowrap; }
  .theme-word { display: none; }
  .stats { gap: .4rem; }
  .stat { flex-direction: column; align-items: flex-start; gap: .1rem; padding: .55rem .6rem; }
  .stat b { font-size: 1.1rem; }
  .stat .meter { display: none; }
    .player-title { font-size: .95rem; }
}

/* ---------- Movement ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.main > * { animation: rise .5s var(--ease) both; }
.main > :nth-child(2) { animation-delay: .07s; } .main > :nth-child(3) { animation-delay: .14s; }
.main > :nth-child(4) { animation-delay: .21s; } .main > :nth-child(n+5) { animation-delay: .28s; }
.cards > *, .plan > *, .prog-sub, .groups li { animation: rise .45s var(--ease) both; }
.cards > :nth-child(2), .plan > :nth-child(2), .prog-sub:nth-child(2), .groups li:nth-child(2) { animation-delay: .1s; }
.cards > :nth-child(3), .plan > :nth-child(3), .prog-sub:nth-child(3), .groups li:nth-child(3) { animation-delay: .18s; }
.prog-sub:nth-child(4), .groups li:nth-child(4) { animation-delay: .26s; }
.groups li:nth-child(n+5) { animation-delay: .32s; }

/* Meters light one window after the other. */
@keyframes meter-on { from { background: var(--raise); box-shadow: none; } 60% { box-shadow: 0 0 8px var(--c); } }
.meter i.on { animation: meter-on .35s calc(.3s + var(--k) * 45ms) both; }

/* Today */
.warm { position: relative; overflow: hidden; }
.warm:not(.is-done)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%); transform: translateX(-120%); animation: sheen 6s 1.5s ease-in-out infinite; }
@keyframes sheen { 25%, 100% { transform: translateX(120%); } }
.warm:not(.is-done) .warm-go { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 .5rem rgba(20, 24, 58, .14); } }
.tile { transition: transform .22s var(--ease); }
@media (hover: hover) { .act:hover .tile { transform: rotate(-6deg) scale(1.1); } }
.stat-ico svg { animation: float 3.6s ease-in-out infinite; }
.stat:nth-child(2) .stat-ico svg { animation-delay: -1.2s; } .stat:nth-child(3) .stat-ico svg { animation-delay: -2.4s; }
@keyframes float { 50% { transform: translateY(-3px); } }

/* Navigation */
.nav-item { position: relative; }
.nav-item[aria-current]::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px; border-radius: 2px; background: var(--gold); animation: grow .3s var(--ease); }
@keyframes grow { from { transform: scaleY(0); } }
.brand i:not(.off) { animation: brand 4s ease-in-out infinite; }
.brand i:nth-child(4) { animation-delay: -2s; }
@keyframes brand { 50% { opacity: .55; } }

/* Topics */
.topic-head { position: relative; overflow: hidden; min-height: 4.6rem; }
.topic-head > :not(.glyphs) { position: relative; z-index: 1; }
.glyphs { position: absolute; inset: 0 0 0 38%; display: flex; justify-content: space-around; align-items: center; pointer-events: none; }
.glyphs i { font: 800 1.7rem var(--display); color: color-mix(in srgb, var(--c) var(--ink-mix), var(--text)); opacity: .22; animation: glyph calc(5s + var(--i) * .7s) calc(var(--i) * -.9s) ease-in-out infinite alternate; }
@keyframes glyph { from { transform: translateY(-.8rem) rotate(-10deg); } to { transform: translateY(.8rem) rotate(10deg); opacity: .4; } }

/* Arcade */
.bank { position: relative; padding-top: 1.7rem; overflow: hidden; }
.bulbs { position: absolute; left: .7rem; right: .7rem; top: .6rem; display: flex; justify-content: space-between; }
.bulbs i { width: .42rem; height: .42rem; border-radius: 50%; background: var(--gold); opacity: .22; animation: chase 1.2s linear infinite; }
.bulbs i:nth-child(3n+2) { animation-delay: .4s; } .bulbs i:nth-child(3n) { animation-delay: .8s; }
@keyframes chase { 0%, 30% { opacity: 1; box-shadow: 0 0 7px var(--gold); } 40%, 100% { opacity: .22; box-shadow: none; } }
.bank.empty .bulbs i { animation: none; }
.bank-time { text-shadow: 0 0 18px rgba(54, 196, 169, .45); }
.game-card { overflow: hidden; }
.game-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, color-mix(in srgb, var(--c) 30%, transparent) 50%, transparent 60%); transform: translateX(-120%); transition: transform .6s var(--ease); pointer-events: none; }
@media (hover: hover) { .game-card:not(.locked):hover::after { transform: translateX(120%); } }

.game-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); flex: 1 0 auto; }
.game-card { position: relative; display: flex; flex-direction: column; padding: 0; transition: transform .16s var(--ease), border-color .16s; animation: rise .5s .2s var(--ease) both; }
.game-card + .game-card { animation-delay: .3s; }
.game-card.locked { opacity: .55; }
@media (hover: hover) { .game-card:hover { transform: translateY(-3px); border-color: var(--c); } }
.game-info { padding: 1rem 1.1rem; }
.preview { position: relative; display: block; flex: 1; min-height: clamp(9rem, 26vh, 22rem); overflow: hidden; background: linear-gradient(#0e1230, #1a2150); }
.pv-grid { display: grid; grid-template-columns: repeat(16, 1fr); grid-template-rows: repeat(6, 1fr); gap: .3rem; padding: .9rem; }
.pv-grid i { border-radius: .3rem; background: var(--hover); }
.pv-grid i.on { background: var(--v); animation: clear 5s calc(var(--c2) * 40ms + var(--r) * 1s) ease-in-out infinite; }
@keyframes clear { 0%, 66%, 100% { transform: none; opacity: 1; filter: none; } 72% { filter: brightness(1.8); transform: scale(1.1); } 80% { opacity: 0; transform: scale(.3); } 92% { opacity: 0; transform: translateY(-1.5rem); } }
/* A zero height with flex lets the card set the size, so that a redraw cannot change it. */
.pv-lane { flex: 1 1 0; width: 100%; height: 0; }
/* Chess: a board in perspective, and a knight that hops across it. */
.pv-chess { perspective: 40rem; display: grid; place-items: center; }
.pv-chess .board { width: min(70%, 16rem); aspect-ratio: 1; border-radius: .4rem; transform: rotateX(52deg) rotateZ(-8deg); background: repeating-conic-gradient(#7d74ad 0 25%, #e9dfc8 0 50%) 0 0 / 25% 25%; box-shadow: 0 1.5rem 2.5rem rgba(0, 0, 0, .5); }
.pv-chess b { position: absolute; left: 50%; top: 42%; font-size: clamp(2.6rem, 6vw, 4rem); line-height: 1; color: var(--gold-ink); text-shadow: 0 0 18px rgba(255, 216, 107, .6); animation: hop 4s var(--ease) infinite; }
@keyframes hop { 0%, 20% { transform: translate(-150%, 30%); } 35% { transform: translate(-90%, -60%); } 50%, 70% { transform: translate(-30%, 0); } 85% { transform: translate(-80%, -70%); } 100% { transform: translate(-150%, 30%); } }
.free-tag { position: absolute; top: .8rem; right: .8rem; padding: .25rem .6rem; border-radius: .5rem; background: var(--gold); color: #14183a; font: 500 .7rem var(--mono); text-transform: uppercase; letter-spacing: .08em; }

/* Progress */
.week-col span { transform-origin: bottom; animation: bar .6s calc(.2s + var(--k) * 60ms) var(--ease) both; }
@keyframes bar { from { transform: scaleY(0); } }

/* Warm-up */
.warm-card > * { animation: rise .4s var(--ease) both; }
.warm-card > h1 { animation-delay: .05s; }
.choice { animation: rise .35s var(--ease) both; }
.choice:nth-child(2) { animation-delay: .06s; } .choice:nth-child(3) { animation-delay: .12s; } .choice:nth-child(4) { animation-delay: .18s; }
.choice.right { animation: pop .35s var(--ease); }
.choice.wrong { animation: shake .35s; }
@keyframes pop { 40% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.warm-dots i { transition: background .3s; }

/* Player: the activity opens like a circle of light from the point that you tapped. */
.player:not([hidden]) { animation: iris .55s var(--ease) both; }
@keyframes iris { from { clip-path: circle(0 at var(--ox, 50%) var(--oy, 50%)); } to { clip-path: circle(150% at var(--ox, 50%) var(--oy, 50%)); } }
.player-bar { box-shadow: 0 2px 0 var(--c, var(--gold)); position: relative; z-index: 1; }
.player-stage { position: relative; }
.player-stage iframe { transition: opacity .3s; }
.player-stage.loading iframe { opacity: 0; }
.player-stage.loading::after { content: ""; position: absolute; left: 50%; top: 45%; width: 1.6rem; height: 2rem; margin-left: -.8rem; border-radius: 3px; background: var(--gold); box-shadow: 0 0 24px var(--gold); animation: lantern 1s ease-in-out infinite alternate; }
@keyframes lantern { to { opacity: .35; transform: scale(.9); } }
.pill.warn { animation: pulse-warn 1s ease-in-out infinite; }
@keyframes pulse-warn { 50% { transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Sign-in, PIN and profile picker (js/account.js) ---------- */
.gate { height: 100dvh; overflow: auto; display: grid; place-items: center; padding: calc(var(--pad) + var(--sat)) var(--pad) calc(var(--pad) + var(--sab)); }
.gate-card { width: min(30rem, 100%); display: flex; flex-direction: column; gap: 1rem; }
.gate-card .brand { display: grid; grid-template-columns: .55rem .55rem 1fr; justify-content: start; padding: 0 0 .5rem; }
/* The narrow-screen rules for the nav hide the brand name. The sign-in pages always show it. */
.gate-card .brand b { display: block; }
.gate-note { color: var(--soft); }
.gate-note.small { font-size: .88rem; color: var(--faint); }
.gate-dev { padding: .6rem .8rem; border: 1px dashed var(--gold); border-radius: .6rem; color: var(--gold-ink); font-size: .9rem; }
.gate-form { display: flex; flex-direction: column; gap: .8rem; }
.gate-form label, .settings label { display: flex; flex-direction: column; gap: .2rem; color: var(--soft); font-size: .92rem; }
.gate-form input, .gate-form select, .dialog select { width: 100%; min-height: 2.75rem; padding: .4rem .7rem; border: 1px solid var(--rim); border-radius: .6rem; background: var(--deep); color: var(--text); font: inherit; font-size: 1rem; }
.dialog select { background: var(--night); }
.gate-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.form-error { color: var(--bad-ink); font-weight: 700; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.small { min-height: 2.2rem; padding: .3rem .8rem; font-size: .9rem; }
.btn.danger { background: transparent; color: var(--bad-ink); border: 1px solid var(--bad); }
.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--gap); }
.kid { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.1rem .8rem; border: 1px solid var(--rim); border-radius: 1rem; background: var(--deep); color: var(--text); transition: transform .12s var(--ease), border-color .15s; }
.kid:hover { border-color: var(--c); }
.kid:active { transform: scale(.97); }
.kid small { color: var(--soft); }
.kid-face { display: grid; place-items: center; width: 3.6rem; height: 3.6rem; border-radius: 50%; background: var(--c); color: var(--on-gold); font-family: var(--display); font-size: 1.7rem; font-weight: 800; box-shadow: 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); }
.fam-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.fam-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; border: 1px solid var(--rim); border-radius: .7rem; }
.fam-list small { color: var(--soft); }
.dialog-row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.head-btns { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Module cards (Phase 2) */
.tick.gold { color: var(--on-gold); background: var(--gold); }
.mods-head { margin: 1.4rem 0 .6rem; font-family: var(--f-mono, "DM Mono", monospace); font-size: .75rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Classes (Phase 4) */
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--gap); }
.role { display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem; border: 1px solid var(--rim); border-radius: 1rem; background: var(--deep); color: var(--text); text-align: left; transition: border-color .15s, transform .12s var(--ease); }
.role:hover { border-color: var(--gold); }
.role:active { transform: scale(.98); }
.role strong { font-family: var(--display); font-size: 1.15rem; }
.role small { color: var(--soft); }

/* Privacy policy, terms and the teacher page (Phase 5) */
.doc { max-width: 46rem; margin: 0 auto; padding: 1.5rem var(--gap) 4rem; line-height: 1.6; }
.doc h1 { font-family: var(--display); font-size: 2.1rem; margin: .5rem 0 .2rem; }
.doc h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.doc a { color: var(--gold-ink); }
.doc ul, .doc ol { padding-left: 1.3rem; }
.doc li { margin: .25rem 0; }
.doc table { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: .95rem; }
.doc th, .doc td { padding: .5rem .6rem; border: 1px solid var(--rim); text-align: left; vertical-align: top; }
.doc th { color: var(--soft); }
.doc-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.doc-meta { color: var(--soft); }
.doc-links { margin-top: 2.5rem; color: var(--soft); }
.admin-acts { display: flex; flex-wrap: wrap; gap: .4rem; }
.admin-msg:empty { display: none; }
.admin-msg { padding: .6rem .8rem; border: 1px solid var(--rim); border-radius: .6rem; }
.admin-pin { max-width: 16rem; }
.legal { color: var(--faint); font-size: .85rem; }
.legal a { color: var(--soft); }
@media print {
  .doc { color: #000; max-width: none; }
  .doc a { color: #000; }
  .doc th, .doc td { border-color: #999; }
  .doc-top .theme-btn { display: none; }
}
body.doc-page { height: auto; min-height: 100%; overflow: auto; }
.terms-check { display: flex !important; flex-direction: row !important; gap: .6rem; align-items: flex-start; color: var(--soft); font-size: .92rem; margin: .8rem 0; }
.terms-check input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; flex: none; accent-color: var(--gold); }
.terms-check a, .gate .legal a, .gate-link { color: var(--gold-ink); }
.gate-link { text-decoration: underline; text-underline-offset: 3px; }
.cf-turnstile { min-height: 65px; }

/* Draft editor (Phase 6) */
.editor .ed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.ed-q { display: flex; flex-direction: column; gap: .5rem; padding: .8rem; border: 1px solid var(--rim); border-radius: .8rem; }
.ed-q.removed { opacity: .45; }
.ed-q.removed label:not(.ed-rm) { pointer-events: none; }
.ed-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.ed-head small { color: var(--faint); }
.ed-rm { flex-direction: row !important; align-items: center; gap: .35rem !important; margin-left: auto; }
.editor textarea, .editor input:not([type=checkbox]), .editor select { width: 100%; padding: .4rem .6rem; border: 1px solid var(--rim); border-radius: .5rem; background: var(--deep); color: var(--text); font: inherit; }
