/* Mobile layout is intentionally isolated from the established desktop scene. */
.mobile-heading,.mobile-nav,.mobile-tools,.mobile-close-directory,.mobile-close-help{display:none}
.mobile-menu:not([open]){display:none}
@media (max-width:760px), (max-width:1024px) and (max-height:600px){
 :root{--mobile-top:calc(70px + env(safe-area-inset-top,0px));--mobile-bottom:calc(72px + env(safe-area-inset-bottom,0px))}
 html,body{width:100%;height:100%;overflow:hidden;overscroll-behavior:none}
 #game{width:100%;height:var(--mobile-vh,100dvh);min-height:0;isolation:isolate}
 #game #viewport{inset:var(--mobile-top) 0 var(--mobile-bottom);touch-action:manipulation}
 #game .hud{inset:0 0 auto;z-index:12;height:var(--mobile-top);padding:calc(8px + env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) 8px max(12px,env(safe-area-inset-left,0px));gap:8px;background:#faf6ecef;border-bottom:1px solid #fff7e5;box-shadow:0 4px 25px #334e3d0d}
 #game .brand{padding:0;background:transparent;border:0;box-shadow:none;border-radius:0;gap:7px;flex-shrink:0}
 #game .brand-icon{font-size:28px}
 #game .brand strong{font-size:24px;letter-spacing:-1px;white-space:nowrap}
 #game .brand small{font-size:6px;letter-spacing:1.3px;margin-top:3px}
 #game .hud>.location{display:none}
 .mobile-heading{display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0}
 #mobileLocation{font-size:11px;line-height:1.4;color:#667660;text-align:right;max-width:112px;overflow-wrap:anywhere}
 #mobileMenuTop{display:grid;place-items:center;width:44px;height:44px;flex-shrink:0;border-radius:14px;background:#e8eddf;color:#47634d}
 #mobileMenuTop svg{width:22px;height:22px}
 #game .mobile-nav{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));position:absolute;z-index:12;inset:auto 0 0;height:var(--mobile-bottom);padding:6px max(8px,env(safe-area-inset-right,0px)) calc(6px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));gap:3px;background:#faf6ecfa;border-top:1px solid #fff7e5;box-shadow:0 -5px 25px #334e3d14}
 .mobile-nav button{min-width:0;min-height:48px;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:4px;padding:5px 1px;border-radius:13px;background:transparent;color:#78816f;font-size:10px;line-height:1.2}
 .mobile-nav svg{width:22px;height:22px}
 .mobile-nav button[aria-current="page"]{background:#e4ebdc;color:#426149;font-weight:700}
 .mobile-nav button:active,#mobileMenuTop:active{background:#d9e3cf}
 #game .mobile-tools{position:absolute;z-index:4;bottom:calc(var(--mobile-bottom) + 12px);left:12px;right:12px;display:flex;justify-content:center;gap:8px;pointer-events:none}
 #game.mobile-editing .mobile-tools{display:none}
 .mobile-tools button{pointer-events:auto;min-height:44px;min-width:100px;max-width:48%;border:1px solid #fff7e8;background:#faf6ecf5;border-radius:14px;box-shadow:0 4px 18px #28443726;padding:10px 17px;font-size:12px;font-weight:600;color:#45604b;white-space:normal}
 .mobile-tools button:last-child{background:#506e54;color:#fff9eb;border-color:#718665}
 #game>.footer-note,#game>.compass,#game>.bottom-hud,#game>#islandLocateWrap,#game>.corse-directory-toggle{display:none!important}
 /* Existing controls are moved here, with their listeners and private state intact. */
 #mobileMenu{position:fixed;inset:auto 0 0;margin:0 auto;width:100%;max-width:560px;max-height:calc(var(--mobile-vh,100dvh) - env(safe-area-inset-top,0px) - 12px);height:auto;padding:0;border:1px solid #fff4dd;border-radius:24px 24px 0 0;color:var(--ink);background:#faf6ec;box-shadow:0 -15px 65px #1b342f55;overflow:hidden}
 #mobileMenu[open]{display:flex;flex-direction:column}
 #mobileMenu::backdrop{background:#203c3699;backdrop-filter:blur(5px)}
 #mobileMenu>header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:20px 20px 14px;border-bottom:1px solid #e0dfcd;flex-shrink:0}
 #mobileMenu>header small{font-size:8px;letter-spacing:1.5px;color:#9b8262}
 #mobileMenuTitle{font:26px Georgia,serif;margin:6px 0 0;color:#4d664d}
 #closeMobileMenu{width:44px;height:44px;border-radius:50%;background:#e8ecdd;font-size:28px;flex-shrink:0}
 #mobileMenuBody{overflow-y:auto;overscroll-behavior:contain;min-height:0;padding:14px 16px calc(22px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:14px}
 #mobileMenuBody>*{flex-shrink:0;min-width:0}
 #mobileMenuBody #sideHud{position:static;inset:auto;transform:none;width:100%;max-height:none;overflow:visible;pointer-events:auto;padding:0;gap:14px}
 #mobileMenuBody .agent-session{position:static;inset:auto;display:flex;flex-wrap:wrap;align-items:center;width:100%;gap:8px;margin:0;padding:10px 12px;box-shadow:none;border-radius:14px;background:#edf0e4}
 #mobileMenuBody .agent-self{margin-right:auto;font-size:13px}
 #mobileMenuBody .agent-self small{font-size:11px}
 #mobileMenuBody .agent-session button,#mobileMenuBody .agent-session a{min-height:44px;padding:10px;font-size:12px;display:flex;align-items:center;color:#596b53}
 #mobileMenuBody .top-actions{display:flex;flex-wrap:wrap;gap:8px}
 #mobileMenuBody .top-actions button{min-height:44px;min-width:44px;box-shadow:none;border-radius:12px;background:#e9e8da;font-size:16px}
 #mobileMenuBody .top-actions #lbgConnection{font-size:12px;font-weight:700}
 #mobileMenuBody #addHousing{flex:1;justify-content:center;display:flex;align-items:center;gap:7px;font-size:13px;background:#506e54;color:#fff7e7;padding:8px 12px}
 #mobileMenuBody #addHousing span{display:inline}
 #mobileMenuBody #fullscreen{display:none}
 #mobileMenuBody #sideHud>.map-modes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));padding:0;gap:7px;background:none;border:0;box-shadow:none}
 #mobileMenuBody #mapModes button{font-size:12px;min-height:46px;padding:11px;background:#edeedf;border-radius:12px}
 #mobileMenuBody #mapModes button[aria-pressed="true"]{background:#506e54;color:#fff7e7}
 #mobileMenuBody #sideHud>.agency-chapter{display:block;padding:0;background:transparent;border:0;box-shadow:none}
 #mobileMenuBody #sideHud .agency-chapter>span,#mobileMenuBody #sideHud .agency-chapter>h1,#mobileMenuBody #sideHud .agency-chapter>p,#mobileMenuBody .corse-chapter,#mobileMenuBody .chapter{display:none}
 #mobileMenuBody #sideHud .agency-shortcuts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:0}
 #mobileMenuBody #sideHud .agency-shortcuts button{min-height:46px;font-size:13px;padding:12px;background:#e8eddf}
 #mobileMenuBody .agency-desks-section{margin:16px 0 0;padding:14px 0 0;border-top:1px solid #dddcc8}
 #mobileMenuBody .agency-desks-section>div:first-child{display:flex;align-items:center;justify-content:space-between}
 #mobileMenuBody .agency-desks-section>div>span{font-size:10px;letter-spacing:1.5px}
 #mobileMenuBody #agencyMyDesk{min-height:44px;font-size:12px;padding:9px 12px}
 #mobileMenuBody #sideHud .agency-desks{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:10px}
 #mobileMenuBody #sideHud .agency-desks button{text-align:left;min-height:66px;padding:12px;background:#eeefe2;border-radius:13px}
 #mobileMenuBody #sideHud .agency-desks strong{font-size:14px}
 #mobileMenuBody #sideHud .agency-desks small{font-size:11px;margin-top:5px}
 #mobileMenuBody .break-chapter{display:none!important}
 #game.is-break #mobileMenuBody #sideHud>.break-chapter{display:flex!important;flex-wrap:wrap;padding:12px;gap:8px;background:#eeefe2;border-radius:14px}
 #mobileMenuBody .break-chapter>span,#mobileMenuBody .break-chapter h1{display:none}
 #mobileMenuBody #sideHud .break-chapter p{font-size:12px;flex-basis:100%;line-height:1.5;margin:0}
 #mobileMenuBody #sideHud #petCat,#mobileMenuBody #sideHud #openPauseChat{width:auto;min-height:44px;margin:0;padding:10px;font-size:12px;flex:1}
 #mobileMenuBody .agency-tier,#mobileMenuBody .corse-team,#mobileMenuBody .personal-office-card,#mobileMenuBody .dock-wrap{position:static!important;inset:auto!important;transform:none!important;max-width:none;width:100%;margin:0;padding:14px;border-radius:14px;max-height:none;height:auto;box-shadow:none;background:#eeefe2}
 #mobileMenuBody .agency-tier{display:flex!important;flex-direction:column;gap:7px}
 #mobileMenuBody .agency-tier strong{font:23px Georgia,serif}
 #mobileMenuBody .agency-tier small{font-size:11px;line-height:1.5;margin:0}
 #mobileMenuBody .agency-tier-track{width:100%;height:5px}
 #mobileMenuBody .corse-team{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 #mobileMenuBody .corse-team button{min-height:54px;min-width:0;padding:5px;gap:6px;font-size:12px}
 #mobileMenuBody .corse-team small{font-size:11px}
 #mobileMenuBody .personal-office-card:not([hidden]){display:block}
 #mobileMenuBody .personal-office-card h2{font-size:23px}
 #mobileMenuBody .personal-xp small,#mobileMenuBody .personal-xp span{font-size:11px;line-height:1.5}
 #mobileMenuBody .personal-office-actions{display:flex;gap:8px}
 #mobileMenuBody .personal-office-actions button{min-height:44px;font-size:12px;flex:1}
 #mobileMenuBody .dock-wrap{display:none!important}
 #game:not(.is-agency):not(.is-office):not(.is-corse):not(.is-break) #mobileMenuBody .dock-wrap{display:block!important}
 #mobileMenuBody #buildingNav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
 #mobileMenuBody .nav-building{min-width:0;min-height:64px;padding:8px;overflow-wrap:anywhere}
 #mobileMenuBody .dock-heading{letter-spacing:.5px;font-size:10px;flex-wrap:wrap}
 /* All detail windows use the same bounded, independently scrolling mobile sheet. */
 #game .property-card,#game .agency-panel,#game #agencyPanel.is-taskboard,#game .agent-settings,#game .is-break .pause-chat,#game.is-break .pause-chat{position:absolute;inset:calc(8px + env(safe-area-inset-top,0px)) 8px calc(8px + env(safe-area-inset-bottom,0px));width:auto;max-width:640px;height:auto;max-height:none;margin:0 auto;transform:none;z-index:30;border-radius:20px;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
 #game .property-card:not([hidden]){display:flex;flex-direction:column}
 #game .property-card>.card-image{height:92px;min-height:92px;flex-shrink:0}
 #game .property-card>.card-body,#game .property-card>.mission-body,#game .property-card>.character-body,#game .property-card>.mission-form{overflow-y:auto;overscroll-behavior:contain;min-height:0;padding:18px 20px;flex:1}
 #game .mission-form-header,#game .character-header{flex-shrink:0;padding:18px 58px 15px 20px}
 #game .mission-form-header h2{font-size:25px;margin:7px 0}
 #game .mission-form-header p{font-size:12px;margin:5px 0 0}
 #game .mission-body h2,#game .card-body h2{font-size:27px;overflow-wrap:anywhere}
 #game .mission-body p,#game .card-body p{font-size:13px;line-height:1.6}
 #game .property-card button,#game .agent-settings button,#game .pause-chat button{min-height:44px}
 #game #closeCard,#game #closeMission,#game #closeCharacter,#game #closeMissionForm,#game #closeHousingForm,#game #closeLbgSync,#game #closeAgentSettings{width:44px;height:44px;right:9px;top:9px;font-size:27px}
 #game input:not([type="checkbox"]):not([type="hidden"]),#game textarea,#game select{font-size:16px;min-width:0;max-width:100%}
 #game input:not([type="checkbox"]):not([type="hidden"]),#game select{min-height:44px}
 #game .mission-form-grid{gap:10px;grid-template-columns:repeat(2,minmax(0,1fr))}
 #game .mission-form-grid>*{min-width:0}
 #game .mission-form input[type="file"]{width:100%;overflow:hidden}
 #game .mission-form input[type="checkbox"]{width:auto;min-height:24px}
 #game .postit-palette>div{gap:9px}
 #game .postit-palette .postit-swatch{width:38px;min-width:38px;min-height:38px;height:38px}
 #game .attachment-list .attachment-remove,#game .staged-files button{min-width:44px;min-height:44px}
 #game .attachment-name{overflow-wrap:anywhere}
 #game #agencyPanel{background:#faf6ec}
 #game #agencyPanel.is-taskboard{border-width:6px;border-radius:16px;display:flex;overflow-y:auto}
 #game .agency-panel-header,#game .is-taskboard .agency-panel-header{position:relative;flex-shrink:0;padding:16px 54px 12px 16px;min-height:80px}
 #game .agency-panel-header h2,#game .is-taskboard .agency-panel-header h2{font-size:25px;margin:6px 0}
 #game #closeAgencyPanel{width:44px;height:44px;top:9px;right:8px;font-size:28px}
 #game .agency-panel-tabs,#game .is-taskboard .agency-panel-tabs{position:static;display:flex;flex-wrap:wrap;gap:6px;padding:8px 12px;flex-shrink:0}
 #game .agency-panel-tabs button{min-height:44px;font-size:12px;padding:9px 12px;flex:1 1 auto}
 #game .agency-panel-tabs .agency-new-postit{flex-basis:100%;margin:0}
 #game .agency-search,#game .is-taskboard .agency-search{padding:4px 12px 10px;flex-shrink:0}
 #game .agency-task-filters{display:flex;gap:8px;padding:0 12px 10px;flex-shrink:0}
 #game .agency-task-filters label{flex:1;min-width:0}
 #game .agency-task-filters select{width:100%;font-size:14px;min-height:44px}
 #game #agencyResults{min-height:0;flex:1;overflow-y:auto;overscroll-behavior:contain}
 #game .is-taskboard #agencyResults{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 12px;padding:23px 14px;flex:0 0 auto;overflow:visible}
 #game .is-taskboard .task-postit{min-height:170px;padding:22px 12px 12px;transform:rotate(var(--note-tilt));font-size:11px}
 #game .is-taskboard .task-postit strong{font-size:17px;line-height:1.25}
 #game .is-taskboard .task-postit small{font-size:10px}
 #game .is-taskboard .postit-top{font-size:9px;gap:4px;flex-wrap:wrap}
 #game .is-taskboard .postit-description{font-size:11px;-webkit-line-clamp:2}
 #game .is-taskboard .postit-footer{font-size:10px;flex-wrap:wrap}
 #game #agencyPagination{flex-shrink:0;padding:9px 14px}
 #game #agencyPagination button{min-height:44px;min-width:44px}
 #game #agencyPanelHint{font-size:10px;padding:10px 14px;flex-shrink:0;margin:0}
 #game .agency-desk-header{padding:10px 14px;flex-shrink:0}
 #game .agency-desk-header small{font-size:11px}
 #game .corse-directory{inset:auto 8px calc(var(--mobile-bottom) + 8px);width:auto;height:min(65dvh,560px);max-height:calc(var(--mobile-vh,100dvh) - var(--mobile-top) - var(--mobile-bottom) - 16px);max-width:none;margin:0;border-radius:20px;z-index:15;background:#faf6ec}
 #game .corse-directory-header{position:relative;padding-right:55px}
 .mobile-close-directory{display:grid;place-items:center;position:absolute;right:6px;top:6px;width:44px;height:44px;border-radius:50%;font-size:27px;background:#e8ecdd}
 #game .corse-result{min-height:64px}
 #game .is-break .pause-chat,#game.is-break .pause-chat{background:#faf6ec;min-height:0}
 #game .pause-chat>header{padding:16px;flex-shrink:0}
 #game .pause-chat h2{font-size:24px}
 #game .pause-messages{min-height:50px;flex:1;overflow:auto}
 #game #pauseChatForm{padding:12px 16px;flex-shrink:0}
 #game .pause-chat-close{width:44px;height:44px}
 #game .agent-settings{z-index:45;padding:20px}
 #game .agent-access-grid{grid-template-columns:1fr}
 #game .agent-settings>header{padding-right:42px}
 #game .agent-access-card{min-width:0}
 #game .agent-access-card label{font-size:12px}
 #game .agent-gate{padding:16px max(16px,env(safe-area-inset-right,0px)) calc(16px + env(safe-area-inset-bottom,0px));z-index:50}
 #game .agent-gate>div{max-height:calc(var(--mobile-vh,100dvh) - 32px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));width:100%;padding:24px;overflow-y:auto}
 #game .agent-gate input,#game .agent-gate button{min-height:44px}
 #game .help-panel{inset:calc(8px + env(safe-area-inset-top,0px)) 8px calc(var(--mobile-bottom) + 8px);max-width:none;margin:0;overflow:auto;font-size:14px;z-index:25;background:#faf6ec}
 #game .help-panel small{font-size:12px}
 #game .help-panel{padding:24px 58px 24px 24px}
 .mobile-close-help{display:grid;place-items:center;position:absolute;right:10px;top:10px;width:44px;height:44px;border-radius:50%;background:#e8ecdd;font-size:27px}
 #game .game-toast{top:calc(var(--mobile-top) + 10px);z-index:40;width:calc(100% - 32px);max-width:360px;padding:12px 15px}
 #game .housing-placement-bar{bottom:calc(var(--mobile-bottom) + 64px);left:12px;right:12px;width:auto;max-width:none;font-size:12px}
 #game .computer-modal{padding:calc(8px + env(safe-area-inset-top,0px)) 8px calc(8px + env(safe-area-inset-bottom,0px));z-index:40}
 #game .computer-desktop{max-height:calc(var(--mobile-vh,100dvh) - 160px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));padding:18px 12px}
 #game #closeComputer{width:44px;height:44px;flex-basis:44px}
 #game .computer-shortcuts{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 #game .computer-shortcut{min-height:112px;padding:12px 6px}
 #game .computer-shortcut strong{font-size:12px}
 #game .computer-shortcut small{font-size:10px}
}
@media (max-width:360px){
 #mobileLocation{font-size:10px;max-width:78px}
 #game .brand strong{font-size:21px}
 #game .brand-icon{font-size:25px}
 #game .brand small{letter-spacing:.6px;font-size:5px}
 #game .is-taskboard #agencyResults{grid-template-columns:1fr;gap:16px;padding:22px 16px}
 #game .mission-form-grid{grid-template-columns:1fr}
 #game .is-taskboard .task-postit strong{font-size:16px}
}
@media (max-width:1024px) and (max-height:600px) and (orientation:landscape){
 :root{--mobile-top:calc(54px + env(safe-area-inset-top,0px));--mobile-bottom:calc(58px + env(safe-area-inset-bottom,0px))}
 #game .brand small{display:none}
 #game .mobile-nav{padding-top:3px;padding-bottom:calc(3px + env(safe-area-inset-bottom,0px))}
 .mobile-nav button{flex-direction:row;gap:7px;min-height:44px;font-size:11px}
 #game .mobile-tools{justify-content:flex-end;right:max(12px,env(safe-area-inset-right,0px));bottom:calc(var(--mobile-bottom) + 8px)}
 .mobile-tools button{font-size:11px;min-width:90px;padding:8px 12px}
 #game .is-taskboard #agencyResults{grid-template-columns:repeat(3,minmax(0,1fr))}
 #game .property-card>.card-image{height:64px;min-height:64px}
 #game .mission-form-header,#game .character-header{padding-top:12px;padding-bottom:10px}
 #game .computer-shortcuts{grid-template-columns:repeat(3,minmax(0,1fr))}
 #game .computer-welcome p,#game .computer-welcome>span{display:none}
 #game .agency-panel-header,#game .is-taskboard .agency-panel-header{min-height:0;padding-top:10px;padding-bottom:8px}
 #game .agency-panel-tabs .agency-new-postit{flex-basis:auto}
 #game .computer-welcome{margin-bottom:12px}
 #game .computer-welcome h2{font-size:23px;margin:4px 0}
}
