/* Last Light V5 mobile/tablet presentation layer.
   Every override is gated by body.mobile-v5 so mouse/keyboard layouts retain
   the established V4 presentation and DOM contracts. */
:root {
  --mobile-control-scale: 1;
  --mobile-control-opacity: .82;
  --mobile-control-button: 52px;
  --mobile-stick-size: 116px;
  --mobile-stick-knob: 50px;
  --mobile-vw: 100vw;
  --mobile-vh: 100vh;
  --mobile-safe-top: max(8px, env(safe-area-inset-top));
  --mobile-safe-right: max(8px, env(safe-area-inset-right));
  --mobile-safe-bottom: max(8px, env(safe-area-inset-bottom));
  --mobile-safe-left: max(8px, env(safe-area-inset-left));
}

.mobile-v5-only,
.mobile-settings { display: none; }

.mobile-orientation-hint[hidden] { display: none !important; }

body.mobile-v5 {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.mobile-v5 .mobile-v5-only { display: flex; }
body.mobile-v5 .mobile-settings { display: block; grid-column: 1 / -1; }
body.mobile-v5 #game-shell { width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; }
body.mobile-v5 #game { width: 100%; height: 100%; }

/* Safe-area-aware panels and production-sized touch targets. */
body.mobile-v5 .panel-screen {
  padding: calc(var(--mobile-safe-top) + 4px) calc(var(--mobile-safe-right) + 4px) calc(var(--mobile-safe-bottom) + 4px) calc(var(--mobile-safe-left) + 4px);
}
body.mobile-v5 .panel {
  width: min(1180px, calc(100vw - var(--mobile-safe-left) - var(--mobile-safe-right) - 8px));
  max-height: calc(100dvh - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 8px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.mobile-v5 button,
body.mobile-v5 select,
body.mobile-v5 input[type="range"] { min-height: 44px; }
body.mobile-v5 button.close,
body.mobile-v5 .squad-assist,
body.mobile-v5 input[type="checkbox"] { min-width: 44px; min-height: 44px; }
body.mobile-v5 [data-map-id],
body.mobile-v5 [data-survivor-id],
body.mobile-v5 [data-career-select],
body.mobile-v5 [data-career-unlock],
body.mobile-v5 [data-career-claim],
body.mobile-v5 .item-slot,
body.mobile-v5 .build-choice { min-height: 44px; }
body.mobile-v5 .v4-tabs,
body.mobile-v5 .craft-layout nav { scrollbar-width: thin; scroll-snap-type: x proximity; }
body.mobile-v5 .v4-tabs button,
body.mobile-v5 .craft-layout nav button { scroll-snap-align: start; }
body.mobile-v5 .settings-panel .settings-layout-v4 label { min-height: 58px; }
body.mobile-v5 .settings-panel input[type="range"] { width: 100%; touch-action: pan-x; }
body.mobile-v5 .settings-panel select { min-height: 44px; }

/* HUD clusters remain independently collapsible; wave/phase/time is never in
   a collapsible cluster and therefore always remains available. */
body.mobile-v5 [data-mobile-cluster] {
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
body.mobile-v5 [data-mobile-cluster][data-mobile-collapsed="true"] {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(-5px) !important;
}
body.mobile-v5 #hud {
  padding: var(--mobile-safe-top) var(--mobile-safe-right) var(--mobile-safe-bottom) var(--mobile-safe-left);
}
body.mobile-v5 .mobile-hud-dock {
  position: absolute;
  z-index: 38;
  top: calc(var(--mobile-safe-top) + 91px);
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(113, 143, 147, .34);
  background: rgba(5, 11, 15, .76);
  box-shadow: 0 7px 20px rgba(0, 0, 0, .38);
  backdrop-filter: blur(5px);
  pointer-events: auto;
}
body.mobile-v5 .mobile-hud-dock button {
  min-width: 60px;
  min-height: 44px;
  padding: 4px 7px;
  border-color: rgba(102, 130, 134, .44);
  background: rgba(15, 27, 32, .9);
  font: 900 9px/1 ui-monospace, Consolas, monospace;
  letter-spacing: .04em;
}
body.mobile-v5 .mobile-hud-dock button span { color: #79d5dd; font-size: 14px; margin-right: 2px; }
body.mobile-v5 .mobile-hud-dock button.collapsed { color: #82918f; background: rgba(8, 14, 18, .84); }

body.mobile-v5 .mobile-orientation-hint {
  position: fixed;
  z-index: 92;
  top: calc(var(--mobile-safe-top) + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - var(--mobile-safe-left) - var(--mobile-safe-right) - 16px));
  align-items: center;
  gap: 9px;
  padding: 8px 8px 8px 12px;
  border: 1px solid #806b3e;
  border-left: 3px solid var(--gold);
  background: rgba(7, 13, 17, .96);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .62);
}
body.mobile-v5 .mobile-orientation-hint div { min-width: 0; flex: 1; }
body.mobile-v5 .mobile-orientation-hint strong,
body.mobile-v5 .mobile-orientation-hint span { display: block; }
body.mobile-v5 .mobile-orientation-hint strong { color: var(--gold2); font: 900 10px ui-monospace, monospace; letter-spacing: .08em; }
body.mobile-v5 .mobile-orientation-hint span { margin-top: 2px; color: #a8b4b1; font-size: 12px; line-height: 1.3; }
body.mobile-v5 .mobile-orientation-hint button { flex: 0 0 44px; width: 44px; padding: 0; font-size: 21px; }

/* The final-loaded V5 layer owns every coarse-pointer coordinate. */
body.mobile-v5 #touch-ui {
  position: absolute;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  touch-action: none;
  transition: visibility .1s, opacity .1s;
}
body.mobile-v5 #touch-ui.mobile-controls-suspended { opacity: 0; visibility: hidden; }
body.mobile-v5 #touch-ui .touch-movement-zone,
body.mobile-v5 #touch-ui .touch-combat-zone,
body.mobile-v5 #touch-ui .touch-context-zone,
body.mobile-v5 #touch-ui .touch-utility-dock,
body.mobile-v5 #touch-ui .touch-secondary-dock { position: static; pointer-events: none; }
body.mobile-v5 #touch-ui .touch-stick {
  inset: auto;
  bottom: calc(var(--mobile-safe-bottom) + 10px);
  width: var(--mobile-stick-size);
  height: var(--mobile-stick-size);
  border: 2px solid rgb(205 228 227 / var(--mobile-control-opacity));
  background: rgb(6 13 17 / var(--mobile-control-opacity));
  box-shadow: inset 0 0 22px rgba(78, 132, 139, .14), 0 5px 20px rgba(0, 0, 0, .28);
  transform: none;
}
body.mobile-v5 #touch-ui #move-stick { left: calc(var(--mobile-safe-left) + 10px); right: auto; }
body.mobile-v5 #touch-ui #aim-stick { right: calc(var(--mobile-safe-right) + 10px); left: auto; }
body.mobile-v5 #touch-ui .touch-stick i {
  width: var(--mobile-stick-knob);
  height: var(--mobile-stick-knob);
  left: calc((100% - var(--mobile-stick-knob)) / 2);
  top: calc((100% - var(--mobile-stick-knob)) / 2);
  background: rgb(176 211 210 / var(--mobile-control-opacity));
  border-color: rgba(239, 250, 247, .54);
}
body.mobile-v5 #touch-ui [data-touch],
body.mobile-v5 #touch-ui [data-mobile-key] {
  position: absolute;
  display: grid;
  place-items: center;
  inset: auto;
  width: var(--mobile-control-button);
  height: var(--mobile-control-button);
  min-width: 44px;
  min-height: 44px;
  padding: 3px;
  border-radius: 13px;
  border: 1px solid rgba(129, 162, 166, .56);
  background: rgb(10 19 24 / var(--mobile-control-opacity));
  color: #eef4ef;
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 4px 14px rgba(0, 0, 0, .36);
  font: 900 10px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0;
  pointer-events: auto;
  touch-action: none;
  transform: none;
}
body.mobile-v5 #touch-ui button[data-touch]:active,
body.mobile-v5 #touch-ui button[data-mobile-pressed="true"] {
  color: #fff5cf;
  border-color: var(--gold2);
  background: rgba(112, 83, 32, .94);
  box-shadow: inset 0 0 14px rgba(255, 220, 121, .22);
}

/* Combat arc, right side by default. */
body.mobile-v5 #touch-ui [data-touch="reload"] { right: calc(var(--mobile-safe-right) + 8px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); }
body.mobile-v5 #touch-ui [data-touch="roll"] { right: calc(var(--mobile-safe-right) + 64px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); }
body.mobile-v5 #touch-ui [data-touch="ability"] { right: calc(var(--mobile-safe-right) + 120px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); border-color: rgba(174, 125, 209, .75); }
body.mobile-v5 #touch-ui [data-touch="combo"] { right: calc(var(--mobile-safe-right) + 8px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5 #touch-ui [data-touch="assist"] { right: calc(var(--mobile-safe-right) + 64px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5 #touch-ui [data-mobile-key="KeyV"] { right: calc(var(--mobile-safe-right) + 120px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }

/* Interaction/build arc, left side by default. */
body.mobile-v5 #touch-ui [data-touch="interact"] { left: calc(var(--mobile-safe-left) + 8px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); border-color: rgba(226, 181, 87, .76); }
body.mobile-v5 #touch-ui [data-touch="command"] { left: calc(var(--mobile-safe-left) + 64px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); }
body.mobile-v5 #touch-ui [data-touch="place"],
body.mobile-v5 #touch-ui [data-touch="rotate"],
body.mobile-v5 #touch-ui [data-mobile-key="KeyU"],
body.mobile-v5 #touch-ui [data-mobile-key="KeyX"] { display: none !important; }
body.mobile-v5.build-mode #touch-ui [data-touch="place"] { display: grid !important; left: calc(var(--mobile-safe-left) + 8px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5.build-mode #touch-ui [data-touch="rotate"] { display: grid !important; left: calc(var(--mobile-safe-left) + 64px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5.build-mode #touch-ui [data-mobile-key="KeyU"] { display: grid !important; left: calc(var(--mobile-safe-left) + 120px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px); }
body.mobile-v5.build-mode #touch-ui [data-mobile-key="KeyX"] { display: grid !important; left: calc(var(--mobile-safe-left) + 120px); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5.build-mode #touch-ui [data-touch="reload"] { display: none !important; }

/* Persistent, labeled panel access and secondary actions. */
body.mobile-v5 #touch-ui .touch-utility-dock {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--mobile-safe-bottom) + 6px);
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
}
body.mobile-v5 #touch-ui .touch-utility-dock button[data-touch],
body.mobile-v5 #touch-ui .touch-utility-dock button[data-mobile-key] {
  position: static;
  width: auto;
  min-width: 58px;
  height: 44px;
  min-height: 44px;
  padding: 4px 9px;
  border-radius: 8px;
}
body.mobile-v5 #touch-ui .touch-secondary-dock {
  position: absolute;
  z-index: 3;
  top: calc(var(--mobile-safe-top) + 5px);
  right: calc(var(--mobile-safe-right) + 5px);
  display: flex;
  gap: 4px;
}
body.mobile-v5 #touch-ui .touch-secondary-dock button[data-mobile-key] {
  position: static;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
}

/* Left-handed mode mirrors thumb-critical controls without mirroring labels. */
body.mobile-v5.mobile-left-handed #touch-ui #move-stick { left: auto; right: calc(var(--mobile-safe-right) + 10px); }
body.mobile-v5.mobile-left-handed #touch-ui #aim-stick { right: auto; left: calc(var(--mobile-safe-left) + 10px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="reload"] { right: auto; left: calc(var(--mobile-safe-left) + 8px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="roll"] { right: auto; left: calc(var(--mobile-safe-left) + 64px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="ability"] { right: auto; left: calc(var(--mobile-safe-left) + 120px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="combo"] { right: auto; left: calc(var(--mobile-safe-left) + 8px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="assist"] { right: auto; left: calc(var(--mobile-safe-left) + 64px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-mobile-key="KeyV"] { right: auto; left: calc(var(--mobile-safe-left) + 120px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="interact"] { left: auto; right: calc(var(--mobile-safe-right) + 8px); }
body.mobile-v5.mobile-left-handed #touch-ui [data-touch="command"] { left: auto; right: calc(var(--mobile-safe-right) + 64px); }
body.mobile-v5.mobile-left-handed.build-mode #touch-ui [data-touch="place"] { left: auto; right: calc(var(--mobile-safe-right) + 8px); }
body.mobile-v5.mobile-left-handed.build-mode #touch-ui [data-touch="rotate"] { left: auto; right: calc(var(--mobile-safe-right) + 64px); }
body.mobile-v5.mobile-left-handed.build-mode #touch-ui [data-mobile-key="KeyU"] { left: auto; right: calc(var(--mobile-safe-right) + 120px); }
body.mobile-v5.mobile-left-handed.build-mode #touch-ui [data-mobile-key="KeyX"] { left: auto; right: calc(var(--mobile-safe-right) + 120px); }
body.mobile-v5.mobile-left-handed #touch-ui .touch-secondary-dock { right: auto; left: calc(var(--mobile-safe-left) + 5px); }

/* Shared mobile HUD compaction. */
body.mobile-v5 .hud-top { gap: 7px; }
body.mobile-v5 .survivor-card,
body.mobile-v5 .wave-card,
body.mobile-v5 .status-card { min-height: 68px; padding: 7px 8px; }
body.mobile-v5 .portrait { width: 48px; height: 48px; }
body.mobile-v5 .objective { max-width: min(310px, 72vw); }
body.mobile-v5 #toast-stack { right: var(--mobile-safe-right); width: min(270px, calc(100vw - var(--mobile-safe-left) - var(--mobile-safe-right))); }
body.mobile-v5 #loot-feed { left: var(--mobile-safe-left); bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 126px); }
body.mobile-v5 .interact-prompt { bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 128px); max-width: 82vw; text-align: center; }
body.mobile-v5 .squad-hud { pointer-events: auto; }
body.mobile-v5 .squad-actions { display: none; }
body.mobile-v5 .quick-actions { display: none !important; }
body.mobile-v5 .command-wheel { max-width: 96vw; max-height: 96dvh; }
body.mobile-v5 .command-wheel kbd { display: none; }

/* Phone portrait: full support, not a forced-rotation fallback. */
body.mobile-v5[data-mobile-layout="phone-portrait"] .hud-top {
  grid-template-columns: minmax(178px, 1fr) 128px;
  align-items: start;
  gap: 5px;
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .survivor-card { min-width: 0; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .survivor-card .portrait { width: 42px; height: 42px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .survivor-card,
body.mobile-v5[data-mobile-layout="phone-portrait"] .wave-card { min-height: 62px; padding: 5px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .name-line { margin-bottom: 2px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .name-line strong { font-size: 11px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .wave-line { gap: 5px; margin: 4px 0 2px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .wave-line span { font-size: 10px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .wave-line strong { font-size: 15px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .wave-card small { font-size: 8px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .status-card {
  display: block;
  grid-column: 1 / -1;
  min-height: 37px;
  padding: 5px 8px;
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .status-card .resource-strip { display: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .status-card .meter.core { margin: 4px 0 0; }
body.mobile-v5[data-mobile-layout="phone-portrait"][data-mobile-cluster-vitals="collapsed"] .hud-top { grid-template-columns: 128px; justify-content: end; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #minimap { display: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #objective:not([data-mobile-collapsed="true"]) {
  display: block;
  top: calc(var(--mobile-safe-top) + 204px);
  left: var(--mobile-safe-left);
  max-width: calc(100vw - var(--mobile-safe-left) - var(--mobile-safe-right));
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .field-op-card:not(.hidden):not([data-mobile-collapsed="true"]) {
  display: block;
  top: calc(var(--mobile-safe-top) + 145px);
  right: var(--mobile-safe-right);
  width: min(188px, 49vw);
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .mobile-hud-dock { top: calc(var(--mobile-safe-top) + 145px); left: var(--mobile-safe-left); transform: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .mobile-hud-dock button { min-width: 44px; width: 54px; padding: 2px; font-size: 8px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-hud {
  top: auto;
  right: var(--mobile-safe-right);
  bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 186px);
  left: var(--mobile-safe-left);
  width: auto;
  max-width: none;
  max-height: 34dvh;
  padding: 6px;
  overflow: auto;
  transform: none;
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-card { width: auto; height: 54px; grid-template-columns: 40px minmax(0, 1fr); }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-card canvas { width: 38px; height: 44px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-card-copy strong { font-size: 9px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-card-copy strong em,
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-card-copy small,
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-assist { display: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .hud-bottom {
  top: auto;
  bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 188px);
  width: min(300px, calc(100vw - 16px));
  transform: translateX(-50%);
  gap: 4px;
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .ability-card { width: 104px; height: 48px; padding: 5px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .ability-card .keycap { display: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .ability-card strong { font-size: 9px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .ability-card small { font-size: 8px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .weapon-card { width: 172px; min-height: 54px; padding: 5px 7px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .weapon-slots { display: none; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .ammo-line strong { font-size: 20px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .build-bar { width: min(330px, calc(100vw - 12px)); min-width: 0; height: 70px; overflow-x: auto; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .build-choice { flex: 0 0 60px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui .touch-utility-dock {
  left: var(--mobile-safe-left);
  bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 14px);
  transform: none;
  flex-direction: row;
  gap: 3px;
}
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui .touch-utility-dock button[data-touch],
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui .touch-utility-dock button[data-mobile-key] { width: 44px; min-width: 44px; height: 44px; padding: 2px; font-size: 8px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui [data-touch="interact"],
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui [data-touch="command"] { bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px); }
body.mobile-v5[data-mobile-layout="phone-portrait"].mobile-left-handed #touch-ui .touch-utility-dock {
  right: var(--mobile-safe-right);
  left: auto;
}
body.mobile-v5[data-mobile-layout="phone-portrait"].build-mode #touch-ui [data-touch="interact"],
body.mobile-v5[data-mobile-layout="phone-portrait"].build-mode #touch-ui [data-touch="command"],
body.mobile-v5[data-mobile-layout="phone-portrait"].build-mode #touch-ui [data-mobile-key="KeyV"] { display: none !important; }
body.mobile-v5[data-mobile-layout="phone-portrait"].build-mode #touch-ui [data-mobile-key="KeyU"] {
  left: calc(var(--mobile-safe-left) + 120px);
  bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px);
}
body.mobile-v5[data-mobile-layout="phone-portrait"].build-mode #touch-ui [data-mobile-key="KeyX"] {
  left: calc(var(--mobile-safe-left) + 176px);
  bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 70px);
}
body.mobile-v5[data-mobile-layout="phone-portrait"].mobile-left-handed.build-mode #touch-ui [data-touch="place"] { right: calc(var(--mobile-safe-right) + 8px); left: auto; }
body.mobile-v5[data-mobile-layout="phone-portrait"].mobile-left-handed.build-mode #touch-ui [data-touch="rotate"] { right: calc(var(--mobile-safe-right) + 64px); left: auto; }
body.mobile-v5[data-mobile-layout="phone-portrait"].mobile-left-handed.build-mode #touch-ui [data-mobile-key="KeyU"] { right: calc(var(--mobile-safe-right) + 120px); left: auto; }
body.mobile-v5[data-mobile-layout="phone-portrait"].mobile-left-handed.build-mode #touch-ui [data-mobile-key="KeyX"] { right: calc(var(--mobile-safe-right) + 176px); left: auto; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #touch-ui .touch-secondary-dock { top: calc(var(--mobile-safe-top) + 252px); }
body.mobile-v5[data-mobile-layout="phone-portrait"] #toast-stack { top: calc(var(--mobile-safe-top) + 304px); }

/* Phone landscape: preserve battlefield height and keep center controls clear. */
body.mobile-v5[data-mobile-layout="phone-landscape"] {
  --mobile-control-button: 48px;
  --mobile-stick-size: 96px;
  --mobile-stick-knob: 42px;
}
body.mobile-v5[data-mobile-layout="phone-landscape"] .hud-top {
  grid-template-columns: minmax(205px, 1fr) 150px minmax(190px, 1fr);
  gap: 6px;
}
body.mobile-v5[data-mobile-layout="phone-landscape"] .survivor-card,
body.mobile-v5[data-mobile-layout="phone-landscape"] .wave-card,
body.mobile-v5[data-mobile-layout="phone-landscape"] .status-card { min-height: 58px; max-height: 64px; padding: 5px 7px; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .portrait { width: 42px; height: 42px; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .status-card { display: block; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .status-card { padding-right: 154px; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .status-card .resource-strip { display: none; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .mobile-hud-dock { top: calc(var(--mobile-safe-top) + 67px); }
body.mobile-v5[data-mobile-layout="phone-landscape"] #objective:not([data-mobile-collapsed="true"]) { display: block; top: calc(var(--mobile-safe-top) + 69px); left: var(--mobile-safe-left); }
body.mobile-v5[data-mobile-layout="phone-landscape"] #minimap { display: none; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .field-op-card:not(.hidden):not([data-mobile-collapsed="true"]) { top: calc(var(--mobile-safe-top) + 69px); right: var(--mobile-safe-right); width: 205px; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .squad-hud { top: calc(var(--mobile-safe-top) + 69px); bottom: auto; left: var(--mobile-safe-left); transform: scale(.82); transform-origin: left top; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .hud-bottom { bottom: calc(var(--mobile-safe-bottom) + 52px); transform: translateX(-50%) scale(.72); transform-origin: bottom center; }
body.mobile-v5[data-mobile-layout="phone-landscape"] .interact-prompt { bottom: calc(var(--mobile-safe-bottom) + 118px); }
body.mobile-v5[data-mobile-layout="phone-landscape"] #loot-feed { bottom: calc(var(--mobile-safe-bottom) + 112px); }
body.mobile-v5[data-mobile-layout="phone-landscape"] #touch-ui [data-mobile-key="KeyV"],
body.mobile-v5[data-mobile-layout="phone-landscape"] #touch-ui [data-touch="assist"],
body.mobile-v5[data-mobile-layout="phone-landscape"] #touch-ui [data-touch="combo"] { bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 64px); }

/* Tablets retain richer HUD/menu information with larger thumb spacing. */
body.mobile-v5[data-mobile-layout^="tablet-"] .hud-top { grid-template-columns: minmax(230px, 1fr) minmax(175px, .72fr) minmax(225px, 1fr); }
body.mobile-v5[data-mobile-layout^="tablet-"] .status-card { display: block; }
body.mobile-v5[data-mobile-layout^="tablet-"] .mobile-hud-dock { top: calc(var(--mobile-safe-top) + 80px); }
body.mobile-v5[data-mobile-layout^="tablet-"] #touch-ui .touch-secondary-dock { top: calc(var(--mobile-safe-top) + 80px); }
body.mobile-v5[data-mobile-layout^="tablet-"] #minimap { top: calc(var(--mobile-safe-top) + 134px); right: var(--mobile-safe-right); width: 140px; height: 140px; }
body.mobile-v5[data-mobile-layout^="tablet-"] .objective { top: calc(var(--mobile-safe-top) + 101px); left: var(--mobile-safe-left); width: 260px; max-width: 260px; }
body.mobile-v5[data-mobile-layout^="tablet-"] .field-op-card { top: calc(var(--mobile-safe-top) + 282px); right: var(--mobile-safe-right); }
body.mobile-v5[data-mobile-layout^="tablet-"] .squad-hud { top: calc(var(--mobile-safe-top) + 154px); left: var(--mobile-safe-left); bottom: auto; transform: scale(.9); transform-origin: left top; }
body.mobile-v5[data-mobile-layout^="tablet-"] .hud-bottom { bottom: calc(var(--mobile-safe-bottom) + 5px); transform: translateX(-50%) scale(.82); transform-origin: bottom center; }
body.mobile-v5[data-mobile-layout="tablet-landscape"] .hud-bottom { bottom: calc(var(--mobile-safe-bottom) + 62px); }
body.mobile-v5[data-mobile-layout="tablet-portrait"] #touch-ui .touch-utility-dock { bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 10px); }
body.mobile-v5[data-mobile-layout="tablet-portrait"] .hud-bottom { bottom: calc(var(--mobile-safe-bottom) + var(--mobile-stick-size) + 62px); }
body.mobile-v5[data-mobile-layout^="tablet-"] .operation-layout { grid-template-columns: minmax(0, 1.4fr) minmax(250px, .7fr); }
body.mobile-v5[data-mobile-layout^="tablet-"] .inventory-layout { grid-template-columns: 190px minmax(0, 1fr); }
body.mobile-v5[data-mobile-layout^="tablet-"] .inventory-layout .item-detail { grid-column: 1 / -1; min-height: 190px; }
body.mobile-v5[data-mobile-layout^="tablet-"] .squad-roster { grid-template-columns: repeat(3, minmax(145px, 1fr)); }

/* Compact portrait menus remain scrollable and safe-area bounded. */
body.mobile-v5[data-mobile-layout="phone-portrait"] .title-screen {
  align-items: flex-start;
  overflow-y: auto;
  padding: calc(var(--mobile-safe-top) + 10px) calc(var(--mobile-safe-right) + 10px) calc(var(--mobile-safe-bottom) + 22px) calc(var(--mobile-safe-left) + 10px);
}
body.mobile-v5[data-mobile-layout="phone-portrait"] .title-command-shell { width: 100%; min-height: 100%; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .title-content { width: 100%; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .title-command-shell .title-content h1 { font-size: clamp(3rem, 15vw, 4rem); }
body.mobile-v5[data-mobile-layout="phone-portrait"] .v4-menu-item { min-height: 52px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] #version { position: static; margin-top: 8px; text-align: right; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .panel { border-radius: 0; padding: 12px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .panel header { top: -12px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .inventory-layout,
body.mobile-v5[data-mobile-layout="phone-portrait"] .craft-layout,
body.mobile-v5[data-mobile-layout="phone-portrait"] .armory-content { display: block; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .inventory-grid { grid-template-columns: repeat(4, minmax(52px, 1fr)); }
body.mobile-v5[data-mobile-layout="phone-portrait"] .item-detail { margin-top: 10px; min-height: 220px; }
body.mobile-v5[data-mobile-layout="phone-portrait"] .squad-roster { grid-template-columns: repeat(2, minmax(135px, 1fr)); }

/* Short landscape previously clipped the seven-entry command center. */
@media (max-height: 520px) and (orientation: landscape) {
  body.mobile-v5 .title-screen {
    align-items: flex-start;
    overflow-y: auto;
    padding: calc(var(--mobile-safe-top) + 5px) calc(var(--mobile-safe-right) + 10px) calc(var(--mobile-safe-bottom) + 8px) calc(var(--mobile-safe-left) + 10px);
  }
  body.mobile-v5 .title-command-shell { display: block; width: 100%; }
  body.mobile-v5 .title-command-shell .title-content { width: 100%; max-width: 720px; }
  body.mobile-v5 .title-command-shell .title-content .eyebrow,
  body.mobile-v5 .title-command-shell .subtitle,
  body.mobile-v5 .title-command-shell .title-footer,
  body.mobile-v5 .title-briefing { display: none; }
  body.mobile-v5 .title-command-shell .title-content h1 { margin: 0 0 6px; font-size: clamp(2.4rem, 14vh, 3.4rem); line-height: .78; }
  body.mobile-v5 .title-command-shell .title-content h1 span { display: inline; margin-left: .12em; }
  body.mobile-v5 .v4-menu-list { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 4px; width: min(720px, 100%); }
  body.mobile-v5 .v4-menu-item,
  body.mobile-v5 .v4-menu-primary { min-height: 46px; padding: 4px 7px; }
  body.mobile-v5 #version { position: fixed; right: var(--mobile-safe-right); bottom: var(--mobile-safe-bottom); }
  body.mobile-v5 .panel-screen { align-items: flex-start; }
  body.mobile-v5 .panel { max-height: calc(100dvh - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 6px); padding: 10px 12px; }
  body.mobile-v5 .panel header { top: -10px; margin-bottom: 10px; padding-bottom: 8px; }
  body.mobile-v5 .settings-layout-v4 { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
  body.mobile-v5 .mobile-settings { grid-column: auto; }
}

/* Ultra-compact fallback: preserve targets, trim nonessential decoration. */
@media (max-width: 360px), (max-height: 360px) {
  body.mobile-v5 .mobile-hud-dock button { min-width: 44px; width: 44px; overflow: hidden; }
  body.mobile-v5 .mobile-hud-dock button span { display: block; margin: 0; }
  body.mobile-v5 .title-atmosphere:before,
  body.mobile-v5 .panel-lede { display: none; }
  body.mobile-v5 .inventory-grid { grid-template-columns: repeat(3, minmax(52px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  body.mobile-v5 [data-mobile-cluster],
  body.mobile-v5 #touch-ui,
  body.mobile-v5 .mobile-orientation-hint { transition: none !important; }
}
