:root {
  /* Bloomberg-terminal palette: near-black ground, amber signal, phosphor green/red */
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #121212;
  --line: #2a2a2a;
  --line-soft: #1a1a1a;
  --text: #e8e2d4;          /* warm off-white, like terminal phosphor text */
  --muted: #9a9388;
  --faint: #6b6457;
  --accent: #ff9e00;        /* signature amber */
  --accent-dim: #cc7e00;
  --home: #2ecc71;          /* phosphor green */
  --away: #ff9e00;          /* amber */
  --live: #ff3b30;
  --radius: 0px;            /* terminals are all sharp corners */
  --radius-sm: 0px;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Top bar ---------- */
header {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--accent);
  background: var(--panel);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
.brand .dot {
  width: 8px; height: 8px; border-radius: 0;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255,59,48,.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,59,48,.55); }
  70% { box-shadow: 0 0 0 7px rgba(255,59,48,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); }
}
header .spacer { flex: 1; }
.seg {
  display: inline-flex; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 0; overflow: hidden;
}
.seg button {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 13px; font-size: 12px; cursor: pointer; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  transition: background .15s, color .15s;
}
.seg button.active { background: var(--accent); color: #000; }
.seg button:not(.active):hover { color: var(--text); }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 28px; border-radius: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.clock { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 12px; letter-spacing: 1px; }
.pill-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 6px 12px; border-radius: 0; cursor: pointer; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  transition: border-color .15s, color .15s;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn #matchesCount { color: var(--accent); font-weight: 700; }

/* ---------- Match grid ---------- */
.stage {
  flex: 1; display: grid; gap: 14px; padding: 14px; min-height: 0;
  grid-auto-rows: 1fr; overflow-y: auto;
}
.stage::-webkit-scrollbar { width: 9px; height: 9px; }
.stage::-webkit-scrollbar-thumb { background: var(--line); border-radius: 0; }
/* single match: centre it and cap the width so it doesn't stretch */
.stage.grid[data-count="1"] { justify-items: center; }
.stage.grid[data-count="1"] .match { max-width: 560px; }

/* Column view: a horizontal row of columns that shrink to a floor width, then
   overflow off-screen so the user can scroll sideways through the rest. */
.stage.column {
  display: flex; flex-direction: row; align-items: stretch;
  grid-auto-rows: initial; overflow-x: auto; overflow-y: hidden;
}
.stage.column .match {
  flex: 1 1 0; min-width: 320px; height: 100%;
}

.match {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  min-height: 0; width: 100%; overflow: hidden;
}
.match-head {
  padding: 9px 14px 8px; border-bottom: 1px solid var(--accent-dim);
  flex-shrink: 0; position: relative; background: var(--panel-2);
}
.rm-btn {
  width: 18px; height: 18px; flex-shrink: 0; border-radius: 0; cursor: pointer;
  background: var(--live); border: 0; color: #000; font-size: 11px; font-weight: 700;
  line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.rm-btn:hover { background: #ff6259; }
.comp-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.comp-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.comp { color: var(--accent); font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.status .blip { width: 7px; height: 7px; border-radius: 0; background: var(--live); animation: pulse 1.8s infinite; }
.status.ht .blip, .status.ft .blip { background: var(--faint); animation: none; }
.status .min { color: var(--live); font-variant-numeric: tabular-nums; }
.status.ht .min, .status.ft .min { color: var(--muted); }

.score-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team.away { flex-direction: row-reverse; text-align: right; }
.crest {
  width: 30px; height: 30px; border-radius: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #000; letter-spacing: .3px;
}
.tname { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .3px; }
.score {
  font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: 2px; padding: 0 6px; white-space: nowrap; color: var(--accent);
}

/* ---------- Stats body ---------- */
.stats { padding: 10px 16px 14px; overflow-y: auto; flex: 1; min-height: 0; }
.stats::-webkit-scrollbar { width: 8px; }
.stats::-webkit-scrollbar-thumb { background: var(--line); border-radius: 0; }
.stat { margin-bottom: 11px; }
.stat:last-child { margin-bottom: 2px; }
.stat-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.stat-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-val.h { color: var(--home); }
.stat-val.a { color: var(--away); }
.bar { display: flex; height: 5px; border-radius: 0; overflow: hidden; background: var(--line-soft); }
.bar .fill-h { background: var(--home); transition: width .6s cubic-bezier(.4,0,.2,1); }
.bar .fill-a { background: var(--away); transition: width .6s cubic-bezier(.4,0,.2,1); }
.bar .gap { width: 2px; background: var(--panel); }

.events { margin-top: 4px; }
.ev-title { font-size: 10.5px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin: 8px 0 6px; padding-top: 6px; border-top: 1px solid var(--accent-dim); }
.ev-none { font-size: 12px; color: var(--faint); padding: 2px 0 4px; }
.ev {
  display: flex; align-items: center; gap: 9px; padding: 4px 0;
  font-size: 12.5px; border-top: 1px solid var(--line-soft);
}
.ev .ev-min { color: var(--accent); width: 30px; font-variant-numeric: tabular-nums; flex-shrink: 0; font-size: 12px; font-weight: 600; }
.ev .ev-ico { width: 18px; text-align: center; flex-shrink: 0; }
.ev .ev-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.away-ev { flex-direction: row-reverse; text-align: right; }
.ev.away-ev .ev-txt { }
/* structural HT/FT markers: a muted, centred full-width divider, distinct from
   the side-aligned player events. */
.ev.ev-marker {
  justify-content: center; gap: 7px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px;
  font-size: 10.5px; font-weight: 700;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.ev.ev-marker .ev-min { width: auto; color: var(--muted); }
.ev.ev-marker .ev-ico { width: auto; }
.ev.ev-marker .ev-txt { flex: 0 0 auto; }

.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--faint); gap: 10px; text-align: center; padding: 30px;
}
.empty .big { font-size: 34px; opacity: .5; }
.empty button {
  margin-top: 6px; background: var(--accent); color: #000; border: 0;
  padding: 8px 16px; border-radius: 0; cursor: pointer; font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ---------- Drawer (settings) ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; max-width: 90vw;
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 50; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.drawer-head h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.drawer-body { overflow-y: auto; padding: 16px 18px; }
.drawer-body::-webkit-scrollbar { width: 8px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.sec-title { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .7px; font-weight: 600; margin: 18px 0 10px; }
.sec-title:first-child { margin-top: 0; }
.opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
}
.opt label { cursor: pointer; user-select: none; font-size: 13.5px; }
.opt:last-child { border-bottom: 0; }
/* toggle */
.tg { position: relative; width: 38px; height: 20px; flex-shrink: 0; }
.tg input { opacity: 0; width: 0; height: 0; }
.tg .track {
  position: absolute; inset: 0; background: var(--line); border-radius: 0;
  cursor: pointer; transition: background .15s; border: 1px solid var(--line);
}
.tg .track:before {
  content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px;
  background: var(--muted); border-radius: 0; transition: transform .15s, background .15s;
}
.tg input:checked + .track { background: var(--accent); border-color: var(--accent); }
.tg input:checked + .track:before { transform: translateX(18px); background: #000; }

.matchpick {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 8px 10px; border-radius: 0; font-size: 13px;
  margin-bottom: 8px; cursor: pointer; font-family: var(--mono);
}
.matchpick:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.chips-empty { font-size: 12.5px; color: var(--faint); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 0; padding: 4px 6px 4px 9px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px;
}
.chip-txt { color: var(--text); }
.chip-x {
  background: transparent; border: 0; color: var(--faint); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 1px 2px; border-radius: 4px;
}
.chip-x:hover { color: var(--live); }
.chips-count { font-size: 11.5px; color: var(--faint); margin-top: 8px; }

.live-note {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--accent);
  border-radius: 0; padding: 10px 12px; margin-top: 6px;
}
.live-note code { background: var(--bg); padding: 1px 5px; border-radius: 0; font-size: 11.5px; color: var(--accent); }
.speed-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.speed-row input[type=range] { flex: 1; accent-color: var(--accent); }
.speed-row .v { font-size: 12px; color: var(--muted); width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: rgba(255,158,0,.25); } 100% { background: transparent; } }

/* row-level update blink for stat bars and timeline entries — a brief amber
   wash that bleeds slightly past the row so it reads as a pulse, not a fill. */
.flash-row { animation: flashRow .9s ease; }
@keyframes flashRow {
  0%   { background: rgba(255,158,0,.20); box-shadow: 0 0 0 1px rgba(255,158,0,.25); }
  100% { background: transparent; box-shadow: 0 0 0 1px transparent; }
}

@media (max-width: 760px) {
  .stage.two { grid-template-columns: 1fr; }
}
