/* The run HUD (js/client/ui/hud.js, ui/perks.js). Dark, sooty panels with ember accents; readable over fire.
   Desktop: vitals top-left, the route strip top-centre, the minimap top-right, the wagon bottom-left, the weapon
   bottom-right, perk cards bottom-centre. Touch: everything moves to the top band, the bottom is for the thumbs. */

.hud {
  --pad: 12px;
  --mm: 150px;
  --panel: rgba(16, 11, 9, 0.78);
  --edge: rgba(255, 200, 150, 0.14);
  position: absolute; inset: 0; pointer-events: none; color: var(--text); font-family: var(--font-body);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); user-select: none; -webkit-user-select: none;
}
.hud > * { position: absolute; }
.hud .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; display: block; }
.hud-world { inset: 0; overflow: hidden; }

/* ---------- vitals */
.hud-vitals { left: calc(var(--sl) + var(--pad)); top: calc(var(--st) + var(--pad)); width: 236px; display: grid; gap: 4px; padding: 8px 10px; border-radius: var(--r-l); background: var(--panel); border: 1px solid var(--edge); }
.hv-hp { position: relative; height: 22px; border-radius: 4px; background: #2a0d08; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); }
.hv-hp .fill { background: linear-gradient(180deg, #ff6b4a, #b3200d); transition: width 0.15s; }
.hv-hp b { position: absolute; right: 8px; top: 1px; font-size: 0.95rem; }
.hud-vitals.low .hv-hp { animation: pulse 0.7s ease-in-out infinite alternate; }
@keyframes pulse { from { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); } to { box-shadow: inset 0 0 0 2px #ff5a3d, 0 0 12px rgba(255, 60, 30, 0.6); } }
.hv-st { position: relative; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hv-st .fill { background: #e9d9a0; }
.hv-row { display: flex; gap: 10px; align-items: baseline; font-weight: 800; font-size: 0.98rem; }
.hv-lvl { color: var(--glow); }
.hv-lives { color: #ff7a6a; }
.hv-lives.last { color: var(--text-faint); }
.hv-kills { margin-left: auto; color: var(--text-dim); }
.hv-xp { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hv-xp .fill { background: linear-gradient(90deg, #7fd3ff, #c9f0ff); transition: width 0.25s; }

/* ---------- the route strip */
.hud-route { left: 50%; top: calc(var(--st) + var(--pad)); transform: translateX(-50%); width: min(46vw, 620px); display: grid; gap: 2px; padding: 2px 8px 5px; border-radius: var(--r-l); background: var(--panel); border: 1px solid var(--edge); }
.hr-strip { position: relative; height: 34px; padding: 0 22px; }
.hr-track { position: absolute; left: 22px; right: 22px; top: 12px; height: 10px; border-radius: 5px; background: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 0 1px var(--edge); overflow: hidden; }
.hr-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #ffb347, #ff6a1f); width: 0; transition: width 0.4s linear; }
.hr-marks { position: absolute; left: 22px; right: 22px; top: 0; bottom: 0; }
.hr-sec { position: absolute; top: 24px; font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; border-left: 1px solid rgba(255, 220, 190, 0.25); padding-left: 3px; white-space: nowrap; overflow: hidden; height: 12px; line-height: 12px; }
.hr-sp, .hr-idol, .hr-wagon { position: absolute; top: 17px; transform: translate(-50%, -50%); }
.hr-sp { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid #ff3b2f; filter: drop-shadow(0 0 3px rgba(255, 60, 30, 0.7)); top: 14px; }
.hr-sp.dead { border-bottom-color: #5b534c; filter: none; }
.hr-idol { width: 7px; height: 14px; border-radius: 3px 3px 1px 1px; background: #c48bff; box-shadow: 0 0 6px rgba(196, 139, 255, 0.8); top: 12px; }
.hr-idol.dead { background: #5b534c; box-shadow: none; }
.hr-wagon { width: 18px; height: 11px; border-radius: 3px; background: var(--tc, #ffb347); border: 2px solid #000; z-index: 2; transition: left 0.4s linear; }
.hr-wagon.own { width: 22px; height: 14px; border-color: #fff; z-index: 3; box-shadow: 0 0 8px rgba(255, 200, 120, 0.8); }
.hr-wagon.dead { opacity: 0.4; }
.hr-end { position: absolute; top: 8px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-size: 0.8rem; background: var(--s700); border: 1px solid var(--edge); color: var(--text); text-shadow: none; }
.hr-end.a { left: 0; }
.hr-end.b { right: 0; background: #2f5d22; color: #fff; }
.hr-info { display: flex; justify-content: center; gap: 14px; font-weight: 800; font-size: 1.02rem; align-items: baseline; flex-wrap: wrap; }
.hr-clock { font-size: 1.15rem; color: var(--text); }
.hr-left { color: var(--text-dim); }
.hr-wave { color: var(--text-faint); }
.hr-wave.soon { color: var(--bad); animation: blink 0.6s steps(2) infinite; font-size: 1.1rem; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- minimap and the race ranking */
.hud-mm { right: calc(var(--sr) + var(--pad)); top: calc(var(--st) + var(--pad)); width: var(--mm); height: var(--mm); border-radius: 50%; overflow: hidden; border: 2px solid rgba(255, 200, 150, 0.35); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 6px 18px rgba(0, 0, 0, 0.5); pointer-events: auto; cursor: pointer; background: #0c0a09; }
.hud-mm canvas { width: 100%; height: 100%; display: block; }
.hud-rank { right: calc(var(--sr) + var(--pad)); top: calc(var(--st) + var(--pad) + var(--mm) + 8px); width: 210px; margin: 0; padding: 6px 8px; list-style: none; border-radius: var(--r); background: var(--panel); border: 1px solid var(--edge); display: none; counter-reset: rk; font-size: 0.92rem; }
.hud-rank.on { display: grid; gap: 2px; }
.hud-rank li { display: flex; gap: 6px; align-items: center; counter-increment: rk; }
.hud-rank li::before { content: counter(rk) '.'; width: 1.3em; color: var(--text-faint); }
.hud-rank li .n { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 4px solid var(--tc); padding-left: 5px; }
.hud-rank li.me { color: var(--glow); }

/* ---------- the wagon(s) */
.hud-wagons { left: calc(var(--sl) + var(--pad)); bottom: calc(var(--sb) + var(--pad)); width: 300px; display: grid; gap: 6px; }
.hw-own { padding: 8px 10px; border-radius: var(--r-l); background: var(--panel); border: 1px solid var(--edge); display: grid; gap: 5px; }
.hw-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hw-name { font-family: var(--font-head); font-weight: 400; letter-spacing: 0.04em; color: var(--bottle); font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-hpt { font-size: 0.85rem; color: var(--text-dim); }
.hw-bar { position: relative; height: 14px; border-radius: 4px; background: #0d1a22; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); }
.hw-bar .fill { background: linear-gradient(180deg, #a8e4ff, #2b8fd6); z-index: 2; transition: width 0.2s; }
.hw-bar .lag { position: absolute; left: 0; top: 0; bottom: 0; background: #ff6a3d; z-index: 1; display: block; }
.hw-bar.small { height: 6px; }
.hw-own.low .hw-bar .fill { background: linear-gradient(180deg, #ffb37a, #d9581a); }
.hw-state { font-weight: 800; font-size: 1rem; color: var(--text); }
.hw-state[data-tone='bad'] { color: var(--bad); }
.hw-state[data-tone='warn'] { color: var(--warn); }
.hw-state[data-tone='hot'] { color: var(--glow); }
.hw-state[data-tone='good'] { color: var(--good); }
.hw-state[data-tone='idle'] { color: var(--text-dim); }
.hw-own.alarm { border-color: var(--bad); animation: alarmb 0.8s ease-in-out infinite alternate; }
@keyframes alarmb { to { box-shadow: 0 0 18px rgba(255, 60, 30, 0.55); } }
.hw-cmds { display: flex; gap: 6px; }
.hw-cmds.touch { display: none; }
.hw-cmd {
  flex: 1; display: flex; gap: 5px; align-items: center; justify-content: center; min-height: 30px; padding: 2px 6px; border-radius: var(--r);
  border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.35); color: var(--text-dim); font-weight: 800; pointer-events: auto; cursor: pointer;
}
.hw-cmd kbd { font-size: 0.75rem; }
.hw-cmd.cur { color: var(--ember-ink); background: var(--ember); border-color: var(--glow); text-shadow: none; }
.hw-cmd.cur kbd { background: rgba(0, 0, 0, 0.25); color: var(--ember-ink); border-color: rgba(0, 0, 0, 0.3); }
.hw-cmd.press { animation: press 0.25s ease-out; }
@keyframes press { from { transform: scale(1.12); filter: brightness(1.6); } to { transform: none; filter: none; } }
.hw-rivals { display: grid; gap: 4px; }
.hw-rival { padding: 4px 8px; border-radius: var(--r); background: var(--panel); border-left: 4px solid var(--tc); font-size: 0.88rem; display: grid; gap: 2px; }
.hw-rival .hw-bar .fill { background: var(--tc); }

/* ---------- the weapon */
.hud-weapon { right: calc(var(--sr) + var(--pad)); bottom: calc(var(--sb) + var(--pad)); width: 250px; display: grid; gap: 6px; justify-items: end; }
.hwp-main { width: 100%; padding: 8px 12px; border-radius: var(--r-l); background: var(--panel); border: 1px solid var(--edge); display: grid; gap: 2px; justify-items: end; position: relative; }
.hwp-name { font-family: var(--font-head); font-weight: 400; font-size: 1.15rem; letter-spacing: 0.04em; color: var(--text-dim); }
.hwp-ammo { font-size: 2rem; line-height: 1; }
.hwp-ammo .mag { color: var(--text); font-weight: 800; }
.hwp-ammo .res { color: var(--text-faint); font-size: 1rem; }
.hud-weapon.empty .hwp-ammo .mag { color: var(--bad); }
.hud-weapon.lowammo .hwp-ammo .mag { color: var(--warn); }
.hwp-rl { position: relative; width: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.06); overflow: hidden; opacity: 0; }
.hud-weapon.reloading .hwp-rl { opacity: 1; }
.hwp-rl .fill { background: var(--glow); }
.hwp-slots { display: flex; align-items: center; gap: 6px; pointer-events: auto; cursor: pointer; }
.hwp-slots.solo { display: none; }
.hwp-slots .slot { padding: 3px 9px; border-radius: var(--r); background: var(--panel); border: 2px solid var(--edge); font-weight: 800; font-size: 0.95rem; color: var(--text-faint); white-space: nowrap; }
.hwp-slots .slot.cur { color: var(--text); border-color: var(--ember); box-shadow: 0 0 10px rgba(255, 140, 40, 0.35); }
.hwp-slots .slot.dry:not(.cur) { color: var(--bad); text-decoration: line-through; }
.hwp-slots .slot-key { font-size: 1.25rem; font-weight: 900; min-width: 1.9em; text-align: center; padding: 2px 8px; border-radius: var(--r); background: var(--ember); color: var(--ember-ink); border: 1px solid rgba(0, 0, 0, 0.3); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }
.hwp-slots.flip { animation: slotflip 0.6s ease-out; }
@keyframes slotflip { 0% { transform: scale(1.18); filter: brightness(1.6); } 100% { transform: none; filter: none; } }
.hwp-thr { display: flex; gap: 6px; pointer-events: auto; cursor: pointer; }
.hwp-thr .thr { padding: 3px 8px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--edge); font-weight: 800; font-size: 0.92rem; color: var(--text-dim); }
.hwp-thr .thr.pref { color: var(--glow); border-color: var(--ember); }
.hwp-thr .thr.none { opacity: 0.4; }
.hud-feed { display: grid; gap: 2px; justify-items: end; }
.hf-row { padding: 2px 8px; border-radius: var(--r-s); background: rgba(60, 122, 31, 0.85); font-weight: 800; animation: feed 0.25s ease-out; }
@keyframes feed { from { transform: translateX(20px); opacity: 0; } }

/* ---------- prompt, action ring, crosshair */
.hud-prompt { left: 50%; bottom: calc(var(--sb) + 130px); transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 99px; background: var(--panel); border: 1px solid var(--edge); font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.hud-prompt.on { display: flex; }
.hud-prompt kbd { font-size: 0.95rem; }
.hud.offer .hud-prompt { bottom: calc(var(--sb) + 200px); }
.hud-act { left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; display: none; place-items: center;
  background: conic-gradient(var(--glow) calc(var(--p, 0) * 360deg), rgba(0, 0, 0, 0.45) 0); -webkit-mask: radial-gradient(circle, transparent 22px, #000 23px); mask: radial-gradient(circle, transparent 22px, #000 23px); }
.hud-act.on { display: grid; }
.hud-act span { position: absolute; top: 66px; white-space: nowrap; font-weight: 800; font-size: 0.95rem; color: var(--glow); }
.hud-cross { left: 0; top: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; display: none; border-radius: 50%; border: 2px solid rgba(255, 220, 170, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.hud-cross i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--glow); }
.hud-cross.on { display: block; }
/* reloading: a dashed ring spins, on a layer of its own (the element's transform is its position) */
.hud-cross.rl { border-color: transparent; box-shadow: none; }
.hud-cross.rl::before { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px dashed rgba(255, 220, 170, 0.9); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts, banner */
.hud-toasts { left: 50%; top: calc(var(--st) + var(--pad) + 74px); transform: translateX(-50%); display: grid; gap: 4px; justify-items: center; width: min(560px, 60vw); }
.hud-toast { padding: 5px 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--edge); font-weight: 700; text-align: center; transition: opacity 0.3s, transform 0.3s; }
.hud-toast.good { border-color: var(--good); }
.hud-toast.bad { border-color: var(--bad); color: #ffd2c8; }
.hud-toast.out { opacity: 0; transform: translateY(-6px); }
.hud-banner { left: 50%; top: 26%; transform: translateX(-50%); display: none; text-align: center; pointer-events: none; }
.hud-banner.on { display: grid; animation: banner 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
.hud-banner b { font-family: var(--font-head); font-weight: 400; font-size: clamp(2.4rem, 7vw, 4.6rem); letter-spacing: 0.04em; line-height: 1; color: var(--glow); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 120, 30, 0.6); }
.hud-banner span { font-weight: 800; font-size: 1.2rem; color: var(--text); }
.hud-banner[data-tone='bad'] b { color: #ff5a3d; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 40, 20, 0.7); }
.hud-banner[data-tone='good'] b { color: #b8ff8a; }
@keyframes banner { from { transform: translateX(-50%) scale(1.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------- speech bubbles and the wagon marker */
.hud-bubble { left: 0; top: 0; max-width: 180px; padding: 4px 9px; border-radius: 10px; background: rgba(240, 228, 210, 0.94); color: #1b120c; font-size: 0.92rem; font-weight: 800; text-shadow: none; display: none; translate: -50% -100%; white-space: nowrap; }
.hud-bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(240, 228, 210, 0.94); }
.hud-bubble.on { display: block; }
.hud-bubble.fade { opacity: 0.4; transition: opacity 0.4s; }
.hud-wmark { left: 0; top: 0; display: none; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(16, 11, 9, 0.85); border: 2px solid var(--bottle); place-items: center; }
.hud-wmark.on { display: grid; }
.hud-wmark.alarm { border-color: var(--bad); animation: alarmb 0.6s ease-in-out infinite alternate; }
.hud-wmark .wm-arrow { position: absolute; inset: -9px; transform: rotate(var(--a, 0rad)); }
.hud-wmark .wm-arrow::after { content: ''; position: absolute; right: -2px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-right: 0; border-left: 10px solid var(--bottle); }
.hud-wmark b { font-size: 0.8rem; color: var(--bottle); }

/* ---------- overlays */
.hud-vign { inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 20, 0, 0.55)); }
.hud-vign.go { animation: vign 0.45s ease-out; }
@keyframes vign { from { opacity: 1; } to { opacity: 0; } }
.hud-down { inset: 0; display: none; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(40, 0, 0, 0.35), rgba(70, 0, 0, 0.8)); }
.hud-down.on { display: grid; }
.hud-down.out { background: rgba(10, 6, 4, 0.55); place-content: end center; padding-bottom: 22vh; }
.hud-down b { font-family: var(--font-head); font-weight: 400; font-size: clamp(2.4rem, 8vw, 4.4rem); color: #ff5a3d; }
.hud-down span { max-width: 30em; font-weight: 700; font-size: 1.15rem; }
.hud-down i { font-style: normal; font-size: 3rem; font-weight: 800; color: var(--text); }
.hud-bigmap { inset: 0; display: none; place-items: center; padding: calc(var(--st) + 16px) calc(var(--sr) + 16px) calc(var(--sb) + 16px) calc(var(--sl) + 16px); background: rgba(6, 4, 3, 0.82); pointer-events: auto; z-index: 5; }
.hud-bigmap.on { display: grid; }
.bm-box { width: min(1100px, 100%); height: min(720px, 100%); display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 10px; border-radius: var(--r-l); background: var(--s850); border: 1px solid var(--line-2); }
.bm-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-head); font-size: 1.4rem; color: var(--glow); }
.bm-box canvas { width: 100%; height: 100%; min-height: 0; display: block; border-radius: var(--r); }
.bm-attr { color: var(--text-faint); justify-self: end; }

/* ---------- perk cards */
.hud-perks { left: 50%; bottom: calc(var(--sb) + var(--pad)); transform: translateX(-50%); display: none; gap: 6px; justify-items: center; pointer-events: none; z-index: 4; }
.hud-perks.on { display: grid; animation: perksin 0.3s ease-out; }
@keyframes perksin { from { transform: translate(-50%, 30px); opacity: 0; } }
.hp-head { font-family: var(--font-head); font-size: 1.3rem; color: var(--glow); letter-spacing: 0.05em; }
.hp-row { display: flex; gap: 8px; }
.hp-card {
  position: relative; width: 168px; min-height: 118px; padding: 10px 10px 12px; border-radius: var(--r-l); display: grid; gap: 3px; align-content: start; justify-items: center; text-align: center;
  background: linear-gradient(180deg, rgba(60, 34, 18, 0.96), rgba(22, 14, 10, 0.96)); border: 2px solid rgba(255, 170, 90, 0.55); color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); pointer-events: auto; cursor: pointer; font: inherit; touch-action: manipulation;
}
.hp-card:hover { border-color: var(--glow); transform: translateY(-3px); }
.hp-glyph { font-size: 1.6rem; line-height: 1; color: var(--glow); }
.hp-name { font-family: var(--font-head); font-weight: 400; font-size: 1.15rem; letter-spacing: 0.03em; }
.hp-desc { font-size: 0.88rem; color: var(--text-dim); line-height: 1.15; }
.hp-key { position: absolute; top: -10px; left: -8px; font-size: 0.95rem; background: var(--ember); color: var(--ember-ink); border-color: rgba(0, 0, 0, 0.4); }

/* ---------- smaller screens */
@media (max-width: 1100px) {
  .hud { --mm: 124px; }
  .hud-route { width: min(42vw, 480px); }
  .hud-vitals { width: 210px; }
  .hud-wagons { width: 260px; }
  .hud-weapon { width: 220px; }
  .hp-card { width: 150px; }
}

/* touch: the bottom belongs to the thumbs; the HUD lives in the top band */
body.nf-touch .hud { --pad: 8px; --mm: 96px; }
body.nf-touch .hud-vitals { width: 172px; padding: 5px 7px; gap: 3px; }
body.nf-touch .hv-hp { height: 16px; }
body.nf-touch .hv-hp b { font-size: 0.8rem; top: 0; }
body.nf-touch .hv-row { font-size: 0.85rem; gap: 7px; }
body.nf-touch .hud-wagons { top: calc(var(--st) + var(--pad) + 96px); bottom: auto; width: 172px; }
body.nf-touch .hw-own { padding: 5px 7px; gap: 3px; }
body.nf-touch .hw-name { font-size: 0.9rem; }
body.nf-touch .hw-hpt { display: none; }
body.nf-touch .hw-bar { height: 10px; }
body.nf-touch .hw-state { font-size: 0.82rem; line-height: 1.1; }
body.nf-touch .hud-weapon { top: calc(var(--st) + var(--pad) + var(--mm) + 8px); bottom: auto; width: 150px; gap: 4px; }
body.nf-touch .hwp-main { padding: 4px 8px; }
body.nf-touch .hwp-name { font-size: 0.85rem; }
body.nf-touch .hwp-ammo { font-size: 1.3rem; }
body.nf-touch .hwp-thr { pointer-events: auto; }
body.nf-touch .hwp-thr .thr { font-size: 0.78rem; padding: 2px 5px; }
body.nf-touch .hwp-slots .slot { font-size: 0.78rem; padding: 2px 6px; }
body.nf-touch .hwp-slots .slot-key { font-size: 1rem; }
body.nf-touch .hud-feed { display: none; }
body.nf-touch .hud-rank { top: auto; bottom: auto; right: auto; left: 50%; transform: translateX(-50%); top: calc(var(--st) + 64px); width: 190px; font-size: 0.8rem; }
body.nf-touch .hud-route { width: min(48vw, 420px); }
body.nf-touch .hud-toasts { top: calc(var(--st) + 70px); }
body.nf-touch .hud-prompt { bottom: auto; top: 52%; font-size: 0.95rem; }
body.nf-touch .hud-perks { bottom: auto; top: 34%; }
body.nf-touch .hp-card { width: 128px; min-height: 104px; padding: 8px 6px; }
body.nf-touch .hp-desc { font-size: 0.8rem; }
body.nf-touch .hud-banner { top: 22%; }
body.nf-touch .hud-banner b { font-size: clamp(1.8rem, 7vw, 3rem); }

/* phone portrait: a narrow column, the strip under the vitals and the minimap */
@media (orientation: portrait) and (max-width: 600px) {
  .hud { --mm: 92px; }
  .hud-route { top: calc(var(--st) + var(--pad) + 98px); width: calc(100% - 2 * var(--pad) - var(--sl) - var(--sr)); }
  .hud-vitals, body.nf-touch .hud-vitals { width: calc(100% - var(--mm) - 44px - 4 * var(--pad) - var(--sl) - var(--sr)); }
  .hud-wagons, body.nf-touch .hud-wagons { top: calc(var(--st) + var(--pad) + 168px); width: 54%; }
  .hud-weapon, body.nf-touch .hud-weapon { top: calc(var(--st) + var(--pad) + 168px); right: calc(var(--sr) + var(--pad)); width: 42%; }
  .hud-toasts, body.nf-touch .hud-toasts { top: calc(var(--st) + 262px); width: 92vw; }
  .hud-banner, body.nf-touch .hud-banner { top: 38%; }
  .hr-info { font-size: 0.85rem; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
  .hr-sec { font-size: 0.55rem; letter-spacing: 0; }
  .hr-clock { font-size: 1rem; }
  .hr-wave.soon { font-size: 0.9rem; }
  .hp-row { flex-direction: column; }
  .hp-card, body.nf-touch .hp-card { width: min(88vw, 340px); min-height: 0; grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: 10px; }
  .hp-card .hp-glyph { grid-row: span 2; align-self: center; }
  .hud-perks, body.nf-touch .hud-perks { top: 30%; }
  .hud-rank, body.nf-touch .hud-rank { top: calc(var(--st) + 108px + 46px); }
}

/* the interactive bits sit above the touch layer (css/touch.css .nf-tc is z-index 20 inside #ui) */
.hud-perks, .hud-mm, .hud-weapon, .hud-bigmap, .hud-wagons { z-index: 30; }

/* the net graph (F3, ui/netgraph.js) */
.netgraph { position: absolute; right: 8px; top: 176px; z-index: 40; display: none; pointer-events: none;
  background: rgba(0,0,0,0.6); border-radius: 6px; padding: 6px; color: #e8e8e8; }
.netgraph.on { display: block; }
.netgraph canvas { display: block; width: 240px; height: 60px; }
.netgraph pre { margin: 4px 0 0; font: 11px/1.35 ui-monospace, Consolas, monospace; white-space: pre; }
@media (orientation: portrait) and (max-width: 600px) {
  .netgraph { top: auto; bottom: 230px; right: auto; left: 50%; transform: translateX(-50%); }
}
