:root {
  --accent: #ff5a3c;
  --accent-dim: #b53524;
  --good: #4cd07d;
  --ink: #f4f4f0;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

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

html,
body {
  width: 100%;
  height: 100%;
  /* Use the dynamic viewport height so mobile address bars don't crop the game. */
  height: 100dvh;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  touch-action: none;
}

#renderCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#topbar {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-weight: bold;
  letter-spacing: 1px;
}

#location {
  text-transform: uppercase;
  font-size: 13px;
  opacity: 0.9;
  text-shadow: var(--shadow);
}

#score {
  font-size: 17px;
  color: var(--accent);
  text-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

#health {
  position: absolute;
  top: 28px;
  left: 14px;
  display: flex;
  gap: 5px;
}

.heart {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}

.heart.empty {
  background: #333;
  opacity: 0.5;
  transform: scale(0.85);
}

/* Vertical icon columns hugging the left (foes) and right (bullets) edges. */
.iconCol {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#foes {
  left: 14px;
  align-items: flex-start;
}

#bullets {
  right: 16px;
  align-items: flex-end;
}

/* Enemy silhouette: a head over a body, in enemy red. */
.foe {
  position: relative;
  width: 16px;
  height: 21px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

.foe::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #e6543b;
}

.foe::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 15px;
  height: 14px;
  margin-left: -7.5px;
  border-radius: 7px 7px 4px 4px;
  background: #e6543b;
}

/* A single round; spent rounds dim out so the magazine reads at a glance. */
.bullet {
  width: 8px;
  height: 17px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(#ffe08a, #d8992a);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  transition: opacity 0.12s, transform 0.12s, background 0.12s;
}

.bullet.spent {
  background: #3a3a3a;
  opacity: 0.4;
  transform: scale(0.8);
}

/* Weapon name, sits just above the magazine on the right. */
#weapon {
  position: absolute;
  right: 14px;
  bottom: calc(50% + 130px);
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  text-align: right;
  color: var(--ink);
  text-shadow: var(--shadow);
}

/* Active effect banner, top-centre. */
#effectBanner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  text-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

/* Powerup pickup toast, centred, briefly flashes then fades. */
#pickupToast {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 34px;
  font-weight: bold;
  letter-spacing: 4px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
}

#pickupToast.show {
  animation: toast 1.2s ease-out forwards;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -65%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(1);
  }
}

/* Time-slow blue wash. */
#slowTint {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(40, 130, 220, 0) 40%,
    rgba(40, 130, 220, 0.28) 100%
  );
}

#slowTint.on {
  opacity: 1;
}

#reloadHint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 2px;
  opacity: 0.55;
  text-shadow: var(--shadow);
  transition: opacity 0.3s;
}

#reloadHint.fade {
  opacity: 0;
}

/* ---------- Cover (duck / reload) ---------- */
#cover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  z-index: 9;
  pointer-events: none;
  transform: translateY(102%);
  transition: transform 0.14s ease-out;
}

#cover.on {
  transform: translateY(0);
}

#coverWall {
  position: absolute;
  inset: 0;
  background: linear-gradient(
      to bottom,
      rgba(10, 12, 16, 0) 0,
      rgba(10, 12, 16, 0.9) 16%,
      #0b0e13 34%
    ),
    repeating-linear-gradient(90deg, #2b313a 0 38px, #232932 38px 40px);
  border-top: 4px solid #0a0d11;
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, 0.7),
    0 -2px 0 rgba(255, 255, 255, 0.06);
}

#coverBadge {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  z-index: 11;
  pointer-events: none;
  padding: 9px 22px;
  border-radius: 10px;
  background: rgba(8, 14, 11, 0.72);
  border: 2px solid var(--good);
  color: var(--good);
  font-weight: bold;
  letter-spacing: 3px;
  font-size: 19px;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
}

#coverBadge.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#coverBadge small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink);
  opacity: 0.75;
}

#coverBadge .dot {
  animation: blink 0.9s steps(2, jump-none) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- Crosshair ---------- */
#crosshair {
  position: absolute;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  z-index: 9;
  pointer-events: none;
  mix-blend-mode: screen;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

#crosshair::before {
  left: 50%;
  top: -8px;
  bottom: -8px;
  width: 2px;
  margin-left: -1px;
}

#crosshair::after {
  top: 50%;
  left: -8px;
  right: -8px;
  height: 2px;
  margin-top: -1px;
}

#crosshair.fire {
  animation: kick 0.12s ease-out;
}

@keyframes kick {
  0% {
    transform: scale(0.7);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Fade / overlay ---------- */
#fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#fade.on {
  opacity: 1;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1a2a3a, #060a10);
}

#overlayPanel {
  text-align: center;
  padding: 30px;
  max-width: 520px;
}

#overlayTitle {
  font-size: 52px;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 4px 0 var(--accent-dim), 0 6px 14px rgba(0, 0, 0, 0.6);
  margin-bottom: 18px;
}

#overlayText {
  font-size: 17px;
  line-height: 1.7;
  opacity: 0.85;
  margin-bottom: 30px;
}

#startButton {
  font-family: inherit;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 3px;
  color: var(--ink);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 14px 46px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-dim);
  transition: transform 0.08s, box-shadow 0.08s;
}

#startButton:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-dim);
}

/* ---------- Rotate notice ---------- */
#rotateNotice {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: #060a10;
  font-size: 22px;
  letter-spacing: 2px;
  text-align: center;
}

#rotateNotice.show {
  display: flex;
}
