
/* ===== Battle UI lab ===== */
/* --- switches panel (battle only) --- */
body:not(.lab-inbattle) .labbar{display:none!important}
.labbar{position:fixed;right:14px;bottom:14px;z-index:96;width:300px;max-height:calc(100vh - 28px);overflow:auto;background:#1d1712;color:#f3ead8;border-radius:14px;box-shadow:0 10px 30px rgba(0,0,0,.35);font:500 13px/1.3 var(--f-body);padding:10px 12px 12px}
.labbar.shut{display:none}   /* opened from the game menu (☰ → Board settings) */
.labbar .labhd{display:flex;align-items:center;gap:8px;justify-content:space-between}
.labbar .labhd b{font:400 17px/1 Marcellus,serif;letter-spacing:.02em}
.labbar .labhd .labbuild{margin-right:auto;font-size:11px;color:var(--muted);letter-spacing:.04em}
.labbar .labtog{font:700 12px var(--f-body);padding:7px 12px;border-radius:999px;border:1px solid #8a6d43;background:#1d1712;color:#f3ead8;cursor:pointer;min-height:32px}
.labbar fieldset{border:0;margin:10px 0 0;padding:0}
.labbar legend{font-size:10px;letter-spacing:.12em;text-transform:uppercase;color:#bfa77a;font-weight:800;margin-bottom:5px}
.labbar .seg{display:flex;flex-wrap:wrap;gap:4px}
.labbar .seg button,.labbar .labbtn{flex:1 1 auto;font:600 12px var(--f-body);padding:6px 8px;border-radius:8px;border:1px solid #6e5634;background:transparent;color:#f3ead8;cursor:pointer;min-height:30px}
.labbar .seg button[aria-pressed="true"]{background:#e8cf95;color:#1d1712;border-color:#e8cf95}
.labbar label.chk{display:flex;align-items:center;gap:7px;margin-top:4px;cursor:pointer}
.labbar input[type=range]{width:100%;accent-color:#e8cf95}
.labbar .rowb{display:flex;gap:6px;margin-top:12px}
.labbar .labbtn{background:#2c241c}
@media (max-width:640px){ .labbar{right:6px;left:6px;width:auto;bottom:calc(84px + env(safe-area-inset-bottom,0px));max-height:60vh} }

/* --- card stock: a dark side edge under the face plus a contact and a soft shadow, drawn by a layer shaped like the face --- */
.labsh,.lablt{display:none}
body.lab-stock .table .card.hasart:not(.mini){filter:none!important}
body.lab-stock .labsh{display:block;position:absolute;inset:0;z-index:0;pointer-events:none;filter:drop-shadow(0 1px 0 #3b2d23) drop-shadow(0 1px 0 #2c2119) drop-shadow(0 3px 2px rgba(0,0,0,.35)) drop-shadow(0 10px 14px rgba(0,0,0,.22))}
.labsh>i{position:absolute;inset:0;background:#2c2119;border-radius:5% / 3.6%}
body.lab-stock .card.hasart>.tk{filter:brightness(.84);box-shadow:0 0 0 1px rgba(20,16,14,.4),0 -1px 5px rgba(0,0,0,.32)}
/* --- light: a rim highlight on the top edge and a soft gloss falling off toward the bottom --- */
body.lab-light .lablt{display:block;position:absolute;inset:0;z-index:1;pointer-events:none;border-radius:5% / 3.6%;
  background:linear-gradient(160deg,rgba(255,255,255,.22) 0%,rgba(255,255,255,0) 28%,rgba(0,0,0,0) 62%,rgba(0,0,0,.22) 100%);mix-blend-mode:soft-light}
body.lab-light .lablt::after{content:"";position:absolute;inset:0;border-radius:inherit;box-shadow:inset 0 1px 0 rgba(255,255,255,.45),inset 0 -2px 3px rgba(0,0,0,.35)}

/* --- card size: cropped (the phone crop) or full, on any screen --- */
html body.lab-crop{--bch:calc(var(--bcw) * .9707)!important}
body.lab-crop .table .card.hasart:not(.mini){background-color:transparent!important;background-size:0 0!important;border-radius:0!important}
body.lab-crop .table .card.hasart:not(.mini)>.cartbg{background-size:100% auto!important;background-position:center top!important;background-color:transparent!important;border-radius:0!important;clip-path:url(#tabclip)}
body.lab-crop .table .card.hasart>.tk{background-size:100% auto;background-position:center top;border-radius:0!important;clip-path:url(#tabclip)}
body.lab-crop .table .card.hasart>.tk>:is(img,canvas){object-fit:cover;object-position:center top}
body.lab-crop .labsh>i,body.lab-crop .lablt,body.lab-crop .gcard .oback{border-radius:0!important;clip-path:url(#tabclip)}
html body.lab-full{--bch:calc(var(--bcw) * 1.3827)!important}
body.lab-full .table .card.hasart:not(.mini){border-radius:5% / 3.6%!important}
body.lab-full .table .card.hasart:not(.mini)>.cartbg{clip-path:none!important;border-radius:5% / 3.6%!important;background-size:100% 100%!important}
body.lab-full .table .card.hasart>.tk{clip-path:none!important;border-radius:5% / 3.6%!important}

/* --- splay: how the copies, gear and tokens behind a unit fan out --- */
body.lab-sp-up .stage{--tkl:0px}
body.lab-sp-diag .card.hasart>.tk{left:calc(var(--tky) * .45 * (var(--j) + 1))!important}
@media (max-width:640px){ body.lab-sp-diag .card.hasart>.tk{left:calc(var(--tky) * .3 * (var(--j) + 1))!important} }
body.lab-sp-fanL .card.hasart>.tk,body.lab-sp-fanR .card.hasart>.tk{left:0!important;top:0!important;transform-origin:50% 100%}
body.lab-sp-fanL .card.hasart>.tk{transform:rotate(calc(-7deg * (var(--j) + 1))) translateY(calc(var(--tky) * -.55 * (var(--j) + 1)))}
body.lab-sp-fanR .card.hasart>.tk{transform:rotate(calc(7deg * (var(--j) + 1))) translateY(calc(var(--tky) * -.55 * (var(--j) + 1)))}
/* identical tokens stack into one tucked card with a count */
.card.hasart>.tk>.tkn{position:absolute;right:7%;top:calc(var(--tky) * .14);z-index:2;background:#2b211a;color:#fff;font:800 10px/14px var(--f-body);padding:0 5px;border-radius:999px;font-size:10px;line-height:14px}

/* --- the deck: the revealed unit is the top card of a pile; thickness shows as card edges under it --- */
.table .deckz .slot.labempty,.table .chz .slot.labempty,.table .grz .labempty{display:flex;align-items:center;justify-content:center;border:2px dashed rgba(110,80,40,.35);border-radius:8px;background:none;color:var(--muted);font-size:12px;font-weight:700;box-sizing:border-box;width:var(--bcw);height:var(--bch)}
.labcnt{position:static;display:inline-block;vertical-align:middle;margin-left:6px;letter-spacing:0;text-transform:none;z-index:6;padding:1px 9px;border-radius:999px;background:linear-gradient(#cfae6e,#a8843f);border:1px solid #6e5223;color:#2b1d0c;font:400 12px/18px Marcellus,serif;white-space:nowrap;box-shadow:0 1px 2px rgba(0,0,0,.3);cursor:pointer;min-height:20px}
.labcnt i{font-style:normal;font-size:11px;margin-left:4px;color:#5a3a8a}
.table .zl.labzl{cursor:pointer}
/* --- the graveyard: a face-down pile, lit like the others, with a count --- */
.table .grave.labgpile{width:auto!important;background:none!important;padding:0!important;min-height:0!important;display:block;cursor:pointer}
.gcard{display:block!important;position:relative;width:var(--bcw);height:var(--bch);isolation:isolate}
.gcard .oback{position:absolute;inset:0;z-index:0}
/* the card back: a placeholder until Brian's card back art (to-do "Add card back art"); swap the look here only. Used by
   the graveyard pile and by a defeated card's flip (.dfback) */
.oback{display:flex;align-items:center;justify-content:center;box-sizing:border-box;border-radius:5% / 3.6%;
  background:radial-gradient(ellipse at 50% 42%,#4a3626 0%,#2e2118 62%,#21170f 100%);
  box-shadow:inset 0 0 calc(var(--bcw,140px) * .12) rgba(0,0,0,.45);
  color:#c9a45f;font:400 calc(var(--bcw,140px) * .13)/1 Marcellus,serif;letter-spacing:.14em;text-indent:.14em;overflow:hidden}
.oback::before{content:"Oasis";text-transform:uppercase;padding:.35em .2em;border-top:1px solid rgba(201,164,95,.55);border-bottom:1px solid rgba(201,164,95,.55)}
.oback::after{content:"";position:absolute;inset:calc(var(--bcw,140px) * .035);border:calc(var(--bcw,140px) * .01) solid #b8924f;border-radius:3% / 2.2%;pointer-events:none}
/* a cropped card (phone) is cut to its type tab at the bottom: the frame and the mark stay inside the card body above it */
body.lab-crop .oback{padding-bottom:calc(var(--bch,140px) * .0625)}
body.lab-crop .oback::after{bottom:calc(var(--bch,140px) * .0625 + var(--bcw,140px) * .035)}
.gcard .gn{position:absolute;right:-8px;top:-10px;z-index:6;background:#6b6258;color:#fff;font:800 11px/16px var(--f-body);padding:0 7px;border-radius:999px}

/* --- zones as mats printed on the table (lean and table views) --- */
body.lab-v-lean .table .tz,body.lab-v-table .table .tz{background:rgba(120,90,50,.10);box-shadow:inset 0 0 0 1.5px rgba(110,80,40,.28),inset 0 2px 6px rgba(80,55,25,.18);border-radius:12px;padding:8px 10px}
body.lab-v-lean .table .tz .zl,body.lab-v-table .table .tz .zl{color:#6e5a3e;font-weight:800}
body.lab-v-lean .line.table,body.lab-v-table .line.table{background:radial-gradient(ellipse at 50% 45%,#e9dfcc 0%,#d9ccb3 60%,#c8b897 100%);box-shadow:inset 0 0 60px rgba(80,55,25,.25);border-radius:18px;padding:18px 14px 22px}
/* lean: each zone's cards lean back on their own; labels stay flat */
body.lab-v-lean .table .tz>.tzc{transform:perspective(700px) rotateX(calc(var(--tilt, 24deg) * .9));transform-origin:50% 100%}
/* table: the whole table tips back */
body.lab-v-table .line.table{position:relative;transform:perspective(1500px) rotateX(var(--tilt, 24deg));transform-origin:50% 60%}
@media (max-width:640px){ body.lab-v-table .line.table{transform:perspective(900px) rotateX(calc(var(--tilt, 24deg) * .92));transform-origin:50% 55%} body.lab-v-lean .line.table,body.lab-v-table .line.table{padding:10px 6px 14px} body.lab-v-lean .table .tz,body.lab-v-table .table .tz{padding:5px 5px} }
/* mats hug their cards, pushed toward the middle of the table */
body.lab-v-lean .table .trow>.tz,body.lab-v-table .table .trow>.tz{width:max-content;max-width:100%;box-sizing:border-box}
body.lab-v-lean .table .trow>.tz:first-child,body.lab-v-table .table .trow>.tz:first-child{justify-self:end}
body.lab-v-lean .table .trow>.tz:last-child,body.lab-v-table .table .trow>.tz:last-child{justify-self:start}
body.lab-v-lean .table .trow>.tz:nth-child(2),body.lab-v-table .table .trow>.tz:nth-child(2){justify-self:center}
/* the charge spot is part of the mat, not a grey box */
body.lab-v-lean .stage .table .charge,body.lab-v-table .stage .table .charge{background:none!important;box-shadow:none!important;border:0!important}
body.lab-v-lean .table .charge>.note,body.lab-v-table .table .charge>.note{display:flex;align-items:center;justify-content:center;width:var(--bcw);height:var(--bch);border:2px dashed rgba(110,80,40,.35);border-radius:8px;box-sizing:border-box}
/* lean: one camera for the whole table, so the far row (the AI's) sits deeper and looks smaller, like a real table */
body.lab-v-lean .line.table{perspective:1100px;perspective-origin:50% 30%}
body.lab-v-lean .line.table>.trow.s1{transform:translateZ(calc(var(--ldepth, 260px) * -1))}
body.lab-v-lean .line.table>.clash{transform:translateZ(calc(var(--ldepth, 260px) * -.5))}
body.lab-v-lean .line.table>.city.s1{transform:translateZ(calc(var(--ldepth, 260px) * -1.5))}
body.lab-v-lean .line.table>.city.s0{transform:translateZ(calc(var(--ldepth, 260px) * .25))}
@media (max-width:640px){ body.lab-v-lean .line.table{perspective:700px;perspective-origin:50% 30%} }
/* the crop as an inline mask (the clip path could fail to apply inside the tilted views, leaving square corners) */
:root{--labmask:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA3NTAgNzI4JyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSdub25lJz48cGF0aCBmaWxsPScjMDAwJyBkPSdNMCw0MCBRMCwwIDQwLDAgSDcxMCBRNzUwLDAgNzUwLDQwIFY2NTAuNSBRNzUwLDY4Mi41IDcxOCw2ODIuNSBINTE1LjUgTDUxMyw2OTAgTDUwNyw3MDAgTDUwMSw3MTAgTDQ5NSw3MjAgTDQ5NCw3MjIgSDI5MC41IEwyODcsNzE4IEwyODEsNzEwIEwyNzQsNzAwIEwyNjcsNjkwIEwyNjQuNSw2ODIuNSBIMzIgUTAsNjgyLjUgMCw2NTAuNSBaJy8+PC9zdmc+")}
body.lab-crop .table .card.hasart:not(.mini)>.cartbg,body.lab-crop .table .card.hasart>.tk,body.lab-crop .labsh>i,body.lab-crop .lablt,body.lab-crop .gcard .oback{clip-path:none!important;-webkit-mask:var(--labmask) center / 100% 100% no-repeat;mask:var(--labmask) center / 100% 100% no-repeat}
/* a breaking Shield token: its shards come from the cropped card too */
/* battle arrows, their labels, and ability notes with their lines draw above the damage cubes */
#view-play .stage .abwin,.abghost{z-index:10}
/* --- performance: depth drawn without filter chains or blend modes, so moving cards stay smooth ---
   the card edge is solid layers under the face; one soft shadow sits on a plain rounded box; tucked cards darken with
   an overlay instead of a filter; the light is a normal-blend gradient */
body.lab-stock .labsh{filter:none!important}
body.lab-stock .labsh>i{box-shadow:0 4px 4px rgba(0,0,0,.3),0 11px 16px rgba(0,0,0,.2)}
body.lab-stock .labsh>b{position:absolute;inset:0;border-radius:5% / 3.6%}
body.lab-crop.lab-stock .labsh>i{box-shadow:none}
body.lab-crop.lab-stock .labsh::before{content:"";position:absolute;inset:4% 2% 7% 2%;border-radius:8px;box-shadow:0 4px 5px rgba(0,0,0,.3),0 12px 18px rgba(0,0,0,.2)}
body.lab-crop.lab-stock .labsh>b{position:absolute;inset:0;background:#2c2119;-webkit-mask:var(--labmask) center / 100% 100% no-repeat;mask:var(--labmask) center / 100% 100% no-repeat}
body.lab-stock .labsh>b{transform:translateY(var(--o,2px))}
body.lab-stock .card.hasart>.tk{filter:none!important}
body.lab-stock .card.hasart>.tk::after{content:"";position:absolute;inset:0;background:rgba(0,0,0,.08);pointer-events:none}
body.lab-light .lablt{mix-blend-mode:normal!important;background:linear-gradient(160deg,rgba(255,255,255,.14) 0%,rgba(255,255,255,0) 30%,rgba(0,0,0,0) 60%,rgba(0,0,0,.16) 100%)!important}
.table .card.hasart:not(.mini){will-change:transform}
/* phones in battle: the play space runs edge to edge (no panel border or side gutters) */
@media (max-width:640px){
  body.lab-inbattle #view-play .panel:has(> .stage){width:100vw;margin-left:calc(50% - 50vw);border-left:0;border-right:0;border-radius:0;padding-left:0;padding-right:0;box-sizing:border-box}
  body.lab-inbattle #view-play .panel:has(> .stage)>.battlectl{margin-left:0;margin-right:0;border-radius:0}
  body.lab-inbattle #view-play .panel:has(> .stage)>.row:not(.battlectl){padding-left:10px;padding-right:10px}
  body.lab-v-lean .line.table,body.lab-v-table .line.table{border-radius:0;padding-left:4px;padding-right:4px}
}
/* the space around the tipped (or leaning) table is sand too, so no page background shows beside its far end */
body.lab-v-lean #view-play .stage,body.lab-v-table #view-play .stage{background:radial-gradient(ellipse at 50% 40%,#ddd0b6 0%,#cdbd9c 70%,#bfae8b 100%)}
@media (max-width:640px){
  body.lab-inbattle.lab-v-lean #view-play .panel:has(> .stage),body.lab-inbattle.lab-v-table #view-play .panel:has(> .stage){background:#cdbd9c}
}

/* --- deck view sheet --- */
.labsheet{position:fixed;inset:0;z-index:120;background:rgba(20,16,12,.38);display:flex;align-items:center;justify-content:center}
.labsheet .lsbox{width:min(760px,94vw);max-height:86vh;background:#f7f7f8;border-radius:16px;box-shadow:0 18px 50px rgba(0,0,0,.3);padding:16px;display:flex;gap:16px;box-sizing:border-box}
.labsheet .lslist{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px;overflow:auto}
.labsheet .lshd{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.labsheet .lshd h2{margin:0;font:400 22px/1 Marcellus,serif}
.labsheet .lshd span{font-size:13px;color:var(--muted)}
.labsheet .lsrow{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:8px 12px;border-radius:10px;border:1px solid var(--line);background:#fff;font:inherit;color:inherit;text-align:left;cursor:pointer}
.labsheet .lsrow[aria-pressed="true"]{background:#fff8e8;border-color:#c9a45c}
.labsheet .lsrow .n{flex:none;width:22px;font-weight:800;color:var(--muted)}
.labsheet .lsrow .nm{font:400 17px/1.1 Marcellus,serif}
.labsheet .lsrow.mir .nm{font-style:italic;color:#6a4f8a}
.labsheet .lsrow .tg{font-size:10px;letter-spacing:.1em;text-transform:uppercase;font-weight:800;color:var(--azure)}
.labsheet .lsrow .chips{display:flex;gap:5px;flex-wrap:wrap}
.labsheet .lsrow .chips span{font-size:11px;font-weight:700;padding:1px 7px;border-radius:999px;background:#efe9dd;border:1px solid #d8ccb4;color:#5a4630}
.labsheet .lsrow .lv{margin-left:auto;flex:none;padding:0 6px;border-radius:999px;border:1px solid #a7834b;color:#6b4e22;background:#fff;font-weight:800;font-size:10px;line-height:15px}
.labsheet .lsart{flex:none;width:250px;display:flex;flex-direction:column;gap:8px}
.labsheet .lsart img{width:100%;border-radius:12px;box-shadow:0 6px 18px rgba(0,0,0,.25)}
.labsheet .lsclose{align-self:flex-start;font:700 13px var(--f-body);padding:8px 12px;border-radius:10px;border:1px solid var(--line);background:#fff;cursor:pointer}
@media (max-width:640px){
  .labsheet{align-items:flex-end}
  .labsheet .lsbox{width:100%;max-height:78vh;border-radius:18px 18px 0 0;flex-direction:column;padding:12px 12px 20px}
  .labsheet .lsart{width:auto;align-items:center}
  .labsheet .lsart img{width:62%}
  .labsheet .lsbox.showart .lslist{display:none}
  .labsheet .lsbox:not(.showart) .lsart{display:none}
}
