/* Final layout rules for phones/tablets; reuse the original live controls. */
#mobileAdventure{display:none}
#joystick,#world,#chargeButton{touch-action:none;user-select:none;-webkit-user-select:none}
.mobile-menu-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.mobile-menu-grid button{min-height:48px;white-space:normal;overflow-wrap:anywhere}
.in-cinema #mobileAdventure{visibility:hidden}
@media(pointer:coarse),(max-width:700px){
 #hud{top:max(8px,env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right));gap:6px;align-items:flex-start}
 #hud .player{width:43%;max-width:230px;min-width:0;padding:6px;gap:5px}
 #hud .crest{display:none}
 #hud .player-data{min-width:0}
 #hud .row{gap:4px;font-size:10px;flex-wrap:wrap;line-height:1.3}
 #hud .row span{font-size:10px;overflow-wrap:anywhere}
 #hud .bar{margin-top:4px;height:18px}
 #hud .bar span{font-size:10px;white-space:nowrap}
 #hud .wallet{max-width:55%;min-width:0;gap:4px!important;padding:4px}
 #hud .coin{display:none}
 #hud .wallet b{min-width:0;font-size:12px;overflow-wrap:anywhere}
 #hud .wallet small{font-size:10px}
 #hud .wallet button{flex:none;min-width:44px;width:44px;height:44px}
 #hud #accountButton{font-size:10px;padding:3px;white-space:normal;line-height:1.2;overflow-wrap:anywhere}
 #mobileAdventure{display:block;position:absolute;top:calc(74px + env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));z-index:7;min-height:44px;width:145px;padding:8px;background:#142940ed;border:1px solid #a8bddd55;border-radius:8px;font-size:13px;touch-action:manipulation}
 #questDock{left:max(8px,env(safe-area-inset-left));right:auto;top:calc(124px + env(safe-area-inset-top));width:min(185px,44vw);max-height:28dvh;gap:0}
 #questDock #quest{padding:9px;max-height:28dvh;overflow:auto;overscroll-behavior:contain}
 #questDock #quest h2{font-size:15px;margin:7px 0}
 #questDock #quest p{font-size:12px;line-height:1.35;margin-bottom:6px}
 #questDock #track{min-height:44px;width:100%;text-align:left}
 #questDock .exp-top{display:none}
 #zone,#controls{display:none}
 #mapBox{top:calc(74px + env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));width:78px;padding:4px}
 #mapBox #map{width:100%;height:auto}
 #mapBox>span{display:none}
 #combatDock{right:max(8px,env(safe-area-inset-right));left:auto;bottom:max(8px,env(safe-area-inset-bottom));width:min(240px,50vw);max-height:calc(100dvh - 172px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:6px;gap:5px;overflow-y:auto;touch-action:pan-y;overscroll-behavior:contain}
 #combatDock::before{display:none}
 #combatDock #combatStatus{order:0}
 #combatDock #hotbar{order:1}
 #combatDock .exp-actions{order:2}
 #combatDock #blessingHud{order:3}
 #combatDock #hotbar,#combatDock .exp-actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}
 #combatDock #hotbar button{display:flex;justify-content:center;align-items:center}
 #combatDock #hotbar kbd{display:none}
 #combatDock #hotbar button,#combatDock .exp-actions button{min-height:48px;padding:5px;font-size:11px;line-height:1.25;text-align:center}
 #combatDock #hotbar span{font-size:12px}
 #combatDock #weaponName{font-size:11px;line-height:1.25;display:block;overflow-wrap:anywhere}
 #combatDock #blessingEquipped{min-height:44px;padding:5px;font-size:11px;text-align:left}
 #combatDock #blessingHud>div{grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
 #combatDock #blessingHud [data-blessing-cast]{display:flex;flex-direction:column;justify-content:center;gap:3px;min-height:72px;padding:5px 2px;text-align:center}
 #combatDock #blessingHud [data-blessing-cast] kbd{display:none}
 #combatDock #blessingHud [data-blessing-cast] span{font-size:10px;line-height:1.2;text-align:center}
 #combatDock #blessingHud [data-blessing-cast] small{font-size:10px;text-align:center}
 #joystick{left:max(10px,env(safe-area-inset-left));right:auto;bottom:max(12px,env(safe-area-inset-bottom));width:96px;height:96px;z-index:5;touch-action:none}
 #joystick i{left:26px;top:26px}
 #movementButtons{left:max(8px,env(safe-area-inset-left));right:auto;bottom:calc(120px + env(safe-area-inset-bottom));width:100px;display:flex;flex-direction:column;gap:5px}
 #movementButtons button{min-height:44px;padding:6px;font-size:11px}
 #movementButtons kbd{display:none}
 #direction{left:max(8px,env(safe-area-inset-left));right:auto;top:auto;bottom:calc(222px + env(safe-area-inset-bottom));width:calc(50vw - 20px);max-width:180px;transform:none;padding:5px}
 #direction b{font-size:10px;overflow-wrap:anywhere}
 #prompt{left:50%;right:auto;top:auto;bottom:calc(320px + env(safe-area-inset-bottom));transform:translateX(-50%);max-width:calc(100vw - 16px);min-height:44px;padding:8px 12px;font-size:12px;z-index:7}
 .in-boss-fight #bossHud{top:calc(74px + env(safe-area-inset-top));left:auto;right:8px;transform:none;width:calc(100vw - 169px);max-width:340px}
 body #toasts,body:not(.in-boss-fight) #toasts{left:8px;top:calc(126px + env(safe-area-inset-top));bottom:auto;max-height:22dvh;width:min(220px,44vw);overflow:hidden}
 dialog,#modal,dialog:has(.talent-map){width:calc(100vw - 16px);max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:16px;overscroll-behavior:contain;scrollbar-gutter:stable;touch-action:pan-y}
 #modalBody{min-width:0;overflow-wrap:anywhere}
 dialog h1{font-size:25px}dialog h2{font-size:21px}dialog p{font-size:14px;line-height:1.5}
 dialog .actions{gap:8px;margin-top:16px}dialog .actions button{flex:1 1 120px;min-height:48px;padding:10px;white-space:normal}
 dialog .shop-item{flex-wrap:wrap;gap:8px}.shop-item>div{flex:1 1 130px}.shop-item button{min-height:44px;max-width:100%;white-space:normal}
 .odds{grid-template-columns:minmax(0,1fr) minmax(65px,40%);gap:10px;font-size:12px}.odds b{overflow-wrap:anywhere;text-align:right}
 .gacha-result{padding:14px}.gacha-result canvas{max-width:100%}
 .sword-mastery-notice{top:calc(124px + env(safe-area-inset-top));bottom:auto;left:8px;width:calc(100vw - 16px);max-width:320px;max-height:30dvh}
 .sword-mastery-notice button{min-height:44px}
 .game-update{top:auto;bottom:max(8px,env(safe-area-inset-bottom));max-width:calc(100vw - 16px);padding:8px;flex-wrap:wrap;justify-content:center}.game-update button{min-height:44px}
}
@media(max-width:480px){#mapBox{display:none}.mobile-menu-grid{grid-template-columns:1fr}.keys{grid-template-columns:1fr}}
@media(max-height:540px) and (pointer:coarse){
 #hud .player{width:200px;max-width:30vw}
 #mobileAdventure{top:calc(66px + env(safe-area-inset-top));width:135px}
 #questDock{top:calc(116px + env(safe-area-inset-top));width:190px;max-height:calc(100dvh - 236px)}
 #questDock #quest{max-height:calc(100dvh - 236px)}
 #combatDock{width:min(240px,34vw);max-height:calc(100dvh - 78px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
 #movementButtons{left:calc(116px + env(safe-area-inset-left));bottom:max(12px,env(safe-area-inset-bottom));width:90px}
 #direction{left:155px;top:calc(66px + env(safe-area-inset-top));bottom:auto;width:160px;max-width:25vw}
 #prompt{left:50%;bottom:max(12px,env(safe-area-inset-bottom));max-width:calc(100vw - 490px);min-width:110px;font-size:11px}
 .in-boss-fight #bossHud{top:calc(8px + env(safe-area-inset-top));right:auto;left:32%;width:33vw;max-width:300px}
 .sword-mastery-notice{top:66px;left:8px;width:min(320px,45vw);max-height:45dvh}
 .game-update{left:50%;bottom:max(8px,env(safe-area-inset-bottom));max-width:60vw}
}

.island-unlock-notice{position:fixed;top:92px;left:50%;transform:translateX(-50%);width:min(360px,90vw);padding:14px;z-index:8;font-size:14px;max-height:35dvh;overflow:auto;touch-action:pan-y;overscroll-behavior:contain}
.island-unlock-notice strong{color:var(--gold)}.island-unlock-notice p{line-height:1.45;margin:8px 0}.island-unlock-notice .actions{display:flex;gap:8px}.island-unlock-notice button{min-height:44px;padding:8px 12px;border-radius:6px;background:#284462;font-size:13px}
@media(pointer:coarse),(max-width:700px){.island-unlock-notice{top:calc(124px + env(safe-area-inset-top));max-height:35dvh;width:calc(100vw - 16px);max-width:360px;font-size:13px}}
@media(max-height:540px){.island-unlock-notice{top:72px;max-height:55dvh}}

#combatDock button,#movementButtons button,#mobileAdventure,#prompt{touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#combatDock #chargeButton{touch-action:none}.graphics-settings label{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin:16px 0}.graphics-settings select{max-width:100%;padding:10px;background:#142f45;color:#eefaff;border:1px solid #79adc166;border-radius:6px}
