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

:root {
  --ocean-deep: #0a1628;
  --ocean-mid: #0d2240;
  --ocean-surface: #1a4a6e;
  --teal-bright: #4fc3f7;
  --teal-dim: #1e88a8;
  --amber: #f59e0b;
  --red-warn: #ef4444;
  --green-ok: #22c55e;
  --yellow-warn: #eab308;
  --text-primary: #e2f4ff;
  --text-secondary: #7fb9d4;
  --text-muted: #4a7a94;
  --panel-bg: rgba(8, 20, 40, 0.92);
  --panel-border: rgba(79, 195, 247, 0.2);
  --hud-bg: rgba(4, 12, 28, 0.85);
  font-family: 'Noto Sans', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  color: var(--text-primary);
}

#main-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ─── Loading Screen ─── */
#loading-screen {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #0a1f3d 0%, #020d1a 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s ease;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

.tektite-logo { margin-bottom: 8px; }
.logo-emblem svg { filter: drop-shadow(0 0 16px #4fc3f7); animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.loading-title {
  font-family: 'Space Mono', monospace;
  font-size: clamp(20px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--teal-bright);
  text-shadow: 0 0 30px rgba(79,195,247,0.5);
}
.loading-subtitle {
  font-family: 'Space Mono', monospace;
  font-size: clamp(10px, 2vw, 14px);
  letter-spacing: 0.3em;
  color: var(--text-secondary);
}
.loading-location {
  font-size: 12px; color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-top: 4px;
}
.loading-bar-container {
  width: 280px; height: 2px;
  background: rgba(79,195,247,0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 16px;
}
.loading-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal-bright));
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--teal-bright);
}
.loading-status {
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.1em;
  min-height: 16px;
}
.loading-credits {
  font-size: 10px; color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-top: 20px;
  opacity: 0.6;
}

/* ─── HUD ─── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
#hud > * { pointer-events: all; }

/* Top Bar */
#top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--hud-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center;
  padding: 0 16px;
  backdrop-filter: blur(8px);
}

#mission-badge {
  display: flex; flex-direction: column;
  min-width: 90px;
}
.badge-label {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-muted);
  letter-spacing: 0.2em;
}
.badge-value {
  font-family: 'Space Mono', monospace;
  font-size: 13px; color: var(--teal-bright);
  font-weight: 700; letter-spacing: 0.1em;
}

#top-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 20px;
}
#top-center > div {
  display: flex; flex-direction: column; align-items: center;
}
.hud-label {
  font-family: 'Space Mono', monospace;
  font-size: 7px; color: var(--text-muted); letter-spacing: 0.2em;
}
.hud-value {
  font-family: 'Space Mono', monospace;
  font-size: 18px; color: var(--teal-bright);
  font-weight: 700; line-height: 1;
}
.hud-unit {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-secondary);
}
.hud-divider {
  width: 1px; height: 30px;
  background: var(--panel-border);
}

#top-right {
  display: flex; gap: 4px;
}
.hud-btn {
  background: rgba(79,195,247,0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.hud-btn:hover {
  background: rgba(79,195,247,0.15);
  color: var(--teal-bright);
  border-color: var(--teal-dim);
}

/* Scene Nav */
#scene-nav {
  position: absolute; top: 60px; left: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.scene-btn {
  background: var(--hud-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 10px; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.scene-btn:hover, .scene-btn.active {
  background: rgba(79,195,247,0.12);
  color: var(--teal-bright);
  border-color: var(--teal-dim);
}
.scene-btn.active { border-color: var(--teal-bright); }

/* Telemetry Panel */
#telemetry-panel {
  position: absolute; top: 60px; right: 16px;
  width: 190px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  backdrop-filter: blur(10px);
}
.telem-header {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-muted);
  letter-spacing: 0.25em;
  margin-bottom: 8px;
}
.telem-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0;
}
.telem-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  letter-spacing: 0.05em;
}
.telem-value {
  font-family: 'Space Mono', monospace;
  font-size: 10px; color: var(--teal-bright);
  font-weight: 700;
}
.telem-divider {
  height: 1px; background: var(--panel-border);
  margin: 8px 0;
}
.telem-indicator-row {
  display: flex; gap: 4px; margin-top: 8px;
}
.indicator {
  flex: 1; height: 20px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 7px; font-weight: 700;
  letter-spacing: 0.05em;
}
.indicator.green { background: rgba(34,197,94,0.2); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.indicator.yellow { background: rgba(234,179,8,0.2); color: #eab308; border: 1px solid rgba(234,179,8,0.3); }
.indicator.red { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }

/* Timeline */
#timeline-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--hud-bg);
  border-top: 1px solid var(--panel-border);
  padding: 10px 16px 12px;
  backdrop-filter: blur(8px);
}
#timeline-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 8px;
}
.timeline-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted); letter-spacing: 0.2em;
  white-space: nowrap;
}
#timeline-controls {
  display: flex; gap: 4px;
}
.tl-btn {
  background: rgba(79,195,247,0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: 4px;
  cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.tl-btn:hover, .tl-btn.active { background: rgba(79,195,247,0.18); color: var(--teal-bright); }
.compare-btn {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: #f59e0b;
  padding: 4px 10px; border-radius: 4px;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 0.1em;
  transition: all 0.2s;
  white-space: nowrap;
}
.compare-btn:hover { background: rgba(245,158,11,0.2); }
#timeline-event-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

#timeline-track {
  position: relative;
}
#timeline-markers {
  display: flex; justify-content: space-between;
  margin-bottom: 4px;
  padding: 0 4px;
}
.tl-marker {
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  gap: 2px;
}
.marker-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal-dim);
  border: 1px solid var(--teal-bright);
  transition: all 0.2s;
}
.marker-dot.highlight { background: var(--amber); border-color: #fbbf24; }
.marker-dot.today { background: var(--green-ok); border-color: #86efac; }
.tl-marker:hover .marker-dot { transform: scale(1.4); }
.marker-label {
  font-family: 'Space Mono', monospace;
  font-size: 7px; color: var(--text-muted);
  text-align: center; line-height: 1.3;
}

#timeline-scrubber {
  position: relative; width: 100%; height: 4px;
  background: rgba(79,195,247,0.1);
  border-radius: 2px; cursor: pointer;
}
#timeline-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal-bright));
  border-radius: 2px;
  width: 0%;
}
#timeline-thumb {
  position: absolute; top: 50%; transform: translate(-50%,-50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal-bright);
  box-shadow: 0 0 8px var(--teal-bright);
  left: 0%;
  cursor: grab;
  transition: transform 0.1s;
}
#timeline-thumb:active { cursor: grabbing; transform: translate(-50%,-50%) scale(1.2); }

/* Info Card */
#info-card {
  position: absolute; bottom: 100px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 340px; width: 90%;
  backdrop-filter: blur(12px);
}
#info-card-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px;
}
#info-card-content h3 {
  font-family: 'Space Mono', monospace;
  font-size: 13px; color: var(--teal-bright);
  margin-bottom: 6px;
}
#info-card-content p {
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.5;
}
#info-card-content .info-meta {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  margin-top: 8px; letter-spacing: 0.1em;
}

/* Nav Hint */
#nav-hint {
  position: absolute; bottom: 80px; right: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  letter-spacing: 0.05em;
}
#nav-hint span { color: var(--teal-bright); }

/* ─── Side Panels ─── */
.side-panel {
  position: fixed; top: 0; right: 0;
  width: 360px; max-width: 96vw; height: 100vh;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  z-index: 200;
  display: flex; flex-direction: column;
  backdrop-filter: blur(16px);
  transform: translateX(0);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.side-panel.hidden { display: none; }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--teal-bright);
  letter-spacing: 0.15em;
  flex-shrink: 0;
}
.panel-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 20px;
  line-height: 1; transition: color 0.2s;
}
.panel-close:hover { color: var(--teal-bright); }

/* Crew Panel */
#crew-tabs {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.crew-tab {
  flex: 1; padding: 10px;
  background: none; border: none;
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  font-size: 10px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.crew-tab.active { color: var(--teal-bright); border-bottom-color: var(--teal-bright); }

#crew-list {
  overflow-y: auto; flex: 1;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.crew-card {
  background: rgba(79,195,247,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 12px;
  cursor: pointer; transition: all 0.2s;
  display: flex; gap: 12px; align-items: flex-start;
}
.crew-card:hover { background: rgba(79,195,247,0.1); border-color: var(--teal-dim); }
.crew-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--ocean-surface);
  border: 2px solid var(--teal-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.crew-info h4 {
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--text-primary);
  margin-bottom: 2px;
}
.crew-info .crew-role {
  font-size: 10px; color: var(--teal-dim);
  margin-bottom: 4px;
}
.crew-info .crew-dates {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
}

/* Archive Panel */
#archive-search-bar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
#archive-search {
  width: 100%;
  background: rgba(79,195,247,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
#archive-search:focus { border-color: var(--teal-dim); }
#archive-search::placeholder { color: var(--text-muted); }

#archive-categories {
  display: flex; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0; flex-wrap: wrap;
}
.arch-cat {
  padding: 4px 10px; border-radius: 20px;
  background: rgba(79,195,247,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  font-size: 9px; cursor: pointer;
  transition: all 0.2s;
}
.arch-cat.active, .arch-cat:hover { background: rgba(79,195,247,0.15); color: var(--teal-bright); border-color: var(--teal-dim); }

#archive-list {
  overflow-y: auto; flex: 1;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.archive-item {
  background: rgba(79,195,247,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 10px 12px;
  cursor: pointer; transition: all 0.2s;
}
.archive-item:hover { background: rgba(79,195,247,0.1); border-color: var(--teal-dim); }
.archive-item-type {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-muted);
  letter-spacing: 0.15em; margin-bottom: 3px;
}
.archive-item h4 {
  font-size: 12px; color: var(--text-primary);
  margin-bottom: 3px;
}
.archive-item p { font-size: 10px; color: var(--text-secondary); line-height: 1.4; }
.archive-item-date {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-muted);
  margin-top: 4px;
}

/* NASA Panel */
#nasa-timeline-content {
  overflow-y: auto; flex: 1;
  padding: 16px 12px;
}
.nasa-event {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--panel-border);
  position: relative;
}
.nasa-event::before {
  content: ''; position: absolute;
  left: 18px; top: 0; bottom: 0;
  width: 1px; background: var(--panel-border);
}
.nasa-event:last-child::before { display: none; }
.nasa-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--teal-dim); border: 2px solid var(--teal-bright);
  flex-shrink: 0; margin-top: 3px; position: relative; z-index: 1;
}
.nasa-dot.highlight { background: var(--amber); border-color: #fbbf24; }
.nasa-event-body {}
.nasa-event-year {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--teal-bright); margin-bottom: 2px;
}
.nasa-event-title {
  font-size: 12px; color: var(--text-primary); font-weight: 600;
  margin-bottom: 3px;
}
.nasa-event-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }

/* Menu */
#menu-modes { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.menu-mode-card {
  background: rgba(79,195,247,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 12px 14px;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px;
}
.menu-mode-card:hover, .menu-mode-card.active {
  background: rgba(79,195,247,0.1);
  border-color: var(--teal-dim);
}
.menu-mode-card.active { border-color: var(--teal-bright); }
.mode-icon { font-size: 22px; flex-shrink: 0; }
.mode-title {
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--text-primary); margin-bottom: 2px;
}
.mode-desc { font-size: 10px; color: var(--text-secondary); line-height: 1.3; }
.menu-divider { height: 1px; background: var(--panel-border); margin: 4px 0; }
.menu-settings { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer;
}
.setting-row input[type="checkbox"] { accent-color: var(--teal-bright); width: 16px; height: 16px; }
.menu-footer { padding: 12px; }
.menu-footer small { font-size: 10px; color: var(--text-muted); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  max-width: 500px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 22px;
}
.modal-close:hover { color: var(--teal-bright); }

/* Aquanaut Modal */
#aquanaut-content .aq-header {
  display: flex; gap: 16px; align-items: flex-start;
  margin-bottom: 16px; padding-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
}
.aq-avatar-lg {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ocean-surface);
  border: 3px solid var(--teal-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.aq-meta h2 {
  font-family: 'Space Mono', monospace;
  font-size: 15px; color: var(--teal-bright);
  margin-bottom: 4px;
}
.aq-meta .aq-role { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.aq-meta .aq-dates {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  letter-spacing: 0.05em;
}
#aquanaut-content section { margin-bottom: 14px; }
#aquanaut-content section h3 {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted);
  letter-spacing: 0.2em; margin-bottom: 6px;
}
#aquanaut-content section p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.aq-discoveries { display: flex; flex-wrap: wrap; gap: 4px; }
.aq-discovery-tag {
  background: rgba(79,195,247,0.1);
  border: 1px solid var(--panel-border);
  border-radius: 20px; padding: 3px 8px;
  font-size: 10px; color: var(--text-secondary);
}
.aq-quote {
  background: rgba(79,195,247,0.06);
  border-left: 3px solid var(--teal-dim);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}

/* Notification */
#notification {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--teal-dim);
  border-radius: 8px; padding: 10px 20px;
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--teal-bright);
  z-index: 400;
  animation: notif-in 0.3s ease;
  white-space: nowrap;
}
@keyframes notif-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Compare Overlay */
#compare-overlay {
  position: fixed; inset: 0; z-index: 150; pointer-events: none;
}
#compare-overlay.hidden { display: none; }
#compare-labels {
  position: absolute; inset: 0;
  display: flex; align-items: stretch;
}
#compare-label-left {
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 70px;
  width: 50%;
  font-family: 'Space Mono', monospace;
  font-size: 22px; font-weight: 700;
  color: rgba(255,200,80,0.8);
  text-shadow: 0 0 20px rgba(255,150,0,0.5);
}
#compare-label-right {
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 70px;
  width: 50%;
  font-family: 'Space Mono', monospace;
  font-size: 22px; font-weight: 700;
  color: rgba(80,200,255,0.8);
  text-shadow: 0 0 20px rgba(0,150,255,0.5);
}
#compare-divider {
  position: absolute; top: 52px; bottom: 68px;
  left: 50%; width: 2px;
  background: rgba(255,255,255,0.5);
  box-shadow: 0 0 10px rgba(255,255,255,0.3);
  pointer-events: all;
}
#compare-slider-handle {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 36px; height: 36px;
  background: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: ew-resize;
  pointer-events: all;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  font-size: 14px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-dim); }

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  /* Top bar compact */
  #top-bar { height: 46px; padding: 0 8px; }
  #mission-badge { min-width: 70px; }
  .badge-value { font-size: 11px; }
  #top-center { gap: 8px; }
  .hud-value { font-size: 14px; }
  .hud-divider { height: 22px; }
  .hud-btn { width: 32px; height: 32px; }

  #cam-toggle-btn { top: 100px; }
  #camera-panel { top: 100px; }

  /* Scene nav becomes horizontal strip */
  #scene-nav {
    flex-direction: row; flex-wrap: nowrap;
    top: 46px; left: 0; right: 0;
    padding: 4px 6px; gap: 4px;
    background: var(--hud-bg);
    border-bottom: 1px solid var(--panel-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .scene-btn { font-size: 9px; padding: 5px 8px; white-space: nowrap; flex-shrink: 0; }

  /* Hide telemetry on small screens */
  #telemetry-panel { display: none; }

  /* Timeline compact */
  #timeline-panel { padding: 6px 10px 8px; }
  #timeline-header { gap: 8px; margin-bottom: 6px; }
  #timeline-markers { display: none; }
  #timeline-event-label { font-size: 8px; }
  #year-compare-toggle { display: none; }

  /* Nav hint hidden on mobile */
  #nav-hint { display: none; }

  /* Info card full width */
  #info-card { width: 95%; bottom: 85px; }

  /* Side panels full width */
  .side-panel { width: 100%; border-left: none; border-top: 1px solid var(--panel-border); }

  /* Notification */
  #notification { font-size: 10px; padding: 8px 14px; white-space: normal; text-align: center; max-width: 85vw; }

  /* Depth gauge */
  #depth-gauge { display: none; }

  /* Species ticker */
  #species-ticker { left: 10px; bottom: 80px; font-size: 8px; max-width: 70vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 480px) {
  .hud-value { font-size: 13px; }
  #top-center { gap: 6px; }
  .badge-value { font-size: 10px; }
  #top-right { gap: 2px; }
  .hud-btn { width: 28px; height: 28px; }
  .hud-btn svg { width: 14px; height: 14px; }
  .timeline-label { display: none; }
  #timeline-controls { gap: 2px; }
  .tl-btn { width: 24px; height: 24px; font-size: 10px; }

  /* Modal adjustments */
  .modal-inner { padding: 16px; }
  .welcome-modal-inner { padding: 0; border-radius: 10px; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  #telemetry-panel { width: 165px; }
  .telem-label { font-size: 8px; }
  .telem-value { font-size: 9px; }
}

/* Species indicator */
#species-ticker {
  position: absolute;
  bottom: 85px;
  left: 80px;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--teal-bright);
  opacity: 0.75;
  pointer-events: none;
  transition: opacity 1s;
}
#species-ticker.fade { opacity: 0; }

/* ─── Welcome Modal ─── */
.welcome-modal-inner {
  max-width: 600px !important;
  padding: 0 !important;
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 90vh;
}

.welcome-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.welcome-logo { flex-shrink: 0; }
.welcome-logo svg { filter: drop-shadow(0 0 10px #4fc3f7); }
.welcome-title {
  font-family: 'Space Mono', monospace;
  font-size: clamp(14px, 3vw, 20px);
  font-weight: 700; letter-spacing: 0.15em;
  color: var(--teal-bright);
}
.welcome-sub {
  font-family: 'Space Mono', monospace;
  font-size: clamp(8px, 1.5vw, 10px);
  color: var(--text-muted); letter-spacing: 0.1em;
  margin-top: 3px;
}

.welcome-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--panel-border);
}
.welcome-tab {
  flex: 1; padding: 10px 4px;
  background: none; border: none;
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  font-size: clamp(8px, 1.8vw, 10px);
  letter-spacing: 0.1em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.welcome-tab.active { color: var(--teal-bright); border-bottom-color: var(--teal-bright); }
.welcome-tab:hover:not(.active) { color: var(--text-secondary); }

.welcome-body {
  flex: 1; overflow-y: auto;
  min-height: 0;
}
.welcome-pane { display: none; padding: 20px 24px; }
.welcome-pane.active { display: block; }

.pane-title {
  font-family: 'Space Mono', monospace;
  font-size: 13px; color: var(--teal-bright);
  margin-bottom: 12px; letter-spacing: 0.05em;
}
.pane-lead {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 16px;
}

/* Story cards */
.story-cards { display: flex; flex-direction: column; gap: 10px; }
.story-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(79,195,247,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 12px;
}
.story-card-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.story-card-title {
  font-family: 'Space Mono', monospace;
  font-size: 10px; color: var(--teal-bright);
  margin-bottom: 4px; letter-spacing: 0.05em;
}
.story-card-text { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }

/* Welcome Timeline */
.wtl-list { display: flex; flex-direction: column; gap: 0; }
.wtl-item {
  display: grid;
  grid-template-columns: 12px 90px 1fr;
  gap: 10px; align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(79,195,247,0.08);
}
.wtl-item:last-child { border-bottom: none; }
.wtl-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--teal-dim);
  border: 2px solid var(--teal-bright);
  margin-top: 3px; flex-shrink: 0;
}
.wtl-dot.amber { background: var(--amber); border-color: #fbbf24; }
.wtl-dot.green { background: var(--green-ok); border-color: #86efac; }
.wtl-date {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--teal-bright);
  padding-top: 2px; line-height: 1.4;
}
.wtl-text { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.wtl-item.highlight .wtl-text { color: var(--text-primary); }

/* Bios */
.wbio-list { display: flex; flex-direction: column; gap: 10px; }
.wbio-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(79,195,247,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 12px;
}
.wbio-emoji { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.wbio-name {
  font-family: 'Space Mono', monospace;
  font-size: 10px; color: var(--text-primary); font-weight: 700;
  margin-bottom: 2px;
}
.wbio-role { font-size: 9px; color: var(--teal-dim); margin-bottom: 5px; }
.wbio-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }

/* About */
.about-section { margin-bottom: 18px; }
.about-section h3 {
  font-family: 'Space Mono', monospace;
  font-size: 10px; color: var(--teal-bright);
  letter-spacing: 0.1em; margin-bottom: 6px;
}
.about-section p {
  font-size: 11px; color: var(--text-secondary);
  line-height: 1.6;
}
.nav-tips { padding-left: 16px; }
.nav-tips li {
  font-size: 11px; color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 4px;
}
.nav-tips li strong { color: var(--text-primary); }

/* Welcome footer */
.welcome-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
  display: flex; justify-content: center;
}
.enter-btn {
  background: rgba(79,195,247,0.12);
  border: 1px solid var(--teal-bright);
  color: var(--teal-bright);
  font-family: 'Space Mono', monospace;
  font-size: 11px; letter-spacing: 0.2em;
  padding: 10px 28px; border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.enter-btn:hover { background: rgba(79,195,247,0.22); box-shadow: 0 0 16px rgba(79,195,247,0.2); }

/* ─── Depth Gauge ─── */
/* Camera POV Panel */
#camera-panel {
  position: absolute; top: 60px; left: 16px;
  display: none;
  flex-direction: column; gap: 4px;
  z-index: 101;
}
#camera-panel.show { display: flex; }

.cam-btn {
  background: var(--hud-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.cam-btn:hover, .cam-btn.active {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border-color: rgba(245,158,11,0.5);
}
.cam-btn.active { border-color: #f59e0b; }

#cam-toggle-btn {
  position: absolute; top: 60px; left: 16px;
  z-index: 102;
}

/* Depth gauge */
#depth-gauge {
  position: absolute;
  left: 16px;
  bottom: 90px;
  width: 8px;
  height: 100px;
  background: rgba(79,195,247,0.1);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
}
#depth-gauge-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, var(--teal-bright), var(--teal-dim));
  border-radius: 4px;
  transition: height 1s ease;
}