/* A map needs a definite viewport. Generic mobile document-style panels use
 * auto height, which collapses or overflows this canvas/flex layout. Scope the
 * correction to the Atlas, retain desktop layout, and keep Close reachable. */
html:root.view-mobile #expedition-window[data-expedition-tab="map"] {
 left:calc(var(--touch-vv-left,0px) + var(--touch-safe-left,0px) + 4px)!important;
 top:calc(var(--touch-vv-top,0px) + var(--touch-safe-top,0px) + 4px)!important;
 width:calc(var(--touch-vv-width,100vw) - var(--touch-safe-left,0px) - var(--touch-safe-right,0px) - 8px)!important;
 max-width:none!important;height:calc(var(--touch-vv-height,100dvh) - var(--touch-safe-top,0px) - var(--touch-safe-bottom,0px) - 8px)!important;
 max-height:calc(var(--touch-vv-height,100dvh) - var(--touch-safe-top,0px) - var(--touch-safe-bottom,0px) - 8px)!important;
 min-height:0!important;transform:none!important;overflow:hidden!important;box-sizing:border-box;
}
html:root.view-mobile #expedition-window[data-expedition-tab="map"]:not([hidden]) {display:flex!important;flex-direction:column;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"]>header {position:relative;flex:0 0 44px;min-height:44px;padding:0 6px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"]>header small {display:none;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"]>nav {flex:0 0 auto;min-height:40px;margin:0;padding:0 4px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"]>footer {display:none;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #expedition-body {flex:1 1 0;height:0;min-height:0;max-height:none;overflow:hidden!important;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .map-layout.atlas-190 {position:relative;display:grid;height:100%;min-height:0;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:minmax(0,1fr);overflow:hidden;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas {min-width:0;min-height:0;padding:5px;display:flex;flex-direction:column;overflow:hidden;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-tools {flex:0 0 auto;flex-wrap:nowrap;min-width:0;max-width:100%;margin:0 0 4px;gap:4px;overflow-x:auto;overflow-y:hidden;overscroll-behavior:contain;touch-action:pan-x;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-tools :is(button,select) {flex:0 0 auto;min-height:40px!important;height:40px;max-width:120px;padding:4px 7px;font-size:11px;white-space:nowrap;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-mobile-only {display:block;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-viewport {flex:1 1 0;min-height:72px;height:0;min-width:0;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] canvas#world-map {width:100%;height:100%;max-height:none;display:block;aspect-ratio:auto;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-zoom-buttons {right:5px;top:5px;gap:4px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-zoom-buttons button {width:44px;height:44px;min-height:44px!important;font-size:22px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-scale {left:5px;bottom:5px;font-size:10px;padding:3px 5px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-estate-legend {gap:1px 8px;padding-top:3px;font-size:9px;line-height:13px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-status {flex:0 0 auto;min-height:28px;padding:0;justify-content:flex-end;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #atlas-coordinates {display:none;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-status label {display:flex;align-items:center;gap:6px;font-size:10px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-status input {width:120px;height:28px;min-height:28px!important;padding:0!important;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-waypoint-details {min-height:22px;max-height:32px;margin:0;padding:3px 5px;font-size:10px;line-height:13px;box-sizing:border-box;}
/* Search is a separate, dismissible view on phones instead of taking half of
 * an already short canvas. Results, filters and waypoint actions still work. */
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-sidebar {display:none;position:absolute;inset:0;z-index:3;min-width:0;min-height:0;padding:6px;gap:4px;border:0;box-sizing:border-box;overflow:hidden;background:#102430;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-190[data-search-open="true"] .atlas-sidebar {display:flex;flex-direction:column;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-sidebar :is(h2,.atlas-search-label,.atlas-route-actions>small) {display:none;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #atlas-search-close {flex:0 0 40px;width:auto;align-self:flex-start;margin:0;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #atlas-search {flex:0 0 44px;height:44px;min-height:44px;padding:5px 7px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-filters {flex:0 0 auto;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-filters select {min-width:0;min-height:40px;font-size:16px!important;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #atlas-results {flex:1 1 0;min-height:0;overflow:auto;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] #atlas-results button {min-height:56px!important;font-size:12px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-route-actions {display:flex;flex-wrap:wrap;flex:0 0 auto;gap:4px;padding-top:3px;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-route-actions button {flex:1;min-height:40px!important;}
html:root.view-mobile #expedition-window[data-expedition-tab="map"] .atlas-route-actions label {width:100%;}

/* The ground radar remains compact and visible in both phone orientations.
 * Space/cabin, keyboard, hidden HUD and explicit hidden states still win. */
html:root.view-mobile:not(.touch-keyboard-open) body:not(.in-space):not(.in-cabin) #hud #hud-right-rail .map-panel:not([hidden]) {display:block!important;order:-1;width:72px!important;padding:3px!important;}
html:root.view-mobile.touch-landscape:not(.touch-keyboard-open) body:not(.in-space):not(.in-cabin) #hud #hud-right-rail .map-panel:not([hidden]) {width:72px!important;}
html:root.view-mobile.touch-landscape #hud #hud-right-rail .map-panel .map-foot {display:none;}
html:root.view-mobile.touch-landscape:not(.touch-keyboard-open) #hud-right-rail {max-height:max(78px,calc(var(--mobile-rail-end) - var(--mobile-rail-top)));}
