/* V1.4.0 — single edge-to-edge stage. Every control still forwards to
 * the same LegionRoom; debug presentation is intentionally unaffected. */
.legion-game.mode-formal{height:100dvh;min-height:0;overflow:hidden;background:#0b171e}
.legion-game.mode-formal .formal-toolbar{height:56px;min-height:56px;z-index:30;box-shadow:0 3px 18px #0009}
.legion-game.mode-formal .room-main{position:relative;display:block!important;height:calc(100dvh - 56px);min-height:0;overflow:hidden;padding:0!important;margin:0!important;width:100%!important}
.legion-game.mode-formal .room-main .battle{position:relative!important;width:100%!important;height:100%!important;min-height:0!important;max-height:none!important;overflow:hidden;isolation:isolate;background:#0b151c!important;border:0!important;padding:0!important;margin:0!important;box-shadow:none!important}
/* Maintain a 16:9 optical viewport instead of stretching the Three.js/Pixi
 * projections. When necessary, crop surplus rather than letterboxing. */
.legion-game.mode-formal .board-wrap,
.legion-game.mode-formal.duel-active .board-wrap,
.legion-game.mode-formal.world-reserves-active .board-wrap{
 position:absolute!important;top:50%!important;left:50%!important;
 width:max(100vw,calc((100dvh - 56px) * 16 / 9))!important;
 height:auto!important;max-width:none!important;min-width:0!important;
 aspect-ratio:16 / 9!important;transform:translate(-50%,-50%)!important;
 padding:0!important;margin:0!important;border:0!important;outline:0!important;
 background:#0b1419!important;box-shadow:none!important;overflow:hidden;
}
.legion-game.mode-formal .board-wrap:after{box-shadow:inset 0 0 72px #050d13bb!important;pointer-events:none}
.legion-game.mode-formal .battle-top,.legion-game.mode-formal .view-toolbar{display:none!important}
/* The large top status band is retained as the development-stage HUD. */
.legion-game.mode-formal .formal-situationbar{position:absolute;z-index:19;top:8px;left:50%;transform:translateX(-50%);width:min(calc(100% - 28px),1340px);height:52px;margin:0!important;border:1px solid #8da6a25c;background:linear-gradient(90deg,#102128e6,#132730e0);box-shadow:0 6px 18px #0006;pointer-events:auto}
.legion-game.mode-formal .formal-situation-segment{padding:6px 13px}
.legion-game.mode-formal .formal-field-tools{position:absolute;z-index:19;top:65px;left:12px;right:12px;display:flex;justify-content:space-between;align-items:center;min-height:0;height:auto;width:auto!important;max-width:none!important;margin:0!important;padding:0 4px;border:0;background:transparent;box-shadow:none;pointer-events:none}
.legion-game.mode-formal .formal-field-tools>*{pointer-events:auto}
.legion-game.mode-formal .formal-field-controls{gap:5px;flex-wrap:wrap;justify-content:flex-end}
.legion-game.mode-formal .formal-field-controls button{background:#0c222bbf;border:1px solid #83a9a062;box-shadow:0 3px 12px #0006;min-height:30px}
.legion-game.mode-formal .formal-team-summary{padding:5px 8px;background:#0c222b9c;text-shadow:0 1px 5px #000e}
/* Keep squad overview as a concise translucent HUD tab, not a bottom panel. */
.legion-game.mode-formal .duel-overlay{position:absolute;z-index:19;top:109px;right:14px;left:auto;width:min(385px,38vw)!important;max-height:min(42vh,310px);overflow-y:auto;overflow-x:hidden;margin:0!important;padding:8px 11px!important;background:#0c1b24d9;border:1px solid #7d9ba06d;border-left:3px solid #8bd4ba;box-shadow:0 6px 20px #0008;scrollbar-width:thin;pointer-events:auto}
.legion-game.mode-formal .duel-overlay[hidden]{display:none!important}
.legion-game.mode-formal .duel-heading{font-size:11px;gap:5px}
.legion-game.mode-formal .duel-overlay p{font-size:10px;line-height:1.5;margin:4px 0!important}
.legion-game.mode-formal .duel-lineup-details{margin-top:4px;padding-top:4px;border-top:1px solid #7a9b9b52}
.legion-game.mode-formal .duel-lineup-details summary{color:#b6dfd1;font-size:10px;font-weight:600;cursor:pointer;user-select:none;list-style-position:inside}
.legion-game.mode-formal .duel-lineup-details:not([open]) .duel-squad{display:none}
.legion-game.mode-formal #duel-squad{max-height:155px;overflow-y:auto;scrollbar-width:thin;margin-top:5px}
/* Let the map own the bottom: no extra 2D reserve, tool strips or log panel. */
.legion-game.mode-formal.world-reserves-mode .reserve-bay,
.legion-game.mode-formal.world-reserves-mode .inventory-strip,
.legion-game.mode-formal.world-reserves-mode .garrison-strip{display:none!important}
/* 2D fallback keeps actionable cards, but as a small scene overlay, not as a
 * document row that makes the game scroll. */
.legion-game.mode-formal:not(.world-reserves-mode) .reserve-bay{
 position:absolute;z-index:20;bottom:0;left:10px;display:block;
 width:min(610px,65vw);max-height:29%;overflow:auto;margin:0;padding:5px;
 background:#0c1b24ee;border:1px solid #557c83
}
.legion-game.mode-formal:not(.world-reserves-mode) .reserve-bay .inventory-list{min-height:65px}
.legion-game.mode-formal:not(.world-reserves-mode) .reserve-bay .inventory-card{min-height:74px}

.legion-game.mode-formal #message{position:absolute;z-index:19;left:14px;bottom:12px;margin:0!important;padding:5px 10px;min-height:0;width:max-content!important;max-width:min(600px,66vw);background:#0c1b23b9;border:0;border-left:2px solid #7fb9a6;color:#bad1cd;font-size:10px;line-height:1.3;pointer-events:none}
.legion-game.mode-formal .formal-board-actions{position:absolute;right:18px;bottom:24px;z-index:20}
.legion-game.mode-formal .formal-board-actions button{min-height:41px;min-width:142px;padding:9px 12px;background:#18665ee8;box-shadow:0 6px 17px #0009}
/* Labels blend into scene edges rather than surrounding the field with a box. */
.legion-game.mode-formal .field-hud-top{padding:110px 17px 9px;background:none}
.legion-game.mode-formal .field-hud-foot{padding:7px 15px;background:linear-gradient(0deg,#07131a9f,transparent);opacity:.7}
.legion-game.mode-formal .field-serial{display:none}
.legion-game.mode-formal #field-live{margin-left:auto}
.legion-game.mode-formal .unit-inspector{width:min(27%,380px);max-height:100%;padding-top:118px}
/* On compact screens keep game space playable, not a long web document. */
@media(max-height:760px){
 .legion-game.mode-formal .formal-situationbar{height:45px;top:4px}
 .legion-game.mode-formal .formal-field-tools{top:52px}
 .legion-game.mode-formal .duel-overlay{top:94px;max-height:28vh}
 .legion-game.mode-formal .unit-inspector{padding-top:93px}
 .legion-game.mode-formal .field-hud-top{padding-top:87px}
 .legion-game.mode-formal #message{bottom:5px}
}
@media(max-width:850px){
 .legion-game.mode-formal .formal-toolbar{height:79px;min-height:79px;flex-direction:column;padding:4px 8px}
 .legion-game.mode-formal .room-main{height:calc(100dvh - 79px)}
 .legion-game.mode-formal .board-wrap,.legion-game.mode-formal.duel-active .board-wrap,.legion-game.mode-formal.world-reserves-active .board-wrap{width:max(100vw,calc((100dvh - 79px) * 16 / 9))!important}
 .legion-game.mode-formal .formal-situationbar{top:3px;width:calc(100% - 10px);flex-wrap:nowrap;min-height:42px;overflow:hidden}
 .legion-game.mode-formal .formal-kings{display:none}
 .legion-game.mode-formal .formal-field-tools{top:53px}
 .legion-game.mode-formal .formal-team-summary{display:none}
 .legion-game.mode-formal .duel-overlay{right:5px;top:96px;width:min(290px,45vw)!important;max-height:25vh}
 .legion-game.mode-formal .formal-field-controls button{font-size:9px;padding:4px 5px}
 .legion-game.mode-formal .formal-board-actions{right:8px;bottom:12px}
 .legion-game.mode-formal #message{max-width:48vw}
}


/* V1.4.1: UI must live in the true viewport, not the oversized 16:9
   renderer which is intentionally cropped at some monitor aspect ratios. */
.legion-game.mode-formal .battle > .unit-inspector{
 position:absolute!important;left:0!important;top:0!important;bottom:0!important;
 width:clamp(250px,27vw,386px)!important;max-width:min(48vw,430px)!important;
 height:100%!important;max-height:100%!important;min-height:0!important;
 overflow:hidden;box-sizing:border-box;z-index:24!important;
 padding:clamp(105px,15vh,155px) 25px 20px 15px!important;
}
/* The map's own diagnostic badges are redundant with the top real HUD and
   are outside the clipped view on some ratios. */
.legion-game.mode-formal .field-hud{display:none!important}
.legion-game.mode-formal .formal-board-actions{
 right:max(14px,env(safe-area-inset-right))!important;
 bottom:max(48px,calc(env(safe-area-inset-bottom) + 34px))!important;
 transform:none;zoom:var(--terra-hud-scale, .95);
}
.legion-game.mode-formal .formal-board-actions button{min-width:134px;max-width:min(42vw,260px)}
.legion-game.mode-formal .formal-situationbar,
.legion-game.mode-formal .formal-field-tools,
.legion-game.mode-formal .duel-overlay,
.legion-game.mode-formal .formal-duel-toggle{zoom:var(--terra-hud-scale,.95)}
.legion-game.mode-formal .battle > .unit-inspector{zoom:var(--terra-hud-scale,.95)}
/* By default the duel briefing is a tiny expandable tab. The team roster
   is still present and functional when the user chooses to open it. */
.legion-game.mode-formal .duel-overlay:not(.is-open){display:none!important}
.legion-game.mode-formal .formal-duel-toggle{
 display:none;position:absolute;right:14px;top:117px;z-index:23;
 min-height:30px;padding:6px 12px;border:1px solid #7ca9a4a0;
 color:#cef2e5;background:#0b242be6;font:600 11px 'Microsoft Yahei',sans-serif;
 cursor:pointer;box-shadow:0 3px 14px #0008;
}
.legion-game.mode-formal.duel-active .formal-duel-toggle:not([hidden]){display:block}
.legion-game.mode-formal .formal-duel-toggle.is-open{background:#23564b;border-color:#a7e5d1}
.legion-game.mode-formal .formal-duel-toggle span{color:#e6c692;margin-left:6px}
.legion-game.mode-formal .duel-overlay{top:154px!important;max-height:min(40vh,300px);right:14px}
/* Status and controls never vanish below the browser safe area even when
   the virtual 16:9 canvas is taller than the viewport. */
.legion-game.mode-formal .formal-field-controls{flex-wrap:nowrap;max-width:min(74vw,850px);overflow-x:auto;scrollbar-width:none}
.legion-game.mode-formal .formal-field-controls button{flex-shrink:0}
.legion-game.mode-formal .formal-field-controls::-webkit-scrollbar{display:none}
.legion-game.mode-formal .formal-situationbar{max-width:calc(100% - 22px)}
.legion-game.mode-formal .formal-situation-segment{min-width:0}
@media(max-width:1000px){
 .legion-game.mode-formal .battle > .unit-inspector{width:min(43vw,350px)!important;max-width:55vw!important;padding-top:110px!important}
 .legion-game.mode-formal .formal-duel-toggle{top:112px}
 .legion-game.mode-formal .duel-overlay{top:148px!important;width:min(340px,43vw)!important}
}
@media(max-height:740px){
 .legion-game.mode-formal .battle > .unit-inspector{padding-top:88px!important;padding-bottom:8px!important}
 .legion-game.mode-formal .formal-duel-toggle{top:90px}
 .legion-game.mode-formal .duel-overlay{top:125px!important;max-height:32vh}
 .legion-game.mode-formal .formal-board-actions{bottom:26px!important}
}
@media(max-width:650px){
 .legion-game.mode-formal .battle > .unit-inspector{width:min(76vw,320px)!important;max-width:78vw!important;padding-top:100px!important}
 .legion-game.mode-formal .formal-duel-toggle{right:8px;top:115px}
 .legion-game.mode-formal .duel-overlay{right:8px;width:min(315px,70vw)!important}
}

.formal-duel-toggle{display:none}
