:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: rgba(16, 24, 32, 0.88);
  --panel-solid: #162229;
  --line: rgba(154, 178, 190, 0.26);
  --text: #eef5f3;
  --muted: #9fb1ba;
  --soft: #c7d2d6;
  --gold: #edae49;
  --green: #2a9d8f;
  --red: #d1495b;
  --blue: #4ea8de;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, a { font: inherit; }
a { color: inherit; }

.game-shell {
  position: relative;
  min-height: 100vh;
}
.map-stage,
.game-map,
.map-vignette {
  position: fixed;
  inset: 0;
}
.game-map {
  background: #dce8d0;
}
.map-vignette {
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(16, 24, 32, 0.64), rgba(16, 24, 32, 0.08) 44%, rgba(16, 24, 32, 0.42)),
    linear-gradient(0deg, rgba(16, 24, 32, 0.72), rgba(16, 24, 32, 0.06) 44%, rgba(16, 24, 32, 0.58));
}

.game-topbar {
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 44px);
  background: rgba(16, 24, 32, 0.76);
  border-bottom: 1px solid rgba(154, 178, 190, 0.16);
  backdrop-filter: blur(18px);
}
.brand-mark {
  font-size: 19px;
  font-weight: 900;
  text-decoration: none;
}
.game-nav {
  display: flex;
  gap: 16px;
  color: var(--soft);
  font-weight: 850;
}
.game-nav a {
  text-decoration: none;
}
.game-nav a[aria-current="page"] {
  color: #fff;
}

.game-panel,
.leaderboard-panel,
.route-strip {
  position: fixed;
  z-index: 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}
.game-panel {
  top: 92px;
  left: clamp(14px, 3vw, 38px);
  width: min(390px, calc(100vw - 28px));
  padding: 18px;
}
.status-kicker {
  margin: 0 0 8px;
  color: #78d6b6;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.game-panel h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 0.94;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}
.stat-grid div {
  min-width: 0;
  min-height: 82px;
  border: 1px solid rgba(154, 178, 190, 0.22);
  border-radius: 7px;
  padding: 11px;
  background: rgba(17, 26, 32, 0.74);
}
.stat-grid span,
.panel-heading span,
.route-meta,
.row-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.stat-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 10px;
  color: #fff;
  font-size: 25px;
  line-height: 1.02;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#areaTotal {
  font-size: 20px;
  line-height: 1.08;
  white-space: normal;
}
.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.primary-button,
.secondary-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  font-weight: 900;
  cursor: pointer;
}
.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #07120f;
}
.secondary-button {
  background: rgba(29, 42, 49, 0.9);
  color: var(--text);
}
.primary-button:disabled,
.secondary-button:disabled {
  cursor: default;
  opacity: 0.55;
}
.sync-state {
  min-height: 19px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
}
.sync-state.error {
  color: #ff9ca8;
}

.leaderboard-panel {
  top: 92px;
  right: clamp(14px, 3vw, 38px);
  width: min(310px, calc(100vw - 28px));
  overflow: hidden;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-heading strong {
  color: #fff;
  font-size: 13px;
}
.leaderboard-rows {
  display: grid;
  gap: 1px;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: rgba(17, 26, 32, 0.68);
}
.leaderboard-row > span:nth-child(2) {
  min-width: 0;
}
.team-swatch {
  width: 11px;
  height: 28px;
  border-radius: 5px;
}
.row-name {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  display: block;
  margin-top: 2px;
  white-space: nowrap;
}
.row-value {
  color: #fff;
  font-size: 19px;
  font-weight: 900;
}

.route-strip {
  left: clamp(14px, 3vw, 38px);
  right: clamp(14px, 3vw, 38px);
  bottom: 20px;
  overflow: hidden;
}
.route-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.route-row {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 13px 14px;
  background: rgba(17, 26, 32, 0.66);
}
.route-row:last-child {
  border-right: 0;
}
.route-name {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.route-dot {
  width: 34px;
  height: 5px;
  border-radius: 3px;
}
.maplibregl-ctrl-top-right {
  top: 86px;
  right: clamp(14px, 3vw, 38px);
}
.maplibregl-ctrl-bottom-right {
  right: clamp(14px, 3vw, 38px);
  bottom: 106px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }
  .game-shell {
    min-height: 100vh;
    padding: 86px 14px 18px;
  }
  .map-stage,
  .game-map,
  .map-vignette {
    position: absolute;
    min-height: 100vh;
  }
  .game-topbar,
  .game-panel,
  .leaderboard-panel,
  .route-strip {
    position: relative;
    inset: auto;
    width: auto;
    margin-bottom: 12px;
  }
  .game-topbar {
    position: fixed;
    margin-bottom: 0;
  }
  .leaderboard-panel {
    right: auto;
  }
  .route-rows {
    grid-template-columns: 1fr;
  }
  .route-row {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .route-row:last-child {
    border-bottom: 0;
  }
  .maplibregl-ctrl-top-right {
    top: 86px;
    right: 14px;
  }
  .maplibregl-ctrl-bottom-right {
    bottom: 14px;
    right: 14px;
  }
}

@media (max-width: 520px) {
  .game-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .game-shell {
    padding-top: 118px;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .panel-actions {
    flex-direction: column;
  }
}