:root {
  --paper: #f4f8f7;
  --ink: #202e32;
  --muted: #52636a;
  --rule: #d9e5e2;
  --rule-strong: #8ba09e;
  --primary: #14685e;
  --accent: #a13c50;
  --shade: #e4f0ed;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --surface: #fff;
  --wash: #e7f2ef;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
a { color: var(--primary); text-underline-offset: .18em; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.wrap { width: min(100% - 64px, 1110px); margin-inline: auto; }
h2 { font-size: clamp(1.35rem, 3vw, 2.15rem); line-height: 1.22; letter-spacing: -.025em; }
h3 { font-size: 1rem; }
.note, .readout { font-size: .875rem; color: var(--muted); margin-top: 7px; }
.note:empty { display: none; }

.live-header {
  padding-block: 30px 10px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 1.5rem;
  align-items: end;
}
.live-title small { display: block; color: var(--primary); font-size: .73rem; font-weight: 750; letter-spacing: .12em; }
.live-title h1 {
  margin-block: .12em .02em;
  font: 600 clamp(2.1rem, 4.6vw, 3.65rem)/1.07 var(--sans);
  letter-spacing: -.052em;
}
.live-title h1 em { font-size: .8em; font-style: normal; font-weight: 550; color: var(--ink); }
.title-join { font-size: .54em; font-weight: 400; padding-inline: .09em; }
.deadline {
  padding-inline-start: 12px;
  min-width: 170px;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.deadline-clock { display: grid; }
.deadline-clock > span, .deadline-times { font-size: .75rem; }
.deadline-clock strong { font: 600 clamp(1.35rem, 3vw, 2rem)/1.12 var(--sans); white-space: nowrap; }
.deadline-times { color: var(--muted); margin-top: 2px; }
.deadline[data-stage=three], .deadline[data-stage=day], .deadline[data-stage=final] { color: var(--accent); }
.deadline[data-stage=final] #countdown span { font-size: 1.26em; }

.freshness-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-height: 43px;
  color: var(--muted);
  font-size: .79rem;
}
.freshness-row button { margin-left: auto; }
.freshness-source { font-variant-numeric: tabular-nums; }
.freshness-source[data-freshness=red] { color: var(--accent); font-weight: 700; }

button {
  border: 0;
  border-radius: 7px;
  background: var(--shade);
  padding: 4px 10px;
  min-height: 32px;
  color: var(--primary);
  font-size: .83rem;
  font-weight: 650;
  white-space: nowrap;
}
button:hover { background: #d6e8e3; }
button:disabled { opacity: .55; cursor: wait; }
.method-switch {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .65rem;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: .83rem;
}
select, input[type=number] {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 5px 7px;
  min-height: 32px;
  max-width: 100%;
}
select { color: var(--primary); }

#state { container: dashboard / inline-size; }
.dashboard-lead {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
  align-items: start;
}
.main-overview {
  container: overview / inline-size;
  display: grid;
  grid-template-columns: minmax(0,5fr) minmax(0,4fr);
  gap: 13px 18px;
  align-items: center;
  padding: clamp(15px, 2.3vw, 25px);
  border-radius: 18px;
  background: var(--wash);
}
.main-overview > div { grid-column: 1 / -1; min-width: 0; }
.verdict-status {
  display: block;
  font-size: .78rem;
  font-weight: 750;
  color: var(--muted);
  letter-spacing: .01em;
}
.verdict[data-status=ahead] .verdict-status,
.verdict[data-status=closing] .verdict-status { color: var(--primary); }
.verdict[data-status=widening] .verdict-status { color: var(--accent); }
.verdict-head { margin-bottom: 3px; }
.gap-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 9px; }
.gap-trend { color: var(--muted); font-size: .83rem; font-weight: 500; white-space: nowrap; }
.verdict-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 9px; }
.hero-rank { display: block; font-size: clamp(1.1rem, 2.1vw, 1.55rem); font-weight: 650; }
.hero-gap {
  display: block;
  color: var(--primary);
  font: 730 clamp(2rem, 8.8cqi, 4rem)/1.1 var(--sans);
  letter-spacing: -.062em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.verdict[data-position=behind] .hero-gap { color: var(--accent); }


#gap-paths h3 { font-size: .9rem; }
.path-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px 10px; margin-top: 2px; }
.path-card { display: grid; grid-row: 1 / span 3; grid-template-rows: subgrid; align-items: baseline; }
.path-card > span { font-size: clamp(.75rem, 2.75cqi, .83rem); color: var(--muted); }
.path-card strong {
  font: 710 clamp(1.55rem, 2.6vw, 2.25rem)/1.15 var(--sans);
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.path-card.platform-emphasis strong { color: var(--primary); }
.platform-bar { height: 4px; margin-top: 2px; background: #d5e4e0; border-radius: 3px; overflow: hidden; }
.platform-bar > span { display: block; height: 100%; background: var(--rule-strong); }
.platform-emphasis .platform-bar > span { background: var(--primary); }
#gap-paths .note { margin-top: 4px; font-size: .76rem; }
#explanation p { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--muted); font-size: .83rem; line-height: 1.45; }
#explanation p > span + span { white-space: nowrap; }
#explanation p strong { color: var(--primary); }

.card { min-width: 0; margin-bottom: 30px; }
.dashboard-lead .battlefields { margin-bottom: 0; padding: 10px 0 0; }
.ranking-panel, .budget, .daily-panel { margin-bottom: 12px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 10px; }
.ranking-panel { padding-block: 10px; }
.budget { background: var(--wash); }
#ranking-toggle { margin-top: 6px; }
#ranking .combined-rate { color: var(--primary); font-weight: 750; }
.ranking-panel > summary, .budget > summary, .daily-panel > summary { padding-block: 10px; }
.ranking-panel[open], .budget[open], .daily-panel[open] { padding-bottom: 12px; }
.daily-panel { margin-bottom: 22px; }
#daily-votes { margin-top: 6px; }
#daily-votes th, #daily-votes td { padding-inline: 10px; }
#daily-votes th:first-child { position: sticky; left: 0; background: var(--paper); min-width: 7rem; }
#daily-votes tbody th { white-space: normal; }
#daily-votes .anton-row th:first-child { background: var(--shade); }
#daily-votes th small { display: block; font-weight: 500; }
.daily-rank { display: inline-block; min-width: 1.3em; color: var(--muted); }
.complete { margin-top: 22px; }

.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.segments { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; background: var(--shade); border-radius: 9px; padding: 3px; }
.segments button { color: var(--muted); background: transparent; font-weight: 500; }
.segments button[aria-pressed=true] { color: var(--primary); background: var(--surface); font-weight: 750; }
.good { color: var(--primary); }
.bad { color: var(--accent); }

table { width: 100%; border-collapse: collapse; text-align: right; font-variant-numeric: tabular-nums; font-size: .87rem; }
th, td { padding: 7px 8px; white-space: nowrap; border: 0; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
thead { color: var(--muted); font-size: .78rem; border-bottom: 1px solid var(--rule); }
#ranking thead th:nth-child(2), #ranking tbody th { text-align: left; }
.battlefields table { margin-top: 2px; }
.battlefields th, .battlefields td { padding-block: 4px; }
.battlefields th { white-space: normal; }
.battlefields td { font-weight: 720; font-size: 1.05rem; white-space: normal; }
.vote-share-change { display: inline-block; margin-inline-start: .35em; color: var(--muted); font-size: .73rem; font-weight: 550; }
.battle-trend-heading { margin-top: 5px; flex-wrap: wrap; }
.battlefields .segments button { padding-inline: 7px; }
.table-scroll { overflow-x: auto; }
.platform-rank strong, .platform-rank small { display: block; }
.platform-rank small { color: var(--muted); font-size: .73rem; }
.anton-row { color: var(--primary); font-weight: 700; background: var(--shade); }

details > summary { color: var(--ink); font-size: 1rem; font-weight: 700; padding-block: 6px; }
details[open] > summary { margin-bottom: 9px; }
.compare-controls { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px 15px; margin-top: 7px; }
.peer-control, .compare-controls label { color: var(--muted); font-size: .82rem; }
.chart-shell, .momentum-chart { position: relative; margin-top: 5px; min-height: 36px; }
.chart-shell svg, .momentum-chart svg { display: block; width: 100%; touch-action: pan-y; }
.chart-shell svg { height: auto; }
.momentum-chart svg { height: auto; }
.momentum-readout {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 7px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: .75rem;
  font-weight: 650;
  pointer-events: none;
}
.momentum-readout[data-side=left] { right: auto; left: 5px; }

.chart-shell text, .momentum-chart text { fill: var(--muted); font-size: 11px; }
.momentum-chart polyline { fill: none; stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.momentum-chart circle { fill: var(--primary); stroke: var(--paper); }
.momentum-chart .endpoint { fill: var(--ink); font-weight: 700; }
.momentum-chart .window-shade { fill: var(--shade); }
.grid, .momentum-zero, .crosshair { stroke: var(--rule); stroke-width: 1; }
.momentum-zero, .crosshair { stroke: var(--rule-strong); stroke-dasharray: 4 3; }
.momentum-times { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .79rem; }
.momentum-times span:last-child { text-align: right; }


.inputs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-block: 9px; }
.inputs label { min-width: 0; font-size: .86rem; font-weight: 650; }
input[type=number] { display: block; width: 100%; }
.strategies { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 20px; margin-top: 12px; }
.strategy { padding-top: 6px; }
.strategy-votes { font: 600 1.65rem/1.3 var(--sans); color: var(--primary); }
.strategy-votes small, .strategy p { font: .83rem/1.5 var(--sans); color: var(--muted); }
.candidate-list { display: flex; flex-wrap: wrap; gap: 4px 13px; margin-top: 7px; }
.candidate { display: flex; align-items: center; gap: 5px; font-size: .81rem; padding-block: 3px; min-height: 30px; cursor: pointer; }
.candidate:has(input:checked) { color: var(--primary); font-weight: 700; }
.candidate input { flex: 0 0 14px; inline-size: 14px; block-size: 14px; accent-color: var(--primary); margin: 0; }
.more-candidates { margin-top: 6px; }
.more-candidates > summary { font-size: .85rem; }
.comparison-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.comparison-legend { display: flex; flex-wrap: wrap; column-gap: 14px; }
.comparison-legend span, .comparison-time { font-size: .79rem; color: var(--muted); }
.comparison-legend svg { display: inline-block; width: 24px; height: 8px; vertical-align: middle; margin-right: 4px; }
.comparison-legend b, .comparison-legend strong { color: var(--ink); }

.formulas { padding-left: 18px; margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
footer { padding-block: 10px 28px; color: var(--muted); font-size: .78rem; }
.settings h2 { font-size: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.chart-cursor:focus-visible { width: calc(100% - 24px); height: 18px; clip: auto; bottom: 20px; left: 12px; }

@container dashboard (min-width: 51rem) {
  .dashboard-lead { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: clamp(13px, 2vw, 24px); }
  .dashboard-lead .battlefields { padding-top: 12px; }
  .battlefields h2 { font-size: 1.3rem; }
}
@container overview (min-width: 33rem) {
  #verdict-summary { grid-column: 1; }
  #gap-paths { grid-column: 2; }
}
@media (max-width: 690px) {
  .wrap { width: calc(100% - 30px); }
  .live-header { padding-block: 11px 8px; gap: 10px; }
  .live-title small { font-size: .58rem; letter-spacing: .07em; }
  .live-title h1 { font-size: clamp(1.5rem, 5.5vw, 2.1rem); }
  .deadline { min-width: 0; padding-left: 8px; }
  .deadline-clock strong { font-size: clamp(.94rem, 3.8vw, 1.25rem); }
  .deadline-clock > span, .deadline-times { font-size: .65rem; }
  .freshness-row { flex-wrap: wrap; gap: 4px 8px; font-size: .72rem; min-height: 36px; }
  .method-switch { margin-top: 6px; }
  .dashboard-lead { gap: 13px; margin-bottom: 16px; }
  .dashboard-lead .battlefields { padding-top: 0; }
  .main-overview { gap: 9px; padding: 13px 14px; }
  .hero-gap { font-size: clamp(1.8rem, 10.4cqi, 3.55rem); }
  .gap-trend { font-size: clamp(.75rem, 4.15cqi, .95rem); }
  #explanation p { display: grid; gap: 0; }

  .card { margin-bottom: 17px; }
  .ranking-panel, .budget, .daily-panel { margin-bottom: 9px; }
  .section-heading { flex-wrap: wrap; }
  .inputs { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .momentum-times { font-size: .73rem; }
  .battlefields th, .battlefields td { padding-inline: 4px; }
  #ranking table { table-layout: fixed; min-width: 34rem; }
  #ranking .rank-col { width: 2.25rem; }
  #ranking .name-col { width: 5.6rem; }
  #ranking th, #ranking td { padding-inline: 4px; }
  #ranking tbody th { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
}
