/* Econ Games — textbook-diagram look: graph paper, navy ink, demand blue, supply red, highlighter timer. */
:root {
  --paper: #F7F9FC;
  --surface: #FFFFFF;
  --grid: #DFE7F2;
  --ink: #1B2A41;
  --ink-2: #44546C;
  --muted: #6A7A91;
  --line: #CBD6E4;
  --demand: #2563D9;
  --demand-soft: #E3ECFC;
  --supply: #D23F35;
  --supply-soft: #FCE7E5;
  --hi: #F7E463;
  --hi-ink: #3A3200;
  --pos: #12805C;
  --neg: #C2362C;
  --focus: #2563D9;
  --r-lg: 14px;
  --r-sm: 8px;
  --shadow: 0 1px 0 rgba(27, 42, 65, .06), 0 6px 18px -10px rgba(27, 42, 65, .25);
  --font-display: 'Bricolage Grotesque', 'Avenir Next Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101826; --surface: #172235; --grid: #1E2B40; --ink: #E8EEF7; --ink-2: #B9C6D8; --muted: #8A9AB0;
    --line: #2C3C55; --demand: #6EA1FF; --demand-soft: #1C2D4D; --supply: #FF7A6E; --supply-soft: #3A2026;
    --hi: #F2DD4B; --hi-ink: #2A2400; --pos: #4FCB9A; --neg: #FF7A6E; --focus: #6EA1FF;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101826; --surface: #172235; --grid: #1E2B40; --ink: #E8EEF7; --ink-2: #B9C6D8; --muted: #8A9AB0;
  --line: #2C3C55; --demand: #6EA1FF; --demand-soft: #1C2D4D; --supply: #FF7A6E; --supply-soft: #3A2026;
  --hi: #F2DD4B; --hi-ink: #2A2400; --pos: #4FCB9A; --neg: #FF7A6E; --focus: #6EA1FF; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 400 17px/1.55 var(--font-body);
  font-variant-numeric: tabular-nums;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px; background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4.8vw, 2.8rem); }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; margin-top: 1.1em; }
p { margin: 0 0 .8em; max-width: 68ch; }
a { color: var(--demand); text-underline-offset: 3px; }
code, .mono { font-family: var(--font-mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font: 800 1.15rem var(--font-display); }
.brand-mark svg path { stroke-width: 3; stroke-linecap: round; fill: none; }
.mk-d { stroke: var(--demand); } .mk-s { stroke: var(--supply); } .mk-e { fill: var(--hi); stroke: var(--ink); stroke-width: 1.2; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav > a { padding: 6px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.topnav > a.on { background: var(--ink); color: var(--paper); }
.account { position: relative; margin-left: 6px; }
.account summary { list-style: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--demand-soft); color: var(--demand); font-weight: 700; }
.account summary::-webkit-details-marker { display: none; }
.account .menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 12px; min-width: 240px; display: grid; gap: 4px; }
.account .who { font-size: .9rem; margin-bottom: 8px; }
.account .who span { color: var(--muted); }

.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; }
.page.narrow { max-width: 560px; }
.page.play { max-width: 1040px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: .95rem; }
.back:hover { color: var(--ink); }
.kicker { color: var(--muted); font-weight: 600; margin: 0 0 4px; font-size: .95rem; }
.lede { font-size: 1.12rem; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.spread { justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 14px; }
.scroll { overflow-x: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
details.card > summary { cursor: pointer; font: 600 1.1rem var(--font-display); }
details.card[open] > summary { margin-bottom: 12px; }
.empty { padding: 28px 0; }
.note { background: var(--demand-soft); border-left: 4px solid var(--demand); padding: 10px 12px; border-radius: 6px; font-size: .95rem; }
.saved { color: var(--pos); font-weight: 600; font-size: .95rem; }
.error { color: var(--neg); background: var(--supply-soft); padding: 10px 12px; border-radius: 6px; }
.hint { color: var(--muted); font-size: .9rem; }
.banner.error { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; border: 1px solid var(--supply); }

/* ---------- Controls ---------- */
button, .button {
  font: 600 1rem var(--font-body); color: var(--ink); background: var(--surface); border: 1.5px solid var(--line);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 44px; transition: background .12s, border-color .12s;
}
button:hover:not(:disabled), .button:hover { border-color: var(--ink-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--demand); border-color: var(--demand); }
button.big, .button.big { font-size: 1.08rem; padding: 12px 22px; min-height: 50px; }
button.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, var(--line)); }
button.link { background: none; border: 0; padding: 4px 0; min-height: 0; color: var(--demand); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
button.link.danger { color: var(--neg); }
button.chosen { background: var(--hi); border-color: var(--hi-ink); color: var(--hi-ink); }
[aria-busy="true"] button[type="submit"], button[aria-busy="true"] { opacity: .6; cursor: progress; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.help { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea {
  font: 400 1.05rem var(--font-body); color: var(--ink); background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; width: 100%; min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--demand); outline: none; box-shadow: 0 0 0 3px var(--demand-soft); }
textarea { resize: vertical; line-height: 1.45; }
textarea.mono { font: .9rem/1.5 var(--font-mono); }
input[type="range"] { padding: 0; min-height: 36px; accent-color: var(--demand); border: 0; background: transparent; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .6; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; min-height: 0; accent-color: var(--demand); flex: none; }
.switch.wide { flex-wrap: wrap; }
.switch.wide .help { flex-basis: 100%; padding-left: 32px; }
.inline { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.inline input { flex: 1 1 180px; width: auto; }
.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--grid); color: var(--ink-2); white-space: nowrap; }
.chip.st-lobby { background: var(--demand-soft); color: var(--demand); }
.chip.st-running { background: var(--hi); color: var(--hi-ink); }
.chip.st-paused { background: var(--supply-soft); color: var(--supply); }
.chip.st-finished { background: var(--grid); color: var(--muted); }

/* ---------- Sign in ---------- */
.signin { display: grid; min-height: calc(100vh - 60px); align-items: center; }
.signin-hero { max-width: 620px; }
.signin h1 { font-size: clamp(2.6rem, 8vw, 4.6rem); line-height: .98; letter-spacing: -.02em; }
.hero-graph { width: min(340px, 80vw); margin: 0 0 18px -8px; overflow: visible; }
.hero-graph .ax { stroke: var(--ink); stroke-width: 2.5; fill: none; }
.hero-graph .d { stroke: var(--demand); stroke-width: 5; fill: none; stroke-linecap: round; stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 1.1s .1s ease-out forwards; }
.hero-graph .s { stroke: var(--supply); stroke-width: 5; fill: none; stroke-linecap: round; stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 1.1s .35s ease-out forwards; }
.hero-graph .eq { fill: var(--hi); stroke: var(--ink); stroke-width: 2.5; opacity: 0; animation: pop .35s 1.2s ease-out forwards; }
.hero-graph .lbl { font: 700 18px var(--font-display); fill: var(--ink); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); transform-origin: 208px 147px; } to { opacity: 1; transform: scale(1); transform-origin: 208px 147px; } }
.google { gap: 12px; margin-top: 8px; }
.fine { color: var(--muted); font-size: .9rem; margin-top: 14px; }
.devlogin { max-width: 420px; display: grid; gap: 12px; }

/* ---------- Student home ---------- */
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.joinclass { display: grid; gap: 6px; min-width: min(100%, 320px); }
.joinclass input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.class-block { margin-bottom: 26px; }
.class-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 8px; }
.class-title h2 { margin: 0; }
.game-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.game-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t c" "y c"; gap: 2px 12px; align-items: center;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; color: var(--ink); }
.game-row:hover { border-color: var(--demand); }
.game-row.running, .game-row.lobby { border-left: 5px solid var(--demand); }
.game-row.finished { opacity: .78; }
.g-title { grid-area: t; font-weight: 700; } .g-type { grid-area: y; font-size: .88rem; color: var(--muted); } .game-row .chip { grid-area: c; }
.home-foot { margin-top: 40px; }

/* ---------- Intro / quiz / waiting ---------- */
.intro, .quiz, .waiting, .teams, .final, .lab-head { max-width: 720px; }
.rules { padding-left: 1.2em; margin: 0 0 18px; }
.rules li { margin-bottom: 6px; max-width: 66ch; }
.q { border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; background: var(--surface); }
.q legend { float: left; width: 100%; font-weight: 700; padding: 0; margin-bottom: 6px; max-width: 60ch; }
.q legend + * { clear: both; }
.q.wrong { border-color: var(--neg); background: var(--supply-soft); }
.q.right { border-color: var(--pos); }
.opt { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 4px; cursor: pointer; }
.opt input { width: 20px; height: 20px; min-height: 0; margin-top: 3px; accent-color: var(--demand); flex: none; }
.feedback { color: var(--neg); margin: 6px 0 0; font-size: .92rem; }
.waiting .pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--hi); border: 2px solid var(--ink); margin: 18px 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .5; } }

/* teams */
.myteam { border: 2px solid var(--ink); }
.myteam-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.members { padding-left: 1.2em; }
.createteam { margin: 16px 0; }
.team-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.team-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }

/* ---------- Live game ---------- */
.live-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.live-head h1 { margin-bottom: 8px; }
.round-badge { display: grid; justify-items: center; line-height: 1; padding: 8px 14px; border: 2px solid var(--ink); border-radius: var(--r-lg); background: var(--surface); min-width: 78px; }
.rb-n { font: 800 2.2rem var(--font-display); }
.rb-of { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* The timer: the one loud thing on screen */
.timer { position: relative; display: flex; align-items: center; gap: 14px; margin: 14px 0; padding: 12px 18px; border-radius: var(--r-lg);
  background: var(--hi); color: var(--hi-ink); overflow: hidden; isolation: isolate; }
.timer-label { font-weight: 700; }
.timer-text { margin-left: auto; font: 800 2rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.timer-track { position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--hi) 45%, var(--paper)); }
.timer-fill { position: absolute; inset: 0; background: var(--hi); transform-origin: left; transition: transform .25s linear; }
.timer.urgent .timer-fill { background: color-mix(in srgb, var(--supply) 75%, var(--hi)); }
.timer.urgent { color: #fff; }
.timer.urgent .timer-text { animation: blink 1s steps(2) infinite; }
.timer.done .timer-text::after { content: ' · closing'; font-size: .9rem; font-weight: 600; }
.timer.paused, .timer.none { background: var(--grid); color: var(--ink-2); }
@keyframes blink { 50% { opacity: .55; } }

.teamstrip { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px dashed var(--ink-2); border-radius: var(--r-sm); margin-bottom: 14px; }
.live-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .live-grid { grid-template-columns: minmax(0, 1fr); } }
.col-main, .col-side, .card, details { min-width: 0; }
.scroll { max-width: 100%; }
.decide { border: 2px solid var(--ink); }
.market-form .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.market-form .fields.off { opacity: .4; }
.market-form .fields input { font-size: 1.3rem; font-weight: 700; }
.preview { margin-top: 16px; padding: 14px; border-radius: var(--r-sm); background: var(--paper); border: 1px solid var(--line); }
.pv-title { font-weight: 700; }
.pv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.pv div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.pv dt { font-size: .82rem; color: var(--muted); }
.pv dd { margin: 0; font-weight: 700; font-size: 1.15rem; }
.pv div.big { border-color: var(--ink); }
.pv div.big dd { font: 800 1.5rem var(--font-display); }
.costs { margin-top: 14px; }
.costs summary { cursor: pointer; font-weight: 600; color: var(--demand); }

table { border-collapse: collapse; width: 100%; }
.mini { font-size: .92rem; margin: 8px 0; }
.mini th, .mini td, .board th, .board td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mini th:first-child, .mini td:first-child, .board th:nth-child(2), .board td:nth-child(2) { text-align: left; }
.mini th, .board th { font-size: .8rem; color: var(--muted); font-weight: 700; }
.mini tr.hl td { background: var(--hi); color: var(--hi-ink); }
.board tr.me td, .mini tr.me td { background: var(--hi); color: var(--hi-ink); font-weight: 700; }
.board td:first-child { font-weight: 700; color: var(--muted); width: 2.5em; }

/* PD */
.pd-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 14px; }
button.pd { min-height: 96px; font: 800 1.4rem var(--font-display); border-width: 3px; border-radius: var(--r-lg); }
button.pd.c { border-color: var(--demand); color: var(--demand); }
button.pd.d { border-color: var(--supply); color: var(--supply); }
button.pd.c.chosen { background: var(--demand); color: #fff; }
button.pd.d.chosen { background: var(--supply); color: #fff; }
.strip { display: grid; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.strip-row { display: flex; gap: 3px; align-items: center; }
.strip-name { font-size: .78rem; color: var(--muted); width: 7em; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; font: 700 .75rem var(--font-body); color: #fff; flex: none; }
.mv.C { background: var(--demand); } .mv.D { background: var(--supply); }
.pd-result .mv { width: 28px; height: 28px; font-size: .9rem; vertical-align: middle; }
.matrix { margin-top: 14px; font-size: .92rem; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 8px; text-align: center; }
.matrix thead th { font-size: .82rem; color: var(--muted); }
.matrix tbody th { text-align: left; font-size: .85rem; }

/* public goods / ultimatum */
.slider-label { font-size: 1.05rem; }
.big-num { font: 800 2rem var(--font-display); color: var(--demand); }
.split { display: flex; justify-content: space-between; font-size: 1.05rem; margin: 6px 0 10px; }
.offer-big { font-size: 1.25rem; }
.punish input { width: 90px; min-height: 40px; text-align: right; }

/* results */
.result-card .total { margin: 12px 0 0; font-size: 1.05rem; }
.public h3 { margin-top: 14px; }
.prices { list-style: none; padding: 0; columns: 2; font-size: .9rem; }
.prices li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; break-inside: avoid; }
.history summary { cursor: pointer; }
.rules-drawer { margin-top: 18px; }
.rules-drawer summary { cursor: pointer; font-weight: 600; color: var(--demand); }

.final-score { display: flex; align-items: center; gap: 24px; margin: 8px 0 22px; flex-wrap: wrap; }
.place { display: grid; justify-items: center; background: var(--hi); color: var(--hi-ink); border: 2px solid var(--ink); border-radius: 50%; width: 112px; height: 112px; place-content: center; line-height: 1; }
.place-n { font: 800 3rem var(--font-display); }
.place-of { font-size: .85rem; }
.score { font: 800 2.4rem var(--font-display); margin: 0; }

/* charts */
.chart { margin: 0; }
.chart figcaption { font: 600 1rem var(--font-display); margin-bottom: 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--ink-2); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 12px var(--font-body); }
.chart .axis { fill: var(--muted); font: 600 12px var(--font-body); }
.chart .ref { stroke: var(--ink-2); stroke-dasharray: 2 4; stroke-width: 1.5; }
.chart .ref-label { fill: var(--ink-2); font: 600 11px var(--font-body); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.chart .line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.dashed { stroke-dasharray: 6 5; stroke-width: 2; }
.chart .c-demand { stroke: var(--demand); fill: var(--demand); } .chart path.c-demand { fill: none; }
.chart .c-supply { stroke: var(--supply); fill: var(--supply); } .chart path.c-supply { fill: none; }
.chart .c-ink { stroke: var(--ink); } .chart .c-muted { stroke: var(--muted); opacity: .55; } .chart path.c-muted { fill: none; }
.chart .c-mark { stroke: var(--ink); fill: var(--hi); } .chart circle.c-mark { r: 7; stroke-width: 2; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin-top: 4px; }
.lg::before { content: ''; display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; background: var(--ink); }
.lg-demand::before { background: var(--demand); } .lg-supply::before { background: var(--supply); } .lg-muted::before { background: var(--muted); }
.lg-mark::before { background: var(--hi); height: 10px; width: 10px; border-radius: 50%; border: 2px solid var(--ink); }
.lg.dashed::before { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px); }
.lg-supply.dashed::before { color: var(--supply); } .lg-demand.dashed::before { color: var(--demand); } .lg-muted.dashed::before { color: var(--muted); }
.chart-empty { color: var(--muted); padding: 20px 0; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 6em 1fr 4em; gap: 8px; align-items: center; font-size: .9rem; }
.bar-track { height: 12px; background: var(--grid); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--demand); }
.bar-fill.mine { background: var(--supply); }

/* strategy lab */
.lab-step h2 { margin-bottom: 10px; }
.explain { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; }
.explain p { margin: 0 0 4px; }
.code summary { cursor: pointer; font-weight: 600; color: var(--demand); margin: 12px 0 8px; }
.tests { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.tests li { border-top: 1px solid var(--line); padding-top: 10px; min-width: 0; }
.test-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tests p { margin: 2px 0 6px; }
.card .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 18px; background: transparent; }
.strip { max-width: 100%; }
.matches { list-style: none; padding: 0; display: grid; gap: 14px; }
pre.mono { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; overflow-x: auto; white-space: pre; }

/* ---------- Instructor ---------- */
.class-card .cc-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.class-card h2 a { color: var(--ink); text-decoration: none; }
.code-box { display: grid; justify-items: end; line-height: 1.1; }
.code-box strong { font: 800 1.6rem var(--font-display); letter-spacing: .14em; color: var(--demand); }
.code-box.big strong { font-size: 2.4rem; }
.newclass summary, .archived summary { cursor: pointer; font: 600 1.1rem var(--font-display); }
.group-h { margin-top: 26px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.type-card { display: grid; gap: 6px; text-align: left; align-content: start; border-radius: var(--r-lg); padding: 16px; min-height: 120px; font-weight: 400; }
.type-card strong { font: 600 1.15rem var(--font-display); }
.type-card span { color: var(--ink-2); font-size: .93rem; }
.type-card:hover { border-color: var(--demand); background: var(--demand-soft); }
.presets { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.presets button { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.presets p { flex-basis: 100%; margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px 18px; margin: 18px 0; align-items: start; }
.settings-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 18px; margin: 14px 0; }
.settings-list dt { font-size: .82rem; color: var(--muted); } .settings-list dd { margin: 0; font-weight: 600; }

.ctrl-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.join-box { display: grid; justify-items: end; text-align: right; line-height: 1.25; }
.join-box strong { font-size: 1.05rem; }

.controls:empty { display: none; }
.controls .big-line { font: 600 1.15rem var(--font-display); margin: 0; }
.ctrl-status { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.ctrl-status .timer { margin: 0 0 8px; }
.exports { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ctrl-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .ctrl-grid { grid-template-columns: minmax(0, 1fr); } }
.sub-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.sub-grid li { display: grid; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.sub-grid li.in { background: var(--demand-soft); border-color: var(--demand); }
.sub-grid li.waiting { color: var(--muted); border-style: dashed; }
.player-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.player { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.player .ok { color: var(--pos); font-weight: 700; }
.player select { width: auto; min-height: 34px; padding: 4px 8px; font-size: .88rem; }
.team-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.team-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.team-box ul { list-style: none; padding: 0; margin: 10px 0; }
.strat-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.strat-list summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.req-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.req-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* projector */
.projector { max-width: none; padding: 28px 40px; min-height: 100vh; font-size: 1.3rem; }
.projector h1 { font-size: clamp(2.4rem, 5vw, 4rem); }
.proj-exit { position: fixed; top: 10px; right: 14px; font-size: .9rem; opacity: .4; }
.proj-exit:hover { opacity: 1; }
.proj-join p { font-size: 1.8rem; margin: 0 0 10px; max-width: none; }
.proj-url { font: 800 clamp(2rem, 5vw, 3.6rem) var(--font-display); color: var(--demand); }
.proj-code { font-family: var(--font-display); letter-spacing: .14em; background: var(--hi); color: var(--hi-ink); padding: 0 12px; border-radius: 8px; }
.proj-count { font: 600 1.6rem var(--font-display); }
.proj-round { font: 600 2rem var(--font-display); }
.proj-round strong { font-size: 3.4rem; }
.projector .timer { font-size: 1.4rem; padding: 18px 26px; }
.projector .timer-text { font-size: 4rem; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; margin-top: 20px; }
.proj-grid .wide { grid-column: 1 / -1; }
.proj-board { padding-left: 1.4em; font-size: 1.5rem; }
.proj-board li { display: flex; justify-content: space-between; gap: 20px; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* toast + dev badge */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: 12px 18px;
  border-radius: 12px; box-shadow: var(--shadow); max-width: min(92vw, 520px); z-index: 50; transition: transform .25s ease; font-weight: 600; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--neg); color: #fff; }
.dev-badge { position: fixed; left: 10px; bottom: 10px; background: var(--hi); color: var(--hi-ink); font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; z-index: 40; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .page { padding: 16px 14px 70px; }
  .card { padding: 14px; }
  .timer-text { font-size: 1.7rem; }
  .projector { padding: 16px; }
  .proj-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .hero-graph .d, .hero-graph .s { stroke-dashoffset: 0; }
  .hero-graph .eq { opacity: 1; }
}

button.armed, .button.armed { background: var(--neg); border-color: var(--neg); color: #fff; }
.toast.warn { background: var(--hi); color: var(--hi-ink); }

.production .inputs { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.production .inputs li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.production .inputs span { color: var(--muted); }
.worksheet input { width: 92px; min-height: 36px; padding: 4px 6px; font-size: .92rem; text-align: right; }
.worksheet td.ok input { border-color: var(--pos); background: color-mix(in srgb, var(--pos) 12%, var(--paper)); }
.worksheet td.bad input { border-color: var(--neg); background: var(--supply-soft); }
