/* Measured viewport bounds shared by the editor and saved layouts. */
.hud-safe-bounds{position:fixed;inset:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));visibility:hidden;pointer-events:none}
body .hud-custom-position{position:fixed!important;left:var(--hud-x)!important;top:var(--hud-y)!important;right:auto!important;bottom:auto!important;width:var(--hud-width)!important;max-width:calc(100vw - 20px)!important;margin:0!important;transform:none!important}
#hud-layout-editor{position:fixed;inset:0;z-index:9000;pointer-events:none;background:linear-gradient(#0002,#0000 45%,#0002);touch-action:none}
#hud-layout-editor[hidden]{display:none}
.hud-editor-bar{pointer-events:auto;position:absolute;top:max(88px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);width:min(430px,calc(100% - 24px));padding:10px;background:#221d14f5;border:1px solid #bda574;border-radius:6px;box-shadow:0 4px 18px #0008;z-index:2;font:14px/1.35 system-ui,sans-serif;color:#f2e4c5}
.hud-editor-bar strong{display:block;margin-bottom:6px}.hud-editor-bar small{font-weight:400;color:#cfbc94}
.hud-editor-pickers,.hud-editor-buttons{display:flex;gap:6px;margin-bottom:6px}
.hud-editor-bar button,.hud-editor-bar select{min-width:0;flex:1;min-height:44px;padding:6px;background:#34291c;color:#f2e4c5;border:1px solid #a98f5b;border-radius:4px;font:14px system-ui;touch-action:manipulation}
.hud-editor-bar [data-hud=save]{background:#ad8d52;color:#16130d;font-weight:650}
.hud-editor-bar output{display:block;font-size:12px;color:#d4c4a3}
.hud-editor-handles>button{position:fixed;pointer-events:auto;touch-action:none;min-height:24px;min-width:24px;margin:0;padding:3px;border:1px dashed #e2c785;background:#ac813a28;border-radius:4px;box-shadow:inset 0 0 0 1px #17120cc0;color:#fff0c5;font:12px/1.2 system-ui;text-shadow:0 1px 2px #000;display:flex;align-items:flex-start;justify-content:center;cursor:move;overflow:hidden}
.hud-editor-handles>button.selected{border:2px solid #fae0a0;background:#e8b95945}
body[data-hud-editing=true] #scene,body[data-hud-editing=true] #cellar-scene{cursor:default}
@media(orientation:landscape) and (max-height:600px){.hud-editor-bar{top:8px;width:min(420px,calc(100% - 270px));padding:6px}.hud-editor-bar strong{font-size:13px;margin-bottom:3px}.hud-editor-bar output{font-size:11px}}

/* Canonical compact default: separate thumb zones, clear centre, mirrored hands. */
body[data-controls=stick].hud-collapsed{--hud-near:max(12px,env(safe-area-inset-left));--hud-far:max(12px,env(safe-area-inset-right));--hud-base:max(12px,env(safe-area-inset-bottom))}
body[data-controls=stick].hud-collapsed #game-shell #move-stick{left:var(--hud-near);right:auto;bottom:var(--hud-base);width:128px;height:128px}
body[data-controls=stick].hud-collapsed #move-stick .stick-knob{left:40px;top:40px}
body[data-controls=stick].hud-collapsed #game-shell #quick-actions{left:auto;right:var(--hud-far);bottom:calc(var(--hud-base) + 62px);display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:174px;gap:6px}
body[data-controls=stick].hud-collapsed #quick-actions button{width:100%;min-width:0;max-width:none;min-height:48px;font-size:14px;padding:6px;line-height:1.2}
body[data-controls=stick].hud-collapsed #game-shell #quick-vitals{left:var(--hud-near);right:auto;bottom:calc(var(--hud-base) + 138px)}
body[data-controls=stick].hud-collapsed #game-shell .hud-tabs{position:fixed;right:var(--hud-far);left:auto;bottom:var(--hud-base);margin:0;width:174px;max-width:none;gap:4px}
body[data-controls=stick].hud-collapsed #game-shell .hud-tabs button{min-height:48px;font-size:11px;white-space:normal}
body[data-controls=stick].hud-collapsed #game-shell .story-peek{left:var(--hud-near);right:var(--hud-far);bottom:calc(var(--hud-base) + 182px);width:auto;min-height:44px;max-height:58px;background:#14170f88}
body[data-controls=stick].hud-collapsed #game-shell .world-tools{position:fixed;left:var(--hud-near);right:var(--hud-far);bottom:calc(var(--hud-base) + 252px);width:auto}
body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell #move-stick,body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell #quick-vitals{left:auto;right:var(--hud-far)}
body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell #quick-actions,body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell .hud-tabs{right:auto;left:var(--hud-near)}
body[data-controls=stick].inside-inn.hud-collapsed #game-shell #inn-shortcuts{position:fixed;left:var(--hud-near);right:var(--hud-far);bottom:calc(var(--hud-base) + 62px);margin:0;width:auto;gap:6px;display:grid;grid-template-columns:repeat(4,minmax(0,1fr))}
body[data-controls=stick].inside-inn.hud-collapsed #game-shell #inn-shortcuts button{min-height:48px;font-size:14px;padding:6px}
#inn-primary{display:none}
body[data-controls=stick].inside-inn.hud-collapsed #game-shell #inn-primary{display:block;position:fixed;bottom:var(--hud-base);left:var(--hud-near);right:auto;width:min(164px,calc(100vw - 210px));min-height:48px;padding:6px;font-size:14px;pointer-events:auto}
body[data-controls=stick][data-stick-side=right].inside-inn.hud-collapsed #game-shell #inn-primary{left:auto;right:var(--hud-far)}
#inn-shortcuts button[aria-current=true]{border-color:#ddc485;box-shadow:inset 0 -2px #ddc485}
body[data-controls=stick].inside-inn.hud-collapsed #game-shell .story-peek{left:var(--hud-near);right:var(--hud-far);bottom:calc(var(--hud-base) + 124px);width:auto}
body[data-controls=stick].inside-inn.hud-collapsed #game-shell .world-tools{bottom:calc(var(--hud-base) + 192px)}
body[data-controls=stick].hud-collapsed #game-shell .hud-tools button{width:44px;min-width:44px;height:44px;min-height:44px}
#game-shell .scene-top{left:0;right:0}
#game-shell .location-time #location{font-size:clamp(17px,4.5vw,24px);line-height:1.25;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#game-shell #world-weather{min-height:44px;pointer-events:auto}
#game-shell .heading-strip{top:86px}
#game-shell #scene-map-button{top:112px}
/* Keep essential navigation fixed even after the user moves the location label. */
#game-shell .hud-tools,.cellar-header nav{position:fixed;top:max(6px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));z-index:50}
#game-shell .location-time{max-width:calc(100% - 148px)}
#game-shell .hud-custom-position.location-time{max-width:calc(100vw - 164px)!important}
#notice{pointer-events:none}
#game-shell #notice{position:absolute;top:180px;left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));height:28px;min-height:0;margin:0;align-self:start;z-index:12}
#game-shell #guardian-status{top:112px;max-width:calc(100% - 108px);font-size:13px}
#game-shell #encounter{position:absolute;top:112px;left:12px;margin:0;width:min(240px,calc(100% - 108px));max-height:calc(100dvh - 340px);overflow:auto;touch-action:pan-y}
#game-shell #encounter h2{font-size:18px;margin:0 0 4px}
#game-shell #encounter p{font-size:13px;margin:3px 0}
#modal .graphics-option{display:flex;flex-wrap:wrap;gap:6px;min-height:48px;margin:8px 0;align-items:center;justify-content:space-between}
#modal .graphics-option select{max-width:100%;min-width:0;min-height:44px;font-size:15px}
#drawer-body,#modal-body,#cellar-dialog-body{touch-action:pan-y;overscroll-behavior:contain}
#game-drawer .drawer-header,#modal .modal-header{padding:8px 12px}
#game-drawer .drawer-header h2,#modal .modal-header h2{font-size:23px;line-height:1.2}
#game-drawer .drawer-header button,#modal .modal-header button{min-width:44px;min-height:44px}
#inn-panel .inn-party{grid-template-columns:minmax(0,1fr)}
#inn-panel .inn-party .arrival-card{grid-template-columns:48px minmax(0,1fr) 86px}
#inn-panel .arrival-card>img{width:48px!important;height:60px!important}
#cellar-dialog[open]{display:flex;flex-direction:column;overflow:hidden}
#cellar-dialog header,#cellar-dialog-return{flex-shrink:0}
#cellar-dialog-body{overflow:auto;min-height:0}
#cellar-dialog-return{min-height:44px}
@media(orientation:landscape) and (max-height:600px){
 body[data-controls=stick].hud-collapsed #game-shell .story-peek{left:162px;right:204px;width:auto;bottom:var(--hud-base);max-height:58px}
 body[data-controls=stick].hud-collapsed #game-shell .world-tools{left:162px;right:204px;width:auto;bottom:calc(var(--hud-base) + 74px)}
 body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell .story-peek,body[data-controls=stick][data-stick-side=right].hud-collapsed #game-shell .world-tools{left:204px;right:162px}
 body[data-controls=stick].inside-inn.hud-collapsed #game-shell #inn-shortcuts{left:var(--hud-near);right:auto;width:330px;bottom:var(--hud-base)}
 body[data-controls=stick].inside-inn.hud-collapsed #game-shell #inn-primary{left:auto;right:var(--hud-far);bottom:calc(var(--hud-base) + 62px);width:174px}
 body[data-controls=stick][data-stick-side=right].inside-inn.hud-collapsed #game-shell #inn-primary{right:auto;left:var(--hud-near)}
 body[data-controls=stick].inside-inn.hud-collapsed #game-shell .story-peek{left:var(--hud-near);right:204px;bottom:calc(var(--hud-base) + 62px);width:auto}
 body[data-controls=stick].inside-inn.hud-collapsed #game-shell .world-tools{left:var(--hud-near);right:204px;bottom:calc(var(--hud-base) + 130px)}
 body[data-controls=stick][data-stick-side=right].inside-inn.hud-collapsed #game-shell #inn-shortcuts{left:auto;right:var(--hud-far)}
 body[data-controls=stick][data-stick-side=right].inside-inn.hud-collapsed #game-shell .story-peek,body[data-controls=stick][data-stick-side=right].inside-inn.hud-collapsed #game-shell .world-tools{left:204px;right:var(--hud-far)}
 #game-shell .heading-strip{top:76px}#game-shell #scene-map-button{top:98px;width:58px;height:58px}
 #game-shell #notice{top:90px;left:28%;right:23%}
 #game-shell #guardian-status{top:122px;left:28%;max-width:45%}
 #game-shell #encounter{top:122px;left:28%;max-width:45%;max-height:calc(100dvh - 190px)}
 #game-shell .game-controls{touch-action:pan-y;overscroll-behavior:contain}
 #modal,#game-drawer{max-height:calc(100dvh - 16px)!important}
 #modal .menu-actions button{min-height:48px}#modal .menu-actions strong{font-size:16px}
 #cellar-dialog{max-height:calc(100dvh - 16px)}
}
@media(max-width:359px){body[data-controls=stick].hud-collapsed #game-shell #move-stick{width:112px;height:112px}body[data-controls=stick].hud-collapsed #move-stick .stick-knob{left:32px;top:32px}body[data-controls=stick].hud-collapsed #game-shell #quick-actions,body[data-controls=stick].hud-collapsed #game-shell .hud-tabs{width:158px}.cellar-actions{width:154px}#cellar-stick{width:118px;height:118px}#cellar-stick .stick-knob{left:35px;top:35px}}
