/* Additive model layer. The original card UI owns all layout and input. */
.battle-piece{display:none}
#summon-canvas{position:fixed;inset:0;pointer-events:none!important;z-index:8;width:100%;height:100%}
#summon-canvas[hidden]{display:none}
.with-summons .slot.has-summon>.art,.with-summons .slot.has-summon>.shade{visibility:hidden}

.with-summons .slot.has-summon.spent{opacity:1}

body:has(#app:not([hidden])) #app .with-summons .battle-command-row :is(.auction-panel,.selection-hint) {
  position:static; grid-column:1/-1; grid-row:2; margin:0; max-width:none;
  width:100%; order:5; box-sizing:border-box;
}
@media(min-width:1101px) {
  body:has(#app:not([hidden])) #app .with-summons .main {
    grid-template-rows:12px 56px minmax(340px,1fr) 68px 166px 14px;
  }
  body:has(#app:not([hidden])) #app .with-summons .battle-command-row {grid-auto-rows:auto}
}
@media(max-height:850px) and (min-width:1101px) {
  body:has(#app:not([hidden])) #app .with-summons .main {
    grid-template-rows:12px 48px minmax(400px,1fr) 68px 140px 12px;
  }
}

@media(max-width:680px) {
  body:has(#app:not([hidden])) .sidebar {flex-wrap:wrap;gap:4px}
  body:has(#app:not([hidden])) .sidebar-bottom {
    display:flex;align-items:center;gap:8px;flex:1 0 100%;margin:0;
  }
  body:has(#app:not([hidden])) .sidebar-bottom > :not([data-home],[data-concede]) {display:none}
  body:has(#app:not([hidden])) .sidebar-bottom > .quiet {
    width:auto;min-height:36px;padding:5px 10px;margin:0;
  }
}

/* A single scene contains terrain, architecture and pieces. The transparent
   controls above it keep the original keyboard and pointer interaction. */
.stat-label{display:none}
.arena-stage{position:relative;isolation:isolate;min-height:0;overflow:hidden;border-radius:12px;background:#424d43;box-shadow:inset 0 0 65px #14201d88}
#app .arena-stage #summon-canvas{position:absolute;inset:0;width:100%;height:100%;z-index:0}
body:has(#app:not([hidden])) #app .arena-stage .board{
 position:absolute;inset:0;display:block;z-index:1;width:100%;height:100%;padding:0;margin:0;
 border:0;background:transparent;box-shadow:none;transform:none;pointer-events:none;
}
body #app .arena-stage .board>.lane{display:contents}
body:has(#app:not([hidden])) #app .arena-stage .board :is(.zone,.battle-divider){display:none}
body:has(#app:not([hidden])) #app .arena-stage .board .lane>.slot[data-slot]{
 position:absolute;left:0;top:0;width:140px;height:100px;min-height:0;max-height:none;
 transform-origin:0 0;pointer-events:auto;margin:0;transition:none;
}
body #app .arena-stage .board .slot .coin-slot{visibility:hidden}
#app .arena-stage .board:after{display:none}
body:has(#app:not([hidden])) #app .arena-stage .board .slot{background:transparent;box-shadow:none;border:1px solid transparent}
body #app .arena-stage .board .slot.empty:before{opacity:0}
body #app .arena-stage .board .slot:is(.target,.selected){background:#e6c06819;box-shadow:inset 0 0 0 2px #e0bf73}
body #app .arena-stage .board .slot.attack-target{box-shadow:inset 0 0 0 2px #ef997c}
body #app .arena-stage .board .unit-name,body #app .arena-stage .board .unit-stats{display:block;left:3px;right:3px;color:#fff6e1;background:#171c18db;text-shadow:0 1px 2px #111;padding:2px 4px;line-height:1.05}
body #app .arena-stage .board .unit-stats{display:flex;bottom:2px;align-items:center;justify-content:space-between;font-size:clamp(10px,.78vw,15px);border-radius:0 0 3px 3px}
body #app .arena-stage .board .unit-name{bottom:calc(clamp(10px,.78vw,15px) + 5px);font-size:clamp(10px,.8vw,15px);border-radius:3px 3px 0 0}
.arena-stage .stat-label{display:inline;color:#d4c7a8;font:600 .7em system-ui}
body #app .arena-stage .board .unit-tag{z-index:1;color:#e7eeee;background:#263c3ef2;border-radius:3px;padding:2px 4px}
body #app .arena-stage .board .in-stealth{border:1px dashed #95d7d4;box-shadow:inset 0 0 16px #6ebbbb42}
body #app .arena-stage .board .in-stealth .unit-tag{background:#173f43;color:#c4fffb}
@media(max-width:1100px){.arena-stage{height:500px;flex-shrink:0}}
@media(max-width:680px){.arena-stage{height:470px}.arena-stage .stat-label{font-size:6px}body #app .arena-stage .board .unit-stats{padding:1px}}
.battle-labels{position:absolute;inset:0;z-index:2;pointer-events:none;font-family:system-ui,sans-serif}
.piece-plate{position:absolute;transform:translate(-50%,-100%);background:linear-gradient(100deg,#182019f0,#1b241ff0);color:#f8eed7;border:1px solid #b4a47780;border-radius:4px;padding:2px 5px 3px;box-shadow:0 2px 3px #0005;text-align:center;line-height:1.08}
.piece-plate>b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font:600 clamp(10px,.83vw,15px)/1.15 Georgia,serif}
.readout{display:flex;align-items:center;justify-content:space-evenly;gap:2px;color:#d1b989;font-size:clamp(8px,.59vw,11px);font-weight:600}
.readout strong{color:#fff2ce;font-size:1.4em}.readout>span+span{color:#dcaaa2}.readout>span+span strong{color:#ffe2db}
.stealth-badge{position:absolute;transform:translateX(-50%);border-radius:3px;padding:2px 5px;background:#352f24;color:#f3d49a;border:1px solid #ae925c;font:bold 9px/1.1 system-ui;letter-spacing:.6px}
.stealth-badge.hidden-unit{background:#153b40;color:#bbffff;border:1px dashed #9de3df}
body #app .arena-stage .has-summon :is(.unit-name,.unit-stats){visibility:hidden}
body #app .arena-stage .has-summon:has(.unit-tag) .unit-tag{max-width:94%;font:700 8px/1.1 system-ui}
body #app .arena-stage .has-summon.in-stealth .unit-tag{visibility:hidden}
body #app .arena-stage .board .spent:after{inset:2px 2px auto auto;background:#282923b0;border-radius:2px;padding:1px 2px;font-size:6px}
body #app .arena-stage .board .battle-divider{color:#fff3cf;text-shadow:0 1px 3px #000,0 0 5px #000}
@media(max-width:680px){.piece-plate{padding:1px 0}.piece-plate>b{font-size:8px}.readout{font-size:6px}.stealth-badge{font-size:6px;padding:1px 2px;letter-spacing:0}}
.piece-plate.compact{padding:1px 3px 2px}.piece-plate.compact .readout{font-size:8px;line-height:1}
body #app .arena-stage .is-assassin .unit-tag{visibility:hidden}
@media(max-width:680px){.piece-plate.compact .readout{font-size:6px}.piece-plate.compact{padding:1px}}
body #app .with-summons .main{background:linear-gradient(180deg,#152019de,#181e19d9 67%,#151b17eb),url('assets/arena-brush.webp') center/cover}
.piece-inspection{display:none}
@media(max-width:680px){
 .piece-inspection:not(:empty){display:block;position:absolute;top:5px;left:5px;right:5px;z-index:3;pointer-events:none;padding:5px 7px;border:1px solid #9c997c80;border-radius:4px;background:#182420ed;color:#f9eed6;text-align:center;font:600 12px/1.2 system-ui}
 .piece-plate .readout{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0}
 .piece-plate .readout>span{display:flex;align-items:center;flex-direction:column;font-size:7px}
 .piece-plate .readout strong{font-size:10px}
}
@media(max-width:680px){.arena-stage{height:536px}}
.arena-camera{position:absolute;top:8px;right:8px;display:flex;z-index:4;overflow:hidden;
 border:1px solid #998d68;border-radius:5px;background:#17201eee}
.arena-camera button{cursor:pointer;border:0;color:#f4e6ce;background:transparent;width:30px;height:29px;font:18px Georgia,serif}
.arena-camera button:is(:hover,:focus-visible){background:#445348}
body #app .arena-stage .board .slot[data-slot]:is(:hover,:focus-visible,.ready){border-color:#d9c78066;background-color:#fff4c005}
body #app .arena-stage .board .slot[data-slot]:is(.target,.selected){box-shadow:inset 0 0 0 3px #e7c87e;background-color:#e8c97b30}
body #app .arena-stage .board .slot[data-slot].attack-target{box-shadow:inset 0 0 0 3px #ef997c;background-color:#f0875823}
.castle-name{
 position:absolute;z-index:2;left:12px;pointer-events:none;
 border:1px solid #dbc494aa;border-left:4px solid var(--livery);
 border-radius:2px;padding:4px 9px;background:#17201fef;color:#f5e5bd;
 font:600 clamp(10px,.8vw,14px)/1.2 Georgia,serif;
}
.far-castle{--livery:#ba5858;top:8px}
.near-castle{--livery:#4ba4ae;bottom:8px}
@media(max-width:680px){
 .castle-name{left:6px;padding:3px 6px;font-size:10px}
 .far-castle{top:4px}.near-castle{bottom:4px}
 .piece-inspection:not(:empty){left:auto;max-width:72%;top:4px;font-size:10px}
}

.castle-gate{position:absolute;z-index:2;transform:translate(-50%,-100%)}
body #app .arena-stage .castle-gate .king-slot{
 display:block;width:100%;height:100%;min-height:0;background:transparent;border:0;
 border-radius:7px;box-shadow:none;cursor:pointer;
}
body #app .arena-stage .castle-gate .king-slot>*{display:none}
body #app .arena-stage .castle-gate button:is(:hover,:focus-visible,.selected,.target){
 outline:2px solid #f1c774;background:#ecc5711f;outline-offset:-2px
}
body #app .arena-stage .castle-gate .attack-target{outline-color:#ff9e80}
body #app .arena-stage .castle-gate .exposed{pointer-events:none}

.arena-stage .castle-name{transform:translate(-50%,-50%);bottom:auto}
@media(max-width:680px){.piece-inspection:not(:empty){top:auto;bottom:3px;left:5px;right:auto}}

body:has(#app:not([hidden])) #app .arena-camera button{font:19px/1 Georgia,serif;padding:2px}
.arena-camera button[aria-pressed="true"]{background:#536054}
.arena-stage .castle-name:has(+.castle-gate button){pointer-events:auto;cursor:pointer}
.arena-stage .castle-name:has(+.castle-gate .attack-target){border-color:#f1a487}
body:has(#app:not([hidden])) #app .arena-stage .board .slot>.hidden-card{
 inset:auto 10% 3%;height:auto;background:#16201bd9;box-shadow:none;border:0;border-radius:3px;padding:2px
}
body #app .arena-stage .board .slot>.hidden-card>span{display:none}
body #app .arena-stage .board .slot>.hidden-card>small{font:600 10px/1.2 system-ui;color:#f0dec3}

/* Keep the camera's viewport fixed while the prompt changes. */
@media(min-width:1101px){
 body:has(#app:not([hidden])) #app .with-summons .battle-command-row{grid-template-rows:42px 24px;row-gap:2px}
}
body:has(#app:not([hidden])) #app .arena-stage .board .slot{animation:none}
.arena-stage .piece-plate,.arena-stage .piece-plate.compact{
 width:max-content!important;max-width:20%;padding:0;border:0;background:none;box-shadow:none;
 --metal:#519d9e;
}
.arena-stage .piece-plate[data-side="1"]{--metal:#c8644d}
.arena-stage .piece-plate>b{display:none}
.arena-stage .piece-plate.inspected>b{display:block;color:white;background:#202923ed;padding:2px 5px}
.arena-stage .piece-plate .readout{display:flex;align-items:center;gap:5px;padding:2px 5px;color:#e4d8b7;background:#20251ee6;border-left:3px solid var(--metal);border-radius:2px;font:600 8px/1 system-ui}
.arena-stage .piece-plate .readout>span{display:inline;white-space:nowrap}
.arena-stage .piece-plate .readout strong{font-size:12px}
.arena-stage .castle-name{white-space:nowrap;font:600 10px/1.1 system-ui;padding:3px 6px;background:#1e2726e8}
@media(max-width:680px){.arena-stage .piece-plate .readout{gap:2px;padding:1px 2px;font-size:6px}.arena-stage .piece-plate .readout strong{font-size:9px}.arena-stage .castle-name{font-size:8px}}
@media(max-width:680px){
 .arena-stage .piece-plate .readout>span{display:flex;flex-direction:column;align-items:center;font:600 6px/1 system-ui}
 .arena-stage .piece-plate .readout{gap:3px;border-left-width:2px}
 .arena-stage .piece-plate .readout strong{font-size:9px}
}

/* Play close to the formations. The overview is optional. Portrait uses
   native horizontal panning, so a soldier stays a practical touch target. */
.arena-window{position:relative;min-height:0;min-width:0;border-radius:10px;overflow:hidden}
.arena-pan,.arena-window .arena-stage{width:100%;height:100%;min-height:0}
.arena-pan{overflow:hidden}
.arena-window .arena-stage{border-radius:0}
body:has(#app:not([hidden])) #app .arena-camera [data-camera="zoom"]{width:auto;padding:3px 9px;font:600 11px/1 system-ui}
@media(min-width:1101px){
 body:has(#app:not([hidden])) #app .with-summons.shell{grid-template-columns:clamp(144px,10.5vw,180px) minmax(0,1fr) clamp(165px,13vw,220px)}
 body:has(#app:not([hidden])) #app .with-summons .main{padding-inline:12px}
}
@media(max-width:1100px){.arena-window{height:500px;flex-shrink:0}}
@media(max-width:680px){
 .arena-window{height:454px}
 .arena-pan{overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin;scrollbar-color:#95876b #253029}
 .arena-window:not(.overview) .arena-stage{min-width:780px}
 .arena-window:not(.overview)::after{content:'↔  Swipe field';position:absolute;left:6px;top:8px;z-index:3;pointer-events:none;color:#f4e9cc;background:#19211de8;padding:5px 7px;border-radius:3px;font:600 10px system-ui}
 .arena-window .arena-camera{top:6px;right:5px}
}
.figure-pick{position:absolute;display:block;transform:translate(-50%,-50%);border-radius:45%;cursor:pointer;touch-action:pan-x pan-y}
.arena-window .castle-gate,.arena-window .castle-name{z-index:3}
@media(min-width:681px){
 .arena-stage .piece-plate .readout{font-size:10px;padding:3px 5px;gap:6px}
 .arena-stage .piece-plate .readout strong{font-size:14px}
}

/* Keep the full six-column footprint legible from the original tabletop angle. */
body:has(#app:not([hidden])) #app .arena-stage .board .slot[data-slot]{border-color:#a7b09570;background:#18302418}
body:has(#app:not([hidden])) #app .arena-stage .board .slot[data-player="1"][data-slot]{border-color:#b19e8970;background:#482a2315}
body:has(#app:not([hidden])) #app .arena-stage .board .slot[data-slot]:is(:hover,:focus-visible,.target,.selected){border-color:#e7c87e}
body:has(#app:not([hidden])) #app .arena-stage .board .slot[data-slot]:is(.target,.selected){background-color:#e8c97b30}
body:has(#app:not([hidden])) #app .arena-stage .board .slot[data-slot].attack-target{border-color:#ef997c}

/* A permanent, visible king marker on the actual castle-gate control. */
.king-location{display:none}
body #app .arena-stage .castle-gate .king-slot{overflow:visible}
body #app .arena-stage .castle-gate .king-slot>.king-location{display:flex;position:absolute;left:50%;bottom:0;transform:translateX(-50%);align-items:center;gap:5px;white-space:nowrap;padding:4px 7px;border:1px solid #e3c579;border-radius:4px;background:#202b23f5;color:#ffe5a0;font:700 10px/1.2 system-ui;pointer-events:none;box-shadow:0 2px 8px #0009}
body #app .arena-stage .castle-gate .king-location>span{font-size:20px;line-height:1}
body #app .arena-stage .castle-gate[data-gate="1"] .king-location{border-color:#c77966;background:#362521f5}
.arena-stage .piece-plate.is-king>b{display:block;color:#ffe5a0;background:#202923f2;padding:3px 5px;border:1px solid #bea15f;border-radius:3px}
.arena-stage .piece-plate.is-king .readout{border-color:#e0bd6e}
body:has(#app [data-figure]:hover,#app [data-king]:hover) #app .rightbar .detail{display:block;overflow-y:auto;max-height:100%;min-height:0}
body:has(#app [data-figure]:hover,#app [data-king]:hover) #app .rightbar .log{display:none}
#app .log-entry b small{display:block;font:6px/1.4 system-ui;letter-spacing:.3px;color:#bca673}
