:root {
  --bg: #f6f1e7;
  --panel: #fffaf1;
  --panel-2: #f0e8d8;
  --ink: #1d1a24;
  --muted: #6b6474;
  --line: #e1d6c2;
  --gold: #a87a1c;
  --gold-soft: #f1e2bd;
  --live: #d7263d;
  --yes: #1f8a5b;
  --no: #b4413a;
  --maybe: #a87a1c;
  --amber: #e0663f;
  --maura: #138a76;
  --ezra: #3d6fd8;
  --tatyana: #a64bc0;
  --connor: #6f9a1c;
  --shadow: 0 1px 2px rgb(40 30 10 / 6%), 0 8px 24px rgb(40 30 10 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100e17;
    --panel: #1a1724;
    --panel-2: #241f31;
    --ink: #f2ecdf;
    --muted: #a49cb2;
    --line: #2f2940;
    --gold: #e2b85a;
    --gold-soft: #3a2f17;
    --live: #ff4d63;
    --yes: #46c98a;
    --no: #f07167;
    --maybe: #e2b85a;
    --amber: #ff8a5c;
    --maura: #3fd0b4;
    --ezra: #7aa2ff;
    --tatyana: #d084ee;
    --connor: #a8d84e;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100e17; --panel: #1a1724; --panel-2: #241f31; --ink: #f2ecdf; --muted: #a49cb2; --line: #2f2940;
  --gold: #e2b85a; --gold-soft: #3a2f17; --live: #ff4d63; --yes: #46c98a; --no: #f07167; --maybe: #e2b85a;
  --amber: #ff8a5c; --maura: #3fd0b4; --ezra: #7aa2ff; --tatyana: #d084ee; --connor: #a8d84e; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Manrope", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0.4rem 0; }
a { color: var(--gold); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

header.top { padding: 22px 0 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.ball {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background:
    conic-gradient(from 20deg, #fff8 0 8%, transparent 8% 16%, #fff5 16% 24%, transparent 24% 33%, #fff7 33% 41%, transparent 41% 50%, #fff4 50% 58%, transparent 58% 66%, #fff6 66% 75%, transparent 75% 83%, #fff5 83% 91%, transparent 91%),
    radial-gradient(circle at 35% 30%, #fff 0, #d9d4e6 18%, #8f88a3 55%, #4b4560 100%);
  box-shadow: inset -4px -6px 10px #0004;
}
.brand h1 { font-size: 1.6rem; line-height: 1.1; }
.brand .sub { color: var(--muted); font-size: 0.9rem; }
.statusbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; font-size: 0.88rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; }
.pill.live { background: var(--live); color: #fff; }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

header.top { padding-top: calc(22px + env(safe-area-inset-top)); }
body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs .wrap { display: grid; grid-template-columns: repeat(4, 1fr); padding: 0 6px; }
nav.tabs a { padding: 14px 2px 12px; text-align: center; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.86rem; border-top: 3px solid transparent; -webkit-tap-highlight-color: transparent; }
nav.tabs a.on { color: var(--ink); border-color: var(--gold); }
.ph { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--c, var(--line)); background: var(--panel-2); }
.who.has-ph, .nm-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }

main section { display: none; padding: 18px 0 40px; }
main section.on { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card > h2, .card > h3 { margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 0.9rem; }

/* win chances */
.odds { display: grid; gap: 10px; margin-top: 10px; }
.odd { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 10px; }
.odd .who { font-weight: 800; }
.odd .who small { display: block; color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.bar { height: 16px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.odd .pct { font-family: "Fraunces", serif; font-size: 1.35rem; font-weight: 600; text-align: right; }

/* scoreboard */
.board { display: grid; gap: 10px; margin-top: 10px; }
.row { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px 10px 0; border-radius: 10px; background: var(--panel-2); }
.row .sw { align-self: stretch; border-radius: 10px 0 0 10px; }
.row .nm { font-weight: 800; }
.row .nm small { color: var(--muted); font-weight: 500; }
.dots { display: flex; gap: 5px; margin-top: 4px; }
.dots span { font-size: 0.75rem; padding: 1px 7px; border-radius: 6px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.dots span.done { color: var(--ink); border-color: var(--gold); }
.row .num { text-align: right; }
.row .num b { font-family: "Fraunces", serif; font-size: 1.4rem; }
.row .num small { display: block; color: var(--muted); font-size: 0.75rem; }

/* paths */
details.path { border-top: 1px solid var(--line); padding: 10px 0; }
details.path:first-of-type { border-top: 0; }
details.path summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; }
details.path summary::-webkit-details-marker { display: none; }
details.path summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; }
details.path[open] summary::after { content: "−"; }
.paths-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.paths-list li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; font-size: 0.93rem; padding: 6px 8px; border-radius: 8px; background: var(--panel-2); }
.paths-list li b { white-space: nowrap; }
.paths-list li.yes b { color: var(--yes); }
.paths-list li.no { opacity: 0.6; }
.paths-list li.no b { color: var(--no); }
.paths-list li.maybe b { color: var(--maybe); }
.paths-list li small { display: block; color: var(--muted); }
.tag { font-size: 0.75rem; font-weight: 700; color: var(--muted); }

/* vote order builder */
.builder { display: grid; gap: 6px; margin-top: 10px; }
.bitem { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel-2); border-radius: 10px; }
.bitem .pos { font-weight: 800; color: var(--muted); }
.bitem button, .btn { font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; min-width: 40px; min-height: 36px; }
.bitem button:disabled { opacity: 0.3; }
.result { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--gold-soft); }
.result ol { margin: 6px 0 0; padding-left: 22px; }

/* stacked vote rank */
.stack { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin: 4px 0 2px; }
.stack i { display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 0.72rem; font-weight: 800; color: #fff; }
.vr { margin: 12px 0; }
.vr .head { display: flex; justify-content: space-between; font-weight: 800; }
.vr .head span { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.ev { display: grid; gap: 8px; margin-top: 8px; }
.ev div { padding: 8px 10px; border-left: 4px solid var(--gold); background: var(--panel-2); border-radius: 0 8px 8px 0; font-size: 0.93rem; }

.pop { display: grid; gap: 6px; margin-top: 10px; }
.pop .odd { grid-template-columns: 96px 1fr 40px; }
.pop .bar { height: 10px; }
.pop .out { opacity: 0.55; }

/* tables */
.scroll { overflow-x: auto; margin-top: 10px; border-radius: 10px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel-2); font-size: 0.78rem; color: var(--muted); }
td:first-child, th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); font-weight: 700; }
th:first-child { background: var(--panel-2); }
td.hi { color: var(--yes); font-weight: 800; }
td.lo { color: var(--no); font-weight: 800; }
td.x { color: var(--muted); }
details.week { border-top: 1px solid var(--line); padding: 10px 0; }
details.week summary { cursor: pointer; font-weight: 800; }
.dance { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.92rem; }
.dance:last-child { border-bottom: 0; }
.dance small { color: var(--muted); }
.dance .sc { text-align: right; font-weight: 800; }
.dance .sc small { display: block; font-weight: 500; }

.prose p { margin: 0.6rem 0; }
.prose ul { padding-left: 20px; }
.prose li { margin: 4px 0; }
footer { color: var(--muted); font-size: 0.82rem; padding: 24px 0 40px; border-top: 1px solid var(--line); }
.banner { padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); font-size: 0.92rem; margin-top: 10px; }
.reveal { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reveal span { padding: 4px 10px; border-radius: 999px; background: var(--panel-2); font-size: 0.85rem; font-weight: 700; }

@media (max-width: 420px) {
  .odd { grid-template-columns: 78px 1fr 54px; gap: 8px; }
  .odd .pct { font-size: 1.15rem; }
  .paths-list li { grid-template-columns: 1fr; gap: 2px; }
}
.odds.with-ph .odd { grid-template-columns: 136px 1fr 56px; }
.row .ph { width: 44px; height: 44px; }
.bitem .ph { width: 30px; height: 30px; border-width: 1.5px; }
