/* MEYDORA V16.3 — responsive touch HUD, navigation map and menu.
   These overrides load AFTER legacy HUD/story styles. Desktop remains unchanged. */
:root{--mobile-ink:#0a202f;--mobile-border:#8acbc991;--mobile-text:#f1fcff;--mobile-accent:#64e4c6}
#mobileUI{display:none}
#mobileMapQuick:focus-visible,#mobileCameraQuick:focus-visible,#mobileMore:focus-visible,
#mobileStick:focus-visible,#mobilePedals button:focus-visible,#touchActions button:focus-visible,
#hudMenu [role="tab"]:focus-visible,#districtSearch:focus-visible{outline:3px solid #e8cc7f;outline-offset:2px}
#mapSelection{max-width:100%;font-size:11px;line-height:1.6;overflow-wrap:anywhere}
#worldMapOverlay{overscroll-behavior:contain}
#worldMapPanel{box-sizing:border-box}
#worldMapPanel .mapTop{display:flex;align-items:center;justify-content:space-between;gap:12px;direction:rtl;padding:2px 6px}
#worldMapPanel .mapTop h2{font-size:clamp(17px,2.8vw,22px);margin:3px 0}
#worldMapPanel .mapHelp{font-size:11px;color:#c0e2e6;line-height:1.75;margin:7px 0}
#districtSearch{width:100%;box-sizing:border-box;border:1px solid #537e8c;background:#0d2535;color:#f8fcff;border-radius:10px;padding:11px;font:12px Vazirmatn,Tahoma,sans-serif;direction:rtl;margin:4px 0 9px}
#districtSearch::placeholder{color:#9ab9c5}
#districtList .district-item{cursor:pointer;min-height:36px;box-sizing:border-box;display:flex;align-items:center}
#districtList .district-item:focus-visible{outline:2px solid #8debd0}
#districtList .district-item:hover{background:#204b55}
#mapDestination{min-width:128px;max-width:220px;min-height:36px;background:#123b49;color:#effffa;border:1px solid #618e91;border-radius:9px;padding:6px 8px;font:12px Vazirmatn,Tahoma,sans-serif}
#mapTools button{min-height:38px}
#mapTools button:disabled{opacity:.5}
#worldMap{background:#d5cfba;touch-action:none;user-select:none;-webkit-user-select:none}
#hudMenu .menuShell{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:#527988 #0d2332}
#hudMenu .menuTop{position:sticky;top:-14px;z-index:2;background:#0b1b2c;padding:7px 0 11px;margin-bottom:10px}
#hudMenu .menuTop small{display:block;font-size:10px;color:#81c9c4;font-weight:500;margin-top:5px}
#hudMenu .menuTabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;position:sticky;top:51px;background:#0b1b2c;padding:8px 0 10px;z-index:2}
#hudMenu .menuTabs button{background:#153347;border:1px solid #395c6d;color:#c2d9e0;border-radius:10px;padding:11px 6px;font:700 12px Vazirmatn,Tahoma,sans-serif;min-height:44px}
#hudMenu .menuTabs button[aria-selected="true"]{background:#185244;border-color:#65d5b6;color:#f5fffa}
#hudMenu .menuPane[hidden]{display:none!important}
#hudMenu .menuPane{padding:8px 0 18px}
#hudMenu .menuPane p{line-height:1.9;color:#aacdd1;font-size:11px}
#hudMenu .menuButtons{grid-template-columns:repeat(2,minmax(0,1fr))}
#hudMenu .menuQuickActions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:14px}
#hudMenu .menuQuickActions button{padding:12px 7px;min-height:48px;border:1px solid #4d8f88;border-radius:10px;background:#123f45;color:#ecfff9;font:700 12px Vazirmatn,Tahoma,sans-serif}
#hudMenu #menuHelp{font-size:13px;line-height:2.15}
#hudMenu #menuHelp kbd{font-size:11px}
@media (pointer:coarse),(max-width:720px){
 html,body,#stage{height:100%;height:100dvh;overscroll-behavior:none}
 #scene{touch-action:none}
 #touch{display:none!important}#controls{display:none!important}
 #mobileUI{display:block;position:static;pointer-events:none}
 #mobileUI button{font-family:Vazirmatn,"Noto Sans Arabic",Tahoma,Arial,sans-serif;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}
 #mobileStick{position:absolute;z-index:96;left:max(11px,env(safe-area-inset-left));bottom:max(14px,env(safe-area-inset-bottom));width:clamp(108px,29vw,138px);aspect-ratio:1;border-radius:50%;pointer-events:auto;touch-action:none;box-sizing:border-box;border:2px solid #85c8cd8a;background:radial-gradient(circle,#0a233aa0 4%,#112c41d8 68%,#0b2035d9 100%);box-shadow:inset 0 0 0 7px #ffffff08,0 6px 22px #0007;overflow:hidden}
 #mobileStick::before,#mobileStick::after{content:"";position:absolute;left:50%;top:50%;width:70%;height:1px;transform:translate(-50%,-50%);background:#a6d9d34f;pointer-events:none}
 #mobileStick::after{transform:translate(-50%,-50%) rotate(90deg)}
 #mobileStickKnob{position:absolute;left:50%;top:50%;width:42%;height:42%;border-radius:50%;transform:translate(-50%,-50%);background:linear-gradient(150deg,#69e2c8,#217f91);border:2px solid #cffef2;box-sizing:border-box;box-shadow:0 4px 15px #0009;pointer-events:none;will-change:transform}
 #mobileStickLabel{position:absolute;z-index:1;pointer-events:none;left:50%;top:5px;transform:translateX(-50%);color:#d5f8f4;font-size:9px;white-space:nowrap;text-shadow:0 2px 3px #05121c}
 #mobilePedals{display:none;position:absolute;z-index:96;right:max(10px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));gap:9px;pointer-events:auto;touch-action:none}
 body.mobile-driving #mobilePedals{display:flex}
 #mobilePedals button{width:clamp(65px,17vw,82px);min-height:78px;padding:5px 4px;border-radius:18px;border:2px solid #9cc5d5ad;color:white;font-size:14px;font-weight:800;background:linear-gradient(155deg,#194055,#071f32);box-shadow:0 6px 18px #0008;touch-action:none}
 #mobilePedals button small{font-size:10px;display:block;color:#c7dce5;margin-top:3px}
 #mobilePedals #mobileGas{background:linear-gradient(155deg,#1d836f,#0a4b4a);border-color:#8cebd0}
 #mobilePedals #mobileBrake{background:linear-gradient(155deg,#8c4144,#54232d);border-color:#f4a5a5}
 #mobilePedals button.is-pressed{filter:brightness(1.25);transform:scale(.96);box-shadow:inset 0 0 0 3px #ffffff22}
 #touchActions{display:grid!important;z-index:96!important;position:absolute!important;left:auto!important;right:max(10px,env(safe-area-inset-right))!important;bottom:max(12px,env(safe-area-inset-bottom))!important;grid-template-columns:repeat(2,minmax(54px,67px))!important;width:auto!important;max-width:none!important;gap:6px!important;pointer-events:auto;direction:rtl;touch-action:none}
 body.mobile-driving #touchActions{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 89px)!important}
 #touchActions button{min-width:0!important;width:100%!important;min-height:47px!important;max-height:52px;border-radius:12px!important;padding:4px 5px!important;font:700 10px Vazirmatn,Tahoma,sans-serif!important;line-height:1.4;background:#102f45ed!important;border:1px solid #80c3ca91!important;box-shadow:0 3px 12px #0007;white-space:normal}
 #touchActions button.is-pressed{background:#1c756e!important;transform:scale(.97)}
 #touchActions button[hidden]{display:none!important}
 #touchActions:not(.extras-open) [data-secondary]{display:none!important}
 #touchActions.extras-open{grid-template-columns:repeat(3,minmax(48px,61px))!important}
 #mobileShortcuts{position:absolute;z-index:97;right:max(10px,env(safe-area-inset-right));bottom:calc(max(12px,env(safe-area-inset-bottom)) + 108px);display:flex;gap:6px;pointer-events:auto;direction:rtl}
 body.mobile-driving #mobileShortcuts{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 198px)}
 #mobileShortcuts button{min-width:42px;min-height:43px;padding:4px 9px;border-radius:12px;background:#10374cea;border:1px solid #8dcfcb99;color:#f8fcff;font-size:18px;box-shadow:0 3px 12px #0007;touch-action:manipulation}
 #mobileShortcuts #mobileMore[aria-expanded="true"]{background:#1b695c;border-color:#d0ffdc}
 body.mobile-map-open #mobileUI,body.mobile-menu-open #mobileUI{display:none!important}
 body.mobile-map-open #touchActions,body.mobile-menu-open #touchActions{display:none!important}
 #hud{width:116px;max-height:122px;overflow:hidden;top:max(8px,env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));padding:6px 9px;border-radius:12px;border-color:#70a6b355}
 #hud .life-head{font-size:8px;margin-top:4px}#hud .meter{height:4px}
 #hud strong{font-size:18px}#hud #wanted{display:none}
 #info,#info.compact{top:max(8px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));max-width:min(200px,47vw);border-radius:11px}
 #info .panelHead{justify-content:flex-start}
 #infoToggle{min-width:44px;min-height:35px;border-color:#83cfc599;font-size:12px;padding:7px 8px}
 #districtHud{max-width:calc(47vw - 55px);margin-top:4px}
 #districtName{font-size:10px!important}#streetName{font-size:9px!important}
 #mapBox{top:calc(max(8px,env(safe-area-inset-top)) + 130px);left:max(8px,env(safe-area-inset-left));bottom:auto!important;padding:5px;border:1px solid #6faaa97a;border-radius:12px;opacity:.98}
 #map{width:96px;height:96px;display:block;border-radius:7px}
 #mapOpenBtn{max-width:none!important;width:100%;margin-top:5px;padding:6px 2px;min-height:30px;font-size:10px;border-radius:8px}
 #qomDriverHUD162{position:absolute!important;z-index:7!important;bottom:auto!important;top:calc(max(8px,env(safe-area-inset-top)) + 12px)!important;left:50%!important;transform:translateX(-50%)!important;max-width:42vw!important;padding:5px 8px!important;font-size:9px!important;white-space:normal;text-align:center}
 #storyMini{right:max(8px,env(safe-area-inset-right));bottom:clamp(248px,33dvh,325px);width:min(200px,48vw);max-width:min(200px,48vw);max-height:118px;overflow:auto;padding:7px 8px;font-size:10px}
 #storyMini button{font-size:10px;min-height:34px}
 #communityHUD{right:max(8px,env(safe-area-inset-right));top:calc(max(8px,env(safe-area-inset-top)) + 65px);max-width:min(190px,49vw);max-height:126px;overflow:auto;font-size:10px}
 #navigationHUD{top:calc(max(8px,env(safe-area-inset-top)) + 65px);left:50%;max-width:42vw;z-index:4}
 #toast{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 154px);max-width:46vw;left:50%;transform:translateX(-50%);font-size:10px}
 #hudMenu{position:fixed;inset:0;z-index:280;background:#020d19d9}
 #hudMenu .menuShell{width:min(420px,100%);max-height:100dvh;padding:14px max(13px,env(safe-area-inset-right)) max(22px,env(safe-area-inset-bottom));border-radius:18px 0 0 18px;box-sizing:border-box}
 #hudMenu .menuTabs{top:50px}
 #worldMapOverlay{position:fixed;inset:0;z-index:275;padding:max(5px,env(safe-area-inset-top)) max(5px,env(safe-area-inset-right)) max(5px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left));box-sizing:border-box}
 #worldMapPanel{width:100%;max-width:100%;height:100%;max-height:100%;padding:8px;display:flex;flex-direction:column;overflow:hidden;border-radius:15px}
 #worldMapPanel .mapTop{flex:0 0 auto}#worldMapPanel .mapTop h2{font-size:17px}
 #mapTools{order:1;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;margin:5px 0;flex:0 0 auto}
 #mapTools button{min-height:42px;padding:5px 2px;font-size:10px;white-space:normal}
 #mapTools #mapZoomValue{align-self:center;font-size:11px}
 #mapTools #mapSelection{grid-column:span 2;display:flex;align-items:center;min-height:38px;padding:5px;text-align:right}
 #mapTools #mapNavigate{grid-column:span 2}
 #mapTools #mapDestination{grid-column:span 3;max-width:none;width:100%;font-size:11px}
 #worldMapPanel .mapHelp{order:2;flex:0 0 auto;font-size:10px;margin:3px 0}
 #worldMapLayout{order:3;flex:1;min-height:0;display:flex;flex-direction:column!important;align-items:stretch;width:100%;gap:4px}
 #worldMap{margin:0 auto!important;width:auto!important;height:auto!important;max-width:100%;max-height:100%;aspect-ratio:1;flex:1 1 auto;min-height:0;object-fit:contain}
 #districtSidebar{width:100%;flex:0 0 auto;min-height:0;max-height:95px;overflow:auto;margin:0;padding:4px 7px}
 #districtSidebar h3{display:none}#districtSidebar p{display:none}
 #districtSearch{margin:0 0 5px;min-height:38px;padding:6px 9px}
 #districtList{display:flex;gap:5px;overflow-x:auto;overflow-y:hidden;padding-bottom:2px;white-space:nowrap}
 #districtList .district-item{flex:0 0 auto;min-height:32px;padding:4px 9px;font-size:10px}
 #worldMapPanel .mapLegend{order:4;flex:0 0 auto;font-size:9px;text-align:center;padding:3px;color:#b3d2d6}
}
@media (pointer:coarse) and (orientation:landscape),(max-width:720px) and (orientation:landscape){
 #mobileStick{width:clamp(104px,22vh,124px)}
 #mobilePedals button{min-height:62px;width:70px;font-size:12px}
 body.mobile-driving #touchActions{bottom:calc(max(7px,env(safe-area-inset-bottom)) + 69px)!important}
 #touchActions{bottom:max(7px,env(safe-area-inset-bottom))!important}
 #touchActions button{min-height:39px!important;max-height:45px;font-size:9px!important}
 #mobileShortcuts{bottom:calc(max(7px,env(safe-area-inset-bottom)) + 94px)}
 body.mobile-driving #mobileShortcuts{bottom:calc(max(7px,env(safe-area-inset-bottom)) + 155px)}
 #mapBox{top:calc(max(5px,env(safe-area-inset-top)) + 90px)}
 #map{width:68px;height:68px}#mapOpenBtn{min-height:28px}
 #hud{max-height:87px}#hud .stat,#hud #carHealthValue{display:none}
 #communityHUD{max-height:80px;top:calc(max(5px,env(safe-area-inset-top)) + 52px)}
 #storyMini{right:40%;bottom:6px;max-height:70px;width:min(220px,26vw);max-width:min(220px,26vw);padding:4px 8px}
 #storyMini button{min-height:29px;padding:3px 5px;font-size:9px}
 #navigationHUD{top:7px}
 #qomDriverHUD162{top:5px!important}
 #toast{bottom:92px}
 #worldMapPanel{padding:5px 10px}
 #worldMapPanel .mapTop h2{font-size:14px}
 #mapTools{grid-template-columns:repeat(8,minmax(0,1fr));gap:4px}
 #mapTools #mapDestination{grid-column:span 2}#mapTools #mapNavigate{grid-column:span 2}
 #mapTools #mapSelection{grid-column:span 2}#mapTools button{min-height:34px}
 #worldMapLayout{flex-direction:row-reverse!important;gap:7px}
 #districtSidebar{width:165px;flex:0 0 165px;max-height:none;overflow:auto}
 #districtSidebar h3{display:block;font-size:11px}
 #districtList{display:grid;overflow-y:auto;overflow-x:hidden;white-space:normal;max-height:calc(100% - 45px)}
 #worldMap{max-width:min(100%,70vh);max-height:100%;margin:auto!important}
 #worldMapPanel .mapHelp{display:none}
}
@media (max-width:360px) and (orientation:portrait){
 #mobileStick{width:112px}
 #touchActions{grid-template-columns:repeat(2,54px)!important}
 #touchActions.extras-open{grid-template-columns:repeat(3,48px)!important}
 #mobileShortcuts button{min-width:38px;padding:4px 7px}
 #mobilePedals button{width:62px}
 #map{width:82px;height:82px}
 #communityHUD{max-height:95px}
}
@media(prefers-reduced-motion:reduce){#mobileUI *,#hudMenu *{animation:none!important;transition:none!important}}
/* Garage is reachable from the quick menu, instead of covering the mobile joystick. */
@media (pointer:coarse),(max-width:720px){
 #hudMenu #qomCarGarage{position:static;display:block;left:auto;bottom:auto;z-index:auto;max-width:100%;width:100%;box-sizing:border-box;margin:12px 0 8px;padding:11px 12px;opacity:1}
 #hudMenu #qomCarGarage select,#hudMenu #qomCarGarage button{min-height:43px}
 #touchActions [data-action="service"]{background:#125748!important;border-color:#64d7b8!important}
}
/* V16.3 layout corrections after 360/390/844 CSS viewport tests. */
@media (pointer:coarse),(max-width:720px){
 body:not(.mobile-driving) #hud .life-head:has(#carHealthValue),
 body:not(.mobile-driving) #hud .meter.vehicle{display:none}
 body:not(.mobile-driving) #hud{max-height:128px}
 body.mobile-driving #hud{max-height:160px}
 body.mobile-driving #mapBox{top:calc(max(8px,env(safe-area-inset-top)) + 166px)}
 #communityHUD{top:calc(max(8px,env(safe-area-inset-top)) + 127px);max-height:100px}
 #communityHUD:not(.hasTask){max-height:67px}
 /* A square map, constrained by BOTH available height and width (including the district rail). */
 #worldMapLayout{container-type:size}
 #districtSidebar{height:72px;max-height:72px;box-sizing:border-box}
 #worldMap{width:min(calc(100cqh - 78px),calc(100cqw - 8px))!important;
           height:min(calc(100cqh - 78px),calc(100cqw - 8px))!important;
           flex:0 0 auto!important;align-self:center;object-fit:contain}
 #worldMapPanel .mapLegend{min-height:15px}
}
@media (pointer:coarse) and (orientation:landscape),(max-width:720px) and (orientation:landscape){
 #communityHUD{top:max(8px,env(safe-area-inset-top));right:calc(max(8px,env(safe-area-inset-right)) + 104px);width:min(160px,24vw);max-width:min(160px,24vw);max-height:72px}
 #communityHUD:not(.hasTask){max-height:57px}
 body.mobile-driving #hud{max-height:87px}
 body.mobile-driving #mapBox{top:calc(max(5px,env(safe-area-inset-top)) + 90px)}
 #districtSidebar{height:auto;max-height:none}
 #worldMap{width:min(100cqh,calc(100cqw - 177px))!important;
           height:min(100cqh,calc(100cqw - 177px))!important}
}
/* Expanded turn-signal panel grows upwards; keep its collapse button reachable. */
@media (pointer:coarse),(max-width:720px){
 body.mobile-driving:has(#touchActions.extras-open) #mobileShortcuts{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 254px)}
}
@media (pointer:coarse) and (orientation:landscape),(max-width:720px) and (orientation:landscape){
 body.mobile-driving:has(#touchActions.extras-open) #mobileShortcuts{bottom:calc(max(7px,env(safe-area-inset-bottom)) + 205px)}
}
