/* ============================================================
   Economics Quest — theme
   Sibling to Literature Quest's "scholarly dark-parchment": same
   storybook-forest DNA and Palatino serif, tuned for a ledger/
   trading-floor feel. Value the Bull 🐂 (green) and Cost the Bear
   🐻 (amber-red) carry the identity. Worlds re-accent as you climb.
   Mobile-first.
   ============================================================ */
:root {
  --bg: #10150e;
  --bg-2: #171e14;
  --panel: #1c2417;
  --panel-2: #242d1d;
  --line: #35402b;
  --ink: #ecead8;
  --ink-dim: #c2c1a4;
  --muted: #93957a;
  --gold: #d7b24a;
  --gold-soft: #ead18a;
  --good: #86b562;
  --bad: #d5765f;
  --heart: #e0705f;
  --bull: #86b562;
  --bear: #d5765f;
  --accent: #9dc06a;          /* per-world accent; JS swaps this on :root */
  --accent-soft: color-mix(in srgb, var(--accent) 52%, #ffffff);
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 720px;
  --fs: 16px;
}

/* accessibility toggles (set on <html>) */
: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%, #22301a 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;
}
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; }
a { color: var(--gold-soft); }
.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; font-weight: 700; }
.skip-link:focus { left: 0; }
.seo-fallback { color: var(--ink-dim); max-width: 60ch; margin: 0 auto; }

/* ---- 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(16,21,14,.86); 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: block; color: var(--gold); }
.chartmark { width: 26px; height: 26px; display: block; filter: drop-shadow(0 0 8px rgba(215,178,74,.45)); }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 17px; }
@media (max-width: 420px) { .brand-name { display: none; } }
.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); }
.hearts-chip, .coins-chip { display: inline-flex; align-items: center; gap: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--ink-dim); }
.hearts-chip:hover, .coins-chip:hover { border-color: var(--gold); }
.heartmark { width: 17px; height: 17px; display: block; }
.coinmark { width: 18px; height: 18px; display: block; }
.coins-chip b { color: var(--gold-soft); }
.streak-flame { filter: drop-shadow(0 0 6px rgba(224,112,95,.5)); }
.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: 52px; height: 4px; background: #0b0f09; border-radius: 3px; overflow: hidden; }
.lvl-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }
.mute-btn { background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); border-radius: 999px; width: 34px; height: 32px; font-size: 15px; padding: 0; }
.mute-btn:hover { border-color: var(--gold); }

/* ---- Layout ------------------------------------------------- */
.screen { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px calc(44px + env(safe-area-inset-bottom)); animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section-head { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin: 26px 4px 12px; }
.section-head.realm-head { color: var(--gold-soft); text-align: center; letter-spacing: 2px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 26px; }

.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; font-family: var(--serif); }
.qbest { color: var(--muted); font-size: 13px; 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); }
.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(215,178,74,.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; }
.toggle-btn { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 13px 16px; border-radius: 12px; font-size: 15px; margin: 6px 0; }
.toggle-btn:hover { border-color: var(--gold); }
.danger-btn { display: block; width: 100%; background: rgba(215,106,99,.12); border: 1px solid var(--bad); color: #f0a9a4; padding: 12px 16px; border-radius: 12px; margin: 6px 0; font-size: 15px; font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--gold-soft); text-decoration: underline; padding: 0; font-size: inherit; }
.prose { color: var(--ink-dim); }
.prose h2 { color: var(--gold-soft); margin: 22px 0 8px; font-size: 20px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 7px 0; }
.prose b { color: var(--ink); }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Home --------------------------------------------------- */
.home-hero { text-align: center; padding: 12px 8px 4px; }
.home-mascots { font-size: 48px; letter-spacing: 6px; }
.hm-bull { display: inline-block; animation: bob 3.4s ease-in-out infinite; }
.hm-bear { display: inline-block; animation: bob 3.4s ease-in-out infinite .6s; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.home-title { font-size: clamp(30px, 8vw, 44px); margin: 6px 0 4px; letter-spacing: .2px; font-weight: 800; }
.home-title::after { content: ""; display: block; width: 42px; height: 2px; margin: 13px auto 0; background: var(--gold); border-radius: 2px; opacity: .8; }
.home-welcome { color: var(--gold-soft); margin: 6px 0 0; font-weight: 600; }
.home-tag { color: var(--muted); margin: 8px auto 18px; max-width: 36ch; font-style: italic; font-family: var(--serif); font-size: 15.5px; }

.coach-tile, .daily-tile {
  position: relative; display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  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); margin-bottom: 12px;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.coach-tile { background: linear-gradient(120deg, rgba(134,181,98,.12), rgba(213,118,95,.12)), var(--panel); border-color: #46543a; }
.coach-tile:hover, .daily-tile:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow); }
.coach-tile-faces { font-size: 34px; flex: none; }
.tile-glyph { font-size: 30px; width: 42px; text-align: center; flex: none; }
.tile-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-title { font-family: var(--serif); font-size: 18px; }
.tile-desc { color: var(--ink-dim); font-size: 13.5px; }
.tile-arrow { color: var(--gold); font-size: 22px; flex: none; }
.daily-tile.done { opacity: .8; }
.daily-badge { position: absolute; top: 10px; right: 12px; background: var(--gold); color: #201a08; font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .5px; }
.exam-tile { background: linear-gradient(120deg, rgba(215,178,74,.14), transparent), var(--panel); border-color: #5a5330; }

/* 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-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  padding: 16px; color: var(--ink); margin-bottom: 11px;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.world-card:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.world-card.locked { opacity: .55; }
.world-card.complete { border-left-color: var(--gold); }
.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: 18px; }
.world-tag { display: block; font-size: 13px; color: var(--ink-dim); margin: 2px 0 8px; }
.world-crown { font-size: 20px; flex: none; }

.progress { position: relative; height: 17px; background: #0c1009; 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-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 600; letter-spacing: .4px; color: var(--ink); text-shadow: 0 1px 2px rgba(0,0,0,.75); }

.home-explore { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.explore-btn { flex: 1; min-width: 150px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 13px; font-size: 14px; }
.explore-btn:hover { border-color: var(--gold); }
.home-foot { text-align: center; margin-top: 26px; color: var(--muted); }
.build-stamp { color: #4a5a3c; font-size: 11px; }

/* arcade tiles */
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .game-grid { grid-template-columns: 1fr; } }
.game-tile { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; color: var(--ink); transition: transform .12s, border-color .12s; }
.game-tile:hover { transform: translateY(-2px); border-color: var(--gold); }
.game-glyph { font-size: 26px; }
.game-body { display: flex; flex-direction: column; gap: 2px; }
.game-body strong { font-family: var(--serif); font-size: 16px; }
.game-desc { color: var(--ink-dim); font-size: 12.5px; }

/* ---- The winding Path (world trail) ------------------------- */
.path-head { text-align: center; margin: 4px 0 6px; }
.path-head .world-glyph { font-size: 40px; }
.path-title { font-size: clamp(24px, 7vw, 34px); margin: 6px 0 2px; }
.path-grades { color: var(--gold-soft); font-size: 13px; font-weight: 600; }
.path-spirit { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 14.5px; max-width: 44ch; margin: 6px auto 4px; }
.path-progress { max-width: 300px; margin: 10px auto 0; }
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 22px 0 8px; }
.path::before {
  content: ""; position: absolute; top: 30px; bottom: 40px; left: 50%; width: 3px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, var(--line) 0 10px, transparent 10px 20px);
}
.path-unit { position: relative; z-index: 1; margin: 10px auto 2px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; font-size: 12px; background: var(--bg); padding: 2px 12px; border-radius: 999px; border: 1px solid var(--line); }
.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); }
.path-node:nth-of-type(odd)  { transform: translateX(-11%); }
.path-node:nth-of-type(even) { transform: translateX(11%); }
.node-bubble {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 30px;
  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)); color: var(--accent-soft); }
.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(157,192,106,.45); } 50% { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 12px rgba(157,192,106,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-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); }

/* ---- Lesson player ----------------------------------------- */
.course { max-width: 640px; margin: 0 auto; }
.course-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.course-x { background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); width: 38px; height: 38px; border-radius: 50%; font-size: 16px; flex: none; }
.course-bar { flex: 1; height: 8px; background: #0c1009; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.course-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); transition: width .35s ease; }
.course-stage { min-height: 40vh; }
.course-foot { margin-top: 22px; }
.course-next {
  width: 100%; background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #241c05;
  border: 0; padding: 15px; border-radius: 12px; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 18px rgba(215,178,74,.25);
}
.course-next:disabled { filter: grayscale(.5) brightness(.7); }

.course-chapter { text-align: center; padding: 18px 0; }
.course-chapter-k { color: var(--gold-soft); font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; }
.course-chapter h2 { font-size: 27px; margin: 10px 0; }
.course-chapter p { color: var(--ink-dim); }
.course-replay-note { color: var(--gold-soft); font-size: 14px; }

/* teaching cards: gold left border, serif accents */
.course-teach { 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; box-shadow: var(--shadow); }
.course-teach-glyph { font-size: 42px; text-align: center; }
.course-teach h3 { font-size: 21px; margin: 8px 0 12px; color: var(--gold-soft); text-align: center; }
.course-teach p { color: var(--ink); font-size: 16px; margin: 10px 0; }
.course-pull { border-left: 3px solid var(--gold); margin: 14px 0 0; padding: 4px 0 4px 14px; color: var(--gold-soft); font-style: italic; font-family: var(--serif); }

.course-q { font-size: clamp(19px, 5vw, 23px); margin: 6px 0 16px; text-align: center; font-family: var(--serif); line-height: 1.35; }
.course-prompt { color: var(--muted); text-align: center; margin: -8px 0 16px; font-size: 14px; }
.course-opts { display: flex; flex-direction: column; gap: 11px; }
.course-opts-wrap { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.course-opt { text-align: left; background: var(--panel); border: 1.5px solid var(--line); color: var(--ink); padding: 15px 16px; border-radius: 13px; font-size: 16px; transition: border-color .12s, background .12s, transform .08s; }
.course-opt:not(:disabled):hover { border-color: var(--accent); background: var(--panel-2); }
.course-opt:not(:disabled):active { transform: scale(.99); }
.course-opt.right { border-color: var(--good); background: rgba(134,181,98,.16); color: #d7f5db; }
.course-opt.wrong { border-color: var(--bad); background: rgba(213,118,95,.15); color: #f6cecb; }
.course-opt:disabled { cursor: default; }

.course-fill { text-align: center; font-size: 20px; margin: 8px 0 16px; font-family: var(--serif); }
.course-blank { display: inline-block; min-width: 74px; border-bottom: 2px dashed var(--gold); color: var(--gold-soft); padding: 0 4px; }
.course-blank.right { border-bottom-style: solid; color: var(--good); }
.course-chip { background: var(--panel); border: 1.5px solid var(--line); border-bottom-width: 3px; color: var(--ink); padding: 10px 15px; border-radius: 11px; font-size: 15.5px; margin: 4px; font-family: var(--serif); }
.course-chip:not(:disabled):hover { border-color: var(--accent); }
.course-chip.right { border-color: var(--good); background: rgba(134,181,98,.16); }
.course-chip.wrong { border-color: var(--bad); opacity: .6; }

.course-sort { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.course-sort-item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.course-sort-item.ok { border-color: var(--good); background: rgba(134,181,98,.12); }
.course-sort-item.miss { border-color: var(--bad); background: rgba(213,118,95,.1); }
.course-sort-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); color: var(--gold-soft); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.course-sort-name { flex: 1; font-size: 15px; }
.course-sort-moves { display: flex; flex-direction: column; gap: 3px; }
.course-move { background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-dim); width: 30px; height: 22px; border-radius: 6px; font-size: 11px; line-height: 1; }
.course-move:disabled { opacity: .3; }
.course-sort-submit { width: 100%; margin-top: 12px; }

.course-match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.course-match-col { display: flex; flex-direction: column; gap: 10px; }
.course-match-cell { background: var(--panel); border: 1.5px solid var(--line); color: var(--ink); padding: 13px 10px; border-radius: 12px; font-size: 14.5px; min-height: 52px; line-height: 1.35; }
.course-match-cell.sel { border-color: var(--gold); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(215,178,74,.18); }
.course-match-cell.done { border-color: var(--good); background: rgba(134,181,98,.14); opacity: .5; border-style: dashed; cursor: default; }
.course-match-cell.miss { border-color: var(--bad); background: rgba(213,118,95,.15); animation: shake .3s ease; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.course-bucket-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.course-bucket { background: var(--panel); border: 2px solid var(--line); color: var(--ink); padding: 20px 12px; border-radius: 14px; font-size: 16px; font-weight: 600; font-family: var(--serif); }
.course-bucket.right { border-color: var(--good); background: rgba(134,181,98,.18); }
.course-bucket.wrong { border-color: var(--bad); background: rgba(213,118,95,.16); }
.course-sort-item-card { text-align: center; font-size: 20px; font-family: var(--serif); background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px; padding: 26px 16px; margin: 8px 0; }

.course-fb { margin-top: 16px; padding: 14px 16px; border-radius: 13px; font-size: 14.5px; border: 1px solid var(--line); }
.course-fb.good { border-color: rgba(134,181,98,.5); background: rgba(134,181,98,.08); color: #d7f5db; }
.course-fb.bad { border-color: rgba(213,118,95,.5); background: rgba(213,118,95,.08); color: #f6cecb; }
.course-fb.neutral { background: var(--panel); color: var(--ink-dim); }

.course-checkpoint-head { text-align: center; margin: 8px 0 16px; }
.course-checkpoint-head span { color: var(--gold-soft); font-size: 13px; }
.course-checkpoint-head h3 { font-size: 19px; margin: 6px 0; }
.course-cp-progress { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.course-cp-done { text-align: center; color: var(--good); font-weight: 700; padding: 16px; font-family: var(--serif); }

.course-out { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8,10,5,.8); padding: 20px; }
.course-out-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; text-align: center; max-width: 380px; box-shadow: var(--shadow); }
.course-out-heart { width: 46px; margin: 0 auto 8px; }
.course-out-heart .heartmark { width: 46px; height: 46px; }
.course-out-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.course-done { text-align: center; padding: 20px 0; }
.course-done-glyph { font-size: 56px; }
.course-done h2 { font-size: 30px; margin: 8px 0; color: var(--gold-soft); }
.course-stars { font-size: 26px; color: var(--gold); letter-spacing: 4px; }
.course-done-msg { color: var(--ink-dim); max-width: 40ch; margin: 8px auto; }

.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 18px auto; max-width: 380px; }
.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; align-items: center; }
.stat-num { font-family: var(--serif); font-size: 20px; color: var(--gold-soft); font-weight: 700; }
.stat-lbl { font-size: 11px; color: var(--muted); }
.result-actions { display: flex; flex-direction: column; gap: 10px; max-width: 380px; margin: 16px auto 0; }

/* ---- Boss --------------------------------------------------- */
.boss { max-width: 640px; margin: 0 auto; }
.boss-gate, .boss-intro, .boss-result { text-align: center; padding: 20px 0; }
.boss-face { font-size: 40px; }
.boss-face-big { font-size: 84px; 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-face-big.defeated { filter: grayscale(.6) drop-shadow(0 0 14px rgba(134,181,98,.5)); transform: rotate(-8deg); opacity: .85; animation: none; }
.boss-intro h2, .boss-result h2 { font-size: 26px; margin: 10px 0; color: var(--gold-soft); }
.boss-blurb { color: var(--ink-dim); max-width: 46ch; margin: 10px auto; }
.boss-meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.boss-stage { padding-top: 6px; }
.boss-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.boss-top .boss-face { font-size: 40px; transition: transform .15s; }
.boss-top .boss-face.hurt { animation: bosshit .4s ease; }
@keyframes bosshit { 0% { transform: scale(1); filter: brightness(2) drop-shadow(0 0 18px rgba(215,178,74,.8)); } 100% { transform: scale(1); } }
.boss-top-bars { flex: 1; }
.boss-name { font-family: var(--serif); font-size: 15px; margin-bottom: 5px; color: var(--gold-soft); }
.boss-hp { height: 14px; background: #0c1009; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.boss-hp-fill { height: 100%; background: linear-gradient(90deg, #b0503c, var(--bad)); transition: width .4s ease; }
.boss-hearts { display: flex; gap: 2px; }
.boss-hearts .heartmark { width: 18px; height: 18px; }
.boss-round { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0; }
.boss-q { text-align: center; font-size: 19px; margin: 6px 0 16px; font-family: var(--serif); }
.boss-win { color: var(--ink-dim); max-width: 44ch; margin: 10px auto; font-style: italic; font-family: var(--serif); }
.boss-reward { color: var(--gold-soft); font-weight: 700; margin: 12px 0; }

/* ---- Guide (Value & Cost mascot) --------------------------- */
.guide { position: fixed; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 74vw; pointer-events: none; }
.guide-hidden { display: none; }
.guide-bubble { display: none; background: var(--panel-2); border: 1px solid var(--gold); border-radius: 14px; padding: 10px 13px; box-shadow: 0 12px 30px rgba(0,0,0,.45); font-size: 13px; max-width: 280px; pointer-events: auto; }
.guide-bubble.show { display: block; animation: fade .2s ease; }
.gb-value, .gb-cost { margin: 3px 0; color: var(--ink-dim); }
.gb-value b { color: var(--bull); }
.gb-cost b { color: var(--bear); }
.guide-pair { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; gap: 2px; box-shadow: 0 6px 16px rgba(0,0,0,.45); pointer-events: auto; font-size: 26px; line-height: 1; }
.guide-pair:hover { border-color: var(--gold); }
.guide-pop .guide-pair { animation: bob 1s ease-in-out 2; }
.guide-compact .guide-pair { font-size: 20px; padding: 5px 8px; }

/* ---- Onboarding -------------------------------------------- */
.onboard-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(8,10,5,.85); backdrop-filter: blur(4px); padding: 18px; }
.onboard-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.onboard-mascots { font-size: 44px; letter-spacing: 8px; }
.onboard-card h2 { font-size: 23px; margin: 6px 0; color: var(--gold-soft); }
.onboard-sub { color: var(--ink-dim); font-size: 14.5px; }
.onboard-label { display: block; text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 16px 0 6px; }
.onboard-input { width: 100%; background: var(--bg-2); border: 1.5px solid var(--line); color: var(--ink); border-radius: 12px; padding: 13px; font-size: 16px; text-align: center; }
.onboard-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215,178,74,.15); }
.onboard-grades { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.onboard-grade { background: var(--bg-2); border: 1.5px solid var(--line); color: var(--ink-dim); border-radius: 11px; padding: 12px 6px; font-size: 13.5px; }
.onboard-grade.sel { border-color: var(--gold); background: rgba(215,178,74,.14); color: var(--ink); font-weight: 700; }
.onboard-note { color: var(--muted); font-size: 12px; margin: 14px 0; }
.onboard-go { width: 100%; }

/* ---- Portfolio --------------------------------------------- */
.pf-hero { text-align: center; margin-bottom: 8px; }
.pf-badge-lvl { font-size: 42px; letter-spacing: 4px; }
.pf-hero h1 { font-size: 25px; margin: 6px 0 2px; }
.pf-rank { color: var(--gold-soft); font-weight: 600; }
.pf-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
@media (max-width: 460px) { .pf-stats { grid-template-columns: repeat(2, 1fr); } }
.pf-stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; text-align: center; }
.pf-stat-g { display: block; font-size: 20px; }
.pf-stat-num { display: block; font-family: var(--serif); font-size: 18px; color: var(--gold-soft); font-weight: 700; }
.pf-stat-lbl { display: block; font-size: 11px; color: var(--muted); }
.pf-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pf-badge { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px; opacity: .6; filter: saturate(.4); }
.pf-badge.has { opacity: 1; filter: none; border-color: rgba(215,178,74,.4); }
.pf-badge-emoji { font-size: 26px; flex: none; }
.pf-badge-name { display: block; font-family: var(--serif); font-size: 14.5px; color: var(--gold-soft); }
.pf-badge-desc { display: block; color: var(--ink-dim); font-size: 12px; }

/* ---- Arcade / results -------------------------------------- */
.arcade-intro { text-align: center; padding: 24px 0; }
.arcade-glyph { font-size: 54px; }
.arcade-intro h1 { font-size: 28px; margin: 8px 0; color: var(--gold-soft); }
.arcade-intro p { color: var(--ink-dim); max-width: 42ch; margin: 8px auto 18px; }
.arcade-hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-family: var(--serif); }
.arcade-score { color: var(--gold-soft); font-weight: 700; }
.arcade-time { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; }
.arcade-combo { color: var(--bear); font-weight: 700; min-width: 46px; text-align: right; }
.arcade-q { text-align: center; font-size: 20px; margin: 8px 0 16px; font-family: var(--serif); }
.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: 32px; margin: 6px 0 2px; color: var(--gold-soft); }
.result-verdict { color: var(--ink-dim); margin: 8px auto; max-width: 42ch; }

/* ---- Equilibrium game -------------------------------------- */
.eq-wrap { max-width: 520px; margin: 0 auto; }
.eq-readout { text-align: center; margin-bottom: 14px; }
.eq-price { font-family: var(--serif); font-size: 26px; color: var(--gold-soft); font-weight: 700; }
.eq-qty { color: var(--ink-dim); font-size: 14px; }
.eq-bars { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.eq-bar-row { display: flex; align-items: center; gap: 10px; }
.eq-bar-label { flex: none; width: 96px; font-size: 13px; color: var(--ink-dim); }
.eq-bar-track { flex: 1; height: 22px; background: #0c1009; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.eq-bar-fill { height: 100%; border-radius: 8px 0 0 8px; transition: width .18s ease; }
.eq-bar-val { flex: none; width: 34px; text-align: right; font-weight: 700; font-size: 14px; }
.eq-label { display: block; text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 8px; }
.eq-slider { width: 100%; accent-color: var(--gold); height: 30px; }
.eq-status { margin-top: 14px; padding: 13px; border-radius: 12px; text-align: center; font-size: 14.5px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); }
.eq-status.eq-ok { border-color: var(--good); background: rgba(134,181,98,.14); color: #d7f5db; }
.eq-status.eq-short { border-color: var(--bear); color: #f6cecb; }
.eq-status.eq-surplus { border-color: #6fa8d0; color: #d6ecff; }
.eq-wrap .primary { margin-top: 14px; }

/* ---- Coach (Value & Cost chat) ----------------------------- */
.coach-hero { text-align: center; margin-bottom: 14px; }
.coach-avatars { font-size: 40px; display: flex; gap: 10px; align-items: center; justify-content: center; }
.coach-vs { font-size: 15px; color: var(--muted); font-style: italic; font-family: var(--serif); }
.coach-bull { animation: bob 3.4s ease-in-out infinite; }
.coach-bear { animation: bob 3.4s ease-in-out infinite .6s; }
.coach-hero h1 { font-size: 26px; margin: 6px 0; color: var(--gold-soft); }
.coach-hero p { color: var(--ink-dim); max-width: 46ch; margin: 6px auto; font-size: 14.5px; }
.coach-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 460px) { .coach-topics { grid-template-columns: 1fr; } }
.coach-topic { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 15px; font-size: 14.5px; text-align: left; }
.coach-topic:hover { border-color: var(--gold); }
.coach-topic-emoji { font-size: 22px; }
.coach-note { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 16px; }
.coach-log { display: flex; flex-direction: column; gap: 12px; padding: 6px 2px 14px; min-height: 40vh; }
.coach-msg { max-width: 90%; }
.coach-user { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--accent); color: var(--ink); padding: 11px 14px; border-radius: 14px 14px 4px 14px; font-size: 14.5px; }
.coach-ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.coach-voice { font-size: 14.5px; line-height: 1.5; padding-left: 8px; }
.coach-voice-tag { font-weight: 800; margin-right: 5px; font-family: var(--serif); }
.coach-value { border-left: 2px solid rgba(134,181,98,.6); }
.coach-value .coach-voice-tag { color: var(--bull); }
.coach-cost { border-left: 2px solid rgba(213,118,95,.6); }
.coach-cost .coach-voice-tag { color: var(--bear); }
.coach-both { border-left: 2px solid rgba(215,178,74,.6); }
.coach-both .coach-voice-tag { color: var(--gold-soft); }
.coach-typing .coach-dots { font-size: 18px; letter-spacing: 2px; animation: pulse2 1.2s ease-in-out infinite; }
@keyframes pulse2 { 0%,100% { opacity: .4; } 50% { opacity: 1; } }
.coach-input { display: flex; gap: 8px; position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--bg) 30%); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
.coach-field { flex: 1; background: var(--bg-2); border: 1.5px solid var(--line); color: var(--ink); border-radius: 999px; padding: 13px 16px; font-size: 15px; }
.coach-field:focus { outline: none; border-color: var(--gold); }
.coach-send { width: auto; padding: 12px 18px; }

/* ---- Certificate ------------------------------------------- */
.cert { max-width: 560px; margin: 0 auto; }
.cert-inner { background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 3px double var(--gold); border-radius: 14px; padding: 30px 26px; text-align: center; box-shadow: var(--shadow); }
.cert-seal { font-size: 40px; letter-spacing: 4px; }
.cert-kicker { color: var(--muted); font-size: 13px; margin: 10px 0 4px; font-family: var(--serif); }
.cert-name { font-size: 30px; color: var(--gold-soft); margin: 4px 0; }
.cert-body { color: var(--ink-dim); font-size: 14px; max-width: 42ch; margin: 12px auto; }
.cert-title { color: var(--muted); margin: 10px 0 2px; }
.cert-rank { font-size: 30px; letter-spacing: 4px; color: var(--good); margin: 2px 0 14px; }
.cert-foot { display: flex; justify-content: space-around; margin: 20px 0 6px; }
.cert-sig { font-size: 14px; }
.cert-sig hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.cert-sig small { color: var(--muted); }
.cert-date { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---- Toasts + confetti ------------------------------------- */
#toast-host { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 480px); }
.toast { background: var(--panel-2); border: 1px solid var(--gold); color: var(--ink); padding: 11px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; text-align: center; }
.toast.show { opacity: 1; transform: none; }
.confetti-host { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.4s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(680deg); opacity: .9; } }

/* ---- Reduced motion + print -------------------------------- */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .appbar, .guide, #toast-host, .game-top { display: none !important; }
  body { background: #fff; color: #111; }
  .cert-inner { border-color: #b8891f; background: #fff; color: #222; }
  .cert-name, .cert-rank { color: #2a6a34; }
}
