/* =====================================================================
   Dogfight — Rivercrest · UI
   Design language: "AAA arcade". Ice-white flight symbology with an orange
   accent for locking, warnings and the primary action, red for anything
   locked / lethal, cyan for secondary controls. Panels are angular (cut
   corners, slanted edges), hairline-outlined and translucent so the sunset
   scene behind them sells the game. Display type is Barlow Condensed, UI
   copy is Rajdhani, every number is Share Tech Mono (tabular).

   Every HUD glyph that redraws each frame carries its own dark under-stroke
   (a layered text-shadow for text, a darker line painted under each light
   line, or a 1px box-shadow edge) instead of a filter, which is the one
   thing that measurably costs frames on a phone.

   Sections
     1  tokens & base           8  HUD · core symbology (reticle, cross, pipper)
     2  screens & panels        9  HUD · world-anchored marks
     3  forms & buttons        10  HUD · instruments (ladder, tapes, heading,
     4  menu                        systems, radar, clock & score)
     5  lobby                  11  HUD · feedback (warnings, feed, banner,
     6  hints, kickers, status     hit, death, click-to-play, loading)
     7  results                12  touch layer  ·  13 rotate  ·  14 short screens
   ===================================================================== */

/* ---------- 1. tokens & base ---------- */
:root {
  --ice: #e8f7ff;                    /* HUD primary */
  --cyan: #63dcff;
  --amber: #ff9d3a;                  /* accent: locking, cautions, primary action */
  --amber-hi: #ffc46c;
  --amber-dim: #a85c18;
  --danger: #ff4a3a;                 /* locked, lethal, FIRE */
  --ink: #06101c;
  --text: #ebf4fb;
  --muted: rgba(205,228,244,.55);
  --line: rgba(160,225,255,.28);
  --line-hi: rgba(160,225,255,.6);
  --fill: rgba(9,17,31,.82);
  --fill-2: rgba(6,13,24,.55);
  /* dark halo behind HUD text */
  --hud-shadow: 0 0 1px rgba(0,8,16,1), 0 0 2px rgba(0,8,16,.95), 0 1px 3px rgba(0,8,16,.7);
  /* dark under-layer for 1–2px lines drawn as gradients, and a 1px dark edge
     for lines drawn as borders */
  --dk: rgba(0,8,16,.6);
  --edge: 0 0 0 1px rgba(0,8,16,.55);
  --font-d: 'Barlow Condensed', 'Rajdhani', sans-serif;
  --font-u: 'Rajdhani', system-ui, sans-serif;
  --font-m: 'Share Tech Mono', ui-monospace, monospace;
  --cut: 16px;
  --slant: 10px;
  /* kept for older references */
  --hud: var(--ice);
  --steel: var(--cyan);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0b1020; color: var(--text);
  font-family: var(--font-u);
  font-variant-numeric: tabular-nums;
  user-select: none; -webkit-user-select: none;
}

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

/* Angular polygon helpers. */
.card, .warn { --_p: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }

@keyframes blink { from { opacity: .5; } to { opacity: 1; } }
@keyframes fadein { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; } }

/* ---------- 2. screens & panels ---------- */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(4,8,18,.12), rgba(4,8,18,.55) 75%),
    linear-gradient(180deg, rgba(4,8,18,.62), rgba(4,8,18,.2) 30%, rgba(4,8,18,.2) 70%, rgba(4,8,18,.62));
  -webkit-backdrop-filter: blur(1.5px) saturate(1.15); backdrop-filter: blur(1.5px) saturate(1.15);
}
/* Cinematic letterbox rules top and bottom. */
.screen::before, .screen::after {
  content: ''; position: absolute; left: 0; right: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--line-hi) 30%, var(--line-hi) 70%, transparent);
  opacity: .6;
}
.screen::before { top: 22px; }
.screen::after { bottom: 22px; }
.hidden { display: none !important; }

/* Panel: hairline gradient outline + translucent fill, both cut-cornered.
   (clip-path also clips box-shadow, so the depth comes from the fill, not a
   drop shadow — flat is the look.) The fill is dark enough that the card
   stays readable over the bright sky at the top of the screen. */
.card {
  position: relative; isolation: isolate;
  width: min(480px, 92vw);
  padding: 24px 30px 20px;
  clip-path: var(--_p);
}
.card::before, .card::after { content: ''; position: absolute; clip-path: var(--_p); pointer-events: none; }
.card::before {
  inset: 0; z-index: -2;
  background: linear-gradient(135deg, rgba(180,232,255,.75), rgba(160,225,255,.18) 35%, rgba(160,225,255,.12) 65%, rgba(255,157,58,.55));
}
.card::after {
  inset: 1px; z-index: -1;
  background:
    linear-gradient(180deg, rgba(160,225,255,.07), transparent 120px),
    linear-gradient(160deg, rgba(14,26,46,.93), rgba(8,15,28,.9) 55%, rgba(12,20,36,.94));
}
.card.wide { width: min(660px, 94vw); }

/* ---------- 3. forms & buttons ---------- */
.row { margin-bottom: 16px; }
.row label {
  display: flex; align-items: center; gap: 8px;
  font: 600 11px var(--font-u); letter-spacing: .26em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.row label::before { content: ''; width: 6px; height: 6px; background: var(--amber); transform: rotate(45deg); flex: none; }

input {
  width: 100%; padding: 10px 14px;
  background: linear-gradient(180deg, rgba(4,10,20,.7), rgba(4,10,20,.5));
  border: 1px solid var(--line); border-bottom: 2px solid var(--line-hi);
  border-radius: 2px 2px 0 0;
  color: var(--text); font: 600 18px var(--font-u); letter-spacing: .06em;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: rgba(205,228,244,.3); }
input:focus { border-bottom-color: var(--amber); box-shadow: 0 6px 18px -8px rgba(255,157,58,.5); }

/* Livery tiles: slanted colour band over a cut-corner tile. The chosen one
   gets a 2px orange edge, an orange marker and its name in white. */
.liveries { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.livery {
  --cut: 9px; position: relative; isolation: isolate; cursor: pointer;
  padding: 9px 4px 7px; text-align: center;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  background: var(--line);
  font: 600 11px var(--font-u); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
  transition: color .12s, transform .12s;
}
.livery::before {
  content: ''; position: absolute; inset: 1px; z-index: -1;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(8,16,30,.9), rgba(6,12,22,.75));
  transition: background .12s;
}
.livery:hover { transform: translateY(-2px); color: var(--text); }
.livery.on { background: linear-gradient(135deg, var(--amber-hi), var(--amber)); color: #fff; font-weight: 700; }
.livery.on::before { inset: 2px; background: linear-gradient(180deg, rgba(255,157,58,.28), rgba(8,16,30,.9)); }
.livery.on::after {
  content: ''; position: absolute; left: 7px; bottom: 9px; width: 6px; height: 6px;
  background: var(--amber); transform: rotate(45deg); box-shadow: 0 0 8px var(--amber);
}
.livery .chip {
  display: block; width: 100%; height: 18px; margin-bottom: 7px;
  clip-path: polygon(0 0, 78% 0, 100% 100%, 22% 100%);
  box-shadow: inset 0 -8px 10px rgba(0,0,0,.3);
}

/* Control-scheme tiles share the livery look; two wide ones with a subtitle. */
.schemes { grid-template-columns: 1fr 1fr; }
.scheme small { display: block; margin-top: 3px; font-size: 9px; letter-spacing: .1em; opacity: .7; text-transform: none; }
.direct-only { display: none; }
.direct .direct-only { display: inline; }
.direct .hint-note.direct-only { display: block; }
.direct .assisted-only { display: none; }

.btns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; text-align: center; letter-spacing: .4em; width: 44%; font-family: var(--font-m); font-size: 17px; }

/* Buttons are parallelograms: outline layer (element bg) + fill (::before)
   + a bright leading edge (::after). Pseudo-elements on <button> are fine in
   every current engine. */
button {
  --bl: var(--line-hi);
  --bf: linear-gradient(180deg, rgba(160,225,255,.16), rgba(160,225,255,.07));
  position: relative; isolation: isolate; cursor: pointer; border: none;
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  background: var(--bl);
  font: 700 15px var(--font-u); letter-spacing: .22em; text-transform: uppercase;
  padding: 13px 22px; color: var(--text);
  transition: transform .08s, filter .12s;
}
button::before, button::after { content: ''; position: absolute; z-index: -1; pointer-events: none; }
button::before { inset: 1px; clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%); background: var(--bf); }
button::after { left: 0; top: 0; bottom: 0; width: 18px; background: linear-gradient(90deg, rgba(255,255,255,.45), rgba(255,255,255,0)); opacity: .55; }
button:hover { filter: brightness(1.12); transform: translateX(2px); }
button:active { transform: translateY(1px); filter: brightness(.95); }
.big { width: 100%; }
.amber {
  --bl: linear-gradient(180deg, #ffd08a, #c96a12);
  --bf: linear-gradient(180deg, #ffc266 0%, #ff9d3a 55%, #ec7d1a 100%);
  color: #221000; text-shadow: 0 1px 0 rgba(255,255,255,.25);
}
.amber::after { opacity: .8; }
.steel {
  --bl: linear-gradient(180deg, rgba(190,236,255,.9), rgba(99,220,255,.45));
  --bf: linear-gradient(180deg, rgba(99,220,255,.32), rgba(99,220,255,.12));
  color: var(--ice); flex: 1;
}
.grey { --bl: rgba(205,228,244,.3); --bf: linear-gradient(180deg, rgba(205,228,244,.1), rgba(205,228,244,.03)); color: var(--text); }
.grey::after { opacity: .25; }

.mini {
  --slant: 6px; padding: 6px 12px; font-size: 10px; letter-spacing: .16em;
  --bl: rgba(99,220,255,.55); --bf: rgba(99,220,255,.12); color: #cdefff;
}
.mini::after { width: 10px; opacity: .3; }
.mini.ghost { --bl: rgba(255,74,58,.55); --bf: rgba(255,74,58,.12); color: #ffb9b0; }

.msg { margin-top: 12px; text-align: center; font-size: 13px; letter-spacing: .04em; color: var(--amber); }
.msg:empty { display: none; }
.small { font: 600 11px var(--font-u); letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }

/* ---------- 4. menu ---------- */
.logo { text-align: center; margin: 0 0 22px; }
.logo-top {
  display: block;
  font: 800 clamp(40px, 19vw, 78px)/0.95 var(--font-d); letter-spacing: .06em;
  background: linear-gradient(180deg, #ffffff 30%, #bfe9ff 60%, #63dcff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,20,40,.6)) drop-shadow(0 0 18px rgba(99,220,255,.35));
}
.logo-rule {
  display: flex; align-items: center; gap: 10px; margin: 6px auto 8px; width: 78%;
  color: var(--amber);
}
.logo-rule::before, .logo-rule::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-hi)); }
.logo-rule::after { background: linear-gradient(90deg, var(--line-hi), transparent); }
.logo-rule i { width: 7px; height: 7px; background: var(--amber); transform: rotate(45deg); box-shadow: 0 0 10px var(--amber); }
.logo-sub {
  display: block; font: 600 12px var(--font-u); letter-spacing: .38em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- 5. lobby ---------- */
.lobby-head { text-align: center; margin-bottom: 16px; }
.lobby-blurb { font: 500 12px var(--font-u); letter-spacing: .06em; color: var(--muted); }
.code {
  display: inline-block; position: relative;
  font: 700 46px/1 var(--font-m); letter-spacing: .34em; text-indent: .34em;
  color: var(--ice); margin: 8px 0 8px; padding: 6px 16px;
  text-shadow: 0 0 22px rgba(99,220,255,.55);
  background: var(--brk-bg); background-repeat: no-repeat;
}
.lobby-list { display: flex; flex-direction: column; gap: 6px; counter-reset: slot; }
.slot {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 10px;
  background: linear-gradient(90deg, rgba(160,225,255,.1), rgba(4,10,20,.55) 30%, rgba(4,10,20,.45));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  font: 600 16px var(--font-u); letter-spacing: .04em;
}
.slot::before {
  counter-increment: slot; content: counter(slot, decimal-leading-zero);
  font: 500 11px var(--font-m); color: var(--muted); width: 18px;
}
.slot.empty { border-style: dashed; background: none; color: rgba(205,228,244,.35); font-weight: 500; letter-spacing: .2em; font-size: 12px; text-transform: uppercase; }
.slot .dot { width: 9px; height: 22px; flex: none; transform: skewX(-18deg); border-radius: 1px; box-shadow: 0 0 8px rgba(0,0,0,.4); }
.slot .tag {
  margin-left: auto; font: 700 10px var(--font-u); letter-spacing: .2em;
  color: var(--ice); border: 1px solid var(--line-hi); padding: 2px 8px;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}
.slot .tag.you { background: var(--amber); border-color: var(--amber); color: #221000; }
.slot .tag.ai { background: rgba(99,220,255,.16); }
.bot-row { display: flex; align-items: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.bot-row .small { margin-right: 4px; }
/* Time of day + weather. Same chips as the AI row; the chosen one is lit, and
   guests get the row read-only so they can see what the host has picked. */
.env-rows { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.env-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.env-row .small { margin-right: 4px; min-width: 64px; }
.mini.on { --bl: var(--amber); --bf: linear-gradient(180deg, rgba(255,170,60,.45), rgba(255,140,30,.22)); color: #fff1dc; }
.mini.on::after { opacity: .9; }
.env-rows.readonly .mini { pointer-events: none; opacity: .45; }
.env-rows.readonly .mini.on { opacity: 1; }

/* ---------- 6. hints, kickers & status lines ---------- */
/* Kicker: the small tracked label over every card's title. */
.kicker {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 0 0 14px; font: 600 12px var(--font-u); letter-spacing: .4em; text-indent: .4em;
  text-transform: uppercase; color: var(--muted);
}
.kicker::before, .kicker::after { content: ''; width: 26px; height: 1px; background: var(--line-hi); flex: none; }
.kicker::before { background: linear-gradient(90deg, transparent, var(--line-hi)); }
.kicker::after { background: linear-gradient(90deg, var(--line-hi), transparent); }

.hint {
  margin-top: 16px; text-align: center; font-size: 12px; line-height: 1.7;
  color: rgba(205,228,244,.55);
}
.card > .hint { border-top: 1px solid var(--line); padding-top: 12px; }
.hint-note { margin-bottom: 8px; }
/* Keycap rows: each cap stays welded to its word, and the row centres and
   wraps as whole pairs, so a line never ends on an orphaned word. */
.hint-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 0; }
.hint-line + .hint-line { margin-top: 2px; }
.kv { white-space: nowrap; padding: 0 7px; position: relative; }
/* Divider drawn with a pseudo-element and clipped by the row, so a pair that
   wraps to a new line does not start with a stray rule. */
.hint-line { overflow: hidden; }
.kv::before { content: ''; position: absolute; left: -1px; top: 2px; bottom: 2px; width: 1px; background: var(--line); }
.kv:first-child::before { display: none; }
.hint b {
  display: inline-block; padding: 0 6px; margin: 0 4px 0 0; line-height: 16px;
  font: 600 10px/16px var(--font-m); color: var(--ice);
  border: 1px solid var(--line-hi); border-radius: 1px; background: rgba(160,225,255,.08);
  vertical-align: 1px;
}

/* Status line: a quiet ruled footer on every card. */
.status-line {
  display: flex; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 9px; border-top: 1px solid var(--line);
  font: 600 10px var(--font-u); letter-spacing: .24em; text-transform: uppercase;
  color: var(--muted);
}
.status-line b { color: var(--ice); font-weight: 600; }
.status-line > span:first-child::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 8px; background: var(--amber); transform: rotate(45deg); vertical-align: 1px; }
.status-line > span:only-child { margin: 0 auto; }

/* ---------- 7. results ---------- */
.res-title {
  position: relative; text-align: center; margin: 0 0 18px; padding: 4px 0 10px;
  font: 800 clamp(34px, 9.5vw, 64px)/1 var(--font-d); letter-spacing: .1em; text-indent: .1em;
  text-transform: uppercase; overflow-wrap: anywhere;
  background: linear-gradient(180deg, #fff 25%, #ffd899 55%, var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,10,20,.7)) drop-shadow(0 0 18px rgba(255,157,58,.45));
}
.res-title::after {
  content: ''; position: absolute; left: 20%; right: 20%; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
}
.res-table { display: flex; flex-direction: column; gap: 6px; }
.res-row {
  display: grid; grid-template-columns: 34px 12px 1fr 58px 58px 64px;
  gap: 12px; align-items: center; padding: 9px 14px 9px 10px;
  background: linear-gradient(90deg, rgba(160,225,255,.08), rgba(4,10,20,.55) 30%, rgba(4,10,20,.45));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  font: 600 16px var(--font-u); letter-spacing: .03em;
}
.res-row.head {
  background: none; border: none; padding: 0 14px 0 10px;
  font: 600 10px var(--font-u); letter-spacing: .24em; text-transform: uppercase; color: var(--muted);
}
.res-row.head .num { font: inherit; text-align: right; }
.res-row.win { border-color: var(--amber); background: linear-gradient(90deg, rgba(255,157,58,.28), rgba(255,157,58,.08) 40%, rgba(4,10,20,.5)); }
.res-row .dot { width: 9px; height: 22px; transform: skewX(-18deg); border-radius: 1px; }
.res-row .num { font: 500 17px var(--font-m); text-align: right; }
.res-row .rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font: 700 14px var(--font-m); color: var(--muted);
  border: 1px solid var(--line-hi); background: rgba(4,10,20,.5);
}
.res-row:nth-child(2) .rank { color: #2a1600; border-color: #ffe08a; background: radial-gradient(circle at 35% 30%, #fff1c2, #ffc650 45%, #d98a12); box-shadow: 0 0 12px rgba(255,200,80,.5); }
.res-row:nth-child(3) .rank { color: #1c2430; border-color: #eef4fa; background: radial-gradient(circle at 35% 30%, #ffffff, #cfd9e6 45%, #8a98ab); }
.res-row:nth-child(4) .rank { color: #2a1406; border-color: #f0b58c; background: radial-gradient(circle at 35% 30%, #ffd9bf, #d9884f 45%, #8f4d22); }

/* ---------- 7b. cockpit view ---------- */
/* One transparent panel image, sized to COVER the viewport and pinned to the
   bottom centre, so the combiner glass frames the gunsight on a 16:10 desktop
   and a 19.5:9 phone alike. It sits under the HUD (z 15 < 20) and over the
   touch layer's nothing — the buttons are in #touch at z 25. */
.cockpit {
  position: fixed; inset: 0; z-index: 15; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 100%;
  pointer-events: none; user-select: none;
}

/* ---------- 8. HUD · core symbology ---------- */
#hud {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  color: var(--ice); text-shadow: var(--hud-shadow);
  font-family: var(--font-u);
}
#hud .tape, #hud .bottom-left, #hud .bottom-right, #hud .top-right { position: absolute; }

/* Bracketed frame: eight corner ticks drawn as backgrounds, so it wraps any
   box without extra markup and never spills past the element's own rect. */
:root { --brk-c: rgba(190,236,255,.8); --brk-l: 10px; --brk-bg:
    linear-gradient(var(--brk-c), var(--brk-c)) 0 0 / var(--brk-l) 1px,
    linear-gradient(var(--brk-c), var(--brk-c)) 0 0 / 1px var(--brk-l),
    linear-gradient(var(--brk-c), var(--brk-c)) 100% 0 / var(--brk-l) 1px,
    linear-gradient(var(--brk-c), var(--brk-c)) 100% 0 / 1px var(--brk-l),
    linear-gradient(var(--brk-c), var(--brk-c)) 0 100% / var(--brk-l) 1px,
    linear-gradient(var(--brk-c), var(--brk-c)) 0 100% / 1px var(--brk-l),
    linear-gradient(var(--brk-c), var(--brk-c)) 100% 100% / var(--brk-l) 1px,
    linear-gradient(var(--brk-c), var(--brk-c)) 100% 100% / 1px var(--brk-l); }
.brk { background: var(--brk-bg); background-repeat: no-repeat; background-color: rgba(3,9,18,.28); }

/* Gradient line helpers. --ln is the light line, --sh the darker one that
   is painted under it, one pixel wider on every side. */
#hud, #touch { --ln: linear-gradient(var(--ice), var(--ice)); --sh: linear-gradient(var(--dk), var(--dk)); }

/* Flight-path marker: a ring, two wings and a fin. Moves with the aim input
   (main.js sets its transform and opacity every frame). */
.reticle {
  position: absolute; left: 50%; top: 50%; width: 42px; height: 42px;
  margin: -21px 0 0 -21px; will-change: transform, opacity;
  background:
    var(--ln) 1px 50% / 12px 2px no-repeat,
    var(--ln) calc(100% - 1px) 50% / 12px 2px no-repeat,
    var(--ln) 50% 1px / 2px 12px no-repeat,
    var(--sh) 0 50% / 14px 4px no-repeat,
    var(--sh) 100% 50% / 14px 4px no-repeat,
    var(--sh) 50% 0 / 4px 14px no-repeat;
}
.reticle::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px;
  margin: -9px 0 0 -9px; border: 2px solid var(--ice); border-radius: 50%;
  box-shadow: var(--edge), inset var(--edge);
}
/* Gun cross: a plus with an open centre, fixed to the boresight. */
.gun-cross {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  margin: -22px 0 0 -22px; opacity: .9;
  background:
    var(--ln) 50% 1px / 1.5px 12px no-repeat,
    var(--ln) 50% calc(100% - 1px) / 1.5px 12px no-repeat,
    var(--ln) 1px 50% / 12px 1.5px no-repeat,
    var(--ln) calc(100% - 1px) 50% / 12px 1.5px no-repeat,
    var(--sh) 50% 0 / 3.5px 14px no-repeat,
    var(--sh) 50% 100% / 3.5px 14px no-repeat,
    var(--sh) 0 50% / 14px 3.5px no-repeat,
    var(--sh) 100% 50% / 14px 3.5px no-repeat;
}
/* Lead pipper: a small orange ring with a dot, nothing like the reticle. */
.pipper {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 1.5px solid var(--amber); border-radius: 50%;
  box-shadow: var(--edge), inset var(--edge);
}
.pipper::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: var(--amber); box-shadow: var(--edge);
}

/* ---------- 9. HUD · world-anchored marks ---------- */
/* Above the fixed centre symbology: a target sitting just over the boresight
   (the normal guns picture) must not have its plates painted under the cross. */
#marks { position: absolute; inset: 0; z-index: 2; }
/* Target designator: corner brackets (never smaller than 24px), name above,
   range and closure below. The light corners sit on dark ones a pixel wider. */
.mark {
  --mc: var(--ice); --ml: 9px;
  position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  transition: opacity .1s;
  background:
    linear-gradient(var(--mc), var(--mc)) 1px 1px / var(--ml) 1.5px no-repeat,
    linear-gradient(var(--mc), var(--mc)) 1px 1px / 1.5px var(--ml) no-repeat,
    linear-gradient(var(--mc), var(--mc)) calc(100% - 1px) 1px / var(--ml) 1.5px no-repeat,
    linear-gradient(var(--mc), var(--mc)) calc(100% - 1px) 1px / 1.5px var(--ml) no-repeat,
    linear-gradient(var(--mc), var(--mc)) 1px calc(100% - 1px) / var(--ml) 1.5px no-repeat,
    linear-gradient(var(--mc), var(--mc)) 1px calc(100% - 1px) / 1.5px var(--ml) no-repeat,
    linear-gradient(var(--mc), var(--mc)) calc(100% - 1px) calc(100% - 1px) / var(--ml) 1.5px no-repeat,
    linear-gradient(var(--mc), var(--mc)) calc(100% - 1px) calc(100% - 1px) / 1.5px var(--ml) no-repeat,
    var(--sh) 0 0 / calc(var(--ml) + 2px) 3.5px no-repeat,
    var(--sh) 0 0 / 3.5px calc(var(--ml) + 2px) no-repeat,
    var(--sh) 100% 0 / calc(var(--ml) + 2px) 3.5px no-repeat,
    var(--sh) 100% 0 / 3.5px calc(var(--ml) + 2px) no-repeat,
    var(--sh) 0 100% / calc(var(--ml) + 2px) 3.5px no-repeat,
    var(--sh) 0 100% / 3.5px calc(var(--ml) + 2px) no-repeat,
    var(--sh) 100% 100% / calc(var(--ml) + 2px) 3.5px no-repeat,
    var(--sh) 100% 100% / 3.5px calc(var(--ml) + 2px) no-repeat;
}
.mark .m-name, .mark .m-dist {
  position: absolute; left: 50%; transform: translateX(-50%);
  padding: 1px 5px; background: rgba(3,9,18,.45); white-space: nowrap;
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}
.mark .m-name {
  bottom: 100%; margin-bottom: 6px;
  font: 600 12px/14px var(--font-u); letter-spacing: .14em; text-transform: uppercase; color: var(--mc);
}
.mark .m-dist {
  top: 100%; margin-top: 6px;
  font: 500 12px/14px var(--font-m); letter-spacing: .06em; color: var(--mc); white-space: pre;
}
/* Locking: orange brackets and a ring that fills clockwise with --lock (0..1,
   set from JS). Locked: solid red ring, a LOCK tag, pulsing. */
.mark.locking { --mc: var(--amber); }
.mark.locked { --mc: var(--danger); }
.mark.locked::after { animation: blink .35s infinite alternate; }   /* only the ring blinks; the plates stay readable */
.mark.locking::after, .mark.locked::after {
  content: ''; position: absolute; inset: -11px; border-radius: 50%;
  background: conic-gradient(var(--mc) calc(var(--lock, 0) * 360deg), rgba(255,157,58,.2) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 2.5px));
}
.mark.locked::before {
  content: 'LOCK'; position: absolute; left: 100%; margin-left: 18px; top: 50%; transform: translateY(-50%);
  font: 700 11px var(--font-d); letter-spacing: .24em; text-indent: .24em; color: var(--danger);
  padding: 1px 4px 1px 6px; border: 1px solid var(--danger); background: rgba(30,4,4,.7);
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}
.chevron {
  position: absolute; width: 0; height: 0; margin: -9px 0 0 -9px;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 16px solid var(--amber);
}

/* ---------- 10. HUD · instruments ---------- */
/* Pitch ladder: short rungs with the tips bent toward the horizon, numbers
   at both ends, dashed below the horizon, a gap around the gunsight. The
   whole thing rotates with bank; each rung's top is set from JS. */
.ladder {
  position: absolute; left: 50%; top: 50%; width: 360px; height: 300px;
  margin: -150px 0 0 -180px; overflow: hidden; opacity: .85;
  -webkit-mask: linear-gradient(transparent, #000 14%, #000 86%, transparent);
  mask: linear-gradient(transparent, #000 14%, #000 86%, transparent);
}
.ladder-inner { position: absolute; inset: 0; transform-origin: 50% 50%; }
.rung { position: absolute; left: 50%; width: 0; height: 0; }
.rung::before, .rung::after { content: ''; position: absolute; top: -2px; width: 62px; height: 9px; }
.rung.pos::before {
  right: 52px;
  background: var(--ln) 0 1px / 100% 1.5px no-repeat, var(--ln) 1px 0 / 1.5px 100% no-repeat,
    var(--sh) 0 0 / 100% 4px no-repeat, var(--sh) 0 0 / 4px 100% no-repeat;
}
.rung.pos::after {
  left: 52px;
  background: var(--ln) 0 1px / 100% 1.5px no-repeat, var(--ln) calc(100% - 1px) 0 / 1.5px 100% no-repeat,
    var(--sh) 0 0 / 100% 4px no-repeat, var(--sh) 100% 0 / 4px 100% no-repeat;
}
.rung.neg { --ln: repeating-linear-gradient(90deg, var(--ice) 0 5px, transparent 5px 9px); }
.rung.neg::before, .rung.neg::after { top: -7px; }
.rung.neg::before {
  right: 52px;
  background: var(--ln) 0 7px / 100% 1.5px no-repeat, linear-gradient(var(--ice), var(--ice)) 1px 0 / 1.5px 100% no-repeat,
    var(--sh) 0 6px / 100% 4px no-repeat, var(--sh) 0 0 / 4px 100% no-repeat;
}
.rung.neg::after {
  left: 52px;
  background: var(--ln) 0 7px / 100% 1.5px no-repeat, linear-gradient(var(--ice), var(--ice)) calc(100% - 1px) 0 / 1.5px 100% no-repeat,
    var(--sh) 0 6px / 100% 4px no-repeat, var(--sh) 100% 0 / 4px 100% no-repeat;
}
.rung.zero::before, .rung.zero::after {
  width: 150px;
  background: var(--ln) 0 1px / 100% 1.5px no-repeat, var(--sh) 0 0 / 100% 4px no-repeat;
}
.rung.zero::before { right: 52px; }
.rung.zero::after { left: 52px; }
.rung .n { position: absolute; top: -8px; font: 500 12px/16px var(--font-m); }
.rung .n.l { right: 122px; }
.rung .n.r { left: 122px; }

/* Airspeed and altitude: bracketed readouts either side of the gunsight. */
.tape { top: 50%; transform: translateY(-50%); text-align: center; padding: 6px 12px 5px; min-width: 104px; }
.tape-l { left: 40px; }
.tape-r { right: 40px; }
.tape-label { font: 600 10px var(--font-u); letter-spacing: .3em; color: rgba(205,228,244,.85); }
.tape-val {
  font: 700 40px/1.05 var(--font-m);
  text-shadow: var(--hud-shadow);
}
.tape-unit { font: 500 10px var(--font-m); letter-spacing: .2em; color: rgba(205,228,244,.7); }

/* Heading strip on a dark backplate, orange caret, boxed heading under it. */
.heading {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: min(460px, 60vw); height: 62px;
}
.heading-tape {
  position: absolute; left: 0; right: 0; top: 0; height: 30px; overflow: hidden;
  border-bottom: 1px solid var(--line-hi);
  background: linear-gradient(180deg, rgba(3,9,18,.45), rgba(3,9,18,.2));
  -webkit-mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}
.heading-inner { position: absolute; top: 0; left: 0; height: 30px; white-space: nowrap; }
.heading-tick { position: absolute; top: 0; width: 0; height: 30px; }
.heading-tick i { position: absolute; left: -0.5px; bottom: 0; width: 1px; height: 6px; background: var(--ice); box-shadow: var(--edge); opacity: .85; }
.heading-tick.maj i { height: 10px; width: 1.5px; opacity: 1; }
.heading-tick b { position: absolute; left: 0; top: 1px; transform: translateX(-50%); font: 500 11px/14px var(--font-m); }
.heading-mark {
  position: absolute; left: 50%; top: 31px; margin-left: -6px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 8px solid var(--amber);
}
.heading-box {
  position: absolute; left: 50%; top: 40px; transform: translateX(-50%);
  padding: 1px 8px 0 9px; font: 700 14px/1.3 var(--font-m); letter-spacing: .1em;
  color: var(--ice); border: 1px solid var(--line-hi); background: rgba(3,9,18,.72);
  box-shadow: var(--edge);
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

/* Systems block, bottom-left: segmented gauges and the missile silhouettes. */
.bottom-left { left: 40px; bottom: 32px; width: 200px; padding: 8px 10px 7px; }
.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font: 600 10px var(--font-u); letter-spacing: .18em; }
.bar span { width: 28px; color: rgba(205,228,244,.85); }
.bar-track {
  flex: 1; height: 8px; background: rgba(3,9,18,.6); border: 1px solid var(--line-hi);
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
  overflow: hidden; position: relative;
}
.bar-track::after {
  /* segment ticks over the fill */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(3,9,18,.7) 9px 10px);
}
.bar-fill { height: 100%; width: 0; background: var(--ice); transition: width .08s linear; }
.bar-fill.ab { background: var(--cyan); }
.bar-fill.heat { background: var(--amber); }
.bar-fill.hull { background: #7ff0b0; width: 100%; }
.bar-fill.hull.warn { background: var(--amber); }
.bar-fill.hull.hot { background: var(--danger); }
.bar-fill.hot { background: var(--danger); }
.msl-count {
  margin-top: 4px; height: 14px;
  display: flex; align-items: center; gap: 5px;
}
.msl-count::before { content: 'MSL'; font: 600 10px var(--font-u); letter-spacing: .18em; color: rgba(205,228,244,.85); width: 28px; margin-right: 3px; }
.msl-count i {
  width: 7px; height: 14px; background: var(--amber);
  clip-path: polygon(50% 0, 100% 32%, 100% 100%, 0 100%, 0 32%);
  box-shadow: var(--edge);
}
.msl-count b { font: 600 10px var(--font-u); letter-spacing: .2em; color: var(--danger); }

/* Radar scope, bottom-right: opaque enough that the city never shows
   through; crosshair, half-range ring, north label, own-ship arrow that
   turns with the jet, and a sweep. */
.bottom-right { right: 40px; bottom: 32px; }
.radar {
  position: relative; width: 128px; height: 128px; border-radius: 50%; overflow: hidden;
  border: 1px solid var(--line-hi);
  background: radial-gradient(circle, rgb(14,30,50), rgb(5,11,21) 72%);
  box-shadow: 0 0 0 3px rgba(3,9,18,.5), inset 0 0 18px rgba(3,9,18,.6);
}
.radar::before, .radar::after { content: ''; position: absolute; background: rgba(160,225,255,.3); }
.radar::before { left: 6px; right: 6px; top: 50%; height: 1px; }
.radar::after { top: 6px; bottom: 6px; left: 50%; width: 1px; }
.radar-sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(99,220,255,.32), rgba(99,220,255,0) 70deg, transparent);
  animation: sweep 3.5s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.radar-ring { position: absolute; inset: 25%; border: 1px solid rgba(160,225,255,.35); border-radius: 50%; }
.radar-self {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 14px; margin: -8px 0 0 -6px;
  transform-origin: 50% 57%; will-change: transform;
}
.radar-self::before, .radar-self::after { content: ''; position: absolute; left: 0; top: 0; width: 0; height: 0; }
.radar-self::before { border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid rgba(0,8,16,.75); }
.radar-self::after { left: 1.5px; top: 2px; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; border-bottom: 11px solid var(--ice); }
.radar-lbl { position: absolute; font: 600 9px var(--font-u); letter-spacing: .18em; color: rgba(205,228,244,.85); }
.radar-lbl.n { top: 4px; left: 50%; transform: translateX(-50%); }
.radar-lbl.rng { bottom: 12px; right: 20px; font-family: var(--font-m); font-weight: 500; }
.blip { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 1px rgba(0,8,16,.85), 0 0 5px currentColor; }
.blip.hi::after, .blip.lo::after {
  content: ''; position: absolute; left: 50%; margin-left: -2.5px;
  border-left: 2.5px solid transparent; border-right: 2.5px solid transparent;
}
.blip.hi::after { bottom: 8px; border-bottom: 4px solid var(--ice); }
.blip.lo::after { top: 8px; border-top: 4px solid var(--ice); }

/* Match clock and scoreboard, top-right. */
.top-right { right: 40px; top: 18px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.clock {
  font: 700 26px/1 var(--font-m); letter-spacing: .08em; padding: 6px 12px 5px;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.clock::before { content: 'TIME'; font: 600 10px var(--font-u); letter-spacing: .3em; color: rgba(205,228,244,.8); }
.clock.low { color: var(--danger); animation: blink .6s infinite alternate; }
/* Local time and the weather under the match clock. */
.env-line {
  margin-top: 4px; display: inline-flex; align-items: center; gap: 8px;
  font: 500 12px/1 var(--font-m); letter-spacing: .14em; color: rgba(205,228,244,.8);
}
.env-line i { width: 3px; height: 10px; background: var(--amber); transform: skewX(-18deg); opacity: .8; }
.env-line #envWx { font: 600 10px var(--font-u); letter-spacing: .3em; color: var(--ice); }
.score { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; align-items: stretch; width: 150px; }
.score-row {
  display: flex; align-items: center; gap: 8px;
  font: 600 13px var(--font-u); letter-spacing: .06em;
  background: linear-gradient(90deg, rgba(3,9,18,.6), rgba(3,9,18,.35)); padding: 3px 8px 3px 6px;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}
.score-row .dot { width: 4px; height: 14px; flex: none; transform: skewX(-18deg); }
.score-row .nm { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-row .k { font: 500 14px var(--font-m); color: var(--amber); min-width: 16px; text-align: right; }
.score-row.me { background: linear-gradient(90deg, rgba(99,220,255,.28), rgba(3,9,18,.45)); box-shadow: inset 0 0 0 1px var(--line-hi); }
.score-row.dead { opacity: .4; }

/* ---------- 11. HUD · feedback ---------- */
/* Cautions stack inside one framed block below the gunsight. Each plate keeps
   its hazard stripes: red for lethal, orange for a stall. */
.warnings {
  position: absolute; left: 50%; top: 70%; transform: translateX(-50%); z-index: 3;
  display: flex; flex-direction: column; gap: 5px; align-items: center;
  min-width: 250px; padding: 5px 12px 9px;
  border: 1px solid rgba(255,74,58,.55); background: rgba(14,4,4,.6);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.warnings:empty { display: none; }
.warnings::before {
  content: 'CAUTION'; font: 600 9px var(--font-u); letter-spacing: .42em; text-indent: .42em;
  color: rgba(255,140,128,.9);
}
.warn {
  --cut: 8px;
  font: 700 18px/1 var(--font-d); letter-spacing: .26em; text-indent: .26em;
  padding: 7px 18px; color: var(--danger);
  clip-path: var(--_p);
  background:
    linear-gradient(rgba(40,6,4,.8), rgba(40,6,4,.8)) padding-box,
    repeating-linear-gradient(135deg, currentColor 0 6px, transparent 6px 12px) border-box;
  border: 2px solid transparent;
  animation: blink .45s infinite alternate;
}
.warn.amber { color: var(--amber); background: linear-gradient(rgba(34,18,2,.8), rgba(34,18,2,.8)) padding-box, repeating-linear-gradient(135deg, currentColor 0 6px, transparent 6px 12px) border-box; }

.feed {
  position: absolute; left: 40px; top: 18px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  font: 600 13px var(--font-u); letter-spacing: .05em;
}
.feed div {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(90deg, rgba(3,9,18,.7), rgba(3,9,18,.35)); padding: 4px 12px 4px 8px;
  border-left: 3px solid var(--amber);
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 100%, 0 100%);
  animation: fadein .25s;
}
.feed b { font-weight: 700; color: #fff; }
.feed .how { color: rgba(205,228,244,.7); font-style: italic; }
/* weapon glyphs: three rounds for guns, a fin-tailed dart for a missile,
   a downward chevron for terrain / boundary */
.fk { display: inline-block; width: 20px; height: 12px; flex: none; }
.fk-gun { background: radial-gradient(circle, var(--amber) 2.2px, transparent 2.8px) 0 0 / 6.5px 100% repeat-x; }
.fk-msl { background: var(--amber); clip-path: polygon(0 35%, 55% 35%, 55% 0, 100% 50%, 55% 100%, 55% 65%, 0 65%); }
.fk-crash { background: var(--danger); clip-path: polygon(20% 0, 50% 55%, 80% 0, 100% 20%, 50% 100%, 0 20%); }

.banner {
  position: absolute; left: 0; right: 0; top: 34%; transform: translateY(-50%);
  text-align: center; pointer-events: none; padding: 14px 0;
  background: linear-gradient(90deg, transparent, rgba(3,9,18,.72) 25%, rgba(3,9,18,.72) 75%, transparent);
  animation: bannerin .35s cubic-bezier(.2,.9,.3,1.2);
}
.banner::before, .banner::after {
  content: ''; position: absolute; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-hi), transparent);
}
.banner::before { top: 0; } .banner::after { bottom: 0; }
.banner .big-text {
  font: 800 96px/1 var(--font-d); letter-spacing: .22em; text-indent: .22em;
  color: #fff;
  text-shadow: 0 0 30px rgba(99,220,255,.65), 0 0 2px rgba(0,12,24,1), 0 4px 0 rgba(0,12,24,.5);
}
.banner .sub-text { margin: 6px 0 4px; font: 600 15px var(--font-u); letter-spacing: .5em; text-indent: .5em; color: var(--amber); }
@keyframes bannerin { from { opacity: 0; transform: translateY(-50%) scaleX(1.25); letter-spacing: .5em; } to { opacity: 1; transform: translateY(-50%); } }

.hitmark {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px;
  margin: -17px 0 0 -17px; opacity: 0;
  background:
    linear-gradient(45deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%),
    linear-gradient(-45deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%);
  -webkit-mask: radial-gradient(circle, transparent 6px, #000 7px);
  mask: radial-gradient(circle, transparent 6px, #000 7px);
}
.hitmark.on { animation: hit .22s; }
@keyframes hit { from { opacity: 1; transform: scale(.6); } to { opacity: 0; transform: scale(1.3); } }

.vignette {
  position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(190,20,10,.6) 100%);
}

/* Death: a full-width band in the lower third, above the marks, so the
   wreck cam and the horizon stay in view above it. While it is up the centre
   symbology fades (the .dead class is the plain twin of the :has() rule). */
.dead-card {
  position: absolute; left: 0; right: 0; top: 74%; transform: translateY(-50%); z-index: 6;
  text-align: center; padding: 14px 0 12px;
  background: linear-gradient(90deg, transparent, rgba(30,4,4,.8) 18%, rgba(30,4,4,.8) 82%, transparent);
}
.dead-card::before, .dead-card::after {
  content: ''; position: absolute; left: 10%; right: 10%; height: 1px;
  background: var(--danger); opacity: .8;
  -webkit-mask: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  mask: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
}
.dead-card::before { top: 0; } .dead-card::after { bottom: 0; }
.dead-title { font: 800 48px/1 var(--font-d); letter-spacing: .24em; text-indent: .24em; color: var(--danger); text-shadow: var(--hud-shadow), 0 0 24px rgba(255,74,58,.5); }
.dead-by { font: 600 13px var(--font-u); letter-spacing: .12em; text-transform: uppercase; color: rgba(205,228,244,.8); margin-top: 5px; }
.dead-timer { margin-top: 6px; font: 700 24px/1 var(--font-m); letter-spacing: .1em; color: var(--amber); }
#hud:has(.dead-card:not(.hidden)) :is(.ladder, .reticle, .gun-cross, .pipper, #marks, .warnings),
#hud.dead :is(.ladder, .reticle, .gun-cross, .pipper, #marks, .warnings) { visibility: hidden; }
/* The countdown / FIGHT banner gets the same clear stage (.banner-up is the
   plain twin of the :has() rule, toggled by banner() in main.js). */
#hud:has(.banner:not(.hidden)) :is(.ladder, .reticle, .gun-cross, .pipper),
#hud.banner-up :is(.ladder, .reticle, .gun-cross, .pipper) { visibility: hidden; }

.ctp {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(3,8,16,.5); pointer-events: auto; cursor: pointer;
}
.ctp span {
  font: 800 30px/1 var(--font-d); letter-spacing: .4em; text-indent: .4em; color: #fff;
  padding: 14px 40px;
  background: var(--brk-bg); background-repeat: no-repeat;
  animation: blink 1.1s infinite alternate;
}

/* loading */
#loading .msg { position: relative; padding-bottom: 18px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; font-size: 11px; }
#loading .msg::after {
  content: ''; position: absolute; left: 20%; right: 20%; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent) 0 0 / 40% 100% no-repeat, rgba(160,225,255,.12);
  animation: loadbar 1.4s ease-in-out infinite;
}
@keyframes loadbar { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* =====================================================================
   12. TOUCH (body.touch is set by main.js on coarse-pointer devices)
   ===================================================================== */
.touch-only { display: none; }
.touch .touch-only { display: block; }
.touch .desktop-only { display: none; }
.ctp .touch-only, .ctp .desktop-only { display: inline; }
.touch .ctp .desktop-only, body:not(.touch) .ctp .touch-only { display: none; }

#touch {
  position: fixed; inset: 0; z-index: 25;
  pointer-events: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-family: var(--font-u); color: var(--ice);
}
#touch > * { pointer-events: auto; }

/* Floating stick: the left half of the screen is the pad. A ringed pad with
   a crosshair and a dark knob with a light ring and a centre dot, so it reads
   over green ground and grey city alike. */
.tc-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; }
.tc-stick {
  position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px;
  border-radius: 50%; border: 1.5px solid rgba(232,247,255,.75);
  background:
    linear-gradient(rgba(232,247,255,.4), rgba(232,247,255,.4)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(rgba(232,247,255,.4), rgba(232,247,255,.4)) 0 50% / 100% 1px no-repeat,
    radial-gradient(circle, rgba(3,9,18,.22), rgba(3,9,18,.5));
  box-shadow: 0 0 0 1px rgba(0,8,16,.45), inset 0 0 0 1px rgba(0,8,16,.45);
}
.tc-stick::before {
  content: ''; position: absolute; inset: 22px; border-radius: 50%;
  border: 1px solid rgba(232,247,255,.45); box-shadow: var(--edge), inset var(--edge);
}
/* Resting position: parked in the corner until a thumb picks it up. */
.tc-stick.idle {
  left: calc(96px + env(safe-area-inset-left, 0px));
  top: auto; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  margin-bottom: 0; opacity: .6;
}
.tc-stick.idle .tc-knob { opacity: .8; }
.tc-stick-label {
  position: absolute; left: 0; right: 0; bottom: -20px; text-align: center;
  font: 600 10px var(--font-u); letter-spacing: .3em; color: rgba(232,247,255,.85); display: none;
  text-shadow: var(--hud-shadow);
}
.tc-stick.idle .tc-stick-label { display: block; }
.tc-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  margin: -27px 0 0 -27px; border-radius: 50%; will-change: transform;
  background: radial-gradient(circle, var(--ice) 0 3px, transparent 4px), rgba(6,12,22,.88);
  border: 2px solid var(--ice);
  box-shadow: 0 4px 12px rgba(0,0,0,.5), 0 0 0 1px rgba(0,8,16,.5), inset 0 0 0 4px rgba(6,12,22,.9), inset 0 0 0 5px rgba(190,236,255,.45);
}

/* Throttle: a quiet rectangular gauge on the right edge, tick rail down the
   left, orange top edge on the fill. */
.tc-throttle {
  position: absolute; right: calc(14px + env(safe-area-inset-right, 0px));
  top: 30%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: 44px;
  border: 1px solid rgba(232,247,255,.6); background: rgba(3,9,18,.5); overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,8,16,.4);
}
.tc-throttle::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; z-index: 1;
  background: repeating-linear-gradient(180deg, rgba(232,247,255,.65) 0 1px, transparent 1px 10%) 0 5% / 100% 100%;
}
.tc-throttle.on { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(0,8,16,.4), 0 0 12px rgba(255,157,58,.35); }
.tc-throttle.on .tc-throttle-fill { background: linear-gradient(180deg, rgba(255,157,58,.5), rgba(255,157,58,.28)); }
.tc-throttle-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 80%;
  background: linear-gradient(180deg, rgba(232,247,255,.42), rgba(232,247,255,.3));
  transition: height .06s linear;
}
.tc-throttle-fill::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--amber); box-shadow: 0 1px 0 rgba(0,8,16,.6); }
.tc-throttle-label {
  position: absolute; left: 0; right: 0; top: 7px; text-align: center; z-index: 1;
  font: 700 10px var(--font-u); letter-spacing: .2em; color: var(--ice); text-shadow: var(--hud-shadow);
}

/* Button cluster, bottom right, hand-placed for a thumb resting on FIRE.
   FIRE is red, MSL orange, A/B cyan, everything else white; every button has
   a dark fill and a dark 1px edge so it reads on any ground. */
.tc-cluster {
  position: absolute; width: 230px; height: 150px;
  right: calc(70px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.tc-btn {
  --bc: var(--ice); --bcr: 232,247,255;
  position: absolute; display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px solid var(--bc); background: rgba(3,9,18,.62);
  color: var(--bc); font: 700 12px var(--font-u); letter-spacing: .1em; text-indent: .1em;
  box-shadow: 0 0 0 1px rgba(0,8,16,.5), 0 3px 10px rgba(0,0,0,.45), inset 0 0 0 3px rgba(3,9,18,.6), inset 0 0 0 4px rgba(var(--bcr), .3);
  text-shadow: var(--hud-shadow);
  transition: transform .06s, background .06s;
}
.tc-btn.on { background: var(--bc); color: var(--ink); transform: scale(.92); text-shadow: none; }
.tc-fire {
  --bc: var(--danger); --bcr: 255,74,58;
  right: 0; bottom: 0; width: 78px; height: 78px; font-size: 16px; letter-spacing: .16em;
  color: #fff;
  background: radial-gradient(circle at 50% 38%, rgba(255,74,58,.42), rgba(36,6,4,.78) 72%);
  box-shadow: 0 0 0 1px rgba(0,8,16,.5), 0 0 18px rgba(255,74,58,.35), 0 3px 10px rgba(0,0,0,.45), inset 0 0 0 3px rgba(30,4,4,.55), inset 0 0 0 4px rgba(255,74,58,.55);
}
.tc-fire.on { background: var(--danger); color: #fff; text-shadow: var(--hud-shadow); }
.tc-msl {
  --bc: var(--amber); --bcr: 255,157,58;
  right: 96px; bottom: 0; width: 56px; height: 56px; color: var(--amber-hi);
  background: radial-gradient(circle at 50% 38%, rgba(255,157,58,.24), rgba(3,9,18,.68) 72%);
}
.tc-msl.on { background: var(--amber); color: #221000; }
.tc-ab { --bc: var(--cyan); --bcr: 99,220,255; right: 12px; bottom: 92px; width: 56px; height: 56px; }
.tc-ab.on { background: var(--cyan); color: var(--ink); }
.tc-rr { right: 78px; bottom: 96px; font-size: 22px; text-indent: 0; }
.tc-rl { right: 130px; bottom: 96px; font-size: 22px; text-indent: 0; }
.tc-lvl { right: 158px; bottom: 6px; }
.tc-cam { right: 182px; bottom: 96px; }
@media (max-width: 720px) {
  .tc-cluster { transform: scale(.85); transform-origin: bottom right; }
  .tc-throttle { width: 38px; }
}

/* ---------- HUD, compacted so the thumbs have room ---------- */
.touch .heading { top: 8px; width: min(360px, 42vw); height: 52px; }
.touch .heading-tape, .touch .heading-inner, .touch .heading-tick { height: 24px; }
.touch .heading-tick b { font-size: 10px; top: 0; }
.touch .heading-mark { top: 25px; border-left-width: 5px; border-right-width: 5px; border-bottom-width: 7px; margin-left: -5px; }
.touch .heading-box { top: 32px; font-size: 12px; padding: 0 6px 0 7px; }
.touch .feed { left: 14px; top: 8px; font-size: 11px; gap: 3px; }
.touch .feed div { padding: 3px 10px 3px 6px; }
.touch .feed div:nth-child(n+4) { display: none; }
.touch .top-right { right: calc(12px + env(safe-area-inset-right, 0px)); top: 8px; }
.touch .clock { font-size: 20px; padding: 4px 8px 3px; }
.touch .env-line { font-size: 10px; margin-top: 2px; gap: 6px; }
.touch .env-line #envWx { font-size: 9px; }
.touch .score { margin-top: 4px; gap: 2px; width: 128px; }
.touch .score-row { font-size: 11px; padding: 2px 6px 2px 5px; }
.touch .tape { padding: 3px 8px; min-width: 84px; }
.touch .tape-val { font-size: 26px; line-height: 1; }
.touch .tape-label { font-size: 9px; line-height: 10px; }
.touch .tape-unit { display: none; }
.touch .tape-l { left: calc(14px + env(safe-area-inset-left, 0px)); }
.touch .tape-r { right: calc(74px + env(safe-area-inset-right, 0px)); }
/* A shorter ladder box leaves the band above the radar for the cautions. */
.touch .ladder { width: 240px; height: 150px; margin: -75px 0 0 -120px; }
.touch .rung::before, .touch .rung::after { width: 40px; }
.touch .rung.zero::before, .touch .rung.zero::after { width: 100px; }
.touch .rung .n { font-size: 10px; }
.touch .rung .n.l { right: 96px; }
.touch .rung .n.r { left: 96px; }
.touch .reticle { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
.touch .gun-cross { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
.touch .mark .m-name { font-size: 11px; }
.touch .mark .m-dist { font-size: 10px; }
/* Cautions sit in the band between the ladder and the centred radar, as one
   row (wrapping upward) so they stay clear of the jet and the buttons. */
.touch .warnings {
  top: auto; bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  flex-direction: row; flex-wrap: wrap; justify-content: center;
  min-width: 0; max-width: 260px; padding: 4px 5px; gap: 4px;
}
.touch .warnings::before { display: none; }
.touch .warn { font-size: 12px; padding: 3px 9px; border-width: 1.5px; }
@media (max-width: 720px) {
  /* the scaled cluster's CAM button reaches further in; nudge the cautions
     left of it */
  .touch .warnings { left: calc(50% - 44px); max-width: 236px; }
}
.touch .banner { padding: 8px 0; left: 18%; right: 18%; }
.touch .banner .big-text { font-size: 56px; }
.touch .banner .sub-text { font-size: 12px; }
/* Phones have no free lower third (stick, gauges, radar and cluster live
   there), so the death band sits high, under the heading box and above the
   horizon, between the feed and the scoreboard. */
.touch .dead-card {
  padding: 6px 0 6px; top: 31%; left: 22%; right: 22%;
  background: linear-gradient(90deg, transparent, rgba(30,4,4,.9) 12%, rgba(30,4,4,.9) 88%, transparent);
}
.touch .dead-title { font-size: 28px; }
.touch .dead-by { font-size: 11px; margin-top: 2px; }
.touch .dead-timer { font-size: 18px; margin-top: 3px; }
/* Bottom row, left to right: the parked stick, the bars, the radar, then the
   button cluster. The touch test asserts none of them overlap at 667x375. */
.touch .bottom-left {
  left: calc(174px + env(safe-area-inset-left, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 110px; padding: 5px 6px 4px;
}
.touch .bar { margin-bottom: 3px; gap: 5px; font-size: 9px; }
.touch .bar span { width: 22px; }
.touch .bar-track { height: 6px; }
.touch .msl-count { margin-top: 2px; height: 11px; gap: 3px; }
.touch .msl-count::before { width: 22px; font-size: 9px; margin-right: 2px; }
.touch .msl-count i { width: 6px; height: 11px; }
.touch .bottom-right {
  left: 50%; right: auto; margin-left: -42px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.touch .radar { width: 84px; height: 84px; }
.touch .radar-lbl { font-size: 8px; }
.touch .radar-lbl.n { top: 3px; }
.touch .radar-lbl.rng { bottom: 8px; right: 13px; }
.touch .radar-self { width: 10px; height: 12px; margin: -7px 0 0 -5px; }
.touch .radar-self::before { border-left-width: 5px; border-right-width: 5px; border-bottom-width: 12px; }
.touch .radar-self::after { left: 1.5px; top: 2px; border-left-width: 3.5px; border-right-width: 3.5px; border-bottom-width: 9px; }
.touch .ctp span { font-size: 22px; padding: 10px 26px; }

/* ---------- 13. portrait: ask for landscape, but only once flying ---------- */
.rotate {
  display: none; position: fixed; inset: 0; z-index: 60;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse at 50% 40%, #132038, #06101c 70%); color: var(--ice);
}
.rotate-icon {
  width: 46px; height: 82px; border: 2px solid var(--ice); border-radius: 8px;
  box-shadow: 0 0 18px rgba(99,220,255,.35), inset 0 0 0 3px #06101c, inset 0 0 0 4px rgba(99,220,255,.45);
  animation: rotatehint 1.6s ease-in-out infinite;
}
@keyframes rotatehint { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
.rotate-text { font: 700 20px var(--font-d); letter-spacing: .34em; text-indent: .34em; text-align: center; color: var(--amber); }
@media (orientation: portrait) {
  .touch #hud:not(.hidden) ~ .rotate { display: flex; }
}

/* ---------- 14. short or narrow screens: compact the cards, let them scroll ---------- */
@media (max-height: 560px), (max-width: 480px) {
  .screen { align-items: flex-start; overflow-y: auto; padding: 10px 0; }
  .screen::before, .screen::after { display: none; }
  /* auto margins centre a card that fits and collapse to 0 for one that has
     to scroll — flex-start alone pins a short card to the top of a tall
     portrait screen. */
  .card { padding: 12px 20px 10px; margin: auto 0; }
  .card.wide { width: min(600px, 94vw); }
  .kicker { margin-bottom: 4px; font-size: 10px; }
  .logo { margin: 0 0 8px; }
  .logo-top { font-size: 44px; }
  .logo-rule { margin: 4px auto 4px; }
  .logo-sub { font-size: 10px; }
  .row { margin-bottom: 8px; }
  .row label { margin-bottom: 4px; }
  input { padding: 7px 12px; font-size: 15px; }
  .livery { padding: 6px 4px 5px; }
  .livery .chip { height: 12px; margin-bottom: 5px; }
  button { padding: 10px 16px; font-size: 14px; }
  .mini { padding: 3px 8px; font-size: 9px; }
  .btns { margin-top: 8px; gap: 6px; }
  .msg { margin-top: 8px; }
  .hint { margin-top: 8px; line-height: 1.6; padding-top: 8px; font-size: 11px; }
  .hint-note { margin-bottom: 4px; }
  .status-line { margin-top: 8px; padding-top: 6px; }
  .code { font-size: 32px; margin: 4px 0 4px; padding: 4px 12px; }
  .lobby-head { margin-bottom: 8px; }
  .slot { padding: 6px 10px 6px 8px; font-size: 14px; }
  .slot .dot, .res-row .dot { height: 18px; }
  .bot-row { margin-top: 6px; gap: 4px; }
  /* The two conditions rows have to fit on a 390 px phone without scrolling:
     tighter chips, and the blurb under the code goes (the roster says it). */
  .env-rows { margin-top: 5px; gap: 3px; }
  .env-row { gap: 4px; }
  .env-row .small { min-width: 52px; font-size: 10px; }
  .lobby-blurb { display: none; }
  #lobby button.big { padding: 8px 16px; }
  .slot { padding: 4px 10px 4px 8px; }
  .slot .dot { height: 16px; }
  .res-title { font-size: clamp(30px, 9vw, 40px); margin: 0 0 10px; padding-bottom: 6px; }
  .res-row { padding: 6px 12px 6px 8px; font-size: 14px; }
}
@media (max-width: 480px) {
  .res-row { grid-template-columns: 26px 9px 1fr 40px 44px 44px; gap: 8px; padding: 6px 8px; font-size: 14px; }
  .res-row .num { font-size: 15px; }
  .res-row .rank { width: 24px; height: 24px; font-size: 12px; }
  .status-line { justify-content: center; }
}
