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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: black;
}

#renderCanvas {
  width: 100%; height: 100%;
  touch-action: none;
}

#ui {
  position: absolute;
  top: 20px; left: 20px;
  color: white;
  font-family: Arial; font-size: 22px;
}

/* ── Score popup ───────────────────────────────────────────────────────── */
.score-popup {
  position: fixed;
  pointer-events: none;
  font-family: 'Arial Black', Arial, sans-serif;
  font-weight: 900;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: scoreFloat 1.4s ease-out forwards;
  z-index: 50;
  text-shadow: 0 0 8px currentColor;
}

.score-popup.ghost-points {
  font-size: 22px;
  color: #44aaff;
}

.score-popup.skeleton-points {
  font-size: 34px;
  color: #ffdd00;
  text-shadow: 0 0 12px #ffaa00, 0 0 24px #ff8800;
}

@keyframes scoreFloat {
  0%   { opacity: 1;   transform: translate(-50%, -50%) scale(1.3); }
  20%  { opacity: 1;   transform: translate(-50%, -80%) scale(1); }
  100% { opacity: 0;   transform: translate(-50%, -180%) scale(0.8); }
}

/* ── Lives HUD ─────────────────────────────────────────────────────────── */
#lives-hud {
  position: absolute;
  bottom: 30px; right: 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

#lives-label {
  font-family: 'Arial Black', Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff4444;
  text-shadow: 0 0 8px #ff0000, 0 0 16px #ff000088;
  text-transform: uppercase;
}

#lives-icons {
  display: flex;
  gap: 8px;
}

.life-icon {
  font-size: 28px;
  line-height: 1;
  color: #cc0000;
  filter: drop-shadow(0 0 6px #ff0000) drop-shadow(0 0 12px #aa0000);
  transition: all 0.4s ease;
}

.life-icon.lost {
  color: #2a2a2a;
  filter: none;
  opacity: 0.35;
  transform: scale(0.8);
}

/* ── Game Over ───────────────────────────────────────────────────────── */
#game-over-screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  gap: 20px;
}

#game-over-screen.active {
  display: flex;
  animation: gameOverFadeIn 0.6s ease;
}

@keyframes gameOverFadeIn {
  from { opacity: 0; transform: scale(1.1); }
  to   { opacity: 1; transform: scale(1); }
}

#game-over-title {
  font-family: 'Arial Black', Arial, sans-serif;
  font-size: 64px;
  font-weight: 900;
  color: #ff2222;
  text-shadow: 0 0 20px #ff0000, 0 0 40px #ff000088;
  letter-spacing: 4px;
  animation: titlePulse 1s ease-in-out infinite alternate;
}

@keyframes titlePulse {
  from { text-shadow: 0 0 20px #ff0000, 0 0 40px #ff000088; }
  to   { text-shadow: 0 0 40px #ff0000, 0 0 80px #ff0000cc; }
}

#game-over-score {
  font-family: Arial, sans-serif;
  font-size: 28px;
  color: #ffffff;
  letter-spacing: 2px;
}

#restart-btn {
  margin-top: 10px;
  padding: 14px 40px;
  font-family: 'Arial Black', Arial, sans-serif;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  color: white;
  background: transparent;
  border: 3px solid #ff4444;
  box-shadow: 0 0 16px #ff000088;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
}

#restart-btn:hover {
  background: #ff2222;
  box-shadow: 0 0 30px #ff0000;
}

/* ── Health HUD ─────────────────────────────────────────────────────────── */
#health-hud {
  position: absolute;
  bottom: 30px; left: 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#health-label {
  font-family: 'Arial Black', Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff4444;
  text-shadow: 0 0 8px #ff0000, 0 0 16px #ff000088;
  text-transform: uppercase;
}

#health-bar {
  position: relative;
  width: 260px;
  height: 22px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #aa0000;
  box-shadow: 0 0 10px #ff000066, inset 0 0 6px rgba(0,0,0,0.8);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  overflow: hidden;
}

#health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b0000 0%, #cc0000 40%, #ff4444 80%, #ff9999 100%);
  box-shadow: inset 0 0 12px rgba(255,200,200,0.4);
  transition: width 0.15s ease-out, background 0.4s ease;
  position: relative;
}

#health-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
}

#health-fill.critical {
  background: linear-gradient(90deg, #3a0000 0%, #880000 50%, #cc0000 100%);
  animation: critPulse 0.5s ease-in-out infinite alternate;
}

@keyframes critPulse {
  from { box-shadow: inset 0 0 8px rgba(255,0,0,0.3); filter: brightness(0.8); }
  to   { box-shadow: inset 0 0 20px rgba(255,0,0,0.8); filter: brightness(1.3); }
}

#health-segments {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  pointer-events: none;
}

#health-segments .seg {
  flex: 1;
  border-right: 1px solid rgba(0,0,0,0.4);
  height: 100%;
}

#health-segments .seg:last-child { border-right: none; }

#health-value {
  font-family: 'Arial Black', Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
  color: #ff6666;
  letter-spacing: 2px;
  text-shadow: 0 0 6px #ff0000;
  text-align: right;
  width: 260px;
}

/* ── Damage flash ───────────────────────────────────────────────────────── */
#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(180,0,0,0.55) 100%);
  opacity: 0;
  transition: opacity 0.08s ease-in;
}

#damage-flash.active {
  opacity: 1;
  transition: none;
}
/* ── Critical alarm ─────────────────────────────────────────────────────────── */
#critical-alarm {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(220,0,0,0.6) 100%);
  opacity: 0;
}

#critical-alarm.active {
  animation: alarmPulse 0.6s ease-in-out infinite;
}

@keyframes alarmPulse {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}
#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 20px; height: 20px;
  pointer-events: none;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 2px;
}

#crosshair::before {
  width: 2px; height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

#crosshair::after {
  width: 100%; height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

#weapon-mode {
  position: absolute;
  top: 50px; left: 20px;
  font-family: Arial; font-size: 15px;
  letter-spacing: 1px;
  pointer-events: none;
}

#radar {
  position: absolute;
  top: 80px;
  left: 20px;
  border-radius: 50%;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 255, 120, 0.5));
}

/* Crosshair turns orange in grenade mode */
body.grenade-mode #crosshair::before,
body.grenade-mode #crosshair::after {
  background: rgba(255, 153, 0, 0.9);
}
