:root {
  --vipps: #ff5b24;
  --vipps-dark: #d94518;
  --bg: #faf6f1;
  --card: #ffffff;
  --ink: #15161a;
  --muted: #6b6b73;
  --rule: #ececef;
  --team-fast: #ff5b24;
  --team-middle: #f59e0b;
  --team-slow: #4f46e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(20, 14, 8, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.4;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ------- Topbar ------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 18px calc(14px + env(safe-area-inset-top, 0)) 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0));
  background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.92) 100%);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--vipps);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 10px rgba(255, 91, 36, 0.35);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 32px;
  display: grid;
  gap: 16px;
}

.section-title {
  margin: 0 4px 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ------- Map card ------- */
.map-card {
  position: relative;
  background: linear-gradient(180deg, #fff7ef 0%, #fdeede 70%, #fbe2ce 100%);
  border-radius: 22px;
  padding: 12px 12px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#track {
  width: 100%;
  height: auto;
  display: block;
}

.hill {
  fill: rgba(255, 91, 36, 0.06);
}

.hill-front {
  fill: rgba(255, 91, 36, 0.1);
}

.track-shadow {
  fill: none;
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(2px);
}

.track-line {
  fill: none;
  stroke: #2a2a2e;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 6;
}

.checkpoint {
  cursor: default;
}

.checkpoint-dot {
  fill: #fff;
  stroke: #2a2a2e;
  stroke-width: 1.5;
}

.checkpoint-dot.start-finish {
  fill: var(--vipps);
  stroke: var(--vipps-dark);
}

.checkpoint-num {
  font-size: 8px;
  font-weight: 700;
  fill: #2a2a2e;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.checkpoint-num.start-finish {
  fill: #fff;
}

.checkpoint-label {
  font-size: 9px;
  font-weight: 600;
  fill: #2a2a2e;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: #fff7ef;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.runner {
  filter: url(#dotShadow);
}

.runner-halo {
  fill: currentColor;
  opacity: 0.18;
}

.runner-core {
  fill: currentColor;
  stroke: #fff;
  stroke-width: 1.5;
}

.runner-label {
  font-size: 8px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.leg-readout {
  position: absolute;
  left: 18px;
  top: 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 10px;
  padding: 6px 10px;
  display: grid;
  gap: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.leg-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.leg-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ------- Controls ------- */
.controls {
  background: var(--card);
  border-radius: 18px;
  padding: 14px 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-elapsed,
.time-total {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 48px;
}

.time-elapsed {
  color: var(--ink);
}

.time-total {
  text-align: right;
}

.scrubber {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--rule);
  border-radius: 999px;
  outline: none;
  background-image: linear-gradient(var(--vipps), var(--vipps));
  background-size: 0% 100%;
  background-repeat: no-repeat;
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--vipps);
  border: 3px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.scrubber::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--vipps);
  border: 3px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--vipps);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(255, 91, 36, 0.4);
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.2s;
}

.play-btn:active {
  transform: scale(0.94);
}

.play-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.play-btn .ic-pause {
  display: none;
}

.play-btn.is-playing .ic-play {
  display: none;
}

.play-btn.is-playing .ic-pause {
  display: block;
}

.speed-group {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #f3f1ef;
  padding: 3px;
  border-radius: 999px;
}

.speed-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 4px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}

.speed-btn.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.restart-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.restart-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.restart-btn:active {
  transform: scale(0.94);
}

/* ------- Leaderboard ------- */
.leaderboard {
  background: var(--card);
  border-radius: 18px;
  padding: 16px 14px;
  box-shadow: var(--shadow);
}

.standings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.standing {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9f7f4;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.standing.is-leader {
  background: #fff5ee;
  border-color: #ffd9c2;
}

.standing.is-finished {
  background: #f4f7ff;
}

.rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--ink);
  font-variant-numeric: tabular-nums;
}

.standing.is-leader .rank {
  background: var(--vipps);
}

.team-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.team-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--c, #ff5b24);
}

.team-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-status {
  text-align: right;
  display: grid;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.team-time {
  font-size: 14px;
  font-weight: 700;
}

.team-progress {
  font-size: 11px;
  color: var(--muted);
}

.standing.is-finished .team-time {
  color: var(--vipps);
}

/* ------- Splits ------- */
.splits {
  background: var(--card);
  border-radius: 18px;
  padding: 16px 14px 12px;
  box-shadow: var(--shadow);
}

.splits-scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -14px;
  padding: 0 14px;
}

.splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 320px;
}

.splits-table th,
.splits-table td {
  padding: 8px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.splits-table th:first-child,
.splits-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
}

.splits-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
}

.splits-table th.team-col[data-team='fast'] {
  color: var(--team-fast);
}

.splits-table th.team-col[data-team='middle'] {
  color: var(--team-middle);
}

.splits-table th.team-col[data-team='slow'] {
  color: var(--team-slow);
}

.splits-table tbody tr {
  border-bottom: 1px solid var(--rule);
}

.splits-table tbody tr:last-child {
  border-bottom: none;
}

.splits-table tbody tr.is-active {
  background: #fff5ee;
}

.splits-table .estimated {
  font-style: italic;
  color: #b09a86;
}

.splits-table td.is-pulse {
  color: var(--vipps);
  font-weight: 700;
}

.footnote {
  margin: 10px 4px 0;
  font-size: 11px;
  color: var(--muted);
}

/* ------- Footer ------- */
.site-footer {
  text-align: center;
  padding: 8px 14px 24px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer span {
  color: var(--vipps);
}

/* ------- Larger screens: a touch more breathing room ------- */
@media (min-width: 560px) {
  main {
    padding: 24px 20px 40px;
    gap: 20px;
  }

  .map-card {
    padding: 16px;
  }

  .brand-text h1 {
    font-size: 19px;
  }

  .splits-table {
    font-size: 13px;
  }
}
