:root {
  --bg: #12141a;
  --panel: rgba(20, 23, 31, 0.92);
  --panel-solid: #171a22;
  --edge: rgba(255, 255, 255, 0.11);
  --ink: #f2f4f8;
  --ink-dim: #9aa2b4;
  --accent: #ffce00; /* line 1 yellow */
  --accent-ink: #1a1a1a;
  --good: #4ade80;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

/* The pin is the whole interaction, so make the target obvious. */
#map.is-guessing {
  cursor: crosshair;
}

/* ---------- overlays (start + end screens) ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 11, 15, 0.82);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.overlay[hidden] {
  display: none;
}

.card {
  position: relative;
  width: min(480px, 100%);
  padding: 32px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  text-align: center;
}

/* Language is not a game setting, so it reads as chrome on the card rather than
   as a fifth row of pills competing with the ones that change the game. */
.langswitch {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--edge);
  border-radius: 999px;
}

.lang {
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.lang:hover {
  color: var(--ink);
}

.lang.is-selected {
  background: rgba(255, 206, 0, 0.12);
  color: var(--accent);
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 24px;
  color: var(--ink-dim);
}

.fineprint {
  margin: 20px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.best {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--accent);
}

/* ---------- choices ---------- */

.choice {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  text-align: left;
}

.choice legend {
  padding: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pool {
  flex: 1 1 100%;
  padding: 12px 14px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pool strong {
  display: block;
  font-size: 15px;
}

.pool span {
  font-size: 12.5px;
  color: var(--ink-dim);
}

.pool:hover,
.pill:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.pool.is-selected {
  border-color: var(--accent);
  background: rgba(255, 206, 0, 0.09);
}

.pill {
  min-width: 62px;
  padding: 9px 16px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pill.is-selected {
  border-color: var(--accent);
  background: rgba(255, 206, 0, 0.12);
  color: var(--accent);
}

/* Deathmatch isn't a round count, so it reads in the danger colour rather than
   sitting in the row pretending to be a fourth number. */
.pill-dm.is-selected {
  border-color: var(--bad);
  background: rgba(248, 113, 113, 0.14);
  color: var(--bad);
}

/* The variant picker hangs off the deathmatch pill, so it is indented under it
   rather than reading as another top-level choice. */
.options-sub {
  margin-top: 8px;
  padding-left: 14px;
  border-left: 2px solid rgba(248, 113, 113, 0.4);
}

.options-sub[hidden] {
  display: none;
}

.choice-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.choice-note[hidden] {
  display: none;
}

/* ---------- buttons ---------- */

.primary {
  width: 100%;
  padding: 13px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px/1 inherit;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}

.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost {
  padding: 7px 13px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  cursor: pointer;
}

.ghost:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
}

.ghost.wide {
  width: 100%;
  margin-top: 8px;
  padding: 10px 20px;
}

/* ---------- basemap preview ---------- */

.demo {
  position: absolute;
  top: 14px;
  left: 40px;
  z-index: 900;
  width: 330px;
  max-width: calc(100% - 80px);
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  text-align: left;
}

.demo[hidden] {
  display: none;
}

.demo-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.demo-head strong {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-dim);
}

.demo .pill {
  min-width: 0;
  padding: 7px 12px;
  font-size: 13.5px;
}

.demo-note {
  margin: 10px 0 0;
  min-height: 34px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.demo-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.demo-zoom {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

/* Past the game's ceiling you are looking at tiles no round will ever serve. */
.demo-zoom.is-past-game {
  color: var(--accent);
}

.demo-hint {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--edge);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-dim);
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  top: 14px;
  left: 40px;
  right: 40px;
  z-index: 900;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hud[hidden] {
  display: none;
}

.hud-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-dim);
}

.hud-score {
  color: var(--accent);
}

.hud-score.is-critical {
  color: var(--bad);
}

/* ---------- deathmatch life bar ---------- */

.lifebar {
  overflow: hidden;
  width: 220px;
  max-width: 100%;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.lifebar[hidden] {
  display: none;
}

.lifebar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--good);
  transition: width 0.45s ease, background 0.45s ease;
}

/* Burn moves the bar every tick, so it tracks the drain linearly instead of
   easing - an ease would spend its whole time chasing the last update. */
.lifebar.is-draining i {
  transition: width 0.22s linear, background 0.45s ease;
}

.lifebar i.is-low {
  background: var(--accent);
}

.lifebar i.is-critical {
  background: var(--bad);
}

@media (prefers-reduced-motion: reduce) {
  .lifebar i {
    transition: none;
  }
}

.hud-timer {
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud-timer[hidden] {
  display: none;
}

.hud-timer.is-urgent {
  color: var(--bad);
  animation: tick 1s steps(2, jump-none) infinite;
}

@keyframes tick {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud-timer.is-urgent {
    animation: none;
  }
}

.hud h2 {
  margin: 4px 0 0;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.badge {
  min-width: 23px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.badge.rer {
  border-radius: 5px;
}

/* ---------- action bar ---------- */

.actionbar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 900;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.actionbar[hidden] {
  display: none;
}

.actionbar .primary {
  width: auto;
  min-width: 128px;
}

.hint {
  margin: 0;
  min-width: 180px;
  font-size: 13.5px;
  color: var(--ink-dim);
}

.hint[hidden],
.result[hidden] {
  display: none;
}

.result {
  display: flex;
  gap: 14px;
  align-items: baseline;
  min-width: 180px;
}

.result-rating {
  font-size: 15px;
  font-weight: 700;
}

.result-distance {
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.result-points {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.result-points.is-damage,
.breakdown .bd-pts.is-damage {
  color: var(--bad);
}

/* Burn's restore can outweigh the miss, and a round that heals you should not
   be printed in the same colour as one that hurt. */
.result-points.is-heal,
.breakdown .bd-pts.is-heal {
  color: var(--good);
}

/* ---------- scorecard ---------- */

.finalscore {
  margin: 0 0 6px;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.finalscore small {
  margin-left: 6px;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink-dim);
}

.breakdown {
  margin: 0 0 24px;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
  list-style: none;
  text-align: left;
  border-top: 1px solid var(--edge);
}

.breakdown li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 2px;
  border-bottom: 1px solid var(--edge);
  font-size: 13.5px;
}

.breakdown .bd-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown .bd-km {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.breakdown .bd-pts {
  min-width: 54px;
  text-align: right;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- map markers ---------- */

.pin {
  width: 15px;
  height: 15px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.pin.guess {
  background: var(--bad);
}

.pin.truth {
  background: var(--good);
}

.truth-label {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--good);
  color: #06240f;
  font: 700 12.5px/1.35 ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Leaflet ships a light attribution chip that fights the dark theme. */
.leaflet-control-attribution {
  background: rgba(18, 20, 26, 0.82) !important;
  color: var(--ink-dim) !important;
  font-size: 10.5px !important;
}

.leaflet-control-attribution a {
  color: var(--ink-dim) !important;
}

.leaflet-bar a {
  background: var(--panel-solid) !important;
  border-color: var(--edge) !important;
  color: var(--ink) !important;
}

.leaflet-bar a:hover {
  background: #22262f !important;
}

@media (max-width: 620px) {
  .card {
    padding: 24px 20px;
  }

  .hud {
    flex-wrap: wrap;
  }

  .hud h2 {
    font-size: 21px;
  }

  .actionbar {
    left: 14px;
    right: 14px;
    flex-wrap: wrap;
    justify-content: space-between;
    transform: none;
  }

  .actionbar .primary {
    flex: 1 1 100%;
  }
}
