/* Logica 2 — The Atlas of Reason
   Layout concept: a chart table. The sea-glass ground is the table; puzzles sit
   on bright paper cards; the island map is the hub. Day chart by default, a
   night chart in dark mode. Puzzle paper stays light in both, like cards under a lamp. */
@import url('../../_kit/fonts.css');

:root {
  --ground: #E4EFEB;
  --ground-2: #D3E5DF;
  --panel: #FFFFFF;
  --panel-2: #F3F7F4;
  --paper: #FFFFFF;
  --paper-edge: #D9E3DE;
  --ink: #17324A;
  --ink-2: #3E566A;
  --ink-3: #4E6475;
  --ink-paper: #17324A;
  --line: rgba(23, 50, 74, 0.14);
  --sun: #FFB43A;
  --sun-2: #F59E0B;
  --sun-ink: #17324A;
  --sea: #2E7DB5;
  --good: #1D8A5B;
  --good-bg: #DFF3E8;
  --try: #6D4FC2;
  --try-bg: #EEE8FC;
  --try-hover-bg: #E2D8FB;
  --try-hover-ink: #5A3EAD;
  --focus: #6D4FC2;
  --gap: #6D4FC2;
  --shadow-sm: 0 1px 0 rgba(23, 50, 74, 0.10), 0 4px 10px rgba(23, 50, 74, 0.06);
  --shadow: 0 2px 0 rgba(23, 50, 74, 0.10), 0 14px 30px rgba(23, 50, 74, 0.12);
  --lift: 0 4px 0 rgba(23, 50, 74, 0.16), 0 18px 34px rgba(23, 50, 74, 0.16);
  --r: 20px;
  --r-sm: 12px;
  --f-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --f-ui: 'Lexend', 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1C29; --ground-2: #13283A; --panel: #172C3F; --panel-2: #1D354B; --paper: #FAF8F1; --paper-edge: #C9C3B2;
    --ink: #E7F0F5; --ink-2: #B9CBD7; --ink-3: #8FA6B6; --line: rgba(220, 235, 245, 0.14);
    --good: #4CC28D; --good-bg: #173B2F; --try: #B9A3FF; --try-bg: #2A2547; --focus: #FFC65C; --gap: #7E62D6;
    --try-hover-bg: #352E5C; --try-hover-ink: #C9B8FF;
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.25);
    --shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 14px 30px rgba(0, 0, 0, 0.35);
    --lift: 0 4px 0 rgba(0, 0, 0, 0.4), 0 18px 34px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0E1C29; --ground-2: #13283A; --panel: #172C3F; --panel-2: #1D354B; --paper: #FAF8F1; --paper-edge: #C9C3B2;
  --ink: #E7F0F5; --ink-2: #B9CBD7; --ink-3: #8FA6B6; --line: rgba(220, 235, 245, 0.14);
  --good: #4CC28D; --good-bg: #173B2F; --try: #B9A3FF; --try-bg: #2A2547; --focus: #FFC65C; --gap: #7E62D6;
  --try-hover-bg: #352E5C; --try-hover-ink: #C9B8FF;
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.25);
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 14px 30px rgba(0, 0, 0, 0.35);
  --lift: 0 4px 0 rgba(0, 0, 0, 0.4), 0 18px 34px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
/* a hidden name for a button whose visible word is dropped on phones */
.show-sm { display: none; }
@media (max-width: 760px) { .topbar .show-sm { display: inline; } }
.rw-sr-only, .sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 10px; }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
h1, h2, h3 { font-family: var(--f-display); font-variation-settings: 'SOFT' 100, 'WONK' 1; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(16px, calc((100vw - 1240px) / 2));
  /* solid, so a line scrolled up under the bar is hidden cleanly rather than showing through */
  background: var(--ground);
  border-bottom: 1px solid var(--line);
  min-height: 62px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; min-width: 44px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--f-display); font-weight: 700; font-size: 1.32rem; font-variation-settings: 'SOFT' 100, 'WONK' 1; line-height: 1; }
.brand-name small { display: block; font-family: var(--f-ui); font-weight: 500; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.topbar-spacer { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: 0.92rem; text-decoration: none; box-shadow: var(--shadow-sm);
  flex: none;
}
.tb-btn svg { width: 20px; height: 20px; flex: none; }
.tb-btn:hover { border-color: var(--ink-3); }
.tb-btn.icon-only { width: 44px; padding: 0; justify-content: center; }
.stars-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0 12px; min-height: 40px; border-radius: 999px; background: var(--panel); border: 1.5px solid var(--line); }
.stars-chip svg { width: 18px; height: 18px; }

/* ---------- generic buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 26px; border-radius: 16px;
  border: 2px solid var(--ink-paper); background: var(--sun); color: var(--sun-ink);
  font-weight: 700; font-size: 1.06rem; text-decoration: none;
  box-shadow: 0 4px 0 var(--ink-paper);
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.btn:hover { background: #FFC15A; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink-paper); }
.btn[disabled] { background: #E9E4D6; color: #56626C; border-color: #B9BFC2; box-shadow: 0 4px 0 #B9BFC2; cursor: not-allowed; }
.btn-quiet { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-quiet:hover { background: var(--panel-2); }
.btn-on-paper { background: #fff; color: var(--ink-paper); border-color: #C9D3D8; box-shadow: 0 3px 0 #C9D3D8; }
.btn-on-paper:hover { background: #F4F7F8; }
.btn-hint { background: var(--try-bg); color: var(--try); border-color: color-mix(in srgb, var(--try) 50%, transparent); box-shadow: 0 3px 0 color-mix(in srgb, var(--try) 35%, transparent); }
.btn-hint:hover:not([disabled]) { background: var(--try-hover-bg); color: var(--try-hover-ink); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 0.95rem; border-radius: 12px; }
.link-btn { background: none; border: 0; padding: 8px 4px; font-weight: 600; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }

/* ---------- screens ---------- */
main { display: block; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
/* what a crawler or a visitor without JavaScript sees; the app replaces it */
.lab-fallback { padding-block: 48px 64px; }
.load-failed { margin: 18px 0; padding: 16px 18px; border-radius: 16px; background: #FFF2D6; border: 1px solid #E8C77A; color: #17324A; }
.load-failed[hidden] { display: none; }
.load-failed p { margin: 0 0 12px; }
.lab-fallback .eyebrow { margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--try); }
.lab-fallback h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.02; margin: 8px 0 14px; }
.lab-fallback p { max-width: 62ch; color: var(--ink-2); }
/* the load-failure note keeps its own dark text on its cream panel, in Day and Night alike */
.lab-fallback .load-failed p { color: #17324A; }
/* one link per line, so the links don't move when the typeface arrives and changes their widths */
.lab-fallback nav { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 18px; font-weight: 600; }
@media (min-width: 720px) { .wrap { padding-inline: 28px; } }
.screen-enter { animation: screenIn .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- atlas (home) ---------- */
.atlas { padding-block: 18px 40px; }
.atlas-frame {
  position: relative; border-radius: 28px; overflow: hidden;
  width: 100%; height: clamp(360px, min(70vh, 58vw), 720px);
  box-shadow: var(--shadow); border: 2px solid var(--ink-paper);
  background: #BFDCDD;
}
:root[data-theme="dark"] .atlas-frame { border-color: #2C4A63; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .atlas-frame { border-color: #2C4A63; } }
.atlas-canvas, .atlas-fog { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.atlas-fog { pointer-events: none; animation: fogDrift 18s ease-in-out infinite alternate; }
@keyframes fogDrift { from { transform: translateX(-6px); } to { transform: translateX(8px); } }
.atlas-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin: 6px 0 16px; }
.atlas-head h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); line-height: .95; font-weight: 800; }
/* on a phone the title stays on one line in its own typeface and in the stand-in shown while
   that loads, so nothing below it jumps when the typeface arrives */
@media (max-width: 520px) { .atlas-head h1 { font-size: min(2.2rem, calc((100vw - 32px) / 11)); } }
.atlas-head p { margin: 8px 0 0; color: var(--ink-2); font-size: 1.05rem; max-width: 48ch; }
.atlas-head p.welcome-back { display: block; width: fit-content; margin: 10px 0 0; padding: 6px 12px; border-radius: var(--r-sm); background: var(--good-bg); color: var(--ink); font-size: .98rem; font-weight: 600; }
.rank { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--try-hover-ink); }
.rank-name, .rank-count { white-space: nowrap; }
/* a phone keeps the rank on one line and the bar with its count on the next */
@media (max-width: 520px) { .rank { flex-wrap: wrap; row-gap: 6px; } .rank-name { flex-basis: 100%; } }
.rank-bar { width: 120px; height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--try); }
.map-label { position: absolute; z-index: 2; left: 18px; top: 14px; font-family: var(--f-display); font-style: italic; font-weight: 600; font-size: .95rem; color: #17324A; background: rgba(255,255,255,.72); border: 1.5px solid rgba(23,50,74,.35); border-radius: 10px; padding: 3px 10px; }
:root[data-theme="dark"] .map-label { color: #E7F0F5; background: rgba(14,28,41,.7); border-color: rgba(220,235,245,.35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .map-label { color: #E7F0F5; background: rgba(14,28,41,.7); border-color: rgba(220,235,245,.35); } }
.lm {
  position: absolute; z-index: 2; transform: translate(-50%, -62%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 4px; color: var(--ink-paper); border-radius: 18px;
  min-width: 64px; min-height: 64px;
}
.lm .landmark { width: clamp(52px, 7vw, 86px); height: auto; filter: drop-shadow(0 3px 0 rgba(23, 50, 74, .2)); transition: transform .25s var(--ease-spring); }
.lm:hover .landmark, .lm:focus-visible .landmark { transform: translateY(-5px) scale(1.06); }
.lm-label {
  font-family: var(--f-display); font-weight: 700; font-size: clamp(.72rem, 1.15vw, .98rem); white-space: nowrap;
  background: var(--paper); border: 1.5px solid var(--ink-paper); border-radius: 999px; padding: 2px 10px 3px; box-shadow: 2px 2px 0 rgba(23, 50, 74, .18);
}
.lm-pips { display: flex; gap: 3px; margin-top: 2px; }
.lm-pips i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .85); border: 1.5px solid var(--ink-paper); }
.lm-pips i.on { background: var(--sun); }
.lm-pips i.full { background: var(--good); border-color: var(--ink-paper); }
.lm.is-next .landmark { animation: beckon 2.4s ease-in-out infinite; }
@keyframes beckon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.lm-blades, .lm .lm-blades { animation: spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.daily-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 16px; background: var(--paper); color: var(--ink-paper); border: 2px solid var(--ink-paper); border-radius: 18px;
  box-shadow: 4px 4px 0 rgba(23, 50, 74, .2); max-width: 440px;
}
.daily-card h2 { font-size: 1.15rem; }
.daily-card p { margin: 2px 0 0; font-size: .86rem; color: #3E566A; }
.daily-card .btn { min-height: 48px; padding: 0 18px; white-space: nowrap; }
/* a narrow phone gives the words the card's width and puts the button under them */
@media (max-width: 480px) { .daily-card { flex-wrap: wrap; row-gap: 10px; } .daily-card > div { flex: 1 1 0; min-width: 0; } .daily-card > .btn { flex: 1 1 100%; justify-content: center; } }
/* the card stays paper in both themes, so its "Charted" green is fixed dark enough for it */
.daily-done { display: inline-flex; align-items: center; gap: 6px; color: #16704A; font-weight: 700; font-size: .9rem; }

.atlas-below { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; margin-top: 26px; align-items: start; }
@media (max-width: 900px) { .atlas-below { grid-template-columns: 1fr; } }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-h h2 { font-size: 1.6rem; }
.section-h p { margin: 0; color: var(--ink-3); font-size: .92rem; }
/* on a phone the heading sits above its line of explanation, at full width */
@media (max-width: 640px) { .section-h { flex-direction: column; align-items: flex-start; gap: 4px; } }
.regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.region-card {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; text-align: left;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--r); padding: 12px 14px;
  color: var(--ink); box-shadow: var(--shadow-sm); transition: transform .2s var(--ease-spring), box-shadow .2s;
  min-height: 92px;
}
.region-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.region-card .landmark { width: 64px; height: 64px; }
.region-card h3 { font-size: 1.12rem; line-height: 1.15; }
.region-card .skill { font-size: .8rem; color: var(--ink-3); margin-top: 1px; }
.meter { display: flex; gap: 3px; margin-top: 8px; }
.meter i { flex: 1; height: 7px; border-radius: 4px; background: var(--line); }
.meter i.s1 { background: color-mix(in srgb, var(--sun) 55%, transparent); }
.meter i.s2 { background: var(--sun); }
.meter i.s3 { background: var(--good); }

.side-stack { display: grid; gap: 14px; }
.panel { background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 1.25rem; margin-bottom: 6px; }
.panel p { margin: 0 0 10px; color: var(--ink-2); font-size: .95rem; }
.head-cards { display: grid; gap: 10px; width: min(100%, 440px); }
.head-cards .daily-card { max-width: none; }
.pip-panel .pip { width: 52px; height: 52px; flex: none; }
.pip-panel > div { flex: 1; min-width: 0; }
.honest { font-size: .82rem; color: var(--ink-3); line-height: 1.5; }
.honest a { color: var(--ink-2); }

/* ---------- region ---------- */
.region-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; padding-block: 22px 8px; }
.region-head .landmark { width: clamp(96px, 14vw, 150px); height: auto; }
.region-head .eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.region-head h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1; margin: 4px 0 8px; }
.region-head p { margin: 0; font-size: 1.1rem; color: var(--ink-2); max-width: 46ch; }
.trail-map { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin: 22px 0 10px; padding: 18px 0 8px; }
/* a shape path and a picture path, each from easy to tricky */
.trail-path h2 { margin: 22px 0 0; font-size: 1.15rem; }
.trail-path h2 small { font-family: var(--f-ui); font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-left: 6px; }
.trail-path .trail-map { margin-top: 8px; }
.trail-map.n-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 60%; }
.trail-map.n-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 40%; }
.stamp-path { margin: 12px 0 0; font-size: .95rem; color: var(--ink-2); }
.trail-map::before { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; border-top: 3px dashed var(--ink-3); opacity: .45; z-index: 0; }
@media (max-width: 760px) {
  .trail-map, .trail-map.n-3, .trail-map.n-2 { grid-template-columns: 1fr; gap: 12px; max-width: none; }
  .trail-map::before { left: 44px; right: auto; top: 6%; bottom: 6%; border-top: 0; border-left: 3px dashed var(--ink-3); }
}
.trail {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 16px; border-radius: var(--r); background: var(--panel); border: 2px solid var(--line); color: var(--ink);
  box-shadow: var(--shadow-sm); min-height: 150px; transition: transform .2s var(--ease-spring), box-shadow .2s;
}
.trail:nth-child(even) { transform: translateY(16px); }
@media (max-width: 760px) { .trail:nth-child(even) { transform: none; } .trail { flex-direction: row; align-items: center; min-height: 0; gap: 14px; } .trail .trail-body { flex: 1; } }
.trail:hover:not([aria-disabled="true"]) { box-shadow: var(--shadow); border-color: var(--ink-3); }
.trail .num { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--sun); color: var(--sun-ink); font-family: var(--f-display); font-weight: 800; font-size: 1.5rem; border: 2px solid var(--ink-paper); box-shadow: 0 3px 0 var(--ink-paper); flex: none; }
.trail h3, .trail .trail-name { display: block; font-family: var(--f-display); font-variation-settings: 'SOFT' 100, 'WONK' 1; letter-spacing: -0.01em; font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.trail .trail-stars { display: flex; gap: 2px; }
.trail .trail-stars svg { width: 22px; height: 22px; }
.trail[aria-disabled="true"] { background: var(--panel-2); border-style: dashed; cursor: not-allowed; }
.trail[aria-disabled="true"] h3, .trail[aria-disabled="true"] .trail-stars { opacity: .7; }
.trail[aria-disabled="true"] .num { background: var(--panel-2); color: var(--ink-3); border-color: var(--ink-3); box-shadow: none; }
.trail .lock-note { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.trail.is-current { border-color: var(--sun-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sun) 35%, transparent), var(--shadow-sm); }
details.grownup-note { margin-top: 26px; background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--r); padding: 4px 18px; }
details.grownup-note summary { cursor: pointer; font-weight: 700; padding: 12px 0; min-height: 44px; }
details.grownup-note p { margin: 0 0 12px; color: var(--ink-2); max-width: 70ch; }
details.grownup-note dt { font-weight: 700; margin-top: 8px; }
details.grownup-note dd { margin: 2px 0 10px; color: var(--ink-2); max-width: 70ch; }

/* ---------- play ---------- */
.play { padding-block: 14px 30px; }
.play-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; scroll-margin-top: 80px; }
.play-title { min-width: 0; flex: 1; }
.play-title .eyebrow { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--ink-3); }
.play-title h1 { font-size: clamp(1.25rem, 2.4vw, 1.7rem); line-height: 1.1; }
.stones { display: flex; gap: 6px; align-items: center; }
.stones i { width: 18px; height: 12px; border-radius: 50%; background: var(--ground-2); border: 2px solid var(--ink-3); transition: background .3s, transform .3s var(--ease-spring); }
.stones i.now { border-color: var(--ink); transform: scale(1.25); }
.stones i.done { background: var(--good); border-color: var(--good); }
.stones i.helped { background: var(--try); border-color: var(--try); }
/* first try and with help differ in shape too, not only in colour: a helped stone is a ring */
.stones i.helped { background: var(--panel); box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 5px var(--try); }

.board {
  /* the board is paper in both themes, so it keeps the day palette for its controls */
  --try: #6D4FC2; --try-bg: #EEE8FC; --good: #1D8A5B; --good-bg: #DFF3E8; --focus: #6D4FC2; --gap: #6D4FC2;
  --panel: #FFFFFF; --panel-2: #F3F7F4; --ink: #17324A; --ink-2: #3E566A; --ink-3: #4E6475; --line: rgba(23, 50, 74, 0.14);
  position: relative; margin-top: 14px; scroll-margin-top: 80px; background: var(--paper); color: var(--ink-paper);
  border-radius: 28px; border: 2px solid var(--paper-edge); box-shadow: var(--shadow);
  padding: clamp(14px, 2.6vw, 28px);
}
.guide { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: end; }
.guide .pip { width: 84px; height: 84px; }
.bubble {
  position: relative; background: #F2F7F5; border: 2px solid #CFDCD6; border-radius: 20px; padding: 12px 16px 12px 18px;
  display: flex; align-items: center; gap: 12px; min-height: 64px; color: var(--ink-paper);
}
.bubble::before { content: ''; position: absolute; left: -11px; bottom: 16px; width: 18px; height: 18px; background: inherit; border-left: 2px solid; border-bottom: 2px solid; border-color: inherit; transform: rotate(45deg); }
.bubble-text { flex: 1; font-size: clamp(1.04rem, 1.9vw, 1.28rem); font-weight: 600; line-height: 1.35; }
.bubble.is-good { background: #E3F5EB; border-color: #9ED3B6; }
.bubble.is-try { background: #F0EAFE; border-color: #C8B7F4; }
.bubble.is-why { background: #FFF6E2; border-color: #F2CF86; }
.speak-btn { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2px solid #CFDCD6; background: #fff; display: grid; place-items: center; color: var(--ink-paper); }
.speak-btn svg { width: 24px; height: 24px; }
.speak-note { grid-column: 1 / -1; margin: 0; padding: 6px 12px; border-radius: 12px; background: #FFF6E2; border: 1.5px solid #F2CF86; color: var(--ink-paper); font-size: .92rem; font-weight: 600; }
.speak-note[hidden] { display: none; }
.speak-btn.is-speaking { border-color: var(--sea); color: var(--sea); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.stage { position: relative; display: grid; place-items: center; min-height: clamp(220px, 34vh, 400px); padding: 18px 0 8px; }
/* with the rule open under the puzzle, the puzzle keeps only the room it needs */
.board:has(#rule .rule-panel) > .stage { min-height: 0; }
.stem { width: 100%; display: grid; place-items: center; }
.why-visual { display: grid; place-items: center; }
.why-visual:empty { display: none; }

.options { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: clamp(10px, 1.8vw, 18px); margin-top: 12px; max-width: 880px; margin-inline: auto; }
.options.n-4 { --n: 4; } .options.n-5 { --n: 5; } .options.n-6 { --n: 6; }
@media (max-width: 640px) { .options.n-5, .options.n-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .options.n-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.opt {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; max-height: 190px; width: 100%; min-width: 0; overflow: hidden;
  background: #fff; border: 2.5px solid #C9D6DD; border-radius: 20px; padding: max(26px, 14%) 11% 11%;
  box-shadow: 0 4px 0 #C9D6DD; color: var(--ink-paper);
  transition: transform .18s var(--ease-spring), box-shadow .18s, border-color .18s, opacity .3s;
  touch-action: manipulation;
}
.opt:hover:not([disabled]) { transform: translateY(-3px); border-color: #8FA6B6; }
.opt > svg, .opt > .opt-group { width: 100%; height: 100%; display: block; min-width: 0; }
.opt .letter { position: absolute; left: 10px; top: 6px; font-weight: 700; font-size: .82rem; line-height: 1.2; color: #4E6475; }
/* keyboard: the focused choice says what Enter will do (choose it, then check it); each choice
   is named by its aria-label, so this note is not read as part of it */
.opt:focus-visible::after { content: 'Enter to choose'; position: absolute; right: 8px; top: 6px; padding: 1px 8px; border-radius: 999px; background: var(--ink-paper); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.5; white-space: nowrap; pointer-events: none; }
.opt[aria-checked="true"]:focus-visible::after { content: 'Enter to check'; }
@media (max-width: 520px) { .opt:focus-visible::after, .opt[aria-checked="true"]:focus-visible::after { content: none; } }
.opt[aria-checked="true"] { border-color: var(--ink-paper); box-shadow: 0 0 0 4px var(--sun), 0 6px 0 var(--ink-paper); transform: translateY(-6px); }
.opt.is-wrong { animation: wobble .5s ease; }
.opt.is-out { opacity: .32; filter: grayscale(.6); transform: scale(.94); box-shadow: none; }
.opt.is-right { border-color: var(--good); box-shadow: 0 0 0 4px #9ED3B6, 0 5px 0 var(--good); }
.opt.is-focus { box-shadow: 0 0 0 5px var(--sun), 0 5px 0 var(--ink-paper); }
.opt.is-dim { opacity: .45; }
@keyframes wobble { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px) rotate(-2deg); } 40% { transform: translateX(8px) rotate(2deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.opt-num { font-family: var(--f-display); font-weight: 800; font-size: clamp(2rem, 5vw, 3.2rem); font-variant-numeric: tabular-nums; }
.options.is-numbers .opt { aspect-ratio: 4 / 3; }
.options.is-rods .opt { aspect-ratio: 1 / 2; max-height: 300px; padding: 28px 6px 8px; }
.options.is-rods .opt > svg { height: 100%; width: auto; }
/* opened sheets have small holes to compare, so the sheet takes nearly the whole card */
.options.is-sheets .opt { padding: 24px 8px 8px; }
@media (max-width: 640px) { .stage { min-height: 0; padding: 16px 0 6px; } }

.actions { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { min-width: 170px; }
.why {
  margin: 18px auto 0; max-width: 880px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; background: #FFF6E2; border: 2px solid #F2CF86; border-radius: 18px; color: var(--ink-paper);
}
.why-badge { justify-self: start; font-family: var(--f-display); font-weight: 800; font-size: .95rem; padding: 4px 10px; border-radius: 999px; background: var(--sun); border: 1.5px solid var(--ink-paper); white-space: nowrap; }
.why-text { font-size: 1.05rem; font-weight: 500; line-height: 1.4; }
.why-steps { display: flex; gap: 5px; margin-top: 6px; }
.why-steps i { width: 22px; height: 5px; border-radius: 3px; background: #EBD9AE; }
.why-steps i.on { background: #C98A12; }
@media (max-width: 640px) { .why { grid-template-columns: 1fr; } .why .btn { width: 100%; } }
.rule-panel { background: #F3EEFF; border-color: #C9B8FA; }
.why .speak-step { width: 44px; height: 44px; }
.why .speak-step svg { width: 20px; height: 20px; }
.why .actions { gap: 10px; }
.rule-panel .why-badge { background: #fff; justify-self: start; }
@media (max-width: 640px) { .board .actions { flex-wrap: nowrap; } .board .actions .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; white-space: nowrap; } .why .actions .btn, .rule-panel .actions .btn { flex: 1 1 auto; } }
/* the narrowest phones: "Show the rule" and its icon fit the half-width button */
@media (max-width: 380px) { .board .actions .btn { padding: 0 8px; gap: 6px; font-size: .95rem; } .board .actions .btn svg { width: 18px; height: 18px; flex: none; } }
.rule-turn { margin-top: 8px; font-weight: 700; color: #4B33A0; }
.why-more { grid-column: 1 / -1; justify-self: end; margin: -8px 0 -6px; }
.why-more .link-btn { color: var(--ink-paper); }
.after-copy { margin: 10px 0 0; display: grid; justify-items: center; gap: 4px; }
.after-copy .after-art { width: 110px; height: 110px; padding: 10px; background: #fff; border: 2px solid #C9B8FA; border-radius: 16px; }
.after-copy .after-art > svg { width: 100%; height: 100%; }
.after-copy figcaption { font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #4B33A0; }
.after-copy.practice .practice-pair { display: flex; align-items: center; gap: 10px; }
.after-copy.practice .after-art { border-color: #9ED3B6; }
.practice-arrow { font-size: 1.5rem; color: #4E6475; }
.practice-note { margin: 6px 0 0; font-size: .9rem; font-weight: 600; color: #4B33A0; text-align: center; }
.trail-waiting { display: block; margin-top: 4px; font-size: .86rem; font-weight: 700; color: var(--try); }
.stem-beads:not(.show-n) .rod-n { visibility: hidden; }
.try-tool { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.try-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.try-ico { display: inline-flex; }
.try-ico svg { width: 1.1em; height: 1.1em; }
.try-tool .ghost-wrap { width: 96px; height: 96px; display: grid; place-items: center; border: 2px dashed #B9A3FF; border-radius: 16px; background: #F7F4FF; }
.try-tool .ghost-wrap svg { width: 80%; height: 80%; transition: transform .45s cubic-bezier(.4, 0, .2, 1); }
.try-rod .ghost-wrap { width: 96px; height: 150px; }
.try-rod .ghost-wrap svg { height: 90%; }
.try-sign { font-size: 1.25em; font-weight: 800; line-height: 1; }

/* gap and focus states inside puzzles */
.gap-mark { font-family: var(--f-display); font-weight: 800; font-size: clamp(2rem, 4vw, 3rem); color: var(--gap); }
[data-gap] { position: relative; }
.is-focus { position: relative; z-index: 1; }
.is-dim { opacity: .35; transition: opacity .35s; }
.fill-pop { animation: fillPop .6s var(--ease-spring) both; }
@keyframes fillPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.flyer { position: fixed; z-index: 60; pointer-events: none; display: grid; place-items: center; }
.flyer svg { width: 100%; height: 100%; }

/* mosaic */
.mosaic { width: min(100%, 460px); height: auto; filter: drop-shadow(0 6px 0 rgba(23, 50, 74, .12)); }
.mosaic .gap-rect { fill: #FBF9F2; stroke: var(--gap); stroke-width: 3; stroke-dasharray: 7 6; animation: dash 1.2s linear infinite; }
.mosaic .gap-q { font-family: var(--f-display); font-weight: 800; font-size: 34px; fill: var(--gap); }
.mosaic .mcell { transition: opacity .35s; }
.mosaic .mcell.is-focus rect:first-child { stroke: #6D4FC2; stroke-width: 3; }
.mosaic [data-gap].is-focus .gap-rect { stroke: #C98A12; }
@keyframes dash { to { stroke-dashoffset: -26; } }
.patch { width: 100%; height: 100%; }

/* matrix */
.matrix { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 10px; width: min(100%, calc(var(--n) * 128px)); padding: 12px; background: #EEF3F1; border-radius: 22px; border: 2px solid #D5E0DB; }
.mx-cell { aspect-ratio: 1; min-width: 0; background: #fff; border-radius: 14px; border: 2px solid #D5E0DB; display: flex; align-items: center; justify-content: center; padding: 12%; transition: opacity .35s, box-shadow .35s; }
.mx-cell > svg { width: 100%; height: 100%; display: block; }
.mx-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.mx-cell.is-focus { box-shadow: 0 0 0 4px #C9B8FA; border-color: #6D4FC2; }

/* analogy */
.stem-analogy { display: grid; gap: 4px; justify-items: center; }
.pair { display: flex; align-items: center; gap: clamp(8px, 2vw, 18px); padding: 10px 14px; border-radius: 22px; background: #EEF3F1; border: 2px solid #D5E0DB; transition: opacity .35s, box-shadow .35s; }
.pair.is-focus { box-shadow: 0 0 0 4px #C9B8FA; border-color: #6D4FC2; }
.pair-label { font-size: .82rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #4E6475; }
.an-card { --s: clamp(84px, 13vw, 128px); width: var(--s); height: var(--s); flex: none; background: #fff; border: 2px solid #D5E0DB; border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: calc(var(--s) * .1); }
.an-card > svg { width: 100%; height: 100%; display: block; }
.an-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.bridge-arrow { width: clamp(40px, 6vw, 60px); stroke: #6B7F8E; }
.stem-analogy { position: relative; }
.morph-ghost { position: absolute; z-index: 5; pointer-events: none; }

/* classify */
.shelf { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, 640px); gap: clamp(6px, 2vw, 16px); padding: 14px clamp(10px, 2vw, 16px) 18px; background: #EEF3F1; border-radius: 22px; border: 2px solid #D5E0DB; position: relative; }
.shelf::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 7px; height: 6px; border-radius: 3px; background: #C9B48D; }
/* the example pictures are drawn near the size of the answer pictures, so a small animal stays easy to see */
.shelf-item { width: 100%; max-width: 148px; aspect-ratio: 1; justify-self: center; min-width: 0; background: #fff; border: 2px solid #D5E0DB; border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: 6%; transition: box-shadow .35s; }
.shelf-item > svg { width: 100%; height: 100%; display: block; }
.shelf-item.is-focus { box-shadow: 0 0 0 4px #C9B8FA; border-color: #6D4FC2; }
.shelf-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.odd-note { margin: 0; color: #4E6475; font-size: .95rem; }
.stem-odd { min-height: 0; }
.stage:has(.stem-odd) { min-height: 0; padding: 10px 0 0; }

/* paper folding */
.stem-fold { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.fold-panel { margin: 0; display: grid; justify-items: center; gap: 4px; width: clamp(100px, 16vw, 150px); }
.fold-panel svg { width: 100%; height: auto; overflow: visible; }
.fold-panel figcaption { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #4E6475; }
.fold-then { font-size: 1.4rem; color: #8FA6B6; }
.paper { fill: #FFFFFF; stroke: #17324A; stroke-width: 1.8; }
.paper-ghost { fill: none; stroke: #8FA6B6; stroke-width: 1.2; stroke-dasharray: 3 4; }
.paper-flap { fill: rgba(255, 180, 58, .18); stroke: none; }
.paper-folded { fill: #FFF7E6; }
.crease { stroke: #8FA6B6; stroke-width: 1.2; stroke-dasharray: 4 3; fill: none; }
.crease-strong { stroke: #6D4FC2; stroke-width: 2; }
.fold-arrow { fill: none; stroke: #E2563D; stroke-width: 2.6; stroke-linecap: round; }
.fold-arrow-head { fill: #E2563D; }
.hole { fill: #17324A; }
.hole.punch { fill: #17324A; animation: punch .5s .3s var(--ease-spring) both; transform-box: fill-box; transform-origin: center; }
@keyframes punch { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; height: 100%; }
.sheet .paper { stroke-width: 1.4; }
.sheet-big { width: min(260px, 70vw); height: auto; }
.twin { transition: transform .85s cubic-bezier(.5, 0, .2, 1), opacity .3s; transform: translate(var(--fx), var(--fy)); opacity: .35; }
.twin.go { transform: translate(0, 0); opacity: 1; }
.hole-new { fill: #6D4FC2; }

/* spatial */
.stem-spatial { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 30px); }
.sp-source, .sp-gap { --s: clamp(110px, 17vw, 170px); width: var(--s); height: var(--s); flex: none; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid #D5E0DB; border-radius: 20px; padding: calc(var(--s) * .12); }
.sp-source > svg, .sp-gap > svg { width: 100%; height: 100%; display: block; transform-origin: 50% 50%; }
.sp-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.op { display: grid; justify-items: center; gap: 6px; font-weight: 700; font-size: .9rem; color: #3E566A; }
.op-turn svg { width: 64px; height: 64px; stroke: #E2563D; }
.op-mirror .mirror-line { display: block; width: 12px; height: 120px; border-radius: 6px; background: linear-gradient(90deg, #C8D7E0, #FFFFFF 40%, #A8BCCB); border: 2px solid #6B7F8E; }
.op-mirror.op-h .mirror-line { width: 120px; height: 14px; background: repeating-linear-gradient(90deg, #8FC5D3 0 12px, #B5DDE7 12px 24px); border-color: #4E8FA3; }
.stem-spatial.axis-h { flex-direction: column; gap: 8px; }
.stem-spatial.axis-h .sp-source, .stem-spatial.axis-h .sp-gap { --s: clamp(92px, 11vw, 124px); }
.grid { width: 100%; height: 100%; }
/* the lines between the squares stand out from the white squares (3.7:1), so empty squares can be counted */
.grid .grid-bg { fill: #748898; }
.grid .grid-empty { fill: #FFFFFF; }

/* quant */
.rods { display: flex; align-items: flex-end; gap: clamp(8px, 2.4vw, 22px); }
.rod-wrap { display: grid; justify-items: center; gap: 4px; width: clamp(48px, 8vw, 74px); }
.rod-svg { width: 100%; height: auto; }
.rod { fill: #8C6A44; } .rod-base { fill: #6B4F31; }
.bead { stroke: #17324A; stroke-width: 1.6; }
.rod-n { font-weight: 700; color: #4E6475; font-variant-numeric: tabular-nums; }
.rod-gap { min-height: 150px; border: 3px dashed var(--gap); border-radius: 14px; background: #F7F4FF; display: grid; place-items: center; }
.rod-wrap.is-focus .rod-n { color: #6D4FC2; }
.scale2 { width: min(100%, 560px); height: auto; overflow: visible; }
.scale2 .scale-beam, .scale2 .scale-post, .scale2 .scale-foot { fill: #8C6A44; }
.scale2 .scale-pin { fill: #F2B134; stroke: #17324A; stroke-width: 2.5; }
.scale2 .cord { fill: none; stroke: #8C6A44; stroke-width: 2; }
.scale2 .ring { fill: #fff; stroke: #8C6A44; stroke-width: 2; }
.scale2 .pan-dish { fill: #D9C59C; stroke: #8C6A44; stroke-width: 2.5; stroke-linejoin: round; }
.scale2 .plus { font: 800 26px var(--f-ui); fill: #3E566A; }
.scale2 .pan-gap rect { fill: #F7F4FF; stroke: var(--gap); stroke-width: 3; stroke-dasharray: 7 6; }
.scale2 .pan-gap .gap-q { font-family: var(--f-display); font-weight: 800; font-size: 34px; fill: var(--gap); }
.scale2 .pan-glow { fill: transparent; stroke: transparent; stroke-width: 4; transition: fill .3s, stroke .3s; }
.scale2 .pan.is-focus .pan-glow { fill: #F3EEFF; stroke: #C9B8FA; }
.scale2 .beam-g, .scale2 .pan { transform-box: view-box; transition: transform 1.1s cubic-bezier(.34, 1.4, .64, 1); }
.scale2 .beam-g { transform-origin: 190px 30px; }
/* the pans hang 98 units either side of the pivot: sin 5° × 98 ≈ 8.5 */
.scale2[data-tilt="left"] .beam-g { transform: rotate(-5deg); }
.scale2[data-tilt="left"] .pan-left { transform: translateY(8.5px); }
.scale2[data-tilt="left"] .pan-right { transform: translateY(-8.5px); }
.opt-group { display: flex; align-items: center; justify-content: center; }
.opt-group .group-svg { width: 100%; height: 100%; display: block; }
.stem-na { display: grid; gap: 10px; max-width: 100%; }
.na-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 14px; min-width: 0; border-radius: 18px; background: #EEF3F1; border: 2px solid #D5E0DB; transition: opacity .35s, box-shadow .35s; }
.na-row.is-focus { box-shadow: 0 0 0 4px #C9B8FA; border-color: #6D4FC2; }
/* three pairs stack, so the cards stay small enough for a 360 px phone and a short laptop */
.na-card { --s: clamp(76px, 11vw, 112px); width: calc(var(--s) * 1.35); height: var(--s); flex: none; background: #fff; border-radius: 14px; border: 2px solid #D5E0DB; display: flex; align-items: center; justify-content: center; padding: 5px; }
.na-card > svg { width: 100%; height: 100%; display: block; }
.na-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.na-arrow { font-size: 1.8rem; color: #8FA6B6; }
/* the numbers and the gap stay on one line: the cards (and their numbers) shrink with the
   space, and each jump label floats above the gap after its number */
.stem-series { container-type: inline-size; }
.series { --sgap: clamp(10px, 3cqi, 24px); display: flex; align-items: center; flex-wrap: nowrap; justify-content: center; gap: var(--sgap); width: 100%; padding-top: 1.5em; }
.num-card { position: relative; display: grid; place-items: center; flex: 1 1 0; min-width: 0; max-width: 80px; height: clamp(44px, 13cqi, 90px); padding: 0 2px; border-radius: 14px; background: #fff; border: 2px solid #D5E0DB; font-family: var(--f-display); font-weight: 800; font-size: clamp(1rem, 7cqi, 2.5rem); font-variant-numeric: tabular-nums; }
.num-gap { border: 3px dashed var(--gap); background: #F7F4FF; }
.jump { position: absolute; right: calc(-0.5 * var(--sgap)); top: -1.55em; transform: translateX(50%); font-family: var(--f-ui); font-size: .82rem; line-height: 1.2; white-space: nowrap; font-weight: 700; color: transparent; padding: 1px 4px; border-radius: 6px; transition: color .3s, background .3s; }
.jump.is-focus { color: #6D4FC2; background: #EEE8FC; }
.equation { font-family: var(--f-display); font-weight: 800; font-size: clamp(2.2rem, 6vw, 4rem); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .3em; flex-wrap: wrap; justify-content: center; }
.eq-box { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 .15em; border: 4px dashed var(--gap); border-radius: 14px; color: var(--gap); background: #F7F4FF; }
.eq-box.solved { border-style: solid; border-color: var(--good); color: var(--ink-paper); background: #E3F5EB; }
.stem-shapes { display: grid; gap: 10px; justify-items: center; }
.shape-line { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 16px; background: #EEF3F1; border: 2px solid #D5E0DB; font-family: var(--f-display); font-weight: 800; font-size: clamp(1.6rem, 4vw, 2.4rem); transition: opacity .35s, box-shadow .35s; }
.shape-line.is-focus { box-shadow: 0 0 0 4px #C9B8FA; }
.glyph { width: clamp(38px, 6vw, 54px); height: auto; }
.op-sym { color: #4E6475; }
.shape-ask { background: #FFF6E2; border-color: #F2CF86; }
.gap-num { font-family: var(--f-display); font-weight: 800; font-size: inherit; }

/* ---------- results ---------- */
@media (max-width: 480px) { .results .actions { flex-direction: column; align-items: stretch; width: 100%; } .results .actions .btn { width: 100%; min-width: 0; } }
.results { overflow-x: clip; padding-block: 26px 40px; display: grid; justify-items: center; text-align: center; gap: 14px; }
.results h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.results .lede { font-size: 1.15rem; color: var(--ink-2); max-width: 46ch; margin: 0; }
.stamp-press { position: relative; width: min(260px, 70vw); aspect-ratio: 1; }
.stamp-press .stamp { width: 100%; height: 100%; }
.stamp-press.go .stamp { animation: press .9s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes press { 0% { transform: translateY(-40px) scale(1.6) rotate(-8deg); opacity: 0; } 55% { transform: translateY(0) scale(.94) rotate(3deg); opacity: 1; } 75% { transform: scale(1.03) rotate(-1deg); } 100% { transform: scale(1) rotate(-2deg); } }
.big-stars { display: flex; gap: 10px; justify-content: center; }
.big-stars svg { width: 56px; height: 56px; }
.big-stars svg.on { animation: starIn .6s var(--ease-spring) both; }
.big-stars svg:nth-child(2).on { animation-delay: .18s; } .big-stars svg:nth-child(3).on { animation-delay: .36s; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.recap { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.recap span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--panel); border: 1.5px solid var(--line); font-size: .92rem; font-weight: 600; white-space: nowrap; }
.recap svg { width: 18px; height: 18px; flex: none; }
.results .actions { margin-top: 6px; }
.praise { font-family: var(--f-display); font-style: italic; font-size: 1.2rem; color: var(--ink-2); max-width: 44ch; }

/* ---------- journal ---------- */
.journal { padding-block: 22px 40px; }
.journal h1 { font-size: clamp(2rem, 4.4vw, 3rem); }
.journal-regions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 8px 36px; }
.stamp-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
/* on a phone a journal stamp is too small for its lettering to be read; the place's name is
   the heading above it, and the trail's name is under it */
@media (max-width: 520px) { .stamp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stamp-slot .stamp-name { display: none; } }
.stamp-slot { display: grid; justify-items: center; gap: 6px; text-align: center; font-size: .78rem; color: var(--ink-3); }
button.stamp-slot { font: inherit; font-size: .78rem; background: none; border: 0; padding: 4px; border-radius: 14px; cursor: pointer; }
button.stamp-slot:hover span { text-decoration: underline; }
.stamp-slot .stamp { width: 100%; height: auto; }
.stamp-slot .not-yet { white-space: nowrap; }
.stamp-slot.empty .stamp { opacity: .28; filter: grayscale(1); }
.journal-region { margin-top: 26px; }
.journal-region h2 { font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.journal-region h2 .landmark { width: 44px; height: 44px; }

/* ---------- grown-ups ---------- */
.grownups { padding-block: 22px 50px; }
.grownups h1 { font-size: clamp(2rem, 4.4vw, 3rem); }
.gate { max-width: 520px; margin: 40px auto; text-align: center; display: grid; gap: 16px; justify-items: center; }
.hold-btn { position: relative; overflow: hidden; }
.hold-btn .hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(23, 50, 74, .18); transition: width 0s; }
.hold-btn.holding .hold-fill { width: 100%; transition: width 2s linear; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.kpi b { display: block; font-family: var(--f-display); font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .85rem; color: var(--ink-3); }
.skill-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 16px; overflow: hidden; border: 1.5px solid var(--line); }
.table-scroll { overflow-x: auto; border-radius: 16px; }
.skill-table th, .skill-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.skill-table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); background: var(--panel-2); }
.skill-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.skill-name { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.skill-name .landmark { width: 40px; height: 40px; flex: none; }
.comfort { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.comfort.c0 { background: var(--panel-2); color: var(--ink-3); }
.comfort.c1 { background: #FFF2D6; color: #8A5A00; }
.comfort.c2 { background: #E6F0FB; color: #1F5C94; }
.comfort.c3 { background: #E1F4EA; color: #18704A; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--sea); border-radius: 4px; }
.gu-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .gu-grid { grid-template-columns: 1fr; } }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting label, .setting .label { font-weight: 600; }
.setting small { display: block; color: var(--ink-3); font-weight: 400; font-size: .82rem; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--panel); padding: 0 12px; min-height: 44px; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.ch { display: none; }
:root.color-help .ch { display: inline; }
.chf { display: none; }
:root.color-help .chf { display: inline; }
.chf-coral { stroke-dasharray: calc(9px * var(--k, 1)) calc(6px * var(--k, 1)); }
.chf-gold { stroke-dasharray: calc(.1px * var(--k, 1)) calc(5px * var(--k, 1)); }
.switch { position: relative; width: 52px; height: 44px; flex: none; }
/* the whole row label toggles a switch, so the target is the row, not just the 52 × 30 switch */
.setting label.label { cursor: pointer; flex: 1; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.switch input { appearance: none; -webkit-appearance: none; position: relative; display: block; width: 52px; height: 44px; margin: 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; }
.switch input::before { content: ''; position: absolute; left: 0; top: 7px; width: 52px; height: 30px; box-sizing: border-box; border-radius: 999px; background: var(--line); border: 1.5px solid var(--ink-3); transition: background .2s, border-color .2s; }
.switch input::after { content: ''; position: absolute; left: 4px; top: 11px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease-spring); }
.switch input:checked::before { background: var(--good); border-color: var(--good); }
.switch input:checked::after { transform: translateX(22px); }
.confirm-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* narrow screens: a label and its row of buttons stack, so the description keeps its width */
@media (max-width: 520px) {
  .setting.setting-seg { flex-wrap: wrap; row-gap: 8px; }
  .setting.setting-seg .label { flex: 1 1 100%; }
}

/* ---------- welcome / modal ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(9, 22, 34, .55); display: grid; place-items: center; padding: 16px; animation: fadeIn .25s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  --try: #6D4FC2; --try-bg: #EEE8FC; --good: #1D8A5B; --focus: #6D4FC2;
  --panel: #FFFFFF; --panel-2: #F3F7F4; --ink: #17324A; --ink-2: #3E566A; --ink-3: #4E6475; --line: rgba(23, 50, 74, 0.14); --ground: #FFFFFF;
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); color: var(--ink-paper); border-radius: 26px; border: 2px solid var(--ink-paper); box-shadow: 6px 6px 0 rgba(23, 50, 74, .3); padding: 24px; animation: rise .4s var(--ease-spring) both; }
@keyframes rise { from { transform: translateY(30px) scale(.96); opacity: 0; } }
.modal h2 { font-size: 1.8rem; line-height: 1.1; }
.modal .actions .btn { white-space: nowrap; }
@media (max-width: 640px) { .fold-then { display: none; } }
.modal p { color: #3E566A; }
.modal .pip { width: 110px; height: 110px; display: block; margin: -6px auto 4px; }
.welcome-read { margin: 0 0 6px; font-weight: 600; color: var(--ink-2); }
.grade-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.grade-pick button { min-height: 72px; border-radius: 16px; border: 2px solid #C9D6DD; background: #fff; box-shadow: 0 3px 0 #C9D6DD; font-family: var(--f-display); font-weight: 800; font-size: 1.5rem; color: var(--ink-paper); }
.grade-pick button small { display: block; font-family: var(--f-ui); font-size: .72rem; font-weight: 600; color: #4E6475; }
.grade-pick button[aria-pressed="true"] { background: var(--sun); border-color: var(--ink-paper); box-shadow: 0 3px 0 var(--ink-paper); }

/* ---------- Pip ---------- */
.pip { overflow: visible; }
.pip .pip-black { fill: #1B2733; }
.pip .pip-belly, .pip .pip-face { fill: #FFFFFF; }
.pip .pip-beak { fill: #F0592A; stroke: #1B2733; stroke-width: 1.5; }
.pip .pip-beak-band { fill: #F6C945; }
.pip .pip-beak-line { stroke: #B23A1A; stroke-width: 1.6; }
.pip .pip-foot { fill: #F28C28; stroke: #1B2733; stroke-width: 1.4; }
.pip .pip-cheek { fill: #F4A3B5; opacity: .8; }
.pip .pip-eye { fill: #1B2733; }
.pip .pip-eye-happy, .pip .pip-brow { stroke: #1B2733; stroke-width: 2.6; stroke-linecap: round; }
.pip .pip-eye-happy { display: none; }
.pip .pip-brow { opacity: 0; transition: opacity .2s; }
.pip .pip-scarf, .pip .pip-scarf-tail { fill: #FFB43A; stroke: #1B2733; stroke-width: 1.4; }
.pip .pip-shadow { fill: rgba(23, 50, 74, .16); }
.pip .pip-body { transform-origin: 58px 106px; animation: breathe 3.6s ease-in-out infinite; }
.pip .pip-head { transform-origin: 58px 48px; transition: transform .35s var(--ease-spring); }
.pip .pip-wing { transform-origin: 36px 66px; transition: transform .35s var(--ease-spring); }
.pip.blink .pip-eye-open { transform: scaleY(.1); transform-origin: 66px 30px; }
@keyframes breathe { 50% { transform: scale(1.015, .985); } }
.pip[data-mood="happy"] .pip-body { animation: hop .7s var(--ease-spring) 2; }
.pip[data-mood="happy"] .pip-eye-open { display: none; }
.pip[data-mood="happy"] .pip-eye-happy { display: block; }
.pip[data-mood="happy"] .pip-wing { transform: rotate(-38deg); }
.pip[data-mood="think"] .pip-head { transform: rotate(-12deg); }
.pip[data-mood="think"] .pip-brow { opacity: 1; }
.pip[data-mood="hint"] .pip-wing { transform: rotate(-70deg) translate(4px, -6px); }
.pip[data-mood="hint"] .pip-head { transform: rotate(6deg); }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-16px) scale(1.02, .98); } 60% { transform: translateY(-16px); } }

/* sparkles */
.spark { position: fixed; z-index: 70; width: 14px; height: 14px; pointer-events: none; }
.spark svg { width: 100%; height: 100%; }

/* stamps */
.stamp .perf { fill: var(--paper); }
.stamp-ink { mix-blend-mode: multiply; }

/* footer */
.foot { padding: 24px 0 36px; border-top: 1px solid var(--line); margin-top: 30px; font-size: .84rem; color: var(--ink-3); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }
/* every footer link is a full-size target, like the grown-ups button beside it */
.foot-label { font-weight: 700; color: var(--ink-2); }
/* the grown-ups' links follow their label and wrap whole, spaced apart, so no separator is left hanging */
.foot-links { display: inline-flex; flex-wrap: wrap; align-items: center; column-gap: 10px; }
.foot-links > * { white-space: nowrap; }
.foot a { color: var(--ink-2); display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; vertical-align: middle; }
.foot .link-btn { vertical-align: middle; padding-inline: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .atlas-frame { height: auto; aspect-ratio: 4 / 4.4; border-radius: 22px; }
  .daily-card { max-width: none; width: 100%; }
  .head-cards { width: 100%; }
  /* phone map: every landmark keeps a short, wrapped name */
  .lm { min-width: 56px; }
  .lm-label { display: block; font-size: .72rem; line-height: 1.1; white-space: normal; max-width: 74px; text-align: center; padding: 2px 6px 3px; }
  .lm-pips { gap: 2px; } .lm-pips i { width: 7px; height: 7px; }
  .lm .landmark { width: 50px; }
  /* phone top bar: icon buttons, and the brand without its subtitle */
  .topbar { gap: 8px; }
  .topbar .tb-btn { width: 44px; padding: 0; justify-content: center; }
  .brand-name small { display: none; }
  .guide { grid-template-columns: 58px minmax(0, 1fr); }
  .guide .pip { width: 58px; height: 58px; }
  .speak-btn { width: 44px; height: 44px; }
  .board { border-radius: 22px; }
  .topbar .hide-sm { display: none; }
  .play-bar .stones { order: 3; width: 100%; justify-content: center; }
  .region-head { grid-template-columns: 1fr; gap: 6px; }
  .actions .btn { flex: 1; min-width: 0; }
  /* turns may stack; a standing mirror must stay upright between the shape and its
     reflection, or it reads as water (the other kind of reflection) */
  /* a turn sits in one row (tile, turn, gap), so the tile never has to shrink to fit the
     screen; only water, which reflects top to bottom, stacks */
  .stem-spatial:not(.axis-h) { flex-direction: row; gap: 10px; }
  .stem-spatial:not(.axis-h) .sp-source, .stem-spatial:not(.axis-h) .sp-gap { --s: clamp(96px, 30vw, 130px); }
  .stem-spatial .sp-source, .stem-spatial .sp-gap { padding: calc(var(--s) * .06); }
  /* Show the rule on a phone: a smaller practice picture and a tighter rule panel, so the
     puzzle, the rule and the choices need as little scrolling as they can */
  .why-visual .sheet-big { width: min(150px, 40vw); }
  .why-visual .after-copy .after-art { width: 84px; height: 84px; padding: 8px; }
  .why-visual .practice-note { margin-top: 2px; font-size: .84rem; }
  .rule-panel { gap: 8px; padding: 10px 12px; }
  .stem-spatial .op-turn svg { width: 48px; height: 48px; }
  .stem-spatial .op { font-size: .8rem; text-align: center; max-width: 64px; }
  .stem-spatial.axis-v .op-mirror .mirror-line { width: 12px; height: clamp(96px, 30vw, 130px); }
}
@media (max-width: 420px) {
  /* hidden from view but still the link's name */
  .topbar .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* the two closest landmarks lean apart so their names never touch */
  .lm[data-go="region/quant"] .lm-label { transform: translateX(-12px); }
  .lm[data-go="region/classify"] .lm-label { transform: translateX(12px); }
  .fold-panel { width: 92px; }
  .grade-pick { grid-template-columns: repeat(2, 1fr); }
  /* a narrow dialog stacks its buttons, so a label never runs past its button */
  .modal .actions { flex-direction: column; align-items: stretch; }
  .modal .actions .btn { width: 100%; flex: none; }
}

/* ---------- shared links ---------- */
.assigned-note { display: inline-block; margin: 6px 0 0; padding: 3px 12px; border-radius: 999px; font-size: .9rem; font-weight: 600; line-height: 1.4; color: var(--ink-2); background: var(--panel-2); border: 1.5px dashed var(--ink-3); }

/* grown-ups: share a trail */
.share-pick { display: grid; gap: 10px; margin: 10px 0; }
.share-pick label { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; }
.share-pick select, .share-out input { min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--ink); padding: 0 12px; font: inherit; font-weight: 500; min-width: 0; }
.gate-ask { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.gate-ask[hidden] { display: none; }
.gate-ask input { min-height: 44px; width: 5em; border-radius: 10px; border: 2px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; padding: 0 10px; }
.share-about { margin: 0 0 10px; font-size: .92rem; color: var(--ink-2); }
.share-out { display: flex; gap: 8px; align-items: center; }
.share-out input { flex: 1; font-size: .88rem; }
.share-out .btn { flex: none; }

/* ---------- see it in place: a tried choice sits in the gap ---------- */
.trial-look { position: relative; z-index: 1; border-color: #C2572E !important; box-shadow: 0 0 0 4px #F6C9B4 !important; }
.mosaic .mcell.trial-look rect:first-child { stroke: #C2572E; stroke-width: 3; }
.pan.trial-look .pan-glow { fill: #FFF4EE; stroke: #C2572E; }
.is-trial:not(g) { border-style: dashed !important; border-color: #C2572E !important; background: #FFF4EE !important; }
.mosaic .trial-ring { fill: none; stroke: #C2572E; stroke-width: 3.5; stroke-dasharray: 7 5; animation: none; }
.trial-pop:not(g) { animation: trialIn .45s var(--ease-spring) both; }
@keyframes trialIn { from { transform: scale(.86); } to { transform: none; } }

/* ---------- Check and Hint always within reach ---------- */
/* While the tray holds only the action buttons, it rides along the bottom of the
   screen until the board's own end scrolls into view. */
.board > #tray:has(> .actions:only-child) {
  position: sticky; bottom: 0; z-index: 6;
  margin-inline: calc(-1 * clamp(14px, 2.6vw, 28px));
  padding: 14px clamp(14px, 2.6vw, 28px) max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--paper) 18px);
  border-radius: 0 0 26px 26px;
}
.board > #tray > .actions:only-child { margin-top: 0; }
.board .actions { position: relative; }
.more-cue { position: absolute; left: 50%; top: -52px; transform: translateX(-50%); min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--ink-3); background: var(--panel); color: var(--ink); font-weight: 700; font-size: .88rem; box-shadow: var(--shadow-sm); white-space: nowrap; }
.more-cue[hidden] { display: none; }

/* Short laptop and Chromebook screens: the puzzle, its choices and Check fit in one view. */
@media (min-width: 700px) and (max-height: 820px) {
  .play { padding-block: 8px 20px; }
  /* the results screen keeps its buttons on screen */
  .results { padding-block: 8px 24px; gap: 8px; }
  .results h1 { font-size: 2.2rem; }
  .stamp-press { width: min(170px, 26vh); }
  .big-stars svg { width: 42px; height: 42px; }
  .results .actions { margin-top: 0; }
  .board { margin-top: 8px; padding: 12px 22px 0; }
  .guide { grid-template-columns: 60px minmax(0, 1fr); }
  .guide .pip { width: 60px; height: 60px; }
  .bubble { min-height: 50px; padding: 8px 12px 8px 16px; }
  .bubble-text { font-size: 1.05rem; }
  .speak-btn { width: 44px; height: 44px; }
  .stage { min-height: 0; padding: 8px 0 4px; }
  .mosaic { width: min(100%, 300px); }
  .matrix { width: min(100%, calc(var(--n) * 92px)); }
  .an-card { --s: clamp(80px, 13.5vh, 112px); }
  .na-card { --s: clamp(56px, 9.5vh, 96px); }
  .stem-na { gap: 6px; } .na-row { padding-block: 5px; }
  .shelf { width: min(100%, 540px); }
  .shelf-item { max-width: 118px; }
  .sp-source, .sp-gap { --s: clamp(104px, 19vh, 150px); }
  .fold-panel { width: clamp(84px, 15vh, 120px); }
  .options { max-width: min(880px, calc(var(--n, 3) * 24vh)); margin-top: 8px; }
  .options.is-rods .opt { max-height: 26vh; }
  .why, .rule-panel { margin-top: 10px; }
}
/* Wide but short (most Chromebooks and laptops): the puzzle and its choices sit side by
   side, so everything the child needs is on one screen without scrolling. */
@media (min-width: 1000px) and (max-height: 820px) {
  .board {
    display: grid; column-gap: clamp(20px, 3vw, 40px); align-items: center;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas: "guide guide" "stage options" "why why" "rule rule" "tray tray";
  }
  .board > .guide { grid-area: guide; }
  .board > .stage { grid-area: stage; }
  .board > .why-visual { grid-area: why; }
  .board > .options { grid-area: options; margin: 0; max-width: none; align-self: center; }
  .board > #rule { grid-area: rule; }
  .board > #tray { grid-area: tray; }
  .mosaic { width: min(100%, 330px); }
  .scale2 { width: min(100%, 520px); }
  /* number pairs: the counters in the pairs are drawn near the size of those on the choices */
  .na-card { --s: clamp(64px, 14.5vh, 112px); width: calc(var(--s) * 1.4); }
  .stem-na { gap: 5px; } .na-row { padding-block: 3px; }
  .options.n-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* "Show the rule" with a practice picture (folding, turning and mirroring): the picture sits
     beside the rule, under the puzzle, so the puzzle and its choices stay in view */
  .board:has(> .why-visual:not(:empty)) { grid-template-areas: "guide guide" "stage options" "why rule" "tray tray"; }
  .board:has(> .why-visual:not(:empty)) > #rule .why { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; margin-top: 10px; }
  .board:has(> .why-visual:not(:empty)) > #rule .why > .why-badge { grid-area: 1 / 1; align-self: center; }
  .board:has(> .why-visual:not(:empty)) > #rule .why > .actions { grid-area: 1 / 2; }
  .board:has(> .why-visual:not(:empty)) > #rule .why > div:not(.actions) { grid-area: 2 / 1 / 3 / 3; }
  .board:has(> .why-visual:not(:empty)) > .options .opt { max-height: min(130px, 20vh); }
  .sheet-big { width: min(200px, 28vh); }
  /* "which one does not belong": the pictures are the puzzle, so they take the full width */
  .board:has(.stem-odd) { grid-template-areas: "guide guide" "stage stage" "options options" "why why" "rule rule" "tray tray"; }
  .board:has(.stem-odd) > .options.n-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 900px; margin-inline: auto; }
  .board:has(.stem-odd) > .options.n-3 { max-width: 640px; margin-inline: auto; }
  .options .opt { max-height: min(170px, 27vh); }
  /* five tall bead rods in two rows stay above the Hint and Check bar */
  .options.is-rods .opt { max-height: 22vh; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

/* Pip's friends across the Sea of Ideas (shared Reasonwell cast) */
.beyond-faces { display: flex; margin-bottom: 6px; }
.beyond-faces svg { width: 52px; height: 52px; margin-left: -12px; background: var(--paper, #fff); border-radius: 50%; border: 2px solid rgba(23, 50, 74, .15); }
.beyond-faces svg:first-child { margin-left: 0; }
.beyond-links { font-weight: 700; }
.beyond-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- storage that can't save ---------- */
.store-wrap { margin-top: 10px; }
.run-note { margin-top: 8px; }
.store-note { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 14px; border-radius: 14px; background: #FFF2D6; border: 1px solid #E8C77A; color: #17324A; font-size: .92rem; line-height: 1.45; }
.store-ico svg { width: 18px; height: 18px; display: block; margin-top: 2px; color: #8A5A00; }

/* ---------- results: expedition stars are labelled as today's route ---------- */
.big-stars-label { margin: 8px 0 -6px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- a screen that failed to open ---------- */
.recovery { padding-block: 40px 20px; max-width: 70ch; }
.recovery h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 10px; }
.recovery p { color: var(--ink-2); }
.recovery .link-btn { padding-inline: 0; }

/* ---------- phones: the puzzle, all its choices and Check in one view ----------
   The header and Pip get compact, the Hint and Check bar sits under the choices instead of
   floating over them, and play.js shrinks the puzzle drawing (never below 55%) until the
   choices and the bar fit on the screen under it. */
@media (max-width: 640px) {
  .play { padding-block: 4px 20px; }
  .play-bar { flex-wrap: nowrap; align-items: flex-start; gap: 6px 10px; }
  .play-bar .stones { order: 0; width: auto; justify-content: flex-end; padding-top: 4px; }
  .play-title .eyebrow { font-size: .66rem; }
  .play-title h1 { font-size: 1.1rem; }
  .assigned-note { font-size: .78rem; padding: 2px 10px; margin-top: 4px; }
  .stones { gap: 4px; }
  .stones i { width: 11px; height: 8px; border-width: 1.5px; }
  .board { margin-top: 6px; padding: 10px 10px 4px; }
  .guide { grid-template-columns: 40px minmax(0, 1fr); gap: 8px; }
  .guide .pip { width: 40px; height: 40px; }
  .bubble { min-height: 44px; padding: 6px 8px 6px 12px; }
  .bubble-text { font-size: 1rem; line-height: 1.3; }
  .stage { padding: 6px 0 2px; }
  .stage > .stem { transform-origin: top center; }
  .options { margin-top: 6px; gap: 8px; }
  .options.is-rods .opt { aspect-ratio: auto; height: 132px; max-height: 132px; }
  /* opened sheets have small holes to compare: on a phone they get the card's full width */
  .options.is-sheets .opt { aspect-ratio: 6 / 7; padding: 22px 5px 5px; }
  .board > #tray:has(> .actions:only-child) { position: static; margin-inline: 0; padding: 10px 0 6px; background: none; border-radius: 0; }
  /* number pairs: less frame around each card, so the counters themselves get the room */
  .stem-na { gap: 6px; }
  .na-row { padding: 3px 6px; gap: 8px; }
  .na-card { --s: 76px; width: calc(var(--s) * 1.45); padding: 4px; }
  .na-arrow { font-size: 1.5rem; }
}
