/* ==========================================================================
   PokéSpire Booster Pack Reward Ceremony (css/booster-pack.css)
   - Light silver foil booster pack with flowing rainbow iridescence
   - Defeated enemy Pokémon printed on pack front
   - Click or horizontal-swipe serrated top tear + foil confetti burst
   - 3 cards fan-out face-down using SpireCardBacks
   - Pre-flip rarity telegraph: common (none), rare (pale blue glow), holo (gold glow + jitter)
   - Individual 3D flip into existing .poke-card.ptcg-v2 with live holo sheen
   ========================================================================== */

:root {
  --bp-pack-w: clamp(232px, 24vw, 276px);
  --bp-pack-h: calc(var(--bp-pack-w) * 1.56);
  --bp-card-w: clamp(192px, 21vw, 244px);
}

/* ---------- Preview Page Shell (isolated from formal game) ---------- */
.bp-preview-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 58% at 50% 24%, rgba(36, 54, 82, 0.92), rgba(13, 18, 30, 0.98) 72%),
    #0b101b;
  color: #f8fafc;
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

.bp-demo-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 18px;
  background: rgba(12, 18, 30, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.bp-demo-back {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease;
}

.bp-demo-back:hover {
  background: rgba(255, 255, 255, 0.16);
}

.bp-demo-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-weight: 600;
}

.bp-demo-control select {
  background: #172133;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.bp-demo-btn {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.bp-demo-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.bp-demo-btn.is-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: rgba(253, 224, 71, 0.55);
  color: #111827;
}

.bp-demo-note {
  margin-left: auto;
  color: #94a3b8;
  font-size: 12px;
}

/* ---------- Booster Stage Overlay (reusable in formal reward modal) ---------- */
.bp-stage {
  position: relative;
  min-height: 100vh;
  padding: 76px 24px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Embedded mode inside formal .sts2-reward-overlay */
.bp-stage.is-embedded {
  min-height: 0;
  width: 100%;
  padding: 4px 12px 10px;
  overflow: visible;
}

.bp-stage.is-embedded .bp-arena {
  min-height: clamp(360px, 52vh, 455px);
}

.bp-stage.is-embedded .bp-header {
  margin-bottom: 10px;
}

.bp-stage.is-embedded .bp-footer {
  margin-top: 32px;
}

.bp-ambient-glow {
  position: absolute;
  width: min(760px, 92vw);
  height: min(520px, 68vh);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--bp-theme, #7dd3fc) 22%, transparent) 0%,
    rgba(255, 255, 255, 0.04) 42%,
    transparent 72%
  );
  filter: blur(26px);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.4s ease, transform 0.5s ease;
}

.bp-stage.is-opened .bp-ambient-glow {
  opacity: 0.55;
  transform: scale(1.16);
}

.bp-header {
  position: relative;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  text-align: center;
}

.bp-ribbon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 280px;
  padding: 10px 38px;
  margin: 0;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #1c1917;
  background: #fcf5e7;
  border: 2.5px solid #1c1917;
  box-shadow: 5px 5px 0 #1c1917;
}

.bp-subtitle {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(241, 245, 249, 0.86);
  letter-spacing: 0.03em;
  min-height: 20px;
}

/* ---------- Center Arena ---------- */
.bp-arena {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 1020px;
  min-height: clamp(390px, 56vh, 490px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Confetti Particle Layer ---------- */
.bp-confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: visible;
}

.bp-confetti {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cf-w, 12px);
  height: var(--cf-h, 7px);
  border-radius: 2px;
  background: var(--cf-bg, linear-gradient(135deg, #f8fafc, #cbd5e1));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translate3d(0, 0, 0);
  animation: bpConfettiFly var(--cf-dur, 1.15s) cubic-bezier(0.16, 0.84, 0.34, 1) forwards;
}

@keyframes bpConfettiFly {
  0% {
    opacity: 1;
    transform: translate3d(var(--cf-sx, 0px), var(--cf-sy, 0px), 0) rotate(0deg) scale(0.75);
  }
  22% {
    opacity: 1;
  }
  75% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--cf-ex, 90px), var(--cf-ey, 120px), 0) rotate(var(--cf-rot, 420deg)) scale(0.95);
  }
}

/* ---------- Light Silver Foil Booster Pack ---------- */
.bp-pack-wrap {
  position: relative;
  z-index: 12;
  width: var(--bp-pack-w);
  height: var(--bp-pack-h);
  perspective: 1100px;
  transform-origin: center bottom;
  opacity: 0;
  transform: translateY(150px) scale(0.84) rotate(-3deg);
  transition: opacity 0.32s ease, transform 0.68s cubic-bezier(0.22, 1.28, 0.36, 1);
  touch-action: none;
}

.bp-pack-wrap.is-entered {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(0deg);
}

.bp-pack-wrap.is-idle {
  animation: bpPackFloat 3.4s ease-in-out infinite;
}

.bp-pack-wrap.is-tearing-out {
  animation: none;
  pointer-events: none;
  opacity: 0;
  transform: translateY(115px) scale(0.86) rotate(4deg);
  transition: opacity 0.42s ease 0.14s, transform 0.56s cubic-bezier(0.55, 0.06, 0.68, 0.19) 0.1s;
}

@keyframes bpPackFloat {
  0%, 100% { transform: translateY(0px) rotate(-0.6deg); }
  50% { transform: translateY(-7px) rotate(0.7deg); }
}

.bp-pack-shadow {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -24px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.52) 0%, transparent 72%);
  filter: blur(5px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.bp-pack-wrap.is-tearing-out .bp-pack-shadow {
  opacity: 0;
  transform: scale(0.7);
}

.bp-pack {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--pack-rx, 0deg)) rotateY(var(--pack-ry, 0deg));
  transition: transform 0.18s ease-out;
  cursor: pointer;
}

/* Top tear strip (detaches on open) */
.bp-pack-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16.5%;
  z-index: 8;
  transform-origin: left bottom;
  transform:
    translate3d(calc(var(--tear-progress, 0) * 14px), calc(var(--tear-progress, 0) * -12px), 6px)
    rotate(calc(var(--tear-progress, 0) * -11deg));
  transition: transform 0.14s ease-out;
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.25));
}

.bp-pack-top.is-torn {
  transition: transform 0.56s cubic-bezier(0.22, 0.85, 0.32, 1), opacity 0.45s ease 0.12s;
  transform: translate3d(130px, -110px, 24px) rotate(26deg) scale(0.92);
  opacity: 0;
}

.bp-pack-top-foil {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Top serrated edge + bottom serrated tear line */
  clip-path: polygon(
    0% 10%, 4% 0%, 8% 10%, 12% 0%, 16% 10%, 20% 0%, 24% 10%, 28% 0%,
    32% 10%, 36% 0%, 40% 10%, 44% 0%, 48% 10%, 52% 0%, 56% 10%, 60% 0%,
    64% 10%, 68% 0%, 72% 10%, 76% 0%, 80% 10%, 84% 0%, 88% 10%, 92% 0%,
    96% 10%, 100% 0%,
    100% 90%, 96% 100%, 92% 90%, 88% 100%, 84% 90%, 80% 100%, 76% 90%,
    72% 100%, 68% 90%, 64% 100%, 60% 90%, 56% 100%, 52% 90%, 48% 100%,
    44% 90%, 40% 100%, 36% 90%, 32% 100%, 28% 90%, 24% 100%, 20% 90%,
    16% 100%, 12% 90%, 8% 100%, 4% 90%, 0% 100%
  );
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.42) 0px,
      rgba(255, 255, 255, 0.42) 2px,
      rgba(148, 163, 184, 0.25) 2px,
      rgba(148, 163, 184, 0.25) 5px
    ),
    linear-gradient(125deg, #f8fafc 0%, #e2e8f0 32%, #ffffff 55%, #cbd5e1 82%, #f1f5f9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-pack-top-label {
  position: relative;
  z-index: 3;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #334155;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.62);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(100, 116, 139, 0.26);
}

/* Interactive Tear Track across the serrated neck */
.bp-tear-track {
  position: absolute;
  top: 14.5%;
  left: -8px;
  right: -8px;
  height: 28px;
  z-index: 15;
  display: flex;
  align-items: center;
  cursor: grab;
}

.bp-tear-track:active {
  cursor: grabbing;
}

.bp-tear-dash {
  position: relative;
  width: 100%;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    rgba(30, 41, 59, 0.55) 0 6px,
    transparent 6px 11px
  );
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.bp-tear-glow {
  position: absolute;
  left: 0;
  top: 50%;
  height: 5px;
  width: calc(var(--tear-progress, 0) * 100%);
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff, #fef08a, #38bdf8, #ffffff);
  box-shadow: 0 0 14px 3px rgba(254, 240, 138, 0.9), 0 0 26px rgba(56, 189, 248, 0.75);
  pointer-events: none;
}

.bp-tear-spark {
  position: absolute;
  left: calc(var(--tear-progress, 0) * 100%);
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(var(--tear-active, 0));
  background: radial-gradient(circle, #ffffff 0%, #fde047 45%, transparent 72%);
  box-shadow: 0 0 18px 6px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  transition: transform 0.1s ease;
}

.bp-tear-hint {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0f172a;
  background: rgba(254, 249, 195, 0.95);
  border: 1.5px solid rgba(202, 138, 4, 0.55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: bpHintPulse 1.9s ease-in-out infinite;
}

.bp-pack-wrap.is-tearing-out .bp-tear-hint,
.bp-pack-wrap.is-dragging .bp-tear-hint {
  opacity: 0;
  animation: none;
}

@keyframes bpHintPulse {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

/* Main Pack Body (below serrated tear line) */
.bp-pack-body {
  position: absolute;
  top: 15%;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  overflow: hidden;
  border-radius: 2px 2px 4px 4px;
  /* Top serrated edge + bottom serrated crimp */
  clip-path: polygon(
    0% 2%, 4% 0%, 8% 2%, 12% 0%, 16% 2%, 20% 0%, 24% 2%, 28% 0%,
    32% 2%, 36% 0%, 40% 2%, 44% 0%, 48% 2%, 52% 0%, 56% 2%, 60% 0%,
    64% 2%, 68% 0%, 72% 2%, 76% 0%, 80% 2%, 84% 0%, 88% 2%, 92% 0%,
    96% 2%, 100% 0%,
    100% 98%, 96% 100%, 92% 98%, 88% 100%, 84% 98%, 80% 100%, 76% 98%,
    72% 100%, 68% 98%, 64% 100%, 60% 98%, 56% 100%, 52% 98%, 48% 100%,
    44% 98%, 40% 100%, 36% 98%, 32% 100%, 28% 98%, 24% 100%, 20% 98%,
    16% 100%, 12% 98%, 8% 100%, 4% 98%, 0% 100%
  );
  /* Light silver-pearl metallic foil base */
  background:
    linear-gradient(
      90deg,
      rgba(148, 163, 184, 0.32) 0%,
      rgba(255, 255, 255, 0.65) 9%,
      rgba(226, 232, 240, 0.3) 20%,
      rgba(255, 255, 255, 0.15) 50%,
      rgba(203, 213, 225, 0.35) 82%,
      rgba(255, 255, 255, 0.68) 92%,
      rgba(148, 163, 184, 0.36) 100%
    ),
    linear-gradient(
      148deg,
      #f8fafc 0%,
      #eef2f7 26%,
      #dce4ef 52%,
      #f1f5f9 76%,
      #e2e8f0 100%
    );
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

/* Soft enemy theme tint on foil */
.bp-pack-tint {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--bp-theme, #60a5fa) 28%, transparent) 0%, transparent 64%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, transparent 38%, color-mix(in srgb, var(--bp-theme, #60a5fa) 18%, transparent) 100%);
  pointer-events: none;
}

/* Slow flowing rainbow iridescence on aluminum foil */
.bp-foil-rainbow {
  position: absolute;
  inset: -45%;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(
    118deg,
    transparent 16%,
    rgba(255, 110, 180, 0.36) 28%,
    rgba(255, 214, 102, 0.38) 38%,
    rgba(110, 242, 185, 0.38) 48%,
    rgba(110, 198, 255, 0.40) 58%,
    rgba(196, 148, 255, 0.36) 68%,
    transparent 80%
  );
  background-size: 220% 220%;
  mix-blend-mode: color-dodge;
  opacity: 0.72;
  animation: bpRainbowFlow 7.5s ease-in-out infinite alternate;
}

.bp-pack-top-foil .bp-foil-rainbow {
  opacity: 0.58;
}

@keyframes bpRainbowFlow {
  0% {
    transform: translate3d(-18%, -10%, 0) rotate(-6deg);
    background-position: 0% 20%;
  }
  50% {
    transform: translate3d(8%, 4%, 0) rotate(2deg);
    background-position: 60% 60%;
  }
  100% {
    transform: translate3d(20%, 12%, 0) rotate(7deg);
    background-position: 100% 85%;
  }
}

/* Subtle metallic specular sheen */
.bp-foil-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    circle at var(--pack-mx, 38%) var(--pack-my, 32%),
    rgba(255, 255, 255, 0.65) 0%,
    rgba(255, 255, 255, 0.16) 28%,
    transparent 62%
  );
  mix-blend-mode: overlay;
}

/* Pack Front Print Content */
.bp-pack-print {
  position: relative;
  z-index: 3;
  height: 100%;
  padding: 14px 14px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.bp-pack-brand {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.bp-pack-brand-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #0f172a;
}

.bp-pack-brand-count {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bp-theme, #0284c7) 18%, #ffffff);
  color: #0f172a;
  border: 1px solid color-mix(in srgb, var(--bp-theme, #0284c7) 42%, transparent);
}

.bp-pack-emblem {
  position: relative;
  width: 86%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0;
}

.bp-pack-emblem-ring {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.85) 0%,
    color-mix(in srgb, var(--bp-theme, #60a5fa) 22%, rgba(255, 255, 255, 0.5)) 58%,
    transparent 74%
  );
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--bp-theme, #60a5fa) 16%, transparent),
    inset 0 2px 12px rgba(255, 255, 255, 0.85);
}

.bp-pack-enemy-img {
  position: relative;
  z-index: 2;
  width: 92%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(15, 23, 42, 0.28));
  pointer-events: none;
}

.bp-pack-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bp-pack-enemy-plate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.86);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
}

.bp-pack-enemy-plate img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.bp-pack-series {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #475569;
  text-transform: uppercase;
}

/* Bottom crimped foil band */
.bp-pack-crimp-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  z-index: 5;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.48) 0 2px,
      rgba(100, 116, 139, 0.22) 2px 5px
    );
  border-top: 1px solid rgba(148, 163, 184, 0.38);
  pointer-events: none;
}

/* Tear flash burst */
.bp-tear-flash {
  position: absolute;
  left: 50%;
  top: 26%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, #ffffff 0%, rgba(254, 240, 138, 0.9) 35%, rgba(125, 211, 252, 0.4) 65%, transparent 75%);
  pointer-events: none;
  z-index: 25;
  opacity: 0;
}

.bp-tear-flash.is-burst {
  animation: bpTearFlash 0.52s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bpTearFlash {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  40% { opacity: 0.95; transform: translate(-50%, -50%) scale(14); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(20); }
}

/* ---------- N-Card Responsive Fan-Out Row & Flip Slots ---------- */
.bp-cards-row {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3.2vw, 42px);
  pointer-events: none;
}

.bp-cards-row.is-multi-4 {
  --bp-card-w: clamp(162px, 17.8vw, 212px);
  gap: clamp(12px, 2vw, 24px);
}

.bp-cards-row.is-multi-5 {
  --bp-card-w: clamp(144px, 15.2vw, 184px);
  gap: clamp(10px, 1.5vw, 18px);
}

.bp-cards-row.is-multi-6plus {
  position: relative;
  flex-wrap: wrap;
  --bp-card-w: clamp(142px, 14.5vw, 178px);
  gap: 36px 16px;
  padding: 12px 10px 36px;
}

.bp-cards-row.is-visible {
  pointer-events: auto;
}

.bp-card-slot {
  position: relative;
  width: var(--bp-card-w);
  aspect-ratio: 0.718;
  perspective: 1200px;
  opacity: 0;
  /* Start tucked inside pack center */
  transform: translate3d(var(--slot-from-x, 0px), 78px, 0) rotate(var(--slot-from-rot, 0deg)) scale(0.42);
  pointer-events: none;
}

.bp-card-slot.is-dealt {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, var(--slot-rest-y, 0px), 0) rotate(var(--slot-rest-rot, 0deg)) scale(1);
  transition:
    transform 0.72s cubic-bezier(0.2, 1.18, 0.34, 1) var(--deal-delay, 0ms),
    opacity 0.28s ease var(--deal-delay, 0ms);
}

.bp-card-slot.is-dealt:hover {
  z-index: 22;
}

.bp-card-slot.is-dealt:not(.is-flipped):hover .bp-card-flipper {
  transform: translateY(-10px) scale(1.03);
}

.bp-card-slot.is-picked {
  z-index: 28;
}

.bp-card-slot.is-dimmed {
  opacity: 0.38;
  filter: saturate(0.65);
  transform: translate3d(0, 12px, 0) scale(0.94);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
}

/* Jitter wrapper for Holo pre-flip anticipation */
.bp-card-jitter {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.bp-card-slot.is-dealt.is-tier-holo:not(.is-flipped) .bp-card-jitter {
  animation: bpHoloJitter 2.4s ease-in-out infinite;
  animation-delay: var(--jitter-delay, 0.6s);
}

@keyframes bpHoloJitter {
  0%, 66%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  70% { transform: translate3d(-2px, -1px, 0) rotate(-0.9deg); }
  74% { transform: translate3d(2.4px, 0.5px, 0) rotate(1deg); }
  78% { transform: translate3d(-1.8px, -1px, 0) rotate(-0.7deg); }
  82% { transform: translate3d(1.6px, 0.5px, 0) rotate(0.7deg); }
  86% { transform: translate3d(-0.8px, 0, 0) rotate(-0.3deg); }
  90% { transform: translate3d(0, 0, 0) rotate(0deg); }
}

/* 3D Flipper Container */
.bp-card-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.72s cubic-bezier(0.22, 1.15, 0.36, 1);
  cursor: pointer;
}

.bp-card-slot.is-flipped .bp-card-flipper {
  transform: rotateY(180deg);
}

.bp-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 4.55% / 3.25%;
}

/* ---------- Card Back Face + Rarity Telegraph Edge Glow ---------- */
.bp-card-back-face {
  transform: rotateY(0deg);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.bp-card-back-face .spire-cardback {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 4.55% / 3.25%;
  box-sizing: border-box;
  transition: box-shadow 0.25s ease, filter 0.25s ease;
}

/* Common: clean card back, no edge glow */
.bp-card-slot.is-tier-common .bp-card-back-face .spire-cardback {
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.42);
}

/* Rare: pale blue edge glow leaking from behind card back */
.bp-card-slot.is-tier-rare .bp-card-back-face::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 6% / 4.4%;
  background: conic-gradient(
    from 0deg,
    rgba(125, 211, 252, 0.9),
    rgba(56, 189, 248, 0.35),
    rgba(186, 230, 253, 0.95),
    rgba(56, 189, 248, 0.35),
    rgba(125, 211, 252, 0.9)
  );
  filter: blur(8px);
  opacity: 0.85;
  z-index: -1;
  animation: bpRarePulse 2.2s ease-in-out infinite;
}

.bp-card-slot.is-tier-rare .bp-card-back-face .spire-cardback {
  box-shadow:
    0 0 14px rgba(125, 211, 252, 0.65),
    0 0 28px rgba(56, 189, 248, 0.38),
    0 12px 26px rgba(0, 0, 0, 0.45);
}

@keyframes bpRarePulse {
  0%, 100% { opacity: 0.62; transform: scale(0.99); }
  50% { opacity: 0.98; transform: scale(1.025); }
}

/* Holo: golden edge glow leaking out + shimmer ring */
.bp-card-slot.is-tier-holo .bp-card-back-face::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 6.4% / 4.8%;
  background: conic-gradient(
    from 0deg,
    rgba(253, 224, 71, 0.98),
    rgba(245, 158, 11, 0.55),
    rgba(255, 251, 235, 1),
    rgba(251, 191, 36, 0.6),
    rgba(253, 224, 71, 0.98)
  );
  filter: blur(11px);
  opacity: 0.96;
  z-index: -1;
  animation: bpHoloGoldPulse 1.65s ease-in-out infinite;
}

.bp-card-slot.is-tier-holo .bp-card-back-face::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 5.2% / 3.8%;
  border: 2px solid rgba(254, 240, 138, 0.88);
  box-shadow: inset 0 0 16px rgba(253, 224, 71, 0.45);
  pointer-events: none;
  z-index: 3;
  animation: bpHoloEdgeShimmer 1.65s ease-in-out infinite;
}

.bp-card-slot.is-tier-holo .bp-card-back-face .spire-cardback {
  box-shadow:
    0 0 20px rgba(250, 204, 21, 0.82),
    0 0 42px rgba(245, 158, 11, 0.52),
    0 14px 30px rgba(0, 0, 0, 0.5);
}

@keyframes bpHoloGoldPulse {
  0%, 100% { opacity: 0.78; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.045); }
}

@keyframes bpHoloEdgeShimmer {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Click-to-flip subtle prompt on hovered face-down card */
.bp-flip-tag {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.bp-card-slot.is-dealt:not(.is-flipped):hover .bp-flip-tag {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* ---------- Card Front Face (hosts existing .poke-card.ptcg-v2) ---------- */
.bp-card-front-face {
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-card-front-face .poke-card.ptcg-v2 {
  width: 100% !important;
  margin: 0 !important;
  cursor: pointer;
}

/* Reveal Burst Ring when a Rare or Holo card flips */
.bp-reveal-burst {
  position: absolute;
  inset: -16px;
  border-radius: 18px;
  pointer-events: none;
  opacity: 0;
  z-index: 25;
}

.bp-card-slot.is-reveal-rare .bp-reveal-burst {
  background: radial-gradient(circle, rgba(186, 230, 253, 0.65) 0%, rgba(56, 189, 248, 0.25) 48%, transparent 72%);
  animation: bpRevealPop 0.65s ease-out forwards;
}

.bp-card-slot.is-reveal-holo .bp-reveal-burst {
  background: radial-gradient(circle, rgba(255, 251, 235, 0.92) 0%, rgba(250, 204, 21, 0.55) 38%, rgba(244, 114, 182, 0.22) 60%, transparent 76%);
  animation: bpRevealPop 0.92s ease-out forwards;
}

@keyframes bpRevealPop {
  0% { opacity: 0; transform: scale(0.72); }
  26% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.32); }
}

/* Select-card action pill beneath flipped card */
.bp-pick-pill {
  position: absolute;
  left: 50%;
  bottom: -40px;
  transform: translateX(-50%) translateY(6px);
  opacity: 0;
  pointer-events: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #1c1917;
  background: #fcf5e7;
  color: #1c1917;
  font-size: 12.5px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 3px 3px 0 #1c1917;
  cursor: pointer;
  transition: opacity 0.22s ease, transform 0.22s ease, background 0.15s ease;
}

.bp-card-slot.is-flipped .bp-pick-pill {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.bp-pick-pill:hover {
  background: #fde68a;
  transform: translateX(-50%) translateY(-2px);
}

.bp-card-slot.is-picked .bp-pick-pill {
  background: #4ade80;
  color: #052e16;
}

/* ---------- Footer Controls ---------- */
.bp-footer {
  position: relative;
  z-index: 8;
  margin-top: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 44px;
}

.bp-action-btn {
  padding: 10px 24px;
  border-radius: 10px;
  border: 2px solid #1c1917;
  background: #fcf5e7;
  color: #1c1917;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 #1c1917;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.2s ease;
}

.bp-action-btn:hover {
  transform: translateY(-2px);
  background: #fef3c7;
}

.bp-action-btn.is-secondary {
  background: rgba(30, 41, 59, 0.86);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.bp-action-btn.is-secondary:hover {
  background: rgba(51, 65, 85, 0.95);
}

.bp-action-btn[hidden] {
  display: none;
}

.bp-status-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  z-index: 130;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  border: 1.5px solid rgba(250, 204, 21, 0.65);
  color: #fef9c3;
  font-size: 13.5px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.bp-status-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  :root {
    --bp-card-w: clamp(140px, 28vw, 185px);
  }
  .bp-cards-row {
    gap: 12px;
  }
  .bp-ribbon {
    min-width: 220px;
    font-size: 18px;
    padding: 8px 24px;
  }
  .bp-demo-note {
    display: none;
  }
}
