:root {
  --bg: #0d1016; --bg2: #141922; --bg3: #1b212c; --line: #262e3b; --line2: #333d4d;
  --ink: #e8ecf2; --ink2: #a9b2c1; --ink3: #737d8e;
  --dem: #3d7bf2; --rep: #e5484d; --oth: #8a93a3; --lib: #d9a514; --gre: #3fae5a;
  --accent: #f5c542; --live: #e5484d; --replay: #8b6cf0; --final: #3fae5a;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--font); }
body { display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
a { color: #8fb4ff; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand b { font-size: 18px; letter-spacing: .02em; }
.brand span { color: var(--ink3); margin-left: 6px; font-size: 12px; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--ink2); }
.crumbs button { background: none; border: 0; color: #8fb4ff; cursor: pointer; padding: 0; }
.grow { flex: 1; }
.sel { display: flex; gap: 8px; align-items: center; color: var(--ink3); font-size: 12px; }
select { background: var(--bg3); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 8px; }
.mode { font-weight: 700; font-size: 12px; letter-spacing: .08em; padding: 4px 10px; border-radius: 4px; }
.mode.live { background: var(--live); color: #fff; }
.mode.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #fff; margin-right: 6px; animation: pulse 1.6s infinite; vertical-align: 1px; }
.mode.replay { background: var(--replay); color: #fff; }
.mode.final { background: var(--final); color: #08130b; }
.mode.quiet { background: none; border: 1px solid var(--live); color: #ff8e91; }
@keyframes pulse { 50% { opacity: .25; } }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 420px; min-height: 0; }
.mapwrap { position: relative; min-height: 0; overflow: hidden; }
#map { width: 100%; height: 100%; display: block; }
.maptools { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 2; }
.maptools.hidden { display: none; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 10px; cursor: pointer; color: var(--ink2); font-size: 12px; }
.seg button.on { background: var(--bg3); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.legend { position: absolute; left: 12px; bottom: 12px; background: rgba(20,25,34,.92); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--ink2); max-width: 360px; }
.legend .row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .sw { width: 14px; height: 10px; border-radius: 2px; display: inline-block; border: 1px solid #0006; }
.legend .ramp { display: flex; height: 10px; border-radius: 2px; overflow: hidden; margin: 4px 0 2px; }
.legend .ramp span { flex: 1; }
.legend .ends { display: flex; justify-content: space-between; font-size: 11px; }
.mapnote { position: absolute; right: 12px; bottom: 12px; font-size: 11px; color: var(--ink3); max-width: 46%; text-align: right; }
.tip { position: absolute; pointer-events: none; background: #0b0e13f2; border: 1px solid var(--line2); border-radius: 6px; padding: 7px 9px; font-size: 12px; max-width: 280px; z-index: 5; }
.tip b { display: block; margin-bottom: 2px; }

path.state { fill: #1e2531; stroke: #0d1016; stroke-width: .6; vector-effect: non-scaling-stroke; }
path.state.supported { fill: #2a3546; cursor: pointer; }
path.state.supported:hover { fill: #36455c; }
path.state.inview { fill: none; pointer-events: none; }
path.area { stroke: #0d1016; stroke-width: .5; cursor: pointer; vector-effect: non-scaling-stroke; }
path.area:hover { stroke: #fff; stroke-width: 1.5; }
path.area.sel { stroke: #fff; stroke-width: 2.2; }
path.area.hl { stroke: var(--accent); stroke-width: 2.2; }
path.outline { fill: none; stroke: #c9d1de; stroke-width: 1.1; vector-effect: non-scaling-stroke; pointer-events: none; }
path.cdline { fill: none; stroke: #e8ecf2aa; stroke-width: 1.2; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; pointer-events: none; }
text.lbl { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: #000a; stroke-width: 3px; }
text.uslbl { fill: var(--ink3); font-size: 10px; text-anchor: middle; pointer-events: none; }

.panel { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.racebar { padding: 10px 12px 0; }
.racebar select { width: 100%; padding: 7px 9px; font-weight: 600; }
.card { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.card .meta { color: var(--ink3); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.cand { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; align-items: baseline; margin: 6px 0; }
.cand .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .nm i { font-style: normal; color: var(--ink3); font-weight: 500; margin-left: 4px; font-size: 12px; }
.cand .pc { font-weight: 700; font-size: 16px; text-align: right; min-width: 56px; }
.cand .vt { color: var(--ink2); text-align: right; min-width: 84px; }
.cand .bar { grid-column: 1 / -1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.cand .bar span { display: block; height: 100%; transition: width .5s ease; }
.cand.lead .nm::after { content: "leading"; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); margin-left: 6px; border: 1px solid var(--line2); border-radius: 3px; padding: 0 4px; }
.marginline { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--ink2); }
.marginline b { color: var(--ink); }
.srcline { font-size: 11px; color: var(--ink3); margin-top: 6px; }
.srcline a { color: var(--ink2); }
.badge { display: inline-block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line2); color: var(--ink2); }
.badge.warn { border-color: #b7791f; color: #f0b44c; }
.badge.none { border-color: #555; color: #aaa; }

.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs button { background: none; border: 0; padding: 9px 8px; color: var(--ink3); cursor: pointer; font-size: 12.5px; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabbody { flex: 1; overflow: auto; padding: 10px 12px 18px; }
.empty { color: var(--ink3); padding: 10px 0; }
h3 { font-size: 13px; margin: 12px 0 6px; color: var(--ink2); text-transform: uppercase; letter-spacing: .06em; }
h3:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--ink3); }
.kv dd { margin: 0; text-align: right; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--ink3); font-weight: 500; padding: 4px 4px; border-bottom: 1px solid var(--line); position: sticky; top: -10px; background: var(--bg2); }
td { padding: 4px 4px; border-bottom: 1px solid #1d232e; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg3); }
.note { font-size: 12px; color: var(--ink3); margin: 8px 0; }

.drop { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; background: var(--bg); }
.drop:hover { border-color: var(--line2); }
.drop.on { border-color: var(--accent); }
.drop .when { display: flex; justify-content: space-between; color: var(--ink3); font-size: 12px; }
.drop .gains { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0; font-weight: 600; }
.drop .gains span.neg { color: #f0b44c; }
.drop .mv { font-size: 12.5px; color: var(--ink2); }
.drop .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chip { font-size: 11px; background: var(--bg3); border-radius: 3px; padding: 1px 5px; color: var(--ink2); }
.chip.neg { color: #f0b44c; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.groups { display: grid; gap: 6px; }
.group { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.group .gh { display: flex; justify-content: space-between; color: var(--ink2); font-size: 12px; }
.group .gm { font-weight: 700; font-size: 15px; }
#scatter { width: 100%; height: 220px; display: block; margin-top: 6px; }
#scatter text { fill: var(--ink3); font-size: 10px; }
#scatter .ax line, #scatter .ax path { stroke: var(--line2); }

.replay { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); background: #17122a; }
.replay.livebar { background: var(--bg2); }
.rmode { font-weight: 700; font-size: 11px; letter-spacing: .08em; color: #c8b8ff; min-width: 70px; }
.livebar .rmode { color: #ff8e91; }
.btn { background: var(--bg3); border: 1px solid var(--line2); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.btn.ghost { background: none; }
#rscrub { flex: 1; accent-color: var(--replay); }
.rclock { min-width: 220px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink2); font-size: 12.5px; }

@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: block; padding-bottom: 92px; }
  .top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; }
  .top .grow { display: none; }
  .crumbs { order: 3; flex-basis: 100%; font-size: 13px; }
  .sel span { display: none; }
  .sel select { max-width: 150px; }
  .mode { font-size: 11px; padding: 3px 7px; }
  .layout { display: block; }
  .mapwrap { overflow: visible; }
  .maptools { position: static; padding: 8px 10px 0; flex-wrap: nowrap; overflow-x: auto; }
  .maptools .seg { flex: none; }
  #map { height: 46vh; }
  .legend { position: static; margin: 0 10px 8px; max-width: none; }
  .mapnote { position: static; text-align: left; max-width: none; padding: 0 10px 6px; }
  .panel { display: block; border-left: 0; border-top: 1px solid var(--line); }
  .tabs { overflow-x: auto; position: sticky; top: 0; background: var(--bg2); z-index: 3; }
  .tabs button { flex: none; }
  .tabbody { overflow: visible; }
  th { top: 36px; }
  .replay { position: fixed; left: 0; right: 0; bottom: 0; flex-wrap: wrap; gap: 6px 8px; padding: 6px 10px; z-index: 10; }
  #rscrub { order: 9; flex-basis: 100%; }
  .rclock { min-width: 0; font-size: 11px; flex: 1; }
  .rmode { min-width: 0; }
}
}

#trend { width: 100%; height: 64px; display: block; margin-top: 12px; }
#trend text { fill: var(--ink3); font-size: 10px; }

.slider { display: block; font-size: 12.5px; color: var(--ink2); margin: 6px 0 10px; }
.slider b { float: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); margin-top: 4px; }
table.scn input { width: 84px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 4px; padding: 2px 5px; text-align: right; font-variant-numeric: tabular-nums; }

#basesel, #methsel, #demosel, #pdemo { padding: 1px 4px; font-size: 12px; margin-left: 4px; }

.hgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.hcard { border: 1px solid var(--line); border-left: 4px solid; border-radius: 6px; padding: 6px 8px; cursor: pointer; background: var(--bg); }
.hcard:hover, .hcard.on { border-color: var(--line2); background: var(--bg3); }
.hcard .hn { font-size: 11px; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; }
.hcard .hl { font-weight: 700; }
.hcard .hl i { font-style: normal; font-weight: 500; color: var(--ink3); font-size: 12px; }
.hcard .hm { font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }

.replay[hidden], .tip[hidden] { display: none; }

path.area.dim { fill: #12161d !important; stroke: #1f2630; cursor: pointer; }
path.pct { stroke: #0d1016; stroke-width: .35; cursor: pointer; vector-effect: non-scaling-stroke; }
path.pct:hover { stroke: #fff; stroke-width: 1.2; }
path.pct.sel { stroke: #fff; stroke-width: 2; }
path.coutline { fill: none; stroke: #e8ecf2; stroke-width: 1.4; vector-effect: non-scaling-stroke; pointer-events: none; }
tr.pclick, tr.dclick { cursor: pointer; }
tr.pclick:hover td, tr.dclick:hover td { background: var(--bg3); }

.toast { position: absolute; top: 56px; right: 12px; background: #0b0e13f2; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-size: 13px; max-width: 340px; z-index: 6; }
.toast b { display: block; color: var(--accent); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 3px; }
.toast > span { margin-right: 10px; font-weight: 600; }
.toast div { color: var(--ink2); font-size: 12px; margin-top: 3px; }
.toast[hidden] { display: none; }
.rlist { display: grid; gap: 2px; margin-bottom: 6px; }
.rrow { display: flex; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 12.5px; }
.rrow:hover, .rrow.on { background: var(--bg3); }
.rrow .rl { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .toast { position: fixed; top: auto; bottom: 100px; left: 10px; right: 10px; max-width: none; } }

.share { font-size: 12px; padding: 4px 10px; color: var(--ink2); }
@media (max-width: 900px) { .share { display: none; } }

.find { background: var(--bg2); border: 1px solid var(--line2); border-radius: 7px; padding: 5px 9px; font-size: 12px; width: 140px; }
.find:focus { outline: none; border-color: var(--accent); }
@media (max-width: 900px) { .find { flex: none; width: 120px; } }

text.uslbl.live { fill: #fff; font-size: 10px; font-weight: 700; paint-order: stroke; stroke: #0009; stroke-width: 3px; }
path.state.supported[fill] { stroke: #0d1016; }

/* ---------------------------------------------------------------- board (front page) */
.boardbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chips button { background: var(--bg2); border: 1px solid var(--line2); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chips button:hover { color: var(--ink); border-color: #4a5568; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips button span { font-size: 11px; font-weight: 600; opacity: .6; font-variant-numeric: tabular-nums; }
.chips.yr button { border-radius: 7px; letter-spacing: .02em; }
.chips + .chips { padding-left: 10px; border-left: 1px solid var(--line); }
.ldot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.6s infinite; }

body.boardmode .racebar, body.boardmode #tabs { display: none; }
body.boardmode .panel { display: flex; flex-direction: column; }
body.boardmode #tabbody { flex: 1; overflow: auto; }

.bsum { display: grid; gap: 8px; }
.bsum-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bsum-h b { font-size: 20px; letter-spacing: .01em; }
.bsum-h span { color: var(--ink3); font-size: 12px; }
.tally { display: flex; gap: 8px; flex-wrap: wrap; }
.tl { display: flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--c) 18%, var(--bg2)); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.tl b { font-size: 22px; line-height: 1; color: #fff; }
.tl span { font-size: 12px; color: var(--ink2); }
.tally-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--bg3); }

.btools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; position: sticky; top: 0; background: var(--bg2); padding: 2px 0 8px; z-index: 1; }
.btools .find { flex: 1; min-width: 0; }
.bgrid { display: grid; gap: 8px; }
.bcard { all: unset; box-sizing: border-box; display: grid; gap: 5px; padding: 9px 11px 8px; border-radius: 10px; cursor: pointer; border: 1px solid var(--line2);
  background: linear-gradient(100deg, color-mix(in srgb, var(--wash) 26%, var(--bg2)) 0%, var(--bg2) 55%); }
.bcard:hover { border-color: color-mix(in srgb, var(--wash) 70%, #fff 0%); transform: translateY(-1px); }
.bcard:focus-visible { outline: 2px solid var(--accent); }
.bh { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); }
.bst { font-weight: 800; color: var(--ink); background: #0006; border-radius: 4px; padding: 1px 6px; letter-spacing: .04em; font-size: 12px; }
.bt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blive { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: #fff; background: var(--live); padding: 1px 6px; border-radius: 3px; }
.bfin { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--ink3); border: 1px solid var(--line2); padding: 0 5px; border-radius: 3px; }
.br { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto 86px; gap: 8px; align-items: center; color: var(--ink2); }
.br.lead { color: var(--ink); font-weight: 700; }
.bp { width: 18px; height: 18px; border-radius: 4px; font-size: 11px; font-weight: 800; color: #fff; display: grid; place-items: center; }
.bn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.bpc { font-size: 15px; }
.br.lead .bpc { font-size: 17px; }
.bv { text-align: right; color: var(--ink3); font-size: 12px; font-weight: 400; }
.bsplit { display: flex; height: 4px; border-radius: 2px; overflow: hidden; gap: 1px; margin-top: 1px; }
.bf { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink3); }
.bm { color: var(--ink2); font-weight: 700; margin-right: auto; }
.bin { width: 54px; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.bin i { display: block; height: 100%; background: var(--ink2); }
.bu { color: var(--ink3); }
text.uslbl { font-size: 10px; font-weight: 800; letter-spacing: .03em; }
@media (max-width: 900px) { .boardbar { padding: 6px 10px; } .chips + .chips { padding-left: 0; border-left: 0; } }
body.boardmode .top .sel { display: none; }
@media (max-width: 900px) {
  .boardbar { flex-direction: column; align-items: stretch; gap: 6px; }
  .boardbar .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .boardbar .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; }
}
details.nofeed { margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg); font-size: 12px; color: var(--ink2); }
details.nofeed summary { cursor: pointer; list-style: none; }
details.nofeed summary::before { content: "▸ "; color: var(--ink3); }
details.nofeed[open] summary::before { content: "▾ "; }
.nfg { display: grid; gap: 4px; margin-top: 8px; }
.nfg > span { color: var(--ink3); }
.nfg div { display: flex; flex-wrap: wrap; gap: 4px; }
.nfg i { font-style: normal; font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg3); border: 1px solid var(--line2); color: var(--ink2); }
body.boardmode path.state { stroke: #323b4a; }
.fliptag { margin-top: 3px; font-size: 11px; font-weight: 700; color: #f5c542; }
.bflip { font-size: 10px; font-weight: 800; letter-spacing: .06em; color: #111; background: #f5c542; padding: 1px 6px; border-radius: 3px; }
.bvia { font-size: 10px; font-weight: 700; color: var(--ink2); border: 1px dashed var(--line2); padding: 0 5px; border-radius: 3px; }
