:root {
  --head: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, "Roboto Mono", Menlo, Consolas, monospace;
  --ink: #e9f4ec;
  --ink-dim: rgba(233, 244, 236, .55);
  --accent: #9dffb0;
  --accent-dim: rgba(157, 255, 176, .22);
  --danger: #ff4a3a;
  --panel: rgba(5, 9, 8, .78);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #05080a;
  font-family: var(--head);
  color: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#camera { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
#sky-fallback {
  position: fixed; inset: 0; z-index: 0;
  background: linear-gradient(180deg, #1c2833 0%, #3a4a5a 45%, #776f60 85%, #453e33 100%);
}
#sky-fallback[hidden] { display: none; }
#gl { position: fixed; inset: 0; z-index: 1; }
#radar { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

/* ---------- Combat visor grade (gameplay) ---------- */
/* Sits above the camera + 3D but below the HUD/menus. Menus (z-9+) cover it, so
   it only tints the actual gameplay view — unifying it with the menu's aesthetic. */
#combat-visor {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(ellipse 92% 82% at 50% 46%, transparent 52%, rgba(1, 8, 5, .62) 100%),
    radial-gradient(ellipse 130% 110% at 50% 50%, transparent 66%, rgba(30, 140, 74, .12) 100%);
}
.cv-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .10) 0 1px, transparent 1px 3px);
  opacity: .45;
  animation: scan-move 9s linear infinite;
}
/* Faint HUD corner ticks so gameplay reads as a tactical display */
#combat-visor::before, #combat-visor::after {
  content: ''; position: absolute; width: 20px; height: 20px;
  border: 2px solid rgba(157, 255, 176, .3);
}
#combat-visor::before { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
#combat-visor::after  { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }
body.nv #combat-visor { display: none; } /* night vision has its own look */

.radar-arrow {
  position: absolute;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 13px solid var(--danger);
  filter: drop-shadow(0 0 5px rgba(255, 40, 20, .55));
  transition: opacity .2s;
}

/* ---------- Night vision ---------- */

body.nv #camera {
  filter: grayscale(1) brightness(2.4) sepia(1) hue-rotate(55deg) saturate(4.5) contrast(1.12);
}
body.nv #gl, body.nv #sky-fallback {
  filter: grayscale(1) brightness(1.35) sepia(1) hue-rotate(55deg) saturate(4) contrast(1.08);
}

#nv-overlay { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#nv-overlay[hidden] { display: none; }
#nv-overlay::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0, 8, 0, 0.97);
  -webkit-mask-image:
    radial-gradient(ellipse 42vmin 46vmin at 34% 50%, transparent 92%, black 100%),
    radial-gradient(ellipse 42vmin 46vmin at 66% 50%, transparent 92%, black 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    radial-gradient(ellipse 42vmin 46vmin at 34% 50%, transparent 92%, black 100%),
    radial-gradient(ellipse 42vmin 46vmin at 66% 50%, transparent 92%, black 100%);
  mask-composite: intersect;
}
.nv-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 40, 0, 0.18) 0px, rgba(0, 40, 0, 0.18) 1px,
    transparent 1px, transparent 3px
  );
  mix-blend-mode: multiply;
}
.nv-flicker {
  position: absolute; inset: 0;
  background: rgba(120, 255, 140, 0.05);
  animation: nv-flicker 2.6s steps(12) infinite;
}
@keyframes nv-flicker {
  0%, 100% { opacity: .25 } 8% { opacity: .5 } 16% { opacity: .2 }
  34% { opacity: .45 } 50% { opacity: .15 } 71% { opacity: .55 } 88% { opacity: .3 }
}
body.nv .hud-cell { border-color: rgba(157, 255, 176, .4); }

/* ---------- Combat feedback ---------- */

#damage-vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(255, 30, 12, .5) 100%);
}
#damage-vignette.flash { animation: dmg .6s ease-out; }
@keyframes dmg { 0% { opacity: 1 } 100% { opacity: 0 } }

#muzzle-flash {
  position: fixed; left: 50%; bottom: 0; z-index: 3; pointer-events: none;
  width: 200px; height: 260px; transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 220, 140, .85) 0%, rgba(255, 160, 60, .3) 40%, transparent 70%);
  opacity: 0;
}
#muzzle-flash.fire { animation: muzzle .09s ease-out; }
@keyframes muzzle { 0% { opacity: 1 } 100% { opacity: 0 } }

#hitmarker {
  position: fixed; left: 50%; top: 50%; z-index: 5; pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 700; color: #fff;
  text-shadow: 0 0 8px rgba(255, 90, 50, .8);
  opacity: 0;
}
#hitmarker.hit { animation: hitm .22s ease-out; }
#hitmarker.kill { animation: hitm .32s ease-out; color: var(--danger); font-size: 34px; }
@keyframes hitm { 0% { opacity: 1; transform: translate(-50%,-50%) scale(1.35) } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.85) } }

#crosshair {
  position: fixed; left: 50%; top: 50%; z-index: 5; pointer-events: none;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}
#crosshair[hidden] { display: none; }
#crosshair span { position: absolute; background: rgba(255,255,255,.8); box-shadow: 0 0 3px rgba(0,0,0,.7); }
#crosshair span:nth-child(1) { left: 50%; top: 0;    width: 1.5px; height: 11px; transform: translateX(-50%); }
#crosshair span:nth-child(2) { left: 50%; bottom: 0; width: 1.5px; height: 11px; transform: translateX(-50%); }
#crosshair span:nth-child(3) { top: 50%; left: 0;    height: 1.5px; width: 11px; transform: translateY(-50%); }
#crosshair span:nth-child(4) { top: 50%; right: 0;   height: 1.5px; width: 11px; transform: translateY(-50%); }
#crosshair.reloading span { background: var(--accent); }
#crosshair { transition: transform .18s ease; }
#crosshair.ads { transform: translate(-50%, -50%) scale(.68); }
#crosshair.ads span { background: var(--accent); box-shadow: 0 0 6px rgba(157, 255, 176, .6); }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px; right: 12px;
  display: flex; gap: 6px; z-index: 6; align-items: stretch;
}
#hud[hidden] { display: none; }

.hud-cell {
  background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 6px 12px 7px;
  display: flex; flex-direction: column; gap: 1px;
  min-width: 64px;
  font-family: var(--head);
  color: var(--ink);
  /* staggered slide-in, armed by body.hud-live */
  opacity: 0; transform: translateY(-10px);
  transition: opacity .45s ease, transform .45s ease;
}
body.hud-live .hud-cell, body.hud-live #hp-wrap, body.hud-live #ammo-wrap { opacity: 1; transform: translateY(0); }
.hud-cell:nth-child(1) { transition-delay: .05s }
.hud-cell:nth-child(2) { transition-delay: .15s }
.hud-cell:nth-child(3) { transition-delay: .25s }
.hud-cell:nth-child(4) { transition-delay: .35s }

.hud-label {
  font-size: 9px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-dim);
}
.hud-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 700;
  line-height: 1.1;
}
.hud-btn { cursor: pointer; margin-left: auto; align-items: flex-start; }
#nv-btn.on { border-color: var(--accent); }
#nv-btn.on .hud-value { color: var(--accent); }

#bottom-hud {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  left: 16px; right: 16px; z-index: 6;
  display: flex; align-items: stretch; gap: 10px;
}
#bottom-hud[hidden] { display: none; }

#hp-wrap {
  flex: 1; height: 12px; border-radius: 3px; position: relative;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  overflow: hidden;
  align-self: center;
  opacity: 0; transform: translateY(10px);
  transition: opacity .45s ease .45s, transform .45s ease .45s;
}
#hp-ghost {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: rgba(255, 255, 255, .55);
  transition: width .7s ease .3s; /* catches down after the bar */
}
#hp-bar {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: var(--accent);
  transition: width .12s ease;
}
#hp-bar.low { background: var(--danger); }
#hp-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 9px; font-weight: 700; color: #04110a;
  mix-blend-mode: plus-lighter; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.7);
}

#ammo-wrap {
  font-family: var(--head); color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  border-radius: 8px; padding: 6px 14px 7px;
  cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 1px;
  opacity: 0; transform: translateY(10px);
  transition: opacity .45s ease .55s, transform .45s ease .55s;
}
.ammo-count {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 20px; font-weight: 700; line-height: 1.05;
}
.ammo-cap { font-size: 11px; font-weight: 600; color: var(--ink-dim); }
#ammo-wrap.reloading .ammo-count { color: var(--accent); }

/* ---------- Banner: letterpress stamp ---------- */

#banner {
  position: fixed; left: 50%; top: 32%; z-index: 7;
  transform: translateX(-50%);
  font-family: var(--head);
  font-size: 30px; font-weight: 700; letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink); text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
  padding: 6px 4px 8px;
  border-top: 1px solid var(--accent-dim);
  border-bottom: 1px solid var(--accent-dim);
  animation: banner-stamp 2s ease-out forwards;
  white-space: nowrap; pointer-events: none;
  text-indent: .3em; /* balance the letter-spacing */
}
#banner[hidden] { display: none; }
@keyframes banner-stamp {
  0% { opacity: 0; transform: translateX(-50%) scale(1.25); filter: blur(4px) }
  18% { opacity: 1; transform: translateX(-50%) scale(1); filter: blur(0) }
  78% { opacity: 1 }
  100% { opacity: 0; transform: translateX(-50%) scale(.99) }
}

#toast {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 66px); left: 50%;
  transform: translateX(-50%); z-index: 7;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  padding: 8px 16px; border-radius: 6px;
  font-family: var(--head);
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap;
}
#toast[hidden] { display: none; }

/* ---------- Combo multiplier ---------- */

#combo {
  position: fixed;
  right: 14px; top: 38%;
  z-index: 6;
  text-align: center;
  pointer-events: none;
}
#combo[hidden] { display: none; }
#combo-mult {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 34px; font-weight: 800;
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .8);
  line-height: 1;
}
#combo.c3 #combo-mult { color: var(--accent); text-shadow: 0 0 14px rgba(157, 255, 176, .5); }
#combo.c4 #combo-mult { color: #ffc94d; text-shadow: 0 0 16px rgba(255, 201, 77, .55); }
#combo.c5 #combo-mult { color: #ff4a3a; text-shadow: 0 0 18px rgba(255, 74, 58, .6); }
#combo-mult.pop { animation: combo-pop .22s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes combo-pop { 0% { transform: scale(1.45) } 100% { transform: scale(1) } }
#combo.break { animation: combo-break .4s ease-out; }
@keyframes combo-break {
  0% { transform: translateX(0) } 25% { transform: translateX(-5px) }
  50% { transform: translateX(4px) } 75% { transform: translateX(-2px) } 100% { transform: translateX(0) }
}
#combo-bar {
  width: 44px; height: 3px;
  margin: 6px auto 4px;
  background: rgba(233, 244, 236, .15);
  border-radius: 2px;
  overflow: hidden;
}
#combo-fill {
  display: block; height: 100%; width: 100%;
  background: currentColor;
  color: var(--ink);
}
#combo.c3 #combo-fill { color: var(--accent); }
#combo.c4 #combo-fill { color: #ffc94d; }
#combo.c5 #combo-fill { color: #ff4a3a; }
#combo-count {
  font-family: var(--head);
  font-size: 9px; font-weight: 600; letter-spacing: .18em;
  color: var(--ink-dim);
}

/* ---------- Ranks ---------- */

#rank-line[hidden] { display: none; }
/* .player-chip (#rank-line) is styled in the landing section below */
.rank-bar {
  width: 74px; height: 3px;
  background: rgba(233, 244, 236, .12);
  border-radius: 2px; overflow: hidden;
}
.rank-bar i {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  transition: width .8s ease;
}
.rank-bar.big { width: 100%; height: 5px; margin: 8px 0 4px; }

#go-rankwrap { margin: -6px 0 22px; }
.rank-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .16em;
}
#go-rankname { color: var(--accent); font-weight: 700; }
#go-ranknext { color: var(--ink-dim); }
#go-rankup {
  margin-top: 10px;
  font-family: var(--head);
  font-size: 13px; font-weight: 700; letter-spacing: .3em; text-indent: .3em;
  color: #ffc94d;
  animation: record-pulse 1.2s ease-in-out infinite;
}
#go-rankup[hidden] { display: none; }

/* Overcharge state */
#crosshair.over span { background: #ffc94d; box-shadow: 0 0 8px rgba(255, 201, 77, .8); }

/* ---------- Kill feed ---------- */

#killfeed {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  left: 12px; z-index: 6;
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
  max-width: 74vw;
}
.feed-line {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em;
  color: var(--ink);
  background: rgba(5, 9, 8, .6);
  border-left: 2px solid var(--ink-dim);
  padding: 3px 8px; border-radius: 0 4px 4px 0;
  transition: opacity .8s ease;
  align-self: flex-start;
}
.feed-line.atk { border-left-color: #ffc94d; }
.feed-line.in  { border-left-color: var(--danger); color: #ffd7d2; }
.feed-line.out { border-left-color: var(--ink-dim); color: var(--ink-dim); }
.feed-line.win { border-left-color: var(--accent); color: var(--accent); }
.feed-line.fade { opacity: 0; }

/* Squad button styled via .cta in the landing section */

/* ---------- Lobby ---------- */

#lobby {
  position: fixed; inset: 0; z-index: 11;
  background:
    radial-gradient(ellipse at 50% 15%, rgba(30, 90, 50, .2), transparent 55%),
    linear-gradient(180deg, #05080a 0%, #0a1410 60%, #05080a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
}
#lobby[hidden] { display: none; }
.lobby-inner { width: min(360px, 92vw); }
#lobby h2 {
  font-family: var(--head);
  font-size: 30px; font-weight: 700; letter-spacing: .22em; text-indent: .22em;
  color: var(--ink); text-align: center; margin-bottom: 10px;
}
.lobby-sub {
  font-size: 13px; line-height: 1.5; color: var(--ink-dim);
  text-align: center; margin-bottom: 24px;
}
.lobby-field { display: block; margin-bottom: 18px; }
.lobby-field span {
  display: block; font-family: var(--head);
  font-size: 10px; letter-spacing: .18em; color: var(--ink-dim); margin-bottom: 6px;
}
.lobby-field input, .lobby-join input {
  width: 100%; font-family: var(--mono);
  font-size: 16px; color: var(--ink);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--accent-dim); border-radius: 6px;
  padding: 12px 14px; outline: none;
}
.lobby-field input:focus, .lobby-join input:focus { border-color: var(--accent); }
.lobby-actions { display: flex; flex-direction: column; gap: 12px; }
.lobby-or { text-align: center; font-size: 11px; letter-spacing: .2em; color: var(--ink-dim); }
.lobby-join { display: flex; gap: 8px; }
.lobby-join input { text-transform: uppercase; letter-spacing: .3em; text-align: center; }
#lob-create, #lob-join, .lobby-ready, .lobby-start {
  font-family: var(--head);
  font-size: 14px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: #04110a; background: var(--accent);
  border: none; border-radius: 6px; padding: 14px 20px; cursor: pointer;
}
#lob-join { flex: 0 0 auto; padding: 14px 24px; }
.lobby-error { color: var(--danger); font-size: 12px; text-align: center; margin-top: 14px; }
.lobby-error[hidden] { display: none; }
.lobby-back {
  display: block; margin: 22px auto 0;
  font-family: var(--head); font-size: 12px; letter-spacing: .12em;
  color: var(--ink-dim); background: none; border: none; cursor: pointer;
}

.lobby-code-row {
  text-align: center; margin-bottom: 20px;
  font-family: var(--head); font-size: 10px; letter-spacing: .2em; color: var(--ink-dim);
}
.lobby-code {
  font-family: var(--mono); font-size: 44px; font-weight: 800; letter-spacing: .3em;
  color: var(--accent); margin: 4px 0 10px; text-indent: .3em;
}
.lobby-share {
  font-family: var(--head); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); background: transparent;
  border: 1px solid var(--accent-dim); border-radius: 4px; padding: 7px 18px; cursor: pointer;
}
.lobby-roster { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.roster-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--accent-dim);
  font-family: var(--mono); font-size: 14px;
}
.roster-row .r-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-dim); flex: 0 0 auto; }
.roster-row.ready .r-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.roster-row .r-name { flex: 1; color: var(--ink); }
.roster-row .r-host { font-family: var(--head); font-size: 9px; letter-spacing: .14em; color: #ffc94d; }
.roster-row .r-you { font-family: var(--head); font-size: 9px; letter-spacing: .14em; color: var(--accent); }
.lobby-voice { display: flex; gap: 8px; margin-bottom: 14px; }
#voice-toggle {
  flex: 1; font-family: var(--head);
  font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); background: transparent;
  border: 1px solid var(--accent-dim); border-radius: 6px; padding: 12px; cursor: pointer;
}
#voice-toggle.on { background: var(--accent); color: #04110a; border-color: var(--accent); }
#voice-mute {
  font-family: var(--head); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink); background: rgba(255,255,255,.05);
  border: 1px solid var(--accent-dim); border-radius: 6px; padding: 12px 18px; cursor: pointer;
}
#voice-mute[hidden] { display: none; }
#voice-mute.muted { color: var(--danger); border-color: rgba(255,74,58,.4); }

#voice-hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 60px); right: 12px;
  z-index: 6;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 17px; line-height: 1;
  background: var(--panel); color: var(--accent);
  border: 1px solid var(--accent); cursor: pointer;
}
#voice-hud[hidden] { display: none; }
#voice-hud.muted { color: var(--danger); border-color: rgba(255,74,58,.5); opacity: .8; }

.lobby-status {
  text-align: center; font-family: var(--head);
  font-size: 11px; letter-spacing: .16em; color: var(--ink-dim); margin-bottom: 16px;
}
.lobby-ready { width: 100%; margin-bottom: 10px; }
.lobby-ready.on { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.lobby-start { width: 100%; margin-bottom: 10px; background: #ffc94d; }
.lobby-start[hidden] { display: none; }

/* ---------- MP countdown ---------- */

#mp-countdown {
  position: fixed; inset: 0; z-index: 12;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 6, .75);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#mp-countdown[hidden] { display: none; }
#mp-count-n {
  font-family: var(--head); font-size: 140px; font-weight: 800;
  color: var(--accent); text-shadow: 0 0 40px rgba(157, 255, 176, .5);
  animation: mp-count .9s ease-out;
}
@keyframes mp-count { 0% { transform: scale(1.6); opacity: 0 } 30% { opacity: 1 } 100% { transform: scale(.9); opacity: .3 } }

/* ---------- Placement ---------- */

#placement {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(4, 6, 6, .88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#placement[hidden] { display: none; }
#placement .card-inner { border-color: var(--accent-dim); }
#place-crown {
  font-size: 46px; color: #ffc94d; margin-bottom: 6px;
  text-shadow: 0 0 26px rgba(255, 201, 77, .6);
}
#place-crown[hidden] { display: none; }
#place-title {
  font-family: var(--head); font-size: 40px; font-weight: 800;
  letter-spacing: .1em; color: var(--ink); margin-bottom: 4px;
}
#placement.win #place-title { color: #ffc94d; }
#placement-stats { margin: 22px 0; }
.place-wait {
  font-family: var(--head); font-size: 11px; letter-spacing: .16em;
  color: var(--ink-dim); animation: record-pulse 1.6s ease-in-out infinite;
}
.place-wait[hidden] { display: none; }
#place-again {
  font-family: var(--head); font-size: 14px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; text-indent: .22em;
  color: #04110a; background: var(--ink);
  border: none; border-radius: 4px; padding: 13px 38px; cursor: pointer;
}
#place-again[hidden] { display: none; }

.score-float {
  position: fixed; z-index: 6; pointer-events: none;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 15px; font-weight: 700; color: var(--accent);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  animation: score-float .9s ease-out forwards;
}
@keyframes score-float {
  0% { opacity: 1; transform: translateY(0) }
  100% { opacity: 0; transform: translateY(-46px) }
}

/* ---------- Mission insertion ---------- */

#insertion {
  position: fixed; inset: 0; z-index: 11;
  background: #04070a;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s ease;
}
#insertion[hidden] { display: none; }
#insertion.out { opacity: 0; }

.ins-radar {
  position: absolute;
  width: 78vmin; height: 78vmin;
  border-radius: 50%;
  border: 1px solid rgba(157, 255, 176, .12);
  background:
    radial-gradient(circle, transparent 62%, rgba(157, 255, 176, .04) 63%, transparent 64%),
    radial-gradient(circle, transparent 40%, rgba(157, 255, 176, .04) 41%, transparent 42%),
    conic-gradient(from 0deg, rgba(157, 255, 176, .28) 0deg, transparent 70deg, transparent 360deg);
  animation: radar-sweep 2.4s linear infinite;
  opacity: .6;
}
@keyframes radar-sweep { to { transform: rotate(360deg) } }

.ins-lines {
  position: relative;
  font-family: var(--mono);
  font-size: 15px; line-height: 2.1;
  letter-spacing: .12em;
  color: var(--accent);
  text-align: left;
  min-height: 96px; min-width: 240px;
  white-space: pre-line;
}
.ins-lines::after {
  content: '▌';
  animation: cursor-blink .8s steps(1) infinite;
}
@keyframes cursor-blink { 50% { opacity: 0 } }

.ins-skip {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  font-family: var(--head);
  font-size: 10px; font-weight: 600; letter-spacing: .22em;
  color: rgba(233, 244, 236, .3);
}

/* ---------- Start screen — cinematic ops menu ---------- */

#start-screen {
  position: fixed; inset: 0; z-index: 10;
  overflow: hidden;
  background: #04070a;
  color: var(--ink);
}
#start-screen[hidden] { display: none; }

/* Hero background — drop assets/hero.jpg to upgrade; the dark gradient shows until then */
.hero-bg {
  position: absolute; inset: 0;
  background-image:
    url('../assets/hero.jpg'),
    radial-gradient(ellipse 130% 90% at 50% -20%, rgba(30, 120, 70, .30), transparent 60%),
    radial-gradient(ellipse 100% 70% at 50% 118%, rgba(150, 40, 25, .22), transparent 55%),
    linear-gradient(180deg, #08131a 0%, #04080c 55%, #02060a 100%);
  background-size: cover, cover, cover, cover;
  background-position: center;
  animation: hero-zoom 26s ease-in-out infinite alternate;
}
@keyframes hero-zoom { from { transform: scale(1.06); } to { transform: scale(1.15); } }

/* Tron-style battlefield floor grid fading up from the bottom */
.hero-grid {
  position: absolute; left: -20%; right: -20%; bottom: 0; height: 42%;
  background-image:
    linear-gradient(rgba(157, 255, 176, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 255, 176, .10) 1px, transparent 1px);
  background-size: 42px 42px;
  transform: perspective(360px) rotateX(66deg);
  transform-origin: bottom center;
  -webkit-mask-image: linear-gradient(to top, #000, transparent);
  mask-image: linear-gradient(to top, #000, transparent);
  opacity: .55;
  animation: grid-drift 6s linear infinite;
}
@keyframes grid-drift { to { background-position: 0 42px, 0 0; } }

/* Rising embers */
.hero-embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hero-embers span {
  position: absolute; bottom: -12px;
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 7px var(--accent);
  opacity: 0; animation: ember-rise linear infinite;
}
.hero-embers span:nth-child(3n) { background: #ff7a4a; box-shadow: 0 0 7px #ff7a4a; }
.hero-embers span:nth-child(1)  { left: 8%;  animation-duration: 9s;  animation-delay: 0s;   }
.hero-embers span:nth-child(2)  { left: 18%; animation-duration: 12s; animation-delay: 2.5s; }
.hero-embers span:nth-child(3)  { left: 27%; animation-duration: 8s;  animation-delay: 1s;   }
.hero-embers span:nth-child(4)  { left: 36%; animation-duration: 11s; animation-delay: 4s;   }
.hero-embers span:nth-child(5)  { left: 45%; animation-duration: 10s; animation-delay: 0.5s; }
.hero-embers span:nth-child(6)  { left: 54%; animation-duration: 13s; animation-delay: 3s;   }
.hero-embers span:nth-child(7)  { left: 62%; animation-duration: 9s;  animation-delay: 5s;   }
.hero-embers span:nth-child(8)  { left: 70%; animation-duration: 12s; animation-delay: 1.5s; }
.hero-embers span:nth-child(9)  { left: 78%; animation-duration: 8.5s;animation-delay: 3.5s; }
.hero-embers span:nth-child(10) { left: 85%; animation-duration: 11s; animation-delay: 0.8s; }
.hero-embers span:nth-child(11) { left: 91%; animation-duration: 10s; animation-delay: 2s;   }
.hero-embers span:nth-child(12) { left: 96%; animation-duration: 13s; animation-delay: 4.5s; }
@keyframes ember-rise {
  0%   { transform: translateY(0) scale(1);   opacity: 0; }
  12%  { opacity: .85; }
  85%  { opacity: .45; }
  100% { transform: translateY(-92vh) scale(.3); opacity: 0; }
}

/* Scanlines + legibility scrim */
.hero-scan {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
  animation: scan-move 8s linear infinite;
}
@keyframes scan-move { to { background-position: 0 6px; } }
.hero-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 26%, rgba(2,6,10,.72) 100%),
    linear-gradient(180deg, rgba(2,6,10,.72) 0%, transparent 24%, transparent 52%, rgba(2,6,10,.94) 100%);
}

/* HUD corner brackets */
.hud-frame { position: absolute; inset: 14px; pointer-events: none; z-index: 2; }
.bracket {
  position: absolute; width: 26px; height: 26px;
  border: 2px solid rgba(157, 255, 176, .55);
  animation: bracket-in .9s .1s both ease;
}
.bracket.tl  { top: 0; left: 0;  border-right: 0; border-bottom: 0; }
.bracket.tr  { top: 0; right: 0; border-left: 0;  border-bottom: 0; }
.bracket.bl  { bottom: 0; left: 0;  border-right: 0; border-top: 0; }
.bracket.brc { bottom: 0; right: 0; border-left: 0;  border-top: 0; }
@keyframes bracket-in { from { opacity: 0; transform: scale(1.5); } to { opacity: 1; transform: none; } }

/* ---- Menu layout ---- */
.menu {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 26px) 22px
    calc(env(safe-area-inset-bottom, 0px) + 26px);
}
.menu-top   { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; animation: rise .6s both ease; }
.menu-hero  { display: flex; flex-direction: column; align-items: center; animation: rise .7s .12s both ease; }
.menu-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; animation: rise .7s .24s both ease; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* Player rank chip (top-left) */
.player-chip {
  display: flex; align-items: center; gap: 9px;
  background: rgba(5, 9, 8, .6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--accent-dim);
  padding: 7px 12px; text-align: left;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
.player-chip[hidden] { display: none; }
.rank-chevron { color: var(--accent); font-size: 12px; line-height: 1; }
.pc-body { display: flex; flex-direction: column; gap: 4px; }
.pc-body b { font-family: var(--head); font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--ink); }
.player-chip .rank-bar { width: 80px; }
.pc-xp { font-family: var(--mono); font-size: 9px; color: var(--ink-dim); align-self: center; white-space: nowrap; }

/* Systems status (top-right) */
.sys-status {
  display: flex; align-items: center; gap: 7px; padding-top: 5px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: var(--ink-dim);
  white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  animation: live-blink 1.8s ease-in-out infinite;
}
.sys-ver { color: rgba(233, 244, 236, .35); }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Insignia reticle */
.start-insignia {
  width: 62px; height: 62px; margin: 0 auto 4px;
  border: 1px solid var(--accent); border-radius: 50%;
  position: relative;
  box-shadow: 0 0 28px rgba(157, 255, 176, .3), inset 0 0 14px rgba(157, 255, 176, .14);
  animation: insignia-float 4s ease-in-out infinite;
}
.start-insignia::before, .start-insignia::after { content: ''; position: absolute; background: var(--accent); }
.start-insignia::before { left: 50%; top: 9px; bottom: 9px; width: 1px; transform: translateX(-50%); }
.start-insignia::after  { top: 50%; left: 9px; right: 9px; height: 1px; transform: translateY(-50%); }
.start-insignia span {
  position: absolute; left: 50%; top: 50%;
  width: 7px; height: 7px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
@keyframes insignia-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hero-eyebrow {
  font-family: var(--head); font-size: 11px; font-weight: 700;
  letter-spacing: .42em; text-indent: .42em; color: var(--accent);
  margin: 16px 0 6px; opacity: .92;
}

#start-screen h1 {
  font-family: var(--head); font-weight: 800;
  font-size: clamp(56px, 18vw, 96px); line-height: .9;
  letter-spacing: .03em; color: var(--ink);
  text-shadow: 0 0 34px rgba(157, 255, 176, .22), 0 4px 22px rgba(0, 0, 0, .6);
  position: relative;
}
#start-screen h1 em {
  font-style: normal; font-size: .4em; vertical-align: middle;
  color: #04110a; background: var(--accent);
  padding: .12em .3em; margin-left: .2em; letter-spacing: .1em;
  box-shadow: 0 0 22px rgba(157, 255, 176, .55);
  clip-path: polygon(0 0, 100% 0, 100% 100%, .32em 100%, 0 calc(100% - .32em));
}
#start-screen h1::after {
  content: ''; display: block; height: 2px; width: 0; margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: line-grow 1s .35s ease forwards;
}
@keyframes line-grow { to { width: 62%; } }

.tagline { color: var(--ink-dim); font-size: 14px; line-height: 1.55; margin-top: 16px; max-width: 340px; }

.score-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.best-line {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 11px; letter-spacing: .16em; color: var(--ink-dim);
  border: 1px solid var(--accent-dim); border-radius: 5px;
  padding: 5px 12px; background: rgba(5, 9, 8, .4);
}
.best-line[hidden] { display: none; }
.best-line b { color: var(--accent); font-weight: 700; margin-left: 5px; }
.best-line.challenge { color: var(--danger); border-color: rgba(255, 74, 58, .35); animation: record-pulse 1.6s ease-in-out infinite; }
.best-line.challenge b { color: var(--danger); }

/* ---- Angular gamer CTAs ---- */
.cta {
  font-family: var(--head); font-weight: 800;
  font-size: 16px; letter-spacing: .2em; text-transform: uppercase; text-indent: .2em;
  padding: 17px 20px; width: min(360px, 86vw);
  border: none; cursor: pointer; position: relative; overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%);
  transition: transform .12s ease, box-shadow .2s ease;
}
.cta:active { transform: scale(.97); }
.cta-primary {
  color: #04110a;
  background: linear-gradient(120deg, #b6ff8a, var(--accent) 55%, #46d6a0);
  box-shadow: 0 6px 30px rgba(120, 220, 130, .4), inset 0 0 0 1px rgba(255, 255, 255, .2);
}
.cta-primary::before {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg); animation: sheen 3.4s ease-in-out infinite;
}
@keyframes sheen { 0% { left: -60%; } 55% { left: 130%; } 100% { left: 130%; } }
.cta-ghost {
  color: var(--ink); background: rgba(8, 14, 12, .55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px var(--accent-dim);
}
.cta-ghost[hidden] { display: none; }
.cta-squad { color: var(--accent); box-shadow: inset 0 0 0 1px rgba(157, 255, 176, .4); }

.briefing-row {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 4px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: rgba(233, 244, 236, .5);
}
.briefing-row span { position: relative; padding-left: 13px; }
.briefing-row span::before { content: '▸'; position: absolute; left: 0; color: var(--accent); }

.fineprint { margin-top: 4px; font-size: 10px; letter-spacing: .06em; color: rgba(233, 244, 236, .3); }

/* ---------- Mission failed ---------- */

#gameover {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(4, 6, 6, .88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#gameover[hidden] { display: none; }
.card-inner {
  width: min(330px, 88vw);
  background: #0a0d0c;
  border: 1px solid rgba(255, 74, 58, .28);
  border-radius: 10px;
  padding: 30px 26px 26px;
  text-align: center;
  animation: card-pop .4s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes card-pop { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.go-rule { width: 34px; height: 1px; background: var(--danger); margin: 0 auto 18px; }
#gameover h2 {
  font-family: var(--head);
  font-size: 27px; font-weight: 700; letter-spacing: .2em; text-indent: .2em;
  color: var(--danger);
  margin-bottom: 6px;
}
.go-sub {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .18em;
  color: rgba(233, 244, 236, .4);
  margin-bottom: 24px;
}
#go-stats { margin-bottom: 26px; }
.go-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 2px;
  border-bottom: 1px solid rgba(233, 244, 236, .08);
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim);
}
.go-row b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 17px; color: var(--ink);
}
#go-record {
  font-family: var(--head);
  font-size: 12px; font-weight: 700;
  letter-spacing: .3em; text-indent: .3em;
  color: var(--accent);
  margin: -12px 0 20px;
  animation: record-pulse 1.4s ease-in-out infinite;
}
#go-record[hidden] { display: none; }
@keyframes record-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }

#retry-btn {
  font-family: var(--head);
  font-size: 14px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  text-indent: .22em;
  color: #04110a; background: var(--ink);
  border: none; border-radius: 4px;
  padding: 13px 38px; cursor: pointer;
}
#share-btn {
  display: block;
  margin: 10px auto 0;
  font-family: var(--head);
  font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  text-indent: .22em;
  color: var(--accent); background: transparent;
  border: 1px solid var(--accent-dim); border-radius: 4px;
  padding: 11px 30px; cursor: pointer;
}

/* ---------- Full AR mode ---------- */

body.xr { background: transparent; }
body.xr #sky-fallback, body.xr #camera, body.xr #gl { display: none; }
