/* The raid HUD (js/client/ui/hud.js). Tokens come from style.css (fallbacks here keep it standalone).
   Layout: vitals top-left, timer + ticker + toasts top-centre, minimap + extracts top-right,
   money bottom-left, weapon + quick slots bottom-right, prompt bottom-centre.
   On touch (.hud-touch) the bottom corners belong to the sticks: weapon and money move up, the slots move aside.
   --efb-mm (the minimap size) is defined on :root because css/touch.css reads it to keep the top band free. */

:root { --efb-mm: 176px; }
@media (max-width: 760px), (max-height: 540px) { :root { --efb-mm: 108px; } }
@media (max-width: 420px) { :root { --efb-mm: 92px; } }

#ui > .efb-hud, .efb-hud { pointer-events: none; }        /* style.css gives #ui > * pointer events */
.efb-hud {
  --hy: var(--bkv, #ffd200);
  --hink: var(--bkv-ink, #17150f);
  --hbg: rgba(15, 17, 20, 0.78);
  --hbg2: rgba(15, 17, 20, 0.9);
  --hline: rgba(255, 255, 255, 0.12);
  --htext: var(--text, #efebe2);
  --hdim: var(--text-dim, #a9a59b);
  --hgood: var(--good, #71d36b);
  --hbad: var(--bad, #ff5b4d);
  --hwarn: var(--warn, #ffb03a);
  --hhead: var(--font-head, 'Anton', Impact, sans-serif);
  --hbody: var(--font-body, 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif);
  --hmono: var(--font-mono, 'JetBrains Mono', ui-monospace, Consolas, monospace);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --e: 12px;                                   /* edge gap */
  position: absolute;                          /* no z-index: its layers stack with the touch layer and panels */
  inset: 0;
  overflow: hidden;
  color: var(--htext);
  font-family: var(--hbody);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.15;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.efb-hud * { box-sizing: border-box; }
.efb-hud > * { z-index: 10; }

.hud-block {
  background: var(--hbg);
  border: 1px solid var(--hline);
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* ---------- screen effects */
.hud-fx { position: absolute; inset: 0; z-index: 5; }
.fx { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.fx-dmg { background: radial-gradient(ellipse at center, transparent 45%, rgba(210, 20, 10, 0.55) 100%); }
.fx-dmg.go { animation: fx-flash 0.5s ease-out; }
.fx-heal { background: radial-gradient(ellipse at center, transparent 50%, rgba(80, 220, 110, 0.45) 100%); }
.fx-heal.go { animation: fx-flash 0.8s ease-out; }
.fx-police {
  background:
    linear-gradient(90deg, rgba(40, 90, 255, 0.55), transparent 22%, transparent 78%, rgba(255, 30, 30, 0.55));
}
.fx-police.go { animation: fx-flash 1.2s ease-out; }
.fx-police.wanted { animation: fx-siren 0.9s steps(1) infinite; }
.fx-low { background: radial-gradient(ellipse at center, transparent 40%, rgba(150, 0, 0, 0.6) 100%); }
.fx-low.on { animation: fx-beat 1.1s ease-in-out infinite; }
.fx-low.crit { animation-duration: 0.7s; }
@keyframes fx-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-beat { 0%, 100% { opacity: 0.25; } 12% { opacity: 0.85; } 24% { opacity: 0.35; } 36% { opacity: 0.75; } }
@keyframes fx-siren { 0% { opacity: 0.3; transform: scaleX(-1); } 50% { opacity: 0.3; transform: none; } }

.hud-world { position: absolute; inset: 0; z-index: 8; }

/* ---------- vitals (top-left) */
.hud-vitals {
  position: absolute;
  left: calc(var(--sl) + var(--e));
  top: calc(var(--st) + var(--e));
  width: 250px;
  padding: 7px 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud-vitals.shake { animation: hud-shake 0.3s; }
@keyframes hud-shake { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
.hud-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 6px; position: relative; }
.hud-row .lbl { font-weight: 800; font-size: 11px; letter-spacing: 0.08em; color: var(--hdim); }
.hud-row .val { font-family: var(--hmono); font-size: 12px; min-width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 10px; border-radius: 3px; background: rgba(0, 0, 0, 0.55); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar .fill, .bar .trail { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; }
.bar .trail { background: #fff; opacity: 0.55; transition: width 0.55s ease-in; }
.bar .fill { transition: width 0.12s linear; }
.hud-row.hp .fill { background: linear-gradient(180deg, #8ae67f, var(--good-deep, #2f8a2a)); }
.hud-row.hp.low .fill { background: linear-gradient(180deg, #ff8a78, var(--bad-deep, #b0261b)); }
.hud-row.hp.low .val { color: var(--hbad); }
.hud-row.hp .bar { height: 14px; }
.hud-row.hp .val { font-size: 14px; font-weight: 800; }
.hud-row.st .fill { background: linear-gradient(180deg, #ffe45c, #d9a900); }
.hud-row.st .trail { display: none; }
.hud-row.st.low .fill { background: #9c7f1a; }
.hud-row.kg .fill { background: linear-gradient(180deg, #bfc5cc, #7c838b); }
.hud-row.kg.over .fill { background: linear-gradient(180deg, #ffc46b, #d97a00); }
.hud-row.kg.over .val { color: var(--hwarn); }
.bar .tick { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--hy); box-shadow: 0 0 2px #000; }
.hud-row .pen {
  position: absolute; right: 56px; top: -1px;
  font-size: 11px; font-weight: 800; color: #111; background: var(--hwarn);
  padding: 0 4px; border-radius: 3px; text-shadow: none;
}
.hud-row .pen:empty { display: none; }

/* police meter: a two-lamp light bar */
.hud-police {
  display: none;
  grid-template-columns: 14px 1fr 14px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  margin-top: 2px;
  --blink: 1s;
}
.hud-police.on { display: grid; }
.hud-police .pbar { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.hud-police .pbar .fill { height: 100%; width: 0; background: linear-gradient(90deg, #3a6bff, #ff3b30); transition: width 0.3s; }
.hud-police .lamp { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35); opacity: 0.45; }
.hud-police .lamp.b { background: #3a6bff; }
.hud-police .lamp.r { background: #ff3b30; }
.hud-police .ptxt { grid-column: 1 / -1; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: 0.18em; color: var(--hdim); }
.hud-police.hot .lamp.b { animation: lamp var(--blink) steps(1) infinite; }
.hud-police.hot .lamp.r { animation: lamp var(--blink) steps(1) infinite calc(var(--blink) / -2); }
.hud-police.wanted .lamp.b { animation: lamp 0.35s steps(1) infinite; }
.hud-police.wanted .lamp.r { animation: lamp 0.35s steps(1) infinite -0.175s; }
.hud-police.wanted .ptxt {
  font-family: var(--hhead); font-weight: 400; font-size: 16px; letter-spacing: 0.08em;
  animation: wanted-txt 0.7s steps(1) infinite;
}
@keyframes lamp { 0% { opacity: 1; box-shadow: 0 0 12px 3px currentColor; } 50% { opacity: 0.3; box-shadow: none; } }
.hud-police .lamp.b { color: #3a6bff; }
.hud-police .lamp.r { color: #ff3b30; }
@keyframes wanted-txt { 0% { color: #ff4a3d; } 50% { color: #6d95ff; } }

/* ---------- top centre: timer, ticker, toasts */
.hud-top {
  position: absolute;
  left: 50%;
  top: calc(var(--st) + var(--e));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(460px, calc(100vw - 2 * var(--efb-mm) - 60px));
}
.hud-timer { padding: 3px 14px 5px; text-align: center; min-width: 96px; }
.hud-timer .t { font-family: var(--hmono); font-weight: 700; font-size: 24px; letter-spacing: 0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hud-timer .prog { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 2px; }
.hud-timer .prog .fill { height: 100%; width: 100%; background: var(--hy); }
.hud-timer.low { border-color: rgba(255, 91, 77, 0.7); }
.hud-timer.low .t { color: var(--hbad); }
.hud-timer.low .prog .fill { background: var(--hbad); }
.hud-timer.crit { animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(255, 91, 77, 0.35); } }
.hud-mapname { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hdim); margin-top: -4px; }
.hud-mapname:empty { display: none; }

/* BKV passenger-information ticker (extract news) */
.hud-ticker {
  display: none;
  max-width: 100%;
  overflow: hidden;
  background: #0b0b09;
  border: 2px solid #26261f;
  border-radius: 4px;
  padding: 3px 0;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9), 0 2px 8px rgba(0, 0, 0, 0.4);
  -webkit-mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.hud-ticker.on { display: block; }
.hud-ticker .txt {
  display: inline-block;
  padding-left: 100%;
  white-space: nowrap;
  font-family: var(--hmono);
  font-weight: 700;
  font-size: 13px;
  color: #ffb000;
  text-shadow: 0 0 6px rgba(255, 160, 0, 0.75);
  letter-spacing: 0.06em;
  animation: ticker 7s linear 1 forwards;
}
@keyframes ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

.hud-toasts { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.hud-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 12px 5px 6px;
  border-radius: 6px;
  background: var(--hbg2);
  border-left: 4px solid var(--info, #7cc6ff);
  font-size: 15px;
  font-weight: 700;
  animation: toast-in 0.22s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.hud-toast.out { opacity: 0; transform: translateY(-6px); }
.hud-toast.bump { animation: toast-bump 0.25s; }
.hud-toast .ti {
  flex: none; display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 12px; font-weight: 800; color: #111; background: var(--info, #7cc6ff); text-shadow: none;
}
.hud-toast .tt { overflow-wrap: anywhere; }
.hud-toast .tc { font-family: var(--hmono); font-size: 12px; color: var(--hy); }
.hud-toast .tc:empty { display: none; }
.hud-toast.good { border-left-color: var(--hgood); }
.hud-toast.good .ti { background: var(--hgood); }
.hud-toast.bad { border-left-color: var(--hbad); }
.hud-toast.bad .ti { background: var(--hbad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(0.96); } }
@keyframes toast-bump { 50% { transform: scale(1.05); } }

/* incident: caution tape across the screen */
.hud-incident {
  position: absolute;
  left: 0; right: 0;
  top: 30%;
  display: none;
  flex-direction: column;
  align-items: stretch;
  transform: rotate(-2deg);
  z-index: 12;
}
.hud-incident.on { display: flex; animation: inc-in 5.2s ease-out forwards; }
.hud-incident .tape {
  height: 14px;
  background: repeating-linear-gradient(-45deg, var(--hy) 0 14px, #111 14px 28px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.hud-incident .itxt {
  background: rgba(10, 10, 10, 0.88);
  color: var(--hy);
  text-align: center;
  font-family: var(--hhead);
  font-size: clamp(18px, 3.2vw, 30px);
  letter-spacing: 0.04em;
  padding: 6px 16px;
  text-transform: uppercase;
}
@keyframes inc-in {
  0% { opacity: 0; transform: rotate(-2deg) scaleX(0.2); }
  6% { opacity: 1; transform: rotate(-2deg) scaleX(1.02); }
  9% { transform: rotate(-2deg) scaleX(1); }
  88% { opacity: 1; }
  100% { opacity: 0; transform: rotate(-2deg) translateY(-10px); }
}

/* ---------- top right: minimap and extracts */
.hud-tr {
  position: absolute;
  right: calc(var(--sr) + var(--e));
  top: calc(var(--st) + var(--e));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hud-mm {
  position: relative;
  width: var(--efb-mm);
  height: var(--efb-mm);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55), 0 6px 18px rgba(0, 0, 0, 0.4);
  background: #202226;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
}
.hud-mm.under { border-color: rgba(228, 31, 24, 0.7); }
.hud-mm .mmc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud-mm .mm-n {
  position: absolute; top: 3px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 800; color: var(--hy);
}
.hud-mm .mm-lv {
  position: absolute; left: 4px; bottom: 3px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  color: #fff; background: var(--m2, #e41f18); padding: 0 4px; border-radius: 3px; text-shadow: none;
}
.hud-mm .mm-lv:empty { display: none; }
.hud-mm .mm-hint {
  position: absolute; right: 4px; top: 4px;
  width: 16px; height: 16px; display: grid; place-items: center;
  font-family: var(--hmono); font-size: 10px; font-weight: 700;
  border-radius: 3px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.3);
}
.hud-mm .mm-attr { position: absolute; right: 3px; bottom: 1px; font-size: 8px; color: rgba(255, 255, 255, 0.55); text-shadow: 0 0 2px #000; }
.efb-hud.hud-touch .hud-mm .mm-hint, .efb-hud.hud-pad .hud-mm .mm-hint { display: none; }

.hud-xlist { display: flex; flex-direction: column; gap: 4px; width: 232px; }
.xr {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 4px 7px 4px 5px;
  border-radius: 6px;
  background: var(--hbg);
  border: 1px solid var(--hline);
  border-left: 4px solid #9aa0a8;
}
.xr .xi { font-size: 16px; text-align: center; text-shadow: none; }
.xr .xb { min-width: 0; }
.xr .xn { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr .xm { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 12px; color: var(--hdim); }
.xr .xs { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.xr .xe { font-family: var(--hmono); font-size: 11px; }
.xr .xe:empty, .xr .xneed:empty { display: none; }
.xr .xneed.ok { color: var(--hgood); }
.xr .xneed.no { color: var(--hbad); }
.xr .xd { display: flex; flex-direction: column; align-items: center; font-family: var(--hmono); font-size: 11px; color: var(--hdim); }
.xr .xa { display: inline-block; color: var(--hy); font-size: 12px; line-height: 1; transition: transform 0.2s; }
.xr.open { border-left-color: var(--hgood); }
.xr.open .xs { color: var(--hgood); }
.xr.arriving { border-left-color: var(--hy); }
.xr.arriving .xs { color: var(--hy); }
.xr.leaving { border-left-color: var(--hwarn); }
.xr.leaving .xs { color: var(--hwarn); animation: blink 0.8s steps(1) infinite; }
.xr.closed { opacity: 0.8; }
.xr.na { opacity: 0.55; border-left-color: var(--bad-deep, #b0261b); }
.xr.na .xn { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.35); }
.xr.here { box-shadow: 0 0 0 2px var(--hy); }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- bottom left: money and pickups */
.hud-bl {
  position: absolute;
  left: calc(var(--sl) + var(--e));
  bottom: calc(var(--sb) + var(--e));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.hud-feed { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.hud-feed .fd {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 4px; border-radius: 5px; background: rgba(15, 17, 20, 0.66);
  font-size: 13px; animation: feed-in 2.6s ease-out forwards;
}
.hud-feed .fg { font-size: 15px; min-width: 18px; text-align: center; text-shadow: none; }
@keyframes feed-in { 0% { opacity: 0; transform: translateX(-10px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
.hud-money { padding: 5px 12px 6px; display: flex; flex-direction: column; gap: 1px; min-width: 150px; }
.hud-money .cash { position: relative; font-family: var(--hmono); font-weight: 800; font-size: 20px; color: var(--hy); font-variant-numeric: tabular-nums; }
.hud-money .pop {
  position: absolute; left: 100%; top: 0; margin-left: 8px; white-space: nowrap;
  font-size: 14px; opacity: 0;
}
.hud-money .pop.up { color: var(--hgood); }
.hud-money .pop.down { color: var(--hbad); }
.hud-money .pop.go { animation: pop-up 1.4s ease-out; }
@keyframes pop-up { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.hud-money .bottles { display: flex; align-items: baseline; gap: 6px; font-size: 15px; }
.hud-money .bottles .ic { text-shadow: none; }
.hud-money .bottles .v { font-family: var(--hmono); font-weight: 800; }
.hud-money .bottles .sub { font-size: 12px; color: var(--hdim); }
.hud-money.bump { animation: money-bump 0.25s; }
@keyframes money-bump { 50% { transform: scale(1.06); } }

/* ---------- bottom right: weapon and quick slots */
.hud-br {
  position: absolute;
  right: calc(var(--sr) + var(--e));
  bottom: calc(var(--sb) + var(--e));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hud-slots { display: flex; gap: 5px; pointer-events: auto; }
.hud-slots.none { display: none; }
.slot {
  --sbg: #2a2d33;
  position: relative;
  width: 44px; height: 44px;
  border-radius: 7px;
  background: var(--sbg);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.slot .k {
  position: absolute; left: 2px; top: 0;
  font-family: var(--hmono); font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.75);
}
.slot .g { font-size: 22px; line-height: 1; text-shadow: none; }
.slot .n { position: absolute; right: 3px; bottom: 0; font-family: var(--hmono); font-size: 10px; font-weight: 700; }
.slot.empty { background: rgba(15, 17, 20, 0.45); border-style: dashed; cursor: default; }
.slot.cont { border-left-color: transparent; opacity: 0.7; }
.slot:active:not(.empty) { transform: translateY(2px); box-shadow: none; }
.efb-hud.hud-touch .slot .k, .efb-hud.hud-pad .slot .k { display: none; }

.hud-weapon {
  position: relative;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 9px 7px;
  min-width: 220px;
}
.hud-weapon .wg {
  --wbg: #ffb347;
  width: 50px; height: 50px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 30px; line-height: 1; text-shadow: none;
  background: var(--wbg);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.hud-weapon .wn { font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.hud-weapon .wa { display: flex; align-items: baseline; gap: 5px; font-family: var(--hmono); font-variant-numeric: tabular-nums; }
.hud-weapon .wa .n { font-size: 28px; font-weight: 800; line-height: 1; }
.hud-weapon .wa .cap { font-size: 14px; color: var(--hdim); }
.hud-weapon .wa .tot { font-size: 13px; color: var(--hdim); }
.hud-weapon .wa.low .n { color: var(--hwarn); }
.hud-weapon .ww { font-size: 12px; color: var(--hdim); text-transform: uppercase; letter-spacing: 0.06em; }
.hud-weapon .ww:empty { display: none; }
.hud-weapon .wk { font-size: 11px; color: var(--hdim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.hud-weapon .wk:empty { display: none; }
.hud-weapon.empty .wa .n, .hud-weapon.empty .ww { color: var(--hbad); }
.hud-weapon.empty .ww { animation: blink 0.9s steps(1) infinite; }
.hud-weapon.melee .wa { display: none; }
.hud-weapon .wrl { position: absolute; left: 7px; right: 7px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: none; }
.hud-weapon .wrl .fill { height: 100%; width: 0; background: var(--hy); }
.hud-weapon.reloading .wrl { display: block; }
.hud-weapon.reloading .ww { color: var(--hy); }

/* ---------- prompt and extract hint (bottom centre) */
.hud-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sb) + 150px);
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 6px 16px 6px 6px;
  border-radius: 10px;
  background: var(--hbg2);
  border: 2px solid rgba(255, 210, 0, 0.55);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 11;
}
.hud-prompt.on { display: flex; animation: prompt-in 0.16s ease-out; }
@keyframes prompt-in { from { opacity: 0; transform: translate(-50%, 6px); } }
.hud-prompt .key {
  --p: 0;
  position: relative;
  flex: none;
  min-width: 34px; height: 34px; padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--hy);
  color: var(--hink);
  font-family: var(--hmono);
  font-weight: 800;
  font-size: 17px;
  text-shadow: none;
  box-shadow: 0 3px 0 #6b5600;
}
.hud-prompt .key.word { font-family: var(--hbody); font-size: 14px; text-transform: uppercase; letter-spacing: 0.03em; }
.hud-prompt .key.hide { display: none; }
.hud-prompt .kring {
  position: absolute; inset: -5px; border-radius: 10px; pointer-events: none;
  background: conic-gradient(#fff calc(var(--p) * 360deg), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 3px;
}
.hud-prompt .ptx { font-weight: 800; font-size: 17px; }
.hud-prompt .phold { font-size: 13px; color: var(--hdim); }
.hud-prompt .phold:empty { display: none; }
.hud-need {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sb) + 206px);
  transform: translateX(-50%);
  display: none;
  max-width: min(520px, calc(100vw - 32px));
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(120, 18, 12, 0.88);
  border: 1px solid rgba(255, 120, 100, 0.6);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  z-index: 11;
}
.hud-need.on { display: block; }

/* ---------- crosshair and rings */
.hud-cross {
  --rl: 0;
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px;
  translate: -50% -50%;
  display: none;
  z-index: 13;
}
.hud-cross.on { display: block; }
.hud-cross .ch {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.hud-cross .ch::before, .hud-cross .ch::after {
  content: ''; position: absolute; background: var(--hy); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.hud-cross .ch::before { left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; }
.hud-cross .ch::after { display: none; }
.hud-cross.melee .ch { border-style: dashed; width: 26px; height: 26px; inset: 2px; }
.hud-cross .carc {
  position: absolute; inset: -6px; border-radius: 50%; display: none;
  background: conic-gradient(var(--hy) calc(var(--rl) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 3px), #000 calc(50% - 2px));
  mask: radial-gradient(circle, transparent 0 calc(50% - 3px), #000 calc(50% - 2px));
}
.hud-cross.rl .carc { display: block; }

.hud-ring {
  --p: 0;
  position: absolute; left: 0; top: 0;
  width: 54px; height: 54px;
  translate: -50% -50%;
  display: none;
  z-index: 13;
}
.hud-ring.on { display: block; }
.hud-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(10, 12, 14, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.hud-ring .arc {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--hy) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.15) 0);
  -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 6px), #000 calc(50% - 5px));
  mask: radial-gradient(circle, transparent 0 calc(50% - 6px), #000 calc(50% - 5px));
}
.hud-ring .rlbl {
  position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-weight: 800; font-size: 13px;
  padding: 1px 7px; border-radius: 4px; background: rgba(10, 12, 14, 0.8);
}
.hud-ring .rlbl:empty { display: none; }
.hud-ring.act.atcross { width: 48px; height: 48px; }
.hud-ring.hold { width: 64px; height: 64px; }
.hud-ring.hold .arc { background: conic-gradient(var(--hgood) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.15) 0); }
.hud-ring .rnum {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--hhead); font-size: 24px; color: #fff;
}

/* ---------- speech bubbles and world markers */
.hud-bubble {
  position: absolute; left: 0; top: 0;
  translate: -50% -100%;
  width: max-content;
  max-width: 230px;
  padding: 5px 10px 6px;
  border-radius: 10px;
  background: var(--paper, #f4f1e8);
  color: var(--paper-ink, #26221d);
  text-shadow: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
  display: none;
  transition: opacity 0.35s;
}
.hud-bubble.on { display: block; }
.hud-bubble.fade { opacity: 0; }
.hud-bubble.pop { animation: bubble-pop 0.25s ease-out; }
.hud-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px;
  border: 8px solid transparent; border-bottom: 0; border-top-color: var(--paper, #f4f1e8);
}
.hud-bubble .who { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #8a6d00; }
.hud-bubble .who:empty { display: none; }
.hud-bubble.mine { background: var(--hy); }
.hud-bubble.mine::after { border-top-color: var(--hy); }
@keyframes bubble-pop { from { transform: scale(0.6); opacity: 0; } }

.hud-xmark {
  position: absolute; left: 0; top: 0;
  translate: -50% -100%;
  display: flex; flex-direction: column; align-items: center;
  font-size: 12px; font-weight: 800;
}
.hud-xmark .mi {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 17px; text-shadow: none;
  background: rgba(15, 17, 20, 0.8);
  border: 2px solid var(--hgood);
  box-shadow: 0 0 0 3px rgba(62, 207, 106, 0.25);
}
.hud-xmark.arriving .mi { border-color: var(--hy); box-shadow: 0 0 0 3px rgba(255, 210, 0, 0.25); }
.hud-xmark.open .mi { animation: xmark-pulse 1.4s ease-in-out infinite; }
.hud-xmark .md { font-family: var(--hmono); font-size: 11px; background: rgba(15, 17, 20, 0.7); padding: 0 4px; border-radius: 3px; margin-top: 2px; }
.hud-xmark .ma { display: none; position: absolute; left: 50%; top: 15px; width: 0; height: 0; }
.hud-xmark.edge { translate: -50% -50%; opacity: 0.9; }
.hud-xmark.edge .ma { display: block; }
.hud-xmark.edge .ma::before {
  content: ''; position: absolute; left: 20px; top: -6px;
  border: 6px solid transparent; border-right: 0; border-left: 9px solid var(--hy);
}
.hud-xmark.lv .mi::after { content: '↓'; position: absolute; right: -8px; top: -6px; font-size: 13px; color: #fff; background: var(--m2, #e41f18); border-radius: 3px; padding: 0 2px; }
.hud-xmark .mi { position: relative; }
@keyframes xmark-pulse { 50% { box-shadow: 0 0 0 7px rgba(62, 207, 106, 0); } }

/* ---------- big map */
.hud-bigmap {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: none;
  place-items: center;
  background: rgba(5, 6, 8, 0.55);
  pointer-events: auto;
  padding: calc(var(--st) + 10px) calc(var(--sr) + 10px) calc(var(--sb) + 10px) calc(var(--sl) + 10px);
}
.hud-bigmap.on { display: grid; animation: bm-in 0.18s ease-out; }
@keyframes bm-in { from { opacity: 0; transform: scale(0.98); } }
.bm-box {
  display: flex; flex-direction: column;
  width: min(92vw, 880px, calc(100vh - 20px) * 1.05);
  height: min(90vh, 960px);
  max-height: 100%;
  background: #121417;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.bm-head { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; background: var(--hy); color: var(--hink); text-shadow: none; }
.bm-title { font-family: var(--hhead); font-size: 22px; letter-spacing: 0.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-lv { display: flex; border-radius: 7px; overflow: hidden; border: 2px solid rgba(0, 0, 0, 0.6); }
.bm-lv:empty { display: none; }
.bm-lv .lvb {
  min-height: 36px; padding: 0 12px; border: 0; background: rgba(0, 0, 0, 0.12); color: var(--hink);
  font: 800 14px var(--hbody); text-transform: uppercase; cursor: pointer; touch-action: manipulation;
}
.bm-lv .lvb + .lvb { border-left: 2px solid rgba(0, 0, 0, 0.6); }
.bm-lv .lvb.on { background: #111; color: var(--hy); }
.bm-close {
  width: 44px; height: 44px; border-radius: 8px; border: 0;
  background: #111; color: var(--hy); font-size: 20px; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.bm-cv { position: relative; flex: 1; min-height: 0; }
.bm-cv .bmc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bm-legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 12px;
  font-size: 12px; color: var(--hdim); border-top: 1px solid var(--hline);
}
.bm-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.bm-legend .lg i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid #000; }
.bm-legend .lg.open i { background: #3ecf6a; }
.bm-legend .lg.arriving i { background: #ffd200; }
.bm-legend .lg.closed i { background: #9aa0a8; }
.bm-legend .lg.na i { background: #b0413a; }
.bm-legend .lg.mach i { background: #3ecf6a; border-radius: 2px; }
.bm-legend .lg.ticket i { background: #a77bff; }
.bm-legend .lg.kiosk i { background: #ffd27a; width: 8px; height: 8px; }
.bm-legend .lg.camp i { background: #c98a4b; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); border: 0; }
.bm-legend .lg.me i { background: #ffd200; border-radius: 0; clip-path: polygon(100% 50%, 0 0, 25% 50%, 0 100%); border: 0; }
.bm-attr { padding: 0 12px 6px; font-size: 11px; color: var(--hdim); text-align: right; }

/* ---------- KO */
.hud-ko {
  position: absolute; inset: 0; z-index: 40;
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(ellipse at center, rgba(40, 0, 0, 0.35), rgba(10, 0, 0, 0.88));
  text-align: center;
  padding: 24px;
  pointer-events: auto;
}
.hud-ko.on { display: flex; animation: ko-in 0.6s ease-out; }
@keyframes ko-in { from { opacity: 0; backdrop-filter: blur(0); } }
.ko-stars { position: relative; width: 120px; height: 44px; animation: ko-spin 2.2s linear infinite; }
.ko-stars .s { position: absolute; font-size: 22px; color: var(--hy); text-shadow: 0 0 8px rgba(255, 210, 0, 0.7); }
.ko-stars .s0 { left: 0; top: 14px; }
.ko-stars .s1 { left: 26px; top: 0; }
.ko-stars .s2 { left: 52px; top: 16px; }
.ko-stars .s3 { left: 78px; top: 2px; }
.ko-stars .s4 { left: 100px; top: 14px; }
@keyframes ko-spin { 0% { transform: rotateY(0) rotate(-6deg); } 50% { transform: rotateY(180deg) rotate(6deg); } 100% { transform: rotateY(360deg) rotate(-6deg); } }
.ko-title { font-family: var(--hhead); font-size: clamp(40px, 9vw, 84px); color: var(--hbad); letter-spacing: 0.03em; line-height: 1; text-shadow: 0 4px 0 #000; transform: rotate(-3deg); }
.ko-sub { max-width: 520px; font-size: 18px; font-weight: 700; color: var(--htext); }

/* =================================================================
   compact: small screens (phones in either orientation, small windows)
   ================================================================= */
@media (max-width: 760px), (max-height: 540px) {
  .efb-hud { --e: 8px; font-size: 13px; }
  .hud-vitals { width: 190px; padding: 5px 7px 6px; gap: 3px; }
  .hud-row { grid-template-columns: 34px 1fr auto; gap: 4px; }
  .hud-row .lbl { font-size: 9px; }
  .hud-row .val { font-size: 10px; min-width: 38px; }
  .hud-row.hp .val { font-size: 12px; }
  .hud-row.hp .bar { height: 11px; }
  .bar { height: 7px; }
  .hud-row .pen { right: 42px; font-size: 9px; }
  .hud-police .ptxt { font-size: 9px; }
  .hud-police.wanted .ptxt { font-size: 13px; }
  .hud-top { gap: 4px; width: min(420px, calc(100vw - 2 * var(--efb-mm) - 40px)); }
  .hud-timer { padding: 2px 9px 3px; min-width: 70px; }
  .hud-timer .t { font-size: 18px; }
  .hud-mapname { display: none; }
  .hud-toast { font-size: 13px; padding: 3px 8px 3px 4px; }
  .hud-toast .ti { width: 16px; height: 16px; font-size: 10px; }
  .hud-ticker .txt { font-size: 11px; }
  .hud-xlist { width: 180px; gap: 3px; }
  .xr { grid-template-columns: 18px 1fr auto; padding: 2px 5px 2px 3px; gap: 4px; }
  .xr .xi { font-size: 13px; }
  .xr .xn { font-size: 12px; }
  .xr .xm { font-size: 10px; }
  .xr .xe, .xr .xd { font-size: 9px; }
  .xr:nth-child(n + 4) { display: none; }
  .hud-money { min-width: 0; padding: 3px 8px 4px; }
  .hud-money .cash { font-size: 16px; }
  .hud-money .bottles { font-size: 13px; }
  .hud-weapon { grid-template-columns: 38px 1fr; min-width: 0; gap: 7px; padding: 5px 10px 7px 5px; }
  .hud-weapon .wg { width: 38px; height: 38px; font-size: 22px; }
  .hud-weapon .wn { font-size: 12px; max-width: 120px; }
  .hud-weapon .wa .n { font-size: 20px; }
  .hud-weapon .wa .cap, .hud-weapon .wa .tot { font-size: 11px; }
  .hud-weapon .ww { font-size: 10px; }
  .hud-prompt { bottom: calc(var(--sb) + 110px); padding: 4px 12px 4px 4px; gap: 8px; }
  .hud-prompt .key { height: 30px; min-width: 30px; font-size: 15px; }
  .hud-prompt .ptx { font-size: 15px; }
  .hud-need { bottom: calc(var(--sb) + 156px); font-size: 13px; }
  .hud-bubble { font-size: 12px; max-width: 170px; padding: 4px 8px 5px; }
  .ko-sub { font-size: 15px; }
}
@media (max-width: 420px) {
  .hud-vitals { width: calc(50vw - 46px); min-width: 128px; }
  .hud-row { grid-template-columns: 1fr auto; }
  .hud-row .lbl { display: none; }
  .hud-top { width: auto; max-width: calc(100vw - 2 * var(--efb-mm) - 24px); }
  .hud-xlist { width: min(180px, 48vw); }
}

/* =================================================================
   touch: the sticks own the bottom corners
   ================================================================= */
.efb-hud.hud-touch .hud-bl {
  left: calc(var(--sl) + var(--e));
  bottom: auto;
  top: calc(var(--st) + var(--e) + var(--vh, 100px) + 6px);
}
.efb-hud.hud-touch .hud-br {
  right: auto;
  left: calc(var(--sl) + var(--e));
  bottom: auto;
  top: calc(var(--st) + var(--e) + var(--vh, 100px) + var(--mh, 30px) + 12px);
  align-items: flex-start;
}
.efb-hud.hud-touch .hud-weapon { order: -1; }
.efb-hud.hud-touch .hud-feed { display: none; }
.efb-hud.hud-touch .hud-money { flex-direction: row; align-items: baseline; gap: 10px; }
.efb-hud.hud-touch .hud-money .bottles .sub { display: none; }

/* touch: quick slots bottom-centre-left, between the move stick and the buttons */
.efb-hud.hud-touch .hud-slots {
  position: fixed;
  left: calc(var(--sl) + 14px + clamp(40px, 12vmin, 62px) * 2 + 24px);
  bottom: calc(var(--sb) + 14px);
}
.efb-hud.hud-touch .hud-prompt { bottom: calc(var(--sb) + 150px); }
.efb-hud.hud-touch .hud-need { bottom: calc(var(--sb) + 196px); }
.efb-hud.hud-touch .hud-weapon { padding: 4px 9px 5px 4px; gap: 6px; grid-template-columns: 30px 1fr; }
.efb-hud.hud-touch .hud-weapon .wg { width: 30px; height: 30px; font-size: 18px; }
.efb-hud.hud-touch .hud-weapon .wn { font-size: 11px; }
.efb-hud.hud-touch .hud-weapon .wa .n { font-size: 17px; }

/* touch portrait: slots in a column above the move stick, the prompt clears the button stack */
@media (orientation: portrait) {
  .efb-hud.hud-touch .hud-slots {
    flex-direction: column-reverse;
    left: calc(var(--sl) + 10px);
    bottom: calc(var(--sb) + 14px + clamp(40px, 12vmin, 62px) * 2 + 34px);
  }
  .efb-hud.hud-touch .hud-prompt { bottom: calc(var(--sb) + 256px); left: calc(50% + 24px); max-width: calc(100vw - 80px); }
  .efb-hud.hud-touch .hud-need { bottom: calc(var(--sb) + 302px); left: calc(50% + 24px); max-width: calc(100vw - 80px); }
}
/* short landscape: the small buttons sit beside the big column, the prompt stays above them */
@media (orientation: landscape) and (max-height: 420px) {
  .efb-hud.hud-touch .hud-prompt { bottom: calc(var(--sb) + 136px); left: 45%; }
  .efb-hud.hud-touch .hud-need { bottom: calc(var(--sb) + 178px); left: 45%; }
  .efb-hud.hud-touch .hud-xlist .xr:nth-child(n + 3) { display: none; }
  .efb-hud.hud-touch .hud-toasts .hud-toast:nth-child(n + 3) { display: none; }
}

/* a panel (FLAKOMAT, till, vendor, NPC) is open: hide the world prompt and the crosshair under it */
body.efb-panel-open .efb-hud .hud-prompt,
body.efb-panel-open .efb-hud .hud-need,
body.efb-panel-open .efb-hud .hud-cross { display: none; }
/* the extract list is sorted (open and near first): show the top rows only */
.hud-xlist .xr:nth-child(n + 7) { display: none; }
@media (max-height: 700px) { .hud-xlist .xr:nth-child(n + 5) { display: none; } }
