:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #121821;
  --muted: #5d6878;
  --border: #d9dee6;
  --accent: #0b63ce;
  --accent-ink: #ffffff;
  --live: #d6263b;
  --good: #1a7f4b;
  --warn: #b26a00;
  --danger: #c02637;
  --board: #0e1520;
  --board-ink: #f2f5f9;
  --board-muted: #9aa7b8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f15;
    --surface: #131a24;
    --surface-2: #1b2430;
    --text: #e8edf3;
    --muted: #97a3b4;
    --border: #283345;
    --accent: #4d9cff;
    --accent-ink: #06121f;
    --live: #ff5467;
    --good: #3fbf7f;
    --warn: #f0a93b;
    --danger: #ff6b7a;
    --board: #070a0f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.hidden { display: none !important; }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--board); color: var(--board-ink);
}
.topbar .brand { font-weight: 800; letter-spacing: 0.06em; color: var(--board-ink); }
.topbar .spacer { flex: 1; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }

/* Controls */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 7px 12px; border-radius: 8px; min-height: 36px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { background: transparent; }
button.sm { padding: 3px 8px; min-height: 28px; font-size: 0.85rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 36px; max-width: 100%;
}
textarea { width: 100%; min-height: 140px; font-family: var(--mono); font-size: 0.85rem; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); align-items: end; }
.form .wide { grid-column: 1 / -1; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 8px 12px; color: var(--muted); white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
th.sortable { cursor: pointer; user-select: none; }
th.sorted { color: var(--text); }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.voided td { text-decoration: line-through; color: var(--muted); }

/* Badges */
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.live { background: var(--live); color: #fff; border-color: var(--live); }
.badge.final { color: var(--text); }
.badge.pp { background: var(--warn); border-color: var(--warn); color: #111; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Game cards (lists) */
.games { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.game-card { display: block; color: inherit; padding: 12px 14px; }
.game-card:hover { text-decoration: none; border-color: var(--accent); }
.game-card .line { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; }
.game-card .score { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.game-card .meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.8rem; color: var(--muted); }

/* Scoreboard */
.board { background: var(--board); color: var(--board-ink); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px; }
.board .teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.board .team { text-align: center; min-width: 0; }
.board .team .name { font-weight: 800; font-size: clamp(1rem, 3.5vw, 1.5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .team .score { font-size: clamp(2.8rem, 12vw, 5rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.board .team .sog { color: var(--board-muted); font-size: 0.9rem; }
.board .team .goalie { color: var(--board-muted); font-size: 0.8rem; margin-top: 2px; }
.board .center { text-align: center; }
.board .clock { font-family: var(--mono); font-size: clamp(2rem, 9vw, 3.6rem); font-weight: 800; letter-spacing: 0.02em; }
.board .clock.stopped { color: var(--board-muted); }
.board .period { font-weight: 700; color: var(--board-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.board .strip { height: 4px; border-radius: 2px; margin: 0 auto 8px; width: 60%; }
.pbox { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; font-size: 0.85rem; }
.pbox .side > div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 8px; background: rgba(255, 255, 255, 0.06); border-radius: 6px; margin-bottom: 4px; }
.pbox .side .t { font-family: var(--mono); font-weight: 700; color: #ffd166; }

/* Event feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.feed .when { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.feed .what b { font-weight: 700; }
.period-head { margin: 14px 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }

/* Leaders */
.leader-card ol { margin: 0; padding-left: 22px; }
.leader-card li { display: list-item; padding: 3px 0; }
.leader-card li span.v { float: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Scorekeeper */
.sk-clock { text-align: center; }
.sk-clock .clock { font-size: clamp(3rem, 14vw, 6rem); }
.sk-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.sk-actions button { min-height: 52px; font-size: 0.95rem; }
.sk-actions button.goal { background: var(--good); color: #fff; border-color: var(--good); }
.sk-actions button.pen { background: var(--warn); color: #111; border-color: var(--warn); }
.numgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.numgrid button { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px; line-height: 1.1; }
.numgrid button .n { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.numgrid button .nm { font-size: 0.68rem; font-weight: 500; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.numgrid button.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.numgrid button.sel .nm { color: inherit; }
.numgrid button.on { outline: 2px solid var(--good); }
.slots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.slots button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(5, 10, 20, 0.55); }
dialog .dlg-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-body { padding: 16px; overflow-y: auto; max-height: calc(100vh - 170px); }
dialog .dlg-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.notice.error { border-color: var(--danger); color: var(--danger); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

@media (max-width: 640px) {
  main { padding: 14px 12px 64px; }
  .board { padding: 14px 10px; }
  .board .teams { gap: 6px; }
  .board .team .name { font-size: 0.95rem; }
  .board .team .score { font-size: 2.6rem; }
  .board .team .goalie { display: none; }
  .board .clock { font-size: 1.9rem; }
  .board .strip { width: 80%; }
  .pbox { grid-template-columns: 1fr; }
  th, td { padding: 5px 6px; }
}

/* Admin roster cards need room for the per-player actions. */
.teamgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.actions select { min-height: 28px; padding: 2px 6px; font-size: 0.85rem; max-width: 130px; }

/* ------------------------------------------------------------------ */
/* Touch / iPad                                                         */

html { -webkit-tap-highlight-color: transparent; }
button, .btn, select, input[type="checkbox"], summary, .tabs button { touch-action: manipulation; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none !important; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* iOS zooms the page when focusing an input under 16px. */
input, select, textarea { font-size: 16px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
summary { cursor: pointer; padding: 6px 0; }

@media (pointer: coarse) {
  button, .btn, input, select { min-height: 44px; }
  button.sm, .btn.sm { min-height: 38px; padding: 6px 12px; }
  .tabs button { padding: 12px 14px; }
  th, td { padding: 9px 8px; }
}

/* Notch / home-indicator safe areas when installed to the home screen. */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.topbar .who { color: var(--board-muted); font-size: 0.8rem; }
.topbar .who a { color: var(--board-ink); }

/* Sheets */
dialog.sheet { width: min(560px, calc(100vw - 24px)); }
dialog { max-height: calc(100dvh - 24px); }
dialog .dlg-body { max-height: calc(100dvh - 180px); }
dialog .dlg-foot button { min-width: 110px; }
dialog .stack > label { width: 100%; }
dialog .stack input:not([type="checkbox"]), dialog .stack select { width: 100%; }
@media (max-width: 640px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog .dlg-foot button { flex: 1; }
}

.conn { font-size: 0.75rem; font-weight: 700; color: var(--good); white-space: nowrap; }
.conn.bad { color: var(--warn); animation: pulse 1.2s infinite; }

/* Tappable rows (roster editing) */
tr.tap { cursor: pointer; }
tr.tap td:last-child { color: var(--muted); text-align: right; }

/* Big tappable list items */
.pick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pick a { display: block; padding: 14px 16px; color: inherit; text-decoration: none; }
.pick a:hover { border-color: var(--accent); }
.pick .teams { font-weight: 700; font-size: 1.05rem; }

/* Getting started checklist */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.checklist li.done { color: var(--muted); }
.checklist .tick { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--border); font-weight: 800; flex: none; }
.checklist li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.checklist .lbl { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 200px; }

/* Scorekeeper: compact, sticky control bar for iPad */
.sk-bar { position: sticky; top: 0; z-index: 5; }
.sk-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.sk-score .side { min-width: 0; }
.sk-score .side .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-score .side .sc { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.sk-score .away { text-align: left; }
.sk-score .home { text-align: right; }
.sk-score .mid { text-align: center; }
.sk-score .mid .clock { font-family: var(--mono); font-size: clamp(2.6rem, 9vw, 4.4rem); font-weight: 800; line-height: 1.05; }
.sk-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.sk-controls .go { min-width: 170px; min-height: 56px; font-size: 1.1rem; }
.sk-controls button { min-height: 48px; }
.sk-actions button, .numgrid button { user-select: none; -webkit-user-select: none; }
@media (max-height: 560px) { .sk-bar { position: static; } }

/* Team graphics */
img.logo { object-fit: contain; vertical-align: middle; flex: none; }
img.logo.sm { width: 22px; height: 22px; margin-right: 6px; vertical-align: -6px; }
img.logo.md { width: 40px; height: 40px; }
img.logo.lg { width: 72px; height: 72px; }
img.logo.xl { width: 96px; height: 96px; }
.board img.logo.lg { display: block; margin: 0 auto 6px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45)); }
@media (max-width: 640px) { .board img.logo.lg { width: 48px; height: 48px; } }
.logo-editor { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo-drop {
  width: 84px; height: 84px; border: 2px dashed var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: var(--surface-2); overflow: hidden; flex: none; text-align: center;
}
.logo-drop img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-drop.over { border-color: var(--accent); }
.title-row { display: flex; gap: 14px; align-items: center; }

/* Draft upload preview */
.summary-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.summary-pills .badge { font-size: 0.8rem; padding: 4px 10px; }
.badge.good { background: var(--good); border-color: var(--good); color: #fff; }
.badge.bad { background: var(--danger); border-color: var(--danger); color: #fff; }
.preview-teams { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.preview-teams .card { margin: 0; }
.preview-teams ul { list-style: none; margin: 0; padding: 0; }
.preview-teams li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.preview-teams li .n { font-family: var(--mono); font-weight: 700; width: 2.6em; text-align: right; flex: none; }
.preview-teams li .tag { margin-left: auto; }
.preview-teams li.err .n { color: var(--danger); }
.steps { counter-reset: step; display: grid; gap: 14px; }
.steps > .card { margin: 0; }
.steps > .card > h2::before { counter-increment: step; content: counter(step) ". "; color: var(--accent); }
.preview-teams li .tag .badge { white-space: nowrap; }
.preview-teams li > span:nth-child(2) { min-width: 0; }

/* ------------------------------------------------------------------ */
/* Main menu: large, centered                                          */

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-bottom: 12px; }
.topbar .brand { justify-self: start; font-size: 1.25rem; }
.topbar .who { justify-self: end; text-align: right; white-space: nowrap; }
.topbar .spacer { display: none; }
.mainnav { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mainnav a {
  display: inline-flex; align-items: center; gap: 9px; min-height: 52px; padding: 10px 22px;
  border-radius: 999px; font-size: 1.12rem; font-weight: 700; color: var(--board-ink);
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none !important; white-space: nowrap; touch-action: manipulation;
}
.mainnav a:hover { background: rgba(255, 255, 255, 0.14); }
.mainnav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mainnav .icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "brand who" "nav nav"; row-gap: 10px; }
  .topbar .brand { grid-area: brand; }
  .topbar .who { grid-area: who; }
  .mainnav { grid-area: nav; display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 6px; }
  .mainnav a { flex-direction: column; justify-content: center; gap: 4px; min-height: 64px; padding: 8px 4px; border-radius: 12px; font-size: 0.9rem; white-space: normal; text-align: center; line-height: 1.15; }
}
.mainnav .short { display: none; }
@media (max-width: 520px) { .mainnav .long { display: none; } .mainnav .short { display: inline; } }

/* Bigger, centered section tabs (Admin) */
.tabs.big, .tabs.medium { justify-content: center; border-bottom: none; gap: 8px; padding: 4px 2px 6px; flex-wrap: wrap; overflow: visible; }
.tabs.big button, .tabs.medium button {
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font-weight: 700; white-space: nowrap;
}
.tabs.big button { font-size: 1.08rem; padding: 12px 22px; min-height: 52px; }
.tabs.medium button { font-size: 0.98rem; padding: 9px 18px; min-height: 46px; }
.tabs.big button.active, .tabs.medium button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs.big { margin-bottom: 20px; }
@media (max-width: 640px) {
  .tabs.big, .tabs.medium { display: grid; grid-template-columns: repeat(2, 1fr); }
  .tabs.big button, .tabs.medium button { white-space: normal; border-radius: 12px; }
}

/* Watch page */
.watch-stage {
  position: relative; aspect-ratio: 16 / 9; width: min(100%, calc((100dvh - 230px) * 16 / 9)); min-width: min(100%, 320px);
  margin: 0 auto 14px; background: #000; border-radius: 12px; overflow: hidden;
}
.watch-media, .watch-media iframe, .watch-media video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.watch-overlay { position: absolute; inset: 0; pointer-events: none; }
.watch-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 6% 8% 18%; text-align: center; color: #dfe6ef;
  background: radial-gradient(ellipse at 50% 35%, #1d2a3d 0%, #070b11 70%);
}
.watch-placeholder p { max-width: 520px; color: #9fb0c6; margin: 0 0 8px; }
.watch-ph-title { font-size: clamp(1.1rem, 2.6vw, 1.6rem); font-weight: 800; }
.watch-exit { display: none; position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 3; background: rgba(0, 0, 0, 0.6); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.watch-stage:fullscreen, .watch-stage:-webkit-full-screen { width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; margin: 0; }
.watch-stage.theater { position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100dvh; aspect-ratio: auto; border-radius: 0; margin: 0; }
.watch-stage.theater .watch-exit { display: inline-flex; }
body.no-scroll { overflow: hidden; }
.watch-controls .row label { min-width: 150px; }
.watch-delay { display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.watch-delay > div:first-child { flex: 1; min-width: 240px; }
.badge.watch { background: #d6263b; border-color: #d6263b; color: #fff; }

/* Sign-in (email + text-message codes) */
.signin label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.signin input:not([type="checkbox"]) { width: 100%; font-size: 1.05rem; padding: 12px; }
.signin .code-input { font-family: var(--mono); font-size: 1.8rem; letter-spacing: 0.4em; text-align: center; }
.big-button { width: 100%; min-height: 48px; font-size: 1.05rem; }
button.link { background: none; border: 0; padding: 6px 0; color: var(--accent); cursor: pointer; font: inherit; min-height: 0; box-shadow: none; }
.steps-mini { display: flex; gap: 8px; }
.steps-mini span { flex: 1; text-align: center; padding: 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.steps-mini .now { background: var(--accent); color: var(--accent-ink); }
.steps-mini .done { background: var(--good); color: #fff; }
.auth-card { max-width: 520px; margin: 24px auto; }
.auth-card details { margin-top: 14px; }
.auth-card summary { cursor: pointer; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.topbar .who a { display: inline-block; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* BLPA Factions */
.order-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  color: #fff; background: var(--order, #64748b); text-decoration: none !important; white-space: nowrap; line-height: 1.6;
}
.order-badge.big { font-size: 1.05rem; padding: 4px 14px; }
.order-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
@media (max-width: 520px) {
  .order-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .order-card { padding: 12px; }
  .order-card .emoji { font-size: 1.5rem; }
  .order-card h3 { font-size: 1.05rem; }
  .order-card .pts { font-size: 1.5rem; }
  .order-card .rank { font-size: 1.2rem; top: 8px; right: 10px; }
}
.order-badge.compact { padding: 2px 6px; }
.order-card {
  position: relative; border-radius: var(--radius); padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-top: 6px solid var(--order); box-shadow: var(--shadow); scroll-margin-top: 16px;
}
.order-card:target { outline: 3px solid var(--order); }
.order-card .rank { position: absolute; top: 10px; right: 14px; font-size: 1.6rem; font-weight: 800; color: var(--muted); }
.order-card .emoji { font-size: 2rem; line-height: 1; }
.order-card h3 { margin: 6px 0 2px; font-size: 1.25rem; }
.order-card .pts { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.order-card .bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.order-card .bar > span { display: block; height: 100%; background: var(--order); }
.order-card.leader { box-shadow: 0 0 0 2px var(--order), var(--shadow); }
.order-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 640px) { .order-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.order-strip a { display: block; text-align: center; padding: 8px 4px; border-radius: 10px; color: #fff; background: var(--order); text-decoration: none; }
.order-strip a strong { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.order-strip a small { opacity: 0.9; }

/* Platform (bare domain) and organization admin */
.platform-hero h1 { font-size: 1.8rem; margin: 0 0 6px; }
.org-form { display: grid; gap: 12px; max-width: 560px; }
.org-form textarea { font-family: inherit; font-size: 1rem; min-height: 0; }
.slug-row { display: flex; align-items: center; gap: 6px; color: var(--text); }
.slug-row input { flex: 1; min-width: 0; text-align: right; }
.slug-row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.good-text { color: var(--good); }
.org-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.org-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.faction-row { display: grid; grid-template-columns: 52px 1fr 64px auto; gap: 8px; align-items: center; }
.faction-row input[type="color"] { width: 56px; height: 40px; padding: 2px; }
.faction-row .emoji { font-size: 1.4rem; text-align: center; }
@media (max-width: 560px) { .faction-row { grid-template-columns: 44px 1fr 52px; } .faction-row .row { grid-column: 1 / -1; } }
.card-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.card-list > li.card { margin: 0; }
