/* ── Earth · Digital Twin ─────────────────────────────────────────── */
:root {
  --bg: #04070f;
  --panel: rgba(10, 18, 32, .72);
  --panel-border: rgba(120, 180, 255, .18);
  --text: #dbe7ff;
  --dim: #8ba3c7;
  --accent: #53d1ff;
  --accent-2: #ffd166;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#globe { position: fixed; inset: 0; }
#globe canvas { display: block; cursor: grab; }
#globe canvas.dragging { cursor: grabbing; }
#globe canvas.on-land { cursor: crosshair; }
#globe canvas.on-city { cursor: pointer; }

/* ── Control panel ────────────────────────────────────────────────── */
#panel {
  position: fixed; top: 16px; left: 16px; z-index: 30;
  width: 228px; padding: 14px 16px 12px;
  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, .45);
  user-select: none;
}
#panel h1 {
  margin: 0 0 10px; font-size: 16px; letter-spacing: .18em; color: #fff;
}
#panel h1 span { font-size: 11px; letter-spacing: .08em; color: var(--accent); }

.row { margin: 8px 0; }

.seg { display: flex; gap: 4px; background: rgba(255,255,255,.06); border-radius: 9px; padding: 3px; }
.seg button {
  flex: 1; padding: 5px 0; font-size: 12px; color: var(--dim);
  background: transparent; border: 0; border-radius: 7px; cursor: pointer;
  transition: background .18s, color .18s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(83, 209, 255, .22); color: #fff; }

.toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--text); }
.toggle input { display: none; }
.toggle .sw {
  width: 30px; height: 17px; border-radius: 17px; background: rgba(255,255,255,.14);
  position: relative; transition: background .18s; flex: none;
}
.toggle .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: #aab8d0; transition: transform .18s, background .18s;
}
.toggle input:checked + .sw { background: rgba(83, 209, 255, .55); }
.toggle input:checked + .sw::after { transform: translateX(13px); background: #fff; }

.hint { margin: 12px 0 0; font-size: 11px; color: var(--dim); }
.hint b { color: var(--accent-2); }

/* ── Hover popup ──────────────────────────────────────────────────── */
#popup {
  position: fixed; z-index: 40; pointer-events: none;
  min-width: 220px; max-width: 280px; padding: 11px 13px;
  background: rgba(8, 14, 26, .92); border: 1px solid rgba(83, 209, 255, .35);
  border-radius: 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .55);
  transition: opacity .12s;
}
#popup.hidden { opacity: 0; visibility: hidden; }
#popup .p-city {
  font-size: 12px; color: var(--accent-2); margin-bottom: 6px;
  padding-bottom: 6px; border-bottom: 1px dashed rgba(255, 209, 102, .3);
}
#popup .p-title { font-size: 15px; font-weight: 700; color: #fff; margin-bottom: 7px; }
#popup .p-title .flag { margin-right: 7px; }
#popup table { width: 100%; border-collapse: collapse; font-size: 12px; }
#popup td { padding: 2px 0; color: var(--text); }
#popup td:first-child { color: var(--dim); padding-right: 12px; white-space: nowrap; }
#popup td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#popup .p-dive { margin-top: 7px; font-size: 10.5px; color: var(--accent); opacity: .8; }

/* ── City labels ──────────────────────────────────────────────────── */
#labels { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.city-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  font-size: 11px; color: #eaf3ff; white-space: nowrap;
  padding: 1px 5px 1px 11px;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, .8);
  transform: translate(-4px, -50%);
  transition: color .15s;
}
.city-label::before {
  content: ""; position: absolute; left: 2px; top: 50%; margin-top: -2.5px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 6px rgba(255, 209, 102, .9);
}
.city-label:hover { color: var(--accent-2); }

/* ── Street map mode ──────────────────────────────────────────────── */
#map-wrap {
  position: fixed; inset: 0; z-index: 50;
  opacity: 0; visibility: hidden; transition: opacity .5s ease;
  background: #0a0f18;
}
#map-wrap.active { opacity: 1; visibility: visible; }
#map { position: absolute; inset: 0; background: #0a0f18; }
#btn-orbit {
  position: absolute; top: 16px; left: 16px; z-index: 1000;
  padding: 9px 16px; font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(10, 18, 32, .85); border: 1px solid var(--panel-border);
  border-radius: 10px; cursor: pointer; backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .5);
}
#btn-orbit:hover { background: rgba(30, 48, 76, .9); }

/* ── Credits ──────────────────────────────────────────────────────── */
#credits {
  position: fixed; right: 10px; bottom: 8px; z-index: 25;
  font-size: 10px; color: rgba(139, 163, 199, .75);
  background: rgba(4, 7, 15, .5); padding: 3px 8px; border-radius: 7px;
}
#credits a { color: rgba(139, 163, 199, .95); }

/* ── Loading screen ───────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0a1428 0%, var(--bg) 70%);
  transition: opacity .7s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.load-box { text-align: center; width: min(320px, 80vw); }
.load-title { font-size: 34px; font-weight: 800; letter-spacing: .42em; color: #fff; text-indent: .42em; }
.load-sub { font-size: 11px; letter-spacing: .22em; color: var(--accent); margin: 6px 0 26px; }
.load-bar {
  height: 3px; background: rgba(255, 255, 255, .1); border-radius: 3px; overflow: hidden;
}
#load-fill {
  height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, #2f7cff, var(--accent));
  transition: width .25s ease;
}
#load-msg { margin-top: 12px; font-size: 11px; color: var(--dim); min-height: 15px; }
#loading.error #load-msg { color: #ff8080; }

.nojs { position: fixed; inset: 0; display: grid; place-items: center; z-index: 200; background: var(--bg); }

/* ── Small screens ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #panel { width: 200px; padding: 10px 12px 8px; top: 10px; left: 10px; }
  #panel h1 { font-size: 14px; }
  .hint { display: none; }
  #credits { font-size: 9px; }
}
