:root {
  --bg: #f8f9fa; --card: #fff; --ink: #202122; --muted: #54595d; --edge: #a2a9b1; --line: #eaecf0;
  --accent: #36c; --accent-dark: #2a4b8d; --accent-soft: #eaf3ff; --warn-bg: #fef6e7; --warn-edge: #fc3;
  --good: #14866d; --link: #36c; --red: #d33;
  --font: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --serif: 'Linux Libertine', 'Georgia', 'Times', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); min-height: 100vh; }
[hidden] { display: none !important; }

.bar { background: #fff; border-bottom: 1px solid var(--edge); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-family: var(--serif); font-size: 22px; color: var(--ink); text-decoration: none; }
#barRight { font-size: 13px; color: var(--muted); }
#app { max-width: 1000px; margin: 0 auto; padding: 16px; }
.panel { background: var(--card); border: 1px solid var(--edge); border-radius: 2px; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; }
.panel.wide { max-width: 720px; }
h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; border-bottom: 1px solid var(--edge); padding-bottom: 4px; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.btn { font: inherit; font-weight: 700; border: 1px solid var(--accent); border-radius: 2px; padding: 10px 18px; background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { background: var(--accent-dark); }
.btn:disabled { background: #c8ccd1; border-color: #c8ccd1; cursor: not-allowed; }
.btn.ghost { background: var(--bg); border-color: var(--edge); color: var(--ink); }
.btn.ghost:hover { background: var(--line); }
.btn.small { padding: 5px 12px; font-size: 13px; }
input, select { font: inherit; border: 1px solid var(--edge); border-radius: 2px; padding: 8px 10px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { font-size: 14px; font-weight: 600; }

.tag { font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); border: 1px solid #c8ccd1; border-radius: 2px; padding: 1px 6px; white-space: nowrap; }
.player { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--edge); border-radius: 2px; padding: 3px 10px 3px 3px; font-weight: 600; font-size: 14px; }
.player.off { opacity: .45; }
.face { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; font-size: 14px; font-weight: 700; color: var(--muted); flex: none; overflow: hidden; }
.mog { position: relative; display: block; width: 100%; height: 100%; }
.mog img { position: absolute; }
.face.sm { width: 22px; height: 22px; }
.face.lg { width: 38px; height: 38px; }

/* vote */
.opt { border: 1px solid var(--edge); border-radius: 2px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; background: #fff; font: inherit; text-align: left; width: 100%; color: var(--ink); }
.opt:hover { background: var(--bg); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt b { font-family: var(--serif); font-size: 18px; font-weight: 700; }
.opt small { color: var(--muted); display: block; font-size: 13px; }
.voters { display: flex; gap: 2px; flex: none; }

/* race */
.race { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
.card { background: #fff; border: 1px solid var(--edge); border-radius: 2px; padding: 12px; }
.goal { font-size: 12px; color: var(--muted); }
.goal b { display: block; font-family: var(--serif); font-size: 24px; font-weight: 400; color: var(--ink); line-height: 1.15; }
.clicks { text-align: center; font-weight: 700; }
.clicks span { font-family: var(--serif); font-size: 40px; display: block; line-height: 1; }
.clicks small { font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.ticker { display: flex; flex-direction: column; gap: 6px; }
.t { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; background: var(--bg); border: 1px solid var(--edge); border-radius: 2px; padding: 3px 10px 3px 3px; }
.t .n { margin-left: auto; font-family: var(--serif); font-size: 18px; }
.t.done { border-color: var(--good); color: var(--good); background: #fff; }
.t.out { opacity: .5; }
.banner { background: var(--warn-bg); border: 1px solid var(--warn-edge); text-align: center; padding: 8px; font-size: 14px; border-radius: 2px; }
.banner b { color: var(--red); font-size: 18px; }
.articleWrap { background: #fff; border: 1px solid var(--edge); border-radius: 2px; min-height: 420px; position: relative; }
.article { padding: 16px 20px 24px; line-height: 1.65; font-size: 15px; overflow-wrap: anywhere; }
.article h1 { font-size: 30px; line-height: 1.25; margin-bottom: 12px; border-bottom: 1px solid var(--edge); }
.article h2 { font-size: 22px; margin: 20px 0 8px; }
.article h3, .article h4 { font-family: var(--serif); font-weight: 700; margin: 16px 0 6px; }
.article .mw-heading { margin: 0; }
.article .w::before { content: attr(data-w); }
.article a[data-title] { color: var(--link); cursor: pointer; }
.article a[data-title]:hover { text-decoration: underline; }
.article ul, .article ol { padding-left: 24px; }
.article blockquote { margin: 8px 0 8px 16px; color: var(--muted); }
.cover { background: #fff; text-align: center; padding: 70px 20px; }
.cover .big { font-family: var(--serif); font-size: 64px; line-height: 1; }
.cover h2 { border: 0; }
.loading { opacity: .45; pointer-events: none; }

/* results */
.rrow { border: 1px solid var(--edge); border-radius: 2px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.rrow.first { border-color: var(--accent); background: var(--accent-soft); }
.rrow .head { display: flex; align-items: center; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.rrow .pts { margin-left: auto; font-family: var(--serif); font-size: 20px; color: var(--accent); }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; }
.path i { font-style: normal; background: #fff; border: 1px solid var(--edge); color: var(--link); border-radius: 2px; padding: 1px 6px; }
.path i.end { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.path s { text-decoration: none; color: var(--muted); }
.scores .rrow { flex-direction: row; align-items: center; gap: 8px; padding: 6px 12px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #202122; color: #fff; padding: 10px 16px; border-radius: 2px; font-size: 14px; z-index: 9; max-width: 90vw; }

@media (max-width: 760px) {
  #app { padding: 10px; }
  .race { grid-template-columns: 1fr; }
  .side { position: static; order: -1; }
  .side .ticker { flex-direction: row; overflow-x: auto; }
  .side .t { flex: none; }
  .article { padding: 12px 14px 20px; }
  .article h1 { font-size: 26px; }
}
