/* Game Center — the public-facing live page.
   Light, readable on a phone, and calm enough to leave open for a whole game. */

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #fff;
  --line: #e2e6ec;
  --fg: #111827;
  --mut: #5b6473;   /* #6b7280 was 4.46:1 on --bg (TR-QA-07) */
  --accent: #1d4ed8;
  --ok: #047857;
  --bad: #b91c1c;
  --warn: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 13.5px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.tiny { font-size: 11.5px; color: var(--mut); }
.empty { color: var(--mut); font-style: italic; text-align: center; padding: 26px; margin: 0; }
.empty.err { color: var(--bad); font-style: normal; }

/* ---- header ---- */
.bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 9px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.who h1 { display: block; font-size: 14px; margin: 0; font-weight: 700; }
.conn { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.conn label { display: flex; gap: 5px; align-items: center; }
input, select, button {
  font: inherit; padding: 4px 7px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--fg);
}
button { cursor: pointer; }
button:hover { border-color: #b6bfcc; }

.status {
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  background: #eef1f6; color: var(--mut); border: 1px solid var(--line);
  white-space: nowrap;
}
.status.live { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.status.connecting { background: #eff6ff; color: var(--accent); border-color: #bfdbfe; }
.status.retrying { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.status.error { background: #fef2f2; color: var(--bad); border-color: #fecaca; }

/* ---- layout ---- */
main { padding: 14px 16px 60px; max-width: 1140px; margin: 0 auto; }
h2 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--mut); margin: 16px 0 6px;
}
.cols { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.5fr); gap: 18px; align-items: start; }
/* Grid and flex items default to min-width:auto, which refuses to shrink
   below their content and pushes the whole page into horizontal scroll.
   Every track that holds free text needs this. */
.col { min-width: 0; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* ---- scorebug ---- */
.scorebug {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 16px; display: grid;
  grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center;
}
.scorebug .team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.scorebug .team.away { justify-content: flex-end; }
.scorebug .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorebug .sc {
  font: 700 32px/1 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums; margin-left: auto;
}
.scorebug .team.away .sc { margin: 0 auto 0 0; }
.dot { width: 11px; height: 11px; border-radius: 4px; flex: 0 0 auto; }
.clk { text-align: center; padding: 0 14px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.clk .per { font-size: 10.5px; color: var(--mut); text-transform: uppercase; letter-spacing: .08em; }
.clk .tm { font: 700 20px/1.2 ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }
.periods {
  grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 9px; font-size: 11.5px; color: var(--mut);
}

/* On a narrow viewport the fixed 32px score squeezes the team name until it
   ellipses to a single letter, which is worse than useless on a scoreboard.
   Let the name wrap and shrink the score instead: the name is the part a
   reader cannot reconstruct from context. */
@media (max-width: 720px) {
  .scorebug { padding: 12px; gap: 9px; }
  .scorebug .nm { white-space: normal; font-size: 12.5px; line-height: 1.25; }
  .scorebug .sc { font-size: 24px; }
  .clk { padding: 0 8px; }
  .clk .tm { font-size: 17px; }
}

/* Below ~520px there is not enough room for two teams side by side without
   the name losing to the score. Stack into three full-width rows so the name
   always has the whole line: on a phone the club you are following is the
   one thing that must never be an ellipsis. */
@media (max-width: 520px) {
  .scorebug { grid-template-columns: 1fr; gap: 4px; }
  .scorebug .team,
  .scorebug .team.away {
    display: grid; grid-template-columns: 12px 1fr auto;
    align-items: center; gap: 10px; justify-content: initial;
  }
  /* The away row is authored score-first for the wide layout; restore
     reading order here so both rows line up under each other. */
  .scorebug .team.away .dot { order: 1; }
  .scorebug .team.away .nm  { order: 2; }
  .scorebug .team.away .sc  { order: 3; }
  .scorebug .sc,
  .scorebug .team.away .sc { margin: 0; text-align: right; }
  .scorebug .nm { white-space: nowrap; font-size: 14px; }
  .clk {
    border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    padding: 7px 0; margin: 3px 0; display: flex; gap: 10px;
    align-items: baseline; justify-content: center;
  }
}

/* ---- play-by-play ---- */
.pbp {
  list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
}
.pbp li {
  display: grid; grid-template-columns: 26px 42px 1fr auto; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); align-items: baseline;
}
.pbp li:last-child { border-bottom: 0; }
.pbp .d { min-width: 0; overflow-wrap: anywhere; }
.pbp li:first-child { background: #eff6ff; }
.pbp .s { font: 600 11.5px/1 ui-monospace, Consolas, monospace; }

/* ---- box score ---- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
table.box { border-collapse: collapse; width: 100%; font: 11.5px/1.35 ui-monospace, Consolas, monospace; }
table.box th, table.box td { padding: 4px 7px; text-align: right; white-space: nowrap; }
table.box th { color: var(--mut); font-weight: 500; border-bottom: 1px solid var(--line); }
table.box .l { text-align: left; }
table.box .b { font-weight: 700; }
/* Row headers (players, the team line) are <th> for screen readers since
 * TR-QA-07, and keep the look they had as <td>. */
table.box tbody th { color: var(--fg); font-weight: 400; border-bottom: 0; }
table.box tr.th th {
  background: #f3f5f8; color: var(--fg); font-weight: 700; padding: 6px 7px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
table.box tr.tot td, table.box tr.tot th { border-top: 1px solid var(--line); color: var(--mut); font-weight: 600; }
table.box tbody tr:hover td, table.box tbody tr:hover th { background: #f8fafc; }

/* ---- shot charts ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .charts { grid-template-columns: 1fr; } }
.charts figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px; }
.charts figcaption { margin-bottom: 5px; }
.court { width: 100%; height: auto; display: block; }
