:root {
  --bg-deep: #02060d;
  --panel-bg: rgba(6, 18, 36, 0.78);
  --panel-border: rgba(0, 240, 255, 0.38);
  --cyan: #00f0ff;
  --emerald: #00ffaa;
  --amber: #ffbe0b;
  --crimson: #ff2a55;
  --magenta: #d946ef;
  --text-main: #e2f7ff;
  --text-dim: #7aa6c2;
  --font-mono: 'SFMono-Regular', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-mono);
  cursor: crosshair;
}

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

/* Scanline subtle overlay */
.scanline-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 12, 24, 0.14) 3px
  );
}

/* Floating 3D Score Popups */
#floating-labels {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.floating-score {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px currentColor, 0 2px 4px #000;
  animation: floatUpFade 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes floatUpFade {
  0% {
    opacity: 1;
    transform: translate(-50%, -30%) scale(0.85);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -90%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -210%) scale(0.95);
  }
}

/* 2D Tactical Crosshair Follower */
#hud-crosshair {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
  will-change: transform;
}

.crosshair-ring {
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border: 1.5px solid rgba(0, 240, 255, 0.75);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
  position: relative;
}

.crosshair-ring::before,
.crosshair-ring::after {
  content: '';
  position: absolute;
  background: var(--cyan);
}

.crosshair-ring::before {
  top: 50%;
  left: -5px;
  right: -5px;
  height: 1px;
  transform: translateY(-50%);
}

.crosshair-ring::after {
  left: 50%;
  top: -5px;
  bottom: -5px;
  width: 1px;
  transform: translateX(-50%);
}

#crosshair-readout {
  position: absolute;
  left: 18px;
  top: 6px;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(2, 10, 22, 0.82);
  padding: 2px 6px;
  border-left: 2px solid var(--cyan);
  letter-spacing: 0.05em;
}

#crosshair-readout.locked {
  color: var(--emerald);
  border-left-color: var(--emerald);
  box-shadow: 0 0 10px rgba(0, 255, 170, 0.25);
}

/* HUD Layout */
#hud-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.hud-panel {
  pointer-events: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55), inset 0 0 15px rgba(0, 240, 255, 0.06);
}

.telemetry-bar {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.stat-block {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.64rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.32rem;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
  letter-spacing: 0.04em;
}

.stat-value.emerald {
  color: var(--emerald);
  text-shadow: 0 0 12px rgba(0, 255, 170, 0.45);
}

.stat-value.amber {
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255, 190, 11, 0.45);
}

/* Alert Banner */
#hud-alert-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 14, 28, 0.92);
  border: 1px solid var(--cyan);
  padding: 7px 20px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.35);
  z-index: 7;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Top Right Controls + Radar */
.hud-top-right {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-row {
  display: flex;
  gap: 6px;
}

.hud-btn {
  background: rgba(8, 26, 48, 0.85);
  color: var(--text-main);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 4px;
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.16);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.hud-btn.active {
  background: rgba(0, 240, 255, 0.22);
  border-color: var(--cyan);
  color: var(--cyan);
}

.hud-btn.muted {
  border-color: var(--crimson);
  color: var(--crimson);
}

.hud-btn.xr-btn {
  border-color: rgba(217, 70, 239, 0.55);
  color: #f3c4ff;
  background: rgba(45, 12, 68, 0.72);
}

.hud-btn.xr-btn.xr-ready {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(0, 255, 170, 0.16);
  box-shadow: 0 0 12px rgba(0, 255, 170, 0.35);
}

.altitude-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 4px 8px;
  background: rgba(4, 15, 30, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 4px;
}

#altitude-slider {
  width: 90px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.radar-box {
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#radar-canvas {
  display: block;
  border-radius: 50%;
  border: 1px solid rgba(0, 240, 255, 0.45);
}

.radar-caption {
  font-size: 0.58rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
}

/* Bottom Tactical Dock: 3 Batteries + EMP Overdrive */
.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dock-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.battery-card {
  pointer-events: auto;
  min-width: 195px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.battery-card:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
}

.battery-card.hyper {
  border-color: rgba(0, 255, 170, 0.48);
}

.battery-card.depleted {
  border-color: rgba(255, 42, 85, 0.55);
  opacity: 0.65;
}

.battery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 800;
}

.battery-key {
  background: rgba(0, 240, 255, 0.18);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.65rem;
  margin-right: 5px;
}

.battery-card.hyper .battery-key {
  background: rgba(0, 255, 170, 0.18);
  border-color: var(--emerald);
  color: var(--emerald);
}

.battery-ammo-text {
  font-size: 0.74rem;
  color: var(--text-main);
}

.ammo-pips {
  display: flex;
  gap: 3px;
  height: 8px;
}

.ammo-pip {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.ammo-pip.active {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

.battery-card.hyper .ammo-pip.active {
  background: var(--emerald);
  box-shadow: 0 0 6px var(--emerald);
}

/* EMP Overdrive Widget */
.emp-card {
  pointer-events: auto;
  min-width: 205px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.emp-bar-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

#emp-bar-fill {
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  box-shadow: 0 0 10px var(--emerald);
  transition: width 0.2s ease;
}

#btn-emp {
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: rgba(0, 40, 65, 0.7);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
}

#btn-emp.ready {
  background: rgba(0, 255, 170, 0.22);
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 16px rgba(0, 255, 170, 0.4);
  animation: pulseGlow 1.1s infinite alternate;
}

@keyframes pulseGlow {
  from {
    box-shadow: 0 0 8px rgba(0, 255, 170, 0.3);
  }
  to {
    box-shadow: 0 0 20px rgba(0, 255, 170, 0.75);
  }
}

.controls-hint-bar {
  font-size: 0.66rem;
  color: var(--text-dim);
  background: rgba(3, 12, 24, 0.78);
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.18);
  letter-spacing: 0.05em;
}

.controls-hint-bar kbd {
  color: var(--cyan);
  font-weight: 700;
}

/* Modals (Title, Tally, Pause, Game Over) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 8, 18, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: default;
}

.hidden {
  display: none !important;
}

.modal-card {
  max-width: 580px;
  width: 100%;
  background: rgba(6, 18, 36, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.55);
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8), 0 0 35px rgba(0, 240, 255, 0.18);
  text-align: center;
}

.badge-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.modal-badge {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: var(--emerald);
  border: 1px solid rgba(0, 255, 170, 0.45);
  padding: 3px 10px;
  border-radius: 99px;
}

.modal-badge.xr-badge {
  color: #f3c4ff;
  border-color: rgba(217, 70, 239, 0.55);
  background: rgba(55, 12, 82, 0.45);
}

.modal-badge.xr-badge.ready {
  color: var(--emerald);
  border-color: var(--emerald);
  background: rgba(0, 255, 170, 0.16);
}

.modal-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.65);
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 0.84rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.5;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
  margin-bottom: 20px;
}

.guide-item {
  background: rgba(10, 28, 52, 0.65);
  border: 1px solid rgba(0, 240, 255, 0.22);
  border-radius: 6px;
  padding: 9px 11px;
}

.guide-item-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cyan);
  margin-bottom: 3px;
}

.guide-item-desc {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.diff-selector {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.diff-btn {
  flex: 1;
  padding: 8px 12px;
  background: rgba(8, 24, 46, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diff-btn.active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cta-btn {
  width: 100%;
  padding: 13px 24px;
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #02101f;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.5);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.cta-btn.xr-cta-btn {
  color: #ffffff;
  background: linear-gradient(90deg, #7209b7, #d946ef);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 20px rgba(217, 70, 239, 0.45);
}

.cta-btn.xr-cta-btn.xr-ready {
  color: #02101f;
  background: linear-gradient(90deg, var(--emerald), var(--cyan));
  box-shadow: 0 0 26px rgba(0, 255, 170, 0.65);
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(0, 255, 170, 0.8);
}

.tally-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.tally-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(10, 28, 52, 0.7);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 6px;
  font-size: 0.88rem;
}

.tally-row.highlight {
  border-color: var(--emerald);
  color: var(--emerald);
  font-weight: 800;
}

@media (max-width: 768px) {
  .guide-grid {
    grid-template-columns: 1fr;
  }
  .battery-card {
    min-width: 140px;
  }
  .controls-hint-bar {
    display: none;
  }
}
