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

body {
  background-color: #07090e;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Header & Stats Banner */
.hud-top {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.badge-bio {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.stats-panel {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.stat-card {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 14px;
  border-radius: 8px;
  min-width: 90px;
}

.stat-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  font-family: monospace;
}

/* Top Right: Connectome Brain HUD */
.hud-brain {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 30;
  width: 275px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
}

.hud-brain::-webkit-scrollbar {
  width: 4px;
}
.hud-brain::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 2px;
}

.brain-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

#brain-canvas {
  width: 100%;
  height: 145px;
  background: #020617;
  border-radius: 6px;
  display: block;
  border: 1px solid rgba(56, 189, 248, 0.15);
}

.raster-panel {
  margin-top: 8px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
}

.neural-activity {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
}

.circuit-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #334155;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.indicator-dot.active-gf {
  background: #eab308;
  box-shadow: 0 0 10px #eab308;
}

.indicator-dot.active-optomotor {
  background: #06b6d4;
  box-shadow: 0 0 10px #06b6d4;
}

.indicator-dot.active-lc4 {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

/* Compound Eye Inset */
.eye-inset {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 6px 8px;
  border-radius: 8px;
}

#eye-canvas {
  width: 54px;
  height: 54px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.12), inset 0 0 6px rgba(0, 0, 0, 0.8);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #090d16;
  flex-shrink: 0;
}

/* Bottom Controls */
.hud-bottom {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
}

.mode-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  transform: scale(1.03);
}

.mode-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(2, 132, 199, 0.5);
}

.status-tag {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Game Over Overlay */
#game-over-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 20;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

#game-over-modal h2 {
  font-size: 38px;
  color: #ef4444;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}

.restart-btn {
  background: #38bdf8;
  color: #030712;
  border: none;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s ease;
}

.restart-btn:hover {
  transform: scale(1.05);
}

/* New Session Button */
.session-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  margin-left: 6px;
}

.session-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.04);
}

/* Training Telemetry Panel */
.telemetry-panel {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.telemetry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.telemetry-legend {
  display: flex;
  align-items: center;
  font-size: 9px;
  color: #cbd5e1;
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 3px;
}

#telemetry-canvas {
  width: 100%;
  height: 74px;
  background: #030712;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}

.telemetry-footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #64748b;
  margin-top: 4px;
}
