/* ===========================================================================
   DEATH FROM ABOVE — HUD / overlay styling
   The 3D feed renders behind; everything here is a transparent overlay.
   =========================================================================== */

:root {
  --ir: #d8ffe0;          /* phosphor green-white */
  --ir-dim: #6f9c79;
  --warn: #ff5a4d;
  --amber: #ffcf6b;
  --hud-font: "Courier New", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--hud-font);
  color: var(--ir);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#viewport, #viewport canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ----- HUD root ----- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;          /* let clicks fall through to canvas */
  z-index: 10;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 0 6px rgba(120, 255, 150, 0.45);
}

.hud-block {
  position: absolute;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ir);
  opacity: 0.92;
}

.top-left  { top: 18px; left: 22px; }
.top-right { top: 18px; right: 22px; text-align: right; }
.bottom-left { bottom: 18px; left: 22px; }

.row { display: flex; gap: 10px; justify-content: space-between; min-width: 168px; }
.top-right .row { justify-content: flex-end; }
.lbl { color: var(--ir-dim); }
.val { color: var(--ir); font-weight: bold; }
.val.warn { color: var(--warn); }

/* ----- route progress ----- */
.route-progress {
  position: absolute;
  top: 88px;
  left: 50%;
  width: min(380px, calc(100vw - 44px));
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ir-dim);
}
.route-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-height: 16px;
  letter-spacing: 0.16em;
}
.route-head span:first-child {
  color: var(--ir);
  font-weight: bold;
}
.route-head span:first-child.warn {
  color: var(--warn);
  text-shadow: 0 0 8px rgba(255,90,77,0.65);
}
.route-bar {
  position: relative;
  height: 5px;
  margin-top: 5px;
  border: 1px solid rgba(216,255,224,0.34);
  background: rgba(8, 25, 13, 0.46);
}
.route-fill {
  width: 0%;
  height: 100%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255,207,107,0.62);
}
.route-city {
  position: absolute;
  top: -5px;
  right: -1px;
  width: 3px;
  height: 13px;
  background: var(--ir);
  box-shadow: 0 0 8px rgba(216,255,224,0.62);
}

/* ----- corner frame brackets ----- */
.frame-bracket {
  position: absolute;
  width: 46px; height: 46px;
  border: 2px solid rgba(150, 255, 170, 0.5);
}
.frame-bracket.tl { top: 12px;    left: 12px;    border-right: none; border-bottom: none; }
.frame-bracket.tr { top: 12px;    right: 12px;   border-left: none;  border-bottom: none; }
.frame-bracket.bl { bottom: 12px; left: 12px;    border-right: none; border-top: none; }
.frame-bracket.br { bottom: 12px; right: 12px;   border-left: none;  border-top: none; }

/* ----- center reticle ----- */
.reticle {
  position: absolute;
  top: 50%; left: 50%;
  width: 260px; height: 260px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.reticle .ret-svg {
  position: absolute; inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 3px rgba(140,255,160,0.6));
}
.reticle.locked .ret-svg { filter: drop-shadow(0 0 5px rgba(255,80,70,0.9)); }

/* each weapon uses an inline-SVG background, scaled differently */
.reticle-25  .ret-svg { background-image: var(--ret25);  background-size: 120px 120px; }
.reticle-40  .ret-svg { background-image: var(--ret40);  background-size: 200px 200px; }
.reticle-105 .ret-svg { background-image: var(--ret105); background-size: 260px 260px; }

.lock-tag {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -240%);
  font-size: 11px; color: var(--warn); font-weight: bold;
  letter-spacing: 0.12em;
  opacity: 0; transition: opacity 0.08s;
  text-shadow: 0 0 6px rgba(255,80,70,0.7);
}
.reticle.locked .lock-tag { opacity: 1; }

.range-tag {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, 210%);
  font-size: 11px; color: var(--ir-dim); letter-spacing: 0.12em;
}

/* ----- bottom-center weapon + ammo ----- */
.bottom-center {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.weapon-strip { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.wpn {
  border: 1px solid rgba(150,255,170,0.35);
  padding: 4px 12px; font-size: 12px;
  color: var(--ir-dim);
  background: rgba(10, 30, 16, 0.35);
}
.wpn.active { color: #04150a; background: var(--ir); border-color: var(--ir); text-shadow: none; }
.wpn .key { color: var(--amber); margin-right: 7px; }
.wpn.active .key { color: #04150a; }

.ammo-line { font-size: 16px; font-weight: bold; display: flex; gap: 18px; justify-content: center; }
.ammo-line .ammo { color: var(--amber); }
.ammo-line.empty .ammo { color: var(--warn); animation: blink 0.6s steps(2) infinite; }

.reload-wrap {
  margin: 7px auto 0; width: 240px; height: 4px;
  background: rgba(150,255,170,0.15);
  display: none;
}
.reload-wrap.active { display: block; }
.reload-bar { height: 100%; width: 0%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.reload-wrap.hot .reload-bar { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.reload-wrap.cooldown .reload-bar { background: var(--ir); box-shadow: 0 0 8px var(--ir); }

@keyframes blink { 50% { opacity: 0.25; } }

/* ----- mission banner ----- */
.banner {
  position: absolute;
  top: 19%; left: 50%;
  transform: translateX(-50%);
  font-size: 22px; font-weight: bold; letter-spacing: 0.18em;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255,200,90,0.7);
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
  text-align: center;
}
.banner.show { opacity: 1; }

/* ----- hint ----- */
.hint { font-size: 11px; color: var(--ir-dim); line-height: 1.7; }

/* ----- mobile / controller controls ----- */
.touch-controls,
.touch-view,
.mobile-status {
  display: none;
}
body.touch-mode .hud-block.hint,
body.touch-mode .hud-block.top-left,
body.touch-mode .hud-block.top-right,
body.touch-mode .hud-block.bottom-center,
body.touch-mode .frame-bracket,
body.controller-mode .hud-block.hint {
  display: none;
}
body.touch-mode .touch-controls {
  display: block;
  pointer-events: auto;
}
body.touch-mode .touch-view,
body.touch-mode .mobile-status {
  display: flex;
}
body.touch-mode .route-progress {
  top: max(12px, env(safe-area-inset-top));
  width: min(320px, calc(100vw - 184px));
  font-size: 10px;
}
body.touch-mode .reticle {
  width: 220px;
  height: 220px;
}
body.touch-mode .reticle-25 .ret-svg { background-size: 106px 106px; }
body.touch-mode .reticle-40 .ret-svg { background-size: 172px 172px; }
body.touch-mode .reticle-105 .ret-svg { background-size: 220px 220px; }
body.touch-mode .range-tag {
  transform: translate(-50%, 190%);
}
body.touch-mode .banner {
  top: 15%;
  max-width: calc(100vw - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
}
.touch-view {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 42px;
  font-family: var(--hud-font);
  font-size: 12px;
  font-weight: bold;
  color: var(--ir);
  background: rgba(6, 18, 10, 0.56);
  border: 1px solid rgba(150,255,170,0.46);
  pointer-events: auto;
  touch-action: none;
}
.mobile-status {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--ir);
  background: rgba(4, 14, 8, 0.36);
}
.mobile-status span:first-child {
  color: var(--amber);
}
.touch-aim-pad {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: clamp(132px, 24vw, 180px);
  height: clamp(132px, 24vw, 180px);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}
.touch-aim-pad::before,
.touch-aim-pad::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}
.touch-aim-pad::before {
  inset: 12%;
  border: 1px solid rgba(216,255,224,0.34);
  background:
    linear-gradient(90deg, transparent 16%, rgba(216,255,224,0.12) 49%, rgba(216,255,224,0.24) 50%, rgba(216,255,224,0.12) 51%, transparent 84%),
    linear-gradient(0deg, transparent 16%, rgba(216,255,224,0.12) 49%, rgba(216,255,224,0.24) 50%, rgba(216,255,224,0.12) 51%, transparent 84%),
    radial-gradient(circle at 50% 50%, rgba(60, 110, 72, 0.22), rgba(4, 14, 8, 0.72) 70%);
  box-shadow: 0 0 22px rgba(90, 255, 135, 0.13);
}
.touch-aim-pad::after {
  inset: 49%;
  background: rgba(216,255,224,0.35);
  box-shadow: 0 0 10px rgba(216,255,224,0.24);
}
.touch-aim-thumb {
  position: absolute;
  left: 35.5%;
  top: 35.5%;
  width: 29%;
  height: 29%;
  border-radius: 50%;
  border: 1px solid rgba(216,255,224,0.36);
  background: radial-gradient(circle at 35% 30%, rgba(236,255,240,0.45), rgba(75, 120, 82, 0.36) 42%, rgba(8, 24, 13, 0.92) 100%);
  box-shadow: 0 8px 16px rgba(0,0,0,0.34);
  transition: transform 0.05s linear, box-shadow 0.12s ease;
}
.touch-aim-pad.is-active .touch-aim-thumb {
  box-shadow: 0 0 20px rgba(216,255,224,0.26), 0 8px 16px rgba(0,0,0,0.36);
}
.touch-actions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.t-cycle,
.t-fire {
  font-family: var(--hud-font);
  font-weight: bold;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.t-cycle {
  width: clamp(58px, 11vw, 76px);
  height: clamp(58px, 11vw, 76px);
  border-radius: 50%;
  color: var(--amber);
  background: rgba(18, 23, 12, 0.62);
  border: 1px solid rgba(255,207,107,0.55);
  font-size: clamp(15px, 2.9vw, 18px);
}
.t-fire {
  width: clamp(92px, 17vw, 122px);
  height: clamp(92px, 17vw, 122px);
  border-radius: 50%;
  color: var(--warn);
  background: radial-gradient(circle at 35% 30%, rgba(255,130,84,0.22), rgba(54,13,10,0.88) 70%);
  border: 1px solid rgba(255,90,77,0.72);
  font-size: clamp(16px, 3.3vw, 20px);
  box-shadow: 0 0 24px rgba(255,90,77,0.16);
}
.t-fire.is-pressed,
.t-fire:active,
.t-cycle:active,
.touch-view:active {
  transform: scale(0.96);
}

.rotate-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: #020704;
  color: var(--ir);
  text-align: center;
  pointer-events: auto;
}
body.needs-landscape .rotate-screen {
  display: flex;
}
body.needs-landscape .start-screen,
body.needs-landscape .hud {
  display: none;
}
.rotate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.18em;
}
.rotate-icon {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(216,255,224,0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: var(--amber);
}

/* ----- start screen ----- */
.start-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,20,16,0.55) 0%, rgba(0,0,0,0.86) 78%);
}
.start-screen.hidden { display: none; }
.start-card {
  max-width: 560px; padding: 32px 36px; text-align: center;
  border: 1px solid rgba(150,255,170,0.3);
  background: rgba(6, 18, 10, 0.7);
}
.start-card h1 { margin: 0 0 4px; font-size: 38px; letter-spacing: 0.12em; color: var(--ir); }
.start-card h2 { margin: 0 0 18px; font-size: 14px; letter-spacing: 0.22em; color: var(--ir-dim); font-weight: normal; }
.brief { font-size: 13px; line-height: 1.7; color: #b9e9c4; text-transform: none; letter-spacing: 0.01em; }
.brief b { color: var(--amber); }
.engage-btn {
  margin-top: 20px; padding: 14px 30px;
  font-family: var(--hud-font); font-size: 16px; font-weight: bold; letter-spacing: 0.14em;
  color: #04150a; background: var(--ir); border: none; cursor: pointer;
  box-shadow: 0 0 22px rgba(150,255,170,0.55);
}
.engage-btn:hover { background: #fff; }
.start-foot { margin-top: 18px; font-size: 11px; color: var(--ir-dim); letter-spacing: 0.18em; }

/* ----- debrief ----- */
.debrief-screen {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.58);
}
.debrief-screen.hidden { display: none; }
.debrief-panel {
  width: min(620px, calc(100vw - 28px));
  padding: 28px 30px 30px;
  text-align: center;
  border: 1px solid rgba(216, 255, 224, 0.34);
  background: rgba(5, 16, 10, 0.86);
  box-shadow: 0 0 30px rgba(20, 80, 42, 0.34);
}
.debrief-kicker {
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0.26em;
  font-weight: bold;
}
.debrief-panel h2 {
  margin: 8px 0 20px;
  color: var(--ir);
  font-size: 28px;
  letter-spacing: 0.14em;
}
.debrief-screen.failed .debrief-kicker,
.debrief-screen.failed .debrief-panel h2 {
  color: var(--warn);
}
.debrief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.debrief-grid div {
  min-height: 66px;
  padding: 11px 10px;
  border: 1px solid rgba(216, 255, 224, 0.18);
  background: rgba(216, 255, 224, 0.06);
}
.debrief-grid span,
.debrief-grid b {
  display: block;
}
.debrief-grid span {
  color: var(--ir-dim);
  font-size: 11px;
  letter-spacing: 0.16em;
}
.debrief-grid b {
  margin-top: 8px;
  color: var(--ir);
  font-size: 18px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}
.debrief-restart { margin-top: 24px; }

/* ----- loading ----- */
.loading {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: var(--ir-dim); font-size: 14px; letter-spacing: 0.2em;
}
.loading.hidden { display: none; }

@media (max-width: 560px) {
  .route-progress { top: 140px; }
  .banner { top: 22%; }
  .debrief-panel { padding: 22px 18px 24px; }
  .debrief-panel h2 { font-size: 22px; }
  .debrief-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
