:root {
  --accent: #46f0d2;
  --danger: #ff3b57;
  --warm: #ffb03a;
  --bg: #07090d;
  --panel: rgba(10, 14, 19, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --text: #dfe7ea;
  --dim: rgba(223, 231, 234, 0.55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

canvas#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#hud.hidden {
  opacity: 0;
}

#vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 59, 87, 0) 42%,
    rgba(255, 59, 87, 0.42) 100%
  );
}

#vignette.hurt {
  box-shadow: inset 0 0 160px 60px rgba(255, 59, 87, 0.6);
}

body.low-health #vignette {
  animation: lowhp-pulse 1.5s ease-in-out infinite;
}

@keyframes lowhp-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 110px 28px rgba(255, 59, 87, 0.16);
  }
  50% {
    box-shadow: inset 0 0 175px 70px rgba(255, 59, 87, 0.52);
  }
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 3;
}

#crosshair .line {
  position: absolute;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.65);
}

#crosshair .line.v {
  width: 2px;
  height: 10px;
  left: -1px;
}

#crosshair .line.h {
  width: 10px;
  height: 2px;
  top: -1px;
}

#crosshair .line.v.top {
  bottom: var(--spread, 6px);
}

#crosshair .line.v.bottom {
  top: var(--spread, 6px);
}

#crosshair .line.h.left {
  right: var(--spread, 6px);
}

#crosshair .line.h.right {
  left: var(--spread, 6px);
}

#crosshair .dot {
  position: absolute;
  width: 2px;
  height: 2px;
  left: -1px;
  top: -1px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px rgba(70, 240, 210, 0.8);
}

#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 3;
  opacity: 0;
}

#hitmarker span {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 2px;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

#hitmarker span:nth-child(1) {
  transform: translate(calc(-50% - 8px), calc(-50% - 8px)) rotate(45deg);
}

#hitmarker span:nth-child(2) {
  transform: translate(calc(-50% + 8px), calc(-50% - 8px)) rotate(-45deg);
}

#hitmarker span:nth-child(3) {
  transform: translate(calc(-50% - 8px), calc(-50% + 8px)) rotate(-45deg);
}

#hitmarker span:nth-child(4) {
  transform: translate(calc(-50% + 8px), calc(-50% + 8px)) rotate(45deg);
}

#hitmarker.crit span {
  background: var(--warm);
  height: 3px;
}

#hitmarker.show {
  animation: hitmark-pop 0.14s ease-out;
}

@keyframes hitmark-pop {
  0% {
    opacity: 1;
    transform: scale(1.3);
  }
  100% {
    opacity: 0;
    transform: scale(0.85);
  }
}

#damage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

#hud-bottom-left {
  position: absolute;
  left: 24px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
}

#health-bar {
  width: 200px;
  height: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px;
}

#health-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transition: width 0.12s linear, background-color 0.15s ease;
}

#health-fill.mid {
  background: var(--warm);
}

#health-fill.low {
  background: var(--danger);
}

#health-num {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
}

body.low-health #health-num {
  color: var(--danger);
}

#hud-bottom-right {
  position: absolute;
  right: 24px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#weapon-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.35em;
  color: var(--dim);
  text-transform: uppercase;
}

#ammo-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#ammo-mag {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

#ammo-mag.low {
  color: var(--danger);
}

#ammo-reserve {
  font-size: 16px;
  font-weight: 600;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

#weapon-slots {
  display: flex;
  gap: 6px;
}

.slot {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(10, 14, 19, 0.6);
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.slot[data-active="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(70, 240, 210, 0.09);
  box-shadow: inset 0 0 0 1px rgba(70, 240, 210, 0.25);
}

#hud-top-right {
  position: absolute;
  top: 18px;
  right: 24px;
  z-index: 4;
  text-align: right;
}

#score {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

#combo {
  min-height: 18px;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--warm);
  opacity: 0;
  transform-origin: right top;
}

#combo.on {
  opacity: 1;
}

#combo.pulse {
  animation: combo-pop 0.18s ease-out;
}

@keyframes combo-pop {
  0% {
    transform: scale(1.45);
  }
  100% {
    transform: scale(1);
  }
}

#wave-banner {
  position: absolute;
  top: 64px;
  left: 50%;
  z-index: 5;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#wave-banner.show {
  opacity: 1;
  animation: banner-drop 0.4s cubic-bezier(0.2, 0.9, 0.25, 1);
}

@keyframes banner-drop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

#wave-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  color: #ffffff;
  text-transform: uppercase;
  white-space: nowrap;
}

#wave-sub {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
}

#debug-stats {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 5;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: rgba(223, 231, 234, 0.66);
  white-space: pre;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#screens {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

#screens section {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(4, 6, 9, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  animation: screen-in 0.22s ease-out;
}

@keyframes screen-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#screens h1 {
  margin: 0;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
  color: #ffffff;
  text-transform: uppercase;
  text-align: center;
}

#dead h1 {
  color: var(--danger);
}

#win h1 {
  color: var(--accent);
}

.tagline {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--dim);
  text-transform: uppercase;
}

.final-line {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.final-line.dim {
  color: var(--dim);
  font-size: 15px;
}

.final-line span {
  color: var(--accent);
  font-weight: 800;
}

button {
  appearance: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(70, 240, 210, 0.07);
  border: 1px solid var(--accent);
  padding: 14px 34px 14px calc(34px + 0.32em);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}

button:hover {
  color: #ffffff;
  background: rgba(70, 240, 210, 0.18);
  box-shadow: 0 0 18px rgba(70, 240, 210, 0.25);
}

button:active {
  transform: translateY(1px) scale(0.985);
  background: rgba(70, 240, 210, 0.3);
}

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.controls-hint {
  margin-top: 26px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.14em;
  line-height: 2;
  text-transform: uppercase;
}

.controls-hint p {
  margin: 0;
}
