/* Layout: one-screen table game. Scoreboard bar, LED ticker, then the board fills the rest.
   Single dark "games room" look by choice. */
:root {
  /* Pitch-side at night: deep pine stands, corner-flag coral for actions,
     LED-scoreboard green for anything the stadium board would show. */
  --night: #07110d;
  --panel: #0e1c16;
  --panel-2: #15281f;
  --line: #24392e;
  --grass-light: #4f9a3c;
  --grass-dark: #3f8631;
  --accent: #ff5a3c;
  --accent-ink: #1a0905;
  --led: #8ff0b0;
  --red: #e8412c;
  --ink: #eef4ee;
  --mute: #8aa396;
  --team0: #e2382f;
  --team1: #2c66dc;
  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-led: "Silkscreen", "Courier New", monospace;
  --f-body: "Barlow", system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input[type="text"], input:not([type]) { -webkit-user-select: text; user-select: text; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  height: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: calc(10px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--f-display); font-weight: 800; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; line-height: 1; }
.brand small { display: block; font-family: var(--f-body); font-weight: 500; font-size: 11px; letter-spacing: .12em; color: var(--mute); margin-top: 3px; }
.tools { display: flex; gap: 8px; }
.tbtn {
  font: 600 13px/1 var(--f-body);
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.tbtn:hover { border-color: var(--mute); }
.tbtn[aria-pressed="false"] { color: var(--mute); }
button:focus-visible, input:focus-visible, summary:focus-visible, .seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Scoreboard */
.score {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.team { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 6px 7px; border-top: 4px solid var(--team0); min-width: 0; }
#teamBox1 { border-top-color: var(--team1); }
.chip { width: 30px; height: 30px; margin-bottom: 2px; }
.team b { font-family: var(--f-display); font-weight: 800; font-size: 24px; line-height: 1; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.team small { font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); white-space: nowrap; }
.centre { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 16px; background: var(--night); border-inline: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.goals { font-family: var(--f-display); font-weight: 900; font-size: 42px; line-height: .95; display: flex; gap: 8px; align-items: center; }
.goals i { font-style: normal; font-size: 22px; color: var(--mute); }
.clock { font-family: var(--f-display); font-weight: 800; font-size: 24px; color: var(--led); line-height: 1.1; }
.clock.low { color: #ff8a7e; }
.half { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }

/* LED ticker */
.ticker {
  --turn: var(--team0);
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--turn);
  border-radius: 6px;
  padding: 6px 10px;
  height: 50px;
  flex: none;
}
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--turn); flex: none; box-shadow: 0 0 10px var(--turn); }
.msg { color: var(--led); flex: 1; min-width: 0; margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-family: var(--f-led); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; line-height: 1.45; text-align: center; text-wrap: balance; }
.timer { flex: none; font-family: var(--f-display); font-weight: 800; font-size: 18px; background: var(--panel-2); border-radius: 999px; padding: 4px 11px; min-width: 2.6em; text-align: center; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red); }

/* Board */
.stage { position: relative; flex: 1; min-height: 0; }
#cv, #cv3d { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#cv3d { z-index: 2; border-radius: 6px; }

/* Broadcast wipe: three angled bands sweep across with the word REPLAY */
.wipe { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; display: grid; place-items: center; }
.wipe i { position: absolute; top: -10%; bottom: -10%; left: 0; width: 70%; transform: translateX(-160%) skewX(-18deg); }
.wipe i:nth-child(1) { background: var(--accent); }
.wipe i:nth-child(2) { background: var(--led); }
.wipe i:nth-child(3) { background: var(--night); }
.wipe b { position: relative; font: 900 54px/1 var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--ink); opacity: 0; }
.wipe.run i { animation: sweep .75s cubic-bezier(.7,0,.3,1) forwards; }
.wipe.run i:nth-child(2) { animation-delay: .06s; }
.wipe.run i:nth-child(3) { animation-delay: .12s; }
.wipe.run b { animation: flash .75s ease forwards; }
@keyframes sweep { to { transform: translateX(260%) skewX(-18deg); } }
@keyframes flash { 30%, 60% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .wipe.run i { animation: none; display: none; }
  .wipe.run b { animation: flash .6s ease forwards; }
}

.replay-tag {
  color: var(--led);
  z-index: 3;
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(10, 14, 24, .86); border: 1px solid rgba(255, 255, 255, .15); border-radius: 6px;
  padding: 6px 10px;
  font: 400 12px/1 var(--f-led); letter-spacing: .1em; text-transform: uppercase;
  pointer-events: none;
}
.replay-tag small { font: 500 11px/1 var(--f-body); letter-spacing: 0; text-transform: none; color: var(--mute); }
.replay-tag .rec { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
@media (prefers-reduced-motion: no-preference) {
  .replay-tag .rec { animation: blink 1s steps(2, start) infinite; }
  @keyframes blink { to { visibility: hidden; } }
}

.banner {
  --team: var(--accent);
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92%, 390px);
  max-height: 94%; overflow-y: auto;
  text-align: center;
  background: color-mix(in srgb, var(--night) 90%, transparent);
  border: 2px solid var(--team);
  border-radius: 8px;
  padding: 16px 16px 18px;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.banner .bt { font-family: var(--f-display); font-weight: 900; font-size: 54px; line-height: .95; text-transform: uppercase; color: var(--team); letter-spacing: .02em; text-wrap: balance; }
.banner .bs { margin-top: 6px; font-family: var(--f-led); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; text-wrap: balance; line-height: 1.5; }
.banner button { pointer-events: auto; margin-top: 14px; width: 100%; }
@media (prefers-reduced-motion: no-preference) {
  .banner.pop { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
  @keyframes pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }
}
.stats { margin-top: 14px; }
.stats table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.stats th { font: 800 15px/1.1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; padding: 0 4px 6px; width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats th:first-child { color: var(--team0-text, var(--ink)); }
.stats td { padding: 5px 4px; border-top: 1px solid var(--line); }
.stats td:nth-child(2) { color: var(--mute); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; width: 40%; }
.stats td:first-child, .stats td:last-child { font-weight: 600; font-size: 16px; }
.stats .lead { color: var(--led); }
.stats caption { caption-side: bottom; color: var(--mute); font-size: 11px; padding-top: 8px; }

/* Menu */
.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: center;
  background: color-mix(in srgb, var(--night) 62%, transparent);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  padding-block: 8px;
  -webkit-overflow-scrolling: touch;
}
.sheet {
  width: min(100%, 440px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 18px 18px;
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  margin: auto;
}
.sheet h1 { margin: 0; font-family: var(--f-display); font-weight: 900; font-size: 38px; line-height: .95; text-transform: uppercase; text-wrap: balance; }
.sheet h1 span { color: var(--accent); }
.lede { margin: -8px 0 0; color: var(--mute); line-height: 1.45; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
fieldset:disabled .seg span, fieldset:disabled .check { opacity: .5; cursor: not-allowed; }
legend { padding: 0; margin-bottom: 8px; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 100%; text-align: center; cursor: pointer;
  padding: 10px 6px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 14px; line-height: 1.2;
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg.small span { padding: 7px 4px; font-size: 12px; }
.seg.pitches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pitches span { padding: 6px 5px 8px; font-size: 13px; }
.pv { display: block; width: 100%; height: 34px; border-radius: 3px; border: 2px solid rgba(255,255,255,.5); }
.pv-stripes { background: repeating-linear-gradient(180deg, var(--grass-light) 0 6px, var(--grass-dark) 6px 12px); }
.pv-checker { background: repeating-conic-gradient(#52a03f 0 25%, var(--grass-dark) 0 50%) 0 0 / 12px 12px; }
.pv-mud { background: radial-gradient(ellipse at 50% 20%, #6b4a2b 0 25%, transparent 55%), radial-gradient(ellipse at 40% 85%, #5d4126 0 25%, transparent 50%), radial-gradient(ellipse at 60% 52%, #63462a 0 18%, transparent 40%), #5a8a3e; }
.pv-felt { background: linear-gradient(transparent 46%, #5ed3dc 46% 54%, transparent 54%), #15191e; border-color: #3ab4c6; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; line-height: 1.35; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--mute); font-size: 13px; }
.note { font-size: 12.5px; color: var(--mute); margin: 0; line-height: 1.45; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1 1 auto; cursor: pointer;
  font: 800 20px/1 var(--f-display); text-transform: uppercase; letter-spacing: .04em;
  padding: 12px 16px; border-radius: 6px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: progress; }
details { color: var(--mute); font-size: 14px; line-height: 1.5; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; color: var(--ink); font-weight: 600; }
details ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* Online */
.online-start { display: flex; flex-direction: column; gap: 8px; }
.join { display: flex; gap: 8px; }
.join input {
  flex: 1; min-width: 0;
  font: 800 22px/1 var(--f-display); letter-spacing: .25em; text-transform: uppercase; text-align: center;
  color: var(--ink); background: var(--night); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
}
.join .btn { flex: 0 0 auto; }
.host-box { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--night); border: 1px dashed var(--line); border-radius: 8px; padding: 12px; }
.code { font: 900 46px/1 var(--f-display); letter-spacing: .22em; color: var(--accent); padding-left: .22em; font-variant-numeric: tabular-nums; }
.host-box .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.note.link { word-break: break-all; text-align: center; -webkit-user-select: all; user-select: all; }
.status { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink); }
.status.err { color: #ff9b8f; }
.status.ok { color: #9be38d; }

/* Kits */
.kits summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; }
.kits summary::-webkit-details-marker { display: none; }
.kits summary::after { content: "Edit"; font-size: 12px; font-weight: 600; color: var(--accent); }
.kits[open] summary::after { content: "Done"; }
.kit-mini { display: flex; gap: 4px; margin-left: auto; }
.kit-mini canvas { width: 22px; height: 22px; }
.kit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.kit { display: flex; flex-direction: column; gap: 10px; background: var(--night); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; color: var(--ink); }
.kit:disabled { opacity: .55; }
.kit-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kit-head canvas { width: 40px; height: 40px; flex: none; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.field span, .kit-label { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.field input {
  width: 100%; min-width: 0;
  font: 800 18px/1 var(--f-display); text-transform: uppercase; letter-spacing: .02em;
  color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sw {
  width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid rgba(255,255,255,.18); background: var(--c);
}
.sw[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--night), 0 0 0 4px var(--accent); }
.kit-note { font-size: 12px; color: var(--mute); margin: 0; }

@media (max-width: 420px) {
  .team b { font-size: 20px; }
  .goals { font-size: 36px; }
  .clock { font-size: 20px; }
  .chip { width: 24px; height: 24px; }
  .brand small { display: none; }
  .msg { font-size: 10px; }
  .banner .bt { font-size: 44px; }
}
@media (max-width: 380px) {
  .kit-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 640px) {
  .chip, .team small, .half { display: none; }
  .goals { font-size: 32px; }
  .team { padding-block: 6px; }
}

/* ---------- Setup sheet header ---------- */
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h1 { font-size: 30px; }

/* ---------- Full-time / banner buttons ---------- */
.banner-actions { display: flex; gap: 8px; margin-top: 14px; }
.banner-actions:not(:has(button:not([hidden]))) { display: none; }
.banner .banner-actions button { margin-top: 0; flex: 1; width: auto; }

/* ---------- Home ----------
   The stadium keeps running behind, dimmed, so the home screen feels like walking in. */
.home {
  position: fixed; inset: 0; z-index: 20;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, color-mix(in srgb, var(--night) 35%, transparent), color-mix(in srgb, var(--night) 92%, transparent) 70%),
    color-mix(in srgb, var(--night) 55%, transparent);
  backdrop-filter: blur(3px);
  padding-inline: 16px;
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-bottom, 0px));
}
.home-inner { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; min-height: 100%; justify-content: center; }
#homeArt { width: min(100%, 360px); height: auto; aspect-ratio: 12 / 5; align-self: center; }
@media (prefers-reduced-motion: no-preference) {
  #homeArt { animation: bob 3.2s ease-in-out infinite; }
  @keyframes bob { 50% { transform: translateY(-6px); } }
}
.home-title { margin: -6px 0 0; font: 900 clamp(48px, 15vw, 72px)/.88 var(--f-display); text-transform: uppercase; letter-spacing: .01em; text-align: center; text-wrap: balance; }
.home-title span { color: var(--accent); display: block; }
.home-lede { margin: 0; text-align: center; color: var(--mute); font-size: 16px; line-height: 1.45; text-wrap: balance; }
.home-play { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.play-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; cursor: pointer;
  padding: 16px 18px; border-radius: 10px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line);
  font: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.play-card:hover { border-color: var(--mute); }
.play-card:active { transform: scale(.98); }
.play-card.hero { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding-block: 20px; }
.pc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pc-text b { font: 800 24px/1 var(--f-display); text-transform: uppercase; letter-spacing: .02em; }
.play-card.hero .pc-text b { font-size: 28px; }
.pc-text small { font-size: 13.5px; opacity: .78; }
.pc-go { font: 800 26px/1 var(--f-display); opacity: .8; }
.home-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; }
.home-links button {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  font: 600 14px/1 var(--f-body); color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 5px; text-decoration-thickness: 2px;
}
.home-links button:hover { text-decoration-color: var(--accent); }
.home-foot { margin: 0; text-align: center; font-size: 12px; color: var(--mute); }

/* ---------- Pause ---------- */
.pause {
  position: fixed; inset: 0; z-index: 15;
  display: grid; place-items: center;
  padding-inline: 16px;
  background: color-mix(in srgb, var(--night) 70%, transparent);
  backdrop-filter: blur(4px);
}
.pause-card {
  width: min(100%, 320px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 18px 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.pause-card h2 { margin: 0; font: 900 40px/1 var(--f-display); text-transform: uppercase; text-align: center; color: var(--led); letter-spacing: .04em; }
.pause-card .note { text-align: center; }
.pause-card .note:empty { display: none; }
.pause-actions { display: flex; flex-direction: column; gap: 8px; }
.btn[data-armed] { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- Rule call-outs and cards ---------- */
.callout {
  --team: var(--accent);
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 200px; max-width: 90%;
  padding: 10px 18px 12px;
  background: color-mix(in srgb, var(--night) 90%, transparent);
  border: 2px solid var(--team); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  text-align: center;
}
.callout b { font: 900 30px/1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; color: var(--team); }
.callout span { font: 400 10.5px/1.4 var(--f-led); letter-spacing: .08em; text-transform: uppercase; }
@media (prefers-reduced-motion: no-preference) {
  .callout.pop { animation: drop .35s cubic-bezier(.2,1.5,.4,1); }
  @keyframes drop { from { transform: translate(-50%, -14px); opacity: 0; } }
}
.cards { display: flex; gap: 4px; min-height: 0; flex-wrap: wrap; justify-content: center; }
.cards:empty { display: none; }
.cards i { font: 700 9px/1 var(--f-body); font-style: normal; padding: 3px 4px 2px; border-radius: 2px; color: #1a1400; background: #f3c623; }
.cards i.bin { background: #e8412c; color: #fff; font-variant-numeric: tabular-nums; }
