:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647084;
  --line: #d7dde8;
  --surface: #ffffff;
  --surface-soft: #f3f6fb;
  --accent: #0a6f64;
  --accent-strong: #084d47;
  --warning: #ffd23f;
  --track: #101827;
  --shadow: 0 18px 50px rgba(26, 36, 58, 0.14);
}

* {
  box-sizing: border-box;
}

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

button,
a,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.debug-panel,
.home-section,
.team-page-header,
.board,
.map-section,
.fixture-section {
  background: var(--surface);
  border: 1px solid rgba(23, 32, 51, 0.08);
  box-shadow: var(--shadow);
}

.debug-panel {
  display: none;
  margin-bottom: 16px;
  padding: 14px 16px 16px;
}

.debug-panel.is-visible {
  display: block;
}

.is-hidden {
  display: none !important;
}

.home-section {
  padding: 24px;
}

.home-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.last-team-link,
.home-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 850;
  text-decoration: none;
}

.last-team-link:hover,
.home-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.home-search {
  display: grid;
  gap: 6px;
  margin-top: 22px;
}

.home-search input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
}

.home-search input:focus-visible,
.team-picker select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.division-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.division-tabs button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.division-tabs button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.team-directory {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.team-card {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  text-decoration: none;
}

.team-card:hover,
.team-card:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(10, 111, 100, 0.18);
  outline-offset: 0;
}

.team-card strong {
  font-size: 1.22rem;
  line-height: 1.1;
}

.team-card span {
  color: var(--muted);
  font-weight: 800;
}

.empty-directory {
  padding: 18px;
  border: 1px dashed var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.team-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
}

.team-page-header strong {
  font-size: 1.12rem;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.debug-header strong {
  display: block;
  font-size: 1.1rem;
}

.debug-live {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--ink);
  font-weight: 850;
}

.debug-live input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.time-slider {
  width: 100%;
  margin: 15px 0 8px;
  accent-color: var(--accent);
}

.time-points {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.board {
  overflow: hidden;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 18px;
  background: var(--track);
  color: #f4f7fb;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #35d07f;
  box-shadow: 0 0 0 5px rgba(53, 208, 127, 0.16);
  flex: 0 0 auto;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 18px;
  padding: 24px;
}

.eyebrow,
.label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2.6rem, 8vw, 6.6rem);
}

h2 {
  font-size: 1.15rem;
}

.match-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.match-card.has-no-field {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-picker {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.team-picker label {
  margin: 0;
}

.team-picker select {
  min-width: min(100%, 300px);
  min-height: 48px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 850;
}

.team-picker span:last-child {
  color: var(--muted);
  font-weight: 750;
}

.match-card > div {
  min-width: 0;
  padding: 18px;
  background: var(--surface-soft);
}

.match-card-action {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  line-height: normal;
  text-align: left;
  cursor: pointer;
}

.match-card-action:hover,
.match-card-action:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.match-card-action:disabled {
  cursor: default;
  color: var(--muted);
}

.match-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.08rem, 2vw, 1.55rem);
}

.countdown-panel {
  display: flex;
  min-height: 270px;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
  background: #fff8d7;
  border-left: 8px solid var(--warning);
}

.clock {
  margin: 4px 0 16px;
  color: var(--track);
  font-family: "SF Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  font-weight: 900;
  line-height: 1;
}

.timing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
}

.timing-grid div {
  padding: 10px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(23, 32, 51, 0.1);
}

.timing-grid div[hidden] {
  display: none;
}

.timing-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.countdown-panel p {
  margin: 14px 0 0;
  color: #3c4556;
  font-weight: 650;
}

.map-section,
.fixture-section {
  margin-top: 16px;
}

.map-toolbar,
.map-footer,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.map-toolbar {
  border-bottom: 1px solid var(--line);
}

.map-toolbar strong {
  display: block;
  font-size: 1.25rem;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.map {
  width: 100%;
  height: min(68vh, 680px);
  min-height: 470px;
  background: #d7ecd0;
}

.text-button[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.48;
}

.field-label {
  color: #07131f;
  font-weight: 900;
  text-shadow:
    0 1px 0 #fff,
    1px 0 0 #fff,
    0 -1px 0 #fff,
    -1px 0 0 #fff;
}

.leaflet-tooltip.field-callout {
  border: 0;
  background: #101827;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-weight: 900;
}

.map-footer {
  min-height: 52px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.map-controls {
  display: none;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.has-debug-tools .map-controls {
  display: flex;
}

.opacity-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.opacity-control input {
  width: 130px;
  accent-color: var(--accent);
}

.drag-control {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

body.has-debug-tools .drag-control {
  display: flex;
}

.drag-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.calibration-panel {
  display: grid;
  gap: 6px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: #f7f9fc;
}

.calibration-panel[hidden] {
  display: none;
}

.calibration-panel pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  background: #101827;
  color: #e8eef8;
  font-family: "SF Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.leaflet-image-layer.field-plan-overlay {
  cursor: grab;
}

.leaflet-image-layer.field-plan-overlay.is-dragging {
  cursor: grabbing;
}

.locate-map-control {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(23, 32, 51, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.22);
  cursor: pointer;
}

.locate-map-control:hover {
  color: var(--accent-strong);
}

.locate-map-control.is-following {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.locate-map-control.is-following:hover {
  background: var(--accent-strong);
  color: #fff;
}

.locate-map-control svg {
  width: 23px;
  height: 23px;
}

.user-location-marker {
  position: relative;
  width: 54px;
  height: 54px;
}

.user-location-marker .heading-cone {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 78px;
  background: rgba(11, 102, 255, 0.28);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  transform: translate(-50%, -100%) rotate(var(--heading, 0deg));
  transform-origin: 50% 100%;
  filter: drop-shadow(0 2px 8px rgba(11, 102, 255, 0.28));
  opacity: 0;
  transition:
    transform 160ms linear,
    opacity 120ms ease;
}

.user-location-marker.has-heading .heading-cone {
  opacity: 1;
}

.user-location-marker .location-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #0b66ff;
  box-shadow:
    0 0 0 5px rgba(11, 102, 255, 0.2),
    0 6px 16px rgba(23, 32, 51, 0.28);
  transform: translate(-50%, -50%);
}

.section-heading {
  border-bottom: 1px solid var(--line);
}

.section-heading span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.fixture-list {
  display: block;
  background: var(--surface);
}

.fixture {
  display: grid;
  grid-template-columns: minmax(145px, 180px) max-content minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 13px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.fixture.is-current {
  background: #e5fbf5;
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.fixture time {
  color: var(--muted);
  font-weight: 800;
}

.fixture strong {
  font-size: 1.03rem;
}

.fixture .opponent {
  font-size: 1.14rem;
}

.field-pill {
  width: fit-content;
  justify-self: end;
  padding: 5px 9px;
  background: var(--track);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.previous-weeks {
  border-top: 1px solid var(--line);
}

.previous-weeks summary {
  min-height: 54px;
  padding: 16px;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 900;
}

.previous-list .fixture {
  background: #f7f9fc;
  color: #4c5870;
}

.fixture.is-bye,
.fixture.is-break {
  background: #f5f7fb;
  color: #606b7f;
  outline: 0;
}

.fixture.is-bye .field-pill,
.fixture.is-break .field-pill {
  background: #d8dee9;
  color: #344055;
}

.fixture.is-bye .field-pill {
  display: none;
}

.fixture.is-break {
  border-top: 1px dashed #bac3d1;
  border-bottom: 1px dashed #bac3d1;
}

.fixture.is-break .field-pill {
  text-transform: uppercase;
}

@media (min-width: 920px) {
  .shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    align-items: start;
    gap: 16px;
  }

  .debug-panel,
  .home-section,
  .team-page-header,
  .board {
    grid-column: 1 / -1;
  }

  .map-section,
  .fixture-section {
    margin-top: 0;
  }

  .map-section {
    grid-column: 1 / 2;
  }

  .fixture-section {
    grid-column: 2 / 3;
  }

  .shell.has-no-map .fixture-section {
    grid-column: 1 / -1;
  }

  .fixture {
    grid-template-columns: minmax(95px, 116px) minmax(0, 1fr) max-content;
  }

  .fixture .opponent {
    font-size: 1.02rem;
  }
}

@media (max-width: 760px) {
  .shell {
    width: 100%;
    padding-top: 0;
  }

  .board,
  .home-section,
  .team-page-header,
  .map-section,
  .fixture-section {
    border-left: 0;
    border-right: 0;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .home-section {
    padding: 18px;
  }

  .home-header,
  .team-page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .last-team-link,
  .home-link {
    width: 100%;
  }

  .match-card {
    grid-template-columns: 1fr;
  }

  .match-card.has-no-field {
    grid-template-columns: 1fr;
  }

  .time-points {
    grid-template-columns: repeat(4, 1fr);
    text-align: left;
  }

  .map-toolbar,
  .map-footer,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-actions > * {
    flex: 1 1 130px;
  }

  .map {
    height: 62vh;
    min-height: 420px;
  }

  .opacity-control {
    width: 100%;
    justify-content: space-between;
  }

  .map-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .fixture {
    grid-template-columns: minmax(108px, 126px) minmax(0, 1fr) max-content;
    gap: 8px 12px;
  }

  .fixture time,
  .fixture .opponent {
    grid-column: auto;
  }

  .fixture .field-pill {
    grid-column: auto;
    grid-row: auto;
    align-self: center;
  }
}

@media (max-width: 460px) {
  .fixture {
    grid-template-columns: minmax(96px, 112px) minmax(0, 1fr);
  }

  .fixture .field-pill {
    grid-column: 2 / 3;
    justify-self: start;
  }

  .fixture.is-bye .opponent {
    grid-column: 2 / 3;
  }
}
