/* HUD / shell styles for the FPS prototype.
   Design system: 8px spacing unit, two families (system-ui + monospace for
   numbers), single accent (#4fd8ff cyan) + semantic red for damage. */

:root {
  --bg: #0b0d11;
  --panel: rgba(14, 18, 24, 0.82);
  --line: rgba(120, 180, 210, 0.22);
  --text: #dbe6ee;
  --text-dim: #8b9aa8;
  --accent: #4fd8ff;
  --accent-hot: #ffb457;
  --danger: #ff4d52;
  --ok: #6ee7a0;
  --u: 8px;
  --spread: 6px;          /* crosshair gap, written every frame from weapon spread */
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  cursor: default;
}
body.locked { cursor: none; }

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

#hud {
  position: fixed; inset: 0; pointer-events: none;
  font-family: var(--sans); user-select: none;
  z-index: 5;
}

/* ---------- crosshair ---------- */
.crosshair {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  --len: 8px; --thick: 2px;
}
.crosshair i {
  position: absolute; background: var(--accent);
  box-shadow: 0 0 6px rgba(79, 216, 255, 0.55), 0 0 1px #000;
  opacity: 0.92; transition: background 120ms linear;
}
.crosshair .ch-t, .crosshair .ch-b { width: var(--thick); height: var(--len); }
.crosshair .ch-l, .crosshair .ch-r { height: var(--thick); width: var(--len); }
.crosshair .ch-t { left: calc(var(--thick) / -2); top: calc(-1 * (var(--spread) + var(--len))); }
.crosshair .ch-b { left: calc(var(--thick) / -2); top: var(--spread); }
.crosshair .ch-l { top: calc(var(--thick) / -2); left: calc(-1 * (var(--spread) + var(--len))); }
.crosshair .ch-r { top: calc(var(--thick) / -2); left: var(--spread); }
.crosshair .ch-dot {
  position: absolute; left: -1px; top: -1px; width: 2px; height: 2px;
  background: #fff; border-radius: 50%; opacity: 0.85;
}
.crosshair.on-target i { background: var(--accent-hot); box-shadow: 0 0 8px rgba(255, 180, 87, 0.7); }
.crosshair.reloading { opacity: 0.35; }

/* ---------- hitmarker ---------- */
.hitmarker { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
.hitmarker i {
  position: absolute; left: -1px; top: -1px; width: 2px; height: 16px;
  background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transform-origin: center;
}
.hitmarker i:first-child { transform: rotate(45deg); }
.hitmarker i:last-child { transform: rotate(-45deg); }
.hitmarker.show { opacity: 1; transform: scale(1); transition: none; }
.hitmarker.show i { animation: hit-pop 320ms ease-out forwards; }
.hitmarker.kill i { background: var(--danger); box-shadow: 0 0 10px rgba(255, 77, 82, 0.8); }
.hitmarker.kill.show i { animation: hit-pop-kill 420ms ease-out forwards; }
@keyframes hit-pop {
  0% { transform: rotate(45deg) scaleY(1.5); opacity: 1; }
  100% { transform: rotate(45deg) scaleY(0.8); opacity: 0; }
}
.hitmarker.kill.show i:last-child, .hitmarker.show i:last-child { }
@keyframes hit-pop-kill {
  0% { transform: rotate(-45deg) scaleY(1.8); opacity: 1; }
  100% { transform: rotate(-45deg) scaleY(0.9); opacity: 0; }
}

/* ---------- top bar ---------- */
.hud-top {
  position: absolute; top: calc(var(--u) * 2); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: var(--u);
}
.objective {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  background: var(--panel); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 6px;
}
.killfeed { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.killfeed div {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--text); background: rgba(20, 10, 12, 0.7);
  border-left: 2px solid var(--danger); padding: 4px 10px; border-radius: 4px;
  animation: kf-in 200ms ease-out;
}
@keyframes kf-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- health (bottom-left) ---------- */
.hud-left { position: absolute; left: calc(var(--u) * 4); bottom: calc(var(--u) * 4); }
.stat-label {
  font-size: 10px; letter-spacing: 0.22em; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase;
}
.health-wrap {
  position: relative; width: 260px; height: 18px;
  background: rgba(10, 14, 18, 0.72);
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
}
.health-lag, .health-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.health-lag { background: rgba(255, 77, 82, 0.45); transition: width 420ms ease-out 120ms; }
.health-fill {
  background: linear-gradient(180deg, #7ce8ff, #2aa9d6);
  transition: width 140ms ease-out;
}
.health-wrap.low .health-fill { background: linear-gradient(180deg, #ff8a8a, #c9272e); }
.health-ticks {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 25px, rgba(0,0,0,0.55) 25px 26px);
}
.health-num {
  position: absolute; right: 8px; top: 0; line-height: 18px;
  font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.sub-stats { display: flex; gap: var(--u); margin-top: 6px; }
.tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--text-dim); background: rgba(12, 16, 20, 0.6);
  border: 1px solid var(--line); border-radius: 3px; padding: 2px 6px;
}

/* ---------- ammo (bottom-right) ---------- */
.hud-right { position: absolute; right: calc(var(--u) * 4); bottom: calc(var(--u) * 4); text-align: right; }
.ammo-block { display: flex; align-items: baseline; gap: var(--u); justify-content: flex-end; }
.ammo-mag {
  font-family: var(--mono); font-size: 48px; line-height: 1;
  font-variant-numeric: tabular-nums; color: #fff;
  text-shadow: 0 0 18px rgba(79, 216, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.9);
}
.ammo-mag.dry { color: var(--danger); text-shadow: 0 0 18px rgba(255, 77, 82, 0.45); }
.ammo-reserve {
  font-family: var(--mono); font-size: 16px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.weapon-name {
  font-size: 11px; letter-spacing: 0.2em; color: var(--text-dim);
  margin-top: 4px; text-transform: uppercase;
}
.weapon-name span { color: var(--accent); }
.weapon-mode {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  color: var(--ok); margin-top: 2px;
}
.reload-hint {
  margin-top: var(--u); font-size: 10px; letter-spacing: 0.18em;
  color: var(--accent-hot); opacity: 0; transition: opacity 160ms linear;
}
.reload-hint.show { opacity: 1; animation: pulse 900ms ease-in-out infinite; }
.reload-hint b { font-family: var(--mono); }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- bottom bar ---------- */
.hud-bottom {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--u) * 2); display: flex; gap: calc(var(--u) * 2); align-items: center;
}
.enemies { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; color: var(--text); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
.enemies b { color: var(--accent-hot); font-variant-numeric: tabular-nums; }
.fps { font-family: var(--mono); font-size: 11px; color: var(--text-dim); opacity: 0; transition: opacity 150ms; }
.fps.show { opacity: 1; }

/* ---------- damage feedback ---------- */
.damage-vignette {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 40, 46, 0.55) 100%);
}
.damage-vignette.show { opacity: 1; transition: none; }
.damage-vignette.fade { opacity: 0; transition: opacity 420ms ease-out; }
.low-health {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(190, 20, 26, 0.4) 100%);
}
.low-health.show { opacity: 1; animation: breathe 1.5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* ---------- start / pause overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(18, 26, 34, 0.72), rgba(6, 8, 11, 0.94));
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.panel {
  width: min(560px, calc(100% - 32px)); padding: 40px;
  background: linear-gradient(180deg, rgba(20, 26, 33, 0.95), rgba(12, 16, 21, 0.95));
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center;
}
.brand {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.4em;
  color: var(--text-dim); margin-bottom: var(--u);
}
.brand b { color: var(--accent); }
.panel h1 {
  font-size: 26px; line-height: 1.25; letter-spacing: 0.06em; margin: 0 0 12px;
  font-weight: 650; text-transform: uppercase;
}
.lead { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0 auto 24px; max-width: 42ch; }
.cta {
  font: inherit; font-size: 15px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: #04141b; cursor: pointer;
  background: linear-gradient(180deg, #7ce8ff, #34b6dd);
  border: 0; border-radius: 8px; padding: 14px 28px; min-height: 44px;
  box-shadow: 0 8px 24px rgba(79, 216, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out, filter 150ms ease-out;
}
.cta:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 12px 30px rgba(79, 216, 255, 0.36); }
.cta:active { transform: translateY(1px); }
.cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.keys {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px;
  margin: 28px 0 20px; text-align: left;
}
.keys div { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.keys kbd {
  font-family: var(--mono); font-size: 10px; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; white-space: nowrap;
}
.foot { font-size: 11px; color: #5c6874; letter-spacing: 0.08em; }

@media (max-width: 640px) {
  .hud-left, .hud-right { left: 16px; right: 16px; bottom: 16px; }
  .hud-left { bottom: 56px; }
  .health-wrap { width: calc(100vw - 32px); }
  .ammo-mag { font-size: 34px; }
  .keys { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 24px; }
}
