:root {
  --bg: #121417;
  --panel: #1b1e22;
  --line: #2c3137;
  --text: #e4e6e8;
  --muted: #8a9198;
  --accent: #f2b134;
  --accent-ink: #1a1405;
  --win: #ffffff;
  --red: #e5544b;
  --green: #5cbf7a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/24px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--text); text-decoration-color: var(--muted); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 28px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
}
.brand span {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover, .top nav a[aria-current] { color: var(--text); }
.top nav a[aria-current] { box-shadow: 0 2px 0 var(--accent); }

.top .who { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.top .who a { color: var(--muted); text-decoration: none; }
.top .who a:hover, .top .who a[aria-current] { color: var(--text); }
.top .who strong { color: var(--text); font-weight: 600; }

.crewbar, .nowbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  padding: 7px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.crewbar { background: #1d1a12; }
.nowbar { background: var(--panel); }
.crewbar .label, .nowbar .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.crewbar .label { color: var(--accent); }
.crewbar a, .nowbar a { text-decoration: none; }
.nowbar a[aria-current] { color: var(--accent); }
.nowbar small { margin-left: 4px; }

.crumb { color: var(--muted); font-size: 14px; margin: 18px 0 0; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--text); }
.crumb .sep { margin: 0 8px; color: #4a5056; }
.crumb + .flash { margin-top: 10px; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 24px 48px; }

h1 { font-size: 26px; margin: 24px 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 32px 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 6px; }
.count { color: var(--muted); font-weight: 400; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 4px 0; display: block; }
small { font-size: 12px; color: var(--muted); }
code { background: var(--panel); padding: 1px 5px; border-radius: 3px; font-size: 13px; word-break: break-all; }

.flash { background: var(--panel); border-left: 3px solid var(--accent); padding: 8px 12px; margin: 16px 0 0; }
.error { border-left: 3px solid var(--red); background: #2a1716; padding: 8px 12px; }
.note { border-left: 3px solid var(--line); padding: 4px 12px; color: var(--muted); }

.tag { font-size: 12px; padding: 1px 7px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); }
.tag.live { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.tag.finished { color: var(--text); }
.tag.test { color: #9fc2e8; border-color: #34506b; }
.gold { color: var(--accent); }
.intro { max-width: 640px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spaced { margin-top: 14px; }
.inline-fields .end { align-self: flex-end; }
.signup { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.card .card-title { font-size: 17px; font-weight: 600; text-decoration: none; }
.card .button { align-self: flex-start; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; max-width: 640px; }
.choice { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); text-decoration: none; }
.choice:hover { border-color: var(--accent); color: var(--text); }
.choice strong { font-size: 17px; }
.choice span { color: var(--muted); font-size: 14px; }

.jumps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.jumps a { font-size: 13px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--muted); }
.jumps a:hover { color: var(--text); border-color: var(--muted); }
h2[id], div[id] { scroll-margin-top: 12px; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); }
.matchlist .go { float: right; color: var(--accent); font-size: 13px; }
.roles td, .roles th { padding-right: 18px; }

/* tables */
table { border-collapse: collapse; }
table.list { width: 100%; }
.list th, .list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.list tbody tr:hover { background: var(--panel); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.leader { font-weight: 600; }

.standings td:nth-child(2) { width: 100%; }

/* forms */
input, select, button, .button {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; padding: 0; }
input.short { width: 76px; }
button, .button { background: var(--panel); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--muted); color: var(--text); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
button.danger { color: var(--red); }
button.danger:hover { border-color: var(--red); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: inherit; }
button.small, .button.small { padding: 4px 12px; font-size: 14px; }

form.inline, .inline-form { display: inline; }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.stack.narrow { max-width: 320px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.stack label.check { flex-direction: row; align-items: center; gap: 8px; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 14px; }
.form-table th, .form-table td { padding: 4px 8px 4px 0; text-align: left; }
.form-table thead th { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-table tbody th { font-weight: 500; white-space: nowrap; padding-right: 12px; }
.form-table input:not([type]) , .form-table input[name^=nick], .form-table input[name=map] { width: 100%; min-width: 120px; }
.danger-zone { margin-top: 32px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.adminbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 0; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: 4px 0; }

/* tournament page */
.title-row h1 { margin-bottom: 2px; }
.meta { margin: 0; color: var(--muted); }
h1 + .meta { margin-bottom: 16px; }
.champion { font-size: 18px; margin: 20px 0 0; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 4px; display: inline-block; }
.champion strong { color: var(--accent); }
.seeds { columns: 2; max-width: 520px; padding-left: 28px; }
.seeds li { padding: 2px 0; }

.matchlist { list-style: none; padding: 0; margin: 0; }
.matchlist li { border-bottom: 1px solid var(--line); }
.matchlist a { display: block; padding: 8px 2px; text-decoration: none; }
.matchlist a:hover { background: var(--panel); color: var(--text); }
.matchlist .where { display: inline-block; min-width: 150px; color: var(--muted); font-size: 13px; }
.matchlist.compact a { padding: 5px 2px; font-size: 14px; }
.matchlist li.st-ready a { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }
.vs { color: var(--muted); font-size: 13px; margin: 0 4px; }
.score { font-variant-numeric: tabular-nums; font-weight: 600; margin: 0 6px; }
.w { color: var(--win); font-weight: 600; }

.rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px 32px; }

/* bracket */
.bracket-scroll { overflow-x: auto; padding-bottom: 8px; }
.bracket { position: relative; }
.bracket svg { position: absolute; inset: 0; }
.bracket path { fill: none; stroke: #3a4047; stroke-width: 1; shape-rendering: crispEdges; }
.col-label { position: absolute; top: 0; font-size: 12px; color: var(--muted); }
.m {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  text-decoration: none;
  overflow: hidden;
}
.m:hover { border-color: var(--muted); color: var(--text); }
.m.st-ready { border-left: 3px solid var(--accent); }
.m.st-waiting { opacity: 0.75; }
.m .row { flex: 1; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0; font-size: 13px; min-width: 0; color: var(--muted); }
.m.st-ready .row, .m.st-walkover .row { color: var(--text); }
.m .row + .row { border-top: 1px solid var(--line); }
.m .row.won { color: var(--win); font-weight: 600; }
.m .row.tbd .nm { color: #5d646b; }
.m .seed { width: 22px; text-align: right; font-size: 11px; color: #5d646b; flex: none; }
.m .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m .sc { font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }
.m .row.won .sc { color: var(--accent); }

/* match page */
.crumb { color: var(--muted); margin-top: 24px; }
.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  font-size: 22px;
  font-weight: 600;
}
.versus > div:first-child { text-align: right; }
.versus small { display: block; font-weight: 400; font-size: 13px; }
.versus .big { font-size: 34px; font-variant-numeric: tabular-nums; color: var(--muted); }
.versus .w { color: var(--accent); }
table.maps { max-width: 420px; margin: 0 auto; }
.report { border-top: 1px solid var(--line); margin-top: 32px; }

@media (max-width: 720px) {
  .top, main, .crewbar, .nowbar { padding-left: 16px; padding-right: 16px; }
  .top .who { margin-left: 0; width: 100%; }
  .matchlist .go { float: none; display: block; }
  .cols { grid-template-columns: 1fr; }
  .seeds { columns: 1; }
  .versus { font-size: 17px; gap: 10px; }
  .versus .big { font-size: 24px; }
  .matchlist .where { display: block; min-width: 0; }
  .list th, .list td { padding: 7px 6px; }
}

/* stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 18px 0 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .muted, .tile a { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.good { color: var(--green); }
.bad { color: var(--red); }
.warn { color: var(--accent); }
small.warn { font-size: 12px; }
.table-scroll { overflow-x: auto; }
table.stats { min-width: 560px; }
table.stats th a { color: var(--muted); text-decoration: none; }
table.stats th a:hover, table.stats th a[aria-current] { color: var(--accent); }
.board { margin-bottom: 18px; }
.board h3 { margin-top: 14px; }
.board table + table, .board .table-scroll + .table-scroll { margin-top: 6px; }
a.player { text-decoration: none; }
a.player:hover { text-decoration: underline; }
a.player.leader { font-weight: 600; }

/* forms and crew bits */
input.steam { width: 220px; }
input.tiny { width: 64px; }
pre.command { white-space: pre-wrap; word-break: break-all; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; font-size: 13px; user-select: all; }
details.report summary { cursor: pointer; color: var(--muted); padding: 14px 0 6px; }
details.report summary:hover { color: var(--text); }
.steps { padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin: 4px 0; }
.compact-table td { padding: 5px 8px; font-size: 13px; }
.nowrap { white-space: nowrap; }
.board-table { table-layout: fixed; }
.board-table col.c-name { width: 30%; }
.board-table .team-row th { padding-top: 14px; color: var(--text); font-size: 13px; text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--line); }
.board-table td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- polish pass (1.3) ---------- */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:active, .button:active { transform: translateY(1px); }
h1 { line-height: 1.2; }

/* front page */
.hero { padding: 26px 0 6px; }
.hero h1 { margin: 0; font-size: 34px; letter-spacing: -0.01em; }
.hero h1 span { color: var(--accent); font-weight: 600; font-size: 0.6em; margin-left: 6px; letter-spacing: 0; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.empty { padding: 18px 20px; border: 1px dashed var(--line); border-radius: 6px; margin-top: 24px; }
.empty p { margin: 4px 0; }
.card { gap: 8px; }
.card.is-live { border-color: #4a3e1c; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-meta { margin: 0; color: var(--muted); font-size: 14px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 6px; font-size: 14px; }
.card-foot > a:last-child { color: var(--muted); text-decoration: none; }
.card-foot > a:last-child:hover { color: var(--text); }
.howto { counter-reset: step; list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.howto li { counter-increment: step; padding: 12px 14px 12px 46px; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 14px; color: var(--muted); }
.howto li strong { color: var(--text); display: block; }
.howto li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; display: grid; place-items: center; }

/* tournament page */
.format-help { color: var(--muted); font-size: 14px; margin: 8px 0 0; max-width: 680px; }
.signup-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 14px 16px; border: 1px solid #4a3e1c; background: #1d1a12; border-radius: 6px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.team-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.team-card.mine { border-color: var(--accent); }
.team-card > div { min-width: 0; }
.seed-badge { flex: none; width: 26px; height: 26px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.team-name { font-weight: 600; text-decoration: none; }
.team-players { font-size: 14px; color: var(--muted); margin-top: 2px; }
.team-players a { color: var(--text); }
.seats { color: var(--muted); margin-left: 6px; }
.m .row.hl { background: #2a2414; color: var(--text); }
.m .row.mine .nm { color: var(--accent); }
.tv-exit { text-align: right; margin: 0; font-size: 13px; }
.tv-exit a { color: var(--muted); }

/* big screen: no chrome, bigger type, everything at a glance */
body.tv .top, body.tv .crewbar, body.tv .nowbar { display: none; }
body.tv main { max-width: none; padding: 16px 32px 32px; }
body.tv { font-size: 18px; }
body.tv h1 { font-size: 40px; margin-top: 8px; }
body.tv h2 { font-size: 15px; }
body.tv .matchlist a { font-size: 20px; padding: 10px 4px; }

/* forms */
.hints { padding-left: 18px; margin: 4px 0; color: var(--muted); font-size: 13px; }
.hints li { margin: 4px 0; }
.m-only { display: none; }
.stack label.leader-pick { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.ok { color: var(--green); font-size: 13px; }
a.warn { font-size: 13px; }

fieldset.roles { border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px 10px; margin: 0; }
fieldset.roles legend { padding: 0 6px; color: var(--muted); font-size: 14px; }
.role-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.role-name { font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 12px; font-size: 14px; color: var(--muted); border-left: 1px solid var(--line); }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input[value="out"]:checked + span { background: var(--bg); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg input:disabled + span { opacity: 0.35; cursor: not-allowed; }
.role-count { margin: 10px 0 0; font-size: 14px; }

/* match page */
.versus .side { min-width: 0; overflow-wrap: anywhere; }
.versus .mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.command-wrap { display: flex; gap: 8px; align-items: flex-start; }
.command-wrap pre { flex: 1; margin: 0; min-width: 0; }

@media (max-width: 720px) {
  /* header: brand and account links on one row, the menu below */
  .top { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding-top: 10px; padding-bottom: 8px; }
  .top .brand span { display: none; }
  .top nav { grid-column: 1 / -1; grid-row: 2; gap: 18px; }
  .top .who { width: auto; justify-content: flex-end; gap: 12px; font-size: 13px; }
  .crewbar, .nowbar { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .hero h1 { font-size: 28px; }
  .hero h1 span { display: block; margin: 2px 0 0; font-size: 15px; }

  /* team form: one block per player */
  .roster thead { display: none; }
  .roster, .roster tbody { display: block; width: 100%; }
  .roster tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .roster th[scope=row] { grid-column: 1 / -1; padding: 0; font-size: 13px; color: var(--muted); }
  .roster td { padding: 0; }
  .roster td:nth-of-type(1) { grid-column: 1 / -1; }
  .roster input, .roster input.short, .roster input.steam { width: 100%; min-width: 0; }
  .roster td.center { grid-column: 1 / -1; text-align: left; }
  .m-only { display: inline; }
  .d-only { display: none; }

  .versus { grid-template-columns: 1fr; text-align: center; gap: 6px; }
  .versus > div:first-child { text-align: center; }
  .command-wrap { flex-direction: column; }
  .role-row { flex-direction: column; align-items: stretch; }
  .seg { display: flex; }
  .seg label { flex: 1; text-align: center; }
}
body.tv .m .row { font-size: 16px; }
body.tv .m .seed { font-size: 13px; width: 26px; }
body.tv .col-label { font-size: 14px; }
/* Whole-pixel line heights keep everything below them on the pixel grid,
   so borders and bracket lines render sharp instead of smeared. */
h1 { line-height: 32px; }
h2 { line-height: 20px; }
h3 { line-height: 22px; }
.hint, small, .crumb, .meta, .format-help { line-height: 20px; }
.hero h1 { line-height: 40px; }
.m { line-height: 16px; }
body.tv .m { line-height: 20px; }
