:root {
  --bg: #070b14;
  --ink: #e6edf6;
  --dim: #8a94a8;
  --accent: #38bdf8;
  --panel: rgba(10, 16, 28, 0.82);
  --line: rgba(122, 145, 178, 0.22);
  --radius: 10px;
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
canvas#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 14px; z-index: 5;
  pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.8);
}
#hud h1 { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: .01em; }
#hud .stats { margin: 2px 0 0; font-size: .78rem; color: var(--dim); }

/* ---------- search ---------- */
#searchbox {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: 14px; z-index: 20; width: min(300px, calc(100vw - 28px));
}
#search {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font-size: .9rem; backdrop-filter: blur(6px);
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 0; }
#results {
  margin-top: 6px; border-radius: var(--radius); border: 1px solid var(--line);
  background: rgba(8, 13, 24, .96); max-height: 46vh; overflow: auto;
}
#results button {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  background: none; border: 0; border-bottom: 1px solid rgba(122,145,178,.12);
  color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer;
}
#results button:last-child { border-bottom: 0; }
#results button:hover, #results button.active { background: rgba(56,189,248,.12); }
#results .sub { color: var(--dim); font-size: .74rem; }

/* ---------- goose takeover ---------- */
#goosePanel {
  position: fixed; z-index: 18; top: 62px; right: 14px; width: min(286px, calc(100vw - 28px));
  padding: 12px 13px 11px; border: 1px solid rgba(251,191,36,.35); border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(30,25,17,.92), rgba(10,16,28,.9));
  box-shadow: 0 10px 30px rgba(0,0,0,.2); backdrop-filter: blur(9px);
}
.goose-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.goose-head h2 { margin: 0; font-size: .98rem; letter-spacing: .01em; }
.goose-kicker { margin: 2px 0 0; color: #f6d58b; font-size: .68rem; }
.goose-emoji { font-size: 1.65rem; line-height: 1; filter: drop-shadow(0 2px 5px rgba(0,0,0,.35)); }
.goose-mode { width: 100%; margin-top: 10px; padding: 8px 10px; border: 1px solid rgba(251,191,36,.5); border-radius: 8px;
  background: rgba(251,191,36,.11); color: #fff4cf; font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; }
.goose-mode:hover, .goose-mode[aria-pressed="true"] { background: rgba(251,191,36,.24); border-color: #fbbf24; }
.goose-status { min-height: 2.25em; margin: 7px 0 8px; color: var(--dim); font-size: .7rem; line-height: 1.35; }
.goose-status.active { color: #fde68a; }
.goose-radius { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; color: #d8dee9; font-size: .72rem; }
.goose-radius output { color: #fbbf24; font-variant-numeric: tabular-nums; }
.goose-radius input { grid-column: 1 / -1; width: 100%; accent-color: #fbbf24; cursor: pointer; }
.goose-actions { display: flex; justify-content: flex-end; }
.goose-actions .chip { padding: 5px 9px; font-size: .7rem; }
.goose-actions button:disabled { cursor: default; opacity: .45; }
.goose-note { margin: 8px 0 0; color: #9299a8; font-size: .63rem; line-height: 1.35; }

/* ---------- airport card ---------- */
#airportCard {
  position: fixed; z-index: 15;
  left: 14px; bottom: calc(128px + env(safe-area-inset-bottom));
  width: min(320px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; backdrop-filter: blur(8px);
}
@media (min-width: 640px) { #airportCard { bottom: 150px; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head h2 { margin: 0; font-size: .95rem; font-weight: 650; }
.card-head .stats { margin: 2px 0 0; font-size: .74rem; color: var(--dim); }
#apClear {
  border: 0; background: none; color: var(--dim); font-size: 1.2rem; line-height: 1;
  padding: 2px 6px; cursor: pointer; border-radius: 6px;
}
#apClear:hover { color: var(--ink); background: rgba(122,145,178,.15); }
.famlist { margin: 8px 0 0; font-size: .76rem; line-height: 1.55; color: var(--ink); }
.famlist b { color: var(--accent); font-weight: 600; }
.famlist .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: baseline; }

/* ---------- filters ---------- */
#filters {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(7,11,20,.92), rgba(7,11,20,0));
  display: flex; flex-direction: column; gap: 8px;
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 5px 11px; font-size: .76rem; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.chip:hover { border-color: rgba(56,189,248,.5); }
.chip .cnt { color: var(--dim); font-size: .68rem; margin-left: 4px; }
.chip.fam { display: inline-flex; align-items: center; gap: 5px; }
.chip.fam .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.on { border-color: rgba(56,189,248,.65); background: rgba(56,189,248,.10); }
.chip.off { opacity: .45; }
.chip[aria-pressed="true"] { border-color: rgba(56,189,248,.65); background: rgba(56,189,248,.10); }
.src { font-size: .68rem; color: var(--dim); margin: 0; }
.src a { color: var(--dim); text-decoration: underline dotted; }

/* ---------- loading / errors ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center;
  justify-items: center; gap: 12px; background: var(--bg); transition: opacity .4s;
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(56,189,248,.18); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { margin: 0; color: var(--dim); font-size: .82rem; }
#nogl { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; background: var(--bg); text-align: center; padding: 0 24px; }

@media (max-width: 639px) {
  #searchbox { top: 62px; left: 14px; right: 14px; width: auto; }
  #goosePanel { top: 116px; left: 14px; right: 14px; width: auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .chip { min-height: 40px; flex-shrink: 0; }
  #airportCard { bottom: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  #loading.done { transition: none; }
  .spinner { animation-duration: 2s; }
}
