/* Math Ridge — styles. Warm paper by day, deep alpine night in dark mode. Big
 * tap targets and generous type for a 10-year-old on a laptop or tablet. */
:root {
  color-scheme: light dark;
  --bg: #f6f1e7; --bg2: #efe7d8; --card: #fffdf8; --ink: #1d2733; --muted: #5c6a78; --line: #e2d9c8;
  --accent: #2f7fb8; --accent-ink: #ffffff; --gold: #d99a2b; --green: #3f9a5f; --red: #d1453b; --purple: #7b5cc4;
  --rock: #7d8a99; --sky1: #bfe0f7; --sky2: #e9f4fb; --sun: #f6c445;
  --ice: #9fd3f0; --crev: #e08a4c; --nut: #c9a26a; --raisin: #6b3fa0;
  --radius: 14px; --shadow: 0 6px 24px rgba(30, 40, 60, .08);
}
/* Dark: follows the OS unless the host stamps an explicit data-theme, which wins either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101820; --bg2: #0b1218; --card: #182330; --ink: #e8eef4; --muted: #9fb0c0; --line: #27394a;
    --accent: #5aa7de; --accent-ink: #0b1218; --gold: #f0b54a; --green: #5fc082; --red: #ef6b62;
    --rock: #3c4a5a; --sky1: #16283a; --sky2: #0f1a26; --sun: #f6c445; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #101820; --bg2: #0b1218; --card: #182330; --ink: #e8eef4; --muted: #9fb0c0; --line: #27394a;
  --accent: #5aa7de; --accent-ink: #0b1218; --gold: #f0b54a; --green: #5fc082; --red: #ef6b62;
  --rock: #3c4a5a; --sky1: #16283a; --sky2: #0f1a26; --sun: #f6c445; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
#app { max-width: 880px; margin: 0 auto; padding: 0 16px 40px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; margin: .2em 0 .4em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3.2vw, 1.9rem); font-weight: 800; }
a { color: var(--accent); }
p { margin: .5em 0; }
small { color: var(--muted); }
code { background: var(--bg2); padding: .1em .35em; border-radius: 5px; font-size: .92em; }
s { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.eyebrow { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0 0 .3em; }
.big { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 800; letter-spacing: .01em; }
.sub { font-size: .95rem; color: var(--muted); font-weight: 400; }
.q { color: var(--accent); }
.expr { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-weight: 700; }
.fine { font-size: .85rem; color: var(--muted); }
.bad-text, p.bad { color: var(--red); }

/* header / footer */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.top .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; text-decoration: none; color: var(--ink); font-size: 1.05rem; letter-spacing: .01em; }
.top .peak { width: 18px; height: 16px; background: linear-gradient(135deg, var(--accent), var(--gold)); clip-path: polygon(50% 0, 100% 100%, 0 100%); display: inline-block; }
.top .sub { flex: 1; text-align: center; font-size: .85rem; }
.top .who { font-weight: 700; color: var(--muted); font-size: .9rem; }
.foot { margin-top: 44px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.foot a { color: var(--muted); }

/* buttons + inputs */
.btn { appearance: none; border: 2px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 999px; cursor: pointer; transition: transform .08s, background .15s, border-color .15s; line-height: 1.2; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; }
.btn.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 18%, var(--card)); }
.btn.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 14%, var(--card)); animation: shake .35s; }
.ni { font: inherit; font-size: 1.1rem; font-weight: 700; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); width: auto; min-width: 4.5rem; text-align: center; }
.ni:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ni.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 14%, var(--card)); }
.ni.bad { border-color: var(--red); animation: shake .35s; }
.ni:disabled { opacity: .85; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
.row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.eq { font-weight: 700; font-size: 1.1rem; }
.unit { font-weight: 700; color: var(--muted); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* fractions */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .15em; font-weight: 700; font-size: .92em; }
.frac .fn { border-bottom: 2px solid currentColor; padding: 0 .25em .05em; }
.frac .fd { padding: .05em .25em 0; }
.mixed { display: inline-flex; align-items: center; gap: .1em; font-weight: 700; }
.fracin { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.fracin .fd { font-weight: 800; border-top: 2px solid currentColor; padding-top: 4px; min-width: 3rem; text-align: center; }
.fracin .ni + .ni { border-top: 2px solid var(--ink); border-radius: 0 0 10px 10px; }

/* content blocks in briefings */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.card .body { font-size: 1.05rem; }
.card .body p { margin: .6em 0; }
table.pv { border-collapse: collapse; margin: 10px 0; font-variant-numeric: tabular-nums; }
table.pv th, table.pv td { border: 1px solid var(--line); padding: 6px 12px; text-align: center; }
table.pv th { background: var(--bg2); font-weight: 700; }
table.pv.words td:first-child, table.pv.inv td { text-align: left; }
table.pv.facts td { text-align: left; font-size: .95rem; }
table.pv td.cur { background: color-mix(in srgb, var(--gold) 22%, var(--card)); font-weight: 800; }
pre.stack { font: 1rem/1.45 ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; background: var(--bg2); border-radius: 10px; padding: 12px 16px; overflow-x: auto; }
ol.pemdas li { margin: .3em 0; }
ul.recap li { margin: .35em 0; }
p.go { border-left: 4px solid var(--gold); padding-left: 12px; color: var(--muted); }

/* welcome */
.welcome .hero { text-align: center; padding-top: 20px; }
.welcome .ridge { width: 100%; max-width: 620px; border-radius: var(--radius); box-shadow: var(--shadow); }
.welcome h1 { font-size: clamp(2.4rem, 7vw, 4rem); margin: .35em 0 .1em; }
.tagline { font-size: 1.15rem; color: var(--muted); max-width: 560px; margin: 0 auto 10px; }
.namecard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin: 22px auto 0; max-width: 540px; box-shadow: var(--shadow); }
.namecard label { display: block; font-weight: 800; font-size: 1.2rem; margin-bottom: 8px; }
.namecard .row { margin: 0; }
.namecard input { flex: 1; min-width: 10rem; text-align: left; font-size: 1.15rem; }
.camps-preview { list-style: none; padding: 0; margin: 26px auto 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-width: 760px; font-size: .9rem; color: var(--muted); }
.camps-preview b { display: inline-block; width: 1.6rem; color: var(--gold); }

/* home / map */
.greet h1 { margin-bottom: .1em; }
.mapwrap { margin: 16px 0; }
svg.map { width: 100%; height: auto; display: block; background: linear-gradient(var(--sky1), var(--sky2)); border-radius: var(--radius); box-shadow: var(--shadow); }
svg.map .mtn { fill: var(--rock); }
svg.map .snow { fill: #fff; opacity: .9; }
svg.map .trail { fill: none; stroke: var(--gold); stroke-width: 4; stroke-dasharray: 10 8; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
svg.map .node { cursor: pointer; }
svg.map .node .ring { fill: var(--card); stroke: var(--line); stroke-width: 3; }
svg.map .node .n { font-weight: 800; font-size: 15px; fill: var(--ink); pointer-events: none; }
svg.map .node .lbl { font-size: 13px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
svg.map .node.done .ring { fill: var(--green); stroke: var(--green); }
svg.map .node.done .n { fill: #fff; }
svg.map .node.open .ring { stroke: var(--accent); }
svg.map .node.cur .ring { fill: var(--gold); stroke: var(--gold); animation: pulse 1.6s infinite; }
svg.map .node.locked { cursor: default; }
svg.map .node.locked .ring { stroke: var(--line); opacity: .7; }
svg.map .node.locked .lbl { opacity: .55; }
svg.map .node.locked .lk { fill: none; stroke: var(--muted); stroke-width: 2; }
svg.map .node:focus { outline: none; }
svg.map .node:focus .ring { stroke-width: 5; }
@keyframes pulse { 0%, 100% { r: 17; } 50% { r: 20; } }
.camplist { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.camplist button { width: 100%; display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.camplist button:hover:not(:disabled) { border-color: var(--accent); }
.camplist button:disabled { opacity: .55; cursor: default; }
.camplist .num { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg2); }
.camplist li.done .num { background: var(--green); color: #fff; }
.camplist li.open .num { background: var(--accent); color: var(--accent-ink); }
.camplist .t { display: flex; flex-direction: column; line-height: 1.25; }
.camplist .st { font-size: .85rem; color: var(--muted); white-space: nowrap; }

/* hub */
.back { display: inline-block; margin: 4px 0 14px; font-weight: 700; text-decoration: none; }
.hub .blurb { font-size: 1.1rem; max-width: 640px; }
.hub .standards { color: var(--muted); font-size: .88rem; }
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 22px 0; }
.stage { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "k t" "k d" "k st"; gap: 2px 12px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; font: inherit; color: var(--ink); cursor: pointer; }
.stage:hover:not(:disabled) { border-color: var(--accent); }
.stage .k { grid-area: k; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg2); }
.stage .t { grid-area: t; font-weight: 800; font-size: 1.1rem; }
.stage .d { grid-area: d; color: var(--muted); font-size: .9rem; }
.stage .st { grid-area: st; font-size: .85rem; font-weight: 700; color: var(--accent); margin-top: 4px; }
.stage.done { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.stage.done .k { background: var(--green); color: #fff; }
.stage.done .st { color: var(--green); }
.stage.locked { opacity: .6; cursor: default; }
.stage.locked .st { color: var(--muted); }

/* briefing */
.briefing .card h2 { margin-top: 0; }
.dots { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: inline-block; }
.dots i.on { background: var(--accent); transform: scale(1.25); }
.dots i.past { background: var(--green); }
.dots i.ok { background: var(--green); }
.dots i.bad { background: var(--red); }
.dots i.cur { background: var(--gold); }
.briefing .nav { display: flex; justify-content: space-between; gap: 12px; }

/* scene */
.scenebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.scenebar .round { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.goal { font-size: 1.05rem; margin: 0 0 8px; }
.hint { min-height: 1.6em; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); opacity: 0; transition: opacity .25s; margin-bottom: 12px; }
.hint.show { opacity: 1; animation: pop .3s; }
@keyframes pop { 0% { transform: translateY(-4px); } 100% { transform: none; } }
.gamehost { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-height: 200px; }
.stage-wrap, .stage { }
.gamehost .stage { display: block; background: transparent; border: 0; padding: 0; cursor: default; }
.story { font-size: 1.12rem; font-weight: 600; margin: 0 0 6px; }
.task { color: var(--muted); margin: 0 0 14px; }
.tag { display: inline-block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; background: var(--accent); color: var(--accent-ink); padding: 2px 8px; border-radius: 6px; margin-right: 6px; vertical-align: middle; }
.yay { font-size: 1.08rem; font-weight: 700; color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--card)); border-radius: 10px; padding: 10px 14px; margin: 12px 0 0; animation: pop .3s; }
.step2 { margin-top: 12px; }
.scenedone { text-align: center; margin: 24px 0 0; padding: 22px; border-radius: var(--radius); background: color-mix(in srgb, var(--green) 12%, var(--card)); border: 2px solid var(--green); animation: pop .4s; }
.scenedone .big { margin: 0; }

/* quiz */
.climb { position: relative; margin: 6px 0 12px; }
.climb svg { width: 100%; max-height: 130px; display: block; background: linear-gradient(var(--sky1), var(--sky2)); border-radius: 12px; }
.climb .mtn { fill: var(--rock); }
.climb .route { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 6 5; }
.climb .pin circle { fill: var(--card); stroke: var(--gold); stroke-width: 2; }
.climb .pin text { font-size: 12px; }
.climb .pin { transition: transform .5s ease; }
.climb .dots { margin: 8px 0 0; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.prompt { font-size: 1.2rem; margin-bottom: 14px; }
.prompt .big { display: block; margin: 6px 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.btn.choice { border-radius: 12px; padding: 14px; font-size: 1.05rem; }
.answer .ni.main { font-size: 1.25rem; min-width: 9rem; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); }
.feedback.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--card)); }
.feedback.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--card)); }
.verdict { font-size: 1.15rem; font-weight: 800; margin: 0 0 6px; }
.verdict .note { font-weight: 500; color: var(--muted); }
details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 700; color: var(--accent); }
ol.steps { padding-left: 1.4em; }
ol.steps li { margin: .4em 0; }
.result { text-align: center; padding: 10px 0; }
.result h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }

/* certificate */
.cert { background: var(--card); border: 6px double var(--gold); border-radius: 8px; padding: 40px 30px; text-align: center; max-width: 680px; margin: 10px auto 18px; box-shadow: var(--shadow); }
.cert-eyebrow { letter-spacing: .3em; text-transform: uppercase; font-size: .8rem; color: var(--muted); }
.cert h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); margin: .3em 0; }
.cert-line { max-width: 520px; margin: 0 auto; }
.cert-date { font-size: 1.3rem; font-weight: 800; margin: 12px 0 4px; }
.cert-score { color: var(--muted); }
.cert-seal { width: 64px; height: 64px; margin: 14px auto 0; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-size: 28px; }
@media print { .top, .foot, .noprint { display: none !important; } body { background: #fff; } .cert { box-shadow: none; } }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .3; } }

/* ───── scene: crates ───── */
.shelf { min-height: 2.2rem; font-size: 1.6rem; letter-spacing: 4px; }
.area { display: grid; gap: 6px; margin: 10px 0; }
.area .corner, .area .hd { display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.area .hd { background: var(--bg2); border-radius: 8px; padding: 6px 10px; }
.area .cell { border: 2px dashed var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; min-height: 5.2rem; justify-content: center; }
.area .cell label { font-size: .9rem; color: var(--muted); font-weight: 700; }
.area .cell.done { border-style: solid; border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--card)); }
.sumrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }

/* ───── scene: ropes (long division) ───── */
.machine { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
pre.ldiv { margin: 0; font: 1.5rem/1.35 ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; background: var(--bg2); padding: 14px 18px; border-radius: 12px; min-width: 9ch; }
pre.ldiv .q { color: var(--accent); }
pre.ldiv .dv { color: var(--muted); }
pre.ldiv .sub { color: var(--red); }
pre.ldiv .line { color: var(--muted); }
pre.ldiv b { background: color-mix(in srgb, var(--gold) 35%, transparent); border-radius: 4px; }
pre.ldiv .pt { color: var(--gold); font-weight: 800; }
pre.ldiv.static { font-size: 1.3rem; display: inline-block; }
.panel .plabel { font-size: 1.1rem; margin: 0 0 6px; }
details.tt { margin-top: 12px; font-size: .9rem; }
details.tt div { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 16px; margin-top: 6px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .machine { grid-template-columns: 1fr; } pre.ldiv { font-size: 1.25rem; } }

/* ───── scene: pointslide ───── */
.alti { display: inline-block; background: #0f1a12; color: #7dff9b; border-radius: 10px; padding: 8px 16px; font-family: ui-monospace, Menlo, monospace; margin-bottom: 10px; box-shadow: inset 0 0 0 3px #2a3a2e; }
.alti-k { font-size: .65rem; letter-spacing: .2em; opacity: .7; }
.alti-v { font-size: 1.6rem; font-weight: 800; }
.digits { display: inline-flex; align-items: center; gap: 2px; font: 800 2.6rem/1 ui-monospace, Menlo, monospace; padding: 8px 6px; border-radius: 12px; background: var(--bg2); }
.digits .dg { padding: 0 4px; }
.digits .gap { width: 22px; height: 56px; border: 2px dashed var(--line); background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.2rem; display: grid; place-items: center; padding: 0; }
.digits .gap:hover { border-color: var(--accent); color: var(--accent); }
.digits .gap.pt { border: 0; color: var(--ink); font-size: 2.6rem; width: 18px; }
.digits.locked .gap:not(.pt) { visibility: hidden; }
.digits.bad { animation: shake .35s; }

/* ───── scene: shiftsplit ───── */
.shifter { display: inline-flex; align-items: center; gap: 14px; font: 800 2.2rem/1 ui-monospace, Menlo, monospace; background: var(--bg2); padding: 12px 20px; border-radius: 12px; }
.shifter .sn { transition: color .2s; }
.shifter .sn.whole { color: var(--green); }
.shifter .op { color: var(--muted); }
.trail { color: var(--muted); font-weight: 600; min-height: 1.5em; }
.btn.lever { background: var(--gold); border-color: var(--gold); color: #1d2733; }

/* ───── scene: bridge ───── */
.bridge { display: flex; align-items: flex-end; gap: 0; margin-bottom: 14px; height: 48px; }
.bridge .edge { width: 18%; height: 40px; background: var(--rock); border-radius: 6px 6px 0 0; }
.bridge .planks { flex: 1; display: flex; gap: 4px; align-items: center; height: 40px; border-bottom: 2px dashed var(--line); }
.bridge .slot { flex: 1; height: 14px; border: 2px dashed var(--line); border-radius: 4px; }
.bridge .slot.laid { background: #b07a3c; border-color: #8a5a28; animation: pop .3s; }
.bars { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
@media (max-width: 640px) { .bars { grid-template-columns: 1fr; } .opsign { text-align: center; } }
.barwrap .blabel { font-size: 1.1rem; margin-bottom: 4px; min-height: 2.4rem; display: flex; align-items: center; }
.bar { display: flex; gap: 2px; height: 42px; border: 2px solid var(--ink); border-radius: 6px; padding: 2px; background: var(--card); }
.bar .seg { flex: 1; border-radius: 3px; background: var(--bg2); position: relative; }
.bar .seg.on { background: var(--accent); }
.bar .seg.on.two { background: var(--gold); }
.bar .seg.cut { background: repeating-linear-gradient(45deg, var(--red) 0 4px, transparent 4px 8px); opacity: .7; }
.bar.ghost .seg.on { background: var(--red); }
.bar.combo { margin: 8px 0; }
.opsign { font-size: 2rem; font-weight: 800; }
.cuts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bars.matched .bar { border-color: var(--green); }
p.matched { color: var(--green); font-weight: 700; }

/* ───── scene: glacier ───── */
.gmap { display: grid; gap: 4px; max-width: 420px; }
.gmap .gh { border-radius: 8px; padding: 6px 0; font-size: .95rem; }
.gmap .gh.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.gmap .gcell { aspect-ratio: 1; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); transition: background .2s; }
.gmap .gcell.ice { background: var(--ice); }
.gmap .gcell.crev { background: repeating-linear-gradient(135deg, var(--crev) 0 5px, var(--bg2) 5px 10px); }
.gmap .gcell.both { background: repeating-linear-gradient(135deg, #7a3a12 0 5px, var(--accent) 5px 10px); }

/* ───── scene: fuel ───── */
.tank { display: grid; gap: 2px; height: 56px; border: 3px solid var(--ink); border-radius: 10px; padding: 3px; background: var(--card); }
.tank .tseg { border-radius: 3px; background: var(--bg2); }
.tank .tseg.liter { border-right: 3px solid var(--ink); }
.tank .tseg.on.c0 { background: var(--accent); }
.tank .tseg.on.c1 { background: var(--gold); }
.tscale { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-weight: 700; margin: 4px 2px 8px; }
.count { font-weight: 700; }
.reveal { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--bg2); }
.rv-k { font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.rv-v { font-size: 1.35rem; font-weight: 800; margin: 6px 0; }
.rv-s { color: var(--muted); }
.flip { display: inline-block; animation: flip 1s ease .3s both; color: var(--accent); }
@keyframes flip { 0% { transform: rotateX(180deg); } 100% { transform: none; } }

/* ───── scene: trailmix ───── */
.recipe { background: var(--bg2); border-radius: 10px; padding: 8px 14px; margin-bottom: 10px; font-size: 1.05rem; }
.mixer { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
@media (max-width: 560px) { .mixer { grid-template-columns: 1fr; } }
.bowl { min-height: 120px; border: 3px solid var(--ink); border-radius: 0 0 80px 80px / 0 0 60px 60px; padding: 12px 18px 22px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-end; background: var(--card); }
.bowl.bad { animation: shake .35s; }
.bowl i { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.bowl .nut { background: var(--nut); border-radius: 45% 55% 50% 50%; }
.bowl .raisin { background: var(--raisin); }
.mixctl { display: grid; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .sl { width: 4.6rem; font-weight: 700; }
.stepper .sv { min-width: 2.2rem; text-align: center; font-weight: 800; font-size: 1.2rem; }
.stepper.locked .sv { color: var(--muted); }
table.ratio { margin-top: 12px; }

/* ───── scene: cards ───── */
.cards { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.card.card, button.card { display: inline-flex; flex-direction: column; align-items: center; padding: 12px 22px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font: inherit; font-weight: 800; font-size: 1.15rem; color: var(--ink); cursor: pointer; min-width: 9rem; box-shadow: var(--shadow); }
button.card:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
button.card .ct { border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 4px; }
button.card.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--card)); }
button.card.bad { border-color: var(--red); animation: shake .35s; }
.work { font-size: 1.15rem; margin: 10px 0; }
.work .dim { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; }

/* ───── scene: race ───── */
.rates { display: grid; gap: 10px; margin: 10px 0; font-size: 1.05rem; }
.rates > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.track { position: relative; margin: 14px 0; padding: 10px 70px 10px 10px; background: var(--bg2); border-radius: 12px; }
.track .lane { position: relative; height: 40px; border-bottom: 2px dashed var(--line); }
.track .lane:last-of-type { border-bottom: 0; }
.track .nm { position: absolute; left: 0; top: 2px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.track .climber { position: absolute; left: 0; bottom: 4px; font-size: 1.6rem; transition: transform linear 3s; }
.track .climber.go { transform: translateX(calc(100vw - 100%)); transform: translateX(min(700px, 100%)); }
.track .flag { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: .85rem; font-weight: 700; text-align: center; }
.track { --lane-w: 100%; }
.track .lane { overflow: visible; }
.track .climber.go { transform: translateX(calc(var(--track-w, 520px))); }

/* ───── scene: lock ───── */
.lockwrap { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; }
@media (max-width: 560px) { .lockwrap { grid-template-columns: 1fr; justify-items: center; } }
.dial { text-align: center; }
.dial svg { width: 110px; height: 110px; }
.dial .ring { fill: var(--bg2); stroke: var(--ink); stroke-width: 3; }
.dial .notches line { stroke: var(--muted); stroke-width: 2; }
.dial .needle { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); transform-origin: 50px 50px; transform-box: view-box; }
.dial .needle polygon { fill: var(--gold); }
.dial .hub { fill: var(--ink); }
.dial.open .ring { stroke: var(--green); fill: color-mix(in srgb, var(--green) 20%, var(--bg2)); }
.dial-k { font-size: .75rem; color: var(--muted); font-weight: 700; }
.lockexpr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 800 1.7rem/1 ui-monospace, Menlo, monospace; padding: 12px; border-radius: 12px; background: var(--bg2); }
.lockexpr.bad { animation: shake .35s; }
.lockexpr .tok { padding: 6px 4px; }
.lockexpr .tok.lp, .lockexpr .tok.rp { color: var(--muted); }
.lockexpr button.tok { border: 2px solid var(--accent); background: var(--card); color: var(--accent); border-radius: 10px; cursor: pointer; font: inherit; padding: 6px 12px; }
.lockexpr button.tok:hover { background: var(--accent); color: var(--accent-ink); }
.lockexpr button.tok.pow { font-size: 1.1rem; padding: 4px 8px; align-self: flex-start; }
ol.steps { font-size: 1rem; }

/* ───── scene: backpack ───── */
.tile { display: inline-grid; place-items: center; font-weight: 800; border-radius: 8px; color: #fff; user-select: none; transition: transform .15s; }
.tile.x { background: var(--green); min-width: 3.4rem; height: 2rem; padding: 0 8px; }
.tile.one { background: var(--crev); width: 2rem; height: 2rem; }
.tile.sel { outline: 3px solid var(--gold); outline-offset: 2px; transform: scale(1.1) !important; }
.pile { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px; min-height: 90px; background: var(--bg2); border-radius: 12px; }
.pile .tile { cursor: pointer; }
.pile.flat .tile { transform: none; }
.bins { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.bin { border: 2px dashed var(--line); border-radius: 12px; padding: 14px; background: var(--card); font: inherit; color: var(--ink); cursor: pointer; display: grid; gap: 4px; }
.bin:hover { border-color: var(--accent); }
.bin.bad { animation: shake .35s; border-color: var(--red); }
.bin .bl { font-size: .85rem; color: var(--muted); font-weight: 700; }
.bin .bc { font-size: 1.5rem; font-weight: 800; min-height: 1.8rem; }
.sliderrow { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; font-weight: 700; }
.sliderrow input { flex: 1; }
.total { font-size: 1.2rem; }
.bundles { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0; }
.bundle { display: flex; gap: 6px; padding: 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--bg2); transition: all .4s; }
.bundles.open .bundle { border-color: transparent; background: transparent; padding: 0; }

/* ───── scene: balance ───── */
.scale { position: relative; height: 170px; margin: 10px 0 6px; }
.scale .beam { position: absolute; left: 6%; right: 6%; top: 20px; height: 8px; background: var(--ink); border-radius: 4px; }
.scale .post { position: absolute; left: 50%; top: 24px; width: 10px; height: 130px; margin-left: -5px; background: var(--rock); border-radius: 4px; }
.scale .pan { position: absolute; top: 28px; width: 40%; min-height: 110px; border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 20px 20px; padding: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-end; background: var(--card); }
.scale .pan.left { left: 4%; }
.scale .pan.right { right: 4%; }
.blk { width: 18px; height: 18px; background: var(--green); border-radius: 4px; display: inline-block; }
.blk.neg { background: var(--red); }
.bag { display: inline-grid; place-items: center; width: 44px; height: 40px; background: var(--gold); border-radius: 10px 10px 14px 14px; font-weight: 800; color: #1d2733; }
.bag.part { background: repeating-linear-gradient(90deg, var(--gold) 0 8px, #f3d48a 8px 16px); }
.bag small { font-size: .65rem; }
.eqline { font-size: 1.35rem; text-align: center; margin: 4px 0 10px; }
.ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; align-items: center; }
.ops .op { display: flex; gap: 8px; align-items: center; }
.ops .op .btn { flex: 1; text-align: left; }
.ops .op .ni { width: 3.2rem; min-width: 0; }

/* legal page */
.legal-body { background: var(--bg); }
.legal { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.legal h1 { margin-top: .2em; }
.legal .back { text-decoration: none; }
.legal .small { font-size: .85rem; }

@media (max-width: 480px) { body { font-size: 16px; } .gamehost, .qcard, .card { padding: 14px; } .top .sub { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
