:root {
  color-scheme: dark;
  --bg: #050608;
  --hud: #c8f0d8;
  --hud-dim: rgba(200, 240, 216, 0.55);
  --hot: #ff4d4d;
  --amber: #f5c542;
  --plate: rgba(6, 10, 14, 0.72);
  --plate-edge: rgba(200, 240, 216, 0.28);
  --plate-edge-hot: rgba(245, 197, 66, 0.45);
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Menlo, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font);
  color: #e8eef5;
  user-select: none;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Boot */
#boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(800px 400px at 50% 20%, rgba(180, 40, 40, 0.25), transparent 60%),
    linear-gradient(180deg, #0a0c10, #050608 70%);
}

.boot-inner { text-align: center; padding: 24px; max-width: 520px; }

.boot-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  color: #8a939e;
  margin-bottom: 14px;
}

#boot h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff 20%, #c44 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}

.boot-sub {
  color: #8a939e;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 6px;
  text-align: left;
  margin: 0 auto 14px;
  max-width: 320px;
}
.field span {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: #8a939e;
  text-transform: uppercase;
}
.field input {
  appearance: none;
  border: 1px solid #3a4450;
  background: #0c1018;
  color: #fff;
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 4px;
  width: 100%;
}
.field input:focus {
  outline: none;
  border-color: #c44;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 360px;
  margin: 0 auto 18px;
}
.mode-btn {
  appearance: none;
  border: 1px solid #2a3340;
  background: #0c1018;
  color: #c8d0da;
  padding: 12px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.mode-btn strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: #fff;
}
.mode-btn span {
  font-size: 0.72rem;
  color: #7a8798;
}
.mode-btn.active {
  border-color: #c44;
  background: rgba(180, 40, 40, 0.2);
  box-shadow: 0 0 0 1px rgba(200, 60, 60, 0.3);
}

.boot-status {
  min-height: 1.2em;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #f5c542;
}
.boot-help {
  margin-top: 14px;
  font-size: 0.72rem;
  color: #5c6570;
  line-height: 1.4;
}

#match-end {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
}
#match-end.hidden { display: none; }
.match-card {
  background: #10161f;
  border: 1px solid #3a4450;
  border-radius: 12px;
  padding: 28px 32px;
  min-width: min(360px, 92vw);
  text-align: center;
}
.match-card h2 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  letter-spacing: 0.06em;
}
#match-board {
  list-style: none;
  margin: 0 0 20px;
  text-align: left;
}
#match-board li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #1c2530;
  font-family: var(--mono);
  font-size: 0.85rem;
}

#match-info {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 16px;
  color: #fff;
}
#match-score { color: var(--amber); }

#roster {
  position: absolute;
  top: 70px;
  left: 24px;
  min-width: 140px;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 8px;
}
.roster-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  color: #b8c0cc;
}
.roster-row.me { color: #5eead4; font-weight: 700; }

.boot-btn {
  appearance: none;
  border: 1px solid #c44;
  background: linear-gradient(180deg, #8b1e1e, #5a1010);
  color: #fff;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 14px 36px;
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 0 30px rgba(200, 40, 40, 0.35);
}

.boot-btn:hover { filter: brightness(1.1); }

.boot-links {
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #5c6570;
}

.boot-links a { color: #8a939e; text-decoration: none; }
.boot-links a:hover { color: #c8f0d8; }

#boot.hidden { display: none; }

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

#hud.hidden { display: none; }

/* Permanent cinematic vignette (grade weight; damage vignette stacks on top) */
#film-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 75% at 50% 48%, transparent 60%, rgba(0, 0, 0, 0.14) 100%);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

#hit-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.35), transparent 55%);
  z-index: 2;
  transition: opacity 0.05s;
}
#hit-flash.on { opacity: 1; }
#hit-flash.kill {
  background: radial-gradient(circle at 50% 50%, rgba(255,80,80,0.4), transparent 50%);
}

#inv-bar {
  position: absolute;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}
.inv-slot {
  min-width: 72px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #9ab;
  text-align: center;
}
.inv-slot span {
  display: block;
  color: #667;
  font-size: 0.6rem;
  margin-bottom: 2px;
}
.inv-slot.active {
  border-color: #f5c542;
  color: #fff;
  box-shadow: 0 0 12px rgba(245,197,66,0.25);
}
.inv-slot.empty { opacity: 0.4; }

#mission-hud {
  position: absolute;
  top: 78px;
  right: 24px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #f5c542;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(245,197,66,0.35);
  padding: 6px 12px;
  z-index: 5;
}
#mission-hud.hidden { display: none; }

/* —— Crosshair (CoD-like sparse center) —— */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  z-index: 5;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(220, 245, 230, 0.92);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.95), 0 0 1px #000;
}

#crosshair::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  /* gap at center */
  clip-path: polygon(0 0, 100% 0, 100% 32%, 0 32%, 0 68%, 100% 68%, 100% 100%, 0 100%);
}

#crosshair::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
  clip-path: polygon(0 0, 32% 0, 32% 100%, 0 100%, 0 0, 68% 0, 68% 100%, 100% 100%, 100% 0);
}

#crosshair.fire {
  filter: brightness(2.2);
  transform: translate(-50%, -50%) scale(0.82);
}

/* —— Hitmarker (CoD X arms, snap + kill red) —— */
#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

#hitmarker.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 0.04s linear, transform 0.05s cubic-bezier(0.2, 1.4, 0.4, 1);
}

#hitmarker::before,
#hitmarker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 2px;
  background: #fff;
  box-shadow: 0 0 3px #000, 0 0 1px #000;
}

/* four arms via two rotated bars with center gap */
#hitmarker::before {
  transform: translate(-50%, -50%) rotate(45deg);
  clip-path: polygon(0 0, 32% 0, 32% 100%, 0 100%, 0 0, 68% 0, 100% 0, 100% 100%, 68% 100%, 68% 0);
}

#hitmarker::after {
  transform: translate(-50%, -50%) rotate(-45deg);
  clip-path: polygon(0 0, 32% 0, 32% 100%, 0 100%, 0 0, 68% 0, 100% 0, 100% 100%, 68% 100%, 68% 0);
}

#hitmarker.kill::before,
#hitmarker.kill::after {
  background: #ff3b3b;
  box-shadow: 0 0 6px rgba(255, 40, 40, 0.85), 0 0 2px #000;
  height: 2.5px;
  width: 13px;
}

/* Headshot: warm gold X (kill still red, slightly thicker) */
#hitmarker.head::before,
#hitmarker.head::after {
  background: #ffd24a;
  box-shadow: 0 0 5px rgba(255, 200, 40, 0.9), 0 0 2px #000;
  height: 2.4px;
  width: 12px;
}

#hitmarker.head.kill::before,
#hitmarker.head.kill::after {
  background: #ff4a2a;
  box-shadow: 0 0 8px rgba(255, 60, 30, 0.95), 0 0 2px #000;
  height: 2.8px;
  width: 14px;
}

#damage-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 80px rgba(180, 0, 0, 0);
  transition: box-shadow 0.15s;
  pointer-events: none;
  z-index: 1;
}

#damage-vignette.on {
  box-shadow: inset 0 0 140px rgba(180, 0, 0, 0.58);
}

/* —— Bottom plates —— */
.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  padding: 0 28px;
  align-items: flex-end;
  z-index: 4;
  gap: 16px;
}

.hud-health {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.hp-chrome {
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-left: 3px solid var(--hud);
  padding: 8px 12px 8px 10px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}

.hud-health .label,
.wpn,
.ammo-sub {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--hud-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.hud-health .bar {
  position: relative;
  width: 188px;
  height: 11px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(200, 240, 216, 0.28);
  margin-bottom: 6px;
  overflow: hidden;
}

.hud-health .bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #1a7a58 0%, #2ecc8a 55%, #7dffe0 100%);
  box-shadow: 0 0 12px rgba(80, 255, 180, 0.45);
  transition: width 0.08s linear;
}

/* Segment ticks over HP bar */
.hud-health .bar-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(10% - 1px),
      rgba(0, 0, 0, 0.45) calc(10% - 1px),
      rgba(0, 0, 0, 0.45) 10%
    );
  opacity: 0.85;
}

.hp-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

#hp-text {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--hud);
  line-height: 1;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9), 0 1px 0 #000;
  font-variant-numeric: tabular-nums;
}

.hp-max {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(200, 240, 216, 0.4);
  letter-spacing: 0.06em;
}

.hud-health.hurt .hp-chrome {
  border-left-color: var(--amber);
}

.hud-health.hurt #hp-text { color: var(--amber); }

.hud-health.hurt .bar i {
  background: linear-gradient(90deg, #8a6010, #f5c542);
  box-shadow: 0 0 12px rgba(245, 197, 66, 0.4);
}

.hud-health.critical .hp-chrome {
  border-left-color: var(--hot);
  box-shadow:
    0 0 0 1px rgba(255, 60, 60, 0.25),
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 0 20px rgba(180, 0, 0, 0.15);
}

.hud-health.critical #hp-text {
  color: var(--hot);
  animation: hp-pulse 0.7s ease-in-out infinite;
}

.hud-health.critical .bar i {
  background: linear-gradient(90deg, #7a1010, #ff4d4d);
  box-shadow: 0 0 14px rgba(255, 60, 60, 0.55);
}

@keyframes hp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Stance dots (stand / sprint / ads) */
#stance {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--plate);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 2px solid rgba(200, 240, 216, 0.35);
  width: fit-content;
}

#stance .dot {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: rgba(200, 240, 216, 0.18);
  border: 1px solid rgba(200, 240, 216, 0.28);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  transform: rotate(45deg);
}

#stance .stance-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: var(--hud-dim);
  margin-left: 4px;
}

#stance[data-stance="stand"] .dot[data-s="stand"],
#stance[data-stance="sprint"] .dot[data-s="sprint"],
#stance[data-stance="ads"] .dot[data-s="ads"] {
  background: var(--hud);
  border-color: var(--hud);
  box-shadow: 0 0 8px rgba(120, 255, 190, 0.55);
}

#stance[data-stance="stand"] .stance-label { content: "STAND"; }
#stance[data-stance="sprint"] .stance-label {
  color: var(--amber);
}
#stance[data-stance="ads"] .stance-label {
  color: #9ecfff;
}

#stance[data-stance="stand"] .stance-label::before { content: none; }

/* label text via attr fallback — set content from data */
#stance[data-stance="stand"] .stance-label { color: var(--hud-dim); }
#stance .stance-label { font-size: 0; }
#stance .stance-label::after {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  content: "STAND";
}
#stance[data-stance="sprint"] .stance-label::after { content: "SPRINT"; color: var(--amber); }
#stance[data-stance="ads"] .stance-label::after { content: "ADS"; color: #9ecfff; }
#stance[data-stance="sprint"] .dot[data-s="sprint"] {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 8px rgba(245, 197, 66, 0.55);
}
#stance[data-stance="ads"] .dot[data-s="ads"] {
  background: #9ecfff;
  border-color: #9ecfff;
  box-shadow: 0 0 8px rgba(120, 180, 255, 0.55);
}

/* Ammo plate */
.hud-ammo {
  text-align: right;
  font-family: var(--mono);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-right: 3px solid rgba(255, 255, 255, 0.55);
  padding: 8px 14px 10px;
  min-width: 148px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}

.hud-ammo .wpn {
  margin-bottom: 2px;
  color: rgba(220, 230, 240, 0.7);
}

.ammo-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  line-height: 1;
}

#ammo-mag {
  font-size: 2.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.slash {
  color: #556;
  font-size: 1.5rem;
  margin: 0 3px 0 2px;
  font-weight: 600;
}

#ammo-res {
  font-size: 1.25rem;
  color: #9ab;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ammo-sub {
  margin-top: 4px;
  margin-bottom: 0;
  opacity: 0.75;
}

#ammo-plate.low #ammo-mag {
  color: var(--amber);
  text-shadow: 0 0 12px rgba(245, 197, 66, 0.45);
}

#ammo-plate.low {
  border-right-color: var(--amber);
  border-color: var(--plate-edge-hot);
}

#ammo-plate.empty #ammo-mag {
  color: var(--hot);
  animation: hp-pulse 0.55s ease-in-out infinite;
}

#ammo-plate.empty {
  border-right-color: var(--hot);
}

/* —— Top chrome —— */
.hud-top {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 4;
}

#compass {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: rgba(200, 240, 216, 0.9);
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-top: 2px solid rgba(200, 240, 216, 0.4);
  padding: 5px 22px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  min-width: 56px;
  text-align: center;
}

#killfeed {
  position: absolute;
  top: 52px;
  right: 20px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #ddd;
  line-height: 1.55;
  text-shadow: 0 1px 3px #000;
  z-index: 4;
  max-width: 280px;
}

#killfeed > div {
  background: rgba(0, 0, 0, 0.4);
  border-right: 2px solid rgba(200, 80, 80, 0.65);
  padding: 2px 8px 2px 10px;
  margin-bottom: 3px;
}

#scoreboard {
  position: absolute;
  top: 14px;
  left: 18px;
  display: flex;
  gap: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: #9ab;
  background: var(--plate);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--amber);
  padding: 0;
  z-index: 4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

#scoreboard .sb-cell,
#scoreboard #round-tag {
  padding: 7px 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

#scoreboard .sb-cell:last-of-type {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

#scoreboard b {
  color: #fff;
  font-weight: 700;
  margin-left: 2px;
}

#round-tag {
  color: var(--amber);
  letter-spacing: 0.1em;
  font-weight: 700;
  border-right: none !important;
  background: linear-gradient(180deg, rgba(245, 197, 66, 0.12), transparent);
}

#prompt {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 16px;
  border-left: 3px solid var(--amber);
  z-index: 4;
}

#prompt.hidden { display: none; }

/* Floating damage numbers (CoD-like hit readability) */
.dmg-float {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 1.4rem;
  color: #fff;
  text-shadow: 0 0 6px #000, 0 2px 0 #c00;
  pointer-events: none;
  z-index: 20;
  animation: dmgUp 0.55s ease-out forwards;
}
.dmg-float.head { color: #fbbf24; font-size: 1.7rem; }
.dmg-float.kill { color: #ff4d4d; font-size: 1.85rem; }
@keyframes dmgUp {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1.15); }
}
#minimap {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 120px;
  height: 120px;
  border-radius: 4px;
  border: 2px solid rgba(200,240,216,0.35);
  background: rgba(10, 18, 14, 0.75);
  overflow: hidden;
  z-index: 5;
}
#minimap canvas { width: 100%; height: 100%; display: block; }
