/* ============================================================
   Government Thread — theme
   Sister to Math Thread, Science Thread & English Thread:
   the same scholarly dark DNA, tinted a patriotic navy — Liberty
   the bald eagle's home. Deep navy glass, gold Liberty Bells, red
   accents on clean white neutrals. Each world climbs a little
   higher through the story of the republic. Mobile-first.
   ============================================================ */
:root {
  --bg: #0f1a33;
  --bg-2: #14213f;
  --panel: #172a4d;
  --panel-2: #22315c;
  --line: #33436e;
  --ink: #eef2f8;
  --ink-dim: #c6d0e0;
  --muted: #8f9cb5;
  --gold: #f2b23d;
  --gold-soft: #f8d187;
  --good: #6fce9f;
  --bad: #e07a68;
  --heart: #e0705f;
  --accent: #b22234;          /* per-world accent; JS swaps this */
  --accent-soft: #e6a1a8;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --maxw: 720px;
  --fs: 16px;
}
/* world accents — a growing economy: from green market shoots up through the
   gold of trade and finance, out to the blues of the global economy. */
:root[data-world="2"] { --accent: #d9a441; --accent-soft: #f2d59a; }
:root[data-world="3"] { --accent: #37b0a0; --accent-soft: #8fe6da; }
:root[data-world="4"] { --accent: #e0954a; --accent-soft: #f2c48f; }
:root[data-world="5"] { --accent: #5a86e6; --accent-soft: #a9c2f4; }
:root[data-world="6"] { --accent: #3fb56d; --accent-soft: #a0e4bd; }
:root[data-world="7"] { --accent: #4fc98a; --accent-soft: #a6e9c6; }
:root[data-world="8"] { --accent: #c8963f; --accent-soft: #f0d59a; }
:root[data-world="9"] { --accent: #7c7ff0; --accent-soft: #c0c2f8; }
:root[data-world="10"] { --accent: #28b8c0; --accent-soft: #9fe3e8; }
:root[data-world="11"] { --accent: #3f8fd0; --accent-soft: #a4cbec; }
:root[data-world="12"] { --accent: #b18cf0; --accent-soft: #d6c2f7; }

/* accessibility toggles */
:root[data-bigtext="1"] { --fs: 19px; }
:root[data-readable="1"] body,
:root[data-readable="1"] button,
:root[data-readable="1"] h1, :root[data-readable="1"] h2, :root[data-readable="1"] h3 {
  font-family: Verdana, "Comic Sans MS", Tahoma, sans-serif !important;
  letter-spacing: .3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #22315c 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
/* faint drifting bubbles / plankton grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: .1px; line-height: 1.18; }
[tabindex="-1"]:focus { outline: none; }
::selection { background: var(--gold); color: #201a08; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--gold); color: #201a08; padding: 8px 14px; z-index: 99; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }
.seo-fallback { color: var(--ink-dim); }

/* ---- App bar ------------------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(12,20,40,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; color: var(--ink); padding: 4px; }
.brand-glyph { display: inline-flex; line-height: 1; }
.brand-glyph svg { width: 26px; height: 26px; display: block; filter: drop-shadow(0 0 10px rgba(178,34,52,.5)); }
/* the Calculator-Token icon: the flat gold quadrant mark */
.token-ico { display: inline-flex; }
.token-ico svg { width: 16px; height: 16px; display: block; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.appbar-stats { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; font-size: 14px; color: var(--ink-dim);
}
.chip b { color: var(--ink); }
.chip.hearts b { color: var(--heart); }
.chip.ink-chip b { color: var(--gold-soft); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); border-radius: 999px; width: 34px; height: 34px; display: grid; place-items: center; font-size: 16px; padding: 0; }
.icon-btn:hover { border-color: var(--gold); color: var(--ink); }
/* Unobtrusive "back to LoomLearn" button — small, tucked at the far top-left. */
.appbar-lead { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.loom-home { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--gold-soft); opacity: .6; text-decoration: none; transition: opacity .14s ease, border-color .14s ease, transform .14s ease; }
.loom-home:hover { opacity: 1; border-color: var(--gold); transform: translateY(-1px); }
.loom-home-mark { display: inline-flex; line-height: 1; }
.level-chip { flex-direction: column; align-items: stretch; gap: 3px; padding: 4px 10px; }
.lvl { font-size: 12px; color: var(--gold-soft); font-weight: 700; text-align: center; }
.lvl-bar { width: 54px; height: 4px; background: #0a1226; border-radius: 3px; overflow: hidden; }
.lvl-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }

@media (max-width: 560px) {
  .brand-name { display: none; }
  .appbar { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .appbar-stats { gap: 5px; flex-wrap: nowrap; }
  .chip { padding: 4px 8px; font-size: 12.5px; gap: 4px; }
  .icon-btn { width: 30px; height: 30px; font-size: 15px; }
  .level-chip { padding: 3px 8px; }
  .lvl-bar { width: 42px; }
  .lvl { font-size: 11px; }
}

/* ---- Layout ------------------------------------------------- */
.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px calc(40px + env(safe-area-inset-bottom));
  animation: fade .28s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Home --------------------------------------------------- */
.home-hero { text-align: center; padding: 10px 8px 4px; }
.home-title {
  font-size: clamp(24px, 5.5vw, 34px);
  margin: 2px 0 2px; color: var(--ink);
  letter-spacing: .2px; font-weight: 800;
}
.home-title::after {
  content: ""; display: block; width: 38px; height: 2px; margin: 9px auto 0;
  background: var(--gold); border-radius: 2px; opacity: .8;
}
.home-tag {
  color: var(--muted); margin: 0 auto 12px; max-width: 36ch;
  font-style: italic; font-family: var(--serif); font-size: 15px;
}
/* the four operations on a coordinate graph — front and center */
.home-book { display: flex; justify-content: center; margin: 6px 0 14px; }
.book-art {
  width: min(230px, 62%); height: auto;
  filter: drop-shadow(0 7px 18px rgba(0,0,0,.45));
  animation: bookbob 5s ease-in-out infinite;
}
@keyframes bookbob { 0%,100% { transform: translateY(0) rotate(-0.6deg); } 50% { transform: translateY(-4px) rotate(0.6deg); } }

.section-head { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin: 26px 4px 12px; }

.continue-btn { margin: 14px 0 4px; }

/* "Your journey" — whole-course progress on the home screen */
.journey {
  margin: 8px 0 4px;
  background: linear-gradient(135deg, rgba(178,34,52,.14), rgba(242,178,61,.10));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.journey-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.journey-title { font-family: var(--serif); font-size: 17px; color: var(--ink); }
.journey-pct { font-family: var(--serif); font-weight: 900; font-size: 20px; color: var(--gold-soft); }
.journey-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 13px; color: var(--ink-dim); }
.journey-stat b { color: var(--ink); }

/* themed chapter headers on the Republic Map */
.chapter-head {
  display: flex; flex-direction: column; gap: 1px;
  margin: 22px 2px 10px; padding-left: 11px;
  border-left: 4px solid var(--accent); border-radius: 2px;
}
.chapter-title { font-family: var(--serif); font-weight: 700; font-size: 17px; color: var(--ink); }
.chapter-check { color: var(--good); }
.chapter-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* Tally's Trial call-out on the home screen */
.trial-cta {
  position: relative; width: 100%; text-align: left; margin: 16px 0 4px;
  display: flex; gap: 14px; align-items: center;
  background: linear-gradient(135deg, rgba(178,34,52,.16), rgba(242,178,61,.12));
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 15px 16px; color: var(--ink);
  box-shadow: 0 0 22px rgba(178,34,52,.14);
  transition: transform .12s ease, box-shadow .12s ease;
}
.trial-cta:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.trial-cta-glyph { font-size: 34px; flex: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); animation: bossbob 3.6s ease-in-out infinite; }
.trial-cta-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.trial-cta-title { font-family: var(--serif); font-size: 19px; color: var(--gold-soft); }
.trial-cta-sub { font-size: 13px; color: var(--ink-dim); }
.trial-cta-badge {
  font-size: 11px; font-weight: 700; color: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: 999px; padding: 3px 10px; flex: none;
  background: rgba(178,34,52,.12);
}
.trial-cta-badge.done { color: var(--good); border-color: rgba(111,206,159,.5); background: rgba(111,206,159,.1); }

/* world cards on home */
.world-list { display: flex; flex-direction: column; gap: 12px; }
.world-card {
  position: relative; text-align: left; width: 100%;
  display: flex; gap: 14px; align-items: center;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  padding: 16px; color: var(--ink);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.world-card:not(:disabled):hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow); }
.world-card:disabled { cursor: default; opacity: .55; }
.world-glyph { font-size: 32px; flex: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); }
.world-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.world-name { font-family: var(--serif); font-size: 19px; }
.world-grade { font-size: 11px; color: var(--accent-soft); font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.world-sub { font-size: 13px; color: var(--ink-dim); }
.world-progress { margin-top: 4px; }
.world-lock { margin-left: auto; font-size: 20px; color: var(--muted); flex: none; }
.world-soon { font-size: 11px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 2px 9px; flex: none; }

.home-foot { text-align: center; margin-top: 26px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.link-btn { background: none; border: 0; color: var(--gold-soft); text-decoration: underline; font-size: 13.5px; padding: 0; }
.home-foot a { color: var(--gold-soft); }

/* ---- Progress bar ------------------------------------------- */
.progress { position: relative; height: 17px; background: #0a1226; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); transition: width .5s ease; }
.progress.gold .progress-fill { background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }
.progress-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10.5px; line-height: 1; font-weight: 600; letter-spacing: .4px;
  color: var(--ink); text-shadow: 0 1px 2px rgba(0,0,0,.75);
}
.world-progress { display: block; }

/* ---- The Path ------------------------------------------------ */
.path-head { text-align: center; margin: 4px 0 6px; }
.path-title { font-size: clamp(26px, 7vw, 36px); margin: 4px 0 2px; }
.path-spirit { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 14.5px; max-width: 44ch; margin: 0 auto 8px; }
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 18px 0 8px; }
.path::before {
  content: ""; position: absolute; top: 30px; bottom: 30px; left: 50%;
  width: 3px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, var(--line) 0 10px, transparent 10px 20px);
}
.path-node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--ink);
  padding: 12px 10px; width: min(340px, 88vw);
}
/* Zigzag the timeline only where there's room. A node is min(340px, 88vw) — on
   a phone that's nearly the full width, so an 11% shift would push it off-screen
   (a 20px horizontal overflow on every world page). Keep the nodes centered on
   narrow screens; reinstate the zigzag once the viewport is wide enough. */
@media (min-width: 620px) {
  .path-node:nth-child(odd)  { transform: translateX(-11%); }
  .path-node:nth-child(even) { transform: translateX(11%); }
}
.node-bubble {
  width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center; font-size: 32px;
  background: var(--panel); border: 3px solid var(--line);
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
  transition: transform .12s ease, border-color .12s ease;
}
.path-node:not(:disabled):hover .node-bubble { transform: translateY(-3px); border-color: var(--accent); }
.path-node:not(:disabled):active .node-bubble { transform: translateY(0); }
.path-node.done .node-bubble { border-color: var(--accent); background: linear-gradient(160deg, var(--panel-2), var(--panel)); }
.path-node.gold .node-bubble { border-color: var(--gold); box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 22px rgba(242,178,61,.35); }
.path-node.next .node-bubble { border-color: var(--accent); animation: pulse 1.8s ease infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 0 rgba(178,34,52,.45); } 50% { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 12px rgba(178,34,52,0); } }
.path-node:disabled { cursor: default; }
.path-node:disabled .node-bubble { opacity: .45; filter: grayscale(.6); }
.node-label { font-family: var(--serif); font-size: 15.5px; text-align: center; max-width: 24ch; }
.path-node:disabled .node-label { color: var(--muted); }
.node-sub { font-size: 12px; color: var(--muted); }
.node-crowns { font-size: 12px; letter-spacing: 1px; color: var(--gold-soft); min-height: 15px; }
.node-boss .node-bubble { width: 92px; height: 92px; font-size: 44px; border-color: #7a4b3a; }
.node-boss.next .node-bubble { border-color: var(--bad); animation: pulse 1.8s ease infinite; }
.node-boss.done .node-bubble { border-color: var(--gold); }
.path-next-world { margin: 20px auto 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---- Lesson player chrome ------------------------------------ */
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.qcount { font-size: 13px; color: var(--muted); text-align: center; flex: 1; font-weight: 600; }
.hearts-live { font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.ghost-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--gold); }
.ob-or {
  display: flex; align-items: center; gap: 12px; margin: 2px 0;
  color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
}
.ob-or::before, .ob-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.loom-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 13px 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.loom-btn:hover { border-color: var(--gold); background: var(--panel-2); }
.loom-btn:active { transform: scale(.99); }
.loom-btn .ll-mark { display: inline-flex; }
.loom-btn .ll-mark svg { display: block; }
.ob-sso { margin-top: 12px; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.4; }
.primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #241c05; border: 0; font-weight: 700; font-size: 16px;
  padding: 14px 20px; border-radius: 12px; width: 100%;
  box-shadow: 0 6px 18px rgba(242,178,61,.25);
  transition: transform .1s ease, filter .1s ease;
}
.primary:hover { filter: brightness(1.05); }
.primary:active { transform: scale(.98); }
.primary:disabled { filter: grayscale(.5) brightness(.7); cursor: default; transform: none; }
.danger-btn { background: rgba(215,106,99,.12); border: 1px solid var(--bad); color: #f0a9a4; padding: 12px 18px; border-radius: 12px; font-weight: 600; }

.qbar { height: 6px; background: #0a1226; border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
.qbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); transition: width .3s ease; }
.qprompt { font-size: clamp(19px, 5vw, 24px); line-height: 1.35; margin: 0 0 18px; font-family: var(--serif); }

/* teaching cards */
.teach-card {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: var(--radius); padding: 18px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); animation: fade .25s ease;
}
.teach-card h3 { margin: 0 0 8px; color: var(--gold-soft); }
.teach-card p { margin: 0 0 10px; color: var(--ink); }
.teach-card p:last-child { margin-bottom: 0; }
.teach-card em { color: var(--accent-soft); font-style: italic; }
.teach-card strong { color: var(--gold-soft); }
.teach-ex { font-family: var(--mono); font-style: normal; background: rgba(0,0,0,.28); border-radius: 10px; padding: 10px 14px; margin: 8px 0; color: var(--accent-soft); font-size: 15px; }

/* "Go deeper" bonus card — Study-screen only, tinted with the world accent */
.deepen-card { border-left-color: var(--accent); background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, var(--panel)), var(--panel)); }
.deepen-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent-soft); background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; margin-bottom: 9px; }
.deepen-card h3 { color: var(--accent-soft); }

/* ---- Exercise widgets ---------------------------------------- */
.options { display: flex; flex-direction: column; gap: 11px; }
.option {
  text-align: left; background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 16px; padding: 15px 16px; border-radius: 13px;
  transition: border-color .12s, background .12s, transform .08s;
}
.option:not(:disabled):hover { border-color: var(--accent); background: var(--panel-2); }
.option:not(:disabled):active { transform: scale(.99); }
.option:disabled { opacity: .95; cursor: default; }
.option.correct { border-color: var(--good); background: rgba(111,206,159,.16); color: #d7f5e6; }
.option.wrong { border-color: var(--bad); background: rgba(215,106,99,.15); color: #f6cecb; }
/* numeric multiple-choice: center the numbers, make them big and monospace */
.options.numeric { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.options.numeric .option { flex: 1 1 40%; min-width: 120px; text-align: center; font-family: var(--mono); font-size: 22px; font-weight: 700; padding: 18px 12px; }

/* tap-the-word / tap-the-number */
.tapwords { display: flex; flex-wrap: wrap; gap: 8px 6px; font-family: var(--serif); font-size: 19px; line-height: 1.6; margin-bottom: 8px; justify-content: center; }
.tapword {
  background: none; border: 1.5px solid transparent; border-radius: 9px;
  color: var(--ink); padding: 3px 9px; font-family: var(--mono); font-size: 20px; font-weight: 700;
  transition: border-color .1s, background .1s;
}
.tapword:not(:disabled):hover { border-color: var(--accent); background: var(--panel-2); }
.tapword.correct { border-color: var(--good); background: rgba(111,206,159,.16); }
.tapword.wrong { border-color: var(--bad); background: rgba(215,106,99,.15); }
.tapword.reveal { border-color: var(--good); }

/* word/number bank builder */
.wb-answer {
  min-height: 58px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  border-bottom: 2px solid var(--line); padding: 6px 2px 12px; margin-bottom: 18px;
  justify-content: center;
}
.wb-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.tile {
  background: var(--panel); border: 1.5px solid var(--line); border-bottom-width: 3px;
  color: var(--ink); font-size: 18px; padding: 9px 15px; border-radius: 11px;
  font-family: var(--mono); font-weight: 700;
  transition: transform .08s, border-color .1s;
}
.tile:not(:disabled):hover { border-color: var(--accent); }
.tile:not(:disabled):active { transform: scale(.96); }
.tile.ghost { opacity: .25; pointer-events: none; }
.wb-answer .tile { background: var(--panel-2); }
.wb-answer.good .tile { border-color: var(--good); }
.wb-answer.bad .tile { border-color: var(--bad); }

/* match pairs */
.mp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.mp-col { display: flex; flex-direction: column; gap: 10px; }
.mp-item {
  text-align: center; background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 15.5px; padding: 12px 12px; border-radius: 12px;
  min-height: 52px; line-height: 1.35; display: grid; place-items: center;
  transition: border-color .1s, background .1s, opacity .3s;
}
.mp-item:not(:disabled):hover { border-color: var(--accent); }
.mp-item.active { border-color: var(--gold); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(242,178,61,.18); }
.mp-item.done { opacity: .35; border-style: dashed; cursor: default; }
.mp-item.flash { border-color: var(--bad); background: rgba(215,106,99,.15); animation: shake .3s ease; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* order-it */
.ord-pool, .ord-answer { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ord-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 16px; padding: 12px 14px; border-radius: 12px;
}
.ord-item:not(:disabled):hover { border-color: var(--accent); }
.ord-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--gold-soft);
}
.ord-item.ok { border-color: var(--good); background: rgba(111,206,159,.1); }
.ord-item.miss { border-color: var(--bad); background: rgba(215,106,99,.1); }
.ord-item.ghost { opacity: .25; pointer-events: none; }

/* feedback + explain */
.explain { margin-top: 18px; border-radius: 13px; padding: 14px 16px; border: 1px solid var(--line); animation: fade .25s ease; }
.explain.good { border-color: rgba(111,206,159,.5); background: rgba(111,206,159,.08); }
.explain.bad { border-color: rgba(215,106,99,.5); background: rgba(215,106,99,.08); }
.explain-head { font-weight: 700; font-family: var(--serif); margin-bottom: 4px; }
.explain.good .explain-head { color: var(--good); }
.explain.bad .explain-head { color: var(--bad); }
.explain-body { color: var(--ink-dim); font-size: 14.5px; }
.explain-body strong { color: var(--gold-soft); font-family: var(--mono); }
.next-btn { margin-top: 16px; }

/* ---- Results / end screens ----------------------------------- */
.result-card { text-align: center; background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 20px; box-shadow: var(--shadow); }
.result-emoji { font-size: 54px; }
.result-card h2 { font-size: 36px; margin: 6px 0 2px; color: var(--gold-soft); }
.result-verdict { color: var(--ink-dim); margin: 0 0 18px; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 6px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--serif); font-size: 20px; color: var(--gold-soft); font-weight: 700; }
.stat-lbl { font-size: 11px; color: var(--muted); }
.record-badge { color: var(--gold-soft); font-weight: 700; margin-bottom: 16px; animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---- Boss battle ---------------------------------------------- */
.boss-head { text-align: center; margin-bottom: 10px; }
.boss-portrait { font-size: 64px; filter: drop-shadow(0 4px 14px rgba(0,0,0,.5)); animation: bossbob 3s ease-in-out infinite; display: inline-block; }
@keyframes bossbob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.boss-portrait.hit { animation: bosshit .4s ease; }
@keyframes bosshit { 0% { transform: scale(1); filter: brightness(2) drop-shadow(0 0 18px rgba(242,178,61,.8)); } 100% { transform: scale(1); } }
.boss-name { font-size: 24px; margin: 2px 0 8px; color: var(--gold-soft); }
.boss-hp { max-width: 300px; margin: 0 auto 4px; }
.boss-hp .progress-fill { background: linear-gradient(90deg, #b0503c, var(--bad)); }
.boss-taunt {
  font-family: var(--serif); font-style: italic; color: var(--ink-dim);
  background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin: 10px auto 14px; max-width: 46ch; min-height: 20px;
  animation: fade .3s ease;
}
.boss-intro-card { text-align: center; }
.boss-intro-card .boss-portrait { font-size: 84px; }

/* ---- Badges / toast / confetti -------------------------------- */
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.badge-pill { background: rgba(242,178,61,.1); border: 1px solid rgba(242,178,61,.35); color: var(--gold-soft); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--gold); color: var(--ink);
  border-radius: 999px; padding: 10px 18px; font-size: 14.5px; z-index: 60;
  box-shadow: var(--shadow); animation: toastin .25s ease;
  max-width: 92vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.confetti { position: fixed; top: -12px; z-index: 70; font-size: 18px; pointer-events: none; animation: confall linear forwards; }
@keyframes confall { to { transform: translateY(105vh) rotate(540deg); opacity: .7; } }

/* ---- Settings / modal ----------------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .2s ease; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; max-width: 420px; width: 100%; max-height: 84dvh; overflow: auto; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 14px; font-size: 22px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-lbl { font-size: 15px; }
.setting-sub { display: block; font-size: 12.5px; color: var(--muted); }
.tog { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; width: 52px; height: 30px; position: relative; flex: none; }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .15s ease, background .15s ease; }
.tog.on { border-color: var(--gold); }
.tog.on::after { transform: translateX(22px); background: var(--gold); }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---- Onboarding ------------------------------------------------ */
.onboard-card { max-width: 460px; margin: 6vh auto 0; }
.ob-penny { display: flex; justify-content: center; margin: 0 0 6px; }
.ob-parents { margin-top: 16px; }
.ob-penny svg { width: 88px; height: 88px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); animation: bookbob 5s ease-in-out infinite; }
.ob-input {
  width: 100%; box-sizing: border-box;
  background: var(--bg-2); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); font-family: inherit; font-size: 17px;
  padding: 13px 14px; margin-bottom: 16px; text-align: center;
}
.ob-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,178,61,.15); }
.ob-input::placeholder { color: var(--muted); }
.ob-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.ob-select {
  flex: 1; min-width: 0;
  background: var(--bg-2); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); font-family: inherit; font-size: 15px; padding: 11px 8px;
}
.ob-select:focus { outline: none; border-color: var(--gold); }

/* recommended-world chip */
.world-card.rec { border-color: var(--gold); box-shadow: 0 0 18px rgba(242,178,61,.12), inset 0 1px 0 rgba(255,255,255,.035); }
.world-card.rec .world-name { padding-right: 74px; }
.rec-chip {
  position: absolute; top: 10px; right: 12px;
  font-size: 11px; color: var(--gold-soft); font-weight: 700;
  background: rgba(242,178,61,.12); border: 1px solid rgba(242,178,61,.35);
  padding: 2px 9px; border-radius: 999px;
}

/* ============================================================
   Tally the octopus — corner mascot (matches Scribbles/Discover:
   quiet mode, cheer bubbles, slide-up help drawer)
   ============================================================ */
.scrib {
  position: fixed; right: 12px; bottom: 92px; z-index: 55;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.scrib > * { pointer-events: auto; }
.scrib-worm-btn {
  width: 64px; height: 64px; padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 0 9px rgba(178,34,52,.5)) drop-shadow(0 6px 12px rgba(0,0,0,.5));
  animation: scrib-bob 3.4s ease-in-out infinite;
}
.scrib.tucked { opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrib.quiet .scrib-worm-btn { pointer-events: none; cursor: default; opacity: .8; }
.scrib.compact { bottom: 150px; }
.scrib.compact .scrib-worm-btn { width: 46px; height: 46px; opacity: .88; }
.scrib.compact .scrib-worm-btn:hover { opacity: 1; }
.scrib.pop .scrib-worm-btn { animation: scrib-pop .5s ease; }
.scrib-worm { width: 100%; height: 100%; display: block; }
@keyframes scrib-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes scrib-pop { 0% { transform: scale(1); } 35% { transform: scale(1.18) rotate(-4deg); } 70% { transform: scale(.95); } 100% { transform: scale(1); } }
.scrib-bubble {
  position: relative; max-width: min(240px, 66vw);
  background: var(--panel-2); border: 1px solid var(--gold);
  border-radius: 13px; padding: 9px 26px 9px 12px;
  color: var(--ink); font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(8px) scale(.96); transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
}
.scrib-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.scrib-bubble::after {
  content: ""; position: absolute; right: 22px; bottom: -8px;
  width: 14px; height: 14px; background: var(--panel-2);
  border-right: 1px solid var(--gold); border-bottom: 1px solid var(--gold);
  transform: rotate(45deg);
}
.scrib-btext { margin: 0; }
.scrib-x {
  position: absolute; top: 5px; right: 7px; width: 20px; height: 20px;
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
}
.scrib-x:hover { color: var(--ink); }
.scrib-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.scrib-abtn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.scrib-abtn.primary { background: var(--gold); border-color: var(--gold); color: #1c1710; font-weight: 700; }

/* Tally's help drawer (the slide-up chat) */
.scrib-veil { position: fixed; inset: 0; z-index: 58; background: rgba(4,12,18,.4); }
.scrib-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 59;
  max-width: 720px; margin: 0 auto;
  background: var(--panel-2); border: 1px solid var(--line); border-bottom: 0;
  border-top: 2px solid var(--gold);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -16px 44px rgba(0,0,0,.55);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s ease;
}
.scrib-drawer.open { transform: translateY(0); }
.scrib-d-head { display: flex; align-items: center; gap: 10px; }
.scrib-d-head .scrib-worm { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 2px 5px rgba(0,0,0,.4)); }
.scrib-d-title { display: flex; flex-direction: column; line-height: 1.2; }
.scrib-d-title strong { font-family: var(--serif); font-size: 16.5px; }
.scrib-d-title span { font-size: 11.5px; color: var(--muted); }
.scrib-d-x {
  margin-left: auto; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
  font-size: 13px; cursor: pointer;
}
.scrib-d-x:hover { border-color: var(--gold); color: var(--ink); }
.scrib-greet { margin: 8px 0; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; font-style: italic; }
.scrib-msgs { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 34vh; margin-bottom: 10px; overscroll-behavior: contain; }
.scrib-dmsg { padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; max-width: 86%; white-space: pre-wrap; }
.scrib-dmsg.me { align-self: flex-end; background: rgba(242,178,61,.15); border: 1px solid rgba(242,178,61,.4); }
.scrib-dmsg.worm { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.scrib-dmsg.typing { color: var(--muted); letter-spacing: 2px; animation: scrib-bob 1s ease-in-out infinite; }
.scrib-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.scrib-chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim); padding: 6px 11px; border-radius: 999px; font-size: 12.5px; cursor: pointer; }
.scrib-chip:hover { border-color: var(--gold); color: var(--ink); }
.scrib-inrow { display: flex; gap: 8px; }
.scrib-in { flex: 1; min-width: 0; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font-size: 14px; }
.scrib-in:focus { outline: none; border-color: var(--gold); }
.scrib-send2 { border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer; background: var(--gold); color: #1c1710; font-weight: 700; font-size: 14px; }
.scrib-send2:disabled { opacity: .55; cursor: default; }

/* ---- Hall of Founders: full-page chat with a founder ------------- */
.scrib-hero { text-align: center; margin: 4px 0 12px; }
.scrib-hero .result-emoji { line-height: 1; }
.scrib-hero .path-spirit { margin: 4px 0 0; }
.scrib-log {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 680px; width: 100%; margin: 0 auto 14px;
}
.scrib-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.scrib-msg.worm { align-self: flex-start; }
.scrib-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.scrib-mini {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px;
  background: var(--panel); border: 1px solid var(--line);
}
.scrib-text {
  padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
.scrib-msg.worm .scrib-text { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.scrib-msg.user .scrib-text { background: rgba(242,178,61,.16); border: 1px solid rgba(242,178,61,.4); border-bottom-right-radius: 5px; }
.scrib-text.dim { color: var(--muted); letter-spacing: 2px; }
.scrib-msg.typing .scrib-text { animation: scrib-bob 1s ease-in-out infinite; }
.scrib-composer {
  display: flex; gap: 8px; align-items: flex-end;
  max-width: 680px; width: 100%; margin: 0 auto;
  position: sticky; bottom: 10px;
}
.scrib-input {
  flex: 1; min-width: 0; resize: none; font-family: inherit; font-size: 15px;
  padding: 12px 14px; border-radius: 14px; max-height: 140px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
}
.scrib-input:focus { outline: none; border-color: var(--gold); }
button.primary.scrib-send {
  width: auto; flex: none; margin: 0; align-self: stretch;
  padding: 12px 22px; border-radius: 14px; font-size: 15px;
}

/* ---- Chat with a Mathematician (Hall of Numbers) ---------------- */
.study-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 540px) { .study-grid { grid-template-columns: 1fr; } }
.scribe-card { align-items: flex-start; }
.scribe-teaches { font-size: 12px; color: var(--gold-soft); margin-top: 4px; }
.scribe-tools { display: flex; justify-content: center; margin-top: 10px; }
.scrib-quiz { font-size: 14px; padding: 9px 16px; }

/* hearts-empty screen */
.hearts-empty { text-align: center; }
.hearts-empty .result-emoji { animation: bossbob 2.4s ease-in-out infinite; }

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

/* ==== Trophy Case (badge collection) ================================== */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 30px; }
.badge-card { background: var(--panel); border: 1px solid rgba(242,178,61,.35); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.badge-card .badge-glyph { font-size: 28px; }
.badge-card .badge-name { font-weight: 700; color: var(--gold-soft); font-size: 14px; }
.badge-card .badge-how { font-size: 12px; color: var(--muted); line-height: 1.35; }
.badge-card.locked { border-color: var(--line); opacity: .62; filter: saturate(.4); }
.badge-card.locked .badge-name { color: var(--ink-dim); }

/* ==== the Game Room (minigames) =========================================== */
.mg-picks, .mg-pool { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.mg-pool { flex-direction: row; flex-wrap: wrap; }
.mg-card { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 15px; cursor: pointer; text-align: left; }
.mg-card:not(.checked):hover { border-color: var(--accent); background: var(--panel-2); }
.mg-card.picked { border-color: var(--accent); }
.mg-card.checked { cursor: default; }
.mg-card.checked.good { border-color: var(--good); background: rgba(111,206,159,.14); }
.mg-card.checked.bad { border-color: var(--bad); background: rgba(215,106,99,.12); }
.mg-slot { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--accent-soft); }
.mg-glyph { font-size: 20px; font-family: var(--mono); font-weight: 700; }
.mg-name { display: flex; flex-direction: column; line-height: 1.25; }
.mg-lived { color: var(--muted); font-size: 12px; }
.mg-truth { color: var(--ink-dim); font-size: 14px; margin: 8px 0; }
.mg-actions { margin: 14px 0 30px; }

/* Sort It! bins */
.sort-item { font-family: var(--mono); font-weight: 700; font-size: 30px; text-align: center; color: var(--ink); background: var(--panel); border: 1.5px solid var(--gold); border-radius: var(--radius); padding: 22px 18px; margin: 6px 0 18px; box-shadow: var(--shadow); }
.sort-bins { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sort-bin { text-align: center; min-height: 76px; display: grid; place-items: center; font-family: var(--serif); font-size: 16px; }
.sort-bin.correct { border-color: var(--good); background: rgba(111,206,159,.16); }
.sort-bin.wrong { border-color: var(--bad); background: rgba(215,106,99,.15); }
@media (max-width: 420px) { .sort-bins { grid-template-columns: 1fr; } }

/* ==== end-of-lesson review round ============================================ */
.review-intro { background: var(--panel); border: 1px solid rgba(178,34,52,.4); border-radius: var(--radius); padding: 18px; margin: 16px 0; text-align: center; }
.review-intro h3 { margin: 0 0 8px; color: var(--accent-soft); }
.review-intro p { color: var(--ink-dim); margin: 0 0 14px; line-height: 1.5; }
.review-tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .4px; color: var(--accent-soft); background: rgba(178,34,52,.12); border: 1px solid rgba(178,34,52,.4); border-radius: 999px; padding: 4px 12px; margin: 10px 0 2px; }
.result-verdict.review-line { color: var(--accent-soft); }

/* ==== Floating dock (Trophy Case + games left, Mathematicians right) ========= */
.dock-rail { position: fixed; left: 10px; top: 72px; z-index: 40; display: flex; flex-direction: column; gap: 11px; }
.dock-hidden .dock-rail, .dock-hidden .dock-study { display: none; }
.dock-btn, .dock-study {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0,0,0,.45);
  cursor: pointer; display: grid; place-items: center;
  transition: transform .12s ease, border-color .12s ease;
}
.dock-btn { position: relative; }
.dock-rail .dock-btn:nth-child(even) { margin-left: 26px; }
.dock-study { position: fixed; right: 10px; top: 72px; z-index: 40; }
.dock-btn:hover, .dock-study:hover { transform: translateY(-2px); border-color: var(--accent); }
.dock-btn:active, .dock-study:active { transform: scale(.94); }
.dock-study { border-color: rgba(242,178,61,.5); }
.dock-study:hover { border-color: var(--gold); }
.dock-ico { font-size: 28px; line-height: 1; }
.dock-count { position: absolute; top: -4px; right: -5px; background: var(--gold); color: #201a08; font-size: 10px; font-weight: 800; line-height: 1; border-radius: 999px; padding: 3px 5px; min-width: 10px; text-align: center; }
.dock-label { position: absolute; left: 66px; top: 50%; transform: translateY(-50%) translateX(-4px); white-space: nowrap; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.dock-label.left { left: auto; right: 66px; transform: translateY(-50%) translateX(4px); }
.dock-btn:hover .dock-label, .dock-btn:focus-visible .dock-label,
.dock-study:hover .dock-label, .dock-study:focus-visible .dock-label { opacity: 1; transform: translateY(-50%) translateX(0); }
@media (max-width: 820px) {
  .dock-btn, .dock-study { width: 40px; height: 40px; }
  .dock-ico { font-size: 19px; }
  .dock-rail  { top: calc(env(safe-area-inset-top) + 80px); left: 6px; gap: 10px; }
  .dock-study { top: calc(env(safe-area-inset-top) + 80px); right: 6px; }
  .dock-rail .dock-btn:nth-child(even) { margin-left: 0; }
  .dock-rail, .dock-study { transition: opacity .38s ease, transform .42s cubic-bezier(.2,.75,.25,1), visibility .42s; }
  .dock.dock-attop .dock-rail  { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-72px); }
  .dock.dock-attop .dock-study { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(72px); }
}

/* ============================================================
   Tally's Trial — the daily timed race
   ============================================================ */
.trial-hero { text-align: center; }
.trial-hero .result-emoji { animation: bossbob 3s ease-in-out infinite; }
.trial-rules { text-align: left; max-width: 380px; margin: 4px auto 18px; color: var(--ink-dim); font-size: 14.5px; line-height: 1.6; }
.trial-rules li { margin-bottom: 6px; }
.trial-meta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.trial-pill { font-size: 12.5px; color: var(--accent-soft); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--panel); }
.trial-pill b { color: var(--gold-soft); }

/* race track */
.race { margin: 6px 0 16px; }
.race-lane { position: relative; height: 46px; margin: 8px 0; background: linear-gradient(180deg, rgba(178,34,52,.06), rgba(178,34,52,.02)); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.race-lane.tally { background: linear-gradient(180deg, rgba(242,178,61,.08), rgba(242,178,61,.02)); }
.race-flag { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 18px; opacity: .8; }
.race-runner { position: absolute; top: 50%; left: 0; transform: translate(0,-50%); font-size: 26px; transition: left .5s cubic-bezier(.3,.8,.4,1); filter: drop-shadow(0 2px 5px rgba(0,0,0,.5)); }
.race-label { position: absolute; left: 10px; top: 3px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* the big timer + question */
.trial-timer { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--accent-soft); text-align: center; }
.trial-timer.low { color: var(--bad); animation: pulse-num .6s ease-in-out infinite; }
@keyframes pulse-num { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.trial-timerbar { height: 8px; background: #0a1226; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 16px; }
.trial-timerbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); transition: width .25s linear; }
.trial-timerbar.low > span { background: linear-gradient(90deg, #b0503c, var(--bad)); }
.trial-eq {
  font-family: var(--mono); font-weight: 700; text-align: center;
  font-size: clamp(38px, 12vw, 60px); color: var(--ink);
  margin: 6px 0 4px; letter-spacing: 2px;
}
.trial-entry {
  font-family: var(--mono); font-weight: 700; text-align: center;
  font-size: clamp(30px, 9vw, 44px); min-height: 1.3em;
  color: var(--gold-soft); letter-spacing: 3px; margin-bottom: 10px;
  border-bottom: 3px solid var(--line); min-width: 120px; display: inline-block;
}
.trial-entry-wrap { text-align: center; }
.trial-entry.filled { border-color: var(--accent); }
.trial-progress { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* number keypad */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 6px auto 0; }
.key {
  background: var(--panel); border: 1.5px solid var(--line); border-bottom-width: 3px;
  color: var(--ink); font-family: var(--mono); font-weight: 700; font-size: 26px;
  padding: 16px 0; border-radius: 13px;
  transition: transform .06s, border-color .1s, background .1s;
}
.key:hover { border-color: var(--accent); background: var(--panel-2); }
.key:active { transform: scale(.95); }
.key.key-enter { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #241c05; border-color: var(--gold); font-size: 18px; }
.key.key-clear { color: var(--bad); font-size: 18px; }
.key.wide { grid-column: span 1; }
.trial-flash { text-align: center; font-family: var(--serif); font-size: 18px; min-height: 24px; margin: 6px 0; }
.trial-flash.good { color: var(--good); }
.trial-flash.bad { color: var(--bad); }

/* ============================================================
   Build 3 — polish pass: spacing, hierarchy, bottom nav, and the
   immersive world page (story / characters / journey / activities)
   ============================================================ */

/* ---- global breathing room ------------------------------------ */
.screen { padding: 20px 18px calc(46px + env(safe-area-inset-bottom)); }
.section-head { margin: 20px 4px 14px; font-size: 13px; }
.home-hero { padding: 10px 8px 2px; }
.home-tag { margin-bottom: 14px; }

/* clear the fixed bottom nav on navigation screens */
body.has-botnav .screen { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
body.has-botnav .scrib { bottom: calc(94px + env(safe-area-inset-bottom)); }

/* ---- richer world cards on the Ocean Map ---------------------- */
.world-card { padding: 18px 18px 18px 22px; gap: 16px; overflow: hidden; }
.world-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent); opacity: .9;
}
.world-card:disabled::before { opacity: .35; }
.world-glyph {
  width: 58px; height: 58px; flex: none; display: grid; place-items: center;
  font-size: 30px; border-radius: 15px;
  background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.08), transparent 60%), var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 0 26px -12px var(--accent);
}
.world-card:not(:disabled):hover { box-shadow: var(--shadow), 0 0 30px -16px var(--accent); }
.world-name { font-size: 20px; }
.world-sub { font-size: 13.5px; line-height: 1.45; margin-top: 1px; }

/* ============================================================
   Bottom navigation bar
   ============================================================ */
.botnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; justify-content: space-around; align-items: stretch;
  gap: 4px;
  background: rgba(10,24,34,.93); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
  box-shadow: 0 -8px 26px rgba(0,0,0,.32);
}
.botnav.botnav-hidden { display: none; }
.botnav-btn {
  position: relative; flex: 1 1 0; min-width: 0;
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px 5px; border-radius: 13px;
  font-size: 11px; font-weight: 700; letter-spacing: .2px;
  transition: color .12s ease, background .12s ease;
}
.botnav-ico { font-size: 22px; line-height: 1; filter: grayscale(.35) opacity(.85); transition: transform .14s ease, filter .14s ease; }
.botnav-label { line-height: 1; }
.botnav-btn:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.botnav-btn.active { color: var(--gold-soft); }
.botnav-btn.active .botnav-ico { filter: none; transform: translateY(-2px) scale(1.06); }
.botnav-btn.active::after {
  content: ""; position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold);
}
.botnav-count {
  position: absolute; top: 3px; left: calc(50% + 6px);
  background: var(--gold); color: #201a08; font-size: 9px; font-weight: 800; line-height: 1;
  border-radius: 999px; padding: 2px 5px; min-width: 8px; text-align: center;
}

/* ============================================================
   The immersive world page
   ============================================================ */
.world-page { animation: fade .3s ease; }
.wp-back { margin-bottom: 16px; }

.wp-hero {
  position: relative; text-align: center; overflow: hidden;
  border-radius: 22px; padding: 32px 22px 26px; margin-bottom: 30px;
  background:
    radial-gradient(130% 100% at 50% -10%, rgba(255,255,255,.08) 0%, transparent 55%),
    linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-top: 3px solid var(--accent);
  box-shadow: var(--shadow), 0 0 70px -28px var(--accent);
}
.wp-hero-glyph {
  font-size: 68px; line-height: 1; display: inline-block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.5));
  animation: bookbob 5.5s ease-in-out infinite;
}
.wp-grade {
  display: inline-block; margin-top: 12px;
  font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; font-weight: 800;
  color: var(--accent-soft); background: rgba(0,0,0,.28);
  border: 1px solid var(--accent); border-radius: 999px; padding: 4px 13px;
}
.wp-title { font-size: clamp(28px, 8vw, 42px); margin: 14px 0 6px; letter-spacing: .2px; }
.wp-spirit { color: var(--ink-dim); font-family: var(--serif); font-style: italic; font-size: 15.5px; max-width: 42ch; margin: 0 auto 18px; }
.wp-progress { max-width: 340px; margin: 0 auto; }

.wp-section { margin: 0 0 34px; }
.wp-sec-head { font-size: 21px; margin: 0 0 4px; color: var(--gold-soft); display: flex; align-items: center; gap: 9px; }
.wp-sec-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 15px; line-height: 1.5; }

.lore-panel {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 15px; padding: 20px 22px; box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.lore-panel p { margin: 0; color: var(--ink-dim); font-size: 15.5px; line-height: 1.75; font-family: var(--serif); }

.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .char-grid { grid-template-columns: 1fr; } }
.char-card {
  position: relative; display: flex; gap: 13px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 15px;
  padding: 15px 15px 15px 15px;
  transition: border-color .12s ease, transform .12s ease;
}
.char-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.char-glyph {
  font-size: 30px; flex: none; width: 54px; height: 54px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 13px;
}
.char-body { min-width: 0; flex: 1; }
.char-name { font-family: var(--serif); font-weight: 700; font-size: 16px; color: var(--ink); line-height: 1.25; }
.char-role { display: block; font-size: 12px; color: var(--accent-soft); font-weight: 600; margin-top: 1px; }
.char-bio { margin: 7px 0 0; font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.char-tag {
  position: absolute; top: 13px; right: 13px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px;
}

.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .activity-grid { grid-template-columns: 1fr; } }
.activity-card {
  display: flex; align-items: center; gap: 13px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 15px;
  color: var(--ink); transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.activity-card:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow); }
.activity-glyph { font-size: 27px; flex: none; }
.activity-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-title { font-family: var(--serif); font-weight: 700; font-size: 15.5px; }
.activity-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.activity-arrow { color: var(--gold-soft); font-size: 20px; flex: none; font-weight: 700; }

.wp-next { text-align: center; color: var(--muted); font-size: 14px; margin: 8px 0 0; line-height: 1.5; }

/* the journey path — nodes now carry a "location" label */
.wp-section .path { padding-top: 8px; }
.node-info { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.node-place { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent-soft); font-weight: 800; opacity: .85; }

/* Closest Catch — numeric estimate choices read best in the number font */
.catch-choices .option { font-family: var(--mono); font-size: clamp(20px, 6vw, 26px); font-weight: 700; letter-spacing: .5px; }

/* Study screen — an accordion of every skill's teaching notes */
.wp-study-btn { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 12px; font-size: 13.5px; }
.study-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.study-node { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.study-node.locked { opacity: .92; }
.study-summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 15px 16px; }
.study-summary::-webkit-details-marker { display: none; }
.study-summary:hover { background: var(--panel-2); }
.study-sum-glyph { font-size: 24px; flex: none; }
.study-sum-title { flex: 1; font-family: var(--serif); font-size: 16px; color: var(--ink); font-weight: 700; }
.study-sum-status { font-size: 12px; color: var(--muted); flex: none; }
.study-summary::after { content: "\25B8"; color: var(--muted); flex: none; transition: transform .15s ease; }
details[open] > .study-summary::after { transform: rotate(90deg); }
.study-body { padding: 2px 16px 16px; }
.study-practice { width: 100%; margin-top: 6px; }
.study-locked-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---- The Diploma (graduation certificate) ---------------------------------- */
.grad-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.diploma {
  max-width: 560px; margin: 8px auto 0;
  background:
    radial-gradient(120% 120% at 50% 0%, #fbf5e4 0%, #f2e6c9 100%);
  border: 3px solid #b8912f; border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  color: #3a2c14;
  font-family: var(--serif);
}
.diploma-inner { border: 1.5px solid #cba44a; border-radius: 8px; margin: 10px; padding: 22px 22px 18px; text-align: center; }
.diploma-mark { display: flex; justify-content: center; }
.diploma-mark svg { width: 42px; height: 42px; }
.diploma-kicker { margin-top: 4px; font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: #7a5a17; font-weight: 700; }
.diploma-title { font-size: clamp(24px, 6vw, 32px); margin: 4px 0 0; color: #2f2410; font-weight: 900; letter-spacing: .3px; }
.diploma-rule { width: 90px; height: 3px; margin: 12px auto 4px; background: linear-gradient(90deg, transparent, #b8912f, transparent); }
.diploma-pre { margin: 12px 0 2px; font-style: italic; color: #6b5a32; font-size: 14px; }
.diploma-name { margin: 2px 0 6px; font-size: clamp(26px, 7vw, 34px); font-weight: 900; color: #2f6b3f; border-bottom: 2px solid #cbb26a; display: inline-block; padding: 0 18px 4px; }
.diploma-body { margin: 8px auto 4px; max-width: 44ch; font-family: var(--sans); font-size: 14px; line-height: 1.5; color: #4a3c22; }
.diploma-rank { margin: 4px 0 12px; font-size: 22px; font-weight: 900; color: #a9791f; letter-spacing: 1px; }
.diploma-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.diploma-stat { background: rgba(184,145,47,.12); border: 1px solid #d8c283; border-radius: 10px; padding: 8px 14px; min-width: 92px; }
.diploma-stat-num { display: block; font-size: 20px; font-weight: 900; color: #2f6b3f; }
.diploma-stat-lbl { display: block; font-family: var(--sans); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #7a5a17; }
.diploma-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 10px; text-align: left; }
.diploma-seal { text-align: center; }
.diploma-seal-glyph { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto; font-size: 26px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #f7dd8f, #cda63a); border: 2px solid #a9791f; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.diploma-seal-txt { font-family: var(--sans); font-size: 10px; letter-spacing: .5px; color: #7a5a17; margin-top: 4px; text-transform: uppercase; }
.diploma-sign { text-align: right; flex: 1; }
.diploma-sign-line { font-size: 17px; color: #2f2410; border-top: 1.5px solid #9c8342; padding-top: 4px; display: inline-block; }
.diploma-sign-sub { font-family: var(--sans); font-size: 11px; color: #6b5a32; }
.diploma-date { font-family: var(--sans); font-size: 12px; color: #7a5a17; margin-top: 6px; }
.diploma-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0 4px; }

@media print {
  body { background: #fff !important; }
  body::before { display: none !important; }
  .appbar, .botnav, .scrib, .wp-back, .diploma-actions, .home-foot, .skip-link { display: none !important; }
  .screen { max-width: none; margin: 0; padding: 0; animation: none; }
  .world-page { animation: none; }
  .diploma { box-shadow: none; border-color: #b8912f; margin: 0 auto; max-width: 100%; }
  @page { margin: 1.2cm; }
}

/* ---- For Parents & Teachers (about) ---------------------------------------- */
.about-page .wp-title { font-size: clamp(24px, 6.2vw, 34px); }
.about-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 20px; }
.about-stat { flex: 1 1 88px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; }
.about-stat-num { display: block; font-family: var(--serif); font-weight: 900; font-size: 24px; color: var(--gold-soft); }
.about-stat-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 3px; }
.about-chapters { display: flex; flex-direction: column; gap: 16px; margin-top: 6px; }
.about-chapter-title { font-family: var(--serif); font-size: 17px; color: var(--ink); margin: 0 0 8px; }
.about-chapter-sub { font-family: var(--sans); font-size: 12px; font-weight: 400; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.about-worldlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.about-world { display: flex; align-items: flex-start; gap: 11px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 12px; }
.about-world-glyph { font-size: 22px; line-height: 1.2; flex: none; }
.about-world-body { display: flex; flex-direction: column; gap: 2px; }
.about-world-name { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 15.5px; }
.about-world-blurb { font-size: 13px; color: var(--ink-dim); line-height: 1.45; }
.about-list { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.about-li { color: var(--ink-dim); line-height: 1.5; }
.about-li strong { color: var(--ink); }
.about-p { color: var(--ink-dim); line-height: 1.6; margin: 4px 0 0; }
.about-cta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0 8px; }
