/* Mass Poll: a league of duels, set like tournament paperwork.
   Cool white sheet, black ink rules, one canary-yellow pairing slip, crimson pen for corrections. */

@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(/fonts/barlow-condensed-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url(/fonts/barlow-condensed-800.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(/fonts/barlow-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url(/fonts/barlow-700.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(/fonts/jetbrains-mono-500.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 800; font-display: swap; src: url(/fonts/jetbrains-mono-800.woff2) format("woff2"); }

:root {
  color-scheme: light dark;
  --paper: #f3f4f5;
  --sheet: #ffffff;
  --ink: #101216;
  --ink-2: #4a515b;
  --hair: rgba(16, 18, 22, 0.16);
  --mark: #ffd52e;
  --mark-rgb: 255, 213, 46;
  --pen: #c9223a;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --text: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111316;
    --sheet: #1b1e23;
    --ink: #f1f2f4;
    --ink-2: #a5acb6;
    --hair: rgba(241, 242, 244, 0.18);
    --pen: #ff7385;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--ink) var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 17px/1.45 var(--text);
  font-variant-numeric: tabular-nums;
  caret-color: var(--ink);
  accent-color: var(--ink);
}
::selection { background: var(--mark); color: #101216; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.slip :focus-visible { outline-color: #101216; }

/* ---------- frame ---------- */
.top { border-bottom: 2px solid var(--ink); background: var(--paper); }
.top-in { max-width: 920px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  font: 800 1.45rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.02em;
  text-decoration: none; display: inline-flex; align-items: center; gap: 10px;
}
.brand::before { content: ""; width: 14px; height: 22px; background: var(--mark); border: 2px solid var(--ink); }
#nav { display: flex; gap: 14px; font: 800 0.95rem var(--display); text-transform: uppercase; letter-spacing: 0.06em; }
#nav a { text-decoration: none; padding: 8px 2px; border-bottom: 2px solid transparent; }
#nav a:hover { border-bottom-color: var(--ink); }
main { max-width: 920px; margin: 0 auto; padding: 0 16px 72px; }
.site-foot { max-width: 920px; margin: 0 auto; padding: 18px 16px 36px; border-top: 1px solid var(--hair); color: var(--ink-2); font: 500 0.8rem var(--mono); }

h1 { font: 800 clamp(2.3rem, 9vw, 3.9rem)/0.95 var(--display); text-transform: uppercase; letter-spacing: 0; margin: 26px 0 10px; text-wrap: balance; }
h2 { font: 800 1.35rem/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; margin: 38px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
p { max-width: 68ch; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.facts { font: 800 0.85rem var(--mono); text-transform: uppercase; letter-spacing: 0.02em; margin: 8px 0 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 8px 20px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--sheet); color: var(--ink); font: 800 1.05rem/1 var(--display);
  text-transform: uppercase; letter-spacing: 0.05em; text-decoration: none;
  transition: background-color 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--mark); color: #101216; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: var(--mark); color: #101216; }
.btn.danger { border-color: var(--pen); color: var(--pen); background: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--pen); color: var(--paper); }
.link-btn { background: none; border: 0; padding: 8px 4px; font: 500 0.8rem var(--mono); text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); }
.link-btn:hover { color: var(--ink); }
button, .btn, .pick { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- tiles (logo or initials) ---------- */
.chip {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 2px; flex: none;
  font: 800 1.7rem/1 var(--display); letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 2px #101216;
}
.chip.emoji { font-size: 2.5rem; }
.chip.logo { background: #fff; padding: 9px; }
.chip.logo img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; user-select: none; }

/* ---------- home: the wall chart ---------- */
.lede { font-size: 1.15rem; color: var(--ink-2); margin: 0 0 22px; }
.polls { border-top: 2px solid var(--ink); }
.poll-row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 8px 18px; align-items: center;
  padding: 20px 0; border-bottom: 1px solid var(--hair); text-decoration: none; color: inherit;
}
.poll-row:hover { background: rgba(var(--mark-rgb), 0.16); }
.tno {
  width: 56px; height: 56px; display: grid; place-items: center; background: var(--mark); color: #101216;
  border: 2px solid var(--ink); font: 800 1.15rem var(--mono);
}
.pr-title { font: 800 clamp(1.5rem, 5vw, 2.1rem)/1 var(--display); text-transform: uppercase; margin: 0 0 4px; }
.pr-desc { margin: 0 0 8px; color: var(--ink-2); max-width: 60ch; }
.pr-meta { font: 500 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.02em; color: var(--ink-2); margin-top: 8px; }
.preview { display: flex; gap: 5px; }
.preview .chip { width: 34px; height: 34px; font-size: 0.8rem; padding: 0; }
.preview .chip.logo { padding: 4px; }
.preview .chip.emoji { font-size: 1.1rem; }
.go { display: inline-flex; align-items: center; gap: 10px; font: 800 1.1rem var(--display); text-transform: uppercase; letter-spacing: 0.05em; }
.go::after { content: ""; width: 10px; height: 10px; border-top: 3px solid currentColor; border-right: 3px solid currentColor; transform: rotate(45deg); }
@media (max-width: 600px) {
  .poll-row { grid-template-columns: 44px 1fr; }
  .tno { width: 44px; height: 44px; font-size: 1rem; }
  .go { grid-column: 2; }
}

/* ---------- voting: the round strip ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; }
.cells { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.cells i { height: 16px; border: 2px solid var(--ink); background: transparent; transition: background-color 0.18s var(--ease); }
.cells i.on { background: var(--ink); }
.count { font: 800 0.85rem var(--mono); text-transform: uppercase; white-space: nowrap; }

.conf { margin: 2px 0 14px; }
.conf-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.conf-label { font: 800 0.85rem var(--display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.conf-text { font: 800 0.9rem var(--mono); text-transform: uppercase; }
.bar { position: relative; height: 14px; border: 2px solid var(--ink); background: var(--sheet); overflow: hidden; }
.bar > i { display: block; width: 100%; height: 100%; background: var(--mark); transform: scaleX(0); transform-origin: left; transition: transform 0.45s var(--ease); }
.bar::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--ink) calc(10% - 1px) 10%); opacity: 0.35; }
.conf-hint { display: block; font: 500 0.78rem var(--mono); margin-top: 6px; color: var(--ink-2); }

.banner, .notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--sheet); border: 2px solid var(--ink); padding: 12px 14px; margin: 14px 0;
}
.notice { display: block; padding: 18px; margin-top: 18px; }
.notice p { margin: 0 0 12px; }

/* ---------- the pairing slip ---------- */
.slip { background: var(--mark); color: #101216; border: 2px solid #101216; border-radius: 2px; box-shadow: 0 14px 26px -18px rgba(0, 0, 0, 0.55); margin-top: 12px; }
.slip-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 2px solid #101216; }
.board { font: 800 0.9rem var(--mono); background: #101216; color: var(--mark); padding: 3px 9px; text-transform: uppercase; white-space: nowrap; }
.question { font: 800 clamp(1.15rem, 4vw, 1.5rem)/1.05 var(--display); text-transform: uppercase; letter-spacing: 0.02em; }

.duel { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform 0.18s var(--ease); will-change: transform; }
.contender {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: #fff; color: #101216; border: 2px solid #101216; border-radius: 2px; padding: 22px 8px 6px;
  transition: opacity 0.16s, transform 0.16s var(--ease), outline-color 0.16s;
}
.contender .pick { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.contender:hover { outline: 3px solid #101216; outline-offset: -1px; }
.contender .chip { width: 92px; height: 92px; font-size: 2rem; }
.contender .chip.logo { padding: 10px; }
.contender .chip.emoji { font-size: 2.9rem; }
.contender .name { font: 800 clamp(1.3rem, 4.4vw, 1.7rem)/1 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.contender .native { font: 500 0.74rem var(--mono); color: #4a515b; text-transform: uppercase; letter-spacing: 0.01em; min-height: 1.1em; }
.contender .dk { margin-top: 8px; padding: 12px 8px; color: #4a515b; }
.contender .dk:hover { color: #101216; }

/* the result stamp between the two contenders: 1-0, 0-1, half-half */
.stamp {
  position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%) rotate(-5deg);
  min-width: 56px; padding: 8px 10px; background: #101216; color: var(--mark); border: 3px solid var(--mark);
  font: 800 1.05rem/1 var(--mono); text-align: center; pointer-events: none; white-space: nowrap;
}
.duel[data-picked] .stamp { animation: stamp 0.3s var(--ease) both; min-width: 76px; font-size: 1.3rem; }
@keyframes stamp {
  from { transform: translate(-50%, -50%) rotate(-5deg) scale(1.7); opacity: 0; }
  to { transform: translate(-50%, -50%) rotate(-5deg) scale(1); opacity: 1; }
}
.duel[data-picked="a"] .contender:first-child,
.duel[data-picked="b"] .contender:last-child { outline: 4px solid #101216; outline-offset: -1px; transform: translateY(-3px); }
.duel[data-picked="a"] .contender:last-child,
.duel[data-picked="b"] .contender:first-child { opacity: 0.32; transform: scale(0.97); }
.duel[data-picked="tie"] .contender { border-style: dashed; }
.duel[data-picked] { pointer-events: none; }
.duel[data-lean="a"] .contender:first-child,
.duel[data-lean="b"] .contender:last-child { outline: 3px solid #101216; outline-offset: -1px; }
.duel[data-lean="tie"] .contender { border-style: dashed; }

.tie-row { display: flex; gap: 10px; margin-top: 14px; }
.tie-row .back { flex: 0 0 auto; padding-inline: 18px; }
.tie-row .tie { flex: 1; }
.duel[data-picked="tie"] ~ .tie-row .tie { background: var(--mark); color: #101216; }
.keys { text-align: center; margin-top: 12px; font: 500 0.75rem var(--mono); color: var(--ink-2); text-transform: uppercase; }
.footnote { margin-top: 20px; color: var(--ink-2); font-size: 0.85rem; }

/* ---------- live ranking while voting ---------- */
.live { margin-top: 22px; background: var(--sheet); border: 2px solid var(--ink); padding: 0 14px 8px; }
.live > summary { cursor: pointer; padding: 10px 0; min-height: 46px; display: flex; align-items: center; font: 800 1.1rem var(--display); text-transform: uppercase; letter-spacing: 0.04em; }
.live-list { list-style: none; margin: 0; padding: 0; }
.live-row { display: grid; grid-template-columns: 26px 30px minmax(80px, 1.1fr) 1.4fr 42px; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--hair); font-size: 0.95rem; will-change: transform; }
.live-row .no { text-align: right; font: 800 0.95rem var(--mono); color: var(--ink-2); }
.live-row .chip { width: 30px; height: 30px; font-size: 0.72rem; padding: 0; box-shadow: inset 0 0 0 1.5px #101216; }
.live-row .chip.logo { padding: 3px; }
.live-row .chip.emoji { font-size: 1.05rem; }
.live-row .who { font: 800 1.05rem var(--display); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-row.unrated { opacity: 0.55; }
.live-row .live-note { grid-column: 4 / 6; font: 500 0.75rem var(--mono); color: var(--ink-2); }
.live-bar { height: 10px; background: var(--hair); }
.live-bar > i { display: block; height: 100%; }
.live-pct { text-align: right; font: 800 0.85rem var(--mono); }

/* ---------- results: the standings sheet ---------- */
.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-top: 14px; }
.tabs { display: inline-flex; border: 2px solid var(--ink); }
.tabs button { background: transparent; border: 0; padding: 10px 18px; min-height: 46px; font: 800 1.05rem var(--display); text-transform: uppercase; letter-spacing: 0.05em; }
.tabs button + button { border-left: 2px solid var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 500 0.78rem var(--mono); text-transform: uppercase; color: var(--ink-2); margin: 16px 0 0; }

.rank-list { list-style: none; margin: 14px 0 0; padding: 0; border-top: 2px solid var(--ink); }
.rank-row {
  display: grid; grid-template-columns: 34px 40px minmax(110px, 0.9fr) 2fr; gap: 6px 12px; align-items: center;
  padding: 12px 6px; border-bottom: 1px solid var(--hair);
}
.rank-list > .rank-row:first-child { background: rgba(var(--mark-rgb), 0.5); }
.rank-row .no { font: 800 1.2rem var(--mono); text-align: right; }
.rank-row .chip { width: 38px; height: 38px; font-size: 0.8rem; padding: 0; box-shadow: inset 0 0 0 2px #101216; }
.rank-row .chip.logo { padding: 4px; }
.rank-row .chip.emoji { font-size: 1.3rem; }
.rank-row .who b { display: block; font: 800 1.3rem/1 var(--display); text-transform: uppercase; }
.rank-row .who span { font: 500 0.72rem var(--mono); color: var(--ink-2); text-transform: uppercase; }
.meter { position: relative; height: 24px; }
.meter .track { position: absolute; inset: 11px 0; background: var(--hair); }
.meter .mid { position: absolute; top: 3px; bottom: 3px; width: 2px; background: var(--ink); opacity: 0.5; }
.meter .range { position: absolute; top: 7px; bottom: 7px; opacity: 0.4; }
.meter .dot { position: absolute; top: 4px; width: 16px; height: 16px; margin-left: -8px; border: 2px solid #101216; transform: rotate(45deg); }
.meter-label { grid-column: 3 / -1; font: 500 0.74rem var(--mono); color: var(--ink-2); margin-top: -2px; }
@media (max-width: 560px) {
  .rank-row { grid-template-columns: 26px 36px 1fr; }
  .rank-row .meter, .meter-label { grid-column: 1 / -1; }
}

/* head-to-head: a crosstable with a hatched diagonal */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; border: 2px solid var(--ink); font: 500 0.78rem var(--mono); }
.matrix th { font: 800 0.8rem var(--mono); padding: 6px 8px; background: var(--sheet); border: 1px solid var(--hair); }
.matrix td { min-width: 46px; height: 42px; text-align: center; border: 1px solid var(--hair); background: var(--sheet); }
.matrix td.self { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--hair) 5px 6px); }
.matrix td small { display: block; color: var(--ink-2); font-size: 0.62rem; line-height: 1; }
.cycles { margin: 6px 0 0; padding-left: 20px; }

/* ---------- share card ---------- */
.card-canvas { display: block; width: 100%; max-width: 540px; height: auto; margin: 12px 0; border: 2px solid var(--ink); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- reset ---------- */
.reset-row { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--hair); }
.reset { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- phones ---------- */
@media (max-width: 600px) {
  main { padding-bottom: 100px; }
  .is-voting > h1 { font-size: 1.7rem; margin: 14px 0 0; }
  .is-voting > h1 ~ .muted, .is-voting > .facts { display: none; }
  .is-voting .progress { margin: 10px 0 6px; }
  .duel { gap: 10px; padding: 12px; }
  .contender { padding: 18px 6px 4px; }
  .contender .chip { width: 80px; height: 80px; }
  .tie-row {
    position: sticky; bottom: 0; margin: 14px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--paper) 72%, transparent);
  }
  .live-row { grid-template-columns: 22px 28px 1fr 56px 38px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .duel, .contender, .cells i, .bar > i { transition: none; }
  .duel[data-picked] .stamp { animation: none; }
}

/* ---------- fixes from the first inspection round ---------- */
.pr-title { border: 0; padding: 0; margin: 0 0 4px; }
/* the stamp sits on the tiles, not over the names */
.duel { --stamp-top: 84px; }
.stamp { top: var(--stamp-top); }
@media (max-width: 600px) {
  .duel { --stamp-top: 70px; }
  .stamp { min-width: 46px; padding: 6px 8px; font-size: 0.95rem; }
  .duel[data-picked] .stamp { min-width: 62px; font-size: 1.15rem; }
  .is-voting .banner { flex-wrap: nowrap; padding: 8px 10px; margin: 10px 0; gap: 10px; font-size: 0.92rem; line-height: 1.25; }
  .is-voting .banner .btn { min-height: 40px; padding: 6px 12px; flex: none; font-size: 0.95rem; }
}

/* ---------- fixes from the finish review ---------- */
.matrix td small { font-size: 0.7rem; }
.matrix-key { font: 500 0.8rem/1.6 var(--mono); color: var(--ink-2); margin: 10px 0 0; max-width: none; overflow-wrap: anywhere; }
.contender .dk { min-height: 44px; padding: 10px 14px; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 600px) {
  /* the pinned bar is a solid ruled strip, not a fade: nothing ghosts through it */
  .tie-row { background: var(--paper); border-top: 2px solid var(--ink); }
  .meter-label, .rank-row .who span, .pr-meta, .live-row .live-note, .conf-hint, .keys, .matrix-key { font-size: 0.8rem; }
}
.matrix-key { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.matrix-key span { white-space: nowrap; }
