/* Battle-local galleries share the real card face and preserve its full rules. */
#app:has(.battle-mulligan),#app:has(.battle-pile-sheet),
.battle-root:has(.battle-mulligan),.battle-root:has(.battle-pile-sheet),
.battle-view:has(.battle-mulligan),.battle-view:has(.battle-pile-sheet){isolation:auto}
.battle-mulligan,.battle-sheet-backdrop{position:fixed;inset:0;z-index:75;background:rgba(3,14,23,.5);backdrop-filter:blur(15px) saturate(.65);-webkit-backdrop-filter:blur(15px) saturate(.65)}
.battle-mulligan {
  display:grid;grid-template: minmax(0,1fr) / minmax(0,1fr);
  overflow:hidden;overscroll-behavior:contain;
  padding:calc(14px + env(safe-area-inset-top,0px)) 12px calc(10px + env(safe-area-inset-bottom,0px));
}
.mulligan-choice:not([hidden]) {
  display:grid;grid-template:auto minmax(0,max-content) auto / minmax(0,1fr);
  align-content:center;gap:12px;min-height:0;
}
.mulligan-status {
  display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px 20px;
  color:#d5eaf6;text-align:center;font:600 17px/1.2 var(--font-ui,sans-serif);
}
.mulligan-swap-pips {
  display:inline-flex;align-items:center;gap:6px;color:#a6d9f6;
  padding:4px 9px;background:#0c202ed9;border:1px solid #9fcae44d;
}
.mulligan-swap-pips .battle-icon {width:16px;height:16px;margin-right:2px}
.mulligan-swap-pips i {
  width:9px;height:9px;border:1px solid #8fb7ce;background:#142d3f;
}
.mulligan-swap-pips i.is-marked {background:#a6d9f6;box-shadow:0 0 7px #79caf788}
.battle-mulligan-cards,.battle-pile-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 12px;width:100%;max-width:580px;align-items:start;margin:0 auto}
.battle-mulligan-cards {
  max-width:362px;min-height:0;overflow:auto;overscroll-behavior:contain;
  scrollbar-width:thin;align-content:start;padding:12px 5px;scroll-padding-block:12px;
}
.battle-opening-card{min-width:0}.battle-mulligan-card,.battle-pile-card{display:block;width:100%;padding:0;position:relative;min-width:0;border:0;background:none;touch-action:pan-y}
.battle-mulligan-card>.card-face,.battle-pile-card>.card-face{box-shadow:0 8px 28px #0005}
.battle-mulligan-card.is-swapping>.card-face{box-shadow:0 0 0 2px #a6d9f6,0 8px 28px #0005}
.battle-mulligan-mark {
  position:absolute;z-index:6;top:0;left:50%;transform:translate(-50%,-50%);
  padding:3px 9px;border:1px solid #c2e5fa;border-radius:3px;background:#a6d9f6;color:#0c2130;
  font:600 11px/1.2 var(--font-ui,sans-serif);letter-spacing:.12em;text-transform:uppercase;pointer-events:none;
}
.battle-mulligan footer{display:flex;justify-content:center}
.battle-mulligan .battle-begin{--control-surface:transparent;--control-hover:rgba(232,239,234,.12);min-width:160px;min-height:47px;font-size:15px!important;background:transparent;color:#e8efea!important;backdrop-filter:none;-webkit-backdrop-filter:none}

.battle-opening-reveal {
  display:grid;justify-items:center;align-content:center;align-self:center;gap:17px;
  max-height:100%;padding:12px 4px;overflow:auto;text-align:center;
  animation:opening-sequence var(--opening-duration) linear both;
}
.opening-opponent img {width:100%;height:100%;object-fit:cover}
.opening-opponent>strong,.opening-ambush {
  color:#e3f3fc;font:600 clamp(17px,4.2vw,22px)/1.15 var(--font-ui,sans-serif);
  letter-spacing:.045em;text-shadow:0 2px 12px #030d17;
}
.opening-ambush {
  padding:8px 28px;border-inline:2px solid currentColor;
  background:linear-gradient(90deg,transparent,#4a2423d9,transparent);
  animation:opening-alert 440ms cubic-bezier(.22,.75,.22,1) both;
}
.opening-ambush,.mulligan-ambush {color:#ffc19f}
.opening-opponent {
  display:grid;justify-items:center;gap:6px;animation:opening-contact-in 215ms 100ms both;
}
.opening-opponent-portrait {
  display:block;width:clamp(74px,17dvh,122px);aspect-ratio:1;overflow:hidden;
  border-radius:50%;border:1px solid #9bc7e3;outline:1px solid #9bc7e360;outline-offset:4px;
  background:#10212e;box-shadow:0 0 36px #72b8dc36;
}
.opening-redraw {position:relative;padding-bottom:26px}
.opening-backs {display:flex;justify-content:center;gap:clamp(7px,2vw,13px)}
.opening-back-slot {position:relative;display:block;width:clamp(38px,11vw,57px);aspect-ratio:var(--card-face-ratio)}
.opening-back,.opening-replacement {position:absolute;inset:0;display:block}
.opening-back {animation:opening-deal 240ms calc(260ms + var(--opening-index)*76ms) both}
.is-redrawn .opening-back {
  animation:opening-deal 240ms calc(260ms + var(--opening-index)*76ms) both,
    opening-return 430ms calc(740ms + var(--opening-index)*33ms) forwards;
}
.opening-replacement {animation:opening-deal 265ms calc(1200ms + var(--opening-index)*33ms) both}
.opening-redraw-count {
  position:absolute;bottom:0;inset-inline:0;display:flex;align-items:center;justify-content:center;
  gap:5px;color:#b7e5ff;font:600 16px/1 var(--font-ui,sans-serif);
  animation:opening-contact-in 175ms 1450ms both;
}
.opening-redraw-count .battle-icon {width:16px;height:16px}
.battle-mulligan .opening-skip {min-width:82px}
.mulligan-choice.is-dealt .battle-opening-card {
  animation:opening-deal 185ms calc(var(--opening-index)*35ms) both;
}
@keyframes opening-sequence {
  0%,93% {opacity:1}
  100% {opacity:0}
}
@keyframes opening-alert {
  from {opacity:0;clip-path:inset(0 49%);transform:scale(1.045)}
  to {opacity:1;clip-path:inset(0);transform:none}
}
@keyframes opening-contact-in {
  from {opacity:0;transform:translateY(8px)}
  to {opacity:1;transform:none}
}
@keyframes opening-deal {
  from {opacity:0;transform:translate(15px,16px) rotate(6deg)}
  to {opacity:1;transform:none}
}
@keyframes opening-return {
  0% {opacity:1;transform:none;filter:none}
  29%,61% {opacity:1;transform:translateY(-9px);filter:drop-shadow(0 0 6px #91d5ff)}
  100% {opacity:0;transform:translate(-12px,-30px) rotate(-9deg);filter:drop-shadow(0 0 6px #91d5ff)}
}
@media(max-height:560px){
 .battle-opening-reveal{gap:10px}
 .opening-back-slot{width:42px}
}
.battle-sheet-backdrop{display:flex;align-items:flex-end;animation:none;padding:calc(15px + env(safe-area-inset-top,0px)) 10px 0}
.battle-pile-sheet{width:min(100%,1040px);max-width:1040px;max-height:100%;margin:0 auto;padding:20px 14px calc(25px + env(safe-area-inset-bottom,0px));background:rgba(8,28,40,.91);border:1px solid #b8d1cf4d;border-bottom:0;border-radius:16px 16px 0 0;overflow:auto;overscroll-behavior:contain}
.battle-pile-sheet>header{position:sticky;top:-20px;z-index:5;padding:12px 0 15px;margin:-2px 0 15px;background:#0b2332f5;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.battle-pile-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-bottom:17px}
.battle-pile-tabs button{min-height:44px}
.battle-pile-tabs b{color:#b1cbd6;font-variant-numeric:tabular-nums}
.battle-pile-grid{max-width:none;margin:0;gap:20px 12px}.battle-pile-card>b{position:static;display:block;padding:9px 8px;margin:8px 0 0;border-radius:4px;font-size:12px;line-height:1.25;color:#10212a;background:#e4cc97}
.battle-pile-card.is-recoverable>.card-face{box-shadow:0 0 0 2px #e7c889,0 8px 28px #0005}
@media(min-width:700px){
 .mulligan-choice:not([hidden]){gap:23px}
 .battle-mulligan-cards,.battle-pile-grid{grid-template-columns:repeat(4,minmax(0,1fr));max-width:1040px;gap:22px 16px}
      .battle-pile-sheet{padding:25px 20px 30px}
 .battle-pile-sheet>header{top:-25px}.battle-pile-grid{max-width:none}
}
@media(prefers-reduced-motion:reduce){.battle-mulligan-card,.battle-sheet-backdrop,.mulligan-choice.is-dealt .battle-opening-card{animation:none!important;transition:none!important}}
.reduce-motion .battle-mulligan-card,.reduce-motion .battle-sheet-backdrop,.reduce-motion .mulligan-choice.is-dealt .battle-opening-card{animation:none!important;transition:none!important}
