/* Colors and font come from the active theme (data/themes/*.json) via these
   variables; the defaults below only show before the theme loads. */
:root {
  /* Whiteboard theme values, so nothing flashes before the theme applies. */
  --bg: #e9ecef;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --accent: #1f6feb;
  --surround: #eef0ee;
  color-scheme: light;
  --font: ui-rounded, -apple-system, system-ui, sans-serif;
  --caption-bg: #000000b3;
  --caption-text: #fff;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  /* The board's surround colour, so letterboxing reads as part of the pitch. */
  background: var(--surround);
  color: var(--text);
  font-family: var(--font);
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
/* body turns off text selection (so drags on the board don't select text);
   on iPad that also blocks typing — text fields must opt back in. */
input, textarea { -webkit-user-select: text; user-select: text; }
button:active { transform: scale(0.96); }

body[data-view="lineup"] .plays-only, body[data-view="lineup"] .log-only,
body[data-view="plays"] .lineup-only, body[data-view="plays"] .log-only,
body[data-view="log"] .lineup-only, body[data-view="log"] .plays-only,
body[data-view="log"] #board { display: none !important; }
body:not([data-view="roster"]) .roster-only,
body[data-view="roster"] .lineup-only, body[data-view="roster"] .plays-only, body[data-view="roster"] .log-only,
body[data-view="roster"] #board { display: none !important; }
/* Phones: no whiteboard at all. */
body[data-device="phone"] #board, body[data-device="phone"] #sheets, body[data-device="phone"] #transport { display: none !important; }
/* Screens: teams → team → game. */
body:not([data-screen="game"]) .game-only, body:not([data-screen="game"]) #board,
body[data-screen="game"] .home-only { display: none !important; }

#board { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#board .token { cursor: pointer; }
#board .token.dragging { opacity: 0.85; }
#board.hide-them .kind-them { display: none; }

/* ------------------------------------------------ floating controls */

/* Solid (no backdrop blur) and never centred with a transform: both make
   text render soft on iPad. */
.float {
  position: fixed;
  z-index: 5;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 1px 3px #0000001f;
  border-radius: 999px;
  transition: opacity 0.4s;
}
#menuBtn {
  top: calc(env(safe-area-inset-top) + 22px);
  right: max(10px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  font-size: 20px;
  opacity: 0.7;
}
/* Lineup tabs: small, top-left, out of the way. */
#sheets {
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  display: flex;
  gap: 2px;
  padding: 3px;
  max-width: calc(100vw - 80px);
  overflow-x: auto;
}
#sheets button {
  min-width: 38px; height: 38px; padding: 0 12px; border-radius: 999px;
  background: transparent; font-size: 15px; font-weight: 700; white-space: nowrap;
}
#sheets button.on { background: var(--accent); color: var(--bg); }
#sheets .game { align-self: center; padding: 0 10px 0 12px; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
#sheets button.add { color: var(--accent); font-size: 20px; }
#transport {
  bottom: max(10px, env(safe-area-inset-bottom));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}
#transport button { width: 56px; height: 56px; border-radius: 999px; background: transparent; font-size: 24px; }
#transport #playPause { background: var(--accent); color: var(--bg); }
#beatCount { padding: 0 12px 0 6px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 15px; }
/* Get out of the way while a play is running. */
body.playing #transport, body.playing #menuBtn { opacity: 0.3; }

#caption {
  position: fixed;
  z-index: 4;
  top: calc(max(10px, env(safe-area-inset-top)) + 56px);
  left: 0; right: 0; margin-inline: auto; width: max-content;
  max-width: min(760px, calc(100vw - 140px));
  padding: 10px 20px;
  border-radius: 14px;
  background: var(--caption-bg);
  color: var(--caption-text);
  font-size: clamp(17px, 2.3vw, 26px);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
}

/* ------------------------------------------------ player picker */

#picker {
  position: fixed;
  z-index: 10;
  width: min(480px, calc(100vw - 24px));
  max-height: 70vh;
  overflow: auto;
  padding: 14px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 20px 60px #0009;
}
#picker header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 22px; }
#picker .title { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
#picker .title small { color: var(--muted); font-size: 14px; }
#picker .rename {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); font: inherit; font-size: 20px;
}
#picker h4 { margin: 12px 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#picker .inspot { display: grid; gap: 6px; }
#picker .chip {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 6px 0 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--text) 6%, transparent); font-size: 18px; font-weight: 600;
}
#picker .chip.starter { outline: 2px solid var(--accent); }
#picker .chip b { color: var(--accent); min-width: 1.6em; font-size: 20px; }
#picker .chip small { margin-left: auto; color: var(--muted); font-size: 13px; }
#picker .chip .icon { width: 44px; height: 44px; border-radius: 10px; background: transparent; color: var(--accent); font-size: 22px; }
#picker .chip small + .icon, #picker .chip span + .icon { margin-left: auto; }
#picker .chip small + .icon { margin-left: 0; }
#picker .empty { margin: 12px 4px 4px; color: var(--muted); font-size: 16px; }
#picker .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
#picker .grid.all { margin-top: 10px; grid-template-columns: repeat(3, 1fr); }
#picker .pick {
  display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 14px;
  border-radius: 14px; background: color-mix(in srgb, var(--text) 10%, transparent);
  font-size: 19px; font-weight: 600; text-align: left;
}
#picker .pick b { font-size: 24px; min-width: 1.6em; color: var(--accent); }
#picker .pick small { margin-left: auto; color: var(--muted); font-size: 13px; }
#picker .more, #picker .ghost { background: transparent; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 10px; }
#picker .more { width: 100%; margin-top: 6px; }

/* ------------------------------------------------ menu (all settings) */

#menu {
  margin: 0 0 0 auto;
  height: 100dvh;
  max-height: none;
  width: min(420px, 100vw);
  border: 0;
  padding: max(16px, env(safe-area-inset-top)) 18px 24px;
  background: var(--panel);
  color: var(--text);
  overflow-y: auto;
}
#menu::backdrop { background: #0006; }
#menu header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
#menu header strong { font-size: 22px; }
#menu h3 { margin: 18px 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, #menu .close, .plays button {
  min-height: 46px; padding: 0 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  font-size: 17px; font-weight: 600;
}
.seg button.danger { color: #ff8a80; }
.seg button.danger.armed { background: #d93a32; color: #fff; }
.seg button.on { background: var(--accent); color: var(--bg); }
.seg.big button { flex: 1; min-height: 52px; font-size: 19px; }
#menu .close { background: transparent; color: var(--accent); padding: 0 6px; }
#menu input.text {
  flex: 1; min-width: 120px; height: 46px; padding: 0 12px; border-radius: 12px; border: 0;
  background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font: inherit; font-size: 17px;
}
.saved { display: grid; gap: 6px; }
.saved .row { display: flex; gap: 6px; }
.saved .row button { min-height: 50px; border-radius: 12px; background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 16px; font-weight: 600; padding: 0 14px; }
.saved .row .load { flex: 1; display: flex; align-items: center; justify-content: space-between; text-align: left; }
.saved .row .load.on { outline: 2px solid var(--accent); }
#menu input[type="date"], #menu input[type="time"] { flex: 0 1 auto; min-width: 0; }
.saved .row .load small { color: var(--muted); font-weight: 400; }
.saved .row .danger { color: #ff8a80; }
.saved .row .danger.armed { background: #d93a32; color: #fff; }
.avail { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.avail button {
  display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 16px; font-weight: 600; text-align: left;
}
.avail button b { color: var(--accent); min-width: 1.6em; }
.avail button.out { opacity: 0.45; text-decoration: line-through; background: transparent; outline: 1px dashed var(--muted); }
.plays { display: grid; gap: 8px; margin-top: 8px; }
.plays button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 64px; text-align: left; padding: 8px 14px; }
.plays button small { color: var(--muted); font-weight: 400; font-size: 13px; }
.plays button.on { outline: 3px solid var(--accent); }
.chips button { min-height: 36px; font-size: 14px; padding: 0 12px; }

.fatal { padding: 24px; white-space: pre-wrap; }
button:focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------ game log */

#log {
  position: fixed; inset: 0; overflow-y: auto; background: var(--bg);
  padding: calc(max(16px, env(safe-area-inset-top)) + 56px) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
#log .wrap { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
#log .board { text-align: center; padding: 8px 60px 0; }
#log .teams { display: flex; align-items: center; justify-content: center; gap: 18px; font-size: clamp(20px, 3vw, 28px); font-weight: 700; }
#log .teams .n { font-size: clamp(44px, 7vw, 64px); font-variant-numeric: tabular-nums; min-width: 1ch; }
#log .teams .them { color: var(--muted); }
#log .when { color: var(--muted); font-size: 15px; margin-top: 2px; }
#log .clock { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
#log .clock .time { font-size: clamp(34px, 6vw, 52px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
#log .clock .period { color: var(--muted); font-size: 17px; font-weight: 600; }
#log button { border-radius: 14px; background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 18px; font-weight: 700; min-height: 52px; padding: 0 18px; }
#log button.primary { background: var(--accent); color: var(--bg); }
#log .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#log .actions .big { min-height: 84px; font-size: 22px; }
#log .actions .keeper { grid-column: 1 / -1; min-height: 60px; }
#log .actions .keeper small { color: var(--muted); font-weight: 600; margin-right: 8px; }
#log h3 { margin: 6px 0 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#log ol.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#log ol.events li { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--text) 6%, transparent); }
#log ol.events li .at { min-width: 4.2em; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
#log ol.events li .what { flex: 1; font-size: 18px; font-weight: 600; }
#log ol.events li .what small { display: block; color: var(--muted); font-weight: 500; font-size: 14px; }
#log ol.events li .danger { min-height: 40px; padding: 0 12px; font-size: 15px; color: #ff8a80; background: transparent; }
#log ol.events li .danger.armed { background: #d93a32; color: #fff; }
#log .gk { display: flex; flex-wrap: wrap; gap: 6px; }
#log .gk span { padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); font-size: 15px; }
#log .empty { color: var(--muted); }

#logPick {
  width: min(560px, 94vw); max-height: 86vh; border: 0; border-radius: 22px; padding: 18px;
  background: var(--panel); color: var(--text);
}
#logPick::backdrop { background: #0008; }
#logPick header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 22px; font-weight: 700; }
#logPick .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
#logPick .grid button, #logPick .none {
  display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 18px; font-weight: 600; text-align: left;
}
#logPick .grid button b { color: var(--accent); min-width: 1.6em; font-size: 22px; }
#logPick .grid button.on-field { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); }
#logPick .none { width: 100%; margin-top: 10px; justify-content: center; color: var(--accent); }
#logPick .close { background: transparent; color: var(--accent); font-size: 17px; font-weight: 700; min-height: 44px; padding: 0 6px; }

/* ------------------------------------------------ game top bar */

/* Solid strip behind the game's top bar: iPadOS blurs a reflection of
   whatever sits right under the status bar; over a flat strip that's
   invisible, and the controls sit just below the effect. */
body[data-screen="game"]::before {
  content: ""; position: fixed; z-index: 4; left: 0; right: 0; top: 0;
  height: calc(env(safe-area-inset-top) + 72px); background: var(--surround);
}
#backBtn {
  top: calc(env(safe-area-inset-top) + 22px);
  left: max(10px, env(safe-area-inset-left));
  height: 44px; padding: 0 16px 0 12px; max-width: 34vw;
  font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#backBtn small { color: var(--muted); font-weight: 600; margin-left: 6px; }
#modes {
  top: calc(env(safe-area-inset-top) + 22px);
  left: 0; right: 0; margin-inline: auto; width: max-content;
  display: flex; padding: 3px; gap: 2px;
}
#modes button { height: 38px; padding: 0 16px; border-radius: 999px; background: transparent; font-size: 16px; font-weight: 700; }
#modes button.on { background: var(--accent); color: var(--bg); }
#lockBadge {
  top: calc(env(safe-area-inset-top) + 22px);
  right: calc(max(10px, env(safe-area-inset-right)) + 54px);
  height: 44px; padding: 0 14px; font-size: 15px; font-weight: 700;
}
#lockBadge.editing { background: #d93a32; color: #fff; }
@media (max-width: 700px) {
  #backBtn small { display: none; }
  #modes button { padding: 0 11px; font-size: 15px; }
}

/* ------------------------------------------------ home: teams + team */

#home {
  position: fixed; inset: 0; overflow-y: auto; background: var(--bg);
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
#home .wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 14px; }
#home h1 { margin: 8px 0 0; font-size: 32px; }
#home h2 { margin: 14px 0 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#home .top { display: flex; align-items: center; gap: 10px; min-height: 48px; }
#home .top .back { background: transparent; color: var(--accent); font-size: 18px; font-weight: 700; padding: 0 6px; min-height: 44px; }
#home .title { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 800; }
#home .title button { background: transparent; color: var(--accent); font-size: 16px; font-weight: 700; min-height: 44px; }
#home .title input { font: inherit; font-size: 26px; width: 10ch; padding: 4px 10px; border-radius: 10px; border: 2px solid var(--accent); background: transparent; color: var(--text); }
#home .card {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 18px; border-radius: 18px; text-align: left;
  background: color-mix(in srgb, var(--text) 8%, transparent); min-height: 76px;
}
#home .card .main { flex: 1; min-width: 0; }
#home .card strong { display: block; font-size: 21px; }
#home .card small { display: block; color: var(--muted); font-size: 15px; margin-top: 3px; }
#home .card .side { text-align: right; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
#home .card .side small { font-size: 13px; font-weight: 700; }
#home .card.continue { background: var(--accent); color: var(--bg); }
#home .card.continue small { color: color-mix(in srgb, var(--bg) 70%, transparent); }
#home .new { width: 100%; min-height: 64px; border-radius: 18px; background: var(--accent); color: var(--bg); font-size: 21px; font-weight: 800; }
#home .chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; vertical-align: 3px; margin-left: 8px; }
#home .chip.live { background: #d93a32; color: #fff; }
#home .chip.final { background: color-mix(in srgb, var(--text) 16%, transparent); color: var(--text); }
#home .chip.half { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); }
#home .res { display: inline-block; min-width: 1.4em; margin-right: 6px; font-size: 15px; }
#home .res.W { color: #1f9d55; } #home .res.L { color: #d12a2a; } #home .res.D { color: var(--muted); }
#home .roster { display: flex; flex-wrap: wrap; gap: 6px; }
#home .roster span { padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); font-size: 15px; }
#home .roster b { color: var(--accent); margin-right: 6px; }
#home .empty { color: var(--muted); margin: 0; }

#newGame {
  width: min(520px, 94vw); border: 0; border-radius: 22px; padding: 20px; background: var(--panel); color: var(--text);
}
#newGame::backdrop { background: #0008; }
#newGame header { display: flex; justify-content: space-between; align-items: center; font-size: 22px; font-weight: 800; margin-bottom: 8px; }
#newGame label { display: block; margin: 14px 0 6px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#newGame input { width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 0; font: inherit; font-size: 18px;
  background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
#newGame .row { display: flex; gap: 10px; }
#newGame .row > div { flex: 1; }
#newGame .seg button { min-height: 46px; padding: 0 14px; border-radius: 12px; background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 16px; font-weight: 700; }
#newGame .seg button.on { background: var(--accent); color: var(--bg); }
#newGame .go { width: 100%; margin-top: 20px; min-height: 58px; border-radius: 16px; background: var(--accent); color: var(--bg); font-size: 20px; font-weight: 800; }
#newGame .close { background: transparent; color: var(--accent); font-size: 17px; font-weight: 700; min-height: 44px; }
.lock-note { color: var(--muted); margin: 6px 0 0; }
#home .card::after { content: "›"; font-size: 28px; color: var(--muted); margin-left: 4px; }
#home .card.continue::after { color: var(--bg); }

/* ------------------------------------------------ phone roster */

#rosterView {
  position: fixed; inset: 0; overflow-y: auto; background: var(--bg);
  padding: calc(max(16px, env(safe-area-inset-top)) + 56px) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
#rosterView .wrap { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#rosterView h3 { margin: 6px 0 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#rosterView ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#rosterView ol.lineup li { display: grid; grid-template-columns: 4.5em 1fr; gap: 4px 10px; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--text) 6%, transparent); }
#rosterView ol.lineup .pos { color: var(--accent); font-weight: 800; }
#rosterView ol.lineup .who { font-weight: 600; font-size: 17px; }
#rosterView ol.lineup li small { grid-column: 2; color: var(--muted); }
#rosterView .avail button { min-height: 50px; }
#newGame img.qr { display: block; width: min(320px, 70vw); margin: 14px auto; border-radius: 12px; background: #fff; }

/* Phone-sized screens: tighter top bar, full-width buttons. */
@media (max-width: 520px) {
  #backBtn { max-width: 30vw; padding: 0 10px; }
  #modes button { padding: 0 12px; }
  #log .actions .big { min-height: 72px; font-size: 19px; }
  #log .clock .time { font-size: 40px; }
}

#home .new.subtle { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); min-height: 54px; font-size: 18px; }
#home h2 .inline { margin-left: 10px; background: transparent; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
#newGame textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 0; font: inherit; font-size: 17px; resize: vertical;
  background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
#newGame .rows { display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
#newGame .rows .row { display: flex; gap: 6px; align-items: center; }
#newGame .rows input.num { width: 4.2em; flex: none; text-align: center; }
#newGame .rows .close { font-size: 24px; min-width: 44px; }
#newGame .qr { width: min(300px, 70vw); margin: 14px auto; padding: 8px; border-radius: 12px; background: #fff; }
#newGame .qr svg { display: block; width: 100%; height: auto; }
#newGame p.lock-note { font-size: 15px; }
.toast { position: fixed; z-index: 50; left: 0; right: 0; margin-inline: auto; width: max-content; bottom: 24px; max-width: 90vw; padding: 12px 18px;
  border-radius: 14px; background: #000d; color: #fff; font-size: 16px; font-weight: 600; }

#home .homeMenu { position: fixed; z-index: 5; top: calc(env(safe-area-inset-top) + 22px); right: max(12px, env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 999px; font-size: 20px; background: color-mix(in srgb, var(--text) 8%, transparent); }
#home .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#newGame video.scan { display: block; width: 100%; max-height: 60vh; border-radius: 14px; background: #000; object-fit: cover; }
#home .link { background: transparent; color: var(--accent); font-size: 16px; font-weight: 700; min-height: 40px; justify-self: center; }

#sheets .label { align-self: center; padding: 0 6px 0 12px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
#home .card.install { background: color-mix(in srgb, var(--accent) 14%, transparent); }
#newGame ol.steps { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 10px; font-size: 17px; line-height: 1.35; }
#newGame .pointer { position: fixed; top: 6px; right: 70px; padding: 8px 14px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; }

#log .clock .time { background: transparent; padding: 0 6px; min-height: 0; border-radius: 12px; font-size: clamp(34px, 6vw, 52px); font-weight: 800; font-variant-numeric: tabular-nums; }
#log .clock .time.stoppage { color: #d12a2a; }
#log .clock .mode { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
#log .halfLen { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-weight: 700; }
#log .halfLen button { min-height: 40px; min-width: 44px; padding: 0; font-size: 22px; }
#newGame .row > div.narrow { flex: 0 0 6.5em; }

#log .clock button.subtle { background: transparent; color: var(--accent); font-size: 16px; }
#log .adjust { display: grid; gap: 10px; padding: 12px; border-radius: 16px; background: color-mix(in srgb, var(--text) 6%, transparent); }
#log .adjust .nudges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#log .adjust .nudges button { min-height: 60px; font-size: 20px; }
#log .adjust .set { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-weight: 700; }
#log .adjust .set input { width: 4.2em; height: 52px; text-align: center; border: 0; border-radius: 12px; font: inherit; font-size: 24px; font-weight: 800;
  background: var(--panel); color: var(--text); font-variant-numeric: tabular-nums; }
#log .adjust .set b { font-size: 24px; color: var(--text); }

#log .adjust .restart { display: flex; justify-content: center; }
#log .adjust .restart button { background: transparent; color: #d12a2a; font-size: 16px; min-height: 44px; }
#log .adjust .restart button.armed { background: #d93a32; color: #fff; }
#log .clock button.danger { color: inherit; }
#log .clock button.danger.armed { background: #d93a32; color: #fff; }

#log ol.events li .at small { display: block; font-size: 12px; font-weight: 600; opacity: 0.8; }

/* ------------------------------------------------ clock pop-over */
#clockDlg { width: min(560px, 94vw); border: 0; border-radius: 24px; padding: 20px; background: var(--panel); color: var(--text); }
#clockDlg::backdrop { background: #000a; }
#clockDlg header { display: flex; justify-content: space-between; align-items: center; font-size: 20px; font-weight: 800; }
#clockDlg .close { background: transparent; color: var(--accent); font-size: 18px; font-weight: 800; min-height: 44px; }
#clockDlg .label { margin-top: 10px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
#clockDlg .bigtime { text-align: center; font-size: clamp(64px, 18vw, 96px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
#clockDlg .bigtime.stoppage { color: #d12a2a; }
#clockDlg .nudges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
#clockDlg .nudges button { min-height: 68px; border-radius: 16px; font-size: 21px; font-weight: 800; background: color-mix(in srgb, var(--text) 10%, transparent); }
#clockDlg .set { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; color: var(--muted); font-weight: 700; }
#clockDlg .set input { width: 4.4em; height: 56px; text-align: center; border: 0; border-radius: 14px; font: inherit; font-size: 26px; font-weight: 800;
  background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font-variant-numeric: tabular-nums; }
#clockDlg .set b { font-size: 26px; color: var(--text); }
#clockDlg .set button { min-height: 56px; padding: 0 22px; border-radius: 14px; font-size: 19px; font-weight: 800; background: var(--accent); color: #fff; }
#clockDlg .restart { display: flex; justify-content: center; margin-top: 14px; }
#clockDlg .restart button { min-height: 48px; padding: 0 16px; border-radius: 12px; background: transparent; color: #d12a2a; font-size: 16px; font-weight: 700; }
#clockDlg .restart button.armed { background: #d93a32; color: #fff; }

/* ------------------------------------------------ live roster */
.live { display: grid; gap: 8px; padding: 14px; border-radius: 18px; background: color-mix(in srgb, var(--text) 5%, transparent); }
.live.off { grid-template-columns: 1fr auto; align-items: center; gap: 14px; }
.live.off strong { display: block; font-size: 18px; }
.live.off small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.live.off button { min-height: 52px; padding: 0 18px; border-radius: 14px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 800; }
.live h3 { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.live h3 small { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; opacity: 0.85; }
.live ol.field { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.live ol.field button { display: grid; grid-template-columns: 3.4em 1fr auto; align-items: center; gap: 8px; width: 100%; min-height: 54px; padding: 0 14px;
  border-radius: 14px; background: var(--panel); font-size: 17px; font-weight: 600; text-align: left; }
.live .pos { color: var(--accent); font-weight: 800; }
.live .pt { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 800; }
.live .bench { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.live .bench button { display: flex; align-items: center; gap: 8px; min-height: 50px; padding: 0 12px; border-radius: 14px;
  background: color-mix(in srgb, var(--text) 8%, transparent); font-size: 16px; font-weight: 600; text-align: left; }
.live .bench b { color: var(--accent); min-width: 1.6em; }
.live .bench small { margin-left: auto; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.live .liveFoot { display: flex; justify-content: flex-end; }
.live .liveFoot button { background: transparent; color: var(--muted); font-size: 14px; min-height: 40px; }
.live .liveFoot button.armed { background: #d93a32; color: #fff; }
#logPick .grid button small { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
#log .teams .opp { background: transparent; font: inherit; color: var(--muted); padding: 0 4px; min-height: 0; border-bottom: 2px dashed color-mix(in srgb, var(--muted) 50%, transparent); border-radius: 0; }
#log .teams .oppEdit { font: inherit; width: 8em; padding: 2px 8px; border-radius: 10px; border: 2px solid var(--accent); background: var(--panel); color: var(--text); }
@media (max-width: 520px) {
  .live.off { grid-template-columns: 1fr; }
  .live ol.field { grid-template-columns: 1fr; }
  #clockDlg { padding: 16px; }
  #clockDlg .nudges button { min-height: 60px; font-size: 18px; }
}

#menu .halfLen { align-items: center; }
#menu .halfLen span { font-weight: 700; margin-right: 6px; }
#menu .halfLen button { min-width: 52px; font-size: 22px; }

#clockDlg .bigtime:focus { outline: none; }

/* Clock block: meta (mode · half) / big time / controls. A row on iPad,
   stacked on phones. */
#log .clock .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#log .clock .ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 520px) {
  #log .clock { flex-direction: column; gap: 4px; }
  #log .clock .meta { flex-direction: row; gap: 10px; align-items: baseline; }
  #log .clock .time { font-size: 56px; line-height: 1.05; }
  #log .board { padding: 4px 0 0; }
  #log .teams { font-size: 17px; gap: 10px; }
  #log .teams .n { font-size: 46px; }
  #log .teams > span:first-child, #log .teams .them { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #log .actions .big { min-height: 64px; font-size: 18px; }
}
#menu header strong:focus { outline: none; }
