:root {
  --bg-dark: #060913;
  --neon-blue: #00e5ff;
  --neon-red: #ff0055;
  --neon-green: #00ff88;
  --panel-bg: rgba(10, 16, 32, 0.65);
  --panel-border: rgba(0, 229, 255, 0.15);
  --panel-border-red: rgba(255, 0, 85, 0.25);
  --panel-border-green: rgba(0, 255, 136, 0.25);
  --text-primary: #ffffff;
  --text-secondary: #8b9bb4;
  --glow-blue: 0 0 15px rgba(0, 229, 255, 0.6), inset 0 0 15px rgba(0, 229, 255, 0.2);
  --glow-red: 0 0 15px rgba(255, 0, 85, 0.6), inset 0 0 15px rgba(255, 0, 85, 0.2);
  --glow-green: 0 0 15px rgba(0, 255, 136, 0.6), inset 0 0 15px rgba(0, 255, 136, 0.2);
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Rajdhani', sans-serif;
  color: var(--text-primary);
  font-weight: 500;
}

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

/* Glassmorphism Panel Template */
.hud-panel, .overlay-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  border-radius: 8px;
}

/* HUD Overlay Container */
.hud-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to canvas unless overridden */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Top Header */
.hud-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.hud-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  min-width: 140px;
}

.hud-panel .label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 4px;
}

.hud-panel .value {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.text-red {
  color: var(--neon-red);
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.5) !important;
}

.text-blue {
  color: var(--neon-blue);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5) !important;
}

.text-green {
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.5) !important;
}

/* Left controls panel */
.hud-side-left {
  position: absolute;
  left: 20px;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto; /* Allow buttons to be clicked */
}

.hud-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.hud-btn svg {
  transition: transform 0.3s ease;
}

.hud-btn:hover {
  border-color: var(--neon-blue);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.1);
}

.hud-btn:hover svg {
  transform: scale(1.1);
}

/* Active Siren State */
.siren-active {
  border-color: var(--neon-red);
  color: var(--neon-red);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.3);
  animation: siren-flash 1s infinite alternate;
}

.siren-active:hover {
  border-color: var(--neon-red);
  background: rgba(255, 0, 85, 0.1);
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.5);
}

@keyframes siren-flash {
  0% {
    box-shadow: 0 0 5px rgba(255, 0, 85, 0.2);
    border-color: rgba(255, 0, 85, 0.5);
  }
  100% {
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.6);
    border-color: var(--neon-red);
  }
}

/* Footer elements */
.hud-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  margin-top: auto;
}

/* Speedometer */
.speedometer-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  padding: 15px 25px;
  min-width: 320px;
  pointer-events: auto;
}

.speed-dial {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dial-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dial-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 6;
}

.dial-fg {
  fill: none;
  stroke: var(--neon-blue);
  stroke-width: 6;
  stroke-dasharray: 283; /* 2 * PI * r (r=45) */
  stroke-dashoffset: 283;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s ease, stroke 0.3s ease;
  filter: drop-shadow(0 0 3px var(--neon-blue));
}

.speed-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#speed-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 900;
}

.speed-text .unit {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.boost-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}

.boost-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 700;
}

.boost-bar-outer {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.boost-bar-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-green));
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
  transform-origin: left;
  transition: transform 0.1s linear;
}

/* Radar/Minimap */
.radar-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: unset;
}

.radar-title {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 6px;
  font-family: 'Orbitron', sans-serif;
}

#radar-canvas {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 4px;
  display: block;
}

/* Screen Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(3, 5, 10, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay-card {
  width: 100%;
  max-width: 500px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: card-appear 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes card-appear {
  0% {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.badge {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--neon-blue);
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--panel-border);
  padding: 6px 16px;
  border-radius: 30px;
  font-weight: 700;
  margin-bottom: 16px;
}

.success-badge {
  color: var(--neon-green);
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--panel-border-green);
}

.danger-badge {
  color: var(--neon-red);
  background: rgba(255, 0, 85, 0.1);
  border-color: var(--panel-border-red);
}

h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.highlight {
  color: var(--neon-blue);
  text-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.tagline {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.instructions-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.instructions-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.control-row:last-child {
  margin-bottom: 0;
}

.keys {
  font-family: 'Orbitron', sans-serif;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--neon-blue);
}

.action {
  color: var(--text-primary);
  font-weight: 700;
}

.audio-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.1);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 24px;
  line-height: 1.4;
}

.menu-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 2px;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 15px 35px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  width: 100%;
  outline: none;
}

.glow-btn-blue {
  background: linear-gradient(135deg, #0088ff, #00e5ff);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.glow-btn-blue:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 229, 255, 0.8);
}

.glow-btn-green {
  background: linear-gradient(135deg, #00aa66, #00ff88);
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.glow-btn-green:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 255, 136, 0.8);
}

.glow-btn-red {
  background: linear-gradient(135deg, #cc0044, #ff0055);
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

.glow-btn-red:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(255, 0, 85, 0.8);
}

/* Stats panel for Game Over / Win */
.stats-panel {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-bottom: 30px;
  gap: 10px;
}

.stat-item {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-weight: 700;
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 900;
}

/* Card Borders customized for Win/Lose */
.win-card {
  border-color: var(--panel-border-green);
  box-shadow: 0 8px 32px 0 rgba(0, 255, 136, 0.1);
}

.lose-card {
  border-color: var(--panel-border-red);
  box-shadow: 0 8px 32px 0 rgba(255, 0, 85, 0.1);
}

/* Screen flash effect when hitting bad guys */
.hit-flash-red {
  animation: fullscreen-red-flash 0.3s ease-out;
}

@keyframes fullscreen-red-flash {
  0% {
    box-shadow: inset 0 0 100px rgba(255, 0, 85, 0.8);
  }
  100% {
    box-shadow: inset 0 0 0px rgba(255, 0, 85, 0);
  }
}
