/* Layout: lobby is a single column; battle page is a stage over a three-column console (agent | booth + log | agent) over a timeline.
   One token layer (colours, spacing, radius, type, motion) and one of each control; every panel builds from those. */
:root {
  --bg: #eef1ec; --surface: #fafbf8; --sunk: #e3e8e0; --fg: #18201b; --muted: #58645c; --line: #cdd5ca;
  --accent: #c9352b; --p1: #2a5fb4; --p2: #9a5c0c; --player: #2a5fb4; --player-bg: #e3ebf7;
  --good: #2c8a44; --warn: #b8860b; --bad: #c4352b;
  --rest: #6b5fa8; --rest-bg: #ebe8f5;
  --camp: #2f7a5a; --camp-bg: #dcefe4;
  --gb0: #0f380f; --gb1: #306230; --gb2: #8bac0f; --gb3: #c4d99a; --gbtext: #e8f2cf; --mark: #fbe9a6;
  /* The stage's backdrop */
  --sky: #dfe6d8; --hill-far: #c8d3c0; --hill-mid: #aebca4; --floor: #c7cfbd; --floor-dark: #b3bca8;
  --f-display: "Silkscreen", "Courier New", monospace;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* Spacing, radius and type steps. Half-pixel sizes are gone: a panel picks a step. */
  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px; --sp5: 24px; --sp6: 32px; --sp7: 48px;
  --r1: 4px; --r2: 8px; --r3: 12px; --r-pill: 999px;
  --fs0: 11px; --fs1: 12px; --fs2: 13px; --fs3: 14px; --fs-body: 15px; --fs4: 16px; --fs5: 18px; --fs6: 22px; --fs7: 28px;
  /* Motion: three durations, three easings; the stage divides every duration by --rate (the speed selector). */
  --t-fast: 120ms; --t: 240ms; --t-slow: 480ms;
  --ease: cubic-bezier(.2, .7, .2, 1); --ease-out: cubic-bezier(.16, 1, .3, 1); --ease-in: cubic-bezier(.6, 0, .9, .4);
  --lift: 0 6px 20px rgb(20 30 20 / .14);
  --rate: 1;
  /* Line charts (public/lib/linechart.js): categorical slots validated on the app's surfaces, light and dark. */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111512; --surface: #191f1b; --sunk: #222a24; --fg: #e3eae4; --muted: #98a59c; --line: #313a33;
  --accent: #ee5b4d; --p1: #7ea8f0; --p2: #e0a54d; --good: #5cc277; --warn: #e2b440; --bad: #f06a5d; --mark: #4d4319;
  --player: #8fb4f2; --player-bg: #1e2a3d;
  --rest: #b4a8f0; --rest-bg: #26223a;
  --camp: #6fd3a3; --camp-bg: #1b3328;
  --sky: #1b2320; --hill-far: #22302a; --hill-mid: #2a3b32; --floor: #26302a; --floor-dark: #1d2622;
  --lift: 0 8px 24px rgb(0 0 0 / .5);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #111512; --surface: #191f1b; --sunk: #222a24; --fg: #e3eae4; --muted: #98a59c; --line: #313a33;
  --accent: #ee5b4d; --p1: #7ea8f0; --p2: #e0a54d; --good: #5cc277; --warn: #e2b440; --bad: #f06a5d; --mark: #4d4319;
  --player: #8fb4f2; --player-bg: #1e2a3d;
  --rest: #b4a8f0; --rest-bg: #26223a;
  --camp: #6fd3a3; --camp-bg: #1b3328;
  --sky: #1b2320; --hill-far: #22302a; --hill-mid: #2a3b32; --floor: #26302a; --floor-dark: #1d2622;
  --lift: 0 8px 24px rgb(0 0 0 / .5);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  color-scheme: dark }
/* The chart series names the chart library uses */
:root { --s1: var(--c1); --s2: var(--c2); --s3: var(--c3); --s4: var(--c4); --s5: var(--c5); --s6: var(--c6); --s7: var(--c7); --s8: var(--c8); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: var(--fs-body); line-height: 1.55; }
a { color: inherit; }
.wrap { max-width: 1400px; margin: 0 auto; padding-inline: 20px; padding-block: var(--sp5) 60px; }
h1, h2, h3 { text-wrap: balance; line-height: 1.2; margin: 0; }
h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 4vw, 40px); }
h2 { font-size: var(--fs5); font-weight: 600; }
p { margin: 0; }
.eyebrow { font-family: var(--f-display); font-size: var(--fs1); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: var(--fs2); }
code, .mono { font-family: var(--f-mono); font-size: .9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lbl { font-size: var(--fs0); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.nowrap { white-space: nowrap; }
.err { color: var(--bad); }
.wa { color: var(--warn); }
.ok { color: var(--good); } .no { color: var(--bad); }
.up { color: var(--good); font-weight: 600; }

/* ---------- Page header: the same on every page ---------- */
.pagehead { display: grid; gap: var(--sp2); margin-bottom: var(--sp4); }
.pagehead .headrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--sp2) var(--sp4); }
.pagehead .pills { display: flex; gap: var(--sp2); flex-wrap: wrap; align-items: center; }

/* ---------- Buttons: one .btn; primary, danger, ghost, icon; sm, lg ---------- */
.btn { font: inherit; font-size: var(--fs3); line-height: 1.2; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--r1); padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; text-decoration: none; transition: border-color var(--t-fast), background-color var(--t-fast), translate var(--t-fast); }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { translate: 0 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--sunk); }
.btn.icon { padding: 0; width: 32px; }
.btn.sm { font-size: var(--fs1); padding: 2px 9px; min-height: 24px; } .btn.sm.icon { width: 24px; }
.btn.lg { font-size: var(--fs4); padding: 9px 20px; min-height: 42px; }
.btn[aria-pressed="true"], .btn.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iactions { display: inline-flex; gap: var(--sp2); align-items: center; margin-left: var(--sp2); }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp2) var(--sp3); }

/* ---------- Fields: one rule for every text control, one focus ring ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea {
  font: inherit; font-size: var(--fs3); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r1); padding: 5px 9px; min-width: 0; max-width: 100%; min-height: 32px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; line-height: 1.5; width: 100%; }
input[type="color"] { width: 32px; height: 26px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--bg); cursor: pointer; }
input[type="file"] { font: inherit; font-size: var(--fs3); max-width: 100%; }
:disabled:is(input, select, textarea), textarea[readonly] { background: var(--sunk); color: var(--muted); }
.picker { display: flex; align-items: center; gap: var(--sp2); }
.picker .lbl { white-space: nowrap; }
.picker select { flex: 1 1 auto; min-width: 12ch; }

/* ---------- Chips: one family. Shape says what it is (square = a fact on a row, pill = a state, mono = a number); tone is semantic. ---------- */
.chip, .pill, .tag, .ctag, .bchip, .bstep, .bturnchip, .chipst, .evhead .kind, .count, .vact, .astatus, .wdays .counts span, .hside .nm .w, .bminetag, .type, .ph {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs0); font-weight: 600; letter-spacing: .03em; padding: 1px 7px; border-radius: 3px; background: var(--sunk); color: var(--fg); white-space: nowrap; line-height: 1.5; vertical-align: middle; }
.chip.pill, .pill, .bchip, .bstep, .bturnchip, .chipst, .count, .vact, .wdays .counts span, .type, .ph, .chip.rest, .chip.camp { border-radius: var(--r-pill); padding: 2px 9px; }
.chip.mono, .chip.mono *, .count, .vact, .bturnchip .mono { font-family: var(--f-mono); font-weight: 400; letter-spacing: 0; }
.ctag, .tag, .evhead .kind, .astatus, .hside .nm .w { text-transform: uppercase; letter-spacing: .06em; font-size: var(--fs0); }
.chip.good, .pill.open, .pill.fresh, .chipst.yes, .bchip.won, .bstep.done, .bturnchip.done, .restsides .chip { background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good); }
.pill.invite, .pill.locked, .chipst.wait, .tag.st { background: color-mix(in srgb, var(--warn) 20%, var(--surface)); color: var(--warn); }
.chipst.no, .bstep.bad, .bturnchip.bad, .tag.out { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--bad); }
.chip.player, .pill.player, .ctag.player { background: var(--player-bg); color: var(--player); }
.chip.rest, .pill.rest { background: var(--rest-bg); color: var(--rest); }
.chip.camp, .pill.camp { background: var(--camp-bg); color: var(--camp); }
.chip.solid, .tag.on, .astatus, .hside .nm .w { background: var(--fg); color: var(--bg); }
.chip.outline, .pill, .pill.house, .pill.closed, .ctag.npc, .bchip, .bstep, .bturnchip, .chipst, .type, .ph, .count { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.ph.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill { color: var(--fg); }
.pill.house, .pill.closed { background: var(--sunk); border-color: transparent; }
.pill.player, .pill.open, .pill.invite, .pill.locked, .pill.rest, .pill.camp, .pill.fresh { border-color: transparent; font-weight: 600; }
.pill.won { color: var(--good); } .pill.lost { color: var(--bad); }
.pill.msflag { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); font-weight: 600; }
.chip.now, .bstep.now, .bturnchip.now { color: var(--fg); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.chip.now::before, .bstep.now::before, .bturnchip.now::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.bturnchip b { color: var(--fg); font-weight: 600; } .bturnchip .mono { font-size: var(--fs0); opacity: .75; }
.bturnchip.you.done, .bchip.you { background: var(--mark); color: var(--fg); }
.bchip.won { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.bchip.lost { opacity: .6; }
.bchip b { font-family: var(--f-mono); }
.bminetag { background: var(--accent); color: #fff; border-radius: var(--r-pill); padding: 1px 9px; justify-self: start; margin-bottom: 2px; }
.bminetag b { font-family: var(--f-mono); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
.dot.done { background: var(--good); }
.dot.err { background: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }
/* Facts on a Pokémon: stat changes and effects, in mono */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp1); min-height: 22px; }
.chip { font-family: var(--f-mono); font-weight: 400; letter-spacing: 0; }
.chip.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); }
.chip.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); }
.chip.up { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--fg); font-weight: 400; }
.chip.down { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.type i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.types { display: flex; gap: var(--sp1); margin: 3px 0; }
.kbd { font-family: var(--f-mono); font-size: var(--fs0); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }

/* ---------- Tabs: primary (underline, accent) for a page's sections; segment (pill group, fg fill) inside a panel ---------- */
.tabs { display: flex; gap: var(--sp1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; font: inherit; font-size: var(--fs-body); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 14px; color: var(--muted); cursor: pointer; display: inline-flex; gap: var(--sp2); align-items: center; transition: color var(--t-fast); }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button.nudge { box-shadow: inset 0 0 0 2px var(--accent); border-radius: var(--r1) var(--r1) 0 0; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--fg); }
.tabs button.tabnew { color: var(--player); }
.tabs button.tabnew[aria-selected="true"] { color: var(--fg); }
.tabs .count { font-size: var(--fs0); padding: 0 7px; font-weight: 400; }
@media (max-width: 520px) { .tabs button { padding: 8px 10px; font-size: var(--fs3); } }
.segment { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--bg); max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.segment::-webkit-scrollbar { display: none; }
.segment button, .segment .tablbl { flex: none; font: inherit; font-size: var(--fs2); border: 0; background: none; color: var(--muted); border-radius: var(--r-pill); padding: 4px 12px; cursor: pointer; transition: background-color var(--t-fast), color var(--t-fast); }
.segment button:hover { color: var(--fg); }
.segment button[aria-selected="true"], .segment .tablbl { background: var(--fg); color: var(--bg); font-weight: 600; }
.segment.sm button { font-size: var(--fs1); padding: 2px 9px; }

/* ---------- Selection: selected is an accent ring and a faint tint; current (today, this turn, on the clock) is a foreground ring. Never a fill. ---------- */
.card, .tcard, .bside, .bwhocard, .wkchip, .vpick, .pickcell, .wday, .msorder li, .lmon {
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast); }
.card { display: grid; gap: var(--sp1); text-align: left; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; cursor: pointer; min-width: 0; }
.card:hover, .tcard:hover, .bside:hover:not(:disabled), .bwhocard:hover, .wkchip:hover:not(:disabled), .vpick:hover { border-color: var(--muted); }
.selected, [aria-pressed="true"]:is(.card, .tcard, .vpick, .wkchip), .bside.sel, .bside.mine, .bwhocard.sel, .pickcell.on, .wkchip.target, .lmon.on {
  border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.current, .wkchip.now, .wday.today, .msorder li.now { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }

/* ---------- Disclosures, confirmations, status lines, toasts ---------- */
details > summary { cursor: pointer; font-size: var(--fs2); color: var(--muted); list-style: none; display: flex; flex-wrap: wrap; gap: 6px var(--sp2); align-items: center; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); transition: rotate var(--t-fast); display: inline-block; flex: none; }
details[open] > summary::before { rotate: 90deg; }
details > summary:hover { color: var(--fg); }
details.why { border-left: 2px solid var(--line); padding-left: 10px; }
.why pre, details.why pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); font-style: italic; max-height: 220px; overflow-y: auto; }
.why.fail summary { color: var(--warn); }
.why.fail .attempt { display: grid; gap: var(--sp1); margin-top: var(--sp2); padding-top: var(--sp2); border-top: 1px solid var(--line); font-style: normal; }
.why.fail .attempt:first-of-type { border-top: 0; }
.why.fail .json { white-space: pre-wrap; max-height: 160px; overflow-y: auto; font-size: var(--fs1); }
.why.fail .verdict { font-style: normal; color: var(--fg); }
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 12px; border-radius: var(--r2); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); font-size: var(--fs2); animation: slideIn var(--t) var(--ease-out); max-width: 100%; }
.confirm.bad { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
@keyframes slideIn { from { opacity: 0; translate: 0 -4px; } }
.status { font-size: var(--fs2); color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.status.ok { color: var(--good); } .status.dirty { color: var(--warn); } .status.err { color: var(--bad); }
.toast { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--fg); color: var(--bg); border-radius: var(--r2); padding: 10px 14px; font-size: var(--fs2); box-shadow: var(--lift); display: flex; gap: 10px; align-items: center; animation: toastIn var(--t) var(--ease-out); max-width: calc(100vw - 32px); }
.toast.out { animation: toastOut var(--t) var(--ease-in) forwards; }
.toast a, .toast .btn { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); background: transparent; }
@keyframes toastIn { from { opacity: 0; translate: 0 10px; } }
@keyframes toastOut { to { opacity: 0; translate: 0 10px; } }
.banner { padding: 10px 14px; border-radius: var(--r2); background: color-mix(in srgb, var(--warn) 18%, var(--surface)); border: 1px solid var(--line); margin-bottom: var(--sp3); }
.empty { color: var(--muted); padding: var(--sp4); border: 1px dashed var(--line); border-radius: var(--r2); }
.waiting { color: var(--muted); font-size: var(--fs2); display: flex; gap: var(--sp2); align-items: center; }
.spin { width: 10px; height: 10px; border: 2px solid var(--line); border-top-color: var(--fg); border-radius: 50%; animation: sp 0.9s linear infinite; flex: none; }
@keyframes sp { to { transform: rotate(360deg); } }
.caret { display: inline-block; width: 7px; height: 13px; background: var(--muted); vertical-align: -2px; animation: pulse .8s steps(2) infinite; }

/* ---------- Top bar: model picker and menu ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px; margin-bottom: var(--sp4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); min-height: 52px; }
.pickerbox { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; flex: 1; }
.pickerbox > * { min-width: 0; max-width: 100%; }
.topbar .hint { font-size: var(--fs1); color: var(--muted); min-width: 0; }
.topbar .err { color: var(--bad); }
.topbar .menubtn { margin-left: auto; font-weight: 600; }
dialog.menu { border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); color: var(--fg); padding: 20px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--lift); }
dialog.menu::backdrop { background: rgb(0 0 0 / .45); }
.menu .mhead { display: flex; justify-content: space-between; align-items: center; gap: var(--sp3); margin-bottom: 14px; }
.menu .msection { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.menu .msection + .msection { margin-top: 14px; }
.menu h3 { font-size: var(--fs-body); }
.mcheck { display: flex; gap: var(--sp2); align-items: center; font-size: var(--fs3); cursor: pointer; }
.who { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: var(--r-pill); background: var(--player-bg); font-size: var(--fs2); }
.who.admin { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); font-weight: 600; margin-left: auto; }
.topbar .who:first-child { margin-left: auto; }
.codebox { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-left: auto; }
.codebox .lbl { font-size: var(--fs2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.codebox input { font-family: var(--f-mono); letter-spacing: .08em; text-transform: uppercase; width: 17ch; }
.codebox .err { flex-basis: 100%; text-align: right; }
.codecell { font-family: var(--f-mono); font-size: var(--fs2); letter-spacing: .06em; white-space: nowrap; }

/* ---------- Modes: spectator, player, admin ---------- */
/* The admin's controls show only to the admin. The server refuses them from anyone else anyway. */
body:not([data-role="admin"]) .adminonly { display: none !important; }
body[data-role="admin"] .adminhide { display: none !important; }

/* ---------- Lobby ---------- */
.lobby { display: grid; gap: var(--sp5); grid-template-columns: minmax(0, 1fr); }
.lobby .topbar { margin-bottom: -6px; }
.lobby header { display: grid; gap: var(--sp2); }
.tabpanel { display: grid; gap: 28px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: var(--sp4); display: grid; gap: var(--sp3); min-width: 0; }
.dhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px var(--sp4); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs3); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-size: var(--fs1); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--sunk); }
.lobby tbody tr { cursor: default; }
#recent tr { cursor: pointer; }
.standings td, .standings th, .sched td, .sched th { white-space: nowrap; }
.sched tr.now td { background: var(--sunk); }
.sched td[rowspan] { vertical-align: top; color: var(--muted); }

/* Draft */
.draft { gap: 14px; }
.draft h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp2); }
.draft .dtop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 20px; }
.draft .dtop > div:first-child { display: grid; gap: var(--sp1); max-width: 70ch; }
.boardwrap { overflow-x: auto; }
/* Draft board: trainers down the side, rounds across the top. Fixed columns, so long names truncate instead of widening the table. */
.board { border-collapse: collapse; width: 100%; font-size: var(--fs2); min-width: 1300px; table-layout: fixed; }
.board th, .board td { border: 1px solid var(--line); padding: 0; text-align: left; white-space: nowrap; height: 34px; }
.board thead th { height: auto; padding: 6px 8px; font-size: var(--fs1); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--sunk); }
.board thead th.cur { color: var(--fg); font-weight: 600; }
.board th.trn { width: 196px; }
.board tbody th.trn { padding: 0 8px; font-weight: 500; color: var(--fg); background: none; }
.board .whoin, .board .whoin .tface { display: flex; align-items: center; gap: 6px; min-width: 0; }
.board .whoin .tface { flex: 1; }
.board .tn { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board .seat, .board .cnt { font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); font-weight: 400; }
.board .seat { width: 1.6em; flex: none; }
.board .cnt { flex: none; }
.board .whoin img { flex: none; }
.board td.cur { background: color-mix(in srgb, var(--sunk) 45%, transparent); }
.board tr.up { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.board td.later { padding: 0 8px; font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); }
.board td.clock { padding: 0 8px; background: color-mix(in srgb, var(--accent) 10%, transparent); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); font-size: var(--fs1); }
.board td.clock .spin { display: inline-block; vertical-align: -1px; margin-right: 4px; }
.pickcell { font: inherit; display: flex; align-items: center; gap: 6px; width: 100%; height: 100%; padding: 0 6px 0 3px; border: 1px solid transparent; background: none; color: var(--fg); cursor: pointer; text-align: left; }
.pickcell:hover { background: var(--sunk); }
.pickcell img { width: 26px; height: 26px; image-rendering: pixelated; flex: none; }
.pickcell > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pickcell small { color: var(--muted); flex: none; }
.dprog { display: flex; align-items: center; gap: var(--sp3); }
.dprog .bar { width: 220px; height: 6px; border-radius: var(--r-pill); background: var(--sunk); overflow: hidden; }
.dprog .bar > span { display: block; height: 100%; background: var(--accent); }
/* While the draft leads the page: the full window width, a tighter header, and the pool as tall as the window. */
.lobby.drafting { max-width: 1880px; gap: var(--sp3); }
.lobby.drafting .pagehead { margin-bottom: 0; gap: var(--sp1); }
.lobby.drafting .pagehead h1 { font-size: 28px; }
.lobby.drafting .pool { max-height: max(480px, calc(100vh - 260px)); }
.clockrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--sp3); }
.onclock { display: grid; align-content: start; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 12px; min-width: 0; }
.onclock .think, .why .think { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs1); max-height: 220px; overflow-y: auto; }

/* Season */
.season { display: grid; gap: var(--sp4); }
.calbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); }
.calwhere { display: grid; gap: 2px; }
.calwhere b { font-family: var(--f-display); font-weight: 400; font-size: var(--fs6); }
.calctl { display: flex; flex-wrap: wrap; gap: 6px; }
.runpanel { border: 2px solid var(--fg); grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px 28px; }
.runpanel.running { border-color: var(--accent); grid-template-columns: minmax(0, 1fr); }
.runpanel.arrived { border-color: var(--good); grid-template-columns: minmax(0, 1fr); }
.runpanel.arrived .eyebrow { color: var(--good); }
.runpanel h3 { font-size: var(--fs3); }
.runpick { display: grid; gap: 14px; min-width: 0; }
.runhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.runhead > div { display: grid; gap: var(--sp1); }
.runhead .eyebrow { display: inline-flex; align-items: center; gap: var(--sp2); }
.wkchips { display: grid; gap: 6px; }
.wkchip { font: inherit; display: grid; justify-items: center; gap: 1px; padding: 6px 2px; min-height: 48px; border-radius: var(--r1); border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; min-width: 0; }
.wkchip b { font-family: var(--f-display); font-weight: 400; font-size: var(--fs2); }
.wkchip span { font-size: var(--fs0); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wkchip:disabled { cursor: not-allowed; background: var(--sunk); color: var(--muted); }
.wkchip.runs { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.wkchip.target span { color: var(--accent); font-weight: 600; }
.runwhat { display: grid; gap: 10px; align-content: start; border-left: 1px solid var(--line); padding-left: var(--sp5); min-width: 0; }
.runwhat ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp2); font-size: var(--fs3); }
.runwhat li { display: flex; gap: 10px; }
.runwhat li > span { font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); min-width: 64px; }
.runwhat li.ms { color: var(--accent); font-weight: 600; }
.runwhat li.ms > span { color: var(--accent); }
@media (max-width: 820px) { .runpanel:not(.running):not(.arrived) { grid-template-columns: minmax(0, 1fr); } .runwhat { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; } .wkchips { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; } }
.runweeks { display: flex; gap: 10px; }
.runweeks > div { display: grid; gap: var(--sp1); flex-basis: 0; min-width: 0; }
.rundays { display: flex; gap: 3px; }
.rundays i { flex: 1; height: 20px; border-radius: 3px; background: var(--sunk); }
.rundays i.match { background: color-mix(in srgb, var(--muted) 40%, var(--sunk)); }
.rundays i.done { background: var(--good); }
.rundays i.done.match { background: color-mix(in srgb, var(--good) 70%, #000); }
.rundays i.now { background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.weekstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 820px) { .weekstrip { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wday { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r1); padding: 8px 10px; display: grid; gap: 3px; align-content: start; min-width: 0; font-size: var(--fs2); }
.wday .dn { font-family: var(--f-display); font-size: var(--fs2); }
.wday.match { background: var(--sunk); }
.wday.done { opacity: .7; }
.wday.today { opacity: 1; }
.wday .fx { color: var(--muted); overflow-wrap: anywhere; }
.today { gap: 10px; }
.fixtures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--sp2); }
.fixtures:has(.livemons) { grid-template-columns: 1fr; } /* live lineups need the full width */
.fixture { display: grid; gap: var(--sp1); border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 12px; background: var(--bg); font-size: var(--fs3); }
.champion { display: grid; gap: 2px; justify-items: start; border: 2px solid var(--fg); border-radius: var(--r2); padding: 14px 16px; background: var(--surface); }
.champion b { font-family: var(--f-display); font-weight: 400; font-size: var(--fs7); }
.seasongrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--sp4); align-items: start; }
@media (max-width: 980px) { .seasongrid { grid-template-columns: minmax(0, 1fr); } }

/* Live match cards: each side's lineup with HP, status and the Pokémon that's in. */
.livestat { display: inline-grid; gap: var(--sp1); justify-items: start; width: 100%; }
.livemons { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp3); width: 100%; margin-top: 2px; }
@media (max-width: 520px) { .livemons { grid-template-columns: 1fr; } }
.lside { display: grid; gap: 3px; min-width: 0; }
.lname { font-size: var(--fs2); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.lname .muted { font-weight: 400; }
.lname .spin { display: inline-block; width: 9px; height: 9px; }
.lmon { display: grid; grid-template-columns: 32px minmax(0, 1fr) 56px 34px 64px; align-items: center; gap: 6px; font-size: var(--fs1); padding: 1px 4px; border-radius: var(--r1); border: 1px solid transparent; }
.lmon img { width: 32px; height: 32px; margin: -4px 0; image-rendering: pixelated; }
.lmon .tags { display: flex; gap: 3px; }
.lmon .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lmon .nm small { color: var(--muted); }
.lmon .hpn { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; font-size: var(--fs0); }
.lmon.out { opacity: .45; }
.lmon .tag { justify-self: start; }
.lmon:not(:has(.minibar)) { grid-template-columns: 32px minmax(0, 1fr) auto; }

/* Weekday feed */
.seasonmain { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: var(--sp4); align-items: start; }
@media (max-width: 900px) { .seasonmain { grid-template-columns: minmax(0, 1fr); } }
.callog { display: grid; gap: 14px; min-width: 0; }
.dayblock { display: grid; gap: var(--sp2); }
.dayblock h4 { margin: 0; font-size: var(--fs1); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.evcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; display: grid; gap: 5px; font-size: var(--fs3); min-width: 0; }
.evcard.quiet { padding: 6px 12px; font-size: var(--fs2); color: var(--muted); }
.evhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.evhead .who, .tname { font-weight: 600; }
.evhead .who { background: none; padding: 0; border-radius: 0; font-size: inherit; }
.evhead .kind { color: var(--muted); }
.chipst { margin-left: auto; }
.evcard ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: var(--fs2); }
.calside { display: grid; gap: 10px; }
.panel.side { padding: 12px 14px; gap: var(--sp2); }
.panel.side h3 { font-size: var(--fs3); }
.budget { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp1); font-size: var(--fs2); }
.budget li { display: flex; justify-content: space-between; align-items: center; }
.pips { display: flex; gap: var(--sp1); }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--fg); }
.pips i.on { background: var(--fg); }
.offerline { font-size: var(--fs2); border-top: 1px solid var(--line); padding-top: 6px; }
.offerline:first-child { border-top: 0; padding-top: 0; }
.deciding { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
/* One row, always: on narrow screens it scrolls sideways instead of wrapping. */
@media (max-width: 900px) { .deciding { grid-template-columns: repeat(4, minmax(240px, 1fr)); overflow-x: auto; padding-bottom: 4px; } }
/* "+N more deciding": its line is always there, so the page doesn't move when it fills or empties. */
.decmore { min-height: 1.5em; margin: 6px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busy { display: grid; gap: 6px; align-content: start; }
.busy .waiting { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busy pre { height: 160px; min-height: 3.2em; margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); font-style: italic; max-height: 160px; overflow-y: auto; }
.weeksum { border: 2px solid var(--fg); }
.sumgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px 18px; }
.sumgrid > div { display: grid; gap: var(--sp1); font-size: var(--fs2); align-content: start; min-width: 0; }
.sumgrid ul { margin: 0; padding-left: 16px; display: grid; gap: 2px; }
.expbar { height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; margin: 3px 0 1px; }
.expbar i { display: block; height: 100%; background: var(--p1); }
.roster .origin { font-size: var(--fs1); color: var(--muted); }
.usage { display: flex; align-items: center; gap: var(--sp2); font-size: var(--fs1); margin: 2px 0; }
.usage b { font-weight: 600; }
.ubar { width: 54px; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; flex: none; }
.ubar i { display: block; height: 100%; background: var(--good); }

/* Notebook */
pre.notebook { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs2); line-height: 1.6; background: var(--sunk); border-radius: var(--r1); padding: 12px; min-height: 80px; }
.notebook .add, .evcard .add { color: var(--good); }
.notebook .del, .evcard .del { color: var(--bad); text-decoration: line-through; }
#nb-edit { font-family: var(--f-mono); font-size: var(--fs2); min-height: 220px; padding: 10px 12px; }

/* Draft board + available Pokémon */
.draftgrid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp4); align-items: start; }
@media (max-width: 1050px) { .draftgrid { grid-template-columns: minmax(0, 1fr); } }
.draftmain { display: grid; gap: 14px; min-width: 0; }
.pool { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg); max-height: 760px; min-width: 0; }
@media (max-width: 1050px) { .pool, .lobby.drafting .pool { max-height: 480px; } }
.poolhead { display: grid; gap: var(--sp2); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.poolhead h3 { font-size: var(--fs3); }
.poolctl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.poolctl input, .poolctl select { font-size: var(--fs2); background: var(--surface); }
.poollist { list-style: none; margin: 0; padding: 0 12px; overflow-y: auto; flex: 1; min-height: 0; }
.poollist li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp2); padding: 8px 0; border-bottom: 1px solid var(--line); }
.poollist li:last-child { border-bottom: 0; }
.poollist li.emptyli { display: block; padding: 12px 0; }
.poollist img { width: 40px; height: 40px; image-rendering: pixelated; object-fit: contain; }
.pinfo { min-width: 0; display: grid; gap: 2px; }
.pinfo .top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: var(--fs2); }
.pinfo .dex { font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); }
.pinfo .lv { font-family: var(--f-display); font-size: var(--fs0); margin-left: auto; }
.pinfo .types { margin: 1px 0; }
.pmoves { font-size: var(--fs1); color: var(--muted); }
.pevo { font-size: var(--fs1); color: var(--muted); font-style: italic; }
.pstats { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: var(--fs0); font-family: var(--f-mono); color: var(--muted); }
.pstats b { color: var(--fg); font-weight: 500; }

/* Trainers */
.trainers { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .trainers { grid-template-columns: minmax(0, 1fr); } }
.tlist { display: grid; gap: var(--sp2); }
@media (max-width: 860px) { .tlist { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tcard { font: inherit; text-align: left; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px; cursor: pointer; display: grid; gap: 6px; }
.tcard .nm { font-family: var(--f-display); font-size: var(--fs5); display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.tcard .nm small { font-family: var(--f-body); font-size: var(--fs1); color: var(--muted); font-variant-numeric: tabular-nums; }
.tcard .persona { font-size: var(--fs2); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard .minis { display: flex; flex-wrap: wrap; gap: 0; min-height: 20px; }
.tcard .minis img { width: 21px; height: 21px; image-rendering: pixelated; }
.tcard .custom { font-size: var(--fs0); font-weight: 600; color: var(--good); }
.tcard .custom.player { color: var(--player); }
.detail { display: grid; gap: 18px; min-width: 0; }
.dname { font-family: var(--f-display); font-size: var(--fs7); }
.dname:has(.tsprite) { display: flex; align-items: flex-end; gap: var(--sp3); }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--fs2); color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--fg); font-weight: 600; }
.detail textarea { min-height: 120px; padding: 10px 12px; }
.backstory-text { white-space: pre-wrap; margin: 6px 0 0; }
#backstory-edit { margin-top: 10px; }
#backstory-edit textarea { min-height: 80px; }
.chars { margin-left: auto; font-size: var(--fs1); color: var(--muted); font-variant-numeric: tabular-nums; }
.detail details[open] > summary { margin-bottom: var(--sp2); }
pre.prompt { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs1); line-height: 1.55; background: var(--sunk); border-radius: var(--r1); padding: 12px; max-height: 360px; overflow-y: auto; }
pre.prompt mark { background: var(--mark); color: var(--fg); border-radius: 2px; }
.roster { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 700px) { .roster { grid-template-columns: minmax(0, 1fr); } }
.roster li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.roster li.emptyli { display: block; border: 0; }
.roster img { width: 52px; height: 52px; image-rendering: pixelated; object-fit: contain; background: var(--gb3); border-radius: var(--r1); }
.roster .top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.roster .dex { font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); }
.roster .lv { font-family: var(--f-display); font-size: var(--fs1); margin-left: auto; }
.roster .moves { font-size: var(--fs1); color: var(--muted); }
.rsort { font-size: var(--fs2); padding: 3px 6px; min-height: 28px; }

/* ---------- Battle page ---------- */
.matchbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp2) var(--sp4); margin-bottom: 14px; }
.matchbar .vs { font-family: var(--f-display); font-size: var(--fs6); }
.matchbar .right { display: flex; gap: var(--sp2); flex-wrap: wrap; align-items: center; }
.back { font-size: var(--fs2); color: var(--muted); text-decoration: none; }
.back:hover { color: var(--fg); }

.console { display: grid; gap: 14px; grid-template-columns: minmax(0,1fr) minmax(0,1.3fr) minmax(0,1fr);
  grid-template-areas: "p1 field p2" "tl tl tl"; align-items: start; }
@media (max-width: 1100px) { .console { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-areas: "field field" "tl tl" "p1 p2"; } }
@media (max-width: 720px) { .console { grid-template-columns: minmax(0,1fr); grid-template-areas: "field" "tl" "p1" "p2"; } }
.field { grid-area: field; display: grid; gap: 10px; min-width: 0; }
.agent.p1 { grid-area: p1; } .agent.p2 { grid-area: p2; }
.timeline { grid-area: tl; }

.logbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; height: 220px; overflow-y: auto; font-size: var(--fs2); }
.logbox .t { font-weight: 600; font-size: var(--fs0); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.logbox .turn + .turn { border-top: 1px solid var(--line); margin-top: var(--sp2); padding-top: var(--sp2); }
.logbox .l { padding: 1px 8px; border-left: 3px solid transparent; border-radius: 0 3px 3px 0; }
.logbox .l + .l { margin-top: 1px; }
.logbox .l.p1 { border-left-color: var(--p1); background: color-mix(in srgb, var(--p1) 12%, transparent); }
.logbox .l.p2 { border-left-color: var(--p2); background: color-mix(in srgb, var(--p2) 12%, transparent); }
.logbox .l.sub { color: var(--muted); font-family: var(--f-mono); font-size: var(--fs1); }
.logbox .old { opacity: .55; }
.logbox .cur .t { color: var(--accent); }
.logbox .l.bmark { border-left-color: var(--rest); color: var(--rest); font-style: italic; font-size: var(--fs1); margin-top: 3px; }

.agent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); display: grid; min-width: 0; }
.agent .hd { padding: 12px 14px 10px; display: grid; gap: var(--sp1); border-bottom: 1px solid var(--line); }
.agent .who { display: flex; align-items: center; gap: var(--sp2); font-weight: 600; background: none; padding: 0; border-radius: 0; font-size: inherit; }
.agent.p1 .who .sw { background: var(--p1); } .agent.p2 .who .sw { background: var(--p2); }
.sw { width: 10px; height: 10px; border-radius: 2px; }
/* The trainer's strategy for the matchup on screen, between its name and the tabs. */
.strat { margin: 12px 12px 4px; padding: 10px 12px; border-radius: var(--r1); border: 1px solid var(--line); display: grid; gap: 6px; align-content: start; min-height: 120px; }
.agent.p1 .strat { background: color-mix(in srgb, var(--p1) 8%, var(--surface)); border-color: color-mix(in srgb, var(--p1) 25%, var(--line)); }
.agent.p2 .strat { background: color-mix(in srgb, var(--p2) 8%, var(--surface)); border-color: color-mix(in srgb, var(--p2) 25%, var(--line)); }
.agent.p1 .strat .lbl { color: var(--p1); } .agent.p2 .strat .lbl { color: var(--p2); }
.strathd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.strathd .small { margin-left: auto; }
.strat .chip { background: var(--surface); }
.stext { font-size: var(--fs2); line-height: 1.5; }
.stext.old { color: var(--muted); text-decoration: line-through; opacity: .75; font-size: var(--fs1); }
.strat pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs0); line-height: 1.5; max-height: 140px; overflow-y: auto; }
.agent .segment { margin: 8px 12px 0; align-self: start; justify-self: start; }
.tabbody { padding: 12px 14px 14px; min-width: 0; min-height: 240px; }
.tabbody pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: var(--fs1); line-height: 1.55; max-height: 360px; overflow-y: auto; }
.think { color: var(--muted); font-style: italic; }
/* Another player's or the bookmaker's thinking: you see it happening, not what it says. */
.think.redacted, .redacted-text { color: var(--line); font-style: normal; letter-spacing: -.5px; user-select: none; }
.privnote { margin: 4px 0 0; }
.out { display: grid; gap: 6px; }
.out + .out { margin-top: 12px; }
.json { background: var(--sunk); border-radius: var(--r1); padding: 8px 10px; font-family: var(--f-mono); font-size: var(--fs1); word-break: break-word; }
.json.rej { text-decoration: line-through; opacity: .6; }
.verdict { font-size: var(--fs1); display: flex; gap: 6px; align-items: baseline; }

/* Lineup (league battles) */
.lineup { display: grid; gap: 6px; }
.team + .lineup { padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); }
.lineup pre { margin-top: 6px; }

/* Team tab */
.team { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp1); }
.team li { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 10px; align-items: start; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.team li:last-child { border-bottom: 0; }
.team li.fnt { opacity: .5; }
.team img { width: 44px; height: 44px; image-rendering: pixelated; object-fit: contain; }
.team .info { display: grid; gap: var(--sp1); min-width: 0; }
.team .top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: var(--fs2); }
.team .top .muted { font-size: var(--fs1); }
.hprow { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--sp2); align-items: center; font-size: var(--fs1); }
.minibar { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.minibar i { display: block; height: 100%; background: var(--good); }
.minibar i.mid { background: var(--warn); } .minibar i.low { background: var(--bad); }
.team .moves { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: var(--fs1); }
.team .moves .empty { text-decoration: line-through; opacity: .6; padding: 0; border: 0; color: inherit; }
.team .chips { margin-top: 0; min-height: 0; }

.timeline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px 14px; display: grid; gap: 10px; }
.tlrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.btns { display: flex; gap: var(--sp1); }
.btns .play { min-width: 64px; }
.speed { min-height: 32px; }
.phases { display: flex; gap: var(--sp1); flex-wrap: wrap; }
.where { font-family: var(--f-display); font-size: var(--fs3); margin-left: auto; }
/* The scrubber over the HP worm: both sides' HP across the battle, faints where a line reaches zero. */
.track { position: relative; height: 34px; }
.track.worm { height: 86px; }
.track input { position: absolute; inset: 8px 0 auto 0; width: 100%; margin: 0; accent-color: var(--accent); z-index: 2; }
.track.worm input { top: auto; bottom: 14px; }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 100%; pointer-events: none; }
.ticks span { position: absolute; top: 24px; transform: translateX(-50%); font-size: var(--fs0); color: var(--muted); font-family: var(--f-mono); }
.track.worm .ticks span { top: auto; bottom: -2px; }
.ticks b { position: absolute; top: 0; width: 7px; height: 7px; transform: translateX(-50%) rotate(45deg); background: var(--bad); }
.track.worm .ticks b { top: auto; bottom: 36px; }
.hpworm { position: absolute; left: 0; right: 0; top: 0; height: 52px; display: block; width: 100%; overflow: visible; pointer-events: none; }
.hpworm .hpl { fill: none; stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hpworm .hpl.p1 { stroke: var(--p1); } .hpworm .hpl.p2 { stroke: var(--p2); }
.hpworm .hpa.p1 { fill: var(--p1); opacity: .14; } .hpworm .hpa.p2 { fill: var(--p2); opacity: .14; }
.hpworm .base { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.hpworm .head { stroke: var(--fg); stroke-width: 1; vector-effect: non-scaling-stroke; }
.legend { font-size: var(--fs1); color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 7px; height: 7px; background: var(--bad); transform: rotate(45deg); margin-right: 6px; }

/* Press tab */
.pressgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .pressgrid { grid-template-columns: minmax(0, 1fr); } }
.issues, .journos { display: grid; gap: 14px; min-width: 0; }
.masthead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 2px solid var(--fg); padding-bottom: var(--sp2); }
.mast { font-family: var(--f-display); font-size: var(--fs6); }
.piece { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); min-width: 0; }
.masthead + .piece { border-top: 0; padding-top: 0; }
.piece .byline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.piece .headline { margin: 0; font-size: var(--fs5); line-height: 1.3; }
.piece .body { margin: 0; line-height: 1.6; white-space: pre-wrap; }
.piece .ranking .got { color: var(--fg); font-weight: 600; }
.qa { display: grid; gap: 3px; font-size: var(--fs2); padding: 6px 0; border-bottom: 1px dashed var(--line); }
.qa:last-child { border-bottom: 0; }
.qa .spin { display: inline-block; vertical-align: -1px; width: 9px; height: 9px; }
.qline { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--sp2); align-items: start; }
.journo { gap: var(--sp2); }
.journo .dname { font-family: var(--f-display); font-size: var(--fs5); }
.journo textarea { min-height: 90px; font-size: var(--fs2); padding: 8px; }
.journo pre.notebook { margin-top: 6px; min-height: 0; }
.jhead { display: flex; gap: var(--sp3); align-items: center; }
.jpersona { white-space: pre-wrap; margin: 6px 0 0; }
.pressbar { display: grid; gap: 10px; margin: 12px 0; }
.pbhead { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.pressbar .deciding { margin: 0; }

/* Thinking tokens used against the cap, above each reasoning box (public/lib/think.js): a blue strip that fills as thinking uses its cap. */
.tmeter { height: 4px; margin: 2px 0 6px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.tmeter i { display: block; height: 100%; background: var(--p1); border-radius: 2px; transition: width .6s linear; }
.tmeter + pre, .tmeter + .think { margin-top: 0 !important; }

/* ---------- Trainer and journalist sprites (public/lib/sprites.js) ---------- */
.tsprite { image-rendering: pixelated; image-rendering: crisp-edges; flex: none; display: block; }
.tface { display: inline-flex; align-items: center; gap: 6px; }
.tcard .nm .tface { gap: var(--sp2); }
/* The look editor (public/lib/look-editor.js): the sprite and where it shows on one side, the parts as picture tiles on the other. They wrap to one column when there's no room. */
.lookedit { display: flex; flex-wrap: wrap; gap: var(--sp4); align-items: stretch; margin-top: 10px; min-width: 0; font-style: normal; color: var(--fg); }
.lk-side { flex: 1 1 260px; display: flex; flex-direction: column; gap: var(--sp3); min-width: 0; }
.lk-main { flex: 999 1 420px; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); overflow: hidden; }
.lk-stage { position: relative; display: flex; justify-content: center; align-items: flex-end; height: 240px; padding-bottom: 30px; box-sizing: border-box; border-radius: var(--r2); overflow: hidden; background: linear-gradient(to bottom, var(--sky) 0 72%, var(--floor) 72%); border: 1px solid var(--line); }
.lk-stage::before { content: ""; position: absolute; left: 50%; bottom: 24px; width: 110px; height: 14px; margin-left: -55px; border-radius: 50%; background: rgb(20 30 20 / .16); }
.lk-stage .lk-hero { position: relative; }
.lk-where { display: grid; gap: var(--sp2); }
.lk-where > div { display: flex; align-items: center; justify-content: space-between; gap: var(--sp2); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r2); min-width: 0; }
.lk-where > div > span { min-width: 0; }
.lk-where small { flex: none; color: var(--muted); font-size: var(--fs1); }
.lk-chip, .lk-byline { display: flex; align-items: center; gap: 6px; max-width: 100%; font-size: var(--fs2); }
.lk-chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface); }
.lk-chip b { font-weight: 500; letter-spacing: .04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-byline b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-ring { flex: none; border-radius: 50%; overflow: hidden; background: var(--sky); padding: 3px 3px 0; }
.lk-tools { display: flex; gap: var(--sp2); margin-top: auto; }
.lk-tools .btn { flex: 1; min-height: 40px; padding-inline: 8px; font-size: var(--fs2); }
.lk-tabs { contain: inline-size; display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.lk-tabs button { flex: none; font: inherit; font-size: var(--fs3); padding: 8px 14px; border: 0; background: none; color: var(--muted); cursor: pointer; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.lk-tabs button:hover { color: var(--fg); }
.lk-tabs button[aria-selected="true"] { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }
.lk-panel { display: grid; gap: var(--sp5); align-content: start; padding: var(--sp4); min-height: 260px; }
.lk-group { display: grid; gap: var(--sp2); }
.lk-group h4 { margin: 0; font-size: var(--fs1); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--sp2); }
.lk-tile { position: relative; display: grid; gap: 6px; justify-items: center; padding: 6px 6px 8px; font: inherit; font-size: var(--fs2); font-weight: 500; color: var(--fg); background: var(--bg); border: 2px solid var(--line); border-radius: var(--r2); cursor: pointer; transition: border-color var(--t-fast); }
.lk-tile:hover { border-color: var(--muted); }
.lk-tile[aria-pressed="true"] { border-color: var(--accent); }
.lk-tile[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.lk-well { display: flex; justify-content: center; align-items: flex-end; width: 100%; height: 68px; border-radius: var(--r1); background: var(--sunk); overflow: hidden; }
.lk-tile[aria-pressed="true"] .lk-well { background: color-mix(in srgb, var(--accent) 10%, var(--sunk)); }
.lk-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp2); }
.lk-swatch { width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.lk-swatch.wide { width: 42px; border-radius: var(--r-pill); }
.lk-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--fg); }
.lk-custom { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 3px; border: 1px dashed var(--line); border-radius: var(--r-pill); font-size: var(--fs2); color: var(--muted); cursor: pointer; }
.lk-custom input { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.lk-pal { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 8px; font: inherit; font-size: var(--fs2); color: var(--fg); background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r-pill); cursor: pointer; }
.lk-pal[aria-pressed="true"] { border-color: var(--fg); }
.lk-pal .dots { display: flex; }
.lk-pal .dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--surface); }
.lk-pal .dots i + i { margin-left: -5px; }
.lk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp3); padding: 10px var(--sp4); border-top: 1px solid var(--line); background: var(--bg); }
.lk-bar .status { margin-left: auto; }
.lk-link { font: inherit; font-size: var(--fs2); padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.lk-link:disabled { cursor: default; opacity: .5; }

/* Match clocks (public/lib/clock.js): elapsed while live, total once over. */
.clock { font-size: var(--fs1); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#clock:empty { display: none; }

/* Season history: every finished week on the Season tab, newest first. */
.history { display: grid; gap: var(--sp3); margin-top: var(--sp2); }
.hist { display: grid; gap: 14px; }
.hweek { border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); overflow: hidden; }
.hweek > header { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.hweek > header h3 { font-family: var(--f-display); font-weight: 400; font-size: var(--fs5); }
.hweek .lead { font-size: var(--fs2); color: var(--muted); }
.hweek .lead b { color: var(--fg); }
.wdays { border-bottom: 1px solid var(--line); }
.wdays > summary { padding: 10px 16px; font-size: var(--fs3); color: var(--fg); }
.wdays .counts { display: flex; gap: 6px; flex-wrap: wrap; }
.wkend { padding: 14px 16px 16px; }
.wkend h4 { font-size: var(--fs1); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.hmatch { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r2); background: var(--bg); border: 1px solid var(--line); }
.hmatch + .hmatch { margin-top: 6px; }
.hside { display: grid; gap: var(--sp1); min-width: 0; }
.hside .nm { font-weight: 600; font-size: var(--fs3); display: flex; gap: 6px; align-items: center; }
.hside.r .nm { justify-content: flex-end; }
.hside.lost .nm { color: var(--muted); }
.hside .tface { display: inline-flex; align-items: center; gap: var(--sp1); }
.hmons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp1); }
.hmon { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px; column-gap: 3px; font-size: var(--fs1); min-width: 0; }
.hmon img { width: 22px; height: 22px; image-rendering: pixelated; grid-row: span 2; align-self: center; }
.hmon span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hmon i { display: block; height: 4px; border-radius: 2px; background: var(--sunk); overflow: hidden; grid-column: 2; }
.hmon i b { display: block; height: 100%; background: var(--good); }
.hmon i b.mid { background: var(--warn); } .hmon i b.low { background: var(--bad); }
.hmon.out span { color: var(--muted); text-decoration: line-through; }
.hmid { display: grid; gap: 2px; justify-items: center; font-size: var(--fs1); color: var(--muted); text-align: center; }
.hmid .ko { font-family: var(--f-mono); font-size: var(--fs-body); color: var(--fg); }
.hmid a { color: var(--accent); }
.hmid .clock { font-size: var(--fs1); }
.hstand { width: 100%; border-collapse: collapse; font-size: var(--fs2); }
.hstand th { font-size: var(--fs0); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.hstand td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.hstand td.n, .hstand th.n { text-align: right; font-variant-numeric: tabular-nums; }
.mv { font-size: var(--fs1); font-weight: 600; white-space: nowrap; }
.mv.up { color: var(--good); } .mv.down { color: var(--bad); } .mv.same { color: var(--muted); font-weight: 400; }
.delta { color: var(--muted); font-size: var(--fs1); }
.wkgrid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--sp4); align-items: start; }
@media (max-width: 820px) { .wkgrid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .hmatch { grid-template-columns: 1fr; }
  .hside.r .nm { justify-content: flex-start; }
  .hmid { justify-items: start; text-align: left; grid-auto-flow: column; gap: 10px; }
}
.wdlist { display: grid; gap: 6px; padding: 0 16px 12px; }
.wdrow { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: var(--sp2); align-items: start; }
.wdrow .d { color: var(--muted); font-size: var(--fs1); font-family: var(--f-mono); padding-top: 10px; }
.wkend .gap { height: 12px; }

/* ---------- Leagues page ---------- */
.leagues { display: grid; gap: 18px; }
table.leaguelist tbody tr { cursor: default; }
table.leaguelist tr.sel td { background: var(--mark); }
table.leaguelist td.acts { text-align: right; }

/* Sign-ups: the Create your trainer form, under the header */
.joincard { display: grid; gap: var(--sp3); padding: 16px 18px; border: 1px solid var(--player); border-radius: var(--r2); background: color-mix(in srgb, var(--player) 6%, var(--surface)); }
.joinform { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.joinfields { display: grid; gap: 10px; }
.joinfields label { display: grid; gap: var(--sp1); }
.joinfields input { width: 100%; }
.joinfields textarea, textarea.persona { min-height: 170px; padding: 7px 10px; }
.joinfields textarea.backstory, textarea.backstory { min-height: 90px; padding: 7px 10px; }
.joinlook { display: grid; gap: 6px; }

/* My trainer */
#panel-me { display: grid; gap: 14px; }
.mehead { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.mehead > img { image-rendering: pixelated; background: var(--sunk); border-radius: var(--r2); padding: 6px; }
.mewho { display: grid; gap: var(--sp1); }
.mewho h2 { font-family: var(--f-display); font-weight: 400; font-size: var(--fs6); margin: 0; }
.mewho .stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: var(--fs3); }
.megrid, .admingrid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.meint { margin: 0; padding-left: 18px; display: grid; gap: var(--sp1); font-size: var(--fs3); }

/* Admin */
#panel-admin { display: grid; gap: 14px; }
.admin-seats, .seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.seats li { display: flex; gap: 10px; align-items: center; }
.seats li img { image-rendering: pixelated; }
.seats .grow { flex: 1; min-width: 0; }
table.codes tr.fresh td { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
@media (max-width: 760px) { .joinform, .megrid, .admingrid { grid-template-columns: 1fr; } }

/* ---------- Battle stage (battle.html): two equal halves, trainer at the outer edge, Pokémon facing the middle ---------- */
.arena { --ms: 2; --shake: 0px;
  position: relative; display: grid; margin-bottom: 14px; isolation: isolate;
  border: 1px solid var(--line); border-radius: var(--r3); overflow: hidden; background: var(--sky); min-height: 330px; }
.arena .bg { position: absolute; inset: 0; pointer-events: none; }
.arena .bg.far { background:
  radial-gradient(60% 90px at 12% 62%, var(--hill-far) 98%, transparent 100%),
  radial-gradient(70% 120px at 48% 64%, var(--hill-far) 98%, transparent 100%),
  radial-gradient(55% 80px at 86% 60%, var(--hill-far) 98%, transparent 100%);
  --amp: calc(var(--shake) * .3); }
.arena .bg.mid { background:
  radial-gradient(40% 60px at 28% 72%, var(--hill-mid) 98%, transparent 100%),
  radial-gradient(44% 70px at 72% 73%, var(--hill-mid) 98%, transparent 100%);
  --amp: calc(var(--shake) * .6); }
.arena .bg.floor { inset: auto -10% 0; top: 60%; background: linear-gradient(var(--floor), var(--floor-dark)); border-radius: 50% 50% 0 0 / 40px 40px 0 0; --amp: var(--shake); }
.arena .stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 330px; --amp: var(--shake); }
.arena::after { content: ""; position: absolute; left: 50%; top: 46px; bottom: 0; border-left: 2px dashed color-mix(in srgb, var(--muted) 35%, transparent); pointer-events: none; }
.ahalf { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: var(--sp2); padding: 18px 22px 70px; min-width: 0; }
.ahalf.p1 { background: linear-gradient(to right, color-mix(in srgb, var(--p1) 12%, transparent), transparent 70%); }
.ahalf.p2 { background: linear-gradient(to left, color-mix(in srgb, var(--p2) 12%, transparent), transparent 70%); grid-template-columns: minmax(0, 1fr) auto; }
.ahalf.p2 .atrainer { order: 2; }
.atrainer { position: relative; z-index: 1; display: grid; justify-items: center; gap: 5px; }
.aspot { position: relative; min-height: 132px; display: grid; align-items: end; }
.aspot::before { content: ""; position: absolute; left: 50%; bottom: -6px; width: 84px; height: 16px; translate: -50% 0; border-radius: 50%; background: rgb(0 0 0 / .16); }
.aspot img { position: relative; transition: filter var(--t-slow), translate var(--t-slow); }
.atn { font-family: var(--f-display); font-size: var(--fs-body); }
.ahalf.p1 .atn { color: var(--p1); } .ahalf.p2 .atn { color: var(--p2); }
.atrainer.lost .aspot img { filter: grayscale(.85) opacity(.6); translate: 0 4px; }
.atrainer.won .aspot img { animation: hop calc(900ms / var(--rate)) var(--ease-out); }
@keyframes hop { 15% { translate: 0 -18px; } 30% { translate: 0 0; } 45% { translate: 0 -10px; } 60% { translate: 0 0; } }
.atrainer.won::before { content: "Winner"; position: absolute; top: -12px; z-index: 1; font-family: var(--f-display); font-size: var(--fs0); background: var(--mark); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r1); padding: 1px 8px; animation: pop calc(400ms / var(--rate)) var(--ease-out); }
.abench { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 140px; }
/* Each bench square shows the Pokémon's visible pixels, cropped to fill it: the sprite's box (public/lib/sprite-bounds.js)
   comes in as --bx --by --bw --bh (canvas pixels) and --size (the canvas width), and the square scales it to --cell. */
.abench span { --cell: 28px; width: calc(var(--cell) + 2px); height: calc(var(--cell) + 2px); border-radius: var(--r1); background: var(--surface); border: 1px solid var(--line); overflow: hidden; position: relative; transition: border-color var(--t), box-shadow var(--t); }
.abench img { --s: min(calc(var(--cell) / var(--bw, 48)), calc(var(--cell) / var(--bh, 48))); position: absolute; max-width: none; image-rendering: pixelated;
  width: calc(var(--size, 96) * var(--s)); height: calc(var(--size, 96) * var(--s));
  left: calc((var(--cell) - var(--bw, 48) * var(--s)) / 2 - var(--bx, 24) * var(--s)); top: calc((var(--cell) - var(--bh, 48) * var(--s)) / 2 - var(--by, 24) * var(--s)); }
.abench span.on { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.ahalf.p1 .abench span.on { color: var(--p1); } .ahalf.p2 .abench span.on { color: var(--p2); }
.abench span.out img { filter: grayscale(1) opacity(.35); }
.abench span.out::after { content: ""; position: absolute; inset: 50% 3px auto; border-top: 2px solid var(--bad); rotate: -35deg; animation: stamp calc(300ms / var(--rate)) var(--ease-out); }
@keyframes stamp { from { scale: 2.5; opacity: 0; } }
.abench span.unk { font-family: var(--f-display); font-size: var(--fs1); color: var(--muted); display: grid; place-items: center; }
.athinking { font-size: var(--fs1); display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); white-space: nowrap; animation: slideIn var(--t) var(--ease-out); }
.athinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.afield { display: grid; grid-template-rows: auto 1fr; justify-items: center; gap: var(--sp1); align-self: stretch; min-width: 0; position: relative; }
.arena.pre .afield { visibility: hidden; }
.aplate { position: relative; z-index: 2; width: min(100%, 250px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 10px; display: grid; gap: var(--sp1); transition: opacity var(--t-slow), translate var(--t-slow), filter var(--t-slow); }
.aplate.off { opacity: 0; translate: 0 -10px; }
.aplate.dim { filter: grayscale(1); opacity: .55; }
.arow { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp2); }
.amn { font-family: var(--f-display); font-size: var(--fs3); min-width: 0; overflow-wrap: anywhere; }
.alv, .atypes { font-size: var(--fs1); color: var(--muted); font-variant-numeric: tabular-nums; }
.atypes { font-size: var(--fs0); }
.ahp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp2); align-items: center; font-size: var(--fs1); font-variant-numeric: tabular-nums; font-family: var(--f-mono); }
/* The HP bar: the real bar moves at once; the ghost stays where the HP was and catches up after a beat, so a big hit reads as one. */
.abar { position: relative; height: 8px; border-radius: var(--r1); background: var(--sunk); overflow: hidden; }
.abar i { position: absolute; left: 0; top: 0; bottom: 0; display: block; border-radius: var(--r1); }
.abar i.ghost { background: color-mix(in srgb, var(--bad) 55%, var(--surface)); transition: width calc(560ms / var(--rate)) var(--ease) calc(380ms / var(--rate)); }
.abar i.real { background: var(--good); transition: width calc(260ms / var(--rate)) var(--ease), background-color calc(300ms / var(--rate)); }
.abar i.real.mid { background: var(--warn); } .abar i.real.low { background: var(--bad); }
.abar.crit::after { content: ""; position: absolute; inset: 0; background: #fff; animation: barflash calc(220ms / var(--rate)) steps(2) 1; }
@keyframes barflash { 50% { opacity: 0; } }
.asub { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 16px; }
.astages { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.astatus, .astage { animation: pop calc(280ms / var(--rate)) var(--ease-out); }
.astatus.psn { background: #a040a0; color: #fff; } .astatus.tox { background: #7a2a8a; color: #fff; } .astatus.brn { background: #f08030; color: #fff; } .astatus.slp { background: #7a7a9a; color: #fff; } .astatus.par { background: #e0c020; color: #000; } .astatus.frz { background: #7ac8e8; color: #000; }
.astage { font-size: var(--fs0); font-weight: 600; padding: 0 5px; border-radius: 3px; background: var(--sunk); font-family: var(--f-mono); }
.astage.up { background: color-mix(in srgb, var(--good) 22%, var(--surface)); color: var(--good); }
.astage.down { background: color-mix(in srgb, var(--bad) 20%, var(--surface)); color: var(--bad); }
@keyframes pop { from { scale: .6; opacity: 0; } 60% { scale: 1.12; } }
.amon { position: relative; align-self: end; display: grid; justify-items: center; z-index: 1; }
.amon .ashadow { position: absolute; left: 50%; bottom: -8px; width: 130px; height: 22px; translate: -50% 0; border-radius: 50%; background: rgb(0 0 0 / .1); transition: scale var(--t-slow), opacity var(--t-slow); }
.aspr { position: relative; transform-origin: 50% 100%; }
.aspr.idle { animation: breathe calc(2600ms / var(--rate)) ease-in-out infinite; }
.ahalf.p2 .aspr.idle { animation-delay: calc(-1300ms / var(--rate)); }
@keyframes breathe { 50% { scale: 1.015 .985; } }
.aflip { position: relative; width: calc(96px * var(--ms)); height: calc(96px * var(--ms)); margin-bottom: calc(-1px * var(--drop, 0) * var(--ms)); }
.ahalf.p1 .aflip { scale: -1 1; } /* Gen 1 front sprites face left: flip p1's to face p2 */
.aflip img, .aflip canvas, .aflip .atint { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; image-rendering: pixelated; }
.aflip img { transition: opacity var(--t-slow); }
/* A tint through a mask of the sprite: the type-colour flash on a hit, white on a reveal, red on a withdraw, blue while frozen. */
.aflip .atint { background: var(--c, #fff); -webkit-mask: var(--m) center / 100% 100% no-repeat; mask: var(--m) center / 100% 100% no-repeat; opacity: 0; pointer-events: none; }
.aflip .atint.hit { animation: tintHit calc(260ms / var(--rate)) steps(2) 1; }
@keyframes tintHit { 0%, 50% { opacity: .85; } 51%, 100% { opacity: 0; } }
.aflip .atint.steady { opacity: .4; transition: opacity var(--t-slow); }
.aflip .atint.reveal { animation: tintReveal calc(420ms / var(--rate)) var(--ease-out) forwards; }
@keyframes tintReveal { from { opacity: 1; } 70% { opacity: 1; } to { opacity: 0; } }
.aflip .atint.beam { animation: tintBeam calc(380ms / var(--rate)) var(--ease-in) forwards; }
@keyframes tintBeam { from { opacity: 0; } 30% { opacity: .9; } to { opacity: .9; } }
.aflip canvas { display: none; }
.amon.gone .aflip img { visibility: hidden; }
.amon.fnt .aflip img { opacity: 0; }
.amon.fnt .ashadow { opacity: 0; }
/* Motion on the Pokémon: one lunge keyframe reads its direction; knockback reads its distance. */
.ahalf.p1 .amon { --d: 1; } .ahalf.p2 .amon { --d: -1; }
.amon.lunge, .amon.fx-lunge { animation: lunge calc(440ms / var(--rate)) var(--ease); }
@keyframes lunge { 0% { translate: 0 0; } 18% { translate: calc(var(--d) * -10px) 0; } 48% { translate: calc(var(--d) * 36px) 0; } 60% { translate: calc(var(--d) * 36px) 0; } 100% { translate: 0 0; } }
.amon.kb { animation: kb calc(420ms / var(--rate)) var(--ease-out); }
@keyframes kb { 30% { translate: var(--kx) 0; } 62% { translate: calc(var(--kx) * -.18) 0; } 100% { translate: 0 0; } }
.amon.hit .aflip img, .amon img.fx-blink { animation: blink calc(500ms / var(--rate)) steps(2) 1; }
@keyframes blink { 0%, 50% { opacity: .1; } 100% { opacity: 1; } }
.amon.drop .aspr { animation: drop calc(520ms / var(--rate)) var(--ease-in) forwards; }
@keyframes drop { to { translate: 0 22px; } }
.aspr.in { animation: reveal calc(420ms / var(--rate)) var(--ease-out); }
@keyframes reveal { from { scale: .12; translate: 0 10px; } 70% { scale: 1.06 .94; } }
.aspr.out { animation: suck calc(380ms / var(--rate)) var(--ease-in) forwards; }
@keyframes suck { to { scale: .1 .3; translate: 0 6px; opacity: 0; } }
.amon.enter .aspr { animation: reveal calc(420ms / var(--rate)) var(--ease-out); }
.amon img.fx-wobble { animation: fxWobble calc(800ms / var(--rate)) ease-in-out; } @keyframes fxWobble { 25% { rotate: 8deg; } 50% { rotate: -8deg; } 75% { rotate: 5deg; } }
.amon img.fx-squash { animation: fxSquash calc(500ms / var(--rate)) ease; } @keyframes fxSquash { 40% { scale: 1.1 .8; } }
.amon img.fx-vanish { opacity: 0; }
/* Floating numbers, callouts and status particles live in each Pokémon's effect layer. */
.afx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.dmg { position: absolute; left: 50%; top: 10%; translate: -50% 0; font-family: var(--f-display); font-size: 20px; color: #fff; -webkit-text-stroke: 1px #000; paint-order: stroke fill; text-shadow: 0 2px 0 rgb(0 0 0 / .5); animation: floatUp calc(760ms / var(--rate)) var(--ease-out) forwards; white-space: nowrap; }
.dmg.se { font-size: 26px; color: #ffe066; }
.dmg.nve { font-size: 16px; color: #cfd8cf; }
.dmg.heal { color: #9be37a; }
@keyframes floatUp { 0% { opacity: 0; translate: -50% 14px; scale: .6; } 15% { opacity: 1; scale: 1.15; } 30% { scale: 1; } 100% { opacity: 0; translate: -50% -34px; } }
.call { position: absolute; left: 50%; top: -14px; translate: -50% 0; z-index: 3; font-family: var(--f-display); font-size: var(--fs1); padding: 2px 10px; border-radius: 3px; color: #fff; background: var(--c, var(--accent)); box-shadow: 0 2px 0 rgb(0 0 0 / .35); animation: callIn calc(900ms / var(--rate)) var(--ease-out) forwards; white-space: nowrap; }
@keyframes callIn { 0% { opacity: 0; scale: .5; } 12% { opacity: 1; scale: 1.1; } 22% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; translate: -50% -8px; } }
.pt { position: absolute; pointer-events: none; }
.pt.psn, .pt.tox { width: 8px; height: 8px; border-radius: 50%; background: #c060d0; border: 1px solid #7a2a8a; animation: rise calc(1100ms / var(--rate)) ease-out forwards; }
.pt.brn { width: 5px; height: 7px; border-radius: 50% 50% 40% 40%; background: #ffb040; box-shadow: 0 0 6px #f08030; animation: rise calc(700ms / var(--rate)) ease-out forwards, flick 120ms steps(2) infinite; }
.pt.slp { font-family: var(--f-display); font-size: var(--fs3); color: #7ac8e8; -webkit-text-stroke: .5px #2a4a6a; animation: zz calc(1400ms / var(--rate)) ease-out forwards; }
.pt.par { width: 14px; height: 14px; background: #f8d030; clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); animation: spark calc(260ms / var(--rate)) steps(2) forwards; }
.pt.frz { width: 6px; height: 6px; background: #fff; clip-path: polygon(50% 0, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0 50%, 35% 35%); animation: glint calc(900ms / var(--rate)) ease-in-out forwards; }
@keyframes rise { from { opacity: 0; translate: 0 0; } 20% { opacity: 1; } to { opacity: 0; translate: var(--dx, 0px) -52px; } }
@keyframes flick { 50% { opacity: .5; } }
@keyframes zz { from { opacity: 0; translate: 0 0; } 20% { opacity: 1; } to { opacity: 0; translate: 26px -48px; scale: 1.5; } }
@keyframes spark { 0% { opacity: 1; scale: .4; } 50% { opacity: 1; scale: 1.2; } 100% { opacity: 0; } }
@keyframes glint { 0% { opacity: 0; scale: .2; } 50% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: .2; } }
.ball { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(#e03030 50%, #fff 50%); border: 2px solid #1a1a1a; z-index: 3; pointer-events: none; }
.ball::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; translate: -50% -50%; border-radius: 50%; background: #fff; border: 1.5px solid #1a1a1a; }
.ball.throw { animation: throwBall calc(520ms / var(--rate)) linear forwards; }
@keyframes throwBall { 0% { translate: 0 0; rotate: 0deg; } 50% { translate: calc(var(--bx) * .5) calc(var(--by) * .5 - 70px); } 100% { translate: var(--bx) var(--by); rotate: 540deg; } }
.ball.back { animation: backBall calc(420ms / var(--rate)) var(--ease-in) forwards; }
@keyframes backBall { 0% { translate: var(--bx) var(--by); } 50% { translate: calc(var(--bx) * .5) calc(var(--by) * .5 - 50px); } 100% { translate: 0 0; } }
.ring { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; translate: -50% -50%; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgb(0 0 0 / .2); animation: ringOut calc(420ms / var(--rate)) var(--ease-out) forwards; pointer-events: none; z-index: 3; }
@keyframes ringOut { to { width: 140px; height: 140px; opacity: 0; } }
/* Stage-wide motion: a layered shake (the far hills move a third as far as the floor), a camera punch, and hit-stop. */
.arena.fx-shake .stage, .arena.fx-shake .bg { animation: shk calc(460ms / var(--rate)) linear; }
@keyframes shk { 20% { translate: calc(var(--amp) * -1) calc(var(--amp) * .35); } 40% { translate: var(--amp) calc(var(--amp) * -.35); } 60% { translate: calc(var(--amp) * -.6) 0; } 80% { translate: calc(var(--amp) * .4) 0; } }
.arena.punch .stage { animation: punch calc(220ms / var(--rate)) var(--ease-out); }
@keyframes punch { 30% { scale: 1.025; } }
.arena.stop .stage *, .arena.stop .bg { animation-play-state: paused !important; }
.fxcanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.fxflash { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; }
.aturn { position: absolute; left: 50%; top: 12px; translate: -50% 0; z-index: 4; font-family: var(--f-display); font-size: var(--fs1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px 12px; white-space: nowrap; overflow: hidden; }
.aturn b { font-weight: 400; display: inline-block; }
.aturn b.roll { animation: roll calc(360ms / var(--rate)) var(--ease-out); }
@keyframes roll { from { translate: 0 110%; opacity: 0; } }
/* The caption types its line at the Game Boy's pace and shows a continue marker when it is done; it never blocks playback. */
.acaption { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 32px 8px 14px; font-size: var(--fs3); min-height: 42px; }
.acaption .more { position: absolute; right: 12px; bottom: 8px; font-size: 10px; color: var(--muted); font-style: normal; opacity: 0; }
.acaption.done .more { opacity: 1; animation: bob 1s steps(2) infinite; }
@keyframes bob { 50% { translate: 0 2px; } }
.acaption .cur { display: inline-block; width: 2px; height: 1em; background: var(--fg); vertical-align: -2px; margin-left: 1px; }
.acaption.done .cur, .acaption:empty .cur { display: none; }
@media (max-width: 720px) {
  .arena { --ms: 1; min-height: 0; }
  .arena .stage { min-height: 0; }
  .ahalf, .ahalf.p2 { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 46px 8px 96px; gap: 10px; }
  .ahalf.p2 .atrainer { order: 0; }
  .afield { order: -1; }
  .aspot { min-height: 88px; } .aspot img { width: 64px; height: 88px; }
  .abench span { --cell: 22px; }
  .dmg { font-size: 15px; } .dmg.se { font-size: 19px; }
  .call { font-size: 10px; }
}
/* The console is one fixed height: both agent panels, and the booth over the play-by-play between them.
   Each box scrolls inside itself, so long thinking or a long plan never stretches the page. */
.console { --console-h: 540px; }
.console > .agent { height: var(--console-h); display: flex; flex-direction: column; overflow: hidden; }
.console > .agent > .tabbody { flex: 1 1 auto; min-height: 120px; overflow-y: auto; }
.console > .agent > .strat { flex: 0 1 auto; max-height: 190px; overflow-y: auto; min-height: 0; }
.console > .field { height: var(--console-h); grid-template-rows: minmax(0, 1fr); }
.console > .field.withbooth { grid-template-rows: 176px minmax(0, 1fr); }
.console > .field.withbooth.boothoff { grid-template-rows: auto minmax(0, 1fr); }
.console > .field .logbox { height: auto; min-height: 0; }
@media (max-width: 1100px) { .console > .field { height: 440px; } }
/* Reasoning boxes keep their full height from the start, so the page doesn't shift as thinking streams in. */
.tabbody.fitted { display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.tabbody.fitted > pre, .tabbody.fitted > pre.think { flex: 1 1 auto; min-height: 80px; max-height: none; height: auto; }
.tabbody.fitted > .out, .tabbody.fitted > div:not(.waiting) { flex: 0 0 auto; }

/* ---------- The commentary booth (src/league/commentary.ts) ---------- */
.booth { background: var(--surface); border: 1px solid color-mix(in srgb, var(--rest) 45%, var(--line)); border-radius: var(--r2); display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; }
.booth .bhd { display: flex; align-items: center; gap: var(--sp2); padding: 6px 10px; background: var(--rest-bg); border-bottom: 1px solid var(--line); font-size: var(--fs2); min-width: 0; }
.booth .bhd b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boothoff .booth .bhd { border-bottom: 0; }
.booth .mic { width: 22px; height: 22px; border-radius: 50%; background: var(--rest); color: var(--surface); font-family: var(--f-display); font-size: 9px; display: grid; place-items: center; flex: none; }
.booth .onair { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-family: var(--f-display); font-size: 10px; color: var(--rest); white-space: nowrap; }
.booth .bfeed { overflow-y: auto; padding: 8px 12px; display: grid; gap: 7px; align-content: start; }
.booth .remark { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: var(--sp2); align-items: baseline; }
.booth .remark .t { font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); }
.booth .remark .x { font-size: var(--fs2); color: var(--muted); }
.booth .remark.now .x { font-size: var(--fs4); line-height: 1.45; color: var(--fg); font-style: italic; }
.booth .remark.now .t { color: var(--rest); font-weight: 500; }
.booth .remark.new .x { animation: speak var(--t-slow) var(--ease-out); }
@keyframes speak { from { opacity: 0; transform: translateY(4px); } }
.booth .bempty { color: var(--muted); font-size: var(--fs2); font-style: italic; }

/* ---------- Mid-season release (Season tab) ---------- */
.panel.midseason { gap: 10px; }
.mshead { display: flex; align-items: baseline; gap: 10px; }
.mshead > :last-child { margin-left: auto; }
.mshead h3 { font-size: var(--fs-body); }
.msgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.msgrid > div { display: grid; gap: var(--sp2); min-width: 0; }
.msorder { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: var(--fs3); }
.msorder li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r1); border: 1px solid transparent; }
.msorder li.done { background: var(--sunk); }
.msorder li.now { background: var(--mark); }
.msorder .no { font-family: var(--f-mono); color: var(--muted); width: 18px; }
.msorder b { min-width: 52px; }
.msorder .got { margin-left: auto; font-size: var(--fs2); text-align: right; }
.mspool { width: 100%; border-collapse: collapse; font-size: var(--fs2); }
.mspool th { text-align: left; font-size: var(--fs1); font-weight: 600; color: var(--muted); padding: 4px 6px; }
.mspool td { padding: 5px 6px; border-top: 1px solid var(--line); }
.mspool tr.own td { color: var(--muted); }
.msflag { color: var(--accent); font-weight: 600; }
.pill.msflag { justify-self: start; }
.wday .msflag { font-size: var(--fs1); margin-top: 2px; }
.sched tr.msrow td { background: var(--mark); border-top: 2px solid var(--accent); white-space: normal; }
.sched tr.msrow.done td { background: var(--sunk); border-top-color: var(--line); }

/* ---------- Bets ---------- */
.bets { display: grid; gap: 18px; }
.bstatus { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.bwhen { display: grid; gap: 2px; flex: 1 1 320px; min-width: 0; }
.bnums { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.bnums > div { display: grid; }
.bnums .big { font-family: var(--f-mono); font-size: var(--fs6); font-weight: 500; }
.betsgrid { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.betsmain { flex: 999 1 560px; min-width: 0; display: grid; gap: 22px; }
.betsside { flex: 1 1 320px; min-width: 0; display: grid; gap: var(--sp4); }
.bdays, .bday { display: grid; gap: 10px; }
.bdays { gap: 22px; }
.bmatch { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px; display: grid; gap: 10px; min-width: 0; }
.bmatch.yours { border-color: var(--accent); }
.bmeta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; font-size: var(--fs1); color: var(--muted); }
.bstate { color: var(--fg); font-weight: 600; }
.bsides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bside { display: grid; gap: 2px; text-align: left; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 12px; cursor: pointer; min-height: 44px; min-width: 0; }
.bside:disabled { cursor: default; }
.bside.won { border-color: var(--good); }
.bside.lost { opacity: .6; }
.bside.mine { opacity: 1; }
.bside.mine:disabled { cursor: default; }
.brow { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp2); min-width: 0; }
.brow > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow b { font-size: var(--fs5); }
.bodds { font-family: var(--f-mono); font-size: var(--fs6); font-weight: 500; }
.bside.p1 .bodds { color: var(--p1); } .bside.p2 .bodds { color: var(--p2); }
.bbar { position: relative; display: flex; height: 10px; border-radius: var(--r-pill); overflow: hidden; background: var(--sunk); }
.bbar .a { background: var(--p1); } .bbar .b { flex: 1; background: var(--p2); }
.bbar .tick { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--fg); }
.bfeedwrap { display: grid; gap: 10px; }
.bfeedwrap h4 { margin: 4px 0 0; font-size: var(--fs2); color: var(--muted); font-weight: 600; }
.bfeed { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; align-items: start; }
.bfeed .evhead .mono { margin-left: auto; }
.bstake { display: grid; gap: var(--sp1); }
.bstake input { font-family: var(--f-mono); font-size: var(--fs5); min-height: 44px; padding: 8px 10px; }
.bchips { display: flex; gap: 6px; }
.bchips .btn { flex: 1; min-height: 44px; }
.bret { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.bmine { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: var(--fs3); border-top: 1px solid var(--sunk); padding-top: var(--sp2); }
.btable th, .btable td { padding: 7px 8px; }
.btable td:first-child, .btable td:nth-child(2) { white-space: normal; }
.btable .pill.player, .bwtable .pill.player { font-size: var(--fs0); padding: 1px 6px; }
#bets-table { overflow-x: auto; }
.btable .sub { display: block; font-size: var(--fs1); }
.btable tr.you td { background: var(--mark); }
.btable td.up, .bmine .up { color: var(--good); } .btable td.down, .bmine .down { color: var(--bad); }
.gamblers { display: grid; gap: var(--sp2); }
.gambler { border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 10px; display: grid; gap: 6px; }
.gambler[open] { gap: var(--sp2); }
.gambler summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.gambler textarea { min-height: 90px; }
.gambler .notebook { max-height: 220px; overflow-y: auto; }
/* Renaming a trainer or journalist before the draft */
.dname .btn.sm { font-family: var(--f-body, inherit); margin-left: 10px; vertical-align: middle; }
.renameform { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--f-body, inherit); font-size: var(--fs3); }
.renameform input { font-size: var(--fs4); width: 14ch; padding: 4px 8px; }
.bline { display: grid; gap: 2px; border-top: 1px solid var(--sunk); padding-top: 6px; }
.bline:first-of-type { border-top: 0; padding-top: 0; }
.bodds-legend { font-size: var(--fs1); }
.bsteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.bsteps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--sunk); font-size: var(--fs3); }
.bsteps li:first-child { border-top: 0; }
.bsteps li.live { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.bturn { font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); text-align: right; }
.bsteps .bstep { white-space: normal; }
@media (max-width: 560px) { .bsteps li { grid-template-columns: 24px minmax(0, 1fr); } .bsteps .bstepcol { grid-column: 2; } }
.bline-est b { color: var(--fg); }
.bmoney { gap: 10px; }
.bmoney .lcwrap { padding-top: 14px; }
.lcwrap { min-width: 0; }
.lc { position: relative; display: grid; gap: var(--sp2); }
.lc svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.lc-grid { stroke: var(--line); stroke-width: 1; opacity: .6; }
.lc-ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.lc-tick { font-size: var(--fs0); fill: var(--muted); font-family: var(--f-mono); }
.lc-end { font-size: var(--fs1); fill: var(--muted); }
.lc-end.strong { fill: var(--fg); font-weight: 600; }
.lc-hair { stroke: var(--muted); stroke-width: 1; }
.lc-dot { stroke: var(--surface); stroke-width: 2; }
.lc svg rect:focus-visible { outline: 2px solid var(--accent); }
.lc-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 10px; font-size: var(--fs1); box-shadow: var(--lift); display: grid; gap: 3px; min-width: 140px; z-index: 2; }
.lc-tiphead { color: var(--muted); font-size: var(--fs0); }
.lc-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 6px; align-items: center; }
.lc-row b { font-family: var(--f-mono); font-weight: 600; }
.lc-row span:last-child { color: var(--muted); }
.lc-key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.lc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs1); color: var(--muted); }
.lc-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lc-table summary { font-size: var(--fs1); }
.bbets { display: grid; gap: 6px; border-top: 1px solid var(--sunk); padding-top: var(--sp2); }
.bbetside { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Bets on a battle's match (battle page) */
.battlebets { margin: 14px 0 0; gap: 10px; }
.bbsides { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp3); }
.bbside { display: grid; gap: 6px; align-content: start; }
.bbhead { display: flex; gap: 10px; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.bbhead .mono { font-size: var(--fs5); }
.bbrow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: var(--fs3); }
.bbrow > .small.muted:last-child { flex-basis: 100%; }
.bbrow.you { background: var(--mark); border-radius: var(--r1); padding: 2px 6px; margin: 0 -6px; }
.allbets td { white-space: normal; vertical-align: top; }
.allbets td:first-child, .allbets td.n { white-space: nowrap; }
.allbets tr.you td { background: var(--mark); }
.allbets td.up { color: var(--good); } .allbets td.down { color: var(--bad); }
[data-allbets][aria-pressed="true"] { border-color: var(--accent); font-weight: 600; }
/* Bets tab, subtab layout */
.bsub { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.bcred { font-size: var(--fs-body); color: var(--fg); }
.bpane { display: grid; gap: var(--sp4); }
.border { display: flex; flex-wrap: wrap; gap: var(--sp2); }
.bwave { font-size: var(--fs0); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); align-self: center; margin-left: 6px; }
.bweek { display: flex; flex-wrap: wrap; gap: var(--sp4); align-items: flex-start; }
.bweekall { flex: 999 1 520px; min-width: 0; }
.bwtable td { white-space: normal; vertical-align: top; }
.bwtable td.n, .bwtable td:first-child { white-space: nowrap; }
.bwtable td.up, .byour .up { color: var(--good); } .bwtable td.down, .byour .down { color: var(--bad); }
.byours { flex: 1 1 240px; min-width: 0; border: 2px dashed var(--line); border-radius: var(--r2); padding: 12px 14px; display: grid; gap: var(--sp2); align-content: start; }
.byour { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: var(--fs3); background: var(--mark); border-radius: var(--r1); padding: 6px 8px; }
.byour > :last-child { grid-column: 1 / -1; }
.bm { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; align-items: center; border-top: 1px solid var(--sunk); padding-top: 10px; margin-top: 2px; }
.bm.yours { background: color-mix(in srgb, var(--accent) 5%, transparent); border-radius: var(--r1); }
.bmday { font-size: var(--fs1); color: var(--muted); display: grid; gap: 2px; }
.bmday .bstate { font-family: var(--f-body); font-size: var(--fs1); color: var(--fg); font-weight: 600; }
.bm .bside { padding: 7px 12px; }
.bm .bodds { font-size: var(--fs5); }
.bmwhy { grid-column: 2 / -1; font-size: var(--fs2); color: var(--muted); }
.bmwhy summary b { color: var(--fg); }
.bmwhy p { margin: 6px 0 0; }
.bmwhy .bbets { margin-top: 6px; }
#bet-slip.active { border: 2px solid var(--accent); }
.bgamblers { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.bwho { flex: 1 1 260px; min-width: 0; display: grid; gap: var(--sp2); }
.bdetail { flex: 999 1 640px; min-width: 0; display: grid; gap: var(--sp4); }
.bwhocard { display: grid; gap: 3px; text-align: left; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; cursor: pointer; min-height: 44px; }
.bwhocard .up { color: var(--good); } .bwhocard .down { color: var(--bad); }
.badd-open { border-style: dashed; min-height: 44px; font-weight: 600; }
.badd { gap: 6px; }
.badd textarea { min-height: 70px; }
.bpersona summary { font-size: var(--fs3); }
.bpersona textarea { min-height: 220px; margin: 8px 0; }
.bpersona p { white-space: pre-wrap; max-width: 75ch; margin: 8px 0 0; }
.bdetail .up { color: var(--good); } .bdetail .down { color: var(--bad); }
.bdetail pre.notebook { max-height: 260px; overflow-y: auto; }
.bhweek { display: grid; gap: var(--sp2); border-top: 1px solid var(--sunk); padding-top: 10px; }
.bhbet { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: var(--fs3); }
.bhwhy { grid-column: 1 / -1; }
.bhweek .why pre { max-height: 260px; }
.btiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp3); }
.btile { gap: 2px; }
.btile .big { font-size: var(--fs6); font-weight: 500; }
@media (max-width: 560px) { .bm { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .bmday { grid-column: 1 / -1; display: flex; gap: var(--sp2); } .bmwhy { grid-column: 1 / -1; } }
/* Bets on a match, under each side's price */
.bmbets { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bmbets .bbetside { display: flex; flex-wrap: wrap; gap: var(--sp1); align-content: flex-start; }
@media (max-width: 560px) { .bmbets { grid-column: 1 / -1; } }
/* What a gambler sees (Bets tab, admin) */
.bsees { display: grid; gap: var(--sp1); }
.bsees .brow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: var(--fs2); }
.bsees .brow .small { display: block; }

/* ---------- Weekend rest: Saturday's picks sit out Sunday ---------- */
.grouplbl { display: flex; align-items: center; gap: 10px; font-size: var(--fs0); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.grouplbl::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.choice.off { background: var(--rest-bg); border-color: transparent; color: var(--muted); cursor: not-allowed; }
.choice.off b, .restnote { color: var(--rest); }
.roster li.resting { background: color-mix(in srgb, var(--rest-bg) 55%, transparent); }
.restsides { display: grid; gap: 6px; font-size: var(--fs1); }
.restsides .rs { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.restsides .chip { border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--good) 40%, var(--line)); background: transparent; font-family: var(--f-body); font-weight: 500; }

/* League tab: rosters at a glance */
.rostercard { margin-bottom: var(--sp4); }
.rostergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp3); }
.rcol { border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 10px; background: var(--bg); min-width: 0; }
.rhead { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 4px; }
.rcol ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.rcol li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 6px; align-items: center; font-size: var(--fs2); line-height: 1.3; }
.rcol img { width: 26px; height: 26px; image-rendering: pixelated; object-fit: contain; transform: scale(1.6); }
.rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rlv { font-size: var(--fs1); color: var(--muted); }

/* ---------- Training camp ---------- */
.roster li.atcamp { background: color-mix(in srgb, var(--camp-bg) 60%, transparent); }
.roster li.atcamp .expbar i { background: var(--camp); }
.roster .campline { font-size: var(--fs1); color: var(--camp); font-weight: 600; }
.wday .campfx { color: var(--camp); font-weight: 600; overflow-wrap: anywhere; }
.evcard.camp { border-color: color-mix(in srgb, var(--camp) 45%, var(--line)); }
.camplist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: var(--fs2); }
.camplist li { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.camplist .nx { flex-basis: 100%; font-size: var(--fs1); color: var(--muted); }
.rcol li.atcamp .rname::after { content: "camp"; margin-left: 6px; font-size: var(--fs0); font-weight: 600; color: var(--camp); background: var(--camp-bg); border-radius: var(--r-pill); padding: 0 6px; }
table.camp td .pill { margin-left: 4px; }

/* ---------- Voice sheets: My trainer's Voice section and the Voices tab (public/lib/voice-form.js, public/voices-admin.js) ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--sp3); }
.vsplit { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.vcol, .veditor, .vcolumn, .vknown, .vrules, .vpresets, .vcast { display: grid; gap: 10px; min-width: 0; }
.vfield { display: grid; gap: var(--sp1); min-width: 0; }
.vfield > label, .vlabel { font-size: var(--fs0); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.vhint { font-size: var(--fs1); color: var(--muted); }
.vfield select, .vfield input[type="text"], .vfield textarea { width: 100%; }
.vpresets select, .vpresets input[type="text"] { width: auto; }
.vpresets input[type="text"] { width: 22ch; }
.vfield textarea { min-height: 60px; line-height: 1.45; }
.vfield textarea.vbox { height: 104px; min-height: 104px; }
.vfield textarea.vexamples { font-family: var(--f-mono); font-size: var(--fs2); }
.vfield :disabled, .vctx select:disabled { opacity: .75; }
.vknown, .vrules { border-top: 1px solid var(--line); padding-top: 12px; }
.vpresets { border-top: 1px dashed var(--line); padding-top: 12px; }
.vctxlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 6px 16px; }
.vctx { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 10px; align-items: start; padding: 7px 9px; border-radius: var(--r1); border: 1px solid transparent; }
.vctx.changed { border-color: var(--accent); background: var(--sunk); }
.vwhat { display: grid; gap: 2px; min-width: 0; }
.vctx label { font-size: var(--fs3); font-weight: 500; }
.vrules ul { margin: 0; padding-left: 18px; font-size: var(--fs2); display: grid; gap: 3px; }
.vact { background: var(--mark); border-color: transparent; color: var(--fg); }
.vcastrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vcastrow .lbl { width: 92px; }
.vpick { font: inherit; font-size: var(--fs3); border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--r-pill); padding: 5px 13px; cursor: pointer; min-height: 34px; display: inline-flex; gap: 6px; align-items: center; }
.vpick[aria-pressed="true"] { font-weight: 600; }
.vpm { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--player); }
.vpersona { max-width: 80ch; border-left: 3px solid var(--line); padding-left: 10px; }
.vbanner { border-left: 3px solid var(--player); padding: 8px 12px; background: var(--player-bg); border-radius: 0 var(--r1) var(--r1) 0; font-size: var(--fs3); margin: 0; }
.vchecks { display: flex; flex-wrap: wrap; gap: 6px; }
.vcheck { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--bg); font-size: var(--fs2); cursor: pointer; }
.vcheck:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-weight: 500; }
.vcheck input { accent-color: var(--accent); margin: 0; }
.vtics { display: grid; }
.vtic { display: grid; grid-template-columns: minmax(0, 1fr) 150px 170px; gap: var(--sp3); align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.vtic:first-child { border-top: 0; }
.vex { font-family: var(--f-mono); font-size: var(--fs1); color: var(--muted); background: var(--sunk); padding: 5px 8px; border-radius: var(--r1); overflow-wrap: anywhere; }
@media (max-width: 640px) { .vctx, .vtic { grid-template-columns: 1fr; } .vctxlist { grid-template-columns: 1fr; } .vcastrow .lbl { width: 100%; } }

/* ---------- Commentators tab (public/commentators-admin.js) ---------- */
.ccast { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp2); align-items: start; }
.vpick.cpick { border-radius: var(--r2); display: grid; justify-items: start; gap: 2px; padding: 8px 12px; text-align: left; }
.vpick.cnew { border-style: dashed; color: var(--muted); align-content: center; }
.cadd { display: grid; gap: 6px; border: 1px dashed var(--line); border-radius: var(--r2); padding: 10px 12px; }
.ctry { display: grid; gap: var(--sp2); border: 1px dashed var(--line); border-radius: var(--r2); padding: 12px; }
.ctry .remark { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: var(--sp2); align-items: baseline; }
.ctry .remark .t { font-family: var(--f-mono); font-size: var(--fs0); color: var(--rest); }
.ctry .remark .x { font-size: var(--fs3); font-style: italic; }

/* ---------- Reduced motion: one switch ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .spin { animation-duration: .9s !important; animation-iteration-count: infinite !important; }
  .aspr.idle, .acaption.done .more, .pt, .arena.fx-shake .stage, .arena.fx-shake .bg, .arena.punch .stage { animation: none !important; }
}

/* ---------- The welcome (public/lib/welcome.js): a seven-card tour over the lobby, first visit and Menu → How it works ---------- */
dialog.welcome { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); color: var(--fg); box-shadow: var(--lift); overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
dialog.welcome:not([open]) { display: none; }
dialog.welcome::backdrop { background: rgb(10 16 12 / .5); }
.welcome .whead { display: flex; align-items: center; gap: var(--sp3); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.welcome .whead .eyebrow { flex: 1; }
.wdots { display: flex; gap: 6px; }
.wdots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: var(--line); cursor: pointer; transition: background-color var(--t-fast), scale var(--t-fast); }
.wdots button[aria-current="step"] { background: var(--accent); scale: 1.25; }
.wcard { display: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; overflow: auto; }
.wcard.on { display: grid; animation: slideIn var(--t) var(--ease-out); }
.wpic { background: var(--sunk); display: grid; place-items: center; padding: var(--sp5); min-height: 300px; position: relative; overflow: hidden; }
.wwords { padding: 28px 28px 24px; display: grid; gap: var(--sp3); align-content: start; }
.wwords h2 { font-family: var(--f-display); font-weight: 400; font-size: var(--fs6); }
.wwords p, .wwords ul { max-width: 42ch; }
.wwords ul { margin: 0; padding-left: 18px; display: grid; gap: var(--sp1); }
.wwords .tip { font-size: var(--fs2); color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }
.welcome .wfoot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.welcome .wfoot label { display: inline-flex; gap: 6px; align-items: center; }
.welcome .wfoot .spacer { flex: 1; }
@media (max-width: 640px) {
  .wcard { grid-template-columns: minmax(0, 1fr); }
  .wpic { min-height: 200px; padding: var(--sp4); }
  .wwords { padding: 20px; }
  .welcome .wfoot label span { display: none; }
}
/* the pictures */
.wpic .px, .wpic .tsprite { image-rendering: pixelated; display: block; }
.whero { display: grid; gap: 10px; justify-items: center; }
.whero .wrow { display: flex; gap: 18px; align-items: flex-end; }
.wmons { display: flex; }
.wmons img { width: 72px; height: 72px; margin: 0 -10px; }
.wwho { display: grid; justify-items: center; gap: 4px; }
.wwho .tn { font-family: var(--f-display); font-size: var(--fs0); }
.wyou { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp4); align-items: center; }
.wyouspr { display: grid; gap: var(--sp2); justify-items: center; }
.wyou .nameplate { font-family: var(--f-display); font-size: var(--fs3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r1); padding: 4px 10px; }
.wlooks { display: grid; gap: 6px; }
.wlooks .lchip { font-size: var(--fs0); padding: 2px 8px; }
.wboard { border-collapse: collapse; font-size: var(--fs0); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.wboard th { background: var(--bg); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: 10px; padding: 4px 6px; border: 1px solid var(--line); }
.wboard td { border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap; }
.wboard td img { width: 22px; height: 22px; vertical-align: middle; margin: -4px 0; display: inline-block; }
.wboard td.clock { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.wboard .spin { display: inline-block; width: 8px; height: 8px; vertical-align: -1px; }
.wweek { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp1); width: 100%; }
.wwday { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r1); padding: 6px 4px; display: grid; gap: 2px; justify-items: center; font-size: 10px; color: var(--muted); text-align: center; min-height: 68px; }
.wwday b { font-family: var(--f-display); font-size: 10px; color: var(--fg); }
.wwday.match { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.wwday img { width: 22px; height: 22px; }
.wstage { width: 100%; border-radius: var(--r2); border: 1px solid var(--line); background: linear-gradient(var(--sky) 0 58%, var(--floor) 58% 100%); position: relative; height: 170px; overflow: hidden; }
.wstage .plate { position: absolute; top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r1); padding: 4px 8px; font-size: 10px; display: grid; gap: 3px; width: 108px; }
.wstage .plate b { font-family: var(--f-display); font-weight: 400; font-size: 10px; }
.wstage .bar { height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.wstage .bar i { display: block; height: 100%; background: var(--good); }
.wstage .bar i.low { background: var(--bad); }
.wstage img { position: absolute; bottom: 22px; width: 72px; height: 72px; }
.wstage .shadow { position: absolute; bottom: 20px; width: 60px; height: 10px; border-radius: 50%; background: rgb(0 0 0 / .12); }
.wstage .turn { position: absolute; left: 50%; top: 8px; translate: -50% 0; font-family: var(--f-display); font-size: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 1px 8px; }
.wstage .cap { position: absolute; left: 8px; right: 8px; bottom: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r1); padding: 3px 8px; font-size: var(--fs0); }
.wstage .dmg { position: absolute; font-family: var(--f-display); font-size: var(--fs3); color: #fff; -webkit-text-stroke: 1px #000; paint-order: stroke fill; animation: wfloat 1.6s ease-out infinite; }
@keyframes wfloat { 0% { opacity: 0; translate: 0 10px; } 15% { opacity: 1; } 100% { opacity: 0; translate: 0 -24px; } }
.wbet { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px; display: grid; gap: var(--sp2); }
.wbet .meta { font-size: var(--fs0); color: var(--muted); display: flex; justify-content: space-between; }
.wbet .sides { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp2); }
.wbet .side { border: 1px solid var(--line); border-radius: var(--r1); background: var(--bg); padding: 8px 10px; display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs2); }
.wbet .side.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.wbet .odds { font-family: var(--f-mono); font-size: var(--fs5); color: var(--p1); }
.wbet .side:last-child .odds { color: var(--p2); }
.wbet .slip { display: flex; justify-content: space-between; font-size: var(--fs1); border-top: 1px solid var(--line); padding-top: var(--sp2); }
.wpaper { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px; display: grid; gap: 6px; }
.wpaper .mast { font-family: var(--f-display); font-size: var(--fs3); border-bottom: 2px solid var(--fg); padding-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.wpaper .mast small { font-family: var(--f-body); font-size: 10px; color: var(--muted); }
.wpaper .col { font-family: var(--f-display); font-size: 9px; color: var(--accent); letter-spacing: .06em; }
.wpaper h4 { margin: 0; font-size: var(--fs2); line-height: 1.3; }
.wpaper p { font-size: var(--fs0); color: var(--muted); line-height: 1.5; }
.wpaper .by { display: flex; gap: 6px; align-items: center; font-size: var(--fs0); }

/* Schedule tab (public/schedule.js): the 14-day calendar, the pattern editor and the add-a-run dialog */
.sched .pill.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.sched .pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.sched .pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.sched .pill.dim { color: var(--muted); }
.sched .dhead h2 { display: inline-flex; align-items: center; gap: var(--sp2); }
.sched .spacer { flex: 1; }
.schednext a { margin-left: 4px; }
.schcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 820px) { .schcal { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.schday { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 9px; min-height: 7.6em; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; min-width: 0; text-align: left; transition: border-color var(--t-fast); }
.schday[data-day] { cursor: pointer; }
.schday[data-day]:hover { border-color: var(--muted); }
.schday.today { border-color: var(--accent); }
.schday .date { font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.schday .date b { color: var(--fg); font-weight: 500; }
.schday .mtag { font-family: var(--f-mono); color: var(--accent); letter-spacing: .04em; }
.schday .runs { display: grid; gap: 4px; align-content: start; }
.schrun { font: inherit; font-size: var(--fs1); line-height: 1.3; color: inherit; border: 0; border-left: 2px solid var(--muted); border-radius: 0; padding: 0 0 0 6px; background: none; text-align: left; display: block; width: 100%; overflow-wrap: anywhere; }
button.schrun { cursor: pointer; }
button.schrun:hover { background: var(--sunk); }
.schrun.match { border-left-color: var(--accent); }
.schrun.oneoff { border-left-color: var(--warn); }
.schrun.done, .schrun.superseded { border-left-color: var(--good); color: var(--muted); }
.schrun.superseded { text-decoration: line-through; }
.schrun.noop { color: var(--muted); }
.schrun.behind { border-left-color: var(--bad); }
.schrun .t { font-family: var(--f-mono); font-size: var(--fs0); }
.schrun .pill { font-size: 10px; padding: 0 6px; margin-left: 2px; }
.schday .pos { font-family: var(--f-mono); font-size: var(--fs0); color: var(--muted); border-top: 1px dashed var(--line); padding-top: 4px; overflow-wrap: anywhere; }
.schday .pos b { color: var(--fg); font-weight: 500; }
.schlegend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs1); color: var(--muted); }
.schlegend span:not(.hint)::before { content: ''; display: inline-block; width: 3px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--muted); }
.schlegend .m::before { background: var(--accent); } .schlegend .o::before { background: var(--warn); } .schlegend .d::before { background: var(--good); }
/* The pattern editor */
.schpat { display: grid; gap: 10px; }
.schpat .prow { width: 100%; }
.schpat label { display: inline-flex; align-items: center; gap: 6px; }
.schpday { border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 12px; display: grid; gap: 6px; background: var(--bg); }
.schpday .pdh { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.schpday .pdh .eyebrow { white-space: nowrap; }
.schstep { display: grid; grid-template-columns: 7.5em auto 1fr auto; gap: 8px; align-items: center; }
.schstep .static { white-space: nowrap; }
@media (max-width: 560px) { .schstep { grid-template-columns: 7.5em 1fr auto; } .schstep .static { grid-column: 1 / -1; } }
.schstep.bad input, .schstep.bad select { border-color: var(--bad); }
/* The dialog */
dialog.sched { width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); color: var(--fg); box-shadow: var(--lift); overflow: auto; }
dialog.sched:not([open]) { display: none; }
dialog.sched::backdrop { background: rgb(10 16 12 / .5); }
dialog.sched .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
dialog.sched .panes { display: grid; grid-template-columns: 1fr 1fr; }
dialog.sched .pane { padding: 14px 16px; min-width: 0; display: grid; gap: 8px; align-content: start; }
dialog.sched .pane + .pane { border-left: 1px solid var(--line); }
@media (max-width: 640px) { dialog.sched .panes { grid-template-columns: 1fr; } dialog.sched .pane + .pane { border-left: 0; border-top: 1px solid var(--line); } }
dialog.sched .monthnav { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs2); }
.schmonth { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-family: var(--f-mono); font-size: var(--fs1); text-align: center; }
.schmonth .h { color: var(--muted); font-size: var(--fs0); padding: 2px 0 4px; }
.schmonth .d { padding: 5px 0; border-radius: 3px; background: none; border: 0; cursor: pointer; font: inherit; color: inherit; }
.schmonth .d:hover { background: var(--sunk); }
.schmonth .d.other { color: var(--muted); opacity: .55; }
.schmonth .d.sel { background: var(--accent); color: #fff; }
.schmonth .d.today { outline: 1px solid var(--accent); outline-offset: -1px; }
.schmonth .d.has { text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
dialog.sched .timerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.schchips { display: flex; gap: 6px; flex-wrap: wrap; }
.schchip { font-family: var(--f-mono); font-size: var(--fs0); padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--muted); background: none; cursor: pointer; transition: border-color var(--t-fast); }
.schchip:hover:not(:disabled) { border-color: var(--muted); }
.schchip.sel { border-color: var(--accent); color: var(--accent); }
.schchip:disabled { opacity: .4; cursor: default; }
.schlcal { display: grid; gap: 4px; }
.schlcal .lweek { display: grid; grid-template-columns: 3em repeat(7, 1fr); gap: 2px; align-items: center; font-family: var(--f-mono); font-size: var(--fs1); text-align: center; }
.schlcal .w { text-align: left; color: var(--muted); font-size: var(--fs0); }
.schlcal .ld { padding: 5px 0; border-radius: 3px; border: 1px solid transparent; background: none; font: inherit; color: inherit; cursor: pointer; }
.schlcal .ld:hover:not(:disabled) { background: var(--sunk); }
.schlcal .ld.past { color: var(--muted); opacity: .5; text-decoration: line-through; cursor: default; }
.schlcal .ld.match { border-color: var(--line); }
.schlcal .ld.sel { background: var(--accent); color: #fff; }
.schlcal .ld.release { box-shadow: inset 0 -2px 0 var(--warn); }
.schlcal .ld.now { outline: 1px solid var(--accent); outline-offset: -1px; }
.schlcal .ld.span { grid-column: span 7; }
dialog.sched .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; background: var(--bg); }
dialog.sched .summary { font-size: var(--fs2); min-width: 0; flex: 1 1 24em; }
