/* Fit the complete 480 × 800 game and its footer without stretching the world.
   Canvas pixels and input coordinates remain owned by the existing game. */
:root{--game-scale:1;--game-frame-width:480px;--game-frame-height:860px;--viewport-height:100dvh;--dialog-width:430px;--dialog-height:740px;--card-scale:1;--viewport-center-x:50vw;--viewport-center-y:50dvh}
html{width:100%;height:100%;overflow:hidden}
body{width:100%;height:100vh;height:var(--viewport-height,100dvh);min-height:0;display:grid;place-items:center;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);overflow:hidden}
#game-viewport{position:relative;width:var(--game-frame-width);height:var(--game-frame-height);min-width:0;min-height:0}
#shell{position:absolute;left:0;top:0;width:480px;max-width:none;margin:0;transform:scale(var(--game-scale));transform-origin:0 0}
#stage{width:480px;height:800px;min-height:800px;max-height:none;aspect-ratio:3/5}
#stage>canvas,#hiref-bonus>canvas{width:100%;height:100%;aspect-ratio:3/5}
#shell>footer{padding:16px 4px;min-height:0}
/* Safe areas are reserved by the outer viewport, once, before uniform scaling. */
#hud,.hiref-hud{top:10px}
#controls{bottom:18px}.hiref-controls{bottom:16px}
#hiref-power-tip{bottom:81px}
/* Native dialogs live in the browser's top layer, outside the scaled shell. */
#info{position:fixed;inset:auto;left:var(--viewport-center-x);top:var(--viewport-center-y);margin:0;width:var(--dialog-width);max-width:none;max-height:var(--dialog-height);overflow:auto;overscroll-behavior:contain;transform:translate(-50%,-50%) scale(var(--game-scale));transform-origin:center}
#info #close{position:sticky;top:0;z-index:2;background:#0c2b3f}
#card-viewer{width:100vw;height:100vh;height:var(--viewport-height,100dvh);max-width:none;max-height:none}
#card-zoom-stage{position:relative;padding:0;width:100%;height:100%;display:block}
#card-detail{position:absolute;left:var(--viewport-center-x);top:var(--viewport-center-y);width:420px;max-width:none;transform:translate(-50%,-50%) scale(var(--card-scale));transform-origin:center}
#card-viewer-close{width:calc(42px * max(1,var(--card-scale)));height:calc(42px * max(1,var(--card-scale)));font-size:calc(22px * max(1,var(--card-scale)))}
/* Controller status must not cover the fitted menus or controls. */
#controller-status{position:fixed;left:50%;top:max(4px,env(safe-area-inset-top));bottom:auto;max-width:calc(100vw - 16px);font-size:12px;opacity:.95}
