/* Immersive landscape phone layout. Portrait uses the existing layout. */
.phone-chat-toggle{display:none}
body.r2-phone-immersive{--phone-left:max(8px,env(safe-area-inset-left));--phone-right:max(8px,env(safe-area-inset-right));--phone-bottom:max(8px,env(safe-area-inset-bottom));font-size:13px}
body.r2-phone-immersive .top-bar,body.r2-phone-immersive #locLandscapeLeftHead,body.r2-phone-immersive #locMobileQuickActions,body.r2-phone-immersive .mobile-chat-tools,body.r2-phone-immersive .mobile-hotbar-edit,body.r2-phone-immersive .mobile-monsters-details>summary,body.r2-phone-immersive .preview-chat-plus,body.r2-phone-immersive .r2-mobile-field-nav,body.r2-phone-immersive .r2-mobile-actions{display:none!important}
body.r2-phone-immersive #locMainPanel{display:contents!important}
body.r2-phone-immersive #locationMapWrap{touch-action:manipulation}
body.r2-phone-immersive #locationMapMarkers .loc-marker{height:clamp(90px,31vh,170px)!important}
body.r2-phone-immersive #locMainPanel .loc-vital-bars{left:calc(var(--phone-left) + 112px)!important;bottom:var(--phone-bottom)!important;transform:none!important;width:clamp(164px,24vw,210px)!important;padding:5px!important;gap:3px!important}
body.r2-phone-immersive .loc-vital-bar{height:17px!important;font-size:11px!important}
body.r2-phone-immersive #locMainPanel .loc-hotbar-wrap{left:auto!important;right:var(--phone-right)!important;bottom:var(--phone-bottom)!important;width:clamp(320px,44vw,384px)!important;padding:2px!important}
body.r2-phone-immersive #locHotbar{width:100%!important;height:auto!important;aspect-ratio:4/1!important;min-height:0!important}
body.r2-phone-immersive #locHotbarGrid{inset:0!important;width:100%!important;height:100%!important}
body.r2-phone-immersive .r2-desktop-menu{left:var(--phone-left)!important;bottom:var(--phone-bottom)!important}
body.r2-phone-immersive .r2-desktop-menu-toggle{height:48px;width:100px;padding:4px;font-size:13px}
body.r2-phone-immersive .r2-desktop-command{min-height:44px;font-size:14px}
body.r2-phone-immersive .r2-desktop-commands{max-height:calc(100dvh - 78px);width:260px;bottom:54px;overscroll-behavior:contain}
body.r2-phone-immersive #locationsSidePanel{display:none!important}
body.r2-phone-immersive #r2MobilePlayersButton:not([hidden]){display:block!important;position:fixed!important;left:auto!important;right:calc(var(--phone-right) + 58px)!important;top:8px!important;bottom:auto!important;height:44px!important;min-height:44px!important;width:76px!important;z-index:125!important;background:#24291ddd!important;border:1px solid #a99961!important;color:#efe7cb!important;font-size:12px!important}
body.r2-phone-immersive #locBtnBackDomains{top:8px!important;left:calc(var(--phone-left) + 98px)!important;min-height:44px!important;padding:6px 10px!important}
body.r2-phone-immersive .immersive-monster-help:not([hidden]){top:8px;right:var(--phone-right);width:44px;height:44px}
body.r2-phone-immersive .immersive-nav .loc-field-arrow{width:48px!important;height:76px!important;top:46%!important;font-size:38px!important;opacity:.65}
body.r2-phone-immersive .immersive-nav #locFieldPrev{left:var(--phone-left)!important}
body.r2-phone-immersive .immersive-nav #locFieldNext{right:var(--phone-right)!important}
body.r2-phone-immersive .phone-chat-toggle{display:block;position:fixed;left:var(--phone-left);top:8px;z-index:150;width:90px;height:44px;color:#efe7cb;background:#24291ddd;border:1px solid #a99961;border-radius:5px;font:14px Arial}
body.r2-phone-immersive #historySection{display:none!important}
body.r2-phone-immersive.phone-chat-open #historySection{display:flex!important;left:var(--phone-left)!important;top:58px!important;bottom:108px!important;height:auto!important;width:min(350px,48vw)!important;z-index:160!important;background:#0a100ef5!important}
body.r2-phone-immersive #historySection .loc-chat-head{min-height:44px!important;flex-basis:44px!important}
body.r2-phone-immersive #historySection .loc-chat-tab{min-height:40px!important;font-size:12px!important}
body.r2-phone-immersive #historySection input{font-size:16px!important}
body.r2-phone-immersive #historySection .global-chat-send-btn{min-height:40px}
body.r2-phone-immersive .preview-extra-chat{display:none!important}
body.r2-phone-immersive .npc-travel-dialog-host,body.r2-phone-immersive .npc-village-dialog-host,body.r2-phone-immersive .domains-pick-grid{left:clamp(58px,var(--npc-dialog-x,64px),calc(100vw - 340px))!important;top:clamp(8px,var(--npc-dialog-y,60px),calc(100dvh - min(280px,100dvh - 114px) - 100px))!important;width:300px!important;max-width:calc(100vw - 116px)!important;height:min(280px,calc(100dvh - 114px))!important;max-height:calc(100dvh - 114px)!important}
body.r2-phone-immersive .npc-travel-dialog{font-size:14px!important}
body.r2-phone-immersive .npc-travel-dialog__title{min-height:34px!important;font-size:12px!important}
body.r2-phone-immersive .npc-travel-dialog button{min-height:40px!important}
body.r2-phone-immersive #monstersSidePanel{width:calc(100vw - 116px)!important;height:calc(100dvh - 32px)!important;max-height:calc(100dvh - 32px)!important;grid-template-columns:160px minmax(0,1fr)!important;grid-template-rows:24px 20px minmax(0,1fr)!important;padding:12px!important;gap:5px 10px!important;z-index:200100!important}
body.r2-phone-immersive .immersive-monster-close{width:44px;height:44px;right:2px;top:0}
body.r2-phone-immersive #monstersSidePanel .monster-card{min-height:48px;padding:8px!important}
body.r2-phone-immersive #monsterSpriteBox,body.r2-phone-immersive #monsterSprite{height:90px!important;min-height:90px!important;max-height:90px!important}
body.r2-phone-immersive #monsterDropIcons{grid-template-columns:repeat(auto-fill,minmax(90px,1fr))!important}
body.r2-phone-immersive #locBuffBar{top:60px!important;right:60px!important;max-width:180px!important}
body.r2-phone-immersive:not(.r2-trade-picking) #locInventoryOverlay #locInventoryHub.loc-inventory-overlay__panel{top:8px!important;bottom:auto!important;right:var(--phone-right)!important;left:auto!important;transform:none!important;max-height:calc(100dvh - 16px)!important;max-width:calc(100vw - 32px)!important;overflow-y:auto!important}
body.r2-phone-immersive.phone-keyboard-open #historySection{top:6px!important;bottom:auto!important;height:calc(var(--phone-visible-height,100dvh) - 12px)!important;width:calc(100vw - 112px)!important;z-index:200200!important}
body.r2-phone-immersive.phone-keyboard-open .phone-chat-toggle{left:auto;right:var(--phone-right);z-index:200201}
body.r2-phone-immersive .npc-travel-dialog-host,body.r2-phone-immersive .npc-village-dialog-host,body.r2-phone-immersive .domains-pick-grid{top:clamp(56px,var(--npc-dialog-y,58px),calc(100dvh - min(280px,100dvh - 164px) - 100px))!important;height:min(280px,calc(100dvh - 164px))!important;max-height:calc(100dvh - 164px)!important}
body.r2-phone-immersive .npc-travel-dialog__title{height:44px!important;min-height:44px!important;flex:0 0 44px!important;padding-right:46px!important}
body.r2-phone-immersive .npc-travel-dialog__close{width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important;top:0!important;right:0!important;font-size:20px!important}
body.r2-phone-immersive .npc-travel-link{font-size:14px!important;line-height:1.35!important}
body.r2-phone-immersive .npc-travel-dialog__close{transform:none!important;display:flex!important;align-items:center!important;justify-content:center!important;line-height:1!important;padding:0!important}
/* Revision 2: compact phone windows. */
body.r2-phone-immersive .npc-travel-dialog-host,body.r2-phone-immersive .npc-village-dialog-host{width:260px!important;left:clamp(54px,var(--npc-dialog-x,58px),calc(100vw - 278px))!important}
body.r2-phone-immersive .npc-travel-dialog__title{height:34px!important;min-height:34px!important;flex-basis:34px!important}
body.r2-phone-immersive .npc-travel-dialog__close{height:34px!important;min-height:34px!important;width:38px!important;min-width:38px!important}
body.r2-phone-immersive .npc-travel-dialog__body{padding:6px 8px!important;font-size:12px!important;line-height:1.25!important}
body.r2-phone-immersive .npc-travel-dialog__body p,body.r2-phone-immersive .npc-travel-dialog__greet,body.r2-phone-immersive .npc-travel-dialog__prompt{margin:0 0 4px!important}
body.r2-phone-immersive .npc-travel-dialog__links{gap:0!important;padding-bottom:2px!important}
body.r2-phone-immersive .npc-travel-dialog .npc-travel-link{min-height:30px!important;padding:4px 1px!important;font-size:12px!important;line-height:1.2!important;margin:0!important}
body.r2-phone-immersive .r2-desktop-commands:not([hidden]){display:grid;grid-template-columns:1fr 1fr;gap:3px;width:min(350px,calc(100vw - 24px));max-height:210px;padding:5px}
body.r2-phone-immersive .r2-desktop-menu-title{display:none}
body.r2-phone-immersive .r2-desktop-command{min-height:44px;font-size:12px;gap:5px;padding:4px}
body.r2-phone-immersive .r2-desktop-command-icon{flex-basis:22px;font-size:16px;height:22px}
body.r2-phone-immersive .r2-desktop-command-separator{margin:0;border-top:0}
body.r2-phone-immersive #r2MobilePlayersOverlay{padding:8px;align-items:flex-start;justify-content:flex-start;background:#0003}
body.r2-phone-immersive #r2MobilePlayersDialog{width:252px;max-height:min(230px,calc(100dvh - 24px));border-radius:6px;margin-top:48px;margin-left:clamp(0px,calc(var(--phone-left) + 90px),calc(100vw - 276px))}
body.r2-phone-immersive #r2MobilePlayersDialog header{padding:2px 7px;gap:5px}
body.r2-phone-immersive #r2MobilePlayersDialog h2{font-size:13px}
body.r2-phone-immersive #r2MobilePlayersDialog .r2-mobile-players-content{padding:5px}
body.r2-phone-immersive #r2MobilePlayersDialog .location-presence-item{font-size:12px;padding:4px 6px;min-height:34px}
body.r2-phone-immersive.loc-inventory-native.inventory-overlay-mode #locInventoryHub .loc-inv-hub-main{zoom:var(--phone-inv-scale,1)!important;width:var(--phone-inv-width,400px)!important;max-width:none!important;transform:none!important}
body.r2-phone-immersive.loc-inventory-native.inventory-overlay-mode #locInventoryHub .image-inventory-wrapper{width:400px!important;max-width:400px!important;height:598px!important;min-height:598px!important;max-height:none!important;transform:none!important}
body.r2-phone-immersive:not(.r2-trade-picking) #locInventoryOverlay #locInventoryHub.loc-inventory-overlay__panel{width:max-content!important;padding:0!important;overflow:visible!important}

/* Keep dialogs usable when the browser address bar reduces landscape height. */
body.r2-phone-immersive #locationMapWrap :is(.npc-travel-dialog-host,.npc-village-dialog-host,.domains-pick-grid){width:min(320px,calc(100vw - 116px))!important;max-width:calc(100vw - 116px)!important;height:min(340px,calc(100dvh - 72px))!important;max-height:calc(100dvh - 72px)!important;left:clamp(8px,var(--npc-dialog-x,58px),calc(100vw - min(320px,100vw - 116px) - 8px))!important;top:clamp(0px,var(--npc-dialog-y,8px),calc(100dvh - min(340px,100dvh - 72px) - 8px))!important;z-index:170!important}
body.r2-phone-immersive #locationMapWrap .npc-travel-dialog{display:flex!important;flex-direction:column!important;resize:none!important}
body.r2-phone-immersive #locationMapWrap .npc-travel-dialog__body{display:block!important;flex:1 1 0!important;min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain;font-size:13px!important;line-height:1.3!important;padding:6px 8px!important;touch-action:pan-y}
body.r2-phone-immersive #locationMapWrap .npc-travel-dialog__scroll{overflow:visible!important;max-height:none!important;padding:0!important;font-size:inherit!important}
body.r2-phone-immersive #locationMapWrap .npc-travel-dialog__actions{overflow:visible!important;max-height:none!important;padding:4px 0!important}
body.r2-phone-immersive #locationMapWrap .npc-travel-link{font-size:13px!important;line-height:1.3!important;min-height:32px!important}
body.r2-phone-immersive #locQuestHud{position:fixed!important;top:60px!important;left:var(--phone-left)!important;max-width:min(260px,42vw)!important;max-height:calc(100dvh - 170px);overflow:auto;pointer-events:auto}
body.r2-phone-immersive:not(.r2-trade-picking) #locInventoryOverlay #locInventoryHub.loc-inventory-overlay__panel.is-drag-positioned{left:clamp(0px,var(--phone-inv-x,0px),calc(100vw - var(--phone-inv-rendered-width,260px)))!important;top:clamp(0px,var(--phone-inv-y,8px),calc(100dvh - var(--phone-inv-rendered-height,260px)))!important;right:auto!important;bottom:auto!important}

/* Native non-modal top layer lifts only the dialog, leaving the field HUD visible. */
body.r2-phone-immersive #locationMapWrap [data-phone-npc-layer]{margin:0!important;right:auto!important;bottom:auto!important;padding:0!important;border:0!important;background:transparent!important;color:inherit;overflow:visible!important}
body.r2-phone-immersive #locationMapWrap [data-phone-npc-layer]::backdrop{background:transparent;pointer-events:none}
#locQuestHud .quest-hud-toggle{pointer-events:auto;display:block;min-height:28px;padding:3px 7px;border:1px solid #a99961;border-radius:4px;background:#25291ee8;color:#f6e7b4;font:12px/1.3 Arial;cursor:pointer;margin-bottom:4px}
#locQuestHud.quest-hud-collapsed>:not(.quest-hud-toggle){display:none!important}
#locQuestHud.quest-hud-collapsed{min-width:0!important;width:max-content!important;padding:3px!important}
#locQuestHud.quest-hud-collapsed .quest-hud-toggle{margin:0}

/* Top row: chat and players on the left, buffs and bestiary on the right. */
body.r2-phone-immersive #locBtnBackDomains{display:none!important}
body.r2-phone-immersive #r2MobilePlayersButton:not([hidden]){left:calc(var(--phone-left) + 98px)!important;right:auto!important}
body.r2-phone-immersive #locBuffBar{position:fixed!important;top:8px!important;right:calc(var(--phone-right) + 58px)!important;left:auto!important;max-width:min(180px,calc(100vw - 264px))!important;flex-wrap:wrap!important;justify-content:flex-end!important}

body.r2-phone-immersive.r2-npc-action-open #locationMapWrap :is(.npc-travel-dialog-host,.npc-village-dialog-host,.domains-pick-grid){visibility:hidden!important;pointer-events:none!important}
