/* Shared phone/tablet layout. World permissions and game state are unchanged. */
#mobile-tools-button,#mobile-tools,#mobile-driving{display:none}
:root{--safe-bottom:env(safe-area-inset-bottom,0px);--safe-top:env(safe-area-inset-top,0px);--mobile-top:104px}
@media(max-width:900px),(pointer:coarse){
 html{ -webkit-text-size-adjust:100%;overscroll-behavior:none }
 body{max-width:100vw}button,a,input,textarea,select{touch-action:manipulation}
 input:not([type=checkbox]):not([type=radio]),textarea,select{font-size:16px!important;min-width:0;max-width:100%;box-sizing:border-box}
 button{min-height:44px}button:focus-visible,a:focus-visible{outline-offset:-2px}
 [data-move],[data-drive-key]{touch-action:none!important;user-select:none;-webkit-user-select:none}
 #scene,#world,#work-scene{touch-action:none}
 body:has(#campus),body:has(#game){height:100dvh;overflow:hidden}
 #campus,#game{height:100dvh;max-height:100dvh}
 /* A two-row header leaves 44px targets for worlds and account actions. */
 #campus>header{height:calc(104px + var(--safe-top));padding:calc(4px + var(--safe-top)) max(10px,env(safe-area-inset-right)) 4px max(10px,env(safe-area-inset-left));display:flex;flex-wrap:wrap;gap:2px 8px;align-content:center}
 #campus>header .brand{margin-right:auto}#campus>header .brand img{width:104px}#campus>header .brand b{font-size:13px}
 #campus>header .floors{order:5;width:100%;overflow-x:auto;flex-wrap:nowrap;padding:0;gap:0;justify-content:center}
 #campus>header .floors button{flex:1;min-width:max-content;max-width:none;font-size:12px;padding:8px 10px}
 #campus>header #directory-toggle,#campus>header #account-button{width:44px;height:44px;min-width:44px;padding:6px}
 body:has(#campus){--mobile-top:calc(104px + var(--safe-top))}
 body #scene{inset:var(--mobile-top) 0 64px!important}
 #campus #directory{display:none;position:fixed;top:calc(var(--mobile-top) + 58px);left:10px;bottom:calc(70px + var(--safe-bottom));width:min(300px,calc(100vw - 20px));max-height:none;background:#142c34fa;padding:14px;overflow:auto;z-index:70;pointer-events:auto;border-radius:12px}
 body.directory-open #campus #directory{display:block}body.room-mode #directory #room-list{display:block}
 #room-heading,#floor-note,#control-hint{display:none!important}
 #campus #room-doors{top:calc(var(--mobile-top) + 60px);left:10px;max-width:180px;gap:4px;max-height:28dvh;overflow:auto}
 #room-doors button{font-size:11px;padding:8px}
 #campus #room-actions{position:fixed;left:10px;right:10px;bottom:calc(76px + var(--safe-bottom));pointer-events:none;justify-content:space-between;gap:8px;z-index:42}
 #room-actions .touch{display:block;order:-1;pointer-events:auto}#room-actions #interact{pointer-events:auto;max-width:46%;font-size:12px;padding:10px;align-self:flex-end}
 .touch button,.touch-controls button{width:44px;height:44px;min-width:44px;padding:0;margin:1px;opacity:1}
 #campus>footer{position:fixed;bottom:var(--safe-bottom);left:0;right:0;min-height:64px;background:#132129f5;display:flex;justify-content:center;padding:8px;gap:4px;z-index:43;overflow-x:auto}
 body #campus .camera.unified-camera{gap:4px;margin:0;flex-shrink:0;display:flex}
 #campus .camera button,.reception-camera-hud .camera-controls button{width:44px;height:44px;min-width:44px;padding:0;font-size:18px}
 #campus .camera #view-toggle,.reception-camera-hud #view-toggle{min-width:88px;width:auto;padding:0 7px;font-size:11px}
 #campus #inspector,body.room-mode #inspector{position:fixed;top:calc(var(--mobile-top) + 60px);bottom:auto;left:10px;right:10px;width:auto;max-height:calc(100dvh - var(--mobile-top) - 145px);overflow:auto;z-index:75;padding:18px}
 #close-card{min-width:44px;min-height:44px}
 /* Secondary HUD lives in one drawer, leaving the scene and movement reachable. */
 body.mobile-layout #mobile-tools-button{display:block;position:fixed;top:calc(var(--mobile-top) + 8px);right:max(10px,env(safe-area-inset-right));z-index:50;min-height:44px;padding:8px 12px;max-width:calc(100vw - 126px);border:1px solid #769591;border-radius:12px;background:#18343bf5;color:#d9e9c7;font:600 12px Arial}
 #mobile-tools-button.has-unread{background:#c8dda9!important;color:#203a2e!important}
 body.mobile-layout #mobile-tools:not([hidden]){display:block;position:fixed;inset:calc(var(--mobile-top) + 58px) 10px calc(72px + var(--safe-bottom));z-index:80;padding:12px;background:#142c34fc;color:#e7eee9;border:1px solid #72938c;border-radius:14px;overflow:auto;overscroll-behavior:contain}
 .mobile-tools-title{display:flex;justify-content:space-between;align-items:center;gap:12px;position:sticky;top:-12px;background:#142c34;z-index:1;padding:4px 0}.mobile-tools-title button{width:44px;min-width:44px;font-size:24px;background:#29454e;color:#fff;border:0;border-radius:8px}
 .mobile-tools-content{display:flex;flex-direction:column;gap:10px;min-width:0}
 #mobile-tools .mobile-tools-content>:is(button,section,aside,div,a){position:static!important;inset:auto!important;transform:none!important;margin:0!important;width:100%!important;max-width:none!important;max-height:none!important;box-sizing:border-box;pointer-events:auto;font-size:13px}
 #mobile-tools #cockpit{overflow:visible!important}#mobile-tools #service-live{visibility:visible!important;box-shadow:none;padding:12px}
 #mobile-tools .reception-status{gap:12px;align-items:stretch}#mobile-tools .player-hud,#mobile-tools .time-hud{position:static!important;inset:auto!important;max-width:none!important;pointer-events:auto}
 #mobile-tools .quest-hud h1{font-size:21px}#mobile-tools .quest-hud p,#mobile-tools .task-item{max-width:none;font-size:13px}
 #mobile-tools #feedback-inbox{position:static!important;width:100%;margin:0}.mobile-tools-content #back-map{display:block!important;max-width:none;font-size:13px}
 #cycle-panel,#team-panel{inset:calc(var(--visible-top,0px) + 8px) 8px auto!important;width:calc(100vw - 16px)!important;height:calc(var(--visible-height,100dvh) - 16px)!important;max-height:calc(var(--visible-height,100dvh) - 16px)!important;z-index:100!important;box-sizing:border-box;padding:14px!important;overflow:auto}
 #team-panel header{position:static;height:auto;padding:0;inset:auto;background:none;gap:8px}#team-panel header button{min-width:44px}
 .team-layout{grid-template-columns:1fr!important;grid-template-rows:112px minmax(0,1fr);gap:10px;height:calc(100% - 105px)}
 #team-people{flex-direction:row;gap:6px;overflow:auto;border-bottom:1px solid #45616a;padding-bottom:8px}#team-people>small{min-width:90px;max-width:110px}#team-people button{min-width:135px;max-width:180px;flex-shrink:0}
 #team-body{font-size:16px!important}#team-status{height:auto;min-height:25px;margin:5px 0}.team-conversation{min-height:130px}
 #cycle-offer{bottom:calc(180px + var(--safe-bottom));max-width:calc(100vw - 24px);width:max-content;padding:10px 14px;font-size:13px}
 #on-foot{bottom:calc(184px + var(--safe-bottom));right:10px;max-width:180px;font-size:11px}
 /* Manual driving buttons stay outside the menu; route settings remain inside. */
 body.mobile-layout.driving-mode #mobile-driving{display:grid;position:fixed;left:10px;right:10px;bottom:calc(76px + var(--safe-bottom));grid-template-columns:144px 1fr;gap:6px 18px;pointer-events:none;z-index:42}
 #mobile-driving .drive-pad{display:block;grid-row:1/3;pointer-events:auto;text-align:center}#mobile-driving .drive-pad>div{display:flex;gap:3px}#mobile-driving .drive-pad button{width:44px;min-width:44px;height:44px;padding:0;margin:1px;background:#24424cef;color:#ecf3df;border:1px solid #73918d;border-radius:9px;font-size:20px}
 #mobile-driving>#exit-car,#mobile-driving>#drive-stop{pointer-events:auto;justify-self:end;max-width:160px;font-size:12px;padding:8px 12px;min-height:44px}
 .drive-help,.move-guide{display:none!important}
 /* Reception uses the same camera/movement zones, plus an object strip. */
 body:has(#game){--mobile-top:calc(60px + var(--safe-top))}
 #game .game-top{top:var(--safe-top);left:10px;right:10px;height:60px;gap:5px;align-items:center}#game .game-brand img{width:94px}#game .game-brand>span{display:none}#game .room-chip{padding:8px;font-size:10px;min-height:44px;display:flex;align-items:center}#game .top-buttons{gap:3px}#game .top-buttons button{width:44px;height:44px;padding:0;font-size:18px}#game #sound{display:none}
 #game .game-bottom{inset:auto 8px calc(8px + var(--safe-bottom));height:116px;display:block;pointer-events:none}
 #game .action-bar{position:absolute;left:0;right:0;bottom:0;width:100%;max-width:none;overflow-x:auto;display:flex;justify-content:space-between;padding:3px;pointer-events:auto}
 #game .action-bar button{min-width:48px;padding:5px;min-height:48px;font-size:10px}#game .action-bar .action-icon{font-size:20px}#game .action-bar kbd{display:none}
 #game .camera-controls{position:absolute!important;bottom:62px!important;right:0!important;left:0;justify-content:center;gap:4px;pointer-events:auto}
 #game .touch-controls{display:block;position:fixed;left:10px;bottom:calc(144px + var(--safe-bottom));opacity:1;z-index:42;text-align:center}
 #game .touch-controls button{width:44px;height:44px;background:#203f48ef;color:#e7f1df;border:1px solid #6c8986}
 #game .interaction-hint{bottom:calc(245px + var(--safe-bottom));font-size:11px;max-width:90%;padding:7px 10px}
 #game .intro-card{top:calc(var(--mobile-top) + 60px);bottom:auto;max-height:calc(100dvh - var(--mobile-top) - 210px);overflow:auto;width:calc(100vw - 24px);max-width:420px;padding:18px;z-index:60}
 #game .intro-card .primary{min-height:44px}
 #message-alerts{top:calc(var(--mobile-top) + 60px)!important;right:10px;width:min(350px,calc(100vw - 20px))}
 /* All task, profile, tuning and purchase forms fit above the on-screen keyboard. */
 body dialog,body #service-orders.compact{box-sizing:border-box!important;inset:calc(var(--visible-top,0px) + 8px) 8px auto!important;margin:0 auto!important;width:calc(100vw - 16px)!important;min-width:0!important;max-width:760px!important;max-height:calc(var(--visible-height,100dvh) - 16px)!important;border-radius:14px;overflow:auto}
 body #player-cabinet{height:calc(var(--visible-height,100dvh) - 16px)!important;overflow:hidden}
 #player-cabinet .pc-close{min-height:44px;min-width:44px}#player-cabinet .pc-tabs{overflow-x:auto;gap:18px}#player-cabinet .pc-header{padding:18px}#player-cabinet .pc-panel{padding:18px}
 dialog input,dialog textarea,dialog select{font-size:16px!important}dialog button{min-height:44px}dialog :is(p,h2,h3,h4){overflow-wrap:anywhere}
 .so-grid,.feedback-form-grid,.form-grid{grid-template-columns:minmax(0,1fr)!important}.so-list{grid-template-columns:minmax(0,1fr)}
 #toast{top:calc(var(--mobile-top) + 58px)!important;z-index:120}
 /* Working service / shared island retain their data below the map. */
 body:has(.work-layout){overflow:auto;height:auto}body:has(.work-layout)>header{height:auto;min-height:70px;padding:12px;flex-wrap:wrap;gap:10px}.head-actions{flex-wrap:wrap;gap:8px}.head-actions a{padding:10px 4px;min-height:44px;display:inline-flex;align-items:center}
 .work-toolbar{height:auto;min-height:64px;padding:8px 12px;gap:8px;flex-wrap:wrap}.work-toolbar>div{flex-wrap:wrap}#save-status{width:100%;order:5}
 .work-layout{display:block;height:auto}.work-layout .map-area{height:calc(100dvh - 160px);min-height:490px}.work-inspector{border-left:0;border-top:1px solid #405b61;padding:20px}
 #rooms-toggle{display:block}#work-rooms{position:fixed;display:none;top:70px;bottom:8px;left:8px;width:min(300px,calc(100vw - 16px));z-index:70;background:#192f37;box-shadow:15px 0 40px #08151c80}#work-rooms.open{display:block}
 .map-area .map-caption{top:12px;left:12px;max-width:calc(100% - 24px)}.map-caption span{display:none}
 .map-area .map-controls{bottom:12px;left:8px;right:8px;max-width:none;justify-content:center;flex-wrap:nowrap;gap:3px;overflow-x:auto}.map-controls button{min-width:44px;padding:8px;font-size:12px}
 .map-area .touch-walk{bottom:72px;left:8px;gap:3px}.touch-walk button{min-width:44px;min-height:44px;padding:7px}
 .map-area .walk-controls{bottom:124px;left:8px;right:8px;max-width:none;gap:5px}.walk-controls button{font-size:11px;min-height:44px;padding:8px}
 #walk-notice{bottom:174px!important;left:8px;right:8px;max-height:80px;overflow:auto}
 .map-area #work-labels button,.map-area #people-labels button{min-height:32px;font-size:10px;max-width:145px}
 .work-inspector .person-row button{min-height:44px;font-size:12px}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
 body:has(#campus){--mobile-top:52px}#campus>header{height:52px;flex-wrap:nowrap;padding:4px 10px}#campus>header .floors{order:0;width:auto;margin-left:auto}#campus>header .brand b{display:none}#campus>header .brand img{width:84px}
 #campus #room-actions,#mobile-driving{bottom:70px!important}#campus #room-doors{max-height:80px}
 #game .game-brand img{width:100px}#game .game-top{height:52px}body:has(#game){--mobile-top:52px}
 #game .touch-controls{bottom:70px}#game .game-bottom{height:52px}#game .action-bar{left:155px;right:310px;width:auto;min-width:140px}#game .camera-controls{left:auto;right:0!important;bottom:0!important;gap:2px}#game .camera-controls button{min-width:36px;width:36px}#game .camera-controls #view-toggle{min-width:78px}
 #game .interaction-hint{bottom:168px}.intro-controls{display:none}#game .intro-card{top:66px;max-height:calc(100dvh - 138px);max-width:360px}
 .team-layout{grid-template-columns:145px minmax(0,1fr)!important;grid-template-rows:minmax(0,1fr)}#team-people{flex-direction:column}#team-people button{min-width:0}
 .work-layout .map-area{height:100dvh;min-height:350px}.map-caption{padding:7px}.map-area .walk-controls{left:auto;bottom:72px}.map-area #walk-notice{bottom:124px!important}
}
@media(max-width:360px){#campus .camera button{min-width:38px;width:38px}#campus .camera #view-toggle{min-width:78px;font-size:10px}#game .game-brand img{width:76px}#game .room-chip{font-size:9px}.mobile-tools-title{font-size:13px}.contact-card{grid-template-columns:1fr}}
@media(max-width:900px),(pointer:coarse){
 #message-alerts{bottom:auto!important;height:auto;pointer-events:none}#message-alerts .message-toast{pointer-events:auto}
 #team-panel:not([hidden]){display:flex;flex-direction:column}#team-panel .team-layout{height:auto;flex:1;min-height:310px;grid-template-rows:180px minmax(130px,1fr)}#team-panel>header,#team-panel .team-preferences,#team-status{flex-shrink:0}
 .mobile-label-occluded{visibility:hidden!important}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){#team-panel .team-layout{grid-template-rows:minmax(150px,1fr);min-height:150px}}
@media(max-width:900px),(pointer:coarse){
 #mobile-driving .drive-pad button{font-size:12px;line-height:1.25;white-space:normal;overflow-wrap:normal}
 #mobile-driving #car-speed{position:absolute;bottom:calc(100% + 8px);right:0;padding:7px 12px;border-radius:9px;background:#16323bf2;color:#e6efdf;font:700 16px Arial}
 .map-label,.world-label,.cycle-labels button{min-height:32px;font-size:11px}
}
.mobile-map-size{display:none}
@media(max-width:900px),(pointer:coarse){
 .mobile-map-size{display:block;position:absolute;top:64px;right:12px;z-index:6;background:#19363ef5;color:#e7f0dd;font-size:12px;padding:8px 12px}
 body.map-expanded{overflow:hidden}body.map-expanded .map-area{position:fixed;inset:0;z-index:80;width:100vw;height:100dvh;min-height:0;background:#142b32}
}
