/*
 * Cryptic Breach — ossuary HUD and responsive overrides.
 * This layer loads after the standalone page styles and keeps the tactical
 * panels readable with the Conclave black/cyan/purple/oxblood identity.
 */
:root {
  --hud-safe: clamp(24px, 2.25vw, 44px);
  --hud-panel: rgba(5, 12, 16, .88);
  --hud-border: rgba(0, 204, 204, .38);
}

.hud-shell {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  letter-spacing: .02em;
}

.hud-panel {
  background:
    linear-gradient(105deg, rgba(5, 12, 16, .95), rgba(15, 19, 27, .76)),
    linear-gradient(90deg, rgba(0, 204, 204, .035), transparent 55%);
  border-color: var(--hud-border);
  box-shadow: inset 0 1px rgba(255,255,255,.035), inset 0 0 35px rgba(0, 204, 204, .028), 0 14px 42px rgba(0,0,0,.3);
  backdrop-filter: blur(12px) saturate(1.2);
}

.hud-top { left: var(--hud-safe); right: var(--hud-safe); top: calc(var(--hud-safe) * .72); }
.sector { font-size: clamp(12px, .8vw, 15px); letter-spacing: 3.8px; margin-bottom: 8px; color: rgba(216,255,255,.92); }
.mission-card { width: clamp(420px, 31vw, 510px); padding: 18px 22px 17px; }
.micro-label { font-size: clamp(10px, .65vw, 12px); letter-spacing: 2.5px; color: rgba(159,222,222,.72); }
#objective-text { font-size: clamp(16px, 1.05vw, 20px); letter-spacing: 1px; }
.mission-line { gap: 13px; margin-top: 9px; }
.mission-pip { width: 8px; height: 8px; background: #00cccc; box-shadow: 0 0 10px rgba(0,204,204,.38); }
.mission-progress { height: 3px; margin-top: 15px; }

.telemetry { min-width: 235px; padding: 15px 18px; }
.telemetry-row { margin-top: 7px; font-size: clamp(10px, .7vw, 13px); color: rgba(159,222,222,.7); }
.telemetry-row b { color: rgba(232,250,250,.94); }

.radar-wrap { left: var(--hud-safe); bottom: 157px; width: 220px; height: 220px; }
#radar { width: 220px; height: 220px; border-color: rgba(0,204,204,.42); box-shadow: inset 0 0 40px rgba(0,204,204,.06), 0 10px 28px rgba(0,0,0,.3); }
.radar-tag { top: -22px; font-size: 10px; letter-spacing: 2.2px; }

.vitals { left: var(--hud-safe); bottom: var(--hud-safe); width: clamp(340px, 25vw, 400px); }
.vital-row { grid-template-columns: 62px 1fr 46px; gap: 11px; margin-top: 9px; }
.vital-name { font-size: clamp(10px, .7vw, 13px); letter-spacing: 2px; }
.vital-value { font-size: clamp(13px, .85vw, 16px); }
.bar { height: 9px; border: 1px solid rgba(255,255,255,.05); }

.weapon-hud { right: var(--hud-safe); bottom: var(--hud-safe); width: clamp(340px, 25vw, 390px); padding: 18px 22px 19px; }
.weapon-name { font-size: clamp(14px, 1vw, 18px); color: rgba(216,255,255,.95); }
#ammo { font-size: clamp(60px, 4.2vw, 76px); letter-spacing: -7px; font-weight: 250; }
.reserve { font-size: clamp(19px, 1.4vw, 25px); }
.ammo-cells { height: 6px; gap: 4px; margin-top: 10px; }
.reload-message { top: -34px; font-size: 11px; }

#sound-state { right: var(--hud-safe); bottom: 152px; font-size: 10px; }
#toast-stack { right: var(--hud-safe); top: 148px; width: 340px; }
.toast { padding: 10px 13px; font-size: 11px; border-right-color: rgba(0,204,204,.82); }

#crosshair { width: 50px; height: 50px; }
#crosshair .top, #crosshair .bottom { left: 24px; height: 9px; }
#crosshair .left, #crosshair .right { top: 24px; width: 9px; }
#crosshair .top { top: 5px; } #crosshair .bottom { bottom: 5px; }
#crosshair .left { left: 5px; } #crosshair .right { right: 5px; }
#crosshair .cross-dot { left: 23.5px; top: 23.5px; }
.hud-shell.sprinting + #hud, #hud.onboarding-hidden { opacity: 0 !important; }
#hud { transition: opacity .8s ease; bottom: 26px; font-size: 11px; }

.target-marker {
  width: 68px;
  height: 48px;
  opacity: .78;
  border-color: rgba(112,41,54,.9);
  transition: width .12s ease, height .12s ease, filter .12s ease;
}
.target-marker::after { top: 52px; font-size: 9px; letter-spacing: .8px; }
.target-health { top: -9px; height: 3px; }
.target-state { position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); color: #8e66c8; font: 800 9px ui-monospace, monospace; letter-spacing: 2px; }
.target-marker.evade-warning { width: 82px; height: 58px; border-color: #8e66c8; filter: drop-shadow(0 0 9px rgba(142,102,200,.48)); animation: targetWarning .14s infinite alternate; }
.target-marker.offscreen { width: 22px; height: 22px; border: 0; clip-path: none; opacity: .75; }
.target-marker.offscreen::before { content: ''; position: absolute; inset: 1px; border: 2px solid rgba(112,41,54,.9); transform: rotate(45deg); }
.target-marker.offscreen::after, .target-marker.offscreen .target-health { display: none; }
.target-marker.offscreen .target-state { bottom: -19px; color: rgba(224,140,150,.86); }
@keyframes targetWarning { to { opacity: .42; } }

.critical .vitals { animation: criticalPulse .55s infinite alternate; }
@keyframes criticalPulse { to { filter: drop-shadow(0 0 8px rgba(112,41,54,.42)); } }
.danger-text { color: #d66b78; }

.settings-panel {
  position: static;
  order: 2;
  transform: none;
  width: min(980px, 94vw);
  flex: 0 0 auto;
  margin: 28px auto 0;
  padding: 15px 20px 14px;
  display: grid;
  /* Riga 1: titolo · qualità · reset. Riga 2: i 4 slider a tutta larghezza
     (ognuno ~220px — review demo: prima erano troppo corti). */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 12px 16px;
  background: rgba(5,10,13,.9);
  border: 1px solid rgba(0,204,204,.28);
  backdrop-filter: blur(12px);
  z-index: 3;
}
.settings-title { grid-column: 1 / 3; grid-row: 1; color: rgba(159,222,222,.62); font: 800 10px ui-monospace, monospace; letter-spacing: 1.8px; white-space: nowrap; }
/* L1: wrapper dei due toggle (qualità AUTO/ULTRA + lingua IT/EN) nella cella 3. */
.panel-toggles { grid-column: 3 / 4; grid-row: 1; display: flex; gap: 14px; justify-self: center; }
.reset-level { grid-column: 4 / 5; grid-row: 1; justify-self: end; }
.quality-toggle { display: flex; gap: 4px; }
.quality-toggle button { padding: 8px 12px; color: rgba(159,222,222,.7); background: rgba(255,255,255,.035); border: 1px solid rgba(0,204,204,.28); font: 800 10px ui-monospace, monospace; cursor: url('/images/cursors/hover.cur') 11 0, url('/images/cursors/hover.png') 11 0, pointer; }
.quality-toggle button.selected { color: #e8fafa; border-color: rgba(0,255,255,.78); background: rgba(0,204,204,.12); box-shadow: inset 0 0 12px rgba(0,204,204,.1); }
.reset-level { padding: 8px 12px; color: rgba(224,140,150,.88); background: rgba(112,41,54,.14); border: 1px solid rgba(112,41,54,.58); font: 800 10px ui-monospace, monospace; letter-spacing: .7px; cursor: url('/images/cursors/hover.cur') 11 0, url('/images/cursors/hover.png') 11 0, pointer; white-space: nowrap; }
.reset-level:hover { color: #f2d9de; border-color: rgba(142,102,200,.86); background: rgba(112,41,54,.3); box-shadow: 0 0 14px rgba(142,102,200,.2); }
/* Slider: etichetta sopra, controllo sotto a tutta larghezza. I range nativi
   erano troppo piccoli da usare (review demo) — traccia e thumb custom. */
.settings-panel label { grid-row: 2; display: grid; grid-template-columns: 1fr; gap: 6px; align-items: center; color: rgba(159,222,222,.72); font: 700 9px ui-monospace, monospace; letter-spacing: 1.4px; }
.settings-panel input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: url('/images/cursors/hover.cur') 11 0, url('/images/cursors/hover.png') 11 0, pointer;
}
.settings-panel input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(0,204,204,.52), rgba(142,102,200,.22));
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45);
}
.settings-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5px;
  border-radius: 50%;
  background: #d8ffff;
  border: 1px solid rgba(5,20,24,.8);
  box-shadow: 0 0 9px rgba(0,204,204,.48);
}
.settings-panel input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(0,204,204,.24);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45);
}
.settings-panel input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(5,20,24,.8);
  border-radius: 50%;
  background: #d8ffff;
  box-shadow: 0 0 9px rgba(0,204,204,.48);
}

/* Sotto i 1100px: intestazione, poi qualità/reset, poi gli slider 2×2 —
   mai schiacciati sotto una dimensione utilizzabile. */
@media (max-width: 1100px) {
  .settings-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
  .settings-title { grid-column: 1 / -1; grid-row: 1; }
  .panel-toggles { grid-column: 1 / 2; grid-row: 2; justify-self: start; }
  .reset-level { grid-column: 2 / 3; grid-row: 2; justify-self: end; }
  .settings-panel label { grid-row: auto; }
}

@media (max-width: 900px) {
  .mission-card { width: min(58vw, 440px); }
  .telemetry { min-width: 170px; }
  .radar-wrap { width: 175px; height: 175px; bottom: 145px; }
  #radar { width: 175px; height: 175px; }
  .vitals { width: 300px; }
  .weapon-hud { width: 300px; }
}

/* Su desktop bassi (es. 1280×720) la seconda riga obiettivo rende la card
   più alta: un radar leggermente più compatto mantiene libera la sua etichetta
   senza aumentare la sovrapposizione col pannello vitali. */
@media (max-height: 800px) and (min-width: 901px) {
  .radar-wrap { width: 190px; height: 190px; bottom: 330px; }
  #radar { width: 190px; height: 190px; }
}

/* Elite revenant bar (in alto al centro) e marker dedicato. */
#boss-bar {
  position: fixed; left: 50%; top: calc(var(--hud-safe) * .72);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px; min-width: 300px; max-width: 46vw;
  background: linear-gradient(105deg, rgba(5,12,16,.95), rgba(15,19,27,.76));
  border: 1px solid var(--hud-border);
  border-radius: 3px;
  box-shadow: inset 0 0 30px rgba(142,102,200,.08), 0 12px 34px rgba(0,0,0,.3);
  backdrop-filter: blur(10px);
  z-index: 12; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
#boss-bar.show { opacity: 1; }
#boss-name { font: 900 13px ui-monospace,monospace; letter-spacing: 2px; color: #8e66c8; text-shadow: 0 0 10px rgba(142,102,200,.38); white-space: nowrap; }
.boss-track { flex: 1; height: 7px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden; }
#boss-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg,#702936,#a64152,#8e66c8); box-shadow: 0 0 8px rgba(112,41,54,.56); transition: width .12s linear; }
#boss-hp { font: 700 11px ui-monospace,monospace; letter-spacing: 1px; color: rgba(216,255,255,.88); white-space: nowrap; text-shadow: 0 0 8px rgba(0,204,204,.24); }
#boss-state { font: 700 10px ui-monospace,monospace; letter-spacing: 1px; color: rgba(159,222,222,.74); white-space: nowrap; }

/* Elite marker più grande e con colori dedicati. */
.target-marker.apex-marker {
  width: 74px; height: 52px;
  border-left-color: #702936;
  border-right-color: #702936;
  opacity: .95;
}
.target-marker.apex-marker .target-health { top: -9px; height: 3px; }
.target-marker.apex-marker .target-health i { background: #702936; box-shadow: 0 0 8px rgba(112,41,54,.56); }
/* Un boss fuori inquadratura tiene la sua barra. La regola generica
   `.target-marker.offscreen .target-health { display: none }` è giusta per i
   droni — sono molti e i loro rombi devono restare piccoli — ma su un Apex
   toglie l'unico riscontro che i colpi stiano arrivando, e nel gauntlet
   dell'ondata 9 almeno due dei quattro sono quasi sempre fuori campo.
   Quattro classi contro tre: questa regola vince per specificità. */
.target-marker.apex-marker.offscreen .target-health {
  display: block;
  left: -7px; right: -7px; top: -11px; height: 3px;
}
.target-marker.apex-marker::after { top: 55px; color: rgba(224,140,150,.9); font: 800 9px ui-monospace,monospace; }

/* Vital HUD: pannello a strati in basso a sinistra, con valori e barre
   abbastanza grandi da restare leggibili durante movimento e combattimento. */
.vitals {
  left: var(--hud-safe);
  bottom: var(--hud-safe);
  width: clamp(360px, 28vw, 470px);
  padding: 18px 22px 16px;
  display: grid;
  gap: 13px;
  border-left: 3px solid rgba(0,204,204,.72);
}
.radar-wrap { bottom: 330px; }
.vitals-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 5px; border-bottom: 1px solid rgba(0,204,204,.2); }
.vitals-head strong { display: block; margin-top: 3px; color: rgba(232,250,250,.94); font: 900 14px/1 ui-monospace, monospace; letter-spacing: 2px; }
.vitals-foot { color: rgba(159,222,222,.6); font: 800 9px ui-monospace, monospace; letter-spacing: 1.5px; }
.vital-meter { display: grid; gap: 6px; }
.vital-meter-head { display: flex; justify-content: space-between; align-items: baseline; }
.vital-name { font-size: 13px; letter-spacing: 2.8px; color: rgba(207,234,234,.82); }
.vital-value { color: #e8fafa; font: 900 clamp(30px, 2.35vw, 42px)/.82 ui-monospace, monospace; letter-spacing: -2px; text-shadow: 0 0 10px rgba(0,204,204,.24); }
.bar { display: block; height: 13px; transform: skewX(-18deg); background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.08); overflow: hidden; }
.bar > i { display: block; height: 100%; transition: width .18s; box-shadow: 0 0 13px currentColor; }
.vitals .health-meter .bar > i { background: linear-gradient(90deg,#702936,#c45a6b); color: #d66b78; }
.vitals .shield-meter .bar > i { background: linear-gradient(90deg,#17696b,#62dddd); color: #00cccc; }
.vitals .stamina-meter .bar > i { background: linear-gradient(90deg,#6e4a9f,#b08ce7); color: #8e66c8; }
.vitals-foot { display: flex; justify-content: space-between; padding-top: 2px; border-top: 1px solid rgba(255,255,255,.08); }
/* Vite: separatore + cuori (uno per vita restante) nel pannello vitals. */
.vitals .lives-meter { padding-top: 5px; border-top: 1px solid rgba(0,204,204,.2); }
.lives-hearts { display: flex; align-items: center; gap: 6px; }
.life-heart {
  color: rgba(255,255,255,.14);
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255,59,92,0);
  transition: color .15s ease, text-shadow .15s ease, filter .15s ease;
}
.life-heart.full { color: #d66b78; text-shadow: 0 0 9px rgba(112,41,54,.58); }
.lives-value {
  /* Stessa tipografia dei valori HEALTH/SHIELD/STAMINA (.vital-value), con
     accento colore: il numero vite deve essere grande quanto gli altri. */
  color: rgba(224,140,150,.94);
  font: 900 clamp(30px, 2.35vw, 42px)/.82 ui-monospace, monospace;
  letter-spacing: -2px;
  text-shadow: 0 0 10px rgba(112,41,54,.34);
}
.weapon-hud #weapon-name { min-width: 0; }

@media (max-width: 900px) {
  .vitals { width: 340px; padding: 15px 18px 14px; }
  .vital-value { font-size: 32px; }
}
@media (max-width: 720px) {
  .vitals { left: 12px; bottom: 20px; width: min(52vw, 300px); padding: 12px 14px; gap: 8px; }
  .vitals-head strong { font-size: 10px; }
  .vitals-foot { font-size: 7px; }
  .vital-name { font-size: 9px; letter-spacing: 1.6px; }
  .vital-value { font-size: 25px; }
  .bar { height: 9px; }
}

/* ============================================================
   MODALITÀ SMARTPHONE (touch)
   ============================================================ */
/* Contenitore dei controlli touch: visibile solo in touch e durante il gioco. */
#touch-controls {
  position: fixed; inset: 0;
  z-index: 20;
  pointer-events: none;
  display: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
#touch-controls.active { display: block; }

/* Joystick virtuali: base + pollice. */
.touch-joystick {
  position: absolute;
  width: 92px; height: 92px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.touch-joystick.active { opacity: 1; }
.touch-joystick-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0,204,204,.42);
  background: radial-gradient(circle, rgba(0,204,204,.08), rgba(255,255,255,.02) 60%, transparent 70%);
  box-shadow: inset 0 0 18px rgba(0,204,204,.14), 0 0 14px rgba(0,0,0,.4);
}
.touch-thumb {
  position: absolute;
  left: 50%; top: 50%;
  width: 44px; height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(216,255,255,.9), rgba(0,204,204,.38) 60%, rgba(0,204,204,.16));
  border: 1px solid rgba(0,255,255,.66);
  box-shadow: 0 0 16px rgba(0,204,204,.34), 0 4px 10px rgba(0,0,0,.5);
}

/* Pulsanti touch: colonna a destra (fuoco, salto, ecc.) + sprint a sinistra.
   Le inset env(safe-area-*) tengono i controlli fuori dalla tacca/indicator. */
.touch-buttons-right {
  position: absolute;
  right: max(22px, calc(env(safe-area-inset-right, 0px) + 12px)); bottom: 120px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 14px;
  pointer-events: none;
}
.touch-btn {
  pointer-events: auto;
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(0,204,204,.64);
  background: radial-gradient(circle at 35% 30%, rgba(25,58,62,.86), rgba(5,10,13,.82));
  color: rgba(216,255,255,.95);
  font: 900 11px ui-monospace, monospace;
  letter-spacing: 1px;
  box-shadow: inset 0 0 14px rgba(0,204,204,.18), 0 6px 16px rgba(0,0,0,.45);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
.touch-btn:active { transform: scale(.94); background: radial-gradient(circle at 35% 30%, rgba(53,31,76,.9), rgba(5,10,13,.84)); }
.touch-btn-fire {
  width: 92px; height: 92px;
  border-color: rgba(112,41,54,.84);
  background: radial-gradient(circle at 35% 30%, rgba(112,41,54,.86), rgba(36,8,14,.8));
  box-shadow: inset 0 0 20px rgba(112,41,54,.3), 0 8px 20px rgba(0,0,0,.5);
  font-size: 13px;
}
.touch-btn-fire:active { background: radial-gradient(circle at 35% 30%, rgba(150,52,73,.94), rgba(60,12,20,.84)); }
.touch-btn-jump { width: 76px; height: 76px; }
.touch-btn-melee { width: 60px; height: 60px; font-size: 10px; }
#touch-btn-sprint {
  position: absolute;
  left: max(22px, calc(env(safe-area-inset-left, 0px) + 12px)); bottom: 120px;
  width: 76px; height: 76px;
}
#touch-btn-pause {
  position: absolute;
  top: max(14px, calc(env(safe-area-inset-top, 0px) + 10px));
  right: max(14px, calc(env(safe-area-inset-right, 0px) + 10px));
  width: 46px; height: 46px;
  font-size: 8px;
  background: radial-gradient(circle at 35% 30%, rgba(25,58,62,.66), rgba(5,10,13,.72));
}

/* Rotate-device guard: overlay full-screen in portrait su touch. */
.rotate-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(circle at 50% 40%, rgba(20,16,34,.98), rgba(5,6,7,.99));
  color: rgba(216,255,255,.95);
  text-align: center;
}
/* L'attributo hidden deve davvero nascondere l'overlay: senza questa regola il
   display:flex qui sopra avrebbe la precedenza sul display:none di default di
   [hidden] (foglio UA), e l'overlay resterebbe visibile anche su desktop. */
.rotate-overlay[hidden] { display: none; }
.rotate-icon { font-size: 56px; animation: rotate-device 1.6s ease-in-out infinite; }
@keyframes rotate-device {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
.rotate-title { font: 900 22px ui-monospace, monospace; letter-spacing: 3px; text-shadow: 0 0 14px rgba(142,102,200,.42); }
.rotate-sub { font: 700 12px ui-monospace, monospace; letter-spacing: 2px; color: rgba(0,204,204,.82); }

/* Su touch: nasconde l'HUD di default e regola il layout per il landscape. */
@media (pointer: coarse) {
  #hud, .keys { display: none; }
  /* Il mirino resta attivo anche in touch durante l'azione: la visibilità è
     governata da syncHudVisibility() (mobile viewfinder deploy). */
  .radar-wrap { display: none; }
  .vitals { left: 10px; bottom: 10px; width: min(240px, 34vw); padding: 10px 12px; gap: 6px; }
  .lives-hearts { gap: 4px; }
  .life-heart { font-size: 12px; }
  .weapon-hud { right: 10px; bottom: 10px; width: min(240px, 34vw); padding: 10px 12px; }
  #toast-stack { right: 10px; top: 58px; width: 260px; }
  #sound-state { display: none; }
  .hud-top { top: 6px; left: 10px; right: 10px; }
  .mission-card { width: min(300px, 42vw); padding: 10px 12px; }
  .telemetry { display: none; }
  /* I controlli touch non devono interferire con i bottoni del pannello. */
  .settings-panel { font-size: 13px; }
}

/* ============================================================
   SMARTPHONE IN LANDSCAPE (schermi bassi)
   Menu avvio/pausa compatto — mai sovrapposto al CTA — e
   colonna pulsanti touch adattata all'altezza dello schermo.
   ============================================================ */

/* Menu: compatto, scrollabile di sicurezza, settings-panel in flow (sotto il
   CTA) invece di absolute-bottom: prima il pannello copriva il pulsante di
   avvio sui telefoni. .keys è già nascosto dal blocco (pointer: coarse). */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  #overlay {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 40px 16px 32px;
  }
  #overlay .boot, #overlay .build { top: 10px; font-size: 7px; letter-spacing: 1px; }
  #overlay .boot { left: 14px; }
  #overlay .build { right: 14px; }
  #overlay h1 { font-size: clamp(22px, 7vh, 34px); letter-spacing: 3px; margin-bottom: 2px; }
  #overlay .sub { font-size: 9px; margin-bottom: 10px; letter-spacing: 1px; }
  #overlay .brief {
    width: min(560px, 92vw);
    padding: 8px 14px;
    margin-bottom: 10px;
    font-size: 9px;
    line-height: 1.5;
    max-height: 4.5em;
    overflow: hidden;
  }
  #overlay .cta { font-size: 12px; padding: 9px 30px; }
  #overlay .loading-panel { margin: 12px 0 4px; }
  #overlay .gpu-warning { margin: 10px 0 4px; padding: 8px 12px; font-size: 9px; }
  .settings-panel {
    position: static;
    transform: none;
    order: 2;
    margin: 8px auto 2px;
    width: min(600px, 94vw);
    padding: 6px 10px;
    gap: 4px 10px;
    font-size: 10px;
  }
  .settings-panel .settings-title { font-size: 8px; letter-spacing: 1.2px; }
  .settings-panel label { gap: 2px; font-size: 8px; }
  .settings-panel input[type="range"] { height: 15px; }
  .settings-panel .quality-toggle button,
  .settings-panel .reset-level { padding: 4px 8px; font-size: 8px; }
}

/* Touch in gioco su schermi bassi (landscape): la colonna a destra era alta
   ~420px (60–92px per pulsante + gap 14px) e finiva fuori schermo — reload e
   melee in cima alla colonna uscivano dal bordo alto. Qui i pulsanti scalano
   con l'altezza (vh) e l'HUD arma si compatta per non collidere con il fuoco. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .touch-buttons-right {
    right: max(10px, calc(env(safe-area-inset-right, 0px) + 8px));
    bottom: calc(10px + 18vh);
    gap: clamp(4px, 1.3vh, 8px);
  }
  .touch-btn {
    width: clamp(38px, 11.5vh, 48px);
    height: clamp(38px, 11.5vh, 48px);
    font-size: clamp(7px, 1.9vh, 10px);
    letter-spacing: .5px;
  }
  .touch-btn-melee {
    width: clamp(34px, 10vh, 42px);
    height: clamp(34px, 10vh, 42px);
    font-size: clamp(6px, 1.6vh, 9px);
  }
  .touch-btn-jump {
    width: clamp(42px, 13vh, 54px);
    height: clamp(42px, 13vh, 54px);
  }
  .touch-btn-fire {
    width: clamp(48px, 15vh, 62px);
    height: clamp(48px, 15vh, 62px);
    font-size: clamp(8px, 2.4vh, 11px);
  }
  #touch-btn-sprint {
    left: max(10px, calc(env(safe-area-inset-left, 0px) + 8px));
    width: clamp(42px, 13vh, 54px);
    height: clamp(42px, 13vh, 54px);
    font-size: clamp(7px, 1.9vh, 10px);
  }
  /* HUD arma compatto: la colonna pulsanti parte sopra di esso. */
  .weapon-hud { width: min(170px, 32vw); padding: 6px 9px; }
  .weapon-hud #weapon-name { font-size: 9px; }
  .weapon-hud #ammo { font-size: 28px; letter-spacing: -3px; }
  .weapon-hud .reserve { font-size: 12px; }
  .weapon-hud .ammo-cells { display: none; }
  .weapon-hud .reload-message { top: -16px; font-size: 9px; }
}
