:root {
  --sea: #0b1a30;
  --land: #15233a;
  --ink: #c9d6ea;
  --ink-dim: #7f93b2;
  --panel: #0f1b30;
  --panel-edge: #1e2f4a;
  --accent: #6fa3e8;
  --accent-ink: #08111f;
  --good: #3fa88a;
  --bad: #c75b6c;
}

html, body {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--sea);
  color: var(--ink);
}

/* Floating control card (top-left) */
#hud {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 1100;
  width: 196px;
  padding: 16px;
  box-sizing: border-box;
  border-radius: 18px;
  /* no backdrop-filter: re-blurring the moving map every frame made zoom/pan stutter */
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--panel-edge) 80%, transparent);
  box-shadow: 0 10px 34px rgba(0,0,0,0.28);
  transition: background-color .5s, border-color .5s;
}
#hud .brand {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
#start-game {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: filter .15s, transform .15s, background-color .5s;
}
#names-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 10px; padding: 9px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--panel-edge) 90%, transparent);
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink-dim);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  cursor: pointer;
  transition: color .25s, background-color .25s, border-color .25s;
}
#names-toggle:hover, #theme-btn:hover { color: var(--ink); }
#names-toggle.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
#names-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.in-game #names-toggle { display: none; }
#start-game:hover { filter: brightness(1.1); transform: translateY(-1px); }
#start-game:active { transform: translateY(0); }
body.in-game #start-game { display: none; }

/* Two-way switches (theme: moon/sun, language: flags): icon-only, sliding thumb */
.switch.seg { margin-top: 10px; height: 40px; }
.switch.seg button { font: inherit; font-size: 12.5px; font-weight: 650; letter-spacing: .02em; }
body.in-game #mode-switch { display: none; }
.hud-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--panel-edge) 90%, transparent);
  overflow: hidden;
}
.switch .thumb {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: transform .38s cubic-bezier(.65,0,.25,1), background-color .5s;
}
.switch[data-kind="lang"].is-en .thumb,
.switch[data-kind="mode"].is-kvarterer .thumb { transform: translateX(100%); }
.switch button {
  position: relative;
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0;
  border: none; background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color .3s, opacity .3s;
}
.switch button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.switch[data-kind="mode"] button.active { color: var(--accent-ink); }
.switch[data-kind="lang"] .flag { width: 22px; height: auto; max-height: 16px; border-radius: 3px; stroke: none; box-shadow: 0 0 0 1px rgba(0,0,0,0.25); opacity: .55; transition: opacity .3s, transform .3s; }
.switch[data-kind="lang"] button.active .flag { opacity: 1; transform: scale(1.06); }
.switch[data-kind="lang"] .thumb { background: color-mix(in srgb, var(--accent) 38%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* Palette button: opens the map style picker */
#theme-btn {
  display: flex; align-items: center; justify-content: center;
  height: 40px; margin: 0; padding: 0; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--panel-edge) 90%, transparent);
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink-dim); cursor: pointer;
  transition: color .25s, background-color .25s, border-color .25s;
}
#theme-btn.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
/* the orb of the current map style (a copy of the picker's), a little smaller */
.btn-orb { display: block; width: 24px; height: 24px; transition: transform .25s; }
.btn-orb .orb { display: block; width: 100%; height: 100%; box-shadow: 0 0 8px 0 color-mix(in srgb, var(--o2, #9a6ddb) 55%, transparent), inset 0 0 0 1px rgba(255,255,255,.4), inset -2px -3px 6px rgba(0,0,0,.35); }
.btn-orb .orb.globe { box-shadow: 0 0 8px rgba(110,180,255,.5); }
#theme-btn:hover .btn-orb, #theme-btn.on .btn-orb { transform: scale(1.1); }

/* About button: a plain link to about.html (fades to the page, see nav.js) */
.hud-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; box-sizing: border-box; margin-top: 10px; padding: 9px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--panel-edge) 90%, transparent);
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink-dim);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: color .25s, background-color .25s;
}
.hud-btn:hover { color: var(--ink); }
.hud-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.in-game .hud-btn { display: none; }

/* the outline minimaps on the Areas / Districts switch (phones only): a mask, so they take the button's text colour */
.mini { display: none; background-color: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.mini-bydele { -webkit-mask-image: url(../img/minimap-bydele.svg); mask-image: url(../img/minimap-bydele.svg); }
.mini-kvarterer { -webkit-mask-image: url(../img/minimap-kvarterer.svg); mask-image: url(../img/minimap-kvarterer.svg); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* No focus box around clicked districts */
.leaflet-container .leaflet-interactive,
.leaflet-container .leaflet-interactive:focus,
.leaflet-container .leaflet-interactive:focus-visible,
.leaflet-container path:focus { outline: none !important; -webkit-tap-highlight-color: transparent; }

/* District name labels: sit inside each district, scale with zoom */
.dlabel { pointer-events: none; }
.dlabel span {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  text-align: center;
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 0 3px var(--land), 0 0 6px var(--land);
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity .2s ease, color .2s ease;
}
.dlabel.show span { opacity: 0.95; }
.dlabel.hover span {
  opacity: 1;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-shadow: 0 0 3px var(--land), 0 0 7px var(--land), 0 0 11px var(--land);
}
body.in-game .dlabel span { opacity: 0 !important; }

/* Map: the sea colour is the page background, everything else is drawn on top */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--sea);
  outline: none;
}
.leaflet-container { background: var(--sea); font-family: inherit; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--sea) 70%, transparent) !important; color: var(--ink-dim) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--ink-dim) !important; }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-bottom-color: var(--panel-edge); }
.leaflet-bar a:hover { background: var(--panel-edge); }

.leaflet-tooltip, .leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.leaflet-tooltip { font-size: 12px; }
.leaflet-tooltip-top:before { border-top-color: var(--panel-edge); }
.leaflet-tooltip-bottom:before { border-bottom-color: var(--panel-edge); }
.leaflet-tooltip-left:before { border-left-color: var(--panel-edge); }
.leaflet-tooltip-right:before { border-right-color: var(--panel-edge); }
.leaflet-popup-content { margin: 8px 12px; font-size: 12px; }

/* Top-center game UI overlay */
#game-ui {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--panel-edge);
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  display: none;
  text-align: center;
  width: 420px;
  max-width: calc(100vw - 480px);
  pointer-events: none;
}
#game-ui * { pointer-events: auto; }

#game-target { font-size: 22px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
#previous-region { font-size: 12px; margin: 0 0 6px; color: var(--ink-dim); }
#score-field { font-size: 12px; margin: 0; color: var(--ink-dim); display: none; letter-spacing: 0.04em; }

#game-complete { display: none; margin-top: 6px; }
#final-result-msg { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
#btn-end-late, #btn-play-again {
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  margin: 0 4px;
  font-size: 13px;
  border: 1px solid var(--panel-edge);
  background: transparent;
  color: var(--ink);
}
#btn-play-again { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* In a game: a round back arrow in the top-left corner (the menu card moves down below it) */
#end-game-top {
  position: fixed; top: 18px; left: 18px; z-index: 1150;
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 94%, transparent); color: var(--ink);
  border: 1px solid var(--panel-edge); box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  cursor: pointer; transition: background-color .2s;
}
#end-game-top:hover { background: var(--panel-edge); }
#end-game-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
body.in-game #hud { top: 74px; }

/* Leave the game? Continue / Exit */
#exit-dialog {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
  background: color-mix(in srgb, var(--sea) 60%, transparent);
  animation: page-in .2s ease backwards;
}
#exit-dialog[hidden] { display: none; }
.exit-card { max-width: 320px; text-align: center; }
.exit-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: var(--ink); }
.exit-text { margin: 0 0 18px; font-size: 14px; color: var(--ink-dim); }
.exit-actions { display: grid; gap: 8px; }
.exit-actions button {
  padding: 12px; border-radius: 12px; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink);
}
#exit-continue { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#exit-leave:hover { color: var(--bad); }

/* Game picker: choose the game mode before a round starts */
#picker, #lb-view {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
  background: color-mix(in srgb, var(--sea) 70%, transparent);
  animation: page-in .2s ease backwards;
}
#picker[hidden], #lb-view[hidden] { display: none; }
.picker-card {
  width: 100%; max-width: 460px;
  padding: 22px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 18px 60px rgba(0,0,0,0.5);
}
.picker-card h2 {
  margin: 0 0 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-dim);
}
#type-switch { margin: 0; }
.picker-card { max-height: calc(100dvh - 32px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--panel-edge) transparent; }

/* daily challenge + random game cards */
#quick-games { display: grid; gap: 10px; margin: 0 0 4px; }
.quick-card {
  display: grid; gap: 4px; text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .2s, background-color .2s, transform .15s;
}
.quick-wrap { position: relative; }
.quick-wrap .quick-card { width: 100%; box-sizing: border-box; padding-right: 64px; }
.crown-btn {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 42px; height: 42px; padding: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, #e7b84b 60%, transparent);
  background: color-mix(in srgb, #e7b84b 14%, transparent);
  color: #e7b84b; cursor: pointer;
  transition: background-color .2s, transform .15s;
}
.crown-btn:hover, .crown-btn:focus-visible { background: color-mix(in srgb, #e7b84b 28%, transparent); outline: none; }
.crown-btn:active { transform: translateY(-50%) scale(0.95); }
.crown-btn svg { width: 22px; height: 22px; fill: color-mix(in srgb, #e7b84b 35%, transparent); stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* the selected one of daily / random (the categories below use their own pressed style) */
.quick-card[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.quick-card:hover, .quick-card:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 24%, transparent); outline: none; }
.quick-card:active { transform: scale(0.99); }
.qc-name { font-size: 17px; font-weight: 700; }
.qc-desc { font-size: 12.5px; line-height: 1.35; color: var(--ink-dim); }
.picker-or { margin: 16px 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim); }

/* street game settings */
#street-settings { display: none; }
.type-chips { gap: 6px; }
.type-chips .chip { padding: 8px 13px; font-size: 13px; }
#picker.is-street #street-settings { display: block; }
#picker.is-street #street-settings h3 {
  margin: 16px 0 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim);
}
#street-settings h3:first-child { margin-top: 0; }
.st-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 16px 0 8px; }
.st-head:first-child { margin-top: 0; }
.st-head h3 { margin: 0 !important; }
.bulk button {
  margin-left: 10px; padding: 0; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--accent);
}
.bulk button:hover { text-decoration: underline; }
#st-loading { color: var(--ink-dim); font-size: 13px; margin: 4px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: transparent; color: var(--ink-dim);
  font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
  transition: color .2s, background-color .2s, border-color .2s;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.small { padding: 4px 9px; font-size: 11.5px; }
.chip.small[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); color: var(--ink); }
.dgroup { margin: 0 0 10px; }
.dgroup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 5px; font-size: 12px; font-weight: 650; color: var(--ink); }
.dgroup-head .bulk button { font-size: 11.5px; }
#st-districts { padding-right: 2px; }
.diff { display: grid; grid-template-columns: repeat(5, 1fr) 1.9fr; gap: 6px; }
.diff button {
  padding: 9px 0; border-radius: 10px;
  border: 1px solid var(--panel-edge); background: transparent; color: var(--ink-dim);
  font: inherit; font-size: 13px; font-weight: 650; cursor: pointer;
  transition: color .2s, background-color .2s, border-color .2s;
}
.diff button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#st-diff-hint, #st-summary { margin: 8px 2px 0; font-size: 13px; color: var(--ink-dim); }
#st-summary { color: var(--ink); font-weight: 600; }

/* street game in play: flag + confirm */
#street-actions {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1000;
  display: flex; gap: 10px;
}
#street-actions[hidden] { display: none; }
#street-actions button {
  padding: 14px 34px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  box-shadow: 0 8px 26px rgba(0,0,0,0.4);
}
#street-actions button:disabled { opacity: .45; cursor: default; }
#street-actions button[hidden] { display: none; }
.flag-pin { filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.flag-pin svg { display: block; }
.target-label.dist-label { color: var(--bad); }
.target-label {
  background: var(--panel); color: var(--ink); border: 1px solid var(--panel-edge);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
#picker-hint[hidden] { display: none; }
#picker-hint { margin: 10px 2px 16px; min-height: 2.7em; font-size: 13px; line-height: 1.35; color: var(--ink-dim); }
#picker-cancel {
  display: block; width: 100%; margin-top: 14px; padding: 10px;
  border: none; background: transparent; color: var(--ink-dim);
  font: inherit; font-size: 13px; cursor: pointer;
}
#picker-cancel:hover { color: var(--ink); }

/* Leaderboard: save prompt after a game, and the top-100 view */
#lb-save { margin: 4px 0 12px; text-align: center; }
#lb-save[hidden], #lb-form[hidden], #lb-done[hidden], #lb-unranked[hidden] { display: none; }
.lb-save-title {
  margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim);
}
.lb-row { display: flex; gap: 8px; }
#lb-name {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink); font: inherit; font-size: 15px; outline: none;
  -webkit-user-select: text; user-select: text;
}
#lb-name:focus { border-color: var(--accent); }
#lb-name.shake { border-color: var(--bad); animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); }
}
@media (prefers-reduced-motion: reduce) { #lb-name.shake { animation: none; } }
#lb-save-btn {
  padding: 10px 18px; border: none; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
}
#lb-save-btn:disabled { opacity: .5; }
.lb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#lb-error { min-height: 1.3em; margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--bad); }
.lb-link { margin: 2px 0 0; padding: 4px; border: none; background: none; color: var(--ink-dim); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.lb-link:hover { color: var(--ink); }
#lb-done-text, #lb-unranked { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--ink); }
#lb-unranked { font-size: 12.5px; font-weight: 500; color: var(--ink-dim); }

#lb-view .picker-card { max-width: 520px; }
#lb-level { margin: 12px 0 0; }
#lb-level[hidden] { display: none; }
/* day navigator for the daily leaderboard */
.lb-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 0; }
.lb-nav .lb-day { flex: 1; text-align: center; font-size: 14px; font-weight: 650; color: var(--ink); }
.lb-nav .lb-day small { display: block; margin-top: 1px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.lb-nav button {
  width: 38px; height: 38px; padding: 0; border-radius: 10px; flex: none;
  border: 1px solid var(--panel-edge); background: transparent; color: var(--ink);
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.lb-nav button:disabled { opacity: .3; cursor: default; }
.lb-nav button:not(:disabled):hover { border-color: var(--accent); }

/* podium: the top three */
#lb-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: end; margin: 14px 0 6px; }
#lb-podium:empty { display: none; }
.pod {
  min-width: 0; padding: 10px 6px 11px; text-align: center; border-radius: 12px;
  border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.pod.p1 { order: 2; padding-top: 16px; padding-bottom: 15px; border-color: #e7b84b; background: color-mix(in srgb, #e7b84b 14%, transparent); }
.pod.p2 { order: 1; border-color: #aab4c4; background: color-mix(in srgb, #aab4c4 11%, transparent); }
.pod.p3 { order: 3; border-color: #c88a5a; background: color-mix(in srgb, #c88a5a 12%, transparent); }
.pod-medal { display: block; margin: 0 auto 4px; width: 26px; height: 26px; line-height: 26px; border-radius: 50%; font-size: 13px; font-weight: 800; color: var(--accent-ink); }
.pod.p2 .pod-medal { background: #aab4c4; }
.pod.p3 .pod-medal { background: #c88a5a; }
.pod.p1 .pod-medal { background: none; width: 30px; height: 30px; color: #e7b84b; }
.pod-medal svg { width: 30px; height: 30px; fill: color-mix(in srgb, #e7b84b 40%, transparent); stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pod-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.pod-score { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
#lb-how, #lb-msg { margin: 10px 2px; font-size: 13px; color: var(--ink-dim); }
#lb-msg[hidden] { display: none; }
#lb-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 42vh; overflow-y: auto; }
#lb-list li {
  display: grid; grid-template-columns: 2.2em 1fr auto 4.6em; align-items: baseline; gap: 8px;
  padding: 7px 6px; border-top: 1px solid color-mix(in srgb, var(--panel-edge) 70%, transparent); font-size: 14px;
}
.lb-rank { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); }
.lb-date { color: var(--ink-dim); font-size: 12px; text-align: right; }
#lb-close { display: block; width: 100%; margin-top: 12px; padding: 10px; border: none; background: transparent; color: var(--ink-dim); font: inherit; font-size: 13px; cursor: pointer; }
#lb-close:hover { color: var(--ink); }

/* Touch: no double-tap zoom / 300ms delay on controls */
button, .switch, .hud-btn, .chip, .quick-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------------------------------------------------------------
   Phones: controls become a bottom bar inside the thumb zone, the
   game banner spans the top, everything respects the notch/home bar.
   --------------------------------------------------------------- */
@media (max-width: 640px), (max-height: 520px) {
  /* a compact card floating at the bottom centre:
       Games
       [areas minimap | districts minimap]  (i)
       layers  map style  [language]       */
  #hud {
    top: auto;
    left: 50%;
    right: auto;
    bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(312px, calc(100vw - 40px));
    padding: 8px;
    border-radius: 20px;
    display: grid;
    grid-template-columns: 48px 48px 1fr 56px;
    gap: 8px;
    align-items: center;
  }
  #mode-switch { grid-row: 2; grid-column: 1 / 4; height: 56px; box-sizing: border-box; }
  #mode-switch .seg-text { display: none; }
  #mode-switch .mini { display: block; width: 88%; height: 44px; }
  #about-btn { grid-row: 2; grid-column: 4; width: 56px; height: 56px; }     /* a square as tall as the switch */
  #names-toggle { grid-row: 3; grid-column: 1; }
  #theme-btn { grid-row: 3; grid-column: 2; width: 48px; }
  #lang-switch { grid-row: 3; grid-column: 3 / 5; }
  #hud .brand { display: none; }
  #start-game { height: 48px; padding: 0; border-radius: 14px; font-size: 15px; }
  #start-game { grid-column: 1 / -1; }
  .switch.seg { margin: 0; }
  .switch.seg button { font-size: 14px; }
  #theme-btn { height: 48px; border-radius: 14px; }
  .btn-orb { width: 27px; height: 27px; }
  #names-toggle, .hud-btn { margin: 0; width: 48px; height: 48px; padding: 0; border-radius: 14px; }
  #names-toggle span, .hud-btn span { display: none; }
  #names-toggle svg, .hud-btn svg { width: 20px; height: 20px; }
  .hud-row { display: contents; }
  .switch { margin: 0; height: 48px; border-radius: 14px; }
  .switch .thumb { border-radius: 11px; }
  .switch button svg { width: 20px; height: 20px; }
  .switch[data-kind="lang"] .flag { width: 26px; max-height: 19px; }

  /* in a game the bar gives way to the End game button; only the palette stays, as a round button bottom-left */
  body.in-game #hud {
    top: auto; left: 12px; right: auto; width: auto; transform: none; padding: 0; display: block;
    background: none; border: none; box-shadow: none;
  }
  body.in-game #lang-switch { display: none; }
  body.in-game #theme-btn {
    width: 48px; border-radius: 50%;
    background: color-mix(in srgb, var(--panel) 92%, transparent); border-color: var(--panel-edge);
    box-shadow: 0 8px 26px rgba(0,0,0,0.4);
  }
  body.in-game #theme-btn.on { background: var(--accent); border-color: var(--accent); }
  #street-actions { bottom: calc(86px + env(safe-area-inset-bottom)); }
  #end-game-top { top: calc(10px + env(safe-area-inset-top)); left: 12px; }

  #game-ui {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(50% + 28px);             /* room for the back arrow on the left */
    width: calc(100vw - 80px);
    max-width: none;
    box-sizing: border-box;
    padding: 10px 14px;
    border-radius: 16px;
  }
  #game-target { font-size: 20px; }
  #btn-end-late, #btn-play-again { padding: 12px 20px; font-size: 15px; border-radius: 12px; }

  /* pinch to zoom; keep attribution clear of the bottom bar */
  .leaflet-control-zoom { display: none; }
  .leaflet-bottom.leaflet-right { margin-bottom: calc(210px + env(safe-area-inset-bottom)); }     /* just above the bar */
  .leaflet-control-attribution { font-size: 9px; }
  /* in a game the bar is gone: the credit sits small in the bottom-right corner, clear of the End game button */
  body.in-game .leaflet-bottom.leaflet-right { margin-bottom: env(safe-area-inset-bottom); }
  body.in-game .leaflet-control-attribution { max-width: 28vw; font-size: 8px; line-height: 1.25; text-align: right; border-radius: 6px 0 0 0; }
}

/* Short landscape phones: keep the game banner compact */
@media (max-height: 520px) and (min-width: 641px) {
  #hud { left: 50%; right: auto; width: 360px; transform: translateX(-50%); }
  #layers-panel, #theme-panel { right: auto; width: 300px; }
  #game-ui { width: 460px; padding: 6px 12px; }
  #game-target { font-size: 17px; margin-bottom: 2px; }
  #previous-region { display: none; }
}

/* Page change (game <-> About): fade in on load, fade out when leaving a link marked data-fade */
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
body { animation: page-in .45s ease backwards; }
body.leaving { opacity: 0; transition: opacity .28s ease; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { body { animation: none; } body.leaving { transition: none; } }

.noscript-note { position: fixed; inset: auto 12px 12px; padding: 12px; background: #fff; color: #000; z-index: 5000; }

/* how many questions + Start */
#count-row { margin: 16px 0 0; }
#count-row[hidden] { display: none; }
.count-head { display: flex; align-items: baseline; justify-content: space-between; }
.count-head label { font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim); }
#count-val { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--ink); }
#count-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px; margin: 4px 0 0; background: transparent; cursor: pointer;
  --fill: 50%;
}
#count-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--fill), color-mix(in srgb, var(--ink) 16%, transparent) var(--fill)); }
#count-range::-moz-range-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 16%, transparent); }
#count-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
#count-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 1px 6px rgba(0,0,0,.4); }
#count-range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 1px 6px rgba(0,0,0,.4); }
#count-range:disabled { opacity: .45; cursor: default; }
.count-scale { display: flex; justify-content: space-between; margin-top: -2px; font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
#count-note { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-dim); }
#game-start {
  display: block; width: 100%; margin-top: 14px; padding: 13px;
  border: none; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
}
#game-start:disabled { opacity: .4; cursor: default; }
#start-fail { margin: 8px 2px 0; font-size: 13px; font-weight: 600; color: var(--bad); }
#start-fail[hidden] { display: none; }

/* ---------------------------------------------------------------
   Map layers: the panel, and what the layers draw
   --------------------------------------------------------------- */
#layers-panel, #theme-panel {
  position: fixed; z-index: 1150;
  left: 228px; top: 18px; width: 248px; box-sizing: border-box;
  padding: 14px 14px 10px; border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 12px 34px rgba(0,0,0,0.35);
}
#layers-panel[hidden], #theme-panel[hidden] { display: none; }
body.in-game #layers-panel { display: none; }      /* the map style can be changed in a game too */

/* Map style picker: nine orbs, three by three; small, so most of the map stays in view */
#theme-panel { width: 252px; padding-bottom: 12px; }
.panel-head { display: flex; align-items: center; gap: 6px; }
.panel-head .lp-title { margin: 0; }
.panel-back {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin: -6px 0 -6px -6px; padding: 0;
  border: none; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
}
.panel-back:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.panel-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.tp-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  margin: 0; padding: 10px 2px 8px; border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--ink-dim); font: inherit; font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: background-color .2s, border-color .2s, color .2s;
}
.tp-grid button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.tp-grid button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.tp-grid button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* a glowing orb in the style's colours: dark rim, swirls of the colours, a soft highlight */
.orb {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  background:
    radial-gradient(circle at 30% 26%, rgba(255,255,255,.75) 0 5%, rgba(255,255,255,0) 20%),
    radial-gradient(ellipse 60% 45% at 62% 68%, var(--o3) 0, transparent 70%),
    radial-gradient(ellipse 55% 60% at 36% 42%, var(--o2) 0, transparent 72%),
    radial-gradient(circle at 50% 50%, var(--o1) 0 48%, color-mix(in srgb, var(--o1) 35%, #000) 100%);
  box-shadow: 0 0 14px 1px color-mix(in srgb, var(--o2) 55%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--o2) 60%, transparent), inset 0 -4px 10px rgba(0,0,0,.45);
  transition: transform .25s;
}
.orb.globe { background: none; box-shadow: 0 0 12px 1px rgba(110,180,255,.5); }      /* satellite: a small earth instead of an orb */
.orb.globe svg { display: block; width: 100%; height: 100%; }
.tp-grid button:hover .orb, .tp-grid button.active .orb { transform: scale(1.08); }
/* Opal: the glass orb full of colour (swirls of blue, violet, pink and gold, a shine on top, a glowing rim) */
.orb.orb-opal, .btn-orb .orb.orb-opal {
  background:
    radial-gradient(ellipse 42% 26% at 38% 22%, rgba(255,255,255,.95), rgba(255,255,255,0) 72%),
    radial-gradient(ellipse 30% 14% at 58% 86%, rgba(255,240,220,.7), rgba(255,240,220,0) 80%),
    radial-gradient(circle at 26% 36%, #5fb6ff 0, rgba(95,182,255,0) 46%),
    radial-gradient(circle at 76% 32%, #a65cff 0, rgba(166,92,255,0) 50%),
    radial-gradient(ellipse 60% 34% at 50% 62%, #ffd447 0, rgba(255,212,71,0) 70%),
    radial-gradient(circle at 22% 74%, #ff4f86 0, rgba(255,79,134,0) 55%),
    radial-gradient(circle at 80% 74%, #ff3f6c 0, rgba(255,63,108,0) 55%),
    #ff7d3b;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), inset -2px -3px 6px rgba(70,10,90,.45), inset 2px 2px 4px rgba(255,255,255,.35), 0 0 10px rgba(255,110,120,.55);
}
.lp-title { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); }
.lp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; color: var(--ink); cursor: pointer; }
.lp-row + .lp-row { border-top: 1px solid color-mix(in srgb, var(--panel-edge) 70%, transparent); }
.lp-row input {
  -webkit-appearance: none; appearance: none; flex: none; position: relative;
  width: 40px; height: 24px; margin: 0; border-radius: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background-color .2s;
}
.lp-row input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); transition: transform .2s, background-color .2s;
}
.lp-row input:checked { background: var(--accent); }
.lp-row input:checked::after { transform: translateX(16px); background: var(--accent-ink); }
.lp-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lp-note { margin: 4px 0 2px; font-size: 12px; color: var(--ink-dim); }
.lp-note[hidden] { display: none; }

/* not during a game: the outlines, icons and street names would give the answers away */
body.in-game .leaflet-ov-areas-pane, body.in-game .leaflet-ov-streets-pane, body.in-game .leaflet-ov-icons-pane { display: none; }
canvas.street-names { position: absolute; left: 0; top: 0; pointer-events: none; }

/* names of parks and lakes (sized to fit like the district names) */
.dlabel.park span { color: color-mix(in srgb, var(--good) 70%, var(--ink)); font-weight: 600; }
.dlabel.lake span { color: color-mix(in srgb, var(--accent) 80%, var(--ink)); font-weight: 600; font-style: italic; }

/* monuments and buildings: a small icon, the name when zoomed in close */
.poi { pointer-events: none; }
.poi-dot {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: 20px; height: 20px; box-sizing: border-box; padding: 3px; border-radius: 50%;
  background: var(--panel); border: 1.5px solid var(--poi, var(--accent)); color: var(--poi, var(--accent));
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.poi-dot svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.poi-monuments { --poi: var(--accent); }
.poi-buildings { --poi: #d9a441; }
.poi-name {
  position: absolute; left: 14px; top: 0; transform: translateY(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 650; color: var(--ink);
  text-shadow: 0 0 2px var(--land), 0 0 4px var(--land), 0 0 6px var(--land);
  opacity: 0; transition: opacity .2s;
}
.poi.named .poi-name { opacity: 1; }
body.in-game .poi:not(.poi-hint) { display: none; }

@media (max-width: 640px), (max-height: 520px) {
  /* the map style picker and the map layers panel sit at the very bottom in place of the bar
     (hidden while choosing); the arrow goes back */
  #layers-panel, #theme-panel { left: 12px; right: 12px; width: auto; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
  body.styles-open #hud, body.layers-open #hud { display: none; }
  .panel-back { display: flex; }
  .panel-head { margin-bottom: 2px; }
}
