:root {
  --bg: #0b0f0d;
  --bg-2: #111815;
  --panel: #141c18;
  --line: #24302a;
  --text: #e9efe9;
  --muted: #93a49a;
  --amber: #ffb020;
  --amber-dim: rgba(255, 176, 32, 0.09);
  --pitch: #1f9d55;
  --home: #ffb020;
  --away: #5ab0ff;
  --red: #ff4d4d;
  --yellow: #ffd23f;
  --radius: 14px;
  --head: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
body[data-sport="basketball"] { --pitch: #e3762b; }
body[data-sport="rugby"] { --pitch: #2fae6a; }
body[data-sport="baseball"] { --pitch: #c9a46a; }
body[data-sport="nfl"] { --pitch: #3d9b4f; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -120px, color-mix(in srgb, var(--pitch) 22%, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--body);
  min-height: 100vh;
  transition: background-color .4s;
}
a { color: var(--amber); }
button, input { font: inherit; color: inherit; }
.wrap { width: min(860px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 10; background: var(--amber); color: #000; padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: rgba(11, 15, 13, .7); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 600 24px/1 var(--head); letter-spacing: .02em; }
.brand b { color: var(--amber); font-weight: 700; }
.brand-mark { width: 30px; height: 30px; color: var(--amber); }
.demo-tag { font: 600 12px/1 var(--body); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); border: 1px solid var(--line); padding: 6px 10px; border-radius: 99px; }

/* Sport tabs */
.sports { margin: 22px 0 16px; }
.sports-track { display: flex; gap: 6px; padding: 5px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px; overflow-x: auto; scrollbar-width: none; }
.sports-track::-webkit-scrollbar { display: none; }
.sport {
  flex: 1 0 auto; border: 0; background: transparent; cursor: pointer;
  padding: 9px 16px; border-radius: 99px;
  font: 600 18px/1 var(--head); letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  transition: background .2s, color .2s;
}
.sport:hover { color: var(--text); }
.sport[aria-selected="true"] { background: var(--pitch); color: #06100a; }

/* Scoreboard */
.board {
  position: relative;
  background: linear-gradient(#0e1311, #080b0a);
  border: 1px solid #2c3833;
  border-radius: 20px;
  padding: 14px 18px 12px;
  box-shadow: 0 0 0 6px #121916, 0 0 0 7px #24302a, 0 24px 60px -20px rgba(0, 0, 0, .8), inset 0 0 40px rgba(0, 0, 0, .7);
  margin: 10px 7px 26px;
}
.board::after { /* LED dot-matrix sheen */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .025) 1px, transparent 1.4px);
  background-size: 5px 5px;
}
.board-head, .board-foot { display: flex; justify-content: space-between; align-items: center; font: 600 15px/1 var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.board-foot { justify-content: center; min-height: 18px; margin-top: 8px; letter-spacing: .08em; text-transform: none; font-size: 16px; }
.board-status { color: var(--amber); }
.board-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 10px; }
.side { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.team-name {
  width: 100%; max-width: 240px; text-align: center;
  background: transparent; border: 1px dashed transparent; border-radius: 8px; padding: 4px 6px;
  font: 700 clamp(18px, 4.4vw, 28px)/1.1 var(--head); letter-spacing: .06em; text-transform: uppercase;
  text-overflow: ellipsis;
}
.team-name:hover { border-color: var(--line); }
.team-name:focus { border-color: var(--amber); outline: none; background: rgba(255, 255, 255, .03); }
.side-home .team-name { color: var(--home); }
.side-away .team-name { color: var(--away); }

.digits { display: flex; gap: clamp(4px, 1vw, 8px); height: clamp(70px, 18vw, 120px); }
.digits svg { height: 100%; width: auto; overflow: visible; }
.seg { fill: currentColor; opacity: .07; transition: opacity .15s; }
.seg.on { opacity: 1; filter: drop-shadow(0 0 6px currentColor); }
.side-home .digits { color: var(--home); }
.side-away .digits { color: var(--away); }
.digits.flash svg { animation: flash .7s ease 2; }
@keyframes flash { 50% { opacity: .25; } }

.clock-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.clock { font: 700 clamp(18px, 4vw, 24px)/1 var(--head); color: var(--text); background: #000; border: 1px solid #222; padding: 6px 10px; border-radius: 8px; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.vs { font: 600 16px/1 var(--head); color: var(--muted); text-transform: uppercase; }

/* Controls */
.controls { display: grid; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.balance-label { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.balance-label output { color: var(--amber); font-weight: 500; }
.balance-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-top: 8px; }
.balance-end { font: 600 14px/1 var(--head); letter-spacing: .08em; text-transform: uppercase; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#balAway { color: var(--away); }
#balHome { color: var(--home); }
input[type="range"] { width: 100%; accent-color: var(--amber); } /* left (-3) = away stronger, right (+3) = home stronger */
.toggles { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--muted); }
.toggle input { width: 18px; height: 18px; accent-color: var(--amber); }
.toggle input:checked + span { color: var(--text); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font: 700 20px/1 var(--head); letter-spacing: .06em; text-transform: uppercase;
  padding: 15px 22px; transition: transform .1s, background .2s, border-color .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn svg { width: 16px; height: 16px; }
.btn-main { flex: 1 1 220px; background: var(--amber); color: #1a1100; }
.btn-main:hover { background: #ffc24d; }
.btn-ghost { flex: 0 1 auto; background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--amber); }
.btn-ghost.stop { border-color: var(--red); color: var(--red); }
.btn-small { font-size: 15px; padding: 10px 14px; background: transparent; border-color: var(--line); color: var(--text); }
.btn-small:hover { border-color: var(--amber); }

/* Panels */
.panels { display: grid; gap: 16px; margin-top: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel h2, .about h2 { margin: 0 0 12px; font: 700 20px/1.1 var(--head); letter-spacing: .08em; text-transform: uppercase; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.chip input:checked + span { border-color: var(--amber); color: var(--text); background: var(--amber-dim); }
.chip input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; }

.table-scroll { overflow-x: auto; }
.linescore { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.linescore th, .linescore td { padding: 8px 9px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.linescore th { font: 600 14px/1 var(--head); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.linescore td:first-child, .linescore th:first-child { text-align: left; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.linescore tr:last-child td { border-bottom: 0; }
.linescore .tot { font-weight: 700; color: var(--text); background: rgba(255, 255, 255, .03); }
.linescore .win { color: var(--amber); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.dot.home { background: var(--home); }
.dot.away { background: var(--away); }

.timeline { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 66px 1fr auto; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); animation: in .25s ease both; }
.ev:last-child { border-bottom: 0; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
.ev-time { font: 600 15px/1 var(--head); color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-text { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ev-text > span:last-child { min-width: 0; }
.ev-team { font-weight: 600; }
.ev-team.home { color: var(--home); }
.ev-team.away { color: var(--away); }
.ev-score { font: 700 16px/1 var(--head); font-variant-numeric: tabular-nums; color: var(--muted); }
.ev.goal .ev-score, .ev.score .ev-score, .ev.pen-in .ev-score { color: var(--text); }
.ico { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; font-size: 13px; line-height: 1; }
.ico.goal, .ico.score { background: var(--pitch); color: #04100a; }
.ico.yellow { width: 14px; height: 19px; border-radius: 3px; background: var(--yellow); margin: 0 4px; }
.ico.red { width: 14px; height: 19px; border-radius: 3px; background: var(--red); margin: 0 4px; }
.ico.sub, .ico.run, .ico.lead { color: var(--pitch); border: 1px solid var(--line); }
.ico.whistle, .ico.info, .ico.period { color: var(--muted); border: 1px solid var(--line); }
.ico.miss, .ico.pen-out, .ico.turnover { color: var(--red); border: 1px solid var(--line); }
.ico.pen-in { background: var(--pitch); color: #04100a; }
.ev.whistle .ev-text, .ev.info .ev-text, .ev.period .ev-text { color: var(--muted); }
.ev.whistle .ev-text { font-weight: 600; letter-spacing: .02em; }
.empty { color: var(--muted); padding: 8px 4px; }

.stats { display: grid; gap: 12px; }
.stat-row { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 10px; }
.stat-mid { text-align: center; }
.stat-name { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.stat-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; height: 7px; }
.bar { background: #0a0e0c; border-radius: 99px; overflow: hidden; position: relative; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar.h i { right: 0; background: var(--home); }
.bar.a i { left: 0; background: var(--away); }
.stat-val { font: 700 20px/1 var(--head); font-variant-numeric: tabular-nums; }
.stat-val.h { text-align: left; color: var(--home); }
.stat-val.a { text-align: right; color: var(--away); }
.stat-row.shared .stat-bars { visibility: hidden; }

.share { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 2px 4px; }
.seed { color: var(--muted); font-size: 15px; }
.seed code { color: var(--text); font: 600 16px/1 var(--head); letter-spacing: .1em; background: var(--bg-2); border: 1px solid var(--line); padding: 4px 8px; border-radius: 6px; }

.about { margin: 34px 0 10px; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 28px; color: var(--muted); }
.about-grid p { margin: 0 0 12px; }
.about-grid b { color: var(--text); font-weight: 600; }

.legal { max-width: 680px; margin: 28px auto 0; }
.legal h1 { font: 700 34px/1.1 var(--head); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 6px; }
.legal h2 { font: 700 20px/1.2 var(--head); letter-spacing: .06em; text-transform: uppercase; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--muted); }
.legal b { color: var(--text); font-weight: 600; }
.legal .updated { font-size: 14px; }
.foot { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 0 40px; color: var(--muted); font-size: 14px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: #000; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 15px;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Ad slots: hidden until body.ads-on; fixed height so the page doesn't jump when an ad loads */
.ad-slot { display: none; }
body.ads-on .ad-slot { display: block; min-height: 280px; margin: 16px 0; text-align: center; overflow: hidden; }
@media (min-width: 728px) { body.ads-on .ad-slot { min-height: 100px; } }

body:not([data-sport="soccer"]) .soccer-only { display: none !important; }

@media (max-width: 560px) {
  .board { padding: 12px 10px 10px; margin-inline: 6px; }
  .board-body { gap: 4px; }
  .clock { min-width: 52px; padding: 5px 6px; }
  .controls, .panel { padding: 14px; }
  .ev { grid-template-columns: 50px 1fr auto; gap: 8px; }
  .stat-row { grid-template-columns: 40px 1fr 40px; }
  .linescore th, .linescore td { padding: 7px 5px; }
  .linescore td:first-child, .linescore th:first-child { max-width: 96px; }
  .btn-ghost { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
