/* ==========================================================================
   PERILUNE ORBITAL TRANSIT & ISS SIMULATOR STYLES
   Obsidian & Warm Ivory Aerospace Minimalism + Full Mobile Responsiveness
   ========================================================================== */

:root {
  --app-width: 100vw;
  --app-height: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --bg-obsidian: #05060a;
  --surface-glass: rgba(6, 10, 15, 0.88);
  --surface-elevated: rgba(12, 17, 24, 0.94);
  --border-hairline: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text-ivory: #ece7dc;
  --text-slate: rgba(154, 164, 174, 0.78);
  --accent-cyan: #67e8f9;
  --accent-amber: #d0a15c;
  --accent-sage: #7fb8a6;
  --accent-rose: #c08a8a;
  --accent-lavender: #9a8fc4;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background: var(--bg-obsidian);
  color: var(--text-ivory);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  width: var(--app-width, 100dvw);
  height: var(--app-height, 100dvh);
}

#canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
  touch-action: none;
}

#canvas-container canvas:active {
  cursor: grabbing;
}

#helmet-visor-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.8), inset 0 0 28px rgba(103, 232, 249, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: block;
}

/* UI SCREENS CONTAINER */
.app-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 20;
  pointer-events: auto;
}

/* ==========================================================================
   SCREEN 1: PERILUNE ORBITAL TITLE SCREEN
   ========================================================================== */
#screen-menu {
  justify-content: space-between;
  align-items: stretch;
  padding: calc(44px + var(--safe-top)) calc(36px + var(--safe-right)) calc(34px + var(--safe-bottom)) calc(44px + var(--safe-left));
  background:
    linear-gradient(90deg, rgba(5, 6, 10, 0.88) 0%, rgba(5, 6, 10, 0.48) 38%, rgba(5, 6, 10, 0.05) 75%, transparent 100%),
    linear-gradient(0deg, rgba(5, 6, 10, 0.82) 0%, transparent 45%);
  pointer-events: auto;
}

.title-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 2px;
}

.title-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2.2px;
  color: rgba(236, 231, 220, 0.85);
}

.title-brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
}

.title-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-chip-btn {
  padding: 6px 12px;
  background: rgba(6, 10, 15, 0.72);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.title-chip-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.title-auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: rgba(6, 10, 15, 0.72);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  backdrop-filter: blur(10px);
}

.title-hero {
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.title-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.4px;
  color: var(--accent-cyan);
}

.title-display {
  font-size: clamp(42px, 6.2vw, 72px);
  font-weight: 300;
  letter-spacing: 0.22em;
  line-height: 0.98;
  color: var(--text-ivory);
  margin: 0;
}

.title-premise {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(236, 231, 220, 0.68);
  max-width: 390px;
}

.title-callsign-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  padding: 6px 0;
  max-width: 340px;
  transition: border-color 0.15s ease;
}

.title-callsign-row:focus-within {
  border-bottom-color: var(--accent-cyan);
}

.title-callsign-lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: var(--text-slate);
}

.title-callsign-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.8px;
  outline: none;
}

.title-cta-row {
  display: flex;
  gap: 10px;
  max-width: 340px;
  margin-top: 4px;
}

.btn-title-primary {
  flex: 1.3;
  padding: 13px 18px;
  background: var(--text-ivory);
  border: 1px solid var(--text-ivory);
  border-radius: 4px;
  color: #05060a;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-title-primary:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.btn-title-secondary {
  flex: 1;
  padding: 13px 14px;
  background: rgba(6, 10, 15, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-title-secondary:hover {
  border-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.08);
}

.title-join-row {
  display: flex;
  gap: 8px;
  max-width: 340px;
}

.title-code-input {
  flex: 1;
  padding: 9px 12px;
  background: rgba(6, 10, 15, 0.65);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  outline: none;
}

.title-code-input:focus {
  border-color: var(--accent-cyan);
}

.btn-title-join {
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  cursor: pointer;
}

.btn-title-join:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.1);
}

.title-telemetry-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.5px;
  color: var(--text-slate);
  margin-top: 2px;
}

.title-telemetry-strip strong {
  color: var(--text-ivory);
  font-weight: 700;
}

.title-telemetry-strip strong.val-sage { color: var(--accent-sage); }
.title-telemetry-strip strong.val-amber { color: var(--accent-amber); }

.strip-sep {
  opacity: 0.4;
}

.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-slate);
  margin-bottom: 5px;
  text-transform: uppercase;
}

.auth-badge-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  flex-shrink: 0;
}

.auth-status-title {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-ivory);
  font-size: 10px;
  letter-spacing: 1.1px;
}

.auth-status-desc {
  font-size: 10px;
  color: var(--text-slate);
}

.btn-auth-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-hairline);
  color: var(--text-ivory);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-auth-action:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-danger-outline {
  background: rgba(192, 138, 138, 0.1) !important;
  border-color: rgba(192, 138, 138, 0.45) !important;
  color: var(--accent-rose) !important;
}

.auth-modal-card {
  width: 460px !important;
  max-width: 95vw;
}

.auth-tabs-row {
  display: flex;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 16px;
  gap: 8px;
}

.auth-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-slate);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 1.2px;
}

.auth-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.auth-links-row {
  font-size: 11px;
  color: var(--text-slate);
  text-align: center;
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.auth-links-row a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
}

.auth-msg-banner {
  margin: 12px 16px 0 16px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-msg-banner.error {
  background: rgba(192, 138, 138, 0.14);
  border: 1px solid rgba(192, 138, 138, 0.45);
  color: #f3c6c6;
}

.auth-msg-banner.success {
  background: rgba(127, 184, 166, 0.14);
  border: 1px solid rgba(127, 184, 166, 0.45);
  color: #bfe3d7;
}

.dossier-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.dossier-stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.dossier-stat-num {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.dossier-stat-lbl {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-slate);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.input-styled {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  color: var(--text-ivory);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease;
}

.input-styled:focus {
  border-color: var(--accent-cyan);
}

.btn-primary {
  width: 100%;
  padding: 12px 18px;
  background: var(--text-ivory);
  border: 1px solid var(--text-ivory);
  border-radius: 6px;
  color: #05060a;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
}

.btn-accent-subtle {
  border-color: rgba(103, 232, 249, 0.32);
  color: var(--accent-cyan);
}

.btn-accent-subtle:hover {
  border-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.1);
}

.join-code-row {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   SCREEN 2: LOBBY STAGING BAY
   ========================================================================== */
#screen-lobby {
  display: none;
  justify-content: space-between;
  padding: calc(44px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: radial-gradient(circle at center, rgba(10, 14, 22, 0.65) 0%, rgba(5, 6, 10, 0.92) 100%);
}

.lobby-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 10px 18px;
  backdrop-filter: blur(12px);
}

.room-code-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code-text {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent-amber);
}

.lobby-count-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent-cyan);
}

.btn-copy {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.lobby-main-area {
  display: flex;
  flex: 1;
  margin: 14px 0;
  gap: 16px;
  min-height: 0;
}

.lobby-players-grid {
  flex: 2;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-items: stretch;
  overflow-y: auto;
}

.lobby-player-pod {
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: border-color 0.2s ease;
}

.lobby-player-pod.occupied {
  border-color: rgba(103, 232, 249, 0.4);
}

.pod-color-indicator {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.pod-color-indicator.empty {
  background: rgba(255, 255, 255, 0.04);
  border-style: dashed;
}

.pod-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-ivory);
}

.pod-role {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.pod-ready-badge {
  padding: 3px 8px;
  background: rgba(127, 184, 166, 0.15);
  border: 1px solid rgba(127, 184, 166, 0.45);
  color: var(--accent-sage);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.lobby-customizer {
  flex: 1;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(12px);
}

.customizer-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--accent-cyan);
}

.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-color-btn {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.lobby-color-btn:hover,
.lobby-color-btn.active {
  transform: scale(1.08);
  border-color: #ffffff;
}

.lobby-roles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby-role-card {
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-ivory);
  transition: all 0.15s ease;
}

.lobby-role-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lobby-role-holders {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-slate);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-role-holders.filled {
  background: rgba(103, 232, 249, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(103, 232, 249, 0.35);
}

.lobby-role-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.08);
}

.lobby-role-card.active {
  border-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.16);
  box-shadow: 0 0 0 1px rgba(103, 232, 249, 0.45), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.lobby-role-card.active[data-role="engineer"] {
  border-color: #d0a15c;
  background: rgba(208, 161, 92, 0.16);
  box-shadow: 0 0 0 1px rgba(208, 161, 92, 0.45), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.lobby-role-card.active[data-role="scientist"] {
  border-color: #7fb8a6;
  background: rgba(127, 184, 166, 0.16);
  box-shadow: 0 0 0 1px rgba(127, 184, 166, 0.45), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.role-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-slate);
  line-height: 1.3;
}

.lobby-role-coverage {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.35;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-role-coverage.warn {
  color: #fcd34d;
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(120, 53, 15, 0.25);
}

.lobby-role-coverage.ready {
  color: #86efac;
  border-color: rgba(127, 184, 166, 0.38);
  background: rgba(6, 78, 59, 0.25);
}

/* Live In-Game Crew Role & Phase Responsibility Panel */
.hud-crew-roster {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 7px;
  border-radius: 5px;
  background: rgba(10, 17, 28, 0.85);
  border: 1px solid rgba(103, 232, 249, 0.22);
  font-family: var(--font-mono);
}

.crew-roster-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.crew-role-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  font-size: 9px;
  line-height: 1.25;
  min-width: 0;
}

.crew-role-chip.is-self {
  border-color: rgba(103, 232, 249, 0.6);
  background: rgba(103, 232, 249, 0.14);
}

.crew-role-chip.is-unstaffed {
  border-style: dashed;
  border-color: rgba(250, 204, 21, 0.35);
  opacity: 0.82;
}

.crew-role-chip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.crew-role-chip-names {
  color: #e2e8f0;
  font-size: 8.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crew-duty-callout {
  font-size: 9.5px;
  line-height: 1.35;
  color: #bae6fd;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.crew-duty-callout strong {
  color: #fef08a;
}

.lobby-pod-duty {
  font-size: 9.5px;
  color: #94a3b8;
  line-height: 1.25;
  margin-top: 2px;
}

.lobby-chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 90px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 8px;
}

.lobby-chat-msgs {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lobby-chat-input {
  flex: 1;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  color: var(--text-ivory);
  border-radius: 4px;
  font-size: 11px;
  outline: none;
}

.lobby-chat-send {
  padding: 5px 12px;
  background: var(--text-ivory);
  border: none;
  border-radius: 4px;
  color: #05060a;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.lobby-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.lobby-controls-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-slate);
}

.lobby-controls-hint strong {
  color: var(--text-ivory);
}

.btn-start-game {
  padding: 13px 28px;
  background: var(--text-ivory);
  border: 1px solid var(--text-ivory);
  border-radius: 6px;
  color: #05060a;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-start-game:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

/* ==========================================================================
   SCREEN 3: IN-GAME HUD (PERILUNE MINIMALIST TELEMETRY)
   ========================================================================== */
#screen-game {
  display: none;
  pointer-events: none;
}

.hud-race-bar-container {
  position: absolute;
  top: 12px;
  left: 16px;
  width: 310px;
  max-width: calc(100vw - 32px);
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 7px 12px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 50;
}

.hud-race-team {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-race-team-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
}

.hud-race-team.coop .hud-race-team-name {
  color: var(--text-ivory);
}

.hud-race-team-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot-coop {
  background: var(--accent-cyan);
}

.hud-race-score {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-amber);
}

.hud-race-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.hud-race-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.fill-coop {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-sage));
}

/* Crosshair Reticle */
#hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  pointer-events: none;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0.65;
  transition: opacity 0.2s ease;
}

.crosshair-dot {
  width: 3px;
  height: 3px;
  background: var(--text-ivory);
  border-radius: 50%;
}

.crosshair-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(236, 231, 220, 0.4);
  border-radius: 50%;
  transition: all 0.2s ease;
}

#hud-crosshair.target-locked {
  opacity: 1;
}

#hud-crosshair.target-locked .crosshair-dot {
  background: var(--accent-cyan);
  transform: scale(1.4);
}

#hud-crosshair.target-locked .crosshair-ring {
  width: 26px;
  height: 26px;
  border-color: var(--accent-cyan);
}

/* Fault Queue Checklist Panel */
.hud-checklist-panel {
  position: absolute;
  top: 56px;
  left: 16px;
  width: 296px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 7px 10px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 45;
}

.hud-checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-ivory);
}

.hud-checklist-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

#hud-checklist-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-checklist-meta-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  white-space: nowrap;
}

#hud-room-code {
  white-space: nowrap;
  flex-shrink: 0;
}

.checklist-count-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(103, 232, 249, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(103, 232, 249, 0.3);
}

.checklist-chevron {
  font-size: 11px;
  color: var(--text-slate);
  transition: transform 0.2s ease;
}

.hud-checklist-panel.collapsed {
  padding: 5px 9px;
}

.hud-checklist-panel.collapsed .hud-checklist-header {
  padding-bottom: 0;
  border-bottom: none;
}

.hud-checklist-panel.collapsed .hud-crew-roster,
.hud-checklist-panel.collapsed .crew-duty-callout {
  display: none !important;
}

.hud-checklist-panel.collapsed .hud-task-list-body {
  display: none !important;
}

.hud-checklist-panel.collapsed .checklist-chevron {
  transform: rotate(-90deg);
}

.hud-task-list-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 2px;
}

.hud-task-list-body::-webkit-scrollbar {
  width: 3px;
}
.hud-task-list-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.task-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 7px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  transition: border-color 0.15s ease;
}

.task-checklist-item:hover {
  border-color: rgba(103, 232, 249, 0.3);
}

.task-checklist-item.done {
  opacity: 0.45;
  border-color: rgba(127, 184, 166, 0.2);
}

.task-status-icon {
  font-size: 10px;
  margin-top: 2px;
  flex-shrink: 0;
}

.task-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.task-title-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-ivory);
}

.task-checklist-item.done .task-title-text {
  text-decoration: line-through;
  color: var(--text-slate);
}

.task-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-all {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-slate);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.badge-cmd {
  background: rgba(192, 138, 138, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(192, 138, 138, 0.35);
}

.badge-eng {
  background: rgba(208, 161, 92, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(208, 161, 92, 0.35);
}

.badge-sci {
  background: rgba(127, 184, 166, 0.15);
  color: var(--accent-sage);
  border: 1px solid rgba(127, 184, 166, 0.35);
}

.task-location-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-loc-pin {
  font-size: 8px;
  opacity: 0.6;
}

.task-loc-text {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-slate);
}

/* Proximity Interact Button [E] */
#btn-proximity-use {
  display: none;
  position: absolute;
  bottom: 28px;
  right: 28px;
  min-width: 170px;
  max-width: 320px;
  height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  background: rgba(6, 10, 15, 0.92);
  border: 1px solid rgba(103, 232, 249, 0.6);
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  z-index: 60;
  transition: border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

#btn-proximity-use:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.prox-key-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(103, 232, 249, 0.16);
  border: 1px solid rgba(103, 232, 249, 0.5);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 700;
}

/* Interactive Mini-Task Modal */
#task-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.84);
  backdrop-filter: blur(14px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  padding: 14px;
}

.task-modal-card {
  width: 780px;
  max-width: 96vw;
  max-height: 90vh;
  background: var(--surface-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#task-modal-content {
  overflow-y: auto;
  max-height: calc(90vh - 78px);
  padding-right: 4px;
}

#task-modal-content::-webkit-scrollbar {
  width: 4px;
}

#task-modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
}

.task-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 10px;
}

.task-modal-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.task-modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-slate);
  font-size: 20px;
  cursor: pointer;
}

.task-modal-close-btn:hover {
  color: var(--text-ivory);
}

/* Mini-Game Controls */
.wires-box {
  display: flex;
  justify-content: space-between;
  padding: 20px 10px;
}

.wire-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wire-node {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wire-node.selected {
  border-color: #ffffff;
  transform: scale(1.06);
}

.wire-node.connected {
  opacity: 0.55;
  border-color: var(--accent-sage);
}

.card-swipe-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}

.card-slot-track {
  width: 380px;
  max-width: 100%;
  height: 86px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.card-item-draggable {
  width: 90px;
  height: 66px;
  background: rgba(103, 232, 249, 0.18);
  border: 1px solid var(--accent-cyan);
  border-radius: 4px;
  position: absolute;
  top: 10px;
  left: 0;
  cursor: grab;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-ivory);
  user-select: none;
}

.card-scanner-led {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.valve-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--accent-rose);
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.laser-radar-grid {
  width: 100%;
  height: 220px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.meteor-blip {
  position: absolute;
  font-size: 22px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.meteor-blip:hover {
  transform: scale(1.25);
}

.meteor-blip.destroyed {
  opacity: 0.25;
  pointer-events: none;
}

/* Victory Overlay */
#victory-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.94);
  backdrop-filter: blur(14px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  pointer-events: auto;
  padding: 24px;
}

.victory-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2.4px;
  color: var(--accent-sage);
  margin-bottom: 10px;
}

.victory-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-ivory);
  letter-spacing: 3px;
  margin-bottom: 10px;
  text-align: center;
}

.victory-msg {
  font-size: 13px;
  color: var(--text-slate);
  margin-bottom: 22px;
  max-width: 460px;
  line-height: 1.6;
  text-align: center;
}

/* Launch Countdown Banner */
#launch-countdown-banner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.9);
  z-index: 180;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-ivory);
  letter-spacing: 3px;
  text-align: center;
  padding: 20px;
}

/* Virtual D-Pad */
#virtual-dpad {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  z-index: 50;
}

.dpad-row {
  display: flex;
  gap: 6px;
}

.dpad-btn {
  width: 50px;
  height: 50px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  color: var(--text-ivory);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
  user-select: none;
  touch-action: none;
}

@media (hover: hover) and (pointer: fine) {
  #virtual-dpad {
    display: none !important;
  }
}

/* ==========================================================================
   TOP-RIGHT COMPACT CONTROLS HUD
   ========================================================================== */
#hud-voice-panel {
  position: absolute;
  top: 12px;
  right: 16px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 6px 10px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 40;
}

.voice-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  user-select: none;
}

.voice-mic-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.voice-mic-btn.muted {
  background: rgba(192, 138, 138, 0.14);
  border-color: rgba(192, 138, 138, 0.45);
  color: var(--accent-rose);
}

.voice-mic-btn.active {
  background: rgba(103, 232, 249, 0.12);
  border-color: rgba(103, 232, 249, 0.55);
  color: var(--accent-cyan);
}

/* ==========================================================================
   CREW EMOTE WHEEL & FLOATING EMOTE FEEDBACK
   ========================================================================== */
#emote-wheel {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--safe-bottom));
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: 10px;
  background: rgba(7, 12, 21, 0.94);
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  z-index: 62;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px) scale(0.97);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

#emote-wheel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.emote-wheel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: var(--accent-cyan);
}

.emote-wheel-hint {
  color: var(--text-slate);
  font-weight: 600;
  letter-spacing: 0.6px;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.emote-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 62px;
  padding: 7px 5px 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.emote-btn:hover,
.emote-btn:focus-visible {
  background: rgba(103, 232, 249, 0.11);
  border-color: rgba(103, 232, 249, 0.5);
  transform: translateY(-1px);
}

.emote-btn:active {
  transform: translateY(0) scale(0.97);
}

.emote-icon {
  font-size: 23px;
  line-height: 1;
}

.emote-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-slate);
}

.emote-hotkey {
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 8px;
  font-weight: 700;
  color: rgba(154, 164, 174, 0.65);
}

#emote-toast {
  position: fixed;
  left: 50%;
  bottom: calc(250px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  padding: 7px 14px;
  background: rgba(7, 12, 21, 0.9);
  border: 1px solid rgba(103, 232, 249, 0.35);
  border-radius: 999px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: 62;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#emote-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.voice-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-slate);
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.voice-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-slate);
  display: inline-block;
}

.voice-pulse-dot.speaking {
  background: var(--accent-sage);
}

.voice-pulse-dot.muted {
  background: var(--accent-rose);
}

.voice-key-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-slate);
  text-align: right;
}

.voice-key-hint strong {
  color: var(--text-ivory);
}

.btn-lobby-voice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.btn-lobby-voice:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-lobby-voice.active {
  background: rgba(127, 184, 166, 0.16);
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}

/* ==========================================================================
   PERSISTENT TOP PERFORMANCE TELEMETRY PILL
   ========================================================================== */
#perf-overlay {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 4px 12px;
  backdrop-filter: blur(12px);
  z-index: 9999;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease;
}

#perf-overlay:hover {
  border-color: var(--accent-cyan);
}

.perf-status-badge {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.8px;
  background: rgba(127, 184, 166, 0.15);
  color: var(--accent-sage);
  border: 1px solid rgba(127, 184, 166, 0.35);
  margin-left: 2px;
}

.perf-status-badge.perf-moderate {
  background: rgba(208, 161, 92, 0.15);
  color: var(--accent-amber);
  border-color: rgba(208, 161, 92, 0.35);
}

.perf-status-badge.perf-caution {
  background: rgba(192, 138, 138, 0.2);
  color: var(--accent-rose);
  border-color: rgba(192, 138, 138, 0.45);
}

.perf-metric {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
}

.perf-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-sage);
}

.perf-label {
  color: var(--text-slate);
  font-size: 9px;
}

.perf-val {
  color: var(--text-ivory);
  font-weight: 700;
  min-width: 18px;
}

.perf-divider {
  color: rgba(255, 255, 255, 0.15);
  font-size: 10px;
}

.voice-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-slate);
  font-size: 12px;
  cursor: pointer;
}

.voice-settings-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--text-ivory);
}

.voice-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

#hud-active-speakers {
  position: absolute;
  top: 76px;
  right: 210px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 40;
}

.active-speaker-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.active-speaker-tag.speaker-local {
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}

.active-speaker-tag.speaker-radio {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* ==========================================================================
   SETTINGS & TELEMETRY MODALS
   ========================================================================== */
.settings-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.8);
  backdrop-filter: blur(14px);
  z-index: 99999;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

.settings-modal-card {
  width: 90%;
  max-width: 500px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid var(--border-hairline);
}

.settings-modal-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--text-ivory);
}

.settings-close-btn {
  background: transparent;
  border: none;
  color: var(--text-slate);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.settings-close-btn:hover {
  color: var(--text-ivory);
}

.settings-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 80vh;
  overflow-y: auto;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-slate);
  letter-spacing: 1px;
}

.settings-val-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.settings-select {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-ivory);
  font-size: 12px;
  outline: none;
}

.settings-select:focus {
  border-color: var(--accent-cyan);
}

.mic-meter-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.mic-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-sage), var(--accent-amber), var(--accent-rose));
  transition: width 0.06s linear;
}

.settings-slider {
  width: 100%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.btn-deafen {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  color: var(--text-slate);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-deafen.active {
  background: rgba(192, 138, 138, 0.16);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

.crewmate-volume-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.crewmate-vol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.crewmate-vol-name {
  font-size: 11px;
  font-weight: 600;
  min-width: 110px;
  color: var(--text-ivory);
}

.settings-keybinds-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 10.5px;
}

.keybind-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-slate);
}

.keybind-row span:first-child {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Diagnostics Overlay */
.hud-diagnostics-deck {
  position: fixed;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 660px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 12px 16px;
  backdrop-filter: blur(16px);
  z-index: 9998;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
  user-select: none;
  font-family: var(--font-mono);
}

.diag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.diag-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-ivory);
}

.diag-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diag-btn-gear {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  color: var(--accent-cyan);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
}

.diag-btn-close {
  background: transparent;
  border: none;
  color: var(--text-slate);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
}

.diag-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

@media (max-width: 640px) {
  .diag-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.diag-stat-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 8px 10px;
}

.diag-stat-label {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-slate);
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.diag-stat-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 2px;
}

.diag-stat-sub {
  font-size: 8.5px;
  color: var(--text-slate);
}

.diag-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: var(--text-slate);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

/* Systems Modal Tabs & Presets */
.systems-modal-card {
  max-width: 560px;
  width: 92%;
}

.preset-profiles-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-hairline);
  gap: 8px;
  flex-wrap: wrap;
}

.preset-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-slate);
  letter-spacing: 1px;
}

.preset-buttons-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  color: var(--text-slate);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
}

.btn-preset.active {
  background: rgba(103, 232, 249, 0.14);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-preset-reset {
  border-color: rgba(192, 138, 138, 0.3);
  color: var(--accent-rose);
}

.systems-tabs-bar {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-hairline);
  overflow-x: auto;
}

.sys-tab-btn {
  flex: 1;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-slate);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
}

.sys-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.05);
}

.sys-tab-content {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.sys-tab-content.active {
  display: flex;
}

.settings-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.settings-toggle-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-ivory);
}

.settings-toggle-desc {
  font-size: 10px;
  color: var(--text-slate);
  margin-top: 2px;
  max-width: 360px;
  line-height: 1.4;
}

.switch-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.14);
  transition: 0.2s ease;
  border-radius: 20px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-ivory);
  transition: 0.2s ease;
  border-radius: 50%;
}

.switch-toggle input:checked + .switch-slider {
  background-color: var(--accent-cyan);
}

.switch-toggle input:checked + .switch-slider:before {
  background-color: #05060a;
  transform: translateX(18px);
}

.network-diagnostics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 10px;
}

.net-diag-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.net-diag-lbl {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-slate);
}

.net-diag-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* ==========================================================================
   3D GLB MODEL HANGAR
   ========================================================================== */
.hangar-modal-card {
  max-width: 1040px;
  width: 95%;
  height: 84vh;
  max-height: 780px;
  display: flex;
  flex-direction: column;
}

.hangar-header {
  padding: 12px 18px;
}

.hangar-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 0;
}

.hangar-sidebar {
  width: 270px;
  background: rgba(5, 6, 10, 0.96);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hangar-tabs-row {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border-hairline);
}

.hangar-tab-btn {
  flex: 1;
  padding: 9px 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-slate);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.hangar-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.hangar-catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hangar-catalog-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
}

.hangar-catalog-card:hover {
  border-color: var(--border-strong);
}

.hangar-catalog-card.active {
  border-color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.08);
}

.hangar-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.hangar-card-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(103, 232, 249, 0.12);
  padding: 2px 6px;
  border-radius: 3px;
}

.hangar-card-role {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-slate);
}

.hangar-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-ivory);
  margin-bottom: 2px;
}

.hangar-card-desc {
  font-size: 10px;
  color: var(--text-slate);
  line-height: 1.35;
}

.hangar-upload-box {
  padding: 10px;
  border-top: 1px solid var(--border-hairline);
}

.hangar-viewport-wrapper {
  flex: 1;
  position: relative;
  background: #05060a;
  display: flex;
  overflow: hidden;
}

#hangar-viewport-container {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.hangar-viewport-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 10;
}

.hangar-ctrl-btn {
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  color: var(--text-slate);
  border-radius: 4px;
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.hangar-ctrl-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.hangar-viewport-status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-ivory);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.hangar-specs-panel {
  width: 280px;
  background: rgba(5, 6, 10, 0.96);
  border-left: 1px solid var(--border-hairline);
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.hangar-spec-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-ivory);
  margin-top: 4px;
  margin-bottom: 6px;
}

.hangar-spec-desc {
  font-size: 11px;
  color: var(--text-slate);
  line-height: 1.45;
  margin-bottom: 14px;
}

.hangar-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 14px;
}

.hangar-stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hangar-stat-lbl {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-slate);
}

.hangar-stat-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* ==========================================================================
   MOBILE ANALOG VIRTUAL THUMBSTICK & FULL RESPONSIVE VIEWPORT ADAPTATION
   ========================================================================== */
#mobile-joystick-zone {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: calc(14px + var(--safe-left));
  width: 118px;
  height: 134px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: auto;
  touch-action: none;
  z-index: 65;
}

#mobile-joystick-base {
  position: relative;
  width: 106px;
  height: 106px;
  border-radius: 50%;
  background: rgba(6, 10, 15, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

#mobile-joystick-ring {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px dashed rgba(103, 232, 249, 0.28);
  pointer-events: none;
}

#mobile-joystick-stick {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(236, 231, 220, 0.9);
  border: 1px solid #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.04s linear;
  pointer-events: none;
}

#mobile-joystick-hint {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-slate);
  text-transform: uppercase;
  pointer-events: none;
}

/* Touch Joystick: only on real touch devices (body.touch-ui or coarse pointer),
   never on narrow non-touch desktop windows. */
body.touch-ui #mobile-joystick-zone {
  display: flex;
}

body.touch-ui #virtual-dpad {
  display: none !important;
}

@media (pointer: coarse), (hover: none) {
  #mobile-joystick-zone {
    display: flex;
  }

  #virtual-dpad {
    display: none !important;
  }
}

/* Tablet & Coarse Touch Devices */
@media (max-width: 900px), (pointer: coarse) {
  #perf-overlay {
    top: calc(6px + var(--safe-top));
    padding: 3px 9px;
    gap: 8px;
  }

  #screen-menu {
    padding: calc(36px + var(--safe-top)) calc(14px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(14px + var(--safe-left));
    background:
      linear-gradient(0deg, rgba(5, 6, 10, 0.95) 0%, rgba(5, 6, 10, 0.78) 48%, rgba(5, 6, 10, 0.12) 100%);
    overflow-y: auto;
  }

  .title-topbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .title-brand {
    font-size: 9px;
    letter-spacing: 1.5px;
  }

  .title-hero {
    max-width: 100%;
    gap: 10px;
  }

  .title-display {
    font-size: clamp(32px, 10vw, 46px);
    letter-spacing: 0.18em;
  }

  .title-premise {
    font-size: 12px;
    max-width: 100%;
  }

  .title-callsign-row,
  .title-cta-row,
  .title-join-row {
    max-width: 100%;
  }

  #screen-lobby {
    padding: calc(38px + var(--safe-top)) 10px calc(10px + var(--safe-bottom)) 10px;
    overflow-y: auto;
    gap: 8px;
  }

  .lobby-top-bar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .room-code-text {
    font-size: 16px;
  }

  .lobby-main-area {
    flex-direction: column;
    margin: 4px 0;
    gap: 10px;
    overflow-y: auto;
  }

  .lobby-players-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .lobby-player-pod {
    padding: 10px 8px;
    gap: 6px;
  }

  .lobby-bottom-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .btn-start-game {
    width: 100%;
    padding: 12px 18px;
  }

  .hangar-modal-card {
    width: 96vw;
    height: calc(var(--app-height, 100dvh) - 20px);
    max-height: none;
  }

  .hangar-modal-body {
    flex-direction: column;
    overflow-y: auto;
  }

  .hangar-sidebar {
    width: 100%;
    max-height: 165px;
    border-right: none;
    border-bottom: 1px solid var(--border-hairline);
  }

  .hangar-viewport-wrapper {
    min-height: 200px;
  }

  .hangar-specs-panel {
    width: 100%;
    max-height: 200px;
    border-left: none;
    border-top: 1px solid var(--border-hairline);
    padding: 10px 12px;
  }
}

/* ==========================================================================
   SHARED EXPEDITION FLOW — LOBBY MISSION SELECT, BRIEFING & DEBRIEF
   ========================================================================== */
.lobby-mission-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  backdrop-filter: blur(12px);
}

.lobby-mission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lobby-mission-selected {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent-cyan);
  margin-top: 2px;
}

.lobby-mission-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-slate);
}

.lobby-mission-cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
}

.lobby-difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-difficulty-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#mission-briefing-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(3, 7, 18, 0.9);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.mission-briefing-card {
  width: min(680px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.mission-briefing-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-ivory);
  margin: 6px 0;
}

.mission-briefing-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent-amber);
  margin-bottom: 14px;
}

.mission-briefing-summary {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-slate);
  text-align: left;
  margin-bottom: 14px;
}

.mission-briefing-objectives {
  text-align: left;
  font-size: 11px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 8px;
}

.victory-debrief {
  width: min(560px, 92vw);
  margin-bottom: 18px;
}

@media (max-width: 900px) {
  .lobby-mission-panel {
    padding: 8px 10px;
  }

  .lobby-mission-cards {
    gap: 6px;
  }

  .lobby-mission-selected {
    font-size: 11px;
  }

  .mission-briefing-card {
    padding: 18px;
  }
}

#victory-overlay {
  overflow-y: auto;
}

/* ==========================================================================
   MOBILE HUD & RESPONSIVE VISIBILITY REFINEMENTS
   Keeps touch controls clear of panels, prevents action bars from overflowing,
   and removes expensive backdrop blurs on phone GPUs.
   ========================================================================== */
@media (max-width: 900px), (pointer: coarse) {
  /* Reduce GPU cost of translucent glass panels on mobile. */
  #perf-overlay,
  #hud-voice-panel,
  .hud-race-bar-container,
  .hud-checklist-panel,
  #space-center-ground-hud,
  #emote-wheel,
  .lobby-top-bar,
  .lobby-customizer,
  .lobby-mission-panel,
  .lobby-player-pod,
  .task-modal-card,
  .settings-modal-card,
  .mission-briefing-card,
  #mobile-joystick-base {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  #task-modal-overlay,
  .settings-modal-overlay,
  #mission-briefing-overlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: rgba(3, 7, 18, 0.96) !important;
  }

  .settings-modal-overlay {
    align-items: stretch;
    padding: 8px;
  }

  .settings-modal-card {
    width: 100%;
    max-width: 520px;
    max-height: calc(var(--app-height, 100dvh) - 16px);
  }

  .settings-modal-body {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  #mobile-joystick-base {
    background: rgba(6, 10, 15, 0.9);
  }

  #hud-voice-panel {
    padding: 5px 7px;
  }

  .lobby-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    align-items: stretch;
    gap: 6px;
    padding: 8px calc(10px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(10px + var(--safe-left));
    background: linear-gradient(0deg, rgba(5, 8, 16, 0.99) 0%, rgba(5, 8, 16, 0.94) 100%);
    border-top: 1px solid var(--border-hairline);
    text-align: center;
  }

  #screen-lobby {
    padding-bottom: calc(126px + var(--safe-bottom)) !important;
  }

  .lobby-controls-hint {
    max-width: 100%;
    font-size: 9px;
    line-height: 1.5;
  }

  /* Mission briefing becomes a full-height, scrollable card with a sticky
     begin button so the primary action is always reachable. */
  #mission-briefing-overlay {
    align-items: stretch;
    padding: 10px;
  }

  .mission-briefing-card {
    width: 100%;
    max-height: calc(var(--app-height, 100dvh) - 20px);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
  }

  .mission-briefing-title {
    font-size: 16px;
    line-height: 1.3;
  }

  .mission-briefing-summary {
    font-size: 11.5px;
    line-height: 1.55;
    margin-bottom: 10px;
  }

  .mission-briefing-objectives {
    overflow-y: auto;
    max-height: 36vh;
    font-size: 10px;
    padding-right: 4px;
  }

  #btn-briefing-begin {
    position: sticky;
    bottom: 0;
    width: 100% !important;
    max-width: none !important;
    margin-top: auto !important;
    padding-top: 10px;
    padding-bottom: 10px;
    box-shadow: 0 -8px 18px rgba(5, 8, 16, 0.92);
  }

  .mission-briefing-card .btn-primary {
    margin-bottom: 0;
  }
}

/* ==========================================================================
   UNIFIED RESPONSIVE HUD SYSTEM & NON-OVERLAPPING ZONE ARCHITECTURE
   ========================================================================== */
#action-toast {
  display: none;
  position: fixed;
  top: calc(44px + var(--safe-top));
  right: auto;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10050;
  width: max-content;
  max-width: clamp(260px, calc(100vw - 960px), 440px);
  padding: 8px 16px;
  border-radius: 6px;
  background: rgba(6, 10, 15, 0.94);
  border: 1px solid rgba(103, 232, 249, 0.45);
  color: var(--text-ivory);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.hud-checklist-panel {
  max-height: calc(var(--app-height, 100dvh) - 170px);
  overflow-y: auto;
}

.hud-task-list-body {
  max-height: min(220px, calc(var(--app-height, 100dvh) - 340px));
  overflow-y: auto;
}

.hud-diagnostics-deck {
  max-height: calc(var(--app-height, 100dvh) - 80px);
  overflow-y: auto;
}

#btn-proximity-use {
  position: fixed;
  bottom: calc(14px + var(--safe-bottom));
  right: calc(16px + var(--safe-right));
  min-width: 170px;
  max-width: 230px;
  height: 42px;
  z-index: 930;
}

/* Center the emote wheel so it never collides with corner HUD bars, and place
   transient emote toasts cleanly below #action-toast. */
#emote-wheel {
  top: 50%;
  left: 50%;
  bottom: auto;
  transform: translate(-50%, -50%) scale(0.92);
  max-height: calc(var(--app-height, 100dvh) - 40px);
  overflow-y: auto;
  z-index: 980;
}

#emote-wheel.open {
  transform: translate(-50%, -50%) scale(1);
}

#emote-toast {
  top: calc(104px + var(--safe-top));
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: clamp(220px, calc(100vw - 960px), 340px);
  white-space: normal;
  z-index: 10040;
}

#btn-telemetry-toggle {
  position: fixed;
  bottom: calc(10px + var(--safe-bottom));
  left: calc(12px + var(--safe-left));
  z-index: 925;
  display: none;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 9px;
  background: rgba(6, 10, 16, 0.90);
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 6px;
  color: rgba(236, 231, 220, 0.90);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

#btn-telemetry-toggle:hover {
  border-color: rgba(103, 232, 249, 0.65);
  color: #ffffff;
}

body.game-active #btn-telemetry-toggle {
  display: inline-flex;
}

body:not(.telemetry-collapsed) #btn-telemetry-toggle {
  border-color: rgba(103, 232, 249, 0.60);
  color: var(--accent-cyan);
}

#perilune-resource-meters {
  position: fixed;
  bottom: calc(10px + var(--safe-bottom));
  left: calc(88px + var(--safe-left));
  z-index: 920;
  display: none;
  gap: 10px;
  align-items: center;
  max-width: calc(100vw - 328px);
  background: rgba(6, 10, 15, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 5px 10px;
  backdrop-filter: blur(10px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}

body.game-active #perilune-resource-meters {
  display: flex;
}

body.telemetry-collapsed #perilune-resource-meters {
  display: none !important;
}

.perilune-res-item {
  min-width: 76px;
  overflow: hidden;
}

.perilune-res-head {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  font-size: 8px;
  letter-spacing: 0.7px;
  color: rgba(236, 231, 220, 0.88);
  white-space: nowrap;
}

.perilune-res-track {
  margin-top: 2px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

/* Primary phase action docks share the centered lower-center slot cleanly
   near the bottom edge (collapsing to the bottom when telemetry is closed). */
#space-center-ground-hud {
  position: fixed;
  bottom: calc(50px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 960;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: max-content;
  min-width: min(440px, calc(100vw - 32px));
  max-width: min(740px, calc(100vw - 32px));
  max-height: calc(var(--app-height, 100dvh) - 180px);
  overflow-y: auto;
  background: rgba(6, 10, 16, 0.90);
  border: 1px solid rgba(103, 232, 249, 0.34);
  padding: 7px 10px;
  border-radius: 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: auto;
}

body.telemetry-collapsed #space-center-ground-hud,
body.telemetry-collapsed #ship-interior-hud {
  bottom: calc(10px + var(--safe-bottom));
}

body.telemetry-collapsed #space-center-ground-hud {
  max-width: min(720px, calc(100vw - 184px));
}

#space-center-ground-hud.is-collapsed {
  padding: 5px 9px;
  gap: 0;
  min-width: 0;
}

#space-center-ground-hud.is-collapsed .sc-hud-body {
  display: none !important;
}

.sc-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.sc-hud-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 180px;
}

.sc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #67e8f9;
  box-shadow: 0 0 8px rgba(103, 232, 249, 0.7);
  flex: 0 0 auto;
}

.sc-status-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(236, 231, 220, 0.94);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-hud-primary {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.sc-hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(14, 22, 34, 0.88);
  color: rgba(236, 231, 220, 0.92);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.45px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.sc-hud-btn:hover {
  border-color: rgba(103, 232, 249, 0.6);
  color: #ffffff;
}

.sc-hud-btn.is-active,
.sc-btn-tour.is-active {
  border-color: rgba(103, 232, 249, 0.72);
  background: rgba(18, 56, 74, 0.88);
  color: #a5f3fc;
}

.sc-btn-term {
  border-color: rgba(103, 232, 249, 0.45);
  background: rgba(12, 36, 48, 0.78);
  color: #67e8f9;
}

.sc-btn-launch {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(54, 34, 10, 0.80);
  color: #fbbf24;
}

.sc-btn-plan {
  border-color: rgba(167, 139, 250, 0.35);
}

.sc-btn-mdl {
  border-color: rgba(251, 191, 36, 0.35);
}

.sc-btn-viz {
  border-color: rgba(96, 165, 250, 0.35);
}

.sc-btn-collapse {
  padding: 4px 7px;
  min-width: 24px;
  color: rgba(186, 200, 218, 0.88);
}

.sc-hud-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sc-hud-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.sc-hud-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.sc-hud-steps::-webkit-scrollbar {
  display: none;
}

.sc-step-chip {
  flex: 0 0 auto;
  font-size: 8.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(214, 222, 232, 0.78);
  white-space: nowrap;
}

.sc-step-chip.is-done {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(16, 62, 46, 0.45);
  color: #6ee7b7;
}

.sc-step-chip.is-active {
  border-color: rgba(103, 232, 249, 0.55);
  background: rgba(14, 52, 68, 0.55);
  color: #67e8f9;
}

.sc-tour-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
}

.sc-tour-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 4px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 19, 30, 0.86);
  color: rgba(226, 232, 240, 0.90);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.35px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.sc-tour-btn:hover {
  border-color: rgba(103, 232, 249, 0.6);
  color: #ffffff;
}

.sc-tour-btn.is-active {
  border-color: rgba(103, 232, 249, 0.75);
  background: rgba(16, 60, 78, 0.85);
  color: #a5f3fc;
}

#ship-interior-hud {
  position: fixed;
  bottom: calc(50px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  max-width: min(740px, calc(100vw - 32px));
  background: rgba(6, 10, 15, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 11px;
  border-radius: 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: auto;
}

/* Minimap strictly below the top-right voice panel */
#perilune-ship-minimap {
  position: fixed;
  top: calc(96px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  width: 184px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(6, 10, 15, 0.86);
  backdrop-filter: blur(12px);
  z-index: 900;
  display: none;
  pointer-events: auto;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#hud-active-speakers {
  top: calc(96px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  align-items: flex-end;
  max-width: 210px;
}

body.interior-active #hud-active-speakers {
  right: calc(212px + var(--safe-right));
}

/* Coarse-touch large tablets / laptops (>900px width): clear bottom-left
   thumbstick from telemetry toggle and resource meters. */
@media (pointer: coarse) and (min-width: 901px) {
  #btn-telemetry-toggle {
    left: calc(142px + var(--safe-left));
  }

  #perilune-resource-meters {
    left: calc(216px + var(--safe-left));
    max-width: calc(100vw - 448px);
  }
}

/* Docking, Launch Cutscene & ISS Showcase Fullscreen HUDs */
#docking-hud-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px calc(18px + var(--safe-bottom)) 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dock-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.dock-title-card {
  background: rgba(6, 10, 16, 0.9);
  border: 1px solid rgba(103, 232, 249, 0.38);
  border-radius: 8px;
  padding: 8px 14px;
  backdrop-filter: blur(10px);
}

#dock-status-badge {
  background: rgba(6, 10, 16, 0.9);
  border: 1px solid rgba(103, 232, 249, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #67e8f9;
  backdrop-filter: blur(10px);
}

.dock-actions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  pointer-events: auto;
}

.dock-hint-line {
  flex-basis: 100%;
  text-align: right;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #94a3b8;
}

.dock-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  pointer-events: none;
}

.dock-bottom-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  align-self: center;
  pointer-events: auto;
  max-width: 100%;
}

.dock-telem-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.dock-telem-card {
  background: rgba(6, 10, 16, 0.92);
  border: 1px solid rgba(103, 232, 249, 0.3);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
  min-width: 105px;
}

.dock-rcs-bar {
  background: rgba(6, 10, 16, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

#launch-cutscene-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(20px + var(--safe-top)) 28px calc(24px + var(--safe-bottom));
  background: radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.75) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.launch-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.launch-badge-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 8px 16px;
  backdrop-filter: blur(8px);
}

#btn-skip-launch {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #cbd5e1;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}

#launch-capcom-banner {
  align-self: center;
  background: rgba(6, 9, 19, 0.85);
  border-left: 4px solid #38bdf8;
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: 1px;
  text-align: center;
  max-width: min(680px, calc(100vw - 24px));
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.25);
  backdrop-filter: blur(8px);
}

#launch-telem-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  align-self: center;
  max-width: 100%;
}

#launch-flash {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s linear;
  z-index: 100000;
}

#iss-showcase-topbar {
  pointer-events: auto;
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  background: rgba(5, 10, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 16px;
  backdrop-filter: blur(14px);
}

#iss-showcase-left {
  pointer-events: auto;
  position: absolute;
  top: calc(82px + var(--safe-top));
  bottom: calc(20px + var(--safe-bottom));
  left: calc(16px + var(--safe-left));
  width: 288px;
  background: rgba(5, 10, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(14px);
}

#iss-showcase-right {
  pointer-events: auto;
  position: absolute;
  top: calc(82px + var(--safe-top));
  bottom: calc(20px + var(--safe-bottom));
  right: calc(16px + var(--safe-right));
  width: 340px;
  background: rgba(5, 10, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(14px);
}

/* Touch tablets/laptops wider than 900px when body.touch-ui is active */
@media (min-width: 901px) {
  body.touch-ui #btn-telemetry-toggle {
    left: calc(142px + var(--safe-left));
  }

  body.touch-ui #perilune-resource-meters {
    left: calc(216px + var(--safe-left));
    max-width: calc(100vw - 448px);
  }
}

/* Medium Desktop (901px .. 1360px): wrap 8-button voice panel into a 4x2 grid
   so it never collides with centered #perf-overlay or left mission HUD panels. */
@media (max-width: 1360px) and (min-width: 901px) {
  .hud-race-bar-container,
  .hud-checklist-panel {
    width: 248px;
  }

  #hud-voice-panel {
    width: 284px;
    padding: 5px 7px;
  }

  .voice-header-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }

  .voice-header-row .voice-mic-btn,
  .voice-header-row .voice-settings-btn {
    width: 100%;
    justify-content: center;
    padding: 4px 4px;
    font-size: 8px;
  }

  #perilune-ship-minimap {
    top: calc(108px + var(--safe-top));
    width: 170px;
  }

  #hud-active-speakers {
    top: calc(108px + var(--safe-top));
  }

  body.interior-active #hud-active-speakers {
    right: calc(198px + var(--safe-right));
  }

  #action-toast {
    max-width: clamp(240px, calc(100vw - 580px), 380px);
  }

  #emote-toast {
    max-width: clamp(200px, calc(100vw - 580px), 320px);
  }

  #perilune-resource-meters {
    gap: 8px;
    padding: 5px 9px;
  }

  .perilune-res-item {
    min-width: 64px;
  }

  #iss-showcase-left {
    top: calc(96px + var(--safe-top));
    width: 244px;
  }

  #iss-showcase-right {
    top: calc(96px + var(--safe-top));
    width: 280px;
  }
}

/* Tablet & Compact Viewports (<= 900px) */
@media (max-width: 900px) {
  #perf-overlay {
    top: calc(6px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 9px;
    gap: 8px;
  }

  .hud-race-bar-container {
    top: calc(36px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: 236px;
    max-width: calc(50vw - 16px);
    padding: 4px 9px;
  }

  .hud-checklist-panel {
    top: calc(82px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: 236px;
    max-width: calc(50vw - 16px);
    max-height: calc(var(--app-height, 100dvh) - 300px);
    overflow-y: auto;
    padding: 6px 8px;
  }

  .hud-task-list-body {
    max-height: 108px;
  }

  #hud-voice-panel {
    top: calc(36px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    bottom: auto;
    left: auto;
    transform: none;
    width: 256px;
    max-width: calc(50vw - 16px);
    padding: 4px 5px;
    z-index: 58;
  }

  .voice-header-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
  }

  .voice-header-row .voice-mic-btn,
  .voice-header-row .voice-settings-btn {
    width: 100%;
    min-height: 28px;
    padding: 3px 2px;
    font-size: 7.5px;
    line-height: 1.1;
    letter-spacing: 0.3px;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }

  .voice-header-row .voice-settings-btn span:first-child {
    font-size: 11px;
    line-height: 1;
  }

  .voice-header-row .voice-mic-btn span,
  .voice-header-row .voice-settings-btn span {
    display: inline;
  }

  .voice-sub-row {
    display: none !important;
  }

  /* Minimap sits strictly below the top-right voice panel */
  #perilune-ship-minimap {
    top: calc(108px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: 148px;
  }

  #hud-active-speakers {
    top: calc(108px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    max-width: 160px;
  }

  body.interior-active #hud-active-speakers {
    right: calc(164px + var(--safe-right));
  }

  /* Sized & positioned for touch-ui / coarse pointers; hidden on desktop */
  #mobile-joystick-zone {
    bottom: calc(10px + var(--safe-bottom));
    left: calc(10px + var(--safe-left));
    width: 104px;
    height: 112px;
  }

  #btn-proximity-use {
    bottom: calc(10px + var(--safe-bottom));
    right: calc(8px + var(--safe-right));
    min-width: 118px;
    max-width: 168px;
    height: 36px;
    padding: 0 10px;
    font-size: 9.5px;
  }

  body.touch-ui #btn-proximity-use {
    bottom: calc(16px + var(--safe-bottom));
    right: calc(10px + var(--safe-right));
  }

  #btn-telemetry-toggle {
    bottom: calc(10px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    height: 28px;
    padding: 0 8px;
    font-size: 8.5px;
  }

  body.touch-ui #btn-telemetry-toggle {
    bottom: calc(16px + var(--safe-bottom));
    left: calc(120px + var(--safe-left));
  }

  body.game-active #perilune-resource-meters {
    display: grid;
  }

  #perilune-resource-meters {
    bottom: calc(44px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    transform: none;
    width: auto;
    max-width: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px;
    padding: 5px 8px;
    backdrop-filter: none;
    z-index: 54;
  }

  body.touch-ui #perilune-resource-meters {
    bottom: calc(126px + var(--safe-bottom));
  }

  #space-center-ground-hud,
  #ship-interior-hud {
    top: auto !important;
    bottom: calc(44px + var(--safe-bottom)) !important;
    left: calc(8px + var(--safe-left)) !important;
    right: calc(8px + var(--safe-right)) !important;
    transform: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 680px !important;
    margin: 0 auto !important;
    max-height: calc(var(--app-height, 100dvh) - 240px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px;
    gap: 5px;
    border-radius: 8px;
    backdrop-filter: none;
    z-index: 90;
  }

  body.telemetry-collapsed:not(.touch-ui) #space-center-ground-hud,
  body.telemetry-collapsed:not(.touch-ui) #ship-interior-hud {
    bottom: calc(8px + var(--safe-bottom)) !important;
    left: calc(82px + var(--safe-left)) !important;
    right: calc(134px + var(--safe-right)) !important;
  }

  body:not(.telemetry-collapsed):not(.touch-ui) #space-center-ground-hud,
  body:not(.telemetry-collapsed):not(.touch-ui) #ship-interior-hud {
    bottom: calc(98px + var(--safe-bottom)) !important;
  }

  body.touch-ui #space-center-ground-hud,
  body.touch-ui #ship-interior-hud {
    bottom: calc(124px + var(--safe-bottom)) !important;
    max-height: calc(var(--app-height, 100dvh) - 310px);
  }

  body.touch-ui:not(.telemetry-collapsed) #space-center-ground-hud,
  body.touch-ui:not(.telemetry-collapsed) #ship-interior-hud {
    bottom: calc(184px + var(--safe-bottom)) !important;
    max-height: calc(var(--app-height, 100dvh) - 350px);
  }

  #space-center-ground-hud.is-collapsed {
    padding: 5px 8px;
    gap: 0;
  }

  .sc-hud-top {
    gap: 6px;
  }

  .sc-status-label {
    font-size: 9.5px;
  }

  .sc-hud-btn {
    padding: 4px 6px;
    font-size: 8.5px;
  }

  .sc-tour-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sc-tour-btn {
    padding: 5px 4px;
    font-size: 8.5px;
  }

  #action-toast {
    top: calc(114px + var(--safe-top));
    bottom: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    font-size: 10px;
    padding: 6px 12px;
  }

  #emote-toast {
    top: calc(154px + var(--safe-top));
    bottom: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
  }

  #docking-hud-overlay {
    padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
  }

  .dock-title-card {
    padding: 6px 10px;
  }

  .dock-title-main {
    font-size: 11px !important;
  }

  #dock-status-badge {
    padding: 5px 10px;
    font-size: 9.5px;
    text-align: center;
  }

  .dock-actions-wrap {
    gap: 5px;
    justify-content: flex-start;
  }

  .dock-actions-wrap button {
    padding: 6px 9px !important;
    font-size: 9px !important;
  }

  .dock-hint-line {
    display: none;
  }

  .dock-reticle {
    width: 140px;
    height: 140px;
  }

  .dock-telem-card {
    min-width: 84px;
    padding: 6px 10px;
  }

  #launch-cutscene-overlay {
    padding: calc(12px + var(--safe-top)) 12px calc(14px + var(--safe-bottom));
  }

  .launch-badge-card {
    padding: 6px 10px;
  }

  .launch-title-main {
    font-size: 12px !important;
  }

  #launch-capcom-banner {
    padding: 8px 14px;
    font-size: 11px;
  }

  #iss-showcase-topbar {
    top: calc(10px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    padding: 8px 10px;
  }

  #iss-showcase-left {
    top: auto;
    bottom: calc(8px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    width: calc(46vw - 12px);
    height: 34vh;
    max-height: 240px;
    border-radius: 10px;
  }

  #iss-showcase-right {
    top: auto;
    bottom: calc(8px + var(--safe-bottom));
    right: calc(8px + var(--safe-right));
    width: calc(54vw - 12px);
    height: 34vh;
    max-height: 240px;
    border-radius: 10px;
  }
}

/* Portrait Phone Breakpoint (<= 540px) */
@media (max-width: 540px) {
  #perf-overlay {
    top: calc(4px + var(--safe-top));
    left: auto;
    right: calc(8px + var(--safe-right));
    transform: none;
    padding: 3px 8px;
    gap: 6px;
  }

  #perf-overlay .perf-label,
  #perf-overlay .perf-divider,
  #perf-latency-badge {
    display: none;
  }

  #perf-overlay .perf-val {
    font-size: 9.5px;
  }

  #perf-overlay .perf-dot {
    width: 5px;
    height: 5px;
  }

  .hud-race-bar-container {
    top: calc(30px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: calc(100vw - 190px);
    max-width: none;
    padding: 4px 8px;
  }

  .hud-checklist-panel {
    top: calc(76px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: calc(100vw - 190px);
    max-width: none;
    max-height: min(176px, calc(var(--app-height, 100dvh) - 340px));
    overflow-y: auto;
    padding: 6px 8px;
  }

  .hud-task-list-body {
    max-height: 76px;
  }

  #hud-checklist-title {
    font-size: 9px;
  }

  #hud-room-code,
  #hud-active-speakers {
    display: none;
  }

  #hud-voice-panel {
    top: calc(30px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: 170px;
    max-width: none;
    padding: 4px;
  }

  .voice-header-row {
    gap: 2px;
  }

  .voice-header-row .voice-mic-btn,
  .voice-header-row .voice-settings-btn {
    min-height: 27px;
    font-size: 6.8px;
    padding: 2px;
  }

  #perilune-ship-minimap {
    top: calc(98px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: 126px;
    max-height: 132px;
    overflow: hidden;
  }

  #mobile-joystick-zone {
    bottom: calc(10px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    width: 94px;
    height: 104px;
  }

  #mobile-joystick-base {
    width: 84px;
    height: 84px;
  }

  #mobile-joystick-stick {
    width: 34px;
    height: 34px;
  }

  #btn-proximity-use {
    bottom: calc(10px + var(--safe-bottom));
    right: calc(8px + var(--safe-right));
    min-width: 112px;
    max-width: calc(100vw - 120px);
    height: 36px;
  }

  body.touch-ui #btn-proximity-use {
    bottom: calc(16px + var(--safe-bottom));
  }

  body.touch-ui #btn-telemetry-toggle {
    bottom: calc(16px + var(--safe-bottom));
    left: calc(108px + var(--safe-left));
  }

  #perilune-resource-meters {
    bottom: calc(44px + var(--safe-bottom));
    padding: 4px 6px;
    gap: 4px 6px;
  }

  body.touch-ui #perilune-resource-meters {
    bottom: calc(116px + var(--safe-bottom));
  }

  .perilune-res-head {
    font-size: 6.5px;
    letter-spacing: 0.3px;
  }

  body.telemetry-collapsed:not(.touch-ui) #space-center-ground-hud,
  body.telemetry-collapsed:not(.touch-ui) #ship-interior-hud {
    bottom: calc(48px + var(--safe-bottom)) !important;
    left: calc(8px + var(--safe-left)) !important;
    right: calc(8px + var(--safe-right)) !important;
    max-height: calc(var(--app-height, 100dvh) - 230px);
    padding: 6px 8px;
  }

  body.touch-ui #space-center-ground-hud,
  body.touch-ui #ship-interior-hud {
    bottom: calc(114px + var(--safe-bottom)) !important;
    max-height: calc(var(--app-height, 100dvh) - 290px);
    padding: 6px 8px;
  }

  body.touch-ui:not(.telemetry-collapsed) #space-center-ground-hud,
  body.touch-ui:not(.telemetry-collapsed) #ship-interior-hud {
    bottom: calc(170px + var(--safe-bottom)) !important;
    max-height: calc(var(--app-height, 100dvh) - 330px);
  }

  .lobby-mission-cards {
    flex-direction: column;
    overflow-x: visible;
  }

  .lobby-mission-cards > button {
    min-width: 0 !important;
    width: 100% !important;
    flex: none !important;
  }

  .mission-briefing-card {
    padding: 14px 12px;
  }

  .mission-briefing-title {
    font-size: 15px;
  }

  .dock-reticle {
    width: 112px;
    height: 112px;
  }

  .dock-rcs-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
}

/* Short Landscape Phones (max-height: 520px and max-width: 900px) */
@media (max-height: 520px) and (max-width: 900px) {
  #perf-overlay {
    top: calc(4px + var(--safe-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .hud-race-bar-container {
    top: calc(28px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: 196px;
    max-width: none;
    padding: 4px 8px;
  }

  .hud-checklist-panel {
    top: calc(74px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    width: 196px;
    max-width: none;
    max-height: calc(var(--app-height, 100dvh) - 180px);
    overflow-y: auto;
  }

  .hud-task-list-body {
    max-height: 62px;
  }

  .hud-crew-roster {
    padding: 4px 5px;
    gap: 3px;
  }

  .crew-duty-callout {
    padding: 3px 5px;
    font-size: 8px;
  }

  #hud-voice-panel {
    top: calc(28px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: 196px;
    padding: 4px;
  }

  #perilune-ship-minimap {
    top: calc(102px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: 132px;
    max-height: 112px;
    overflow: hidden;
  }

  #hud-active-speakers {
    top: calc(102px + var(--safe-top));
  }

  body.interior-active #hud-active-speakers {
    right: calc(148px + var(--safe-right));
  }

  #action-toast {
    top: calc(32px + var(--safe-top));
    bottom: auto;
    transform: translateX(-50%);
    max-width: clamp(200px, calc(100vw - 420px), 380px);
    font-size: 9.5px;
    padding: 5px 10px;
  }

  #emote-toast {
    top: calc(82px + var(--safe-top));
    bottom: auto;
    transform: translateX(-50%);
    max-width: clamp(180px, calc(100vw - 440px), 320px);
  }

  body.touch-ui #btn-telemetry-toggle,
  body.touch-ui #perilune-resource-meters {
    display: none !important;
  }

  #mobile-joystick-zone {
    bottom: calc(8px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    width: 88px;
    height: 88px;
  }

  #mobile-joystick-hint {
    display: none;
  }

  #mobile-joystick-base {
    width: 80px;
    height: 80px;
  }

  #mobile-joystick-stick {
    width: 32px;
    height: 32px;
  }

  #btn-proximity-use {
    bottom: calc(10px + var(--safe-bottom));
    right: calc(8px + var(--safe-right));
    min-width: 112px;
    max-width: 164px;
    height: 36px;
  }

  /* In short landscape, dock ground/station bars cleanly along bottom-center. */
  #space-center-ground-hud,
  #ship-interior-hud {
    top: auto !important;
    bottom: calc(8px + var(--safe-bottom)) !important;
    left: calc(80px + var(--safe-left)) !important;
    right: calc(134px + var(--safe-right)) !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    max-height: 112px !important;
    padding: 5px 8px !important;
    gap: 4px !important;
  }

  body.touch-ui #space-center-ground-hud,
  body.touch-ui #ship-interior-hud {
    left: calc(102px + var(--safe-left)) !important;
    right: calc(176px + var(--safe-right)) !important;
  }

  .sc-hud-btn {
    padding: 3px 6px;
    font-size: 8px;
  }

  .sc-tour-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .sc-tour-btn {
    padding: 3px 3px;
    font-size: 7.5px;
  }

  .dock-reticle {
    width: 92px;
    height: 92px;
  }

  .dock-telem-card {
    padding: 4px 8px;
    min-width: 72px;
  }

  #iss-showcase-left,
  #iss-showcase-right {
    height: calc(var(--app-height, 100dvh) - 104px);
    max-height: 220px;
    width: min(220px, 36vw);
  }
}

/* Fullscreen Mode Isolation: keep normal flight/ground HUDs strictly hidden
   during Docking, Launch Cutscene, and ISS 3D Showcase modes. */
body.docking-active .hud-race-bar-container,
body.docking-active #hud-checklist-panel,
body.docking-active #hud-crew-roster,
body.docking-active #hud-voice-panel,
body.docking-active #hud-active-speakers,
body.docking-active #btn-telemetry-toggle,
body.docking-active #perilune-resource-meters,
body.docking-active #space-center-ground-hud,
body.docking-active #ship-interior-hud,
body.docking-active #perilune-ship-minimap,
body.docking-active #btn-proximity-use,
body.docking-active #mobile-joystick-zone,
body.docking-active #virtual-dpad,
body.docking-active #emote-wheel,
body.docking-active #emote-toast,
body.docking-active #launch-countdown-banner,
body.docking-active #perf-overlay,
body.docking-active .hud-diagnostics-deck,
body.launch-active .hud-race-bar-container,
body.launch-active #hud-checklist-panel,
body.launch-active #hud-crew-roster,
body.launch-active #hud-voice-panel,
body.launch-active #hud-active-speakers,
body.launch-active #btn-telemetry-toggle,
body.launch-active #perilune-resource-meters,
body.launch-active #space-center-ground-hud,
body.launch-active #ship-interior-hud,
body.launch-active #perilune-ship-minimap,
body.launch-active #btn-proximity-use,
body.launch-active #mobile-joystick-zone,
body.launch-active #virtual-dpad,
body.launch-active #emote-wheel,
body.launch-active #emote-toast,
body.launch-active #launch-countdown-banner,
body.launch-active #perf-overlay,
body.launch-active .hud-diagnostics-deck,
body.iss-showcase-active .hud-race-bar-container,
body.iss-showcase-active #hud-checklist-panel,
body.iss-showcase-active #hud-crew-roster,
body.iss-showcase-active #hud-voice-panel,
body.iss-showcase-active #hud-active-speakers,
body.iss-showcase-active #btn-telemetry-toggle,
body.iss-showcase-active #perilune-resource-meters,
body.iss-showcase-active #space-center-ground-hud,
body.iss-showcase-active #ship-interior-hud,
body.iss-showcase-active #perilune-ship-minimap,
body.iss-showcase-active #btn-proximity-use,
body.iss-showcase-active #mobile-joystick-zone,
body.iss-showcase-active #virtual-dpad,
body.iss-showcase-active #emote-wheel,
body.iss-showcase-active #emote-toast,
body.iss-showcase-active #launch-countdown-banner,
body.iss-showcase-active #perf-overlay,
body.iss-showcase-active .hud-diagnostics-deck,
body.mission-viz-active .hud-race-bar-container,
body.mission-viz-active #hud-checklist-panel,
body.mission-viz-active #hud-crew-roster,
body.mission-viz-active #hud-voice-panel,
body.mission-viz-active #hud-active-speakers,
body.mission-viz-active #btn-telemetry-toggle,
body.mission-viz-active #perilune-resource-meters,
body.mission-viz-active #space-center-ground-hud,
body.mission-viz-active #ship-interior-hud,
body.mission-viz-active #perilune-ship-minimap,
body.mission-viz-active #btn-proximity-use,
body.mission-viz-active #mobile-joystick-zone,
body.mission-viz-active #virtual-dpad,
body.mission-viz-active #emote-wheel,
body.mission-viz-active #emote-toast,
body.mission-viz-active #launch-countdown-banner,
body.mission-viz-active #perf-overlay,
body.mission-viz-active .hud-diagnostics-deck,
body.vr-stereo-active .hud-race-bar-container,
body.vr-stereo-active #hud-checklist-panel,
body.vr-stereo-active #hud-crew-roster,
body.vr-stereo-active #hud-voice-panel,
body.vr-stereo-active #hud-active-speakers,
body.vr-stereo-active #btn-telemetry-toggle,
body.vr-stereo-active #perilune-resource-meters,
body.vr-stereo-active #space-center-ground-hud,
body.vr-stereo-active #ship-interior-hud,
body.vr-stereo-active #perilune-ship-minimap,
body.vr-stereo-active #btn-proximity-use,
body.vr-stereo-active #mobile-joystick-zone,
body.vr-stereo-active #virtual-dpad,
body.vr-stereo-active #emote-wheel,
body.vr-stereo-active #emote-toast,
body.vr-stereo-active #launch-countdown-banner,
body.vr-stereo-active #perf-overlay,
body.vr-stereo-active #iss-showcase-ui,
body.vr-stereo-active #mission-viz-ui,
body.vr-stereo-active .hud-diagnostics-deck {
  display: none !important;
}
