:root {
  --bg-deep: #090c0a;
  --panel-bg: rgba(13, 17, 15, 0.76);
  --panel-border: rgba(212, 163, 89, 0.25);
  --dawn-gold: #d4a359;
  --dawn-bright: #f2cf94;
  --moss-muted: #93a697;
  --gpr-cyan: #4fd1c5;
  --amber-warn: #f6ad55;
  --text-main: #f2f4f0;
  --text-muted: #a6b2a8;
  --text-dim: #6e7a70;
  --radius: 12px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at center, #1b241d 0%, #090c0a 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.65s ease, visibility 0.65s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.loader-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(212, 163, 89, 0.22);
  border-top-color: var(--dawn-gold);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-family: 'Cinzel', 'Noto Sans SC', serif;
  letter-spacing: 2px;
  font-size: 16px;
  color: var(--dawn-bright);
}

.loader-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Top HUD Header */
.hud-header {
  position: fixed;
  top: 16px;
  left: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11.5px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.back-link:hover {
  color: var(--dawn-bright);
  border-color: rgba(212, 163, 89, 0.45);
  background: rgba(212, 163, 89, 0.12);
}

.brand-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(212, 163, 89, 0.14);
  border: 1px solid rgba(212, 163, 89, 0.42);
  color: var(--dawn-bright);
  white-space: nowrap;
}

.brand-title {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.brand-title .en-sub {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--dawn-gold);
}

.brand-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-meta .dot {
  color: var(--text-dim);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--gpr-cyan);
  font-size: 11px;
  white-space: nowrap;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gpr-cyan);
  box-shadow: 0 0 8px var(--gpr-cyan);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: rgba(212, 163, 89, 0.45);
  background: rgba(212, 163, 89, 0.12);
}

.icon-btn.active {
  border-color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.2);
  color: var(--dawn-bright);
}

.icon-btn.cyan-active.active {
  border-color: var(--gpr-cyan);
  background: rgba(79, 209, 197, 0.18);
  color: #a7f3ec;
}

.btn-icon {
  font-size: 13px;
}

/* Side HUD Panels */
.hud-panel {
  position: fixed;
  top: 86px;
  bottom: 58px;
  width: 286px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 163, 89, 0.3) transparent;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.left-panel {
  left: 18px;
}

.right-panel {
  right: 18px;
}

.panel-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 13px 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.14);
  border: 1px solid rgba(212, 163, 89, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.section-header h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  flex: 1;
  white-space: nowrap;
}

.mono-readout {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--dawn-bright);
}

.status-ok {
  font-size: 10.5px;
  color: var(--gpr-cyan);
  background: rgba(79, 209, 197, 0.12);
  border: 1px solid rgba(79, 209, 197, 0.35);
  padding: 1px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

/* Mode Selector */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.mode-card:hover {
  border-color: rgba(212, 163, 89, 0.45);
  background: rgba(212, 163, 89, 0.09);
}

.mode-card.active {
  border-color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.18);
  box-shadow: 0 0 12px rgba(212, 163, 89, 0.15);
}

.mode-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
}

.swatch-sarsen {
  background: linear-gradient(135deg, #9b998e, #555952);
}
.swatch-lidar {
  background: radial-gradient(circle, #68f7eb 15%, #164e63 75%);
}
.swatch-wire {
  background: repeating-linear-gradient(45deg, #2d3748, #2d3748 3px, #7dd3fc 3px, #7dd3fc 4px);
}
.swatch-heat {
  background: linear-gradient(135deg, #3b82f6, #eab308, #ef4444);
}

.mode-name {
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.mode-desc {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.heatmap-legend {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.legend-bar {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, #2563eb 0%, #22c55e 35%, #facc15 68%, #ef4444 100%);
}

/* Era & GPR Subsurface Controls */
.segment-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 9px;
}

.seg-btn {
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.seg-btn:hover {
  color: var(--text-main);
  border-color: rgba(212, 163, 89, 0.45);
}

.seg-btn.active {
  color: var(--dawn-bright);
  border-color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.18);
}

.toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(79, 209, 197, 0.26);
  background: rgba(79, 209, 197, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-bar:hover {
  background: rgba(79, 209, 197, 0.12);
}

.toggle-bar.active {
  border-color: var(--gpr-cyan);
  background: rgba(79, 209, 197, 0.16);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-main);
}

.toggle-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.toggle-pill {
  width: 34px;
  height: 18px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-pill::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle-bar.active .toggle-pill {
  background: var(--gpr-cyan);
}

.toggle-bar.active .toggle-pill::after {
  transform: translateX(16px);
}

/* Time Slider */
.slider-wrap input[type="range"] {
  width: 100%;
  accent-color: var(--dawn-gold);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.quick-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.chip-btn {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chip-btn:hover {
  color: var(--text-main);
  border-color: rgba(212, 163, 89, 0.45);
}

.chip-btn.active {
  color: var(--dawn-bright);
  border-color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.18);
}

.night-chip.active {
  color: #a7f3ec;
  border-color: #4fd1c5;
  background: rgba(79, 209, 197, 0.18);
}

/* Camera Presets */
.camera-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cam-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7.5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.cam-btn:hover {
  border-color: rgba(212, 163, 89, 0.45);
  background: rgba(212, 163, 89, 0.1);
}

.cam-btn.active {
  border-color: var(--dawn-gold);
  background: rgba(212, 163, 89, 0.2);
  color: var(--dawn-bright);
}

.cam-index {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--dawn-gold);
  width: 22px;
}

/* Right Panel Metrics & Telemetry */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 8px 10px;
}

.metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.metric-val {
  margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--dawn-bright);
}

.metric-val.sm {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px;
  font-weight: 500;
}

.metric-val .unit {
  font-size: 10.5px;
  color: var(--text-muted);
}

.sensor-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sensor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
}

.sensor-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sensor-name {
  color: var(--text-muted);
}

.sensor-val.mono {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.sensor-val.warn {
  color: var(--amber-warn);
}

.sensor-val.tech {
  color: var(--gpr-cyan);
}

/* Hotspot Detail Card */
.detail-section {
  flex: 1;
}

.detail-en {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dawn-gold);
  margin-bottom: 8px;
}

.detail-desc {
  font-size: 12px;
  line-height: 1.65;
  color: #dde3dc;
  margin-bottom: 11px;
}

.detail-specs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.spec-item span {
  color: var(--text-muted);
  white-space: nowrap;
}

.spec-item strong {
  color: var(--dawn-bright);
  font-weight: 500;
  text-align: right;
}

/* 3D Projected Hotspots */
#hotspot-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.hotspot-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 5px;
  border-radius: 99px;
  background: rgba(13, 17, 15, 0.86);
  border: 1px solid rgba(212, 163, 89, 0.72);
  color: var(--text-main);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.25s ease;
}

.hotspot-pin.gpr-pin {
  border-color: rgba(79, 209, 197, 0.78);
}

.hotspot-pin.gpr-pin .hotspot-num {
  background: var(--gpr-cyan);
  color: #062524;
}

.hotspot-pin:hover,
.hotspot-pin.active {
  background: rgba(176, 128, 56, 0.94);
  border-color: #fff8e6;
  transform: translate(-50%, -50%) scale(1.08);
  z-index: 12;
}

.hotspot-pin.gpr-pin:hover,
.hotspot-pin.gpr-pin.active {
  background: rgba(24, 142, 134, 0.94);
  border-color: #d6fffa;
}

.hotspot-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--dawn-gold);
  color: #1c1509;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hotspot-pin.active .hotspot-num {
  background: #fff;
  color: #5c4010;
}

/* Bottom Footer */
.hud-footer {
  position: fixed;
  bottom: 12px;
  left: 18px;
  right: 18px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: rgba(13, 17, 15, 0.7);
  border: 1px solid rgba(212, 163, 89, 0.18);
  border-radius: 9px;
  backdrop-filter: blur(10px);
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.controls-hint {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--dawn-bright);
  margin-right: 4px;
}

.footer-credit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-dim);
}

/* Immersive Mode */
body.immersive .hud-header {
  transform: translateY(-130%);
  opacity: 0;
  pointer-events: none;
}

body.immersive .left-panel {
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
}

body.immersive .right-panel {
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
}

body.immersive .hud-footer {
  transform: translateY(130%);
  opacity: 0;
  pointer-events: none;
}

.exit-immersive {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--dawn-gold);
  background: rgba(13, 17, 15, 0.84);
  color: var(--dawn-bright);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .hud-panel {
    width: 250px;
  }
}

@media (max-width: 860px) {
  .right-panel {
    display: none;
  }
  .brand-meta {
    display: none;
  }
}
