@font-face { font-family: Archivo; src: url(/fonts/Archivo_400Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Archivo; src: url(/fonts/Archivo_600SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: Archivo; src: url(/fonts/Archivo_800ExtraBold.ttf) format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --red: #CE1126; --yellow: #FCD116; --green: #007A5E;
  --bg: #FBF8F0; --surface: #FFFFFF; --ink: #141414; --muted: #5E5E5E; --line: #E3DDCD;
  --empty: #ECE7DA; --empty-ink: #6B6B6B; --accent: var(--green); --accent-ink: #fff;
  --danger: #B3261E; --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Archivo, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--green); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; }
code { background: var(--empty); padding: 0 .3em; border-radius: 4px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.inline { display: inline; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 800; color: var(--green); margin: 0 0 .4em; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: .82rem; line-height: 1.15; margin-right: auto; }
.brand strong { font-size: 1rem; font-weight: 800; }
.brand img { border-radius: 5px; }
.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a, .linklike { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .92rem; }
.site-nav a:hover, .linklike:hover { background: var(--bg); }
.site-nav a.active { background: var(--bg); box-shadow: inset 0 -3px 0 var(--yellow); }
.site-nav .btn { color: var(--accent-ink); }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }
.nav-toggle { display: none; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font: inherit; font-weight: 600; }
  .site-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .site-nav.open { display: flex; }
  .site-nav .btn { text-align: center; }
}

/* buttons, forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; min-height: 42px; }
.btn:hover { filter: brightness(1.08); }
.btn-small { padding: 6px 10px; min-height: 34px; font-size: .88rem; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: var(--danger); }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row label { min-width: 140px; }
.check { display: flex !important; align-items: flex-start; gap: 8px; font-weight: 400 !important; }
.check input { margin-top: 4px; }
input, select { font: inherit; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); min-width: 0; max-width: 100%; }
input:focus, select:focus, .btn:focus-visible, .tile:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
input[type=color] { padding: 2px; width: 52px; height: 40px; }
.num-input { width: 96px; }
.hint { font-weight: 400; font-size: .86rem; color: var(--muted); }
.search { display: flex; gap: 8px; margin: 12px 0; max-width: 460px; }
.search input { flex: 1; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; box-shadow: var(--shadow); }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; font-weight: 600; }
.flash-success { background: #E3F4EC; color: #0B5B41; }
.flash-error { background: #FBE7E6; color: #8C1D18; }

/* hero */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; margin-bottom: 24px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
.lede { font-size: 1.2rem; font-weight: 600; }
.welcome { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 22px; position: relative; overflow: hidden; }
.welcome::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: linear-gradient(90deg, var(--red) 0 33.3%, var(--yellow) 33.3% 66.6%, var(--green) 66.6%); }
.welcome h2 { color: var(--yellow); }
.welcome .btn-ghost { color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.4); }
.welcome .muted { color: #c9c9c9; }
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lock-note { font-size: .92rem; margin-bottom: 0; }
.lock-note.locked { color: var(--danger); font-weight: 600; }
.welcome .lock-note.locked { color: #FF9C94; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

/* board */
.board { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 32px; }
.board-past { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
@media (max-width: 900px) { .board, .board-past { grid-template-columns: 1fr; } }
.board-map, .board-side > * { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.board-side { display: grid; gap: 16px; }
.map-help { margin: 12px 0 0; }

.map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 10px minmax(0, 1fr); grid-template-rows: repeat(5, auto); gap: 8px; }
.tile { --tile: var(--empty); --tile-ink: var(--empty-ink); position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; min-height: 92px; padding: 9px 10px; border: 0; border-radius: 10px; background: var(--tile); color: var(--tile-ink); text-align: left; font: inherit; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
div.tile { cursor: default; }
button.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.tile:not(.picked) { background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(0,0,0,.025) 8px 16px); }
.tile-name { font-size: .8rem; font-weight: 600; line-height: 1.15; }
.tile-party { font-size: 1.55rem; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.tile:not(.picked) .tile-party { font-size: 1rem; opacity: .7; }
.tile-foot { display: flex; justify-content: space-between; gap: 6px; font-size: .78rem; min-height: 1.1em; }
.tile-margin { font-weight: 800; }
.tile-cand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mark { position: absolute; top: 6px; right: 8px; font-weight: 800; font-size: 1.1rem; }
.tile.wrong { opacity: .55; }
.map-sea { grid-row: 2 / span 4; grid-column: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border-radius: 10px; color: #4f7f9a; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .8rem; background: repeating-linear-gradient(0deg, #EAF3F7 0 10px, #E1EEF4 10px 20px); }
.map-sea small { font-weight: 600; letter-spacing: .02em; text-transform: none; }
@media (max-width: 520px) {
  .map { gap: 5px; grid-template-columns: repeat(3, minmax(0, 1fr)) 4px minmax(0, 1fr); }
  .tile { min-height: 78px; padding: 7px; }
  .tile-name { font-size: .68rem; }
  .tile-party { font-size: 1.1rem; }
  .tile-foot { font-size: .66rem; flex-direction: column; gap: 0; }
  .map-sea { font-size: .6rem; }
}

/* tally */
.tally-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tally-need { font-size: .82rem; font-weight: 600; color: var(--muted); }
.tally-rows { display: grid; gap: 8px; margin: 8px 0; }
.tally-row { display: grid; grid-template-columns: 64px 1fr 36px; gap: 10px; align-items: center; margin-bottom: 6px; }
.tally-code { font-weight: 800; }
.small-code { font-size: .8rem; }
.tally-bar { position: relative; height: 22px; background: var(--empty); border-radius: 6px; overflow: visible; }
.tally-bar > span { display: block; height: 100%; border-radius: 6px; transition: width .25s ease; }
.tally-bar > i { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px dashed var(--ink); }
.tally-num { font-weight: 800; font-size: 1.2rem; text-align: right; }
.tally-verdict { margin: 4px 0 0; }
.tally-verdict .muted { display: block; }

/* share */
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.share-fb { background: #1877F2; }
.share-wa { background: #128C4B; }
.share-x { background: #111; }
.share-note { margin: 10px 0 0; }
.cta-box { background: var(--yellow) !important; border-color: transparent !important; }

/* dialog */
.seat-dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--ink); }
.seat-dialog::backdrop { background: rgba(10,10,10,.55); }
.dialog-body { padding: 20px; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.dialog-close { background: var(--bg); border: 0; border-radius: 50%; width: 36px; height: 36px; font-size: 1.3rem; cursor: pointer; flex: none; }
.cand-options { display: grid; gap: 8px; margin: 12px 0; }
.cand-option { display: flex; align-items: center; gap: 12px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; }
label.cand-option { position: relative; }
label.cand-option:hover { border-color: var(--opt, var(--green)); }
.cand-option.is-selected, .cand-option:has(input:checked) { border-color: var(--opt, var(--green)); background: #F1F7F3; background: color-mix(in srgb, var(--opt, var(--green)) 14%, #fff); box-shadow: inset 0 0 0 1px var(--opt, var(--green)); }
.cand-option.is-selected::after { content: "\2713"; margin-left: auto; font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.cand-option input { position: absolute; left: 12px; top: 50%; width: 1px; height: 1px; opacity: 0; }
.cand-option:focus-within { outline: 3px solid var(--yellow); outline-offset: 2px; }
.cand-options-static .cand-option { cursor: default; }
.guest-note { background: #FFF7D1; border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.cand-option .cand-text { display: grid; line-height: 1.25; }
.cand-option .cand-party { font-size: .85rem; color: var(--muted); }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: var(--chip, #8A8F98); color: #fff; }
.margin-field { display: grid; gap: 6px; font-weight: 600; margin: 8px 0 14px; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dialog-error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 8px 0 0; }

/* chips, tables */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: #fff; font-weight: 800; font-size: .8rem; text-shadow: 0 0 2px rgba(0,0,0,.35); }
.chip-lg { font-size: 1rem; padding: 6px 14px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.num { text-align: right; }
.leaderboard tr.winner { background: #FFF7D1; }
.leaderboard tr.me td { font-weight: 800; }
.admin-table input:not([type=color]):not(.num-input) { width: 100%; min-width: 120px; }
.admin-table.compact td { padding: 6px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }
.stack { display: flex; height: 14px; min-width: 120px; border-radius: 4px; overflow: hidden; background: var(--empty); }
.stack span { display: block; height: 100%; }

/* misc pages */
.page-head { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.score-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.score-strip > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; }
.score-strip .big { font-size: 2rem; font-weight: 800; line-height: 1; }
.score-strip span:not(.big) { color: var(--muted); font-size: .88rem; }
.pick-list { margin-top: 8px; }
.player-grid { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.player-grid a { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.player-grid a:hover { border-color: var(--green); }
.player-name { font-weight: 800; overflow-wrap: anywhere; }
.player-parties { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.pager { display: flex; gap: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.tabs a { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.past-summary { margin-bottom: 12px; }
.past-totals { display: flex; gap: 8px; flex-wrap: wrap; }
.how .steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; padding: 0; list-style: none; counter-reset: s; }
.how .steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 16px 56px; position: relative; counter-increment: s; }
.how .steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--yellow); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.stat-block { margin-bottom: 28px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.stat-grid .tally-row { grid-template-columns: 140px 1fr 56px; }

/* admin */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding: 8px; background: var(--ink); border-radius: var(--radius); }
.admin-nav a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.admin-nav a.active { background: var(--yellow); color: var(--ink); }
.seat-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.seat-jump a { font-size: .82rem; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.seat-admin { scroll-margin-top: 80px; }
.seat-name-form { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.cand-list { display: grid; gap: 10px; margin-bottom: 12px; }
.cand-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.cand-row .avatar { align-self: center; }
.cand-row form { margin: 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--green); margin-bottom: 10px; }
.publish-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.publish-box p, .publish-box form { margin: 0; }

/* footer */
.site-footer { background: var(--ink); color: #d6d6d6; font-size: .9rem; padding-bottom: 28px; }
.flag-bar { display: flex; height: 8px; margin-bottom: 20px; }
.flag-bar span { flex: 1; }
.flag-bar span:nth-child(1) { background: var(--red); }
.flag-bar span:nth-child(2) { background: var(--yellow); }
.flag-bar span:nth-child(3) { background: var(--green); }
.footer-mark { font-weight: 800; color: #fff; letter-spacing: .08em; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.share-warning { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: #FBE7E6; color: #8C1D18; font-size: .88rem; }
.share-warning code { background: rgba(255,255,255,.6); }
.player-seat { color: var(--muted); }
/* Player predicts a majority (8+ seats) for one party: card takes that party's colour. */
.player-grid a.majority { background: var(--card); color: var(--card-ink); border-color: var(--card); }
.player-grid a.majority:hover { filter: brightness(1.06); border-color: var(--card-ink); }
.player-grid a.majority .player-seat { color: inherit; opacity: .8; }
.player-grid a.majority .chip { box-shadow: 0 0 0 2px rgba(255,255,255,.9); }
