:root {
  --bg: #060b14;
  --panel: rgba(10, 18, 32, 0.82);
  --panel-border: rgba(120, 180, 255, 0.18);
  --text: #e8f0fa;
  --text-dim: #93a7c2;
  --accent: #4cc3ff;
  --accent-dim: rgba(76, 195, 255, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
}

#globe {
  position: absolute;
  inset: 0;
}

/* ---------- loading overlay ---------- */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, #0a1426 0%, #04070d 100%);
  z-index: 50;
  transition: opacity 0.6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loadingText { color: var(--text-dim); font-size: 14px; letter-spacing: 0.04em; }
.spinner {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 3px solid rgba(76, 195, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- control panel ---------- */
#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 264px;
  padding: 16px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
#panel h1 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
#panel .hint {
  margin: 0 0 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle .switch {
  flex: none;
  width: 36px; height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  position: relative;
  transition: background 0.2s;
}
.toggle .switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #c8d6e8;
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .switch { background: var(--accent-dim); }
.toggle input:checked + .switch::after {
  transform: translateX(16px);
  background: var(--accent);
}
.toggle .label { font-size: 13.5px; }
.toggle .label small { color: var(--text-dim); font-size: 11px; }

#flightStatus,
#geoStatus {
  margin: 4px 0 2px;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  background: rgba(76, 195, 255, 0.08);
  border-radius: 8px;
}

#resetView {
  margin-top: 10px;
  width: 100%;
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
#resetView:hover { background: rgba(76, 195, 255, 0.18); }

#panel .credits {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 9.5px;
  line-height: 1.5;
  color: #5f7187;
}

/* ---------- country popup ---------- */
#popup {
  position: absolute;
  z-index: 20;
  min-width: 230px;
  max-width: 280px;
  padding: 13px 15px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#popup .head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 3px;
}
#popup .flag { font-size: 24px; line-height: 1; }
#popup .name { font-size: 15.5px; font-weight: 650; }
#popup .region {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
#popup .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 3.5px 0;
  font-size: 12.5px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
#popup .row .k { color: var(--text-dim); }
#popup .row .v { font-variant-numeric: tabular-nums; font-weight: 550; }
#popup .pill {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text);
  background: rgba(159, 216, 255, 0.16);
  border: 1px solid rgba(159, 216, 255, 0.3);
  border-radius: 8px;
  vertical-align: 1px;
}
#popup .pill.gold {
  color: #ffd24c;
  background: rgba(255, 210, 76, 0.12);
  border-color: rgba(255, 210, 76, 0.35);
}

#popup .foot {
  margin-top: 8px;
  font-size: 10px;
  color: #5f7187;
}

/* ---------- error banner ---------- */
#errorBanner {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 9px 16px;
  font-size: 12.5px;
  background: rgba(120, 40, 40, 0.88);
  border: 1px solid rgba(255, 120, 120, 0.4);
  border-radius: 10px;
  backdrop-filter: blur(10px);
}

/* Cesium chrome adjustments */
.cesium-viewer-bottom { opacity: 0.6; }
.cesium-widget-credits { font-size: 9px !important; }

@media (max-width: 600px) {
  #panel { width: calc(100vw - 32px); }
  #popup { display: none !important; }
}
