/* Mobile combat only. Desktop and every out-of-battle menu retain the shared shell geometry. */
#battle-menu-toggle,.mobile-battle-rotate{display:none}.mobile-battle-actions:empty{display:none}
@media(max-width:1000px){
 body:has(#game:not([hidden])){--mobile-dock-height:52px;--mobile-reserve-width:116px;--mobile-safe-top:env(safe-area-inset-top,0px);--mobile-safe-bottom:env(safe-area-inset-bottom,0px);--mobile-safe-left:env(safe-area-inset-left,0px);--mobile-safe-right:env(safe-area-inset-right,0px)}
 body:has(#game:not([hidden])) main{box-sizing:border-box;width:100%;height:100dvh;max-width:none;padding:0;margin:0;overflow:hidden}
 html:has(#game:not([hidden])){scroll-padding:0}
 body:has(#game:not([hidden])) #game-shell{position:fixed;top:calc(2px + var(--mobile-safe-top));left:4px;right:auto;display:block;width:44px;height:44px;min-height:0;padding:0;margin:0;background:transparent;border:0;box-shadow:none;pointer-events:none;z-index:40}
 body:has(#game:not([hidden])) #game-shell .game-brand,body:has(#game:not([hidden])) #game-shell .game-context{display:none}
 body:has(#game:not([hidden])) #battle-menu-toggle{display:block;pointer-events:auto;box-sizing:border-box;width:44px;height:44px;min-height:44px;padding:0;border:1px solid #b7c7bc55;border-radius:9px;background:#0b2635c9;color:#f5efd8;font:700 10px/1.2 "Malgun Gothic",sans-serif;touch-action:manipulation}
 body:has(#game:not([hidden])) #game-shell .game-nav{display:none;position:absolute;top:48px;left:0;grid-template-columns:repeat(4,minmax(44px,1fr));width:min(360px,calc(100vw - 12px));padding:8px;gap:4px;background:#102b38f5;border:1px solid #92b1ab88;border-radius:10px;box-shadow:0 10px 30px #04121b66;pointer-events:auto}
 body:has(#game:not([hidden])) #game-shell[data-battle-menu-open=true] .game-nav{display:grid}
 body:has(#game:not([hidden])) #game-shell .game-nav a{color:#ecf2e6;font-size:12px}body:has(#game:not([hidden])) #game-shell .game-nav a[aria-current=page]{background:#37665e;color:#ffe7a1}
 #game:not([hidden]){height:100%;display:block;position:relative;isolation:isolate;overflow:hidden}
 #game:before{content:'';position:absolute;inset:0 0 auto;height:calc(48px + var(--mobile-safe-top));background:#0a2635de;pointer-events:none;z-index:3}
 #game .battle-top{position:absolute;z-index:10;top:var(--mobile-safe-top);left:52px;right:164px;height:46px;display:block;min-width:0;border:0;pointer-events:none}
 #game .game-title{display:none}
 #game .hud{position:static;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:27px 13px;gap:1px 8px;max-width:300px;height:44px;min-width:0;padding:2px 0;border:0;background:none;box-shadow:none;text-shadow:0 1px 3px #061b29}
 #game .hud>div{display:flex;align-items:baseline;gap:5px;min-width:0;padding:0;border:0;white-space:nowrap}
 #game .hud>div>span{display:none}
 #game .hud>div:before{font-size:9px;font-weight:700;color:#c9ded7}
 #game .hud>div:nth-child(1):before{content:'WAVE'}#game .hud>div:nth-child(2):before{content:'HP'}#game .hud>div:nth-child(3):before{content:'COIN'}
 #game .hud strong,#game .hud #wave>span{font-size:18px;line-height:1.25;margin:0;color:#fff4d9}
 #game .hud #coins{color:#ffdf91}#game .hud #wave small{font-size:10px;margin-left:2px}
 #game .hud progress,#game .hud .hud-caption{display:none}
 #game .hud>.wave-display{grid-column:1/-1;display:block;min-width:0;width:100%;max-width:none;margin:0;pointer-events:none}
 #game .hud>.wave-display:before{content:none}#game .wave-clock{min-height:0;padding:0;font-size:10px;line-height:12px;color:#efdeb6}
 #game .battle-controls{display:contents}
 #game .battle-controls>#pause,#game .battle-controls>#speed,#game .battle-options>summary{box-sizing:border-box;position:absolute;top:calc(2px + var(--mobile-safe-top));z-index:18;min-width:48px;width:48px;min-height:44px;height:44px;padding:4px 2px;margin:0;border:1px solid #b7c7bc55;border-radius:9px;background:#0b2635c9;color:#fff2d5;font:700 10px/1.3 "Malgun Gothic",sans-serif;touch-action:manipulation;text-align:center;list-style:none}
 #game .battle-controls>#pause{right:108px}#game .battle-controls>#speed{right:56px}#game .battle-options>summary{right:4px;display:grid;place-items:center}
 #game .battle-options>summary::-webkit-details-marker{display:none}
 #game .battle-controls>#jump-bench,#game .battle-metrics{display:none}
 #game .battle-options{position:static;margin:0;padding:0;border:0}
 #game .battle-options .options-content{box-sizing:border-box;position:absolute;top:calc(50px + var(--mobile-safe-top));right:4px;z-index:35;width:min(360px,calc(100vw - 12px));max-height:calc(100dvh - 64px - var(--mobile-safe-top));padding:16px;overflow:auto;overscroll-behavior:contain;border:1px solid #9ebbb2aa;background:#102b38f5;border-radius:10px;box-shadow:0 10px 30px #04121b66}
 #game .mobile-battle-actions{display:flex;gap:8px;flex-wrap:wrap;padding-top:10px;border-top:1px solid #8baaa455}
 #game .mobile-battle-rotate{display:block}
 #game .mobile-battle-actions button{min-height:44px;min-width:64px;padding:8px 14px;font-size:12px}
 #game .arena-layout{position:absolute;inset:calc(48px + var(--mobile-safe-top)) 4px var(--mobile-safe-bottom);height:auto;display:grid;grid-template-columns:minmax(0,1fr) var(--mobile-reserve-width);gap:5px;min-height:0;align-items:stretch}
 #game .arena-column{min-height:0;overflow:hidden;border:0;border-radius:7px;background:transparent}
 #game .stage{width:100%;height:100%;min-height:0;min-width:0;aspect-ratio:auto;border:0;border-radius:7px}
 #game .reserve-column{position:relative;display:flex;min-width:0;min-height:0;padding:0 0 100px;gap:0}
 #game .bench-panel{min-height:0;flex:1;padding:5px;margin:0;border:1px solid #9bb8aa55;border-radius:8px;background:#102b3899;box-shadow:none}
 #game .bench-heading{display:block;min-height:25px;margin:0 0 4px}#game .bench-heading h2{font-size:11px;line-height:1.5;white-space:nowrap}#game #bench-count{margin-left:3px;font-size:9px}
 #game .bench-heading .eyebrow,#game .bench-actions,#game .auto-merge-info{display:none}
 #game .bench-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:min-content;align-content:start;gap:4px;min-height:0;max-height:none;overflow:auto;padding:1px;background:transparent;border:0;scrollbar-width:none}
 #game .bench-card{box-sizing:border-box;min-width:44px;min-height:64px;padding:2px;border-radius:5px;margin:0;touch-action:pan-y}
 #game .bench-card img{height:40px;margin:0 0 2px;border-radius:3px}#game .bench-card b{font-size:8px;left:2px;top:2px;padding:1px 3px}#game .bench-card .stack-count{top:29px;right:1px;font-size:10px;padding:1px 3px}
 #game .bench-card>span{font-size:9px;line-height:14px}#game .bench-card em,#game .bench-card small{display:none}
 #game .bench-empty{left:4px;right:4px;top:50%;bottom:auto;font-size:10px;line-height:1.5}
 #game .command-dock{box-sizing:border-box;position:absolute!important;left:auto;right:9px;bottom:calc(4px + var(--mobile-safe-bottom));z-index:12;display:block;width:106px;height:94px;min-height:0;padding:0;margin:0;gap:0;border:0;border-radius:0;background:none;box-shadow:none;pointer-events:none}
 #game .command-dock>.main-commands{position:absolute;inset:0;display:grid;grid-template-columns:1fr;grid-template-rows:44px 44px;gap:5px;width:100%;min-width:0}
 #game .main-commands button{box-sizing:border-box;pointer-events:auto;width:100%;min-width:0;min-height:44px;padding:4px 3px;font-size:11px;line-height:1.3;white-space:normal;border-radius:8px;background:#133c42d9;box-shadow:inset 0 1px #fff6}
 #game .main-commands #summon{background:#d5b16ddb;color:#102e37;border-color:#eed89a}#game .main-commands #merge{background:#21534de6;border-color:#9abfa7;color:#f0f5d8}
 #game .command-dock>.dock-state{position:absolute;bottom:0;right:calc(100% + 6px);width:44px;height:44px;min-height:0;display:block;margin:0;pointer-events:auto}
 #game #inspect-card{box-sizing:border-box;width:44px;height:44px;min-height:44px;padding:0;border:1px solid #b7c7bc66;border-radius:9px;background:#0b2635d9;color:#fff2d5;font-size:0}
 #game #inspect-card strong,#game #inspect-card span{font-size:0}#game #inspect-card strong:after{content:none}#game #inspect-card:before{content:'정보';font:700 10px/1.2 "Malgun Gothic",sans-serif}
 #game .command-dock>.unit-commands{position:absolute;bottom:0;right:calc(100% + 56px);display:flex;flex-wrap:nowrap;gap:4px;width:max-content;max-width:calc(100vw - 190px);overflow-x:auto;pointer-events:auto;scrollbar-width:none}
 #game .unit-commands button{box-sizing:border-box;min-width:44px;min-height:44px;margin:0;padding:5px 8px;font-size:10px;background:#0b2635dc;border-color:#a8beb477;border-radius:8px;white-space:nowrap}
 #game .unit-commands:not(:has(button:not([hidden]))){display:none}
 #game .inspector{display:none}#game .inspector[data-open=true]{box-sizing:border-box;display:grid;position:absolute;top:calc(52px + var(--mobile-safe-top));right:8px;z-index:25;width:280px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 164px);margin:0;padding:12px;border:1px solid #aac5b899;border-radius:10px;background:#102b38f5;box-shadow:0 8px 30px #04121b66;overflow:auto}
 #game .encounter-minimal{top:6px;left:8px;right:8px}#game .encounter-minimal .encounter-heading>strong,#game .encounter-minimal [data-encounter-health-text]{font-size:11px}#game .encounter-minimal .encounter-pattern strong,#game .encounter-minimal .encounter-pattern>p{font-size:10px}
 #game .action-feedback{left:8px;bottom:calc(56px + var(--mobile-safe-bottom));max-width:calc(100% - 145px);min-height:0;margin:0;padding:5px 9px;background:#102b38d9;pointer-events:none}#game .action-feedback strong{font-size:10px}#game .action-feedback p{display:none}
 #game button:focus-visible,#game summary:focus-visible,#battle-menu-toggle:focus-visible{outline:2px solid #ffe0a1;outline-offset:1px}
 body:has(#game:not([hidden])) #game-shell{left:calc(4px + var(--mobile-safe-left))}
 #game .battle-top{left:calc(52px + var(--mobile-safe-left));right:calc(164px + var(--mobile-safe-right))}
 #game .battle-controls>#pause{right:calc(108px + var(--mobile-safe-right))}#game .battle-controls>#speed{right:calc(56px + var(--mobile-safe-right))}#game .battle-options>summary{right:calc(4px + var(--mobile-safe-right))}
 #game .arena-layout{left:calc(4px + var(--mobile-safe-left));right:calc(4px + var(--mobile-safe-right))}#game .command-dock{right:calc(9px + var(--mobile-safe-right))}
}
@media(max-width:720px) and (orientation:landscape){body:has(#game:not([hidden])){--mobile-reserve-width:76px}#game .bench-grid{grid-template-columns:1fr}#game .bench-heading h2{font-size:10px}#game #bench-count{display:block;margin:0;font-size:9px}#game .bench-heading{min-height:30px}#game .command-dock{width:66px}#game .main-commands button{font-size:10px}#game .command-dock>.unit-commands{max-width:calc(100vw - 145px)}}
@media(max-width:1000px) and (orientation:portrait){
 /* Fixed control reserve: selecting a card must never move it between the two taps. */
 #game{--mobile-dock-height:100px}
 #game .arena-layout{inset:calc(48px + var(--mobile-safe-top)) 4px calc(var(--mobile-dock-height) + 90px + var(--mobile-safe-bottom));display:block}
 #game .arena-column{display:block;width:100%;height:100%;overflow:auto;overscroll-behavior:contain}
 #game .stage{height:100%;min-height:0}
 #game .reserve-column{position:fixed;left:calc(4px + var(--mobile-safe-left));right:calc(4px + var(--mobile-safe-right));bottom:calc(var(--mobile-dock-height) + var(--mobile-safe-bottom));height:86px;padding:0}
 #game .bench-panel{width:100%;padding:3px 5px}
 #game .bench-heading{display:flex;justify-content:space-between;align-items:center;min-height:16px;margin:0 0 2px}#game .bench-heading h2{font-size:10px}#game #bench-count{font-size:9px}
 #game .bench-actions{display:block;font-size:9px}#game .bench-actions button{display:none}
 #game .bench-grid{display:grid;grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:58px;grid-template-rows:62px;gap:4px;overflow-x:auto;overflow-y:hidden;align-content:start;justify-content:start}
 #game .bench-card{width:58px;min-height:60px;touch-action:pan-x}#game .bench-card img{height:38px}#game .bench-card .stack-count{top:27px}
 #game .bench-empty{top:32px}
 #game .command-dock{position:absolute!important;left:calc(4px + var(--mobile-safe-left));right:calc(4px + var(--mobile-safe-right));bottom:var(--mobile-safe-bottom);width:auto;height:var(--mobile-dock-height);background:linear-gradient(0deg,#102b38d9,#102b3800);border:0}
 #game .command-dock>.dock-state{right:auto;left:0;bottom:4px}
 #game .command-dock>.main-commands{inset:auto 0 4px 50px;width:auto;height:44px;grid-template-columns:1fr 1fr;grid-template-rows:44px;gap:5px}
 #game .command-dock>.unit-commands{left:0;right:0;bottom:54px;width:100%;max-width:none;justify-content:end}
 #game .inspector[data-open=true]{top:auto;bottom:calc(var(--mobile-dock-height) + 96px);right:8px;max-height:calc(100dvh - var(--mobile-dock-height) - 164px)}
 #game .action-feedback{bottom:calc(var(--mobile-dock-height) + 96px);max-width:calc(100% - 16px)}
}
@media(max-width:600px) and (orientation:portrait){#game .stage{height:auto;aspect-ratio:7/13;min-height:0}}
@media(max-width:450px){
 #game .battle-top{right:calc(140px + var(--mobile-safe-right))}#game .hud{grid-template-columns:1fr .8fr 1.4fr;gap:1px 4px}
 #game .hud>div{gap:3px}#game .hud strong,#game .hud #wave>span{font-size:15px}#game .hud #wave small{font-size:9px;margin-left:1px}
 #game .hud>div:nth-child(1):before{content:'W'}#game .hud>div:nth-child(2):before{content:'♥'}#game .hud>div:nth-child(3):before{content:'◈'}
 #game .battle-controls>#pause,#game .battle-controls>#speed,#game .battle-options>summary{width:44px;min-width:44px;font-size:9px}#game .battle-controls>#pause{right:calc(96px + var(--mobile-safe-right))}#game .battle-controls>#speed{right:calc(50px + var(--mobile-safe-right))}
}
@media(max-width:1000px){#game .hud .critical #lives{color:#ffb199}#game .hud .critical:before{color:#ffb199}}
