/* The match uses the available viewport. Cards remain attached to the arena. */
.play {
 width:100%;max-width:1600px;height:100dvh;min-height:0;
 display:grid;grid-template-areas:"hud" "arena" "deck" "actions";
 grid-template-rows:auto minmax(0,auto) auto auto;align-content:center;gap:8px;
 padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
}
.hud{grid-area:hud;margin:0;gap:14px;min-width:0}
.energy{min-width:112px;padding:5px 12px;gap:8px}
.energy>span{font-size:34px}.energy strong{font-size:26px}
.mission-heading{min-width:0}.mission-heading strong{font-size:clamp(13px,1.5vw,20px);line-height:1.2}
.game-menu-button,.lab-toggle{min-width:44px;min-height:44px;padding:8px 12px;flex-shrink:0}
.lab-toggle{background:#ded3ed;font-size:21px}
.arena{grid-area:arena;min-width:0;min-height:0;width:100%;aspect-ratio:var(--scene-ratio);max-height:calc(100dvh - var(--match-chrome,230px));position:relative;display:grid;place-items:center;overflow:hidden}
.field-wrap{width:100%;min-width:0;margin:0;border-width:2px;border-radius:16px;box-shadow:0 5px 16px #140c2044}
#field{display:block;width:100%;height:auto;touch-action:none}
.mode-note{position:absolute;top:5px;left:50%;transform:translateX(-50%);width:max-content;max-width:94%;margin:0;z-index:3;font-size:11px;padding:7px 12px;pointer-events:none;box-shadow:0 2px 8px #20142c44}
.deck-bar{grid-area:deck;display:grid;grid-template-columns:repeat(var(--cards),minmax(0,144px));justify-content:center;gap:8px;margin:0;padding:3px;min-height:0;min-width:0}
.deck-card{width:100%;height:100px;min-width:0;flex:none;padding:3px 6px 5px;font-size:11px;line-height:1.15;border-radius:13px}
.deck-card .sprite{width:50px;height:50px}
.deck-card>span:not(.sprite){min-height:26px;width:100%;overflow-wrap:anywhere;text-align:center}
.deck-card strong{font-size:13px;line-height:16px;margin-top:0}
.deck-card.can-place:not(.selected){border-color:#789e7b}
.deck-card.unaffordable{opacity:.65}.deck-card kbd{font-size:9px;left:6px;top:5px}
.tools{grid-area:actions;min-width:0;display:flex;flex-wrap:nowrap;justify-content:safe center;gap:6px;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin;padding:2px 3px 5px;margin:0}
.tools:empty{display:none}.tools button,.tools select{flex-shrink:0;min-height:42px;font-size:11px;padding:8px 11px;white-space:nowrap;scroll-snap-align:start}
.tools select{max-width:170px}.report{max-height:85%;overflow:auto}
.lab-tools{position:fixed;top:76px;right:max(14px,env(safe-area-inset-right));z-index:9;width:min(510px,calc(100vw - 28px));max-height:calc(100dvh - 96px);overflow:auto;display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:0;padding:18px;background:#fff2db;color:#412b3f;border:2px solid #624b68;border-radius:18px;box-shadow:0 8px 30px #160e2955}
.lab-tools label{display:flex;flex-direction:column;gap:5px;min-width:0;font-size:12px}.lab-tools label:first-of-type{grid-column:1/-1}
.lab-tools select,.lab-tools label select{width:100%;max-width:100%;min-width:0;margin:0;min-height:44px}
.lab-tools button{min-height:44px}.lab-tools .lab-close{grid-column:1/-1;justify-self:end;min-width:44px;padding:3px 12px;font-size:22px}
.touch-loupe{position:fixed;z-index:8;width:220px;pointer-events:none;border:3px solid #ffe29a;border-radius:17px;overflow:hidden;background:#312339;box-shadow:0 8px 25px #120b3266}
.touch-loupe canvas{width:100%;height:auto}.touch-loupe>span{display:block;text-align:center;font-size:12px;font-weight:900;padding:6px;color:#fff1cd}

/* Portrait tablets keep the board and cards together, with taller lanes. */
@media(min-width:651px) and (max-width:900px) and (orientation:portrait){
 .play{height:auto;min-height:100dvh;grid-template-rows:auto auto auto auto;align-content:center}
 .arena{aspect-ratio:var(--scene-ratio);width:100%}
}
/* Portrait phones use a readable three-column card tray. */
@media(max-width:650px) and (orientation:portrait){
 .play{height:auto;min-height:100dvh;grid-template-rows:auto auto auto auto;align-content:center;gap:10px;padding:12px 9px}
 .arena{aspect-ratio:var(--scene-ratio);width:100%}
 .hud{gap:8px}.energy{min-width:86px;padding:5px 8px;gap:4px}.energy>span{font-size:25px}.energy strong{font-size:23px}.energy small{font-size:9px}
 .mission-heading small{font-size:8px}.mission-heading strong{font-size:13px}.mission-heading #wave{font-size:10px}.heart{font-size:16px}
 .game-menu-button{padding:7px}.game-menu-button span{display:none}.lab-toggle{padding:5px;font-size:18px}
 .deck-bar{grid-template-columns:repeat(var(--portrait-cols),minmax(0,1fr));gap:7px}
 .deck-card{height:100px;font-size:11px;padding:3px 6px}.deck-card .sprite{width:46px;height:46px}.deck-card>span:not(.sprite){min-height:28px}.deck-card strong{font-size:13px}.deck-card kbd{display:none}
 .tools{justify-content:flex-start;scroll-snap-type:x proximity}.tools button,.tools select{min-height:44px;font-size:11px}
 .report{position:fixed;inset:auto 12px 12px;max-height:55dvh;width:auto;max-width:none;z-index:8}
 .mode-note{font-size:10px;padding:6px 9px}
}
@media(max-width:650px) and (orientation:portrait) and (max-height:700px){
 .play{padding:8px;gap:6px}.deck-card{height:84px;font-size:10px}.deck-card .sprite{width:34px;height:34px}.deck-card>span:not(.sprite){min-height:24px}.deck-card strong{font-size:12px}
 .energy{min-width:76px;padding:4px}.energy strong{font-size:20px}.energy>span{font-size:22px}.hud{gap:5px}.mission-heading strong{font-size:12px}.heart{font-size:14px;margin:0}.lab-toggle{min-width:40px}
}
/* Short landscape: cards sit alongside the board and can scroll independently. */
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .play{grid-template-areas:"hud hud" "deck arena" "actions actions";grid-template-columns:128px minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;gap:5px;padding:6px 8px}
 .arena{aspect-ratio:auto;max-height:none}
 .hud{gap:10px}.energy{min-width:102px;padding:2px 8px;gap:5px}.energy>span{font-size:23px}.energy strong{font-size:20px}.energy small{font-size:8px}.mission-heading small{display:none}.mission-heading strong{font-size:13px}.mission-heading #wave{font-size:9px}
 .heart{font-size:17px}.game-menu-button,.lab-toggle{height:42px;min-height:42px;padding:5px 10px}
 .deck-bar{display:flex;flex-direction:column;justify-content:flex-start;gap:4px;overflow-y:auto;overscroll-behavior-y:contain;scrollbar-width:thin;padding:3px}
 .deck-card{display:grid;grid-template-columns:36px minmax(0,1fr);grid-template-rows:1fr auto;align-items:center;flex:0 0 46px;min-height:46px;height:46px;padding:2px 4px;border-width:1px;border-radius:9px;font-size:9px;text-align:left;box-shadow:0 2px 0 #20172a}
 .deck-card .sprite{grid-row:1/3;grid-column:1;width:35px;height:35px}.deck-card>span:not(.sprite){grid-column:2;min-height:0;line-height:10px;text-align:left;justify-items:start}.deck-card strong{grid-column:2;font-size:10px;line-height:12px;justify-self:start}.deck-card kbd{display:none}
 .tools{padding:2px 3px 3px;justify-content:flex-start}.tools button,.tools select{min-height:40px;font-size:10px;padding:7px 10px}
 .field-wrap{border-radius:12px}.mode-note{max-width:85%;font-size:10px}
}
