:root {
  --bg: #0a0f1a;
  --panel: #111827;
  --ink: #e8edf5;
  --muted: #8b95a8;
  --line: #24304a;
  --accent: #ffc857;
  --water: #0e2a47;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}
.top { padding: 14px 20px 8px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand-tld { color: var(--accent); font-weight: 600; }
.top .sub { color: var(--muted); font-size: 14px; flex: 1 1 400px; }
.debug-strip { width: 100%; max-width: 1200px; border: 1px solid var(--line); display: block; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
  gap: 0;
  min-height: 0;
}
@media (max-width: 860px) {
  /* Phones: the page scrolls as a whole; the globe takes a fixed share of the screen and the
     results flow underneath at full height (no inner scrolling strip). */
  html, body { height: auto; min-height: 100%; }
  body { display: block; }
  .top { padding: 12px 16px 6px; }
  .top .sub { font-size: 12.5px; }
  .layout { display: block; }
  .globe-wrap { height: 56vh; min-height: 300px; }
  .panel { overflow: visible; border-left: 0; border-top: 1px solid var(--line); padding: 16px 16px 28px; }
  #chart { width: min(100%, 300px); }
  /* Header on phones: wordmark + Share on one line, the hint underneath. */
  .top { gap: 8px 12px; }
  .viewlink-wrap { order: 1; margin-left: auto; }
  .top .sub { order: 2; flex-basis: 100%; }
  /* Jump box and location button share one line: the select shrinks, the button doesn't. */
  .presets { flex-wrap: nowrap; }
  .presets select { flex: 1 1 0; min-width: 0; max-width: none; font-size: 12.5px; }
  .presets button.locate { flex: 0 0 auto; font-size: 12px; }
}

.globe-wrap { position: relative; min-height: 420px; }
#globe { width: 100%; height: 100%; display: block; cursor: crosshair; }
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(10,15,26,0.85);
  color: var(--muted);
  font-size: 15px;
}
.overlay[hidden] { display: none; }
.loadbox { width: min(360px, 80%); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.progress { width: 100%; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.15s; }
.presets {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.presets button {
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink); background: rgba(17,24,39,0.85);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; cursor: pointer;
}
.presets button:hover { border-color: var(--accent); }
.presets select {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink); background: rgba(17,24,39,0.92);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 32px 6px 12px; cursor: pointer; max-width: min(100%, 420px);
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.presets select:hover { border-color: var(--accent); }
.presets select option, .presets select optgroup { background: #111827; color: var(--ink); font-weight: 400; }
.presets button.locate { margin-left: auto; border-color: #3b82f6; color: #bfdbfe; }
.presets button.locate.on { background: #1d4ed8; color: #fff; }

/* Country labels: HTML overlay projected from the globe each frame. */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute; left: 0; top: 0;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: #f3f4f6; white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 6px #000, 0 1px 2px #000;
  will-change: transform;
}
.label.big { font-size: 13px; letter-spacing: 0.03em; }
.label[hidden] { display: none; }

/* Tooltip for great-circle paths. */
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: rgba(17,24,39,0.95); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 9px; font-size: 12.5px; color: var(--ink); white-space: nowrap;
  transform: translate(12px, 12px);
}
.tip[hidden] { display: none; }
.tip .tip-country { font-weight: 700; }
.tip .tip-meta { color: var(--muted); }

.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 18px 20px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.place .name { font-size: 18px; font-weight: 700; }
.place .coords { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.place .hint { color: var(--muted); }
.viewlink-wrap { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; }
.viewlink {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--bg); background: var(--accent); border: 0; border-radius: 999px;
  padding: 6px 14px; cursor: pointer;
}
.viewlink:hover:not(:disabled) { filter: brightness(1.08); }
.viewlink:disabled { opacity: 0.45; cursor: default; }
.viewlink-status { font-size: 12.5px; color: var(--muted); word-break: break-all; }

.chart-wrap { display: grid; place-items: center; }
#chart { width: min(100%, 340px); height: auto; }
#chart .ring { fill: none; stroke: var(--line); stroke-width: 1; }
#chart .tick { stroke: var(--line); stroke-width: 1; }
#chart .tick-label { fill: var(--muted); font-size: 11px; text-anchor: middle; font-weight: 600; }
#chart .you { fill: var(--accent); }
#chart .wedge { stroke: none; }
#chart .wedge:hover { opacity: 0.75; }

.legend-head { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.step-ctl { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.step-ctl select { font: inherit; font-size: 12px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: baseline; font-size: 14px; padding: 3px 6px; margin: 0 -6px; border-radius: 6px; cursor: default; }
.legend li.hl, .legend li:hover { background: rgba(255,200,87,0.12); }
#chart .wedge.hl { stroke: #fff; stroke-width: 1.5; }
.legend .swatch { width: 14px; height: 14px; border-radius: 3px; transform: translateY(2px); }
.legend .country { font-weight: 600; }
.legend .country small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.legend .ranges { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; }
.legend .home .country::after { content: " (home)"; color: var(--accent); font-weight: 400; }
.legend .blocked { color: var(--muted); font-size: 12.5px; }

.note { color: var(--muted); font-size: 12.5px; }
.note:first-of-type { border-top: 1px solid var(--line); padding-top: 12px; }
.note strong { color: var(--ink); font-weight: 600; }
.note em { font-style: italic; }
.note a { color: var(--accent); }
