:root {
  --accent: #00e5ff;
  --accent-dim: #007a8a;
  --enemy: #ff3b5c;
  --enemy-dim: #7a1d2e;
  --bg-0: #05070b;
  --bg-1: #0c1118;
  --text: #d6e9ee;
  --muted: #6b7d86;
  --warn: #ffb547;
  --good: #4cf08c;
  --hud-pad: 22px;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --font-display: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0a1322 0%, #05070b 60%);
}

.hidden {
  display: none !important;
}

/* ========== HUD ========== */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute;
  top: var(--hud-pad);
  left: var(--hud-pad);
  right: var(--hud-pad);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: start;
}

.health-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(8, 14, 22, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 229, 255, 0.18);
  padding: 10px 14px;
  border-radius: 4px;
  min-width: 240px;
  max-width: 360px;
  position: relative;
  overflow: hidden;
}

.health-block::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.enemy-block::before {
  background: var(--enemy);
  box-shadow: 0 0 12px var(--enemy);
}

.enemy-block {
  border-color: rgba(255, 59, 92, 0.18);
  margin-left: auto;
}

.label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--muted);
  text-transform: uppercase;
}

.bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 1px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #6ef0ff);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
  transition: width 0.18s ease, background 0.2s ease;
}

.bar.enemy {
  background: linear-gradient(90deg, var(--enemy), #ff8da0);
  box-shadow: 0 0 12px rgba(255, 59, 92, 0.6);
}

.bar.low { background: linear-gradient(90deg, var(--warn), #ffd28a); }
.bar.crit { background: linear-gradient(90deg, #ff3b5c, #ff8da0); }

.hp {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.06em;
}

.center-info {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--muted);
  padding-top: 12px;
}

#round-status {
  color: var(--accent);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

/* Crosshair */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ch-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
  transform: translate(-50%, -50%);
}

.ch-line {
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 4px rgba(0, 229, 255, 0.7);
}

.ch-line.top, .ch-line.bottom {
  width: 2px;
  height: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.ch-line.top { top: 0; }
.ch-line.bottom { bottom: 0; }

.ch-line.left, .ch-line.right {
  height: 2px;
  width: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.ch-line.left { left: 0; }
.ch-line.right { right: 0; }

/* Bottom HUD */
.hud-bottom {
  position: absolute;
  bottom: var(--hud-pad);
  left: var(--hud-pad);
  right: var(--hud-pad);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.hud-info { display: flex; gap: 16px; align-items: center; }
.hud-info .key {
  display: inline-block;
  padding: 3px 8px;
  margin-right: 6px;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 3px;
  color: var(--accent);
  font-size: 10px;
  background: rgba(0, 229, 255, 0.06);
}

.hud-stats { display: flex; gap: 22px; }
.hud-stats span { color: var(--accent); margin-left: 6px; }

/* Effects */
#damage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 59, 92, 0) 40%, rgba(255, 59, 92, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.28s ease;
}

#damage-overlay.flash { opacity: 1; }

#hit-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  opacity: 0;
  pointer-events: none;
  background:
    linear-gradient(45deg, transparent 46%, var(--good) 46%, var(--good) 54%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, var(--good) 46%, var(--good) 54%, transparent 54%);
  filter: drop-shadow(0 0 6px var(--good));
  transition: opacity 0.18s ease;
}

#hit-marker.show { opacity: 1; }

#muzzle-flash {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, 0);
  background: radial-gradient(circle at center, rgba(255, 220, 120, 0.95) 0%, rgba(255, 140, 40, 0.6) 18%, rgba(255, 100, 30, 0) 60%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.06s ease;
  mix-blend-mode: screen;
}

#muzzle-flash.flash { opacity: 1; }

/* ========== Overlays (start / end) ========== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(0, 229, 255, 0.06) 0%, rgba(0, 0, 0, 0.85) 65%),
    linear-gradient(180deg, #03060a 0%, #060a12 100%);
}

.overlay-inner {
  text-align: center;
  padding: 40px 56px;
  max-width: 560px;
  position: relative;
}

.overlay-inner::before,
.overlay-inner::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  opacity: 0.6;
}

.overlay-inner::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.overlay-inner::after {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(48px, 8vw, 96px);
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 28px rgba(0, 229, 255, 0.45);
  line-height: 1;
}

.title-sub {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.4em;
  color: var(--accent);
  letter-spacing: 0.2em;
  vertical-align: middle;
}

.tagline {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}

.controls-card {
  margin: 36px auto 28px;
  max-width: 360px;
  padding: 20px 24px;
  border: 1px solid rgba(0, 229, 255, 0.22);
  background: rgba(8, 14, 22, 0.55);
  border-radius: 4px;
  text-align: left;
}

.controls-card h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.36em;
  color: var(--accent);
  margin-bottom: 14px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.06em;
}

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

.key {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}

.key.big {
  display: inline-block;
  min-width: 72px;
  text-align: center;
  padding: 6px 10px;
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.06);
  color: var(--accent);
  font-size: 12px;
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.32em;
  padding: 14px 38px;
  background: var(--accent);
  color: #02151a;
  border: none;
  cursor: pointer;
  border-radius: 2px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 0 0 rgba(0, 229, 255, 0.0);
}

.btn:hover {
  background: #6ef0ff;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.6);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.end-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin: 32px 0 28px;
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-top: 4px;
}

#end-screen.defeat .title {
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 59, 92, 0.55);
}

#end-screen.defeat .stat-num { color: var(--enemy); text-shadow: 0 0 12px rgba(255, 59, 92, 0.4); }
#end-screen.defeat .controls-card { border-color: rgba(255, 59, 92, 0.22); }
#end-screen.defeat .btn { background: var(--enemy); color: #1a0207; }
#end-screen.defeat .btn:hover { background: #ff8da0; box-shadow: 0 0 24px rgba(255, 59, 92, 0.6); }
#end-screen.defeat .overlay-inner::before,
#end-screen.defeat .overlay-inner::after { border-color: var(--enemy); }
