/* ═══════════════════════════════════════════════
   ASTEROID ATLAS — DARK SPACE THEME
   ═══════════════════════════════════════════════ */
:root {
  --bg: #000005;
  --panel-bg: rgba(5, 8, 20, 0.92);
  --border: rgba(80, 140, 255, 0.25);
  --accent: #3b82f6;
  --accent2: #f97316;
  --text: #c8d8ff;
  --dim: #5a6a8a;
  --red: #ef4444;
  --green: #22c55e;
  --yellow: #eab308;
  --panel-w: 320px;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ── HUD BUTTONS ── */
.hud-btn {
  background: rgba(10, 20, 50, 0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.hud-btn:hover { background: rgba(59, 130, 246, 0.25); border-color: var(--accent); }
.hud-btn.active { background: rgba(59, 130, 246, 0.35); border-color: var(--accent); color: #fff; }
.hud-btn.accent { background: rgba(249, 115, 22, 0.2); border-color: var(--accent2); color: #fcd7a5; }
.hud-btn.accent:hover { background: rgba(249, 115, 22, 0.4); }
.hud-btn.small { font-size: 10px; padding: 3px 7px; }
.hud-btn.full-width { width: 100%; margin-top: 8px; font-size: 13px; padding: 8px; }

/* ── TOP HUD ── */
#hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(0,0,10,0.95) 0%, transparent 100%);
  z-index: 100;
  flex-wrap: wrap;
}

#logo {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.15em;
  color: #7eb8ff;
  text-shadow: 0 0 20px #3b82f6;
  flex-shrink: 0;
}

#time-hud {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  flex-wrap: wrap;
}

#sim-date {
  font-size: 12px;
  color: #aac4ff;
  letter-spacing: 0.08em;
  margin-left: 6px;
  min-width: 90px;
}

#top-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* ── DATE SLIDER ── */
#date-slider-wrap {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,5,20,0.8);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  z-index: 100;
}

.slider-label { font-size: 10px; color: var(--dim); }

#date-slider {
  width: min(400px, 50vw);
  -webkit-appearance: none;
  height: 3px;
  background: linear-gradient(90deg, #1a3a8a, #3b82f6);
  border-radius: 2px;
  outline: none;
}
#date-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent);
}

/* ── CAMERA HUD ── */
#hud-camera {
  position: fixed;
  bottom: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  align-items: flex-end;
}

#body-lock-select {
  background: rgba(10, 20, 50, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  width: 140px;
}

/* ── LAUNCHER BUTTON ── */
#hud-launcher-btn {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 100;
}
#hud-launcher-btn .hud-btn {
  font-size: 13px;
  padding: 8px 16px;
  animation: pulse-orange 3s infinite;
}
@keyframes pulse-orange {
  0%, 100% { box-shadow: 0 0 8px rgba(249,115,22,0.3); }
  50% { box-shadow: 0 0 20px rgba(249,115,22,0.7); }
}

/* ── PANELS ── */
.panel {
  position: fixed;
  top: 50px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  overflow: hidden;
}

.panel.hidden { display: none; }

#panel-launcher { left: 14px; width: var(--panel-w); }
#panel-results  { left: 14px; width: var(--panel-w); }
#panel-compare  { right: 14px; width: min(600px, 95vw); }
#panel-tour     { right: 14px; width: 300px; }
#panel-quiz     { left: 50%; transform: translateX(-50%); width: min(400px, 95vw); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: bold;
  color: #a8c4ff;
  flex-shrink: 0;
}

.panel-close {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.panel-close:hover { color: var(--text); }

.panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
}

.panel-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 3px;
  background: linear-gradient(90deg, #1a3a8a, #3b82f6);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

input[type="text"] {
  width: 100%;
  background: rgba(0,10,30,0.8);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }

select {
  width: 100%;
  background: rgba(0,10,30,0.8);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
}

/* ── COMPOSITION BUTTONS ── */
.btn-group { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.comp-btn {
  background: rgba(10, 20, 50, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  line-height: 1.4;
}
.comp-btn small { color: var(--dim); font-size: 9px; }
.comp-btn.active { border-color: var(--accent); background: rgba(59,130,246,0.2); }
.comp-btn:hover { border-color: var(--accent); }

/* ── DROPDOWN ── */
.dropdown {
  position: absolute;
  background: rgba(5,10,30,0.97);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 300;
  width: 100%;
  left: 0;
}
.dropdown.hidden { display: none; }

#city-group { position: relative; }

.dropdown-item {
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid rgba(80,140,255,0.08);
}
.dropdown-item:hover { background: rgba(59,130,246,0.2); }

.small-text { font-size: 10px; color: var(--dim); margin-top: 3px; }

/* ── COMPARE ROW ── */
.compare-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
#compare-count { font-size: 10px; color: var(--dim); }

/* ── TOOLTIP ── */
#tooltip {
  position: fixed;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  z-index: 300;
  pointer-events: auto;
  min-width: 180px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}
#tooltip.hidden { display: none; }

#tooltip-name {
  font-size: 14px;
  font-weight: bold;
  color: #a8c4ff;
  margin-bottom: 6px;
}
#tooltip-body { font-size: 11px; line-height: 1.7; color: var(--text); }
.tooltip-row { display: flex; justify-content: space-between; gap: 20px; }
.tooltip-val { color: #7eb8ff; }

/* ── FUN FACT ── */
#fun-fact {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,5,25,0.85);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 11px;
  color: var(--dim);
  z-index: 90;
  text-align: center;
  max-width: min(500px, 90vw);
  transition: opacity 1s;
  pointer-events: none;
}

/* ── RESULTS ── */
.result-section { margin-bottom: 12px; }
.result-section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.result-val { color: #7eb8ff; font-weight: bold; }
.result-val.danger { color: var(--red); }
.result-val.warn { color: var(--yellow); }
.result-val.ok { color: var(--green); }

/* ── IMPACT RINGS LEGEND ── */
.ring-legend { margin-top: 8px; }
.ring-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  padding: 2px 0;
}
.ring-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── TOUR ── */
#tour-list { display: flex; flex-direction: column; gap: 6px; }
.tour-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.tour-item:hover { background: rgba(59,130,246,0.1); }
.tour-icon { font-size: 18px; flex-shrink: 0; }
.tour-info h4 { font-size: 12px; color: #a8c4ff; margin-bottom: 2px; }
.tour-info p { font-size: 10px; color: var(--dim); }

#tour-narrator {
  padding: 10px;
  background: rgba(0,10,30,0.5);
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
#tour-narrator.hidden { display: none; }
#tour-text {
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 8px;
  min-height: 60px;
}
.tour-controls { display: flex; gap: 6px; }

/* ── QUIZ ── */
#quiz-body { min-height: 200px; }
.quiz-question { font-size: 14px; color: #a8c4ff; margin-bottom: 14px; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt {
  background: rgba(10,20,50,0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.quiz-opt:hover { border-color: var(--accent); background: rgba(59,130,246,0.15); }
.quiz-opt.correct { border-color: var(--green); background: rgba(34,197,94,0.15); color: var(--green); }
.quiz-opt.wrong   { border-color: var(--red); background: rgba(239,68,68,0.15); color: var(--red); }

.quiz-progress { font-size: 10px; color: var(--dim); margin-bottom: 10px; }
.quiz-score { text-align: center; padding: 20px; }
.quiz-score .score-big { font-size: 48px; color: var(--accent); }
.quiz-score p { font-size: 12px; color: var(--dim); margin-top: 8px; }

/* ── COMPARE PANEL ── */
#compare-body { display: flex; gap: 12px; overflow-x: auto; }
.compare-col {
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.compare-col h3 { font-size: 12px; color: #a8c4ff; margin-bottom: 8px; }
.compare-row-item { font-size: 11px; border-bottom: 1px solid rgba(80,140,255,0.1); padding: 3px 0; display: flex; flex-direction: column; }
.compare-label { color: var(--dim); font-size: 9px; text-transform: uppercase; }
.compare-val { color: #7eb8ff; }

/* ── MAP OVERLAY ── */
#map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,10,0.85);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
#map-overlay.hidden { display: none; }
#map-canvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 95vw;
  max-height: 80vh;
}

/* ── LOADING ── */
#loading {
  position: fixed;
  inset: 0;
  background: #000008;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s;
}
#loading.fade-out { opacity: 0; pointer-events: none; }
#loading.hidden { display: none; }

#loading-inner { text-align: center; width: 300px; }
#loading-logo {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 0.2em;
  color: #7eb8ff;
  text-shadow: 0 0 30px #3b82f6;
  margin-bottom: 30px;
}
#loading-bar-wrap {
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 10px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
#loading-bar {
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  border-radius: 10px;
  width: 0%;
  transition: width 0.3s;
  box-shadow: 0 0 10px #3b82f6;
}
#loading-text { font-size: 11px; color: var(--dim); letter-spacing: 0.08em; }

/* ── KB HINT ── */
#kb-hint {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: rgba(90,106,138,0.6);
  pointer-events: none;
  z-index: 90;
  letter-spacing: 0.05em;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── MOBILE ── */
@media (max-width: 600px) {
  #hud-top { padding: 6px 10px; }
  #logo { font-size: 12px; }
  #panel-launcher, #panel-results { left: 0; right: 0; width: 100%; bottom: 0; top: auto; max-height: 65vh; border-radius: var(--radius) var(--radius) 0 0; }
  #panel-compare, #panel-tour { left: 0; right: 0; width: 100%; top: auto; bottom: 0; max-height: 65vh; border-radius: var(--radius) var(--radius) 0 0; }
  #date-slider-wrap { bottom: 56px; }
  #hud-launcher-btn { bottom: 56px; }
  #hud-camera { bottom: 56px; }
  .panel { top: auto; }
}
