:root {
  color-scheme: light;
  --ink: #0f1720;
  --muted: #667483;
  --paper: #f3f5ee;
  --panel: #fffdf7;
  --navy: #071827;
  --blue: #174f83;
  --green: #2f7351;
  --red: #c83b33;
  --gold: #dca52e;
  --line: rgba(15, 23, 32, 0.13);
  --shadow: 0 18px 36px rgba(9, 24, 39, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  font: inherit;
  letter-spacing: 0;
}

.derby-hero {
  min-height: 470px;
  padding: 12px 12px 72px;
  color: #fffdf7;
  background:
    linear-gradient(90deg, rgba(7, 24, 39, 0.96), rgba(7, 24, 39, 0.76)),
    linear-gradient(135deg, #214d37 0%, #071827 56%, #5c1d21 100%);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.top-nav a,
.map-action,
.section-head a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

.top-nav a {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
}

.hero-copy {
  width: min(1080px, 100%);
  margin: 54px auto 0;
}

h1,
h2 {
  margin: 0;
  line-height: 0.96;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.75rem, 12vw, 6.9rem);
  font-weight: 1000;
}

h2 {
  font-size: 1.55rem;
}

.hero-copy p {
  max-width: 470px;
  margin: 14px 0 0;
  color: #e8eef2;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.35;
}

.score-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(1080px, 100%);
  margin: 46px auto 0;
}

.score-strip article,
.selected-player,
.map-panel,
.leaderboard-panel,
.table-panel,
.source-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.score-strip article {
  min-height: 104px;
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.94);
}

.score-strip span,
.map-head span,
.section-head span,
.source-strip p {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.score-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
  font-weight: 1000;
  line-height: 1;
}

.score-strip em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 850;
}

main {
  display: grid;
  gap: 16px;
  padding: 14px 12px 30px;
  min-width: 0;
}

.map-panel,
.leaderboard-panel,
.table-panel,
.source-strip {
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
  box-shadow: 0 12px 26px rgba(9, 24, 39, 0.12);
}

.map-panel {
  margin-top: -58px;
  overflow: hidden;
}

.map-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.map-action {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #fffdf7;
  background: var(--red);
  cursor: pointer;
}

.map-action[aria-pressed="true"] {
  color: #fffdf7;
  background: var(--blue);
}

.map-wrap {
  position: relative;
  min-height: 500px;
  background: #dbe2da;
}

#distanceMap {
  display: block;
  width: 100%;
  height: min(68vh, 700px);
  min-height: 500px;
  background: #dbe2da;
}

.map-fallback {
  display: grid;
  position: absolute;
  inset: 0;
  z-index: 1000;
  place-items: center;
  padding: 18px;
  color: #fffdf7;
  background: #071827;
  font-weight: 900;
}

.map-fallback[hidden],
.map-status[hidden] {
  display: none;
}

.map-status {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 900;
  width: min(360px, calc(100% - 100px));
  padding: 9px 12px;
  border-radius: 6px;
  color: #fffdf7;
  background: rgba(7, 24, 39, 0.92);
  font-size: 0.75rem;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
}

.selected-player {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 800;
  width: min(320px, calc(100% - 20px));
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.95);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.selected-player:empty {
  display: none;
}

.selected-player span,
.player-card span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.selected-player strong {
  display: block;
  margin-top: 5px;
  font-size: 1.1rem;
  font-weight: 1000;
}

.selected-player p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
}

.scale-note {
  margin: 0;
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.35;
}

.leaderboard-panel,
.table-panel {
  padding-bottom: 14px;
}

.section-head a {
  color: #fffdf7;
  background: var(--blue);
}

.player-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0 14px;
}

.player-card {
  min-height: 160px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.player-card[data-active] {
  border-color: var(--player-color, var(--red));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--player-color, var(--red)) 34%, transparent);
}

.player-card button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 158px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.player-card button:focus-visible,
.map-action:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.player-rank {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fffdf7;
  background: var(--player-color, var(--red));
  font-weight: 1000;
}

.player-main {
  min-width: 0;
}

.player-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.route-direction {
  padding: 3px 6px;
  border-radius: 5px;
  color: #fffdf7;
  background: var(--player-color, var(--red));
  font-size: 0.64rem;
  white-space: nowrap;
}

.player-main strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 1000;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
}

.block-line b {
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 1000;
  line-height: 1;
}

.block-line span {
  color: var(--muted);
  font-size: 0.65rem;
}

.distance-bar {
  display: block;
  height: 9px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf0e9;
}

.distance-bar i {
  display: block;
  width: var(--bar);
  height: 100%;
  background: linear-gradient(90deg, var(--player-color, var(--red)), var(--gold));
}

.player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.player-meta b {
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--ink);
  background: #f1f3ee;
  font-size: 0.76rem;
}

.table-wrap {
  margin: 0 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  font-weight: 850;
}

td:first-child {
  color: var(--muted);
}

.leaflet-container {
  color: var(--ink);
  font-family: inherit;
  letter-spacing: 0;
}

.leaflet-control-zoom a {
  color: var(--ink);
  font-weight: 1000;
}

.leaflet-control-attribution {
  max-width: min(70vw, 520px);
  font-size: 0.62rem;
}

.leaflet-tooltip {
  border: 1px solid rgba(15, 23, 32, 0.15);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 8px 20px rgba(7, 24, 39, 0.18);
  font-size: 0.74rem;
  font-weight: 800;
}

.route-endpoint-shell,
.stadium-marker-shell {
  border: 0;
  background: transparent;
}

.route-endpoint,
.stadium-marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #fffdf7;
  border-radius: 50%;
  color: #fffdf7;
  background: var(--route-color, var(--red));
  box-shadow: 0 4px 12px rgba(7, 24, 39, 0.36);
  font-size: 0.78rem;
  font-weight: 1000;
}

.stadium-marker {
  width: 46px;
  height: 46px;
  border: 4px solid #fffdf7;
  background: var(--navy);
  font-size: 0.68rem;
}

.source-strip {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.source-strip p {
  margin: 0;
  line-height: 1.45;
  text-transform: none;
}

.source-strip a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 430px) {
  .map-head {
    align-items: stretch;
    flex-direction: column;
  }

  .map-action {
    width: 100%;
  }

  #distanceMap {
    height: 520px;
    min-height: 520px;
  }

  .selected-player {
    position: static;
    width: auto;
    margin: 10px;
    pointer-events: auto;
  }

  .map-wrap {
    min-height: 0;
  }

  .leaflet-control-attribution {
    max-width: 260px;
    font-size: 0.58rem;
  }
}

@media (min-width: 720px) {
  .derby-hero {
    padding-inline: 20px;
  }

  .score-strip {
    grid-template-columns: repeat(4, 1fr);
  }

  .player-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1040px) {
  .player-cards {
    grid-template-columns: repeat(4, 1fr);
  }

  h2 {
    font-size: 1.9rem;
  }
}
