:root {
  --amber: #ffb454;
  --amber-dim: #c98a3a;
  --ink: #14120e;
  --paper: #f3e9d7;
  --gap: 6px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d0b08; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--paper);
  user-select: none;
  -webkit-user-select: none;
}
#app, #app canvas { position: fixed; inset: 0; }

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

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  transition: opacity 0.12s;
}
.ch-line { position: absolute; background: rgba(255, 244, 220, 0.9); box-shadow: 0 0 3px rgba(0,0,0,0.8); }
.ch-t { width: 2px; height: 9px; left: -1px; top: calc(-1 * var(--gap) - 9px); }
.ch-b { width: 2px; height: 9px; left: -1px; top: var(--gap); }
.ch-l { width: 9px; height: 2px; top: -1px; left: calc(-1 * var(--gap) - 9px); }
.ch-r { width: 9px; height: 2px; top: -1px; left: var(--gap); }
.ch-dot { position: absolute; width: 2px; height: 2px; left: -1px; top: -1px; background: rgba(255,244,220,0.9); }

.reticle { position: absolute; left: 50%; top: 50%; opacity: 0; transition: opacity 0.1s; pointer-events: none; }
.rd-dot { position: absolute; width: 5px; height: 5px; left: -2.5px; top: -2.5px; border-radius: 50%;
  background: #ff3524; box-shadow: 0 0 6px #ff3524, 0 0 2px #ff3524; }
.holo-ring { position: absolute; width: 46px; height: 46px; left: -23px; top: -23px; border-radius: 50%;
  border: 2px solid rgba(80, 255, 170, 0.75); box-shadow: 0 0 6px rgba(80,255,170,0.4); }
.holo-dot { position: absolute; width: 4px; height: 4px; left: -2px; top: -2px; border-radius: 50%;
  background: #50ffaa; box-shadow: 0 0 5px #50ffaa; }
.sc-h { position: absolute; width: 46vmin; height: 2px; left: -23vmin; top: -1px; background: rgba(15,15,15,0.95); box-shadow: 0 0 2px rgba(255,255,255,0.6); }
.sc-v { position: absolute; width: 2px; height: 46vmin; left: -1px; top: -23vmin; background: rgba(15,15,15,0.95); box-shadow: 0 0 2px rgba(255,255,255,0.6); }
#scope-overlay {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.12s;
  background: radial-gradient(circle at 50% 50%, transparent 26vmin, rgba(5,5,5,0.985) 27.5vmin);
}
#scope-overlay::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 53vmin; height: 53vmin;
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 2px solid rgba(30,30,30,0.9); box-shadow: inset 0 0 40px rgba(0,0,0,0.6);
}

#hitmarker { position: absolute; left: 50%; top: 50%; opacity: 0; }
#hitmarker span { position: absolute; width: 10px; height: 2px; background: #fff; box-shadow: 0 0 4px #000; }
#hitmarker span:nth-child(1) { transform: translate(-14px, -9px) rotate(45deg); }
#hitmarker span:nth-child(2) { transform: translate(4px, -9px) rotate(-45deg); }
#hitmarker span:nth-child(3) { transform: translate(-14px, 7px) rotate(-45deg); }
#hitmarker span:nth-child(4) { transform: translate(4px, 7px) rotate(45deg); }
#hitmarker.show { animation: hitpop 0.28s ease-out; }
#hitmarker.kill span { background: #ff5030; }
@keyframes hitpop { 0% { opacity: 1; transform: scale(1.4); } 100% { opacity: 0; transform: scale(0.9); } }

#ammo-panel {
  position: absolute; right: 28px; bottom: 24px; text-align: right;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
#hud-build { font-size: 11px; letter-spacing: 0.14em; color: var(--amber); opacity: 0.9; text-transform: uppercase; }
#ammo-row { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#ammo-mag.low { color: #ff5030; }
#ammo-sep { color: var(--amber-dim); margin: 0 4px; font-size: 30px; }
#ammo-reserve { font-size: 24px; color: rgba(243,233,215,0.75); }
#fire-mode { font-size: 13px; letter-spacing: 0.3em; color: var(--amber); margin-top: 4px; }

#stats-panel {
  position: absolute; left: 28px; bottom: 24px; font-size: 12px; letter-spacing: 0.12em;
  color: rgba(243,233,215,0.85); text-shadow: 0 1px 3px rgba(0,0,0,0.9); line-height: 1.7;
}
#stats-panel b { color: var(--amber); font-variant-numeric: tabular-nums; margin-left: 6px; }

#hint {
  position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%);
  font-size: 13px; letter-spacing: 0.18em; color: var(--paper); text-shadow: 0 1px 3px #000;
}
#toast {
  position: absolute; left: 50%; top: 20%; transform: translateX(-50%);
  font-size: 14px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber);
  text-shadow: 0 1px 4px #000; opacity: 0; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
#controls-strip {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.1em; color: rgba(243,233,215,0.45); white-space: nowrap;
}

/* ---------- Field kit ---------- */
#kit {
  position: fixed; inset: 0; z-index: 20; display: none;
  background: rgba(12, 10, 7, 0.72); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#kit.open { display: flex; }
#kit-panel {
  width: min(1060px, 94vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(160deg, #211c14, #171310);
  border: 1px solid rgba(255, 180, 84, 0.35); border-radius: 10px;
  padding: 22px 26px; box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}
#kit-head h2 { letter-spacing: 0.35em; color: var(--amber); font-size: 20px; }
#kit-head p { font-size: 12px; color: rgba(243,233,215,0.7); margin: 6px 0 14px; }
#kit-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kit-cat-label {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--amber-dim);
  margin-bottom: 7px; display: flex; align-items: center; gap: 6px;
}
.kit-key {
  display: inline-flex; width: 16px; height: 16px; border: 1px solid var(--amber-dim); border-radius: 3px;
  font-size: 9px; align-items: center; justify-content: center; color: var(--amber);
}
.kit-opt {
  display: block; width: 100%; text-align: left; margin-bottom: 6px; padding: 7px 9px;
  background: rgba(255, 244, 220, 0.05); border: 1px solid rgba(255, 244, 220, 0.14);
  border-radius: 6px; color: var(--paper); cursor: pointer; transition: all 0.12s;
}
.kit-opt:hover { background: rgba(255, 180, 84, 0.14); border-color: var(--amber-dim); }
.kit-opt.active { background: rgba(255, 180, 84, 0.2); border-color: var(--amber); box-shadow: 0 0 10px rgba(255,180,84,0.25); }
.kit-opt-name { display: block; font-size: 12px; font-weight: 600; }
.kit-opt-desc { display: block; font-size: 9.5px; color: rgba(243,233,215,0.55); margin-top: 3px; line-height: 1.35; }
#kit-foot { margin-top: 16px; display: flex; align-items: flex-end; gap: 26px; flex-wrap: wrap; }
#kit-bars { flex: 1; min-width: 300px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.bar-label { width: 78px; color: rgba(243,233,215,0.7); }
.bar-track { flex: 1; height: 5px; background: rgba(255,244,220,0.1); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--amber); border-radius: 3px; transition: width 0.25s; }
.bar-fill.invert { background: #e0684a; }
#kit-summary { font-size: 12px; color: var(--amber); letter-spacing: 0.08em; }
.kit-note { width: 100%; font-size: 10px; color: rgba(243,233,215,0.45); letter-spacing: 0.14em; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: none;
  background: rgba(10, 8, 5, 0.78); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.overlay.open { display: flex; }
.overlay-panel {
  width: min(620px, 92vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(165deg, #221c13, #15110d);
  border: 1px solid rgba(255, 180, 84, 0.4); border-radius: 12px;
  padding: 34px 38px; text-align: center; box-shadow: 0 30px 90px rgba(0,0,0,0.8);
}
.overlay-panel h1 { letter-spacing: 0.22em; color: var(--amber); font-size: 30px; line-height: 1.25; }
.overlay-panel h3 { letter-spacing: 0.3em; color: var(--amber-dim); font-size: 12px; margin: 18px 0 6px; }
.tagline { margin: 10px 0; font-size: 14px; color: var(--paper); letter-spacing: 0.06em; }
.desc { font-size: 12.5px; line-height: 1.65; color: rgba(243,233,215,0.72); }
.controls-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 18px 0 4px;
  font-size: 11.5px; color: rgba(243,233,215,0.8); text-align: left;
}
.controls-grid b { color: var(--amber); }
.pause-build-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 6px; }
.pause-build-list span {
  font-size: 10.5px; padding: 3px 9px; border: 1px solid rgba(255,180,84,0.4);
  border-radius: 20px; color: var(--paper); letter-spacing: 0.06em;
}
.pause-build-stats { font-size: 11px; color: rgba(243,233,215,0.6); }
.big-btn {
  margin-top: 22px; padding: 13px 42px; font-size: 15px; letter-spacing: 0.3em; font-weight: 700;
  color: var(--ink); background: linear-gradient(180deg, #ffc06a, #e89a3e); border: none; border-radius: 8px;
  cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.big-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(255, 180, 84, 0.4); }
.fine { margin-top: 14px; font-size: 10.5px; color: rgba(243,233,215,0.45); letter-spacing: 0.08em; }

/* ---------- Mobile notice ---------- */
#mobile-note {
  position: fixed; inset: auto 0 0 0; z-index: 40; display: none;
  padding: 14px; text-align: center; font-size: 12px; line-height: 1.5;
  background: rgba(12, 10, 7, 0.92); color: var(--amber); letter-spacing: 0.06em;
}
@media (max-width: 760px), (pointer: coarse) {
  #mobile-note { display: block; }
  #controls-strip { display: none; }
  #ammo-row { font-size: 32px; }
  #kit-grid { grid-template-columns: repeat(2, 1fr); }
}
