:root {
  --bg: #f6f2ea;
  --panel: #fffdf8;
  --ink: #1d1a17;
  --ink-2: #4a443d;
  --muted: #6d655b;
  --line: #e2d9cb;
  --grid: #ebe4d8;
  --chip: #efe7da;
  --accent: #a3242c;
  /* sides (marks only; validated as a pair against --panel) */
  --mafia: #a3242c;
  --town: #9a7a2e;
  /* rule sets (categorical, validated all-pairs against --panel) */
  --sport: #4a3aa7;
  --open: #1baf7a;
  --imbalanced: #eb6834;
  /* diverging: above / below average, gray midpoint */
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --div-mid: #f0efec;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121012; --panel: #1b181b; --ink: #efe8dc; --ink-2: #cfc6b8; --muted: #a39a8e; --line: #2f2a2e; --grid: #2a262a;
    --chip: #262126; --accent: #e0565e;
    --mafia: #bf3442; --town: #ad8c36;
    --sport: #9085e9; --open: #199e70; --imbalanced: #d95926;
    --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #383835;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121012; --panel: #1b181b; --ink: #efe8dc; --ink-2: #cfc6b8; --muted: #a39a8e; --line: #2f2a2e; --grid: #2a262a;
  --chip: #262126; --accent: #e0565e;
  --mafia: #bf3442; --town: #ad8c36;
  --sport: #9085e9; --open: #199e70; --imbalanced: #d95926;
  --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #383835;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; overflow-x: hidden; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4.4vw, 44px); margin: 40px 0 8px; }
h2 { font-size: 26px; margin: 64px 0 12px; }
h3 { font-size: 18px; margin: 0 0 8px; }
h3.sub { margin: 32px 0 10px; }
p { max-width: 72ch; }
.lede { font-size: 17px; color: var(--muted); margin-top: 0; }
section { scroll-margin-top: 72px; }

header.site { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-family: Fraunces, Georgia, serif; font-size: 19px; font-weight: 600; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mafia); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mafia) 20%, transparent); }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 5px 9px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14px; }
nav a:hover { color: var(--ink); background: var(--chip); }

footer.site { border-top: 1px solid var(--line); margin-top: 72px; padding: 20px 0 36px; }
.fine { font-size: 12px; color: var(--muted); max-width: 90ch; }
.fine a { color: var(--muted); }

/* KPI tiles: sans, proportional figures */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 22px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.card .k { font-size: 13px; color: var(--muted); }
.card .v { font-size: 28px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.card .s { font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr 1fr; } }

.rulecards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; margin: 18px 0; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.rule h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.rule ul { margin: 8px 0 0; padding-left: 18px; }
.rule li { margin: 5px 0; font-size: 14px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.key.sport { background: var(--sport); } .key.open { background: var(--open); } .key.imbalanced { background: var(--imbalanced); }
.key.mafia { background: var(--mafia); } .key.town { background: var(--town); }
.key.line { width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; }

/* filters: one row, segmented controls */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 14px 0; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel); line-height: 1.3; vertical-align: bottom; }
th.l, td.l { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--chip) 60%, transparent); }
td .lab { display: block; font-size: 12px; color: var(--muted); }
td .name { font-weight: 600; }
td.rank { color: var(--muted); width: 32px; }
.se { color: var(--muted); font-size: 12px; }
.note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.score { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.score svg { margin-left: auto; flex: none; }
.dim td { color: var(--muted); }

figure { margin: 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 10px; }
figure svg { display: block; width: 100%; height: auto; overflow: visible; }
svg text { fill: var(--ink); font: 12px Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
svg .muted { fill: var(--muted); }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .base { stroke: var(--line); stroke-width: 1; }
svg [data-t] { cursor: default; }
svg [data-t]:hover, svg [data-t]:focus { opacity: .8; outline: none; }
.legend { display: flex; gap: 6px 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 24px; }
.multiples h4 { margin: 0 0 4px; font: 600 13px Inter, system-ui, sans-serif; }
details.tableview { margin: -4px 0 0; }
details.tableview summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 6px 0 4px; }
.pod { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.pod .r { font-size: 12px; color: var(--muted); }
.pod .n { font-weight: 600; margin: 2px 0; }
.pod .v { font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.pod .s { font-size: 12px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.pairs .tablewrap td { padding: 8px 10px; }
.pairs .pair { white-space: normal; min-width: 150px; text-align: left; }
.pairs .pair > span { display: block; }
.pairs .vs { color: var(--muted); font-size: 12px; }
figure.heat { margin-top: 32px; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.scale .ramp { flex: 1; height: 8px; border-radius: 4px; min-width: 120px; }

.prose p, .prose li { max-width: 72ch; }
.prose li { margin: 4px 0; }
.prose h3 { margin: 28px 0 8px; }

.quote { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.quote blockquote { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 17px; line-height: 1.5; }
.quote .who { font-size: 13px; color: var(--muted); }
.quote .ctx { font-size: 14px; }
.quote h3 { margin-bottom: 0; }
.quote .big { font-size: 34px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }

#tip { position: fixed; z-index: 20; pointer-events: none; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 13px; max-width: 280px; line-height: 1.4; }
#tip .tv { font-weight: 600; font-size: 14px; }
#tip .tr { display: flex; align-items: center; gap: 6px; }
#tip .tl { color: var(--muted); }
.grid2.pairs.wide { grid-template-columns: 1fr; }
.grid2.pairs.wide figure.heat { max-width: 680px; margin-top: 8px; }
