/* Battle-screen styles (arena layout, units, hand, battle HUD, ultimate comic panel, end poses).
   Owned by the battle agent; loaded after style.css so rules here override. Everything is scoped under #battle / .ultx. */

/* ---------- screen layout: full-height column, the field takes whatever the HUD + hand leave ---------- */
#battle{display:flex;flex-direction:column;flex:1;min-height:calc(100dvh - 22px - var(--sat) - var(--sab));gap:0}
#battle .btop{display:flex;align-items:center;justify-content:space-between;gap:6px;flex-wrap:nowrap;flex:none}
#battle .btop button{font-size:13px;padding:3px 9px;min-height:36px;border-radius:12px;box-shadow:0 3px 0 var(--ink)}
#battle .btop .row{display:flex;gap:6px;flex-wrap:nowrap}
#battle #autoBtn.on{background:linear-gradient(#bff59a,#5cc23a);color:#fff;text-shadow:var(--ol1)}
#battle #roundLbl{font-size:13.5px;font-weight:700;background:#fff;border:2.5px solid var(--ink);border-radius:999px;padding:2px 10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
#battle #roundLbl .fat{color:#8a5cff;font-size:11.5px}

#battle #field{position:relative;flex:1 1 auto;height:auto;min-height:330px;max-height:560px;margin:4px 0 2px;border-radius:22px;overflow:visible}
#battle #field>svg{position:absolute;inset:0;width:100%;height:100%}
#battle .midline{position:absolute;left:8%;right:8%;top:50%;height:0;border-top:3px dashed #ffffff99;pointer-events:none}

/* ---------- units: compact (name · HP · rage above the sprite), sized from the field height ---------- */
#battle .cu{position:absolute;width:min(150px,36vw);translate:-50% -50%;text-align:center;z-index:2;--sz:min(138px,16.5dvh)}
#battle .cu.slot0{z-index:3}
#battle .cu .bw{position:relative;height:calc(var(--sz) * .7);margin-top:calc(var(--sz) * -.06);display:grid;place-items:end center}
#battle .cu .bw svg{margin-top:calc(var(--sz) * -.12)}
#battle .cu .bw svg{width:var(--sz);height:auto;transition:filter .2s}
#battle .cu.foe .bw svg{scale:-1 1}
#battle .cu.boss{--sz:min(165px,19.5dvh);width:min(170px,42vw)}
#battle .cu.boss .bw::before{content:'';position:absolute;inset:-8px;background:radial-gradient(circle,#ff5a7a55,transparent 65%);animation:pulse 2s ease-in-out infinite;border-radius:50%}
#battle .cu::after{content:'';position:absolute;left:50%;bottom:-2px;translate:-50% 0;width:calc(var(--sz) * .8);height:10px;border-radius:50%;background:#5b3a3226;z-index:-1}

#battle .nm{display:flex;align-items:center;justify-content:center;gap:2px;max-width:100%;font-size:10.5px;line-height:15px;background:#fff;border:2px solid var(--ink);border-radius:999px;padding:0 5px;margin:0 auto 2px;white-space:nowrap;width:max-content}
#battle .nm .n{overflow:hidden;text-overflow:ellipsis;max-width:62px}
#battle .nm .lv{font-size:9.5px;line-height:12px;padding:0 4px;border-width:1.5px}
#battle .nm .sp{font-size:9.5px;opacity:.75}
#battle .foe .nm{background:#fff0f0}
#battle .ally .nm{background:#f0fff0}

#battle .hpbar{position:relative;height:14px;margin:0 4px;background:#fff;border:2.5px solid var(--ink);border-radius:9px;overflow:hidden}
#battle .hpbar span{position:absolute;inset:0;font-size:10px;line-height:10px;font-weight:700;color:#fff;text-shadow:var(--ol1);white-space:nowrap}
#battle .cu.low .hpbar{animation:lowHp .8s ease-in-out infinite}
@keyframes lowHp{50%{box-shadow:0 0 0 3px #ff3a5a88}}
#battle .ragebar{position:relative;height:7px;margin:2px 12px 0;background:#fff;border:2px solid var(--ink);border-radius:6px;overflow:visible}
#battle .ragebar i{display:block;height:100%;width:0;border-radius:4px;background:linear-gradient(90deg,#ffcf4a,#ff7a2a,#ff3a3a);transition:width .3s}
#battle .ragebar b{position:absolute;left:-13px;top:-6px;font-size:11px;line-height:1;filter:grayscale(1) opacity(.5);transition:filter .3s}
#battle .ragebar.full{box-shadow:0 0 8px 2px #ff5a3a;animation:pulse .5s infinite}
#battle .ragebar.full b{filter:none;transform:scale(1.25)}

/* statuses: small pills overlaid at the sprite's feet */
#battle .sts{position:absolute;left:50%;bottom:-6px;translate:-50% 0;display:flex;gap:2px;flex-wrap:wrap;justify-content:center;width:max-content;max-width:150%;min-height:0;font-size:10px;margin:0;pointer-events:none;z-index:4}
#battle .sts span{background:#fff;border:1.5px solid var(--ink);border-radius:999px;padding:0 4px;line-height:14px;animation:pop .3s;white-space:nowrap}
#battle .sts span i{font-style:normal;font-size:8.5px;opacity:.7;margin-left:1px}
#battle .sts .up{background:#fff6c8}#battle .sts .down{background:#e8e0ff}#battle .sts .psn{background:#f0dcff}#battle .sts .stn{background:#fff3a0;animation:pop .3s,wob 1s ease-in-out infinite}
@keyframes wob{50%{transform:rotate(12deg)}}

/* queued cards (chips) float above the head; turn-order badge; target badge */
#battle .qc{position:absolute;left:50%;top:-20px;translate:-50% 0;display:flex;gap:2px;min-height:0;z-index:5;pointer-events:none}
#battle .chip.mc{width:13px;height:18px;border-radius:4px;border-width:2px;box-shadow:inset 0 0 0 2px #ffffffaa;rotate:-6deg}
#battle .chip.mc:nth-child(even){rotate:6deg}
#battle .ordb{position:absolute;left:0;bottom:calc(var(--sz) * .4);width:22px;height:22px;border-radius:50%;background:#7fd3ff;border:2.5px solid var(--ink);color:#fff;text-shadow:var(--ol1);font-size:12px;font-weight:700;line-height:17px;display:none;z-index:5}
#battle .cu.has-ord .ordb{display:block;animation:pop .3s}
#battle .cu.has-ord.done .ordb{opacity:.35;transform:scale(.8)}
#battle .cu.acting .ordb{background:#ffb627;transform:scale(1.2)}
#battle .tg{position:absolute;right:0;bottom:calc(var(--sz) * .45);font-size:11px;background:#ff7096;color:#fff;border:2px solid var(--ink);border-radius:999px;padding:0 4px;line-height:15px;display:none;z-index:5;white-space:nowrap}
#battle .cu.targeted .tg{display:block;animation:pop .3s}
#battle .cu.targeted .bw svg{filter:drop-shadow(0 0 6px #ff7096)}
#battle .cu.locked .bw::after{content:'';position:absolute;left:50%;top:50%;width:calc(var(--sz) * 1.1);aspect-ratio:1;translate:-50% -50%;border:3px dashed #ff3a6a;border-radius:50%;animation:lockSpin 1.2s linear infinite;pointer-events:none}
@keyframes lockSpin{to{rotate:360deg}}

#battle .cu.hl .bw svg{filter:drop-shadow(0 0 8px #fff) drop-shadow(0 0 5px #ffb627)}
#battle .cu.acting .bw svg{filter:drop-shadow(0 0 10px #fff) drop-shadow(0 0 4px #ffd34a)}
#battle .cu.acting{z-index:6}
#battle .cu.dead{animation:faint 1s forwards;pointer-events:none}
#battle .cu.dead .bw{transition:transform .9s;transform:rotate(-14deg) translateY(14px)}

/* ---------- HUD + hand ---------- */
#battle .log{flex:none;font-size:12px;line-height:16px;min-height:32px;max-height:32px;overflow:hidden;color:var(--ink);text-align:center;padding:0 6px;display:flex;align-items:center;justify-content:center}
#battle .bbar{display:flex;align-items:center;gap:8px;flex:none}
#battle .energy{width:54px;height:54px;font-size:22px;flex:none}
#battle .pile{font-size:10.5px;line-height:1.25;padding:3px 7px;flex:none}
#battle #fightBtn{flex:1;min-height:50px;font-size:19px}
#battle #fightBtn.ready{animation:readyPulse 1.2s ease-in-out infinite}
@keyframes readyPulse{50%{box-shadow:0 6px 0 var(--ink),0 0 0 6px #ffb62788}}

#battle .hand{flex:none;display:flex;flex-wrap:nowrap;justify-content:flex-start;gap:7px;overflow-x:auto;overflow-y:visible;min-height:0;padding:24px 12px 10px 18px;margin:0 -12px;
  scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;scrollbar-width:none;overscroll-behavior-x:contain;scroll-padding-inline:18px 12px}
#battle .hand::-webkit-scrollbar{display:none}
#battle .hand .card{flex:none;scroll-snap-align:start;width:98px;height:150px;padding:4px;border-radius:14px}
#battle .hand .card .art{height:44px;margin-bottom:2px}
#battle .hand .card .art svg{height:40px}
#battle .hand .card .cname{font-size:12.5px;line-height:1.2}
#battle .hand .card .cdesc{font-size:10px;line-height:1.3}
#battle .hand .card .owner{font-size:9.5px}
#battle .hand .card.q{transform:translateY(-16px)!important;box-shadow:0 0 0 4px #ffb627,0 8px 18px #ffb62788}
#battle .hand .card .ord{top:-14px;right:-6px;font-size:11.5px;padding:0 6px;background:#ff7096}
#battle .hand .card .hint{position:absolute;left:50%;bottom:-9px;translate:-50% 0;display:flex;gap:2px;pointer-events:none}
#battle .hand .card .hint span{font-size:9.5px;line-height:14px;padding:0 5px;border-radius:999px;border:1.5px solid var(--ink);white-space:nowrap;color:#fff;text-shadow:var(--ol1)}
#battle .hand .card .hint .adv{background:#5cc23a}
#battle .hand .card .hint .dis{background:#a89a94}
#battle .hand .card .hint .blk{background:#fff;text-shadow:none}
@media (hover:none){#battle .hand .card:hover{transform:none}#battle .hand .card.q:hover{transform:translateY(-16px)!important}}

/* Rexy's tutorial bubble: ui/style.css docks it at the top in battle (over the foe back row) — kept as is */

/* ---------- ultimate comic panel ---------- */
.ultx{position:fixed;inset:0;z-index:62;display:grid;place-items:center;pointer-events:none;background:#0007;animation:fadeIn .15s}
.ux-panel{position:relative;width:min(88vw,370px);aspect-ratio:1.15;border:5px solid var(--ink);border-radius:8px;overflow:hidden;
  background:radial-gradient(circle,#fff 0 18%,var(--c) 60%,var(--c2));box-shadow:8px 8px 0 var(--ink);rotate:-3deg;
  animation:uxIn var(--dur) cubic-bezier(.2,.9,.3,1.3) both}
.theirs .ux-panel{rotate:3deg;animation-name:uxIn2}
.ux-lines{position:absolute;inset:-40%;background:repeating-conic-gradient(from 0deg,#ffffff88 0 3deg,transparent 3deg 12deg);animation:lockSpin 6s linear infinite}
.ux-panel::after{content:'';position:absolute;inset:0;background:radial-gradient(#5b3a3233 1.2px,transparent 1.6px) 0 0/9px 9px;mix-blend-mode:multiply;pointer-events:none}
.ux-sfx{position:absolute;top:6%;left:6%;font-size:42px;font-weight:700;color:#fff;text-shadow:var(--ol),0 5px 0 var(--ink);rotate:-10deg;z-index:2;animation:uxSfx .4s .15s cubic-bezier(.2,.9,.3,1.6) both}
.ux-dino{position:absolute;inset:16% 10% 26%;display:grid;place-items:center;z-index:1}
.ux-dino svg{width:78%;height:auto;animation:uxDino var(--dur) ease-out both}
.theirs .ux-dino svg{scale:-1 1}
.ux-cap{position:absolute;left:0;right:0;bottom:0;background:#fff;border-top:4px solid var(--ink);padding:5px 10px 7px;display:flex;flex-direction:column;align-items:center;gap:1px;z-index:2}
.ux-cap b{font-size:21px;line-height:1.2}
.ux-cap small{font-size:12px;color:var(--muted)}
.ux-who{font-size:11px;background:var(--c);color:#fff;text-shadow:var(--ol1);border:2px solid var(--ink);border-radius:999px;padding:0 8px;margin-top:-18px}
@keyframes uxIn{0%{transform:translateX(-120%) scale(.6)}18%{transform:none}86%{transform:none;opacity:1}100%{transform:translateX(30%) scale(.9);opacity:0}}
@keyframes uxIn2{0%{transform:translateX(120%) scale(.6)}18%{transform:none}86%{transform:none;opacity:1}100%{transform:translateX(-30%) scale(.9);opacity:0}}
@keyframes uxSfx{from{transform:scale(0) rotate(-30deg)}}
@keyframes uxDino{0%{transform:scale(.7)}25%{transform:scale(1.12)}40%{transform:scale(1)}100%{transform:scale(1.04)}}

/* ---------- end-of-battle poses (CSS fallback; art.creaturePoseSVG replaces the sprite when available) ---------- */
#battle .cu.posed{opacity:1;filter:none;animation:none}
#battle .cu .pose-tag{position:absolute;right:-2px;top:22px;font-size:20px;z-index:6;animation:pop .4s}
#battle .cu.pose-win .bw{animation:jump .45s ease-in-out infinite alternate}
#battle .cu.pose-hips .bw{animation:sway 1.2s ease-in-out infinite}
#battle .cu.pose-lose .bw{filter:saturate(.75)}
#battle .cu.pose-lose:not(.svgpose) .bw{transform:rotate(-80deg) translate(10px,6px);transition:transform .6s}
#battle .cu.pose-lose .pose-tag{animation:pop .4s,wave .6s ease-in-out infinite alternate;transform-origin:bottom left}
@keyframes wave{to{rotate:-25deg}}
#battle .cu.pose-sit .bw{filter:saturate(.85)}
#battle .cu.pose-sit:not(.svgpose) .bw{transform:scaleY(.86) translateY(8px)}
#battle .cu.pose-gloat .bw{animation:jump .5s ease-in-out infinite alternate}

/* ---------- v3: planning timer, reserve bench, stage condition, card level / moving-card badges ---------- */
#battle .bt-timer{flex:none;width:0;height:46px;overflow:hidden;opacity:0;transition:width .25s,opacity .25s;position:relative;display:grid;place-items:center;--p:1}
#battle .bt-timer.on{width:46px;opacity:1}
#battle .bt-timer::before{content:'';position:absolute;inset:0;border-radius:50%;border:2.5px solid var(--ink);
  background:conic-gradient(#7fd3ff calc(var(--p) * 360deg),#fff 0);box-shadow:0 3px 0 var(--ink)}
#battle .bt-timer::after{content:'';position:absolute;inset:7px;border-radius:50%;background:#fff;border:2px solid var(--ink)}
#battle .bt-timer b{position:relative;z-index:1;font-size:15px;line-height:1}
#battle .bt-timer.warn::before{background:conic-gradient(#ffb627 calc(var(--p) * 360deg),#fff 0)}
#battle .bt-timer.crit::before{background:conic-gradient(#ff5a5a calc(var(--p) * 360deg),#fff 0)}
#battle .bt-timer.crit{animation:pulse .5s ease-in-out infinite}
#battle .bt-timer.crit b{color:#e0303a}

#battle .cond-chip{position:absolute;right:6px;top:50%;translate:0 -50%;z-index:4;max-width:46%}
#battle .cond-chip button{display:flex;flex-direction:column;align-items:flex-end;font-size:10.5px;line-height:14px;background:#ffffffeb;border:2px solid var(--ink);border-radius:12px;padding:2px 8px;min-height:0;box-shadow:none;text-align:right}
#battle .cond-chip button i{font-style:normal;opacity:.6}
#battle .cond-chip button small{font-size:9.5px;line-height:12px;opacity:.8;white-space:normal}

#battle .bench{position:absolute;z-index:1;width:58px;text-align:center;background:#ffffffcc;border:2px dashed var(--ink);border-radius:14px;padding:2px 2px 3px;pointer-events:auto}
#battle .bench.ally{left:2px;top:50%;margin-top:14px}
#battle .bench.foe{right:2px;top:50%;margin-top:-104px}
#battle .bench .bsvg svg{width:46px;height:auto;display:block;margin:0 auto -2px}
#battle .bench.foe .bsvg svg{scale:-1 1}
#battle .bench small{display:block;font-size:9px;line-height:11px;color:var(--muted)}
#battle .bench b{display:block;font-size:9.5px;line-height:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#battle .bench.ally{animation:benchBob 2.4s ease-in-out infinite}
@keyframes benchBob{50%{transform:translateY(-3px)}}

#battle .nm .pas{font-size:10px;margin-left:1px}
#battle .hand .card .clv{position:absolute;left:-5px;top:-9px;font-size:10px;line-height:15px;padding:0 5px;border-radius:999px;background:#7a5cff;color:#fff;border:2px solid var(--ink);text-shadow:var(--ol1);z-index:2}
#battle .hand .card .mv{position:absolute;right:3px;bottom:3px;font-size:11px;opacity:.8;pointer-events:auto}

/* ---------- reserve swap animations (driven by Web Animations in battle.js; these are the props) ---------- */
#battle .cu.leaving{animation:none;opacity:1;filter:saturate(.6)}
#battle .cu.leaving .hpbar,#battle .cu.leaving .ragebar,#battle .cu.leaving .nm,#battle .cu.leaving .sts{opacity:0;transition:opacity .3s}
#battle .cu.swapin{z-index:7}
#battle .cu .swap-tag{position:absolute;left:50%;top:-30px;translate:-50% 0;font-size:22px;z-index:8;animation:pop .35s}
#battle .swap-rope{position:absolute;left:50%;top:55%;width:46px;height:0;border-top:3px dashed #a8743a;transform-origin:left center;rotate:180deg}
#battle .ally .swap-rope{rotate:0deg}
#battle .swap-balloons{position:absolute;left:50%;bottom:34%;translate:-50% 0;width:70px;display:flex;justify-content:center;gap:0;font-size:26px;z-index:8;pointer-events:none}
#battle .swap-balloons svg{width:58px;height:auto;display:block}
#battle .swap-balloons:has(svg)::after{display:none}
#battle .swap-balloons span{display:inline-block;animation:sway 1.1s ease-in-out infinite alternate}
#battle .swap-balloons span:nth-child(2){translate:0 -12px;animation-delay:.3s}
#battle .swap-balloons::after{content:'';position:absolute;left:50%;bottom:-26px;height:28px;border-left:2px solid #5b3a32aa}
#battle .cu.floaty .bw{transform:rotate(0) translateY(0)!important}

/* ---------- v3 poses: crown / UFO escape / run away ---------- */
#battle .cu .pose-tag.pt-crown{right:auto;left:50%;top:6px;translate:-50% 0;font-size:24px;animation:pop .4s,crownBob 1s ease-in-out infinite alternate}
@keyframes crownBob{to{translate:-50% -5px;rotate:6deg}}
#battle .cu.pose-crown .bw{animation:jump .6s ease-in-out infinite alternate}
#battle .cu .pose-tag.pt-ufo{right:auto;left:50%;top:auto;bottom:-8px;translate:-50% 0;font-size:34px}
#battle .cu.pose-ufo{animation:ufoUp 2.6s ease-in .6s both}
@keyframes ufoUp{0%{transform:none}25%{transform:translateY(-14px) rotate(-3deg)}45%{transform:translateY(-8px) rotate(3deg)}100%{transform:translateY(-260px) scale(.6);opacity:0}}
#battle .cu.pose-ufo .bw::after{content:'';position:absolute;left:50%;bottom:-6px;translate:-50% 0;width:70%;height:130%;background:linear-gradient(#fff7a000,#fff7a088);clip-path:polygon(30% 0,70% 0,100% 100%,0 100%);z-index:-1;animation:pulse 1s infinite}
#battle .cu.pose-run{animation:runAway 1.8s ease-in .5s both}
#battle .cu.pose-run .bw{animation:jump .18s ease-in-out infinite alternate}
#battle .cu .pose-tag.pt-run{right:auto;left:-8px;top:auto;bottom:4px;font-size:22px}
#battle .cu.foe.pose-run{animation-name:runAwayL}
@keyframes runAwayL{0%{transform:none}100%{transform:translateX(-120vw)}}
@keyframes runAway{0%{transform:none}20%{transform:translateX(-8px)}100%{transform:translateX(120vw)}}

/* friend feedback (narrow web/phone screens): all 5 hand cards fit on one row, no sideways scrolling needed */
#battle .hand{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px;overflow:visible;padding:24px 6px 10px;margin:0 -6px}
#battle .hand .card{width:auto;min-width:0;height:142px;padding:3px;overflow:hidden}
#battle .hand .card .art{height:36px}
#battle .hand .card .art svg{height:34px}
#battle .hand .card .cname{font-size:11.5px}
#battle .hand .card .cdesc{font-size:9.5px;line-height:1.25;overflow:hidden}
@media (max-width:380px){#battle .hand .card .cname{font-size:10.5px}#battle .hand .card .cdesc{font-size:8.5px}}
