:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #111827;
  --muted: #607086;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --green: #15803d;
  --warn: #b45309;
  --tooltip-bg: #17202a;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  color-scheme: light;
}

body[data-theme="dark"] {
  --bg: #0b1118;
  --panel: #121b26;
  --panel-2: #172331;
  --ink: #edf4fb;
  --muted: #9aaabb;
  --line: #27384b;
  --accent: #64c7c4;
  --accent-2: #8fb6ff;
  --green: #58d68d;
  --warn: #f2c15f;
  --tooltip-bg: #05090f;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: clamp(27px, 3.5vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

.hero p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.controls {
  display: grid;
  grid-template-columns: 112px 180px 72px 64px 190px;
  gap: 8px;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

select,
input,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.controls select,
.controls input,
.controls button {
  width: 100%;
  height: 40px;
  min-height: 40px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

button {
  cursor: pointer;
  font-weight: 850;
}

button.accent {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: var(--accent);
  color: #062323;
}

button.ghost {
  background: var(--panel-2);
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: .58;
}

.sport-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 -3px 10px;
  padding: 7px 3px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.sport-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.sport-nav span {
  color: var(--accent-2);
}

.status-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  color: var(--ink);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
}

.sports-body {
  display: block;
}

.sports-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
  gap: 12px;
}

.primary-sports,
.secondary-sports,
.sports-stack,
.sports-compact-board {
  display: grid;
  gap: 10px;
}

.sports-compact-board {
  grid-template-columns: repeat(auto-fit, minmax(280px, max-content));
  align-items: start;
}

.sports-compact-board .sport-section {
  width: fit-content;
  max-width: min(420px, 100%);
}

.sport-section {
  scroll-margin-top: 58px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  margin-bottom: 5px;
}

h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
}

.section-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-2);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 850;
}

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  align-items: start;
  gap: 6px;
}

.compact-section .event-grid,
.medium-section .event-grid,
.race-section .event-grid {
  grid-template-columns: 1fr;
}

.primary-sports .wide-section .event-grid,
.sports-stack .wide-section .event-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.secondary-sports .event-grid {
  grid-template-columns: 1fr;
}

.sports-compact-board .event-grid {
  grid-template-columns: max-content;
}

.sports-compact-board .event-card {
  width: max-content;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 32px));
}

.event-card {
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 9px;
  box-shadow: none;
  overflow: hidden;
}

.race-card {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

.event-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
}

.live-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #ee4d4d;
  color: white;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 900;
}

.event-title {
  min-width: 0;
  font-size: 11px;
  font-weight: 820;
  line-height: 1.22;
}

.event-meta,
.event-card p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.event-card p {
  color: color-mix(in srgb, var(--accent) 72%, var(--ink));
}

.matchup {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
}

.matchup-tail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 0 0 auto;
}

.matchup-separator {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: left;
  flex: 0 0 auto;
}

.team {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 0 0 auto;
}

.team:last-child {
  justify-content: flex-start;
  text-align: left;
}

.team img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex: 0 0 auto;
}

.team span {
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  line-height: 1.15;
}

.team strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
}

.racing-panel {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.race-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.race-status span {
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2) 18%, transparent);
  color: var(--ink);
  padding: 3px 7px;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.race-status small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.horse-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.horse-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  color: var(--ink);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 760;
  cursor: help;
}

.horse-chip.matched {
  border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line));
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

.horse-chip.confirmed {
  border-color: color-mix(in srgb, var(--green) 64%, var(--line));
  background: color-mix(in srgb, var(--green) 22%, transparent);
  color: var(--ink);
  font-weight: 850;
}

.runner-details {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.runner-details summary {
  cursor: pointer;
  color: var(--accent-2);
}

.runner-details div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.runner-details span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
}

.muted {
  color: var(--muted);
}

.empty {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
}

.hover-tip {
  position: fixed;
  z-index: 50;
  max-width: min(460px, calc(100vw - 32px));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: 8px;
  background: var(--tooltip-bg);
  color: #edf3f8;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 650;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .42);
  pointer-events: none;
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sports-layout {
    grid-template-columns: 1fr;
  }

  .secondary-sports {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .secondary-sports .event-grid,
  .medium-section .event-grid,
  .race-section .event-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 1500px);
    padding-top: 14px;
  }

  .controls,
  .event-grid {
    grid-template-columns: 1fr;
  }

  .sports-body {
    display: block;
  }

  .sports-layout,
  .primary-sports,
  .secondary-sports,
  .sports-stack,
  .sports-compact-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .sports-compact-board .sport-section,
  .sports-compact-board .event-card {
    width: 100%;
    max-width: none;
  }

  .sports-compact-board .event-grid {
    grid-template-columns: 1fr;
  }

  .sport-section {
    margin-bottom: 10px;
  }

  .sport-nav {
    top: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .sport-nav a {
    white-space: nowrap;
  }
}
