:root {
  /* Surfaces: dark elevation climbs in lightness, about +0.04 L per level. */
  --bg: oklch(0.1439 0.0083 165);
  --panel: oklch(0.1869 0.0134 160);
  --panel-2: oklch(0.2113 0.0165 160);
  --glass: oklch(0.2113 0.0165 160 / 0.72);
  --line: oklch(0.2701 0.0232 157);
  --line-soft: oklch(0.2350 0.0194 161);

  /* Ink: faint sits at 4.7:1 on the card surface, over the 4.5:1 body floor. */
  --text: oklch(0.9574 0.0150 152);
  --muted: oklch(0.6915 0.0363 157);
  --faint: oklch(0.6105 0.0293 159);

  --accent: oklch(0.7957 0.2002 154);
  --accent-dim: oklch(0.6759 0.1692 154);
  --accent-ink: oklch(0.1658 0.0262 162);
  --amber: oklch(0.8490 0.1484 81);
  --live: oklch(0.6756 0.2131 20);

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Archivo", "Helvetica Neue", sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, monospace;

  /* One easing set, reused everywhere. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scrollbar-color: var(--line) var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus is visible on every control: the accent ring at 2px, offset so it clears
   the element's own border. Never removed without a replacement. */
:where(button, a, input, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* The dialog takes focus on open so screen readers announce it, but it is a
   programmatic target, not a control: no ring. Its children still get one. */
[tabindex="-1"]:focus { outline: none; }

strong { font-weight: 600; }

/* Announced, not drawn. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.floodlight {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 50% -120px, rgba(0, 224, 126, 0.10), transparent 70%),
    radial-gradient(1400px 800px at 85% 110%, rgba(0, 224, 126, 0.035), transparent 60%);
  z-index: 0;
}

header, main, footer, .window-banner { position: relative; z-index: 1; }

/* ---------- header ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: oklch(0.1439 0.0083 165 / 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 30px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 15px; }

.mark {
  width: 44px; height: 44px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.mark::before {
  content: "";
  position: absolute;
  left: 50%; top: -2px; bottom: -2px;
  width: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  opacity: 0.85;
}
.mark span {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
  transform: translate(-50%, -50%);
}

.wordmark h1 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}
.wordmark h1 em { font-style: normal; color: var(--accent); }
.tag { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.header-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  white-space: nowrap;
}
.chip.ok { color: var(--accent); border-color: rgba(0, 224, 126, 0.35); }
.chip.warn { color: var(--amber); border-color: rgba(255, 194, 75, 0.35); }

/* ---------- international window banner ---------- */

.window-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 30px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: linear-gradient(90deg, rgba(0, 224, 126, 0.10), rgba(0, 224, 126, 0.02));
  border-bottom: 1px solid var(--line-soft);
}
.window-banner::before { content: "●"; font-size: 9px; }

/* ---------- layout ---------- */

main {
  display: grid;
  grid-template-columns: 252px 1fr;
  flex: 1;
  min-height: 0;
}

#league-nav {
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px 30px;
  /* The fixture list runs thousands of pixels; the competition switcher rides along
     with it instead of scrolling away at the top of the page. */
  align-self: start;
  position: sticky;
  top: var(--header-h, 90px);
  max-height: calc(100svh - var(--header-h, 90px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.nav-group {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.19em;
  color: var(--faint);
  margin: 20px 10px 7px;
}
.nav-group:first-child { margin-top: 0; }

.league-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font-family: var(--body);
  font-size: 13.5px;
  text-align: left;
  transition: background 0.12s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .league-btn:hover { background: var(--panel); }
}
.league-btn:active { background: var(--panel-2); }
.league-btn.active {
  background: var(--panel-2);
  border-left-color: var(--accent);
  color: var(--accent);
}
.league-btn .nav-icon,
.league-btn .nav-flag {
  flex-shrink: 0;
  width: 15px;
  display: grid;
  place-items: center;
}
.league-btn .nav-icon { color: var(--accent-dim); }
.league-btn.active .nav-icon { color: var(--accent); }

.league-btn .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.league-btn.active .count { color: var(--accent-dim); }

/* ---------- fixtures ---------- */

#fixtures { padding: 24px 30px 50px; overflow-y: auto; }

.day-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: oklch(0.1439 0.0083 165 / 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0 12px;
}
.day-header:first-child { margin-top: 0; }
.day-header b {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text);
}
.day-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.match-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
  /* Rows stagger 40ms apart, capped so the last one starts within 280ms. */
  animation: rise 0.35s var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 7) * 40ms);
  transition: border-color 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .match-card:hover { border-color: var(--line); background: var(--panel-2); }
}

.match-when { display: flex; flex-direction: column; gap: 2px; }
.match-time {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.match-live {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--live);
}
.match-live::before {
  content: "●";
  margin-right: 4px;
  animation: pulse 1.4s infinite;
}

.match-middle { min-width: 0; }

.match-teams {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-teams img {
  width: 24px; height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}
.match-teams .vs {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.1em;
  padding: 0 2px;
}

.match-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
}
.comp-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
}
.odds-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--amber);
  letter-spacing: 0.05em;
}

.sim-btn {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.12s var(--ease-out), transform 0.12s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .sim-btn:hover { background: oklch(0.8614 0.2002 154); transform: translateY(-1px); }
}
.sim-btn:active { transform: scale(0.97); }
.sim-btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.sim-btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

.empty-note { color: var(--faint); padding: 30px 0; font-size: 14px; }

/* ---------- modal ---------- */

#modal-backdrop[hidden] { display: none; }
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 4, 0.8);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 20px 20px;
  z-index: 10;
  overflow-y: auto;
}

#modal {
  background: var(--panel);
  /* Dark elevation: a hairline light ring plus a long soft shadow, not a dark border. */
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.06), 0 16px 48px oklch(0 0 0 / 0.5);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 660px;
  width: 100%;
  padding: 28px 30px;
  position: relative;
  animation: rise 0.25s var(--ease-out) both;
}

#modal-close {
  position: absolute;
  top: 10px; right: 12px;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s var(--ease-out), color 0.12s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  #modal-close:hover { color: var(--text); background: var(--panel-2); }
}
#modal-close:active { transform: scale(0.94); }

.faceoff {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin: 4px 0 6px;
}
.faceoff .side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 150px;
}
.faceoff img { width: 54px; height: 54px; object-fit: contain; }
.faceoff .side b {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.15;
}
.faceoff .vs-big {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.2em;
}

.fixture-meta {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
}
.fixture-meta .odds-tag { margin-left: 8px; }

.modal-copy { color: var(--muted); font-size: 13.5px; max-width: 58ch; margin: 0 auto 14px; text-align: center; }

.field { margin: 14px 0; text-align: center; }
.field label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 13.5px;
  cursor: pointer;
}
.field input[type="checkbox"] { accent-color: var(--accent); }
.field .hint { color: var(--faint); font-size: 11.5px; margin-top: 4px; }

.price-line {
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--amber);
  margin: 14px 0;
  letter-spacing: 0.04em;
}

.modal-actions { text-align: center; }

pre.payload {
  background: #060a08;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 13px 15px;
  font: 11.5px/1.65 var(--mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #9fd4b8;
  margin: 12px 0;
  text-align: left;
}

.status-line { font-size: 13.5px; margin: 10px 0; text-align: left; }
.status-line a { color: var(--accent); }
.status-line.err { color: var(--live); }

.progress-stages { list-style: none; margin: 10px 0; font-family: var(--mono); font-size: 12px; text-align: left; }
.progress-stages li { padding: 3px 0; color: var(--faint); }
.progress-stages li.done { color: var(--accent); }
.progress-stages li.running { color: var(--text); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line-soft);
  padding: 14px 30px;
  color: var(--faint);
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
footer a { color: var(--muted); text-decoration-color: var(--line); }
@media (hover: hover) and (pointer: fine) {
  footer a:hover { color: var(--accent); }
}
.foot-sep { color: var(--line); }

/* ---------- motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* The LIVE dot stops blinking but stays red, so status is never carried by motion alone. */
  .match-live::before { opacity: 1; }
  .sim-btn:active, #modal-close:active { transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  #league-nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    padding: 10px 14px;
  }
  .nav-group { display: none; }
  .league-btn { width: auto; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .league-btn.active { border-left: none; border-bottom-color: var(--accent); }
  .match-card { grid-template-columns: 50px minmax(0, 1fr); }
  .match-card .sim-btn { grid-column: 1 / -1; }
  .match-teams { font-size: 17px; white-space: normal; }
}
