:root {
  --bg: #07051a;
  --panel: rgba(22, 15, 52, 0.72);
  --border: rgba(167, 139, 250, 0.22);
  --text: #ece8ff;
  --muted: #a39dc9;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-pink: #e879f9;
  --crosshair: rgba(240, 171, 252, 0.9);
  --good: #4ade80;
  --bad: #fb7185;
  --radius: 18px;
  --card-pad: 20px;
  --gap: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Keep `hidden` working on elements that set their own display. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(124, 58, 237, 0.35), transparent 60%),
    radial-gradient(ellipse 60% 45% at 95% 35%, rgba(219, 39, 119, 0.2), transparent 60%),
    radial-gradient(ellipse 90% 50% at 50% 105%, rgba(37, 99, 235, 0.25), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Starfield: tiles of different, coprime sizes so the pattern never visibly repeats. */
.stars, .stars::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 25px 35px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 90px 150px, #e9d5ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 160px 60px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 40px 190px, #c7d2fe 50%, transparent 51%),
    radial-gradient(2px 2px at 220px 120px, #fff 50%, transparent 51%);
  background-size: 173px 173px, 241px 241px, 311px 311px, 197px 197px, 389px 389px;
  opacity: 0.7;
}

.stars::after {
  content: "";
  background-position: 70px 110px, 30px 60px, 120px 200px, 150px 20px, 10px 300px;
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.15; }
  to { opacity: 0.8; }
}

/* Header */
.site-header {
  text-align: center;
  padding: 18px 0 14px;
}

.logo {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.logo span {
  background: linear-gradient(90deg, var(--accent), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.site-header { position: relative; width: 100%; }

/* Statistics and How to play, top right. */
.header-actions {
  position: absolute;
  top: 18px;
  right: 0;
  display: flex;
  gap: 8px;
}

.header-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(22, 15, 52, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.header-button:hover { background: rgba(139, 92, 246, 0.45); border-color: var(--accent); }
.header-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Statistics: four numbers, then a bar per number of guesses. */
.stats { display: grid; gap: 14px; }
.stats:empty { display: none; }
.stats-empty { margin: 0; color: var(--muted); text-align: center; }

/* In the 📊 dialog: room above the Close button, like the help steps. */
.help .stats { margin-bottom: 22px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.stats-grid b {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stats-grid span { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }

.dist-title { margin: 0; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; }

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

.dist li {
  display: grid;
  grid-template-columns: 1.2em 1fr;
  gap: 8px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.dist .bar {
  width: var(--w);
  min-width: 1.8em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(167, 139, 250, 0.25);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
}

.dist li.lost .bar { background: rgba(148, 163, 184, 0.22); }
.dist li.today .bar { background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink)); color: #fff; }

.share-button { margin-top: 14px; }

.result .stats { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* How to play */
.help {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background: #140d33;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(139, 92, 246, 0.2);
}

.help[open] { animation: help-in 0.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.help::backdrop { background: rgba(5, 3, 18, 0.7); backdrop-filter: blur(4px); }

@keyframes help-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.help-body { padding: 24px; }
.help h2 { margin: 0 0 16px; font-size: 1.5rem; text-align: center; }

.help-steps {
  display: grid;
  gap: 14px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.help-steps li { display: flex; gap: 14px; align-items: center; }
.help-steps p { margin: 0; color: var(--muted); line-height: 1.45; }
.help-steps strong { color: var(--text); }

.help-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.16);
  font-size: 1.3rem;
}

.primary-button {
  display: block;
  width: 100%;
  padding: 13px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink));
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.4);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* "New city!" note for returning players */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 20;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(20, 13, 51, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 24px rgba(167, 139, 250, 0.35);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.35s, transform 0.35s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.puzzle-label {
  display: inline-block;
  margin: 8px 0 0;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

main {
  width: 100%;
  max-width: 720px;
}

/* Card */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  padding: var(--card-pad);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 80px rgba(139, 92, 246, 0.12);
}

.intro { text-align: center; }
.intro h2 { margin-top: 0; }
.intro p { color: var(--muted); }

code {
  background: rgba(167, 139, 250, 0.15);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--accent);
}

/* Narrow screens: image on top, globe and controls below (the page scrolls). */
.game {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.image-column, .globe-column {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

/* Round status */
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.round-label {
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

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

.pips li {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}

.pips li.current {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.pips li.wrong { background: var(--bad); border-color: transparent; }
.pips li.correct { background: var(--good); box-shadow: 0 0 10px var(--good); border-color: transparent; }

/* The reveal image, once the game is over: a hollow ring with a dot, set apart from the rounds. */
.pips li.reveal {
  margin-left: 6px;
  border: 1.5px solid var(--accent);
  background: radial-gradient(circle, var(--accent) 0 2px, transparent 2.5px);
}

/* The image on screen gets a bright ring. */
.pips li.viewing {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--crosshair), 0 0 12px rgba(240, 171, 252, 0.6);
}

/* Satellite viewport */
.viewport {
  position: relative;
  margin: 0;
  width: 100%;
  aspect-ratio: 1;
  flex: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0c0824;
  border: 1px solid var(--border);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.08), 0 0 50px rgba(139, 92, 246, 0.25);
}

/* Horizontal swipes browse images; vertical ones still scroll the page. */
.viewport { touch-action: pan-y; } /* Pinches reach the page as pointer events, for zooming between images. */
.viewport.swipeable { cursor: grab; }
.viewport.dragging { cursor: grabbing; }

.track {
  display: flex;
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.track img {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

/*
 * A small dot at the centre, where the city is, on every image after the first.
 * The dark outline keeps it visible on snow, sea and city alike.
 */
.center-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(7, 5, 26, 0.55);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.2s;
}

/* Two soft pulses when it appears after a zoom, so the eye finds it. */
.center-dot.pulse { animation: center-dot-pulse 0.8s ease-out 2; }

@keyframes center-dot-pulse {
  0% { opacity: 1; box-shadow: 0 0 0 1.5px rgba(7, 5, 26, 0.55), 0 0 0 0 rgba(240, 171, 252, 0.85); }
  100% { box-shadow: 0 0 0 1.5px rgba(7, 5, 26, 0.55), 0 0 0 18px rgba(240, 171, 252, 0); }
}

/* Out of the way while the image is being dragged. */
.viewport.dragging .center-dot { opacity: 0; }

/* A copy of the image that was on screen, scaled during a zoom transition (see zoomTo in app.js). */
.zoom-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  will-change: transform, opacity;
}

.nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 42px;
  height: 42px;
  padding: 0 0 4px;
  transform: translateY(-50%);
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(7, 5, 26, 0.65);
  backdrop-filter: blur(6px);
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}

.nav.prev { left: 14px; }
.nav.next { right: 14px; }
.nav:hover { background: rgba(139, 92, 246, 0.55); }
.viewport:hover .nav, .nav:focus-visible { opacity: 1; }

/* No hover on touch screens, so keep the arrows faintly visible. */
@media (hover: none) {
  .nav { opacity: 0.8; }
}

.zoom-badge {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(7, 5, 26, 0.7);
  backdrop-filter: blur(6px);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.zoom-badge:has(button:not([hidden])) { padding-right: 6px; }

.zoom-badge button {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink));
  color: #fff;
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}

/* Each new image arrives as if the camera pulls back. */
.track img.reveal {
  animation: pull-back 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes pull-back {
  from { transform: scale(1.35); filter: blur(6px) brightness(1.4); opacity: 0.3; }
  to { transform: scale(1); filter: none; opacity: 1; }
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(233, 213, 255, 0.7);
  pointer-events: none;
}
.corner.tl { top: 12px; left: 12px; border-right: 0; border-bottom: 0; border-top-left-radius: 6px; }
.corner.tr { top: 12px; right: 12px; border-left: 0; border-bottom: 0; border-top-right-radius: 6px; }
.corner.bl { bottom: 12px; left: 12px; border-right: 0; border-top: 0; border-bottom-left-radius: 6px; }
.corner.br { bottom: 12px; right: 12px; border-left: 0; border-top: 0; border-bottom-right-radius: 6px; }

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.8rem;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15), rgba(12, 8, 36, 0.92) 70%);
  transition: opacity 0.3s;
}

.loader.hidden { opacity: 0; pointer-events: none; }

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.7); box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.6); }
  50% { transform: scale(1); box-shadow: 0 0 0 10px rgba(167, 139, 250, 0); }
}

/* Globe */
.globe-area {
  display: flex;
  justify-content: center;
}

.globe {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 1;
}

.globe canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none; /* Dragging on the globe rotates it instead of scrolling the page. */
  cursor: grab;
}

.globe canvas.dragging { cursor: grabbing; }

/* The ring's radius matches SELECT_RADIUS in globe.js. */
.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--crosshair);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(240, 171, 252, 0.45);
  pointer-events: none;
}

.crosshair::before, .crosshair::after {
  content: "";
  position: absolute;
  background: linear-gradient(var(--dir), var(--crosshair) 0 9px, transparent 9px calc(100% - 9px), var(--crosshair) calc(100% - 9px));
}

/* Win: the crosshair snaps tight onto the city, turns green and pulses. */
.crosshair.locked {
  --crosshair: rgba(74, 222, 128, 0.95);
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.6);
  animation: lock-on 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), lock-pulse 1.1s ease-in-out 0.5s 3;
}

@keyframes lock-on {
  from { transform: translate(-50%, -50%) scale(1.8); opacity: 0.2; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes lock-pulse {
  50% { transform: translate(-50%, -50%) scale(0.82); box-shadow: 0 0 28px rgba(74, 222, 128, 0.85); }
}

.crosshair::before { --dir: to bottom; left: 50%; top: -12px; bottom: -12px; width: 1.5px; transform: translateX(-50%); }
.crosshair::after { --dir: to right; top: 50%; left: -12px; right: -12px; height: 1.5px; transform: translateY(-50%); }

/* The new band's signal strength, at the top of the globe while it pulses (timings from app.js). */
.signal-readout {
  position: absolute;
  top: 6%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--band) 55%, transparent);
  border-radius: 999px;
  background: rgba(7, 5, 26, 0.78);
  box-shadow: 0 0 14px color-mix(in srgb, var(--band) 35%, transparent);
  color: var(--band);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  pointer-events: none;
  animation: readout-in 250ms ease-out;
  transition: opacity 700ms; /* MERGE_MS */
}

.signal-readout[hidden] { display: none; }
.signal-readout.fading { opacity: 0; }
.signal-readout .untyped { visibility: hidden; }
.signal-readout .signal-bars i.lit { animation: readout-pulse var(--pulse-ms) ease-in-out var(--pulses); }

@keyframes readout-in {
  from { opacity: 0; transform: translate(-50%, -6px); }
}

/* Dim to bright and back, in step with the band (sin² in globe.js). */
@keyframes readout-pulse {
  from, to { opacity: 0.4; }
}

.globe-hint {
  margin: -6px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.globe-hint.highlight { color: var(--crosshair); }
.game.over .globe-hint { display: none; }

/* Ring tip: sits just below the globe, pointing up at it, so it never covers the ring. */
.ring-tip {
  position: relative;
  flex: none;
  width: min(340px, 100%);
  margin: 4px auto 0;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: #140d33;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55), 0 0 24px rgba(167, 139, 250, 0.35);
  font-size: 0.88rem;
  line-height: 1.45;
  animation: tip-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.ring-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  width: 14px;
  height: 14px;
  transform: translateX(-50%) rotate(45deg);
  border-left: 1px solid var(--accent);
  border-top: 1px solid var(--accent);
  background: #140d33;
}

.ring-tip p { margin: 0 0 10px; color: var(--muted); }
.ring-tip strong { color: var(--text); }

.ring-tip button {
  display: block;
  margin-left: auto;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink));
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

@keyframes tip-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Guess: the city in the crosshair plus the button */
.guess-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(7, 5, 26, 0.7);
}

.selection {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.selection-label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.selected-name {
  font-size: 1.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-name.empty { color: var(--muted); font-weight: 500; }

.guess-form button {
  padding: 13px 24px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink));
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.4);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.guess-form button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(168, 85, 247, 0.55); }
.guess-form button:active { transform: translateY(0); }
.guess-form button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* A short pulse when a new city lands in the crosshair, to draw the eye to Guess. */
.guess-form button.attention { animation: guess-pulse 0.6s ease-out; }

@keyframes guess-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(232, 121, 249, 0.7); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(232, 121, 249, 0); }
}

/*
 * Narrow screens: the guess bar sticks to the bottom of the screen while the
 * globe section is in view, so Guess is reachable without scrolling.
 */
.guess-form {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  background: rgba(14, 9, 38, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.message {
  margin: 0 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.message:empty { display: none; }

/* Previous guesses */
.guesses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.guesses:empty { display: none; }

/* Each chip is coloured by its distance band (--band, set from app.js): warm = strong signal (close), cold = faint (far). */
.guess-chip {
  --band: var(--bad);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--band) 55%, transparent);
  background: color-mix(in srgb, var(--band) 14%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
}

.guess-chip:hover { background: color-mix(in srgb, var(--band) 24%, transparent); }
.guess-chip.active { box-shadow: 0 0 0 2px var(--band), 0 0 14px color-mix(in srgb, var(--band) 50%, transparent); }
.guess-chip .x { color: var(--band); }
.guess-chip .band { color: var(--band); font-weight: 700; margin-left: 2px; white-space: nowrap; }
.guess-chip .signal-bars { margin-right: 5px; }

/* Phone-style signal bars in the current colour; unlit bars stay faintly visible. */
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.8em;
}

.signal-bars i {
  width: 3px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.25;
}

.signal-bars i:nth-child(1) { height: 25%; }
.signal-bars i:nth-child(2) { height: 50%; }
.signal-bars i:nth-child(3) { height: 75%; }
.signal-bars i:nth-child(4) { height: 100%; }
.signal-bars i.lit { opacity: 1; }

/* The latest wrong guess: pops in, then pulses along with its band on the globe (timings from app.js). */
.guess-chip.fresh {
  animation:
    chip-pop 450ms cubic-bezier(0.2, 0.9, 0.3, 1.3) var(--pop-delay) both,
    chip-pulse var(--pulse-ms) ease-in-out var(--pulse-delay) var(--pulses);
}

@keyframes chip-pop {
  from { opacity: 0; transform: scale(0.6); }
}

@keyframes chip-pulse {
  50% {
    background: color-mix(in srgb, var(--band) 40%, transparent);
    box-shadow: 0 0 0 2px var(--band), 0 0 18px color-mix(in srgb, var(--band) 70%, transparent);
  }
}

/* Reduced motion: lit up steadily while the band is, like on the globe. */
@keyframes chip-hold {
  from, to {
    background: color-mix(in srgb, var(--band) 40%, transparent);
    box-shadow: 0 0 0 2px var(--band);
  }
}

/* End of game */
.result {
  padding: 18px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.2), rgba(232, 121, 249, 0.08));
}

.result.won { border-color: rgba(74, 222, 128, 0.45); box-shadow: 0 0 40px rgba(74, 222, 128, 0.12); }

/* The result card slides up with a glow when a game has just ended (not on a restore). */
.result.celebrate { animation: result-in 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.result.won.celebrate { animation: result-in 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), won-glow 1.8s ease-out 0.3s; }

@keyframes result-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes won-glow {
  30% { box-shadow: 0 0 60px rgba(74, 222, 128, 0.45); }
}

/* Full-screen canvas for the win starburst; never blocks clicks. */
.starburst {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.result h2 { margin: 0 0 6px; font-size: 1.6rem; }
.result p { margin: 0; color: var(--muted); }
.result strong { color: var(--text); }
.result p.result-hint { margin-top: 10px; font-size: 0.85rem; }

/* "See the overview": a quiet text button that scrolls up to the image and zooms out again. */
.link-button {
  margin-top: 6px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.link-button:hover { color: var(--accent-pink); text-decoration: underline; }
.link-button[hidden] { display: none; }

/*
 * Narrow screens, once the game is over: in the guess bar's place at the bottom
 * of the screen, saying how it went and leading down to the result card. It
 * slides away while the card is on screen (.away, set from app.js).
 */
.result-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 5;
  width: min(calc(100% - 2 * (16px + var(--card-pad) + 1px)), calc(720px - 2 * var(--card-pad) - 2px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(14, 9, 38, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transform: translateX(-50%);
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.4s;
}

.result-bar[hidden] { display: none; }
.result-bar.away { transform: translate(-50%, calc(100% + 24px)); opacity: 0; pointer-events: none; }
.result-bar.won { border-color: rgba(74, 222, 128, 0.45); }
.result-bar.won.celebrate { animation: won-glow 1.8s ease-out 0.3s; }

.result-bar-text {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-bar-cta {
  padding: 13px 18px;
  border-radius: 999px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-pink));
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.4);
}

.result p.next-city {
  margin-top: 12px;
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Footer */
.attribution {
  margin-top: auto;
  padding: 14px 0 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.attribution a { color: var(--muted); }
.attribution a:hover { color: var(--accent); }

@media (max-width: 480px) {
  /* Thin margins: the image spans the card, so it gets nearly the full screen width. */
  :root { --card-pad: 10px; }
  body { padding: 0 8px; }
  .guess-form { padding-left: 16px; }
  .guess-form button { padding: 13px 18px; }
  .result-bar { width: calc(100% - 2 * (8px + var(--card-pad) + 1px)); padding-left: 16px; }
}

/*
 * Wide, landscape windows: image on the left as tall as the window allows,
 * globe and controls on the right, nothing to scroll.
 */
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  body { height: 100vh; height: 100dvh; }

  main {
    flex: 1;
    min-height: 0;
    max-width: none;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    container-type: size;
  }

  /* Every pixel of height goes to the image: a one-row header and a thin footer. */
  .site-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 0;
  }

  .logo { font-size: 1.9rem; }
  .tagline, .puzzle-label { margin: 0; }
  .header-actions { top: 50%; transform: translateY(-50%); }

  .attribution { padding: 6px 0 8px; }

  /*
   * The image is as tall as the window allows (but never wider than the room
   * next to a minimal globe column). Then it grows sideways, up to the image's
   * own shape (--image-aspect, set from app.js), as long as the globe column
   * keeps --globe-pref. In between, object-fit: cover crops the sides.
   */
  .game {
    --image-aspect: 1;
    --columns-gap: 28px;
    --globe-min: 300px;
    --globe-pref: 420px;
    --globe-max: 560px;
    --inner-w: calc(100cqw - 2 * var(--card-pad) - 2px - var(--columns-gap));
    --view-h: min(100cqh - 2 * var(--card-pad) - 2px, var(--inner-w) - var(--globe-min), 1100px);
    --view-w: max(var(--view-h), min(var(--view-h) * var(--image-aspect), var(--inner-w) - var(--globe-pref)));
    display: grid;
    grid-template-columns: var(--view-w) minmax(var(--globe-min), var(--globe-max));
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: var(--columns-gap);
    row-gap: var(--gap);
    width: min(100%, calc(var(--view-w) + 2 * var(--card-pad) + 2px + var(--columns-gap) + var(--globe-max)));
    height: calc(var(--view-h) + 2 * var(--card-pad) + 2px);
  }

  /* The round and pips move above the globe, so the image gets the full height. */
  .image-column { display: contents; }
  .status-row { grid-column: 2; grid-row: 1; }

  .viewport {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: var(--view-w);
    height: var(--view-h);
  }

  .globe-column {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
  }

  /* The globe takes whatever height the controls below it leave. */
  .globe-area {
    flex: 1;
    min-height: 160px;
    container-type: size;
  }

  .globe { width: min(100cqw, 100cqh); }

  /* Everything fits on screen here, so the guess bar stays in place, and the result card is in view. */
  .guess-form { position: static; box-shadow: none; }
  .result-bar { display: none; }
}

/* Not enough room for the tagline beside the logo and puzzle label. */
@media (min-width: 760px) and (max-width: 999px) and (min-aspect-ratio: 1/1) {
  .tagline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stars::after, .pulse, .track img.reveal, .guess-form button.attention, .help[open], .ring-tip,
  .crosshair.locked, .result.celebrate, .center-dot.pulse, .signal-readout,
  .signal-readout .signal-bars i.lit, .result-bar.won.celebrate { animation: none; }
  .result-bar { transition: none; }
  .toast { transition: none; }
  .track { transition: none; }
  .guess-chip.fresh { animation: chip-hold calc(var(--pulse-ms) * var(--pulses)) linear var(--pulse-delay); }
}
