:root{--visible-height:100dvh;--keyboard-top:0px}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
button,a,input,select,textarea{touch-action:manipulation}
[data-move]{touch-action:none;user-select:none;-webkit-user-select:none}
dialog.game-dialog{overscroll-behavior:contain;-webkit-overflow-scrolling:touch;max-height:calc(var(--visible-height) - 24px)}
.touch-controls[hidden],.h5-play[hidden]{display:none!important}
.h5-play{position:absolute;inset:45% auto auto 50%;transform:translateX(-50%);z-index:35;min-height:48px;padding:12px 24px;background:#191b17e8;border:1px solid #d7bf85;color:#fff0d2;font-size:18px}
@media(pointer:coarse),(max-width:767px){
 html,body{height:auto;min-height:100%;overflow-x:clip;overflow-y:auto}
 .game{height:auto;min-height:100svh;padding-top:clamp(300px,48svh,440px);padding-bottom:max(20px,env(safe-area-inset-bottom));overflow:visible}
 .world-stage{height:clamp(300px,48svh,440px);bottom:auto}
 .hud-top{top:max(12px,env(safe-area-inset-top));left:max(16px,env(safe-area-inset-left));right:max(16px,env(safe-area-inset-right))}
 .hud-button{min-width:44px;min-height:44px}.game-brand h1{font-size:20px!important}
 .game-brand small,.chapter-hud,.quest-hud,.identity-hud,.controls-help{display:none!important}
 .touch-controls{display:flex;top:calc(clamp(300px,48svh,440px) - 62px);left:max(16px,env(safe-area-inset-left));gap:12px}
 .touch-controls button{width:48px;height:48px}
 .world-prompt{top:calc(clamp(300px,48svh,440px) - 118px);min-height:44px}
 .dialogue-hud{position:relative;left:auto;right:auto;bottom:auto;transform:none;width:calc(100% - 16px);margin:0 8px;max-height:none;padding:22px 24px}
 .choice-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .choice,.custom-choice{min-height:118px!important;white-space:normal}
 .choice-title{font-size:18px}.choice-hint{font-size:14px!important;overflow-wrap:anywhere}
 .narration-row p,.has-story .narration-row p{max-height:none;overflow:visible;font-size:16px}
 .game-dialog select,.game-dialog textarea{font-size:16px!important}
 dialog.game-dialog{width:calc(100vw - 20px)!important;padding:68px 26px 28px;margin:auto;overflow:auto;max-height:calc(var(--visible-height) - 24px)}
 .keyboard-open dialog[open]{position:fixed;top:calc(var(--keyboard-top) + 12px);bottom:auto;margin:0 auto}
 .custom-dialog textarea{min-height:110px!important;max-height:28svh}
 .custom-dialog .custom-footer{display:flex;flex-wrap:wrap;gap:8px}
 .custom-dialog .custom-footer .primary{width:100%;min-width:0}
 .custom-dialog .input-help{display:none}
 .history-dialog .tree-body,.history-dialog .tree-body.tree-solo{display:block}
 .history-dialog .tree-detail,.tree-body.tree-solo .tree-detail{border-left:0;padding:18px 0 0;margin:18px 0 0;border-top:1px solid #70664d50}
 .tree-canvas{width:100%!important;height:auto!important;display:grid;gap:12px}
 .tree-lines{display:none}.branch-node{position:relative;left:auto!important;top:auto!important;width:100%;min-height:90px}
 .ending-panel,.generation-hud,.preview-ready .generation-hud{position:relative;left:auto;bottom:auto;transform:none;width:calc(100% - 24px);margin:12px;max-height:none}
 .show-dialogue{position:relative;left:auto;bottom:auto;transform:none;margin:16px}
 .game.playing .world-stage>video{object-fit:contain}
 .toast{max-width:calc(100vw - 32px);white-space:normal}
}
@media(max-width:360px){.choice-grid{grid-template-columns:1fr}.choice,.custom-choice{min-height:94px!important}.game-brand h1{font-size:17px!important}.hud-tools{gap:2px}}
@media(pointer:coarse) and (orientation:landscape){.game{padding-top:100svh}.world-stage{height:100svh}.touch-controls{top:calc(100svh - 62px)}.world-prompt{top:calc(100svh - 118px)}.choice-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
