/* Viewport UI stays readable independently of the fixed-coordinate world. */
html,body{width:100%;height:100%;margin:0;padding:0;overflow:hidden;overscroll-behavior:none}
body{min-height:0}.brand,body>footer{display:none}
#stage,#game-wrapper{position:fixed;inset:0;width:100%;height:100%;height:100dvh;min-height:0;margin:0;transform:none;border:0;border-radius:0;box-shadow:none;overflow:hidden;background:radial-gradient(ellipse at center,#28312b,#0e1518)}
#gameCanvas{position:absolute;display:block;max-width:none;touch-action:none}
#hud-top{top:max(8px,env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right))}
#hud-bottom{bottom:max(8px,env(safe-area-inset-bottom));left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right))}
#hud-top>.top-row:first-child{flex-wrap:wrap}.stat-box{flex-wrap:wrap}#hud-top .stat-box:last-child{margin-left:auto}
#wave-preview-bar{flex-wrap:wrap;max-width:100%}#boss-hud{max-width:min(620px,95%)}
#tower-menu{max-height:calc(100dvh - 100px);overflow-y:auto}.build-confirm{display:none}.menu-close{display:block;margin:5px auto 0;background:none;border:0;color:#c8b78d;cursor:pointer;padding:6px 15px}
#main-hub-overlay{padding:clamp(10px,2vw,24px);height:100%;overflow:hidden}.hub-body{min-height:0}.hub-header{flex-shrink:0}.mode-picker{flex-shrink:0}#mode-description{flex-shrink:0}
.result-box{max-width:calc(100% - 24px);max-height:calc(100dvh - 24px);overflow-y:auto}.report-actions{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-top:12px}.report-status{font-size:12px;line-height:1.5;text-align:center;color:#c9b888;margin:8px 0 0}.report-fallback{display:none;width:100%;min-height:140px;padding:10px;user-select:text;font:12px sans-serif;background:#101a1d;color:#e2dccd;border:1px solid #8c7a51}
.touch-layout .hud-btn{min-height:36px;padding:5px 8px;font-size:11px}.touch-layout #hud-top{gap:4px}.touch-layout .stat-box{gap:5px;padding:4px 7px}.touch-layout #hud-top .stat-box:last-child{margin-left:0}.touch-layout #wave-preview-bar{font-size:10px;gap:3px;padding:4px 6px;max-height:42px;overflow:auto}.touch-layout .preview-tag{font-size:9px}
.touch-layout #hud-bottom{display:block}.touch-layout .bottom-left-group{display:grid;grid-template-columns:1fr 1fr;gap:6px;align-items:end}.touch-layout #hero-card{min-width:0;padding:6px;grid-column:1/-1}.touch-layout .hero-top{font-size:12px}.touch-layout .hero-btn{min-height:36px;font-size:11px}.touch-layout .spell-bar{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;gap:6px}.touch-layout .spell-btn{min-width:0;padding:6px;min-height:44px}.touch-layout .spell-title{font-size:11px}.touch-layout .spell-desc{font-size:9px}.touch-layout #btn-cancel-action{grid-column:1/-1;min-height:36px}.touch-layout #hud-bottom>.stat-box{display:none}
.touch-layout #tower-menu{position:fixed;left:8px!important;right:8px;top:auto!important;bottom:max(8px,env(safe-area-inset-bottom));width:auto;max-height:55dvh;z-index:30;padding:9px;border:1px solid #b8a06e;box-shadow:0 -10px 35px #000a}.touch-layout #tower-menu .menu-btn{min-height:46px;font-size:12px}.touch-layout #tower-menu.build-menu{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.touch-layout #tower-menu.build-menu[style*="display: none"]{display:none!important}.touch-layout #tower-menu.build-menu h4{grid-column:1/-1;margin:0;font-size:12px}.touch-layout .build-menu .menu-btn{padding:10px 3px;min-height:72px!important;text-align:center;margin:0}.touch-layout .build-menu .menu-btn strong{display:block;font-size:12px}.touch-layout .build-menu .menu-btn small{display:none}.touch-layout .build-menu .menu-btn.chosen{background:#53563b;border-color:#eed394;box-shadow:inset 0 0 0 1px #e6c27d}.touch-layout .build-confirm{display:flex;grid-column:1/-1;align-items:center;justify-content:space-between;gap:8px;font-size:11px;color:#d4c39d}.touch-layout .build-confirm button{min-height:42px;min-width:120px}.touch-layout .menu-close{grid-column:1/-1;margin:0;min-height:30px}
@media(max-width:700px){#hud-top>.top-row:first-child{gap:4px}#hud-top .stat-box{font-size:10px}#hud-top .hud-btn{font-size:10px;padding:3px 6px;min-height:30px}#btn-dmg-text{display:none}.hub-header{gap:8px;flex-wrap:wrap;margin-bottom:8px}.hub-title{font-size:17px}.hub-actions{flex-wrap:wrap;gap:4px}.star-wallet{font-size:10px;padding:5px}.small-action-btn{min-height:32px}.mode-picker{gap:5px}.mode-picker button{padding:8px 4px;font-size:10px}.mode-picker strong{font-size:12px;margin-left:3px;letter-spacing:0}.mode-picker span{font-size:9px;margin:4px 0 0;line-height:1.5}#mode-description{font-size:10px;min-height:0;margin-bottom:8px}#main-hub-overlay{overflow-y:auto}.hub-body{display:flex;flex-direction:column;overflow:visible;flex:none}.panel-box{overflow:visible;flex-shrink:0}.scroll-list{overflow:visible;flex:none}.level-card{padding-top:48px}.hero-select-card{min-height:150px}.codex-grid{grid-template-columns:1fr}.result-box{padding:16px}.stats-grid{grid-template-columns:1fr;gap:7px}.stat-panel{max-height:110px}.result-top h2{font-size:20px}#codex-modal{padding:12px}.pause-banner{inset:42% 15% auto}}
@media(pointer:coarse) and (orientation:landscape){.touch-layout #hud-top>.top-row:first-child{flex-wrap:nowrap}.touch-layout #hud-top .stat-box{font-size:9px;gap:4px;padding:3px}.touch-layout #hud-top .hud-btn{font-size:9px;min-height:28px;padding:3px 5px}.touch-layout #btn-dmg-text{display:none}.touch-layout #wave-preview-bar{max-height:25px}.touch-layout .bottom-left-group{display:flex;align-items:end}.touch-layout #hero-card{width:235px}.touch-layout .spell-bar{display:flex}.touch-layout .spell-btn{width:140px}.touch-layout .spell-desc{display:none}.touch-layout #btn-cancel-action{max-width:140px}.touch-layout #tower-menu{left:25%!important;right:25%;max-height:65dvh}.touch-layout #tower-menu.build-menu{left:12px!important;right:12px}.touch-layout .build-menu .menu-btn{min-height:48px!important}.touch-layout .hero-btn{min-height:28px}.touch-layout .hero-bars{gap:2px}.touch-layout .bar-wrap{height:4px}}
