/* ==========================================================================
   ZOTH CIVILIZATION v5.2 — SOVEREIGN MOBILE & DESKTOP ARCHITECTURE
   - Unlocks vertical scrolling across ALL 10 views (fixes trapped height:100%
     containers in Adytum, Cockpit Graph, Conclave, and Mission Control).
   - Fixes Desktop .world-top zero-overflow layout with scrollable middle colony
     track + pinned left controls & pinned right View popover even with 9+ colonies.
   - Fixes Cockpit Graph canvas sizing on Desktop & stacked sidebar on Mobile.
   - Eliminates gameplay overlay chaos: single native 46px Walk D-Pad, unmistakable
     🌍 Orbit exit pill, auto-hiding planet switcher, non-blocking top-slotted toasts.
   ========================================================================== */

:root {
  --z4-bg: #05050A;
  --z4-surface: rgba(11, 10, 20, 0.94);
  --z4-gold: #E9C46A;
  --z4-gold-hot: #FFD97A;
  --z4-gold-line: rgba(233, 196, 106, 0.28);
  --z4-emerald: #10B981;
  --z4-cyan: #38BDF8;
  --z4-text: #F4F1FA;
  --z4-muted: #94A3B8;
  --z4-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z4-mobile-nav-h: 64px;
}

/* ==========================================================================
   1. GLOBAL FLEX SHELL & CHROME DECLUTTER
   ========================================================================== */

.cross-banner-elements,
#funnelHeroBanner,
#zothAiGuestBanner,
.z-decree {
  display: none !important;
}

html {
  background: var(--z4-bg) !important;
  overflow-x: hidden !important;
}

body {
  background: var(--z4-bg) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  width: 100% !important;
  max-width: 100vw !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  overscroll-behavior: none;
}

.header-bar {
  flex: 0 0 auto !important;
  width: 100% !important;
  max-width: 100vw !important;
  background: rgba(7, 6, 14, 0.96) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
  border-bottom: 1px solid var(--z4-gold-line) !important;
  position: relative !important;
  z-index: 80 !important;
  padding: 0 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
}

main.main-viewport {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  position: relative !important;
  overflow: hidden !important;
}

#view-pixel-world.view-section.active {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

#view-pixel-world .pixel-world-container {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  overflow: hidden !important;
  border-radius: 0 !important;
}

/* ==========================================================================
   2. UNIVERSAL SCROLLABILITY & LAYOUT FIX FOR ALL 9 CONTENT VIEWS
   Unlocks Adytum, Cockpit Graph, Conclave, Mission Control on ALL screens!
   ========================================================================== */

.view-section:not(#view-pixel-world).active {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
}

/* Unlock trapped inner height:100% / overflow:auto containers */
.adytum-container,
.cockpit-container,
.mission-container,
.mission-container.conclave-layout,
.library-wrap {
  height: auto !important;
  min-height: 100% !important;
  overflow: visible !important;
  box-sizing: border-box !important;
  max-width: 1480px !important;
  margin: 0 auto !important;
}

/* Cockpit Graph: guaranteed non-zero canvas box on Desktop & clean stack on Mobile */
.cockpit-container {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start !important;
  gap: 18px !important;
  padding: 18px !important;
}

.cockpit-container .graph-canvas-box {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  height: 540px !important;
  min-height: 480px !important;
  position: relative !important;
}

.cockpit-container .graph-canvas-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

.cockpit-container .cockpit-sidebar {
  flex: 0 0 380px !important;
  width: 380px !important;
  max-width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

/* Adytum 3D Sanctum & Details Panel: keep 100% contained with 0px horizontal overflow */
#adytum3DGameDeck,
.adytum-game-deck,
.adytum-details-panel {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

.adytum-details-panel .glass-card {
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.adytum-key-carousel,
.journey-strip,
.adytum-journey-bar {
  max-width: 100% !important;
  overflow-x: auto !important;
  scrollbar-width: thin !important;
  padding-bottom: 6px !important;
}

.person-chip-row,
.person-chip {
  max-width: 100% !important;
  flex-wrap: wrap !important;
  box-sizing: border-box !important;
}

/* Living Minds: contain horizontal sovereign avatar strip cleanly */
.lm-rail,
.lm-list,
.lm-roster,
#lmRosterList {
  max-width: 100% !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
}

@media (max-width: 980px) {
  .cockpit-container {
    flex-direction: column !important;
    padding: 12px !important;
    gap: 14px !important;
  }
  .cockpit-container .graph-canvas-box {
    width: 100% !important;
    flex: none !important;
    height: 365px !important;
    min-height: 340px !important;
  }
  .cockpit-container .cockpit-sidebar {
    width: 100% !important;
    flex: none !important;
  }
  .cockpit-sidebar .telemetry-gauge .gauge-val {
    font-size: clamp(14px, 4.1vw, 20px) !important;
    line-height: 1.25 !important;
    word-break: break-word !important;
  }
  .adytum-stage-grid,
  .adytum-diorama-grid,
  .adytum-main-grid {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .adytum-stage-canvas-wrap,
  .adytum-viewport-box {
    min-height: 280px !important;
    height: 300px !important;
  }
  .adytum-viewport-hud-top {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
  }
  .adytum-viewport-hud-top .adytum-hud-pill {
    font-size: 10px !important;
    padding: 4px 9px !important;
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }
  .adytum-focus-orb-btn {
    min-height: 44px !important;
    padding: 9px 11px !important;
    gap: 10px !important;
    align-items: center !important;
    text-align: left !important;
  }
  .adytum-focus-orb-btn > span:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: left !important;
    word-spacing: normal !important;
    line-height: 1.35 !important;
  }
  .adytum-focus-orb-btn > span:last-child {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 11px !important;
  }
}

/* Collapsible Skill Shelf helper in Wishlist so mobile isn't a 44,000px wall */
.z5-shelf-toggle {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(233, 196, 106, 0.12);
  border: 1px solid rgba(233, 196, 106, 0.42);
  color: var(--z4-gold-hot);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.z5-collapsed-list {
  display: none !important;
}

/* ==========================================================================
   3. DESKTOP HEADER & NAV (>= 901px)
   ========================================================================== */

.header-row {
  padding: 7px 16px !important;
  min-height: 46px !important;
  gap: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  overflow: hidden !important;
  max-width: 100% !important;
}

.header-row .brand-section { gap: 8px !important; min-width: 0 !important; }
.header-row .brand-icon { font-size: 17px !important; filter: drop-shadow(0 0 8px rgba(233, 196, 106, 0.55)); }
.header-row .brand-title { font-family: 'Plus Jakarta Sans', sans-serif !important; font-size: 14px !important; font-weight: 800 !important; letter-spacing: 0.08em !important; color: #FFF !important; }
.header-row .brand-badge {
  background: rgba(233, 196, 106, 0.12) !important;
  border: 1px solid rgba(233, 196, 106, 0.42) !important;
  color: var(--z4-gold-hot) !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 9.5px !important;
  font-weight: 700 !important;
  padding: 3px 8px !important;
  border-radius: 999px !important;
  letter-spacing: 0.06em !important;
}

.header-row .sovereign-header-ticker {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 11px !important;
  color: #CBD5E1 !important;
  gap: 7px !important;
}
.header-row .sovereign-header-ticker .ticker-money { color: var(--z4-gold-hot) !important; font-weight: 700 !important; }

/* Move noisy secondary header buttons into the 1-click Command Deck */
.header-stats #headerLeaderBadge,
.header-stats #headerAgyBadge,
.header-stats #headerAdytumBadge,
.header-stats #btnDispatchAgy,
.header-stats .clock-pill,
.header-stats #btnTriggerElection,
.header-stats #btnStepAdytum,
.header-stats #btnWatchMotionEdit,
.header-stats #btnOpenWorldPortalModal,
.header-stats button[title*="Copy Solana"] {
  display: none !important;
}

.header-stats {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin-left: auto !important;
  flex-shrink: 0 !important;
}

.header-stats .btn-ctrl,
#zothHeaderAiStatusBtn,
#btnZothCommandDrawer {
  min-height: 32px !important;
  padding: 0 11px !important;
  border-radius: 9px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  white-space: nowrap !important;
  cursor: pointer;
}

#btnZothCommandDrawer {
  background: linear-gradient(135deg, rgba(233, 196, 106, 0.18), rgba(168, 85, 247, 0.14)) !important;
  border: 1px solid rgba(233, 196, 106, 0.48) !important;
  color: var(--z4-gold-hot) !important;
}

.nav-tabs {
  padding: 4px 14px !important;
  gap: 3px !important;
  background: rgba(6, 5, 12, 0.94) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  min-height: 29px !important;
  padding: 4px 9px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  color: #CBD5E1 !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  gap: 5px !important;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(233, 196, 106, 0.2), rgba(168, 85, 247, 0.12)) !important;
  border-color: rgba(233, 196, 106, 0.5) !important;
  color: #FFFFFF !important;
}

/* ==========================================================================
   4. STREAMLINED DESKTOP 3D WORLD HUD (REDUCED FROM 38 TO 14 CONTROLS!)
   Zero duplicate buttons, zero right-edge overflow at 1440px!
   ========================================================================== */

.world-top {
  padding: 5px 14px !important;
  background: linear-gradient(180deg, rgba(7, 6, 14, 0.88) 0%, rgba(7, 6, 14, 0.56) 100%) !important;
  border-bottom: 1px solid rgba(233, 196, 106, 0.18) !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

.world-top .globe-toolbar {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.world-top .globe-btn {
  min-height: 28px !important;
  padding: 3px 10px !important;
  font-size: 11px !important;
  border-radius: 7px !important;
  background: rgba(15, 14, 28, 0.82) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.world-top .globe-btn.active {
  background: rgba(233, 196, 106, 0.18) !important;
  border-color: rgba(233, 196, 106, 0.55) !important;
}

/* Move secondary world toggles out of desktop bar into our sleek View Settings
   popover (#btnDesktopWorldSettings) so 100% of colonies + controls fit cleanly! */
@media (min-width: 901px) {
  .world-top #btnToggle3DMode,
  .world-top #btnAutoSpin,
  .world-top #btnDayNight,
  .world-top #btnToggleAudio,
  .world-top #btnOpenGameIntro,
  .world-top #btnToggleTurbo60,
  .world-top #btnCamFollowImperator,
  .world-top #btnResetGlobeCam,
  .world-top #altitudeTelemetry,
  .world-top #worldCensusBadge,
  .world-top .walk-compass,
  .world-top [id*="fps" i],
  .world-top [class*="fps" i],
  .world-top .globe-toolbar-label {
    display: none !important;
  }

  .world-top .globe-toolbar > .globe-toolbar-group:first-child {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }

  /* Middle colony track scrolls cleanly inside itself even with 9+ founded colonies */
  .world-top .globe-toolbar > .globe-toolbar-group:nth-child(2) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%) !important;
    mask-image: linear-gradient(to right, #000 92%, transparent 100%) !important;
    padding-right: 20px !important;
  }
  .world-top .globe-toolbar > .globe-toolbar-group:nth-child(2)::-webkit-scrollbar {
    display: none;
  }

  /* Right utility cluster (Max 3D) stays pinned without pushing View off-screen */
  .world-top .globe-toolbar > .globe-toolbar-group:nth-child(3) {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin-left: 0 !important;
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }

  .world-top .globe-btn {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }

  #btnDesktopWorldSettings {
    margin-left: 0 !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    border-color: rgba(233, 196, 106, 0.45) !important;
    color: var(--z4-gold-hot) !important;
  }

  /* Streamline Bottom 3D Dock: remove exact duplicates of Top Bar / Command Deck */
  #pixelHudDeck.zoth-bottom-hud-bar #hudWalkQuick,
  #pixelHudDeck.zoth-bottom-hud-bar #hudToggleToolbar,
  #pixelHudDeck.zoth-bottom-hud-bar #hudOpenWorldPortal,
  #pixelHudDeck.zoth-bottom-hud-bar #hudShowDiagnostics,
  #pixelHudDeck.zoth-bottom-hud-bar #hudShowCommands,
  #pixelHudDeck.zoth-bottom-hud-bar .hud-pill-label {
    display: none !important;
  }

  #pixelHudDeck.zoth-bottom-hud-bar {
    gap: 8px !important;
    padding: 4px 14px !important;
  }

  #pixelHudDeck.zoth-bottom-hud-bar .hud-pill-btn {
    padding: 0 10px !important;
    font-size: 11px !important;
  }

  /* Hide duplicate 21 Agents & Dossier buttons in Helios bar (live in Command Deck) */
  #zothStarSystemBar #btnZothCharactersDeck,
  #zothStarSystemBar .zss-dossier-btn {
    display: none !important;
  }
}

/* Desktop View Settings Popover */
#zothDesktopViewPopover {
  display: none;
  position: absolute;
  top: 46px;
  right: 14px;
  width: 280px;
  z-index: 70;
  background: rgba(10, 10, 22, 0.97);
  backdrop-filter: blur(18px);
  border: 1px solid var(--z4-gold-line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.78);
}
#zothDesktopViewPopover.is-open { display: block; }

/* Anchor Helios-Zoth 6-Worlds Bar cleanly above the unclipped Bottom HUD */
#zothStarSystemBar {
  position: absolute !important;
  bottom: 48px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  max-width: calc(100% - 24px) !important;
  z-index: 52 !important;
  background: rgba(8, 8, 18, 0.86) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(233, 196, 106, 0.3) !important;
  border-radius: 999px !important;
  padding: 4px 8px !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65) !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
  flex-wrap: nowrap !important;
}
#zothStarSystemBar::-webkit-scrollbar { display: none; }

#zothSiteFooter {
  flex: 0 0 auto !important;
  background: rgba(6, 6, 12, 0.98) !important;
  border-top: 1px solid rgba(233, 196, 106, 0.18) !important;
  padding: 6px 16px !important;
  font-size: 11px !important;
  z-index: 40 !important;
}

/* ==========================================================================
   5. GAMEPLAY TOAST & HERALD HYGIENE (NEVER COVER CONTROLS OR DRAWERS!)
   ========================================================================== */

#hudToast {
  top: 102px !important;
  bottom: auto !important;
  font-size: 11.5px !important;
  padding: 6px 12px !important;
}

/* ==========================================================================
   6. UNIFIED COMMAND DRAWER / MOBILE BOTTOM SHEET
   ========================================================================== */

#zothCommandBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 10, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--z4-ease);
}
#zothCommandBackdrop.is-open { opacity: 1; pointer-events: auto; }

#zothCommandSheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 92vw);
  background: linear-gradient(175deg, rgba(16, 14, 30, 0.98) 0%, rgba(8, 8, 16, 0.99) 100%);
  border-left: 1px solid var(--z4-gold-line);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.8);
  z-index: 1210;
  display: flex;
  flex-direction: column;
  transform: translateX(104%);
  transition: transform 0.28s var(--z4-ease);
  color: var(--z4-text);
  font-family: 'Plus Jakarta Sans', sans-serif;
}
#zothCommandSheet.is-open { transform: translateX(0); }

.zcs-handle { display: none; }
.zcs-head { padding: 15px 18px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.zcs-title { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--z4-gold-hot); display: flex; align-items: center; gap: 8px; }
.zcs-close { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); color: #E2E8F0; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.zcs-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 28px; display: flex; flex-direction: column; gap: 16px; }
.zcs-section-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--z4-muted); margin: 0 0 8px; }
.zcs-status-strip, .zcs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.zcs-stat { background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; padding: 10px 12px; }
.zcs-stat-k { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--z4-muted); margin-bottom: 3px; }
.zcs-stat-v { font-size: 12.5px; font-weight: 700; color: var(--z4-gold-hot); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zcs-action-btn { min-height: 44px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.1); color: #F4F1FA; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none; text-align: left; }
.zcs-action-btn:hover, .zcs-action-btn:active { background: rgba(233, 196, 106, 0.14); border-color: rgba(233, 196, 106, 0.48); }
.zcs-action-btn.is-gold { background: linear-gradient(135deg, #E9C46A, #D4AF37); border-color: #FFD97A; color: #07070D; font-weight: 800; }
.zcs-action-btn.is-emerald { background: rgba(16, 185, 129, 0.16); border-color: rgba(16, 185, 129, 0.45); color: #6EE7B7; }
.zcs-action-btn.is-cyan { background: rgba(56, 189, 248, 0.14); border-color: rgba(56, 189, 248, 0.42); color: #7DD3FC; }
.zcs-action-btn.is-active { background: rgba(233, 196, 106, 0.18); border-color: rgba(233, 196, 106, 0.58); color: #FFF; }
.zcs-elements-row { display: flex; flex-wrap: wrap; gap: 6px; }
.zcs-elem-chip { font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); color: #CBD5E1; }

/* Hidden on Desktop */
#zothMobileBottomNav,
#zothMobileWorldBar,
#zothMobilePopover {
  display: none;
}

/* ==========================================================================
   7. MOBILE & TABLET NATIVE-APP EXPERIENCE (<= 900px)
   ========================================================================== */

@media (max-width: 900px) {
  .header-row {
    padding: 6px 12px !important;
    min-height: 52px !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .header-row .brand-title { font-size: 13.5px !important; letter-spacing: 0.05em !important; }
  .header-row .brand-badge { font-size: 9px !important; padding: 2px 6px !important; }

  .header-row .sovereign-header-ticker,
  .header-stats #btnPause,
  .header-stats #btnSpeed,
  .header-stats #headerProContainer,
  .header-stats button[onclick*="openSovereignGeneratorModal"],
  .nav-tabs,
  #zothSiteFooter,
  .world-top,
  #pixelHudDeck.zoth-bottom-hud-bar,
  #zothDesktopViewPopover,
  #hudToast {
    display: none !important;
  }

  .header-stats { gap: 6px !important; }

  #zothHeaderAiStatusBtn {
    min-height: 36px !important;
    padding: 0 10px !important;
    border-radius: 10px !important;
    font-size: 0 !important;
    gap: 0 !important;
  }
  #zothHeaderAiStatusBtn::after {
    content: "🔑 AI";
    font-size: 11.5px;
    font-weight: 800;
    color: #7DD3FC;
    letter-spacing: 0.03em;
  }

  #btnZothCommandDrawer {
    min-height: 36px !important;
    padding: 0 11px !important;
    font-size: 12px !important;
    border-radius: 10px !important;
  }

  /* Tame Toasts & Herald Banners on Mobile so they NEVER block controls or drawers! */
  .z-toasts {
    top: 110px !important;
    bottom: auto !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    z-index: 58 !important;
  }
  .z-toasts .z-toast {
    padding: 7px 11px !important;
    font-size: 11.5px !important;
    border-radius: 10px !important;
  }
  /* Cap to 1 crisp toast at a time on mobile, and hide globe migration toasts while reading secondary views */
  .z-toasts .z-toast:not(:first-child) {
    display: none !important;
  }
  body:not(.z4-on-world) .z-toasts {
    display: none !important;
  }

  .z-herald {
    top: 110px !important;
    min-width: 0 !important;
    width: calc(100vw - 28px) !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    z-index: 59 !important;
  }
  .z-herald-title { font-size: 17px !important; margin-top: 4px !important; }
  .z-herald-sub { font-size: 11.5px !important; margin-top: 3px !important; }
  .z-herald-rule { margin-top: 8px !important; }

  /* Floating Mobile World Controls Pill Bar */
  #zothMobileWorldBar {
    display: flex !important;
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 62;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    pointer-events: none;
  }

  .zmw-group { display: inline-flex; align-items: center; gap: 6px; pointer-events: auto; }
  .zmw-pill {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(8, 8, 18, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(233, 196, 106, 0.34);
    color: #F4F1FA;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    white-space: nowrap;
  }
  .zmw-pill.is-active { background: rgba(233, 196, 106, 0.24); border-color: var(--z4-gold-hot); color: #FFF; }
  .zmw-pill.is-emerald.is-active { background: rgba(16, 185, 129, 0.24); border-color: #34D399; color: #A7F3D0; }

  #zothMobilePopover {
    display: none;
    position: absolute;
    top: 58px;
    left: 10px;
    right: 10px;
    z-index: 70;
    background: rgba(10, 10, 22, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--z4-gold-line);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.82);
  }
  #zothMobilePopover.is-open { display: block !important; }

  .zmp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .zmp-btn {
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F4F1FA;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }

  /* Helios-Zoth 6-Worlds Bar: auto-hides whenever Walk mode OR any drawer is open! */
  #zothStarSystemBar {
    position: absolute !important;
    bottom: 12px !important;
    left: 10px !important;
    right: 10px !important;
    transform: none !important;
    max-width: none !important;
    width: auto !important;
    padding: 5px 8px !important;
    gap: 6px !important;
    border-radius: 14px !important;
    z-index: 56 !important;
  }

  body.z4-walk-mode #zothStarSystemBar,
  body.z4-drawer-open #zothStarSystemBar {
    display: none !important;
  }

  #zothStarSystemBar .zss-planet-pill,
  #zothStarSystemBar .zss-action-btn,
  #zothStarSystemBar .zss-brand-tag {
    min-height: 36px !important;
    padding: 4px 10px !important;
    font-size: 11.5px !important;
    flex-shrink: 0 !important;
  }

  /* Single Native Touch Walk Pad (#zothTouchWalkPad from civ_gameplay_engine.js)
     cleanly positioned above the 64px Bottom Nav — crisp 46px targets & touch-action! */
  #zothTouchWalkPad {
    bottom: 78px !important;
    left: 12px !important;
    right: 12px !important;
    z-index: 64 !important;
  }
  #zothTouchWalkPad > div:first-child {
    grid-template-columns: repeat(3, 46px) !important;
    grid-template-rows: repeat(2, 46px) !important;
    gap: 7px !important;
  }
  #zothTouchWalkPad button {
    min-width: 46px !important;
    min-height: 46px !important;
    touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.58) !important;
    transition: transform 0.1s ease, background-color 0.14s ease !important;
  }
  #zothTouchWalkPad [data-walkkey] {
    width: 46px !important;
    height: 46px !important;
    border-radius: 12px !important;
    background: rgba(8, 12, 24, 0.92) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.62) !important;
    font-size: 15px !important;
  }
  #zothTouchWalkPad button:active {
    transform: scale(0.93) !important;
  }
  #zothTouchWalkPad #btnTouchInteract,
  #zothTouchWalkPad #btnTouchJump {
    height: 46px !important;
    padding: 0 15px !important;
    border-radius: 12px !important;
    background: rgba(8, 12, 24, 0.92) !important;
    font-size: 13px !important;
  }

  /* Make 🌍 Orbit exit pill unmistakable while walking on surface */
  body.z4-walk-mode #zmwOrbitBtn {
    background: rgba(14, 12, 26, 0.94) !important;
    border-color: rgba(233, 196, 106, 0.82) !important;
    color: var(--z4-gold-hot) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(233, 196, 106, 0.25) !important;
  }

  /* Living Minds mobile roster readability */
  .lm {
    padding: 16px 14px 48px !important;
  }
  .lm-item {
    width: 92px !important;
  }
  .lm-item-name {
    font-size: 14px !important;
    max-width: 86px !important;
  }

  /* Hide desktop keyboard "Press F" proximity banner on mobile (Talk button is on thumb pad!) */
  #avatarProximityPrompt {
    display: none !important;
  }

  /* Clean Bottom Seating for All World Drawers on Mobile (since planet bar auto-hides!) */
  .floating-dialogue-feed,
  .world-encounter,
  .civic-panel,
  .avatar-dialogue-box,
  .quick-dock,
  .z-realm,
  body .huddle-dock {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: none !important;
    top: auto !important;
    bottom: 10px !important;
    max-height: 54vh !important;
    border-radius: 16px !important;
    z-index: 66 !important;
  }

  /* Imperator Quest & Decree Drawer on Mobile */
  #zothQuestDrawer {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    top: 62px !important;
    max-height: calc(100dvh - 144px) !important;
    z-index: 90 !important;
  }

  /* FLEX-DOCKED Native 5-Tab Bottom Navigation Bar */
  #zothMobileBottomNav {
    display: grid !important;
    flex: 0 0 auto !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    height: calc(var(--z4-mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px env(safe-area-inset-bottom, 0px);
    background: rgba(8, 8, 16, 0.98);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-top: 1px solid var(--z4-gold-line);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.65);
    position: relative;
    z-index: 1100;
  }

  .zmb-tab {
    background: transparent;
    border: none;
    color: #94A3B8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    font-family: 'Plus Jakarta Sans', sans-serif;
  }
  .zmb-tab .zmb-ico { font-size: 18px; line-height: 1; }
  .zmb-tab .zmb-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
  .zmb-tab.is-active { color: var(--z4-gold-hot); background: rgba(233, 196, 106, 0.12); }
  .zmb-tab.is-active::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 2px; border-radius: 999px; background: var(--z4-gold-hot); }

  /* Mobile Bottom Sheet Command Deck */
  #zothCommandSheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 84dvh;
    border-left: none;
    border-top: 1px solid var(--z4-gold-line);
    border-radius: 22px 22px 0 0;
    transform: translateY(104%);
  }
  #zothCommandSheet.is-open { transform: translateY(0); }
  .zcs-handle { display: block; width: 40px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.24); margin: 10px auto 0; }

  /* Secondary Views Responsive Padding & Grids */
  .view-section:not(#view-pixel-world) {
    padding: 12px 12px 28px !important;
  }
  .adytum-container,
  .mission-container,
  .library-wrap {
    flex-direction: column !important;
    padding: 4px 0 24px !important;
    gap: 14px !important;
  }
  .card-showcase-panel { width: 100% !important; max-width: 100% !important; position: static !important; }
  .view-section:not(#view-pixel-world) .glass-card { padding: 16px !important; border-radius: 14px !important; }

  .lm-layout, .lm-grid, .conclave-grid, .treasury-grid, .lineage-grid,
  .wishlist-grid, .shelf-grid, .halls-grid, .buildings-grid, .colony-grid, .pay-grid {
    grid-template-columns: 1fr !important;
  }

  #zothGameIntroOverlay { padding: 10px !important; }
  .zg-intro-container { max-height: 92dvh !important; border-radius: 18px !important; }
  .zg-intro-header { padding: 12px 14px !important; }
  .zg-intro-body { padding: 16px !important; }
  .zg-hero-title { font-size: 21px !important; }
}

@media (max-width: 420px) {
  .header-row .brand-badge { display: none !important; }
  .zmw-pill { padding: 0 10px; font-size: 11.5px; }
}
