/* ADEERA ENCORE! photocards, COLLECT BOOK binder and unboxing (cards.js). */

.pc, .bd, .ub {
  --pc-night: var(--night, #160b2e);
  --pc-stage: var(--stage, #2e1257);
  --pc-hot: var(--hot, #ff4fa3);
  --pc-lav: var(--lav, #b9a6ff);
  --pc-mint: var(--mint, #5ef2d0);
  --pc-butter: var(--butter, #ffe066);
  --pc-sky: var(--sky, #7cc8ff);
  --pc-text: var(--text, #f6efff);
  --pc-cute: var(--cute, "Jua", ui-rounded, system-ui, sans-serif);
  --pc-loud: var(--loud, "Black Han Sans", "Jua", Impact, sans-serif);
}

/* ---------- Photocard ---------- */
/*
 * The flat CSS card: every binder pocket, the fallback when there is no WebGL2, and the card that
 * flies to its pocket. cards.js drives it with --mx / --my (the light, in %) and --tx / --ty (the
 * tilt, -1..1 on each axis); everything else (angles, the shadow's shift, how hard a foil flares)
 * is derived here, so one pointer move or one sway frame is five custom properties and no layout.
 */

.pc {
  --mx: 50%;
  --my: 50%;
  --tx: 0;
  --ty: 0;
  --lit: 0; /* how far off-axis the card is, 0..1: the foils flare with it */
  --glare: 0;
  --flip: 0deg;
  --rx: calc(var(--ty) * -12deg);
  --ry: calc(var(--tx) * 12deg);
  /* a slightly underdamped spring (about 12% overshoot): the tilt lands with a little wobble */
  --pc-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  width: 100%;
  aspect-ratio: 300 / 465;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@supports (transition-timing-function: linear(0, 1)) {
  .pc {
    --pc-spring: linear(0, 0.062 4%, 0.212 8%, 0.403 12%, 0.598 17%, 0.773 21%, 0.915 25%, 1.018 29%, 1.084 33%, 1.118 38%, 1.126 42%, 1.117 46%, 1.097 50%, 1.073 54%, 1.049 58%, 1.027 62%, 1.009 67%, 0.997 71%, 0.989 75%, 0.985 79%, 0.984 83%, 0.985 88%, 0.988 92%, 0.991 96%, 1);
  }
}

/* The shadow lives outside the tilt, on the "table": it slides against the tilt and softens as the
   card lifts, instead of rotating with the card like a box-shadow would. */
.pc::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4.67% / 3.01%;
  pointer-events: none;
  box-shadow: 0 13px 22px -5px rgba(10, 4, 24, 0.62), 0 2px 5px rgba(10, 4, 24, 0.4);
  opacity: calc(1 - var(--lit) * 0.28);
  transform: translate(calc(var(--tx) * -4%), calc(1.5% + var(--ty) * 3%)) scale(calc(1 - var(--lit) * 0.04));
  transition: transform 0.8s var(--pc-spring), opacity 0.4s;
}

.pc.is-live::before { transition: transform 0.1s ease-out, opacity 0.2s; }
.pc.is-missing::before { display: none; }

.pc-tilt,
.pc-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.pc-tilt {
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.8s var(--pc-spring);
}

.pc.is-live .pc-tilt { transition: transform 0.1s ease-out; }
/* a swaying card is retargeted every frame: a short lag keeps it smooth (a spring would restart each time) */
.pc.is-sway:not(.is-live) .pc-tilt,
.pc.is-sway:not(.is-live)::before { transition-duration: 0.14s; transition-timing-function: linear; }

.pc-flip {
  transform: rotateY(var(--flip));
  transition: transform 0.62s cubic-bezier(0.3, 1.35, 0.45, 1);
}

.pc.is-flipped { --flip: 180deg; }

.pc-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4.67% / 3.01%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* a hair of ring: the laminate's outer edge */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: var(--pc-night);
}

/* Thickness: a 1-2 px light rim over the art, bright on the lit top-left edges, a touch of shade on the
   far ones. Painted over the canvas (an inset shadow on the face itself would sit under it). */
.pc-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 1.5px 1.5px 0 rgba(255, 255, 255, 0.5),
    inset -1px -1.5px 0 rgba(30, 12, 56, 0.32),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.22);
}

.pc-face canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pc-back { transform: rotateY(180deg); }

.pc-foil,
.pc-sparkle,
.pc-glare,
.pc-pearl,
.pc-gold {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Glare: a hot spot where the light is, a soft shade on the far side (overlay, so it lifts contrast
   instead of fogging the art), and a broad sheen band that slides across as the light moves. */
.pc-glare {
  background:
    radial-gradient(farthest-corner circle at var(--mx) var(--my),
      rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.14) 28%, rgba(20, 8, 40, 0.3) 90%),
    linear-gradient(112deg, transparent 34%, rgba(255, 255, 255, 0.34) 47%, rgba(255, 255, 255, 0.04) 55%, transparent 64%);
  background-size: 100% 100%, 280% 100%;
  background-position: center, calc(var(--mx) * 1.0) 0;
  mix-blend-mode: overlay;
  opacity: calc(var(--glare) * 0.75);
  transition: opacity 0.3s;
}

/* HOLO: two banded rainbows that slide against each other (parallax), dodged into the art. Dim when
   the card faces you, flaring as it tilts: --lit rides the opacity, the dodge turns that into
   brightness and contrast, with no filter pass (nine pockets stay cheap). */
.pc--holo .pc-foil {
  background-image:
    repeating-linear-gradient(115deg,
      hsla(330, 100%, 72%, 0.62) 0%,
      hsla(50, 100%, 70%, 0.56) 7%,
      hsla(160, 100%, 66%, 0.56) 14%,
      hsla(200, 100%, 70%, 0.56) 21%,
      hsla(275, 100%, 76%, 0.62) 28%,
      hsla(330, 100%, 72%, 0.62) 35%),
    repeating-linear-gradient(62deg,
      hsla(190, 100%, 70%, 0.34) 0%,
      hsla(300, 100%, 76%, 0.34) 9%,
      hsla(45, 100%, 70%, 0.34) 18%,
      hsla(190, 100%, 70%, 0.34) 27%),
    radial-gradient(farthest-corner circle at var(--mx) var(--my), rgba(255, 255, 255, 0.24), rgba(0, 0, 0, 0.36) 120%);
  background-size: 260% 260%, 190% 190%, 100% 100%;
  background-position: var(--mx) var(--my), calc(100% - var(--mx)) calc(100% - var(--my)), center;
  background-blend-mode: soft-light, overlay, normal;
  mix-blend-mode: overlay;
  opacity: calc(0.4 + var(--lit) * 0.5);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.pc--holo .pc-sparkle {
  background-image: var(--sparkle);
  background-size: 34% auto;
  background-position: calc(100% - var(--mx)) calc(100% - var(--my));
  mix-blend-mode: color-dodge;
  opacity: calc(0.3 + var(--lit) * 0.4);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.pc--holo .pc-glare { opacity: calc(0.12 + var(--glare) * 0.3); }

/* POB: a pearl border. Screened pastel iridescence that slides with the light, on the printed border
   only (the mask is the card minus the art window), so the art stays true-coloured. */
.pc-pearl {
  background:
    radial-gradient(120% 60% at var(--mx) var(--my), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 62%),
    linear-gradient(112deg,
      rgba(255, 170, 222, 0) 4%, rgba(255, 170, 222, 0.85) 20%, rgba(170, 238, 255, 0.85) 34%,
      rgba(255, 255, 255, 0.95) 46%, rgba(255, 244, 170, 0.85) 58%, rgba(206, 178, 255, 0.85) 72%, rgba(255, 170, 222, 0) 92%);
  background-size: 100% 100%, 300% 100%;
  background-position: center, calc(var(--mx) * 1.0) 0;
  mix-blend-mode: screen;
  opacity: calc(0.42 + var(--lit) * 0.4);
  -webkit-mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  -webkit-mask-size: 100% 100%, calc(100% - 6.67%) calc(100% - 4.3%);
  mask-size: 100% 100%, calc(100% - 6.67%) calc(100% - 4.3%);
  -webkit-mask-position: 0 0, center;
  mask-position: 0 0, center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* FANSIGN: gold foil on the signature ink (the mask is the very ink, drawn by cards.js) and a faint
   warm shimmer on the polaroid's chin. Nowhere else. */
.pc-gold {
  background: linear-gradient(104deg, #c23a72 0%, #ea8138 13%, #ffb62e 24%, #ffe680 30%, #ffb62e 36%, #dc7330 48%, #b8346a 60%, #f08e3e 72%, #ffc23c 82%, #c23a72 100%);
  background-size: 320% 100%;
  background-position: calc(var(--mx) * 1.0) 50%;
  -webkit-mask-image: var(--ink), linear-gradient(180deg, transparent 75.5%, rgba(0, 0, 0, 0.22) 77%);
  mask-image: var(--ink), linear-gradient(180deg, transparent 75.5%, rgba(0, 0, 0, 0.22) 77%);
  -webkit-mask-size: 100% 100%, 100% 100%;
  mask-size: 100% 100%, 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-composite: source-over;
  mask-composite: add;
  opacity: calc(0.58 + var(--lit) * 0.3);
}

.pc.is-missing .pc-face { box-shadow: inset 0 0 0 2px rgba(185, 166, 255, 0.25); }
.pc.is-missing .pc-face::after { display: none; }

.pc-badge {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  font: 13px/1 var(--pc-loud);
  letter-spacing: 0.04em;
  color: var(--pc-night);
  background: var(--pc-butter);
  border-radius: 999px;
  padding: 4px 8px 3px;
  box-shadow: 0 2px 0 rgba(22, 11, 46, 0.4);
}

.pc-count { right: -4px; top: -6px; }

.pc-onstage {
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  white-space: nowrap;
  color: #fff;
  background: var(--pc-hot);
  font-size: 10px;
}

/* ---------- COLLECT BOOK ---------- */

.bd {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(10px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  color: var(--pc-text);
  font-family: var(--pc-cute);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(185, 166, 255, 0.22), transparent 70%),
    radial-gradient(ellipse 110% 60% at 50% 100%, rgba(255, 79, 163, 0.18), transparent 70%),
    linear-gradient(var(--pc-night), var(--pc-stage) 80%, #1c0a35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bd--in {
  padding: 2px 0 0;
  background: none;
}

.bd *, .ub * { box-sizing: border-box; }

.bd > * { flex-shrink: 0; }

.bd button, .ub button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bd button:focus-visible, .ub button:focus-visible {
  outline: 3px solid var(--pc-butter);
  outline-offset: 3px;
}

.bd-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.bd-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.bd-title b {
  font: 24px/1 var(--pc-loud);
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 79, 163, 0.6);
}

.bd-title span { font-size: 13px; color: var(--pc-lav); margin-top: 3px; }

.bd-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 13px;
  color: rgba(246, 239, 255, 0.75);
}

.bd-stats b { font: 16px/1 var(--pc-loud); color: #fff; letter-spacing: 0.04em; }
.bd-honey b { color: var(--pc-butter); }

.bd-x {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  font: 20px/1 var(--pc-loud);
  background: rgba(22, 11, 46, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  transition: transform 0.12s, background 0.12s;
}

.bd-x:hover { background: rgba(255, 79, 163, 0.35); }
.bd .bd-x:focus-visible { outline-offset: -5px; }
.bd-x:active { transform: scale(0.92); }

.bd-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 2px 6px;
  margin: 0 -4px;
  scroll-snap-type: x proximity;
}

.bd-tabs::-webkit-scrollbar { display: none; }

.bd-tab {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  scroll-snap-align: center;
  opacity: 0.62;
  transform: scale(0.92);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
}

.bd-tab canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.bd-tab[aria-selected="true"] {
  opacity: 1;
  transform: scale(1.06);
}

.bd-tab[aria-selected="true"] canvas { box-shadow: 0 0 0 3px #fff, 0 0 18px var(--pc-hot); }

.bd-tab i {
  position: absolute;
  right: -5px;
  bottom: -5px;
  font: 10px/1 var(--pc-loud);
  font-style: normal;
  color: var(--pc-night);
  background: #fff;
  border-radius: 999px;
  padding: 3px 5px 2px;
}

.bd-tab.is-full i { background: var(--pc-butter); }

.bd-book {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bd-side {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name stage" "how stage";
  align-items: center;
  column-gap: 10px;
}

.bd-cover { display: none; }

.bd-name {
  grid-area: name;
  margin: 0;
  font: 22px/1.05 var(--pc-loud);
  letter-spacing: 0.04em;
  color: #fff;
}

.bd-name small {
  display: block;
  margin-top: 4px;
  font: 13px/1.2 var(--pc-cute);
  letter-spacing: 0;
  color: var(--pc-lav);
}

.bd-how {
  grid-area: how;
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(246, 239, 255, 0.72);
}

.bd-prog {
  height: 6px;
  margin: 6px 0 2px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.bd-prog i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--pc-hot), var(--pc-butter));
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bd-stage {
  grid-area: stage;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.bd-stage canvas {
  width: 74px;
  height: auto;
  filter: drop-shadow(0 0 14px rgba(255, 79, 163, 0.4));
  animation: bd-bob 2.4s ease-in-out infinite;
  transform-origin: 50% 100%;
}

@keyframes bd-bob {
  50% { transform: translateY(-3px) rotate(2deg); }
}

.bd-bubble {
  display: none;
  margin: 0;
  max-width: 220px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #3a1a5c;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 2px var(--pc-hot);
}

.bd-onstage-label {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  font: 11px/1 var(--pc-loud);
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: #fff;
  background: var(--pc-hot);
  border-radius: 999px;
  padding: 3px 6px 2px;
}

.bd-page {
  position: relative;
  padding: 12px 12px 10px 22px;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 22px),
    linear-gradient(160deg, #3a1d6e, #2a1356 60%, #24104a);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  touch-action: pan-y;
}

.bd-rings {
  position: absolute;
  left: 6px;
  top: 14%;
  bottom: 14%;
  width: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.bd-rings i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #12082a;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.bd-pagehead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font: 14px/1 var(--pc-loud);
  letter-spacing: 0.06em;
  color: rgba(246, 239, 255, 0.85);
}

.bd-pagehead span { color: var(--pc-butter); font-size: 16px; }

.bd-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 10px;
}

.bd-grid.is-nine { width: min(100%, 300px); margin: 0 auto; gap: 8px; }

.bd-pocket {
  position: relative;
  padding: 5px;
  border: 0;
  border-radius: 10px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), inset 0 -10px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bd-pocket::after {
  /* the clear sleeve's gloss */
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 7px;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.22), transparent 30%, transparent 70%, rgba(255, 255, 255, 0.08));
}

.bd-ph {
  width: 100%;
  aspect-ratio: 300 / 465;
  border-radius: 4.67% / 3.01%;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.05) 30%, rgba(255, 255, 255, 0.16) 50%, rgba(255, 255, 255, 0.05) 70%);
  background-size: 300% 100%;
  animation: bd-shimmer 1s linear infinite;
}

@keyframes bd-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

.bd-pocket:hover { transform: translateY(-3px) rotate(-1deg); }
.bd-pocket:active { transform: scale(0.96); }
.bd-pocket.is-new { animation: bd-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes bd-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.08); }
}

.bd-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  font: 13px/1 var(--pc-loud);
  letter-spacing: 0.08em;
  color: rgba(246, 239, 255, 0.6);
}

.bd-arrow {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.bd-arrow:active { transform: scale(0.92); }

.bd-arrow svg, .bd-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.bd-line {
  position: relative;
  align-self: center;
  margin: 2px auto 0;
  max-width: 340px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  color: #3a1a5c;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 0 0 3px var(--pc-hot), 0 0 24px rgba(255, 79, 163, 0.4);
}

.bd-line::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -12px;
  margin-left: -8px;
  border-style: solid;
  border-width: 0 8px 12px;
  border-color: transparent transparent #fff;
  filter: drop-shadow(0 -3px 0 var(--pc-hot));
}

.bd-spacer { flex: 1 1 auto !important; min-height: 4px; }

.bd-foot {
  display: flex;
  gap: 10px;
}

.bd-btn {
  flex: 1;
  min-height: 46px;
  padding: 10px 14px;
  font: 16px/1 var(--pc-cute);
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pc-hot), #b06cff);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5) inset, 0 6px 20px rgba(255, 79, 163, 0.35);
  transition: transform 0.12s;
}

.bd-btn:hover { transform: scale(1.03); }
.bd-btn:active { transform: scale(0.96); }

.bd-btn.alt {
  background: rgba(22, 11, 46, 0.55);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45) inset;
}

.bd-btn.gold {
  color: var(--pc-night);
  background: linear-gradient(135deg, var(--pc-butter), #ffb347);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6) inset, 0 6px 20px rgba(255, 200, 80, 0.35);
}

.bd-btn[disabled] {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

/* ---------- Binder sheets (detail / trade / odds) ---------- */

.bd-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 4, 24, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: bd-fade 0.2s ease-out;
}

.bd-sheet[hidden] { display: none; }

@keyframes bd-fade { from { opacity: 0; } }

.bd-sheet-in {
  position: relative;
  width: min(100%, 560px);
  max-height: 92%;
  overflow-y: auto;
  padding: 18px max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(170deg, #34186a, #1d0d3e);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: bd-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes bd-up { from { transform: translateY(40%); opacity: 0; } }

.bd-sheet-in .bd-x {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
}

.bd-sheet h3 {
  margin: 0 52px 4px 0;
  font: 24px/1.1 var(--pc-loud);
  letter-spacing: 0.03em;
  color: #fff;
}

.bd-sheet p { margin: 0; }

.bd-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.bd-dcard {
  --dcw: min(62vw, 260px, 42vh);
  width: var(--dcw);
  margin-top: 6px;
}

/* A live 3D card (card3d.js): its GL canvas overhangs the card box by 16% / 11% for tilt and the
   contact shadow, and the sheet scrolls (so it clips), so the box gets that room as margin. */
.bd-dcard.is-3d {
  margin: calc(var(--dcw) * 0.17) calc(var(--dcw) * 0.16) calc(var(--dcw) * 0.14);
}

.bd-dinfo {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  align-items: center;
}

.bd-dinfo h3 { margin: 0; }

.bd-chip {
  display: inline-block;
  font: 12px/1 var(--pc-loud);
  letter-spacing: 0.1em;
  color: var(--pc-night);
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px 4px;
}

.bd-chip.r-pob { background: var(--pc-sky); }
.bd-chip.r-fansign { background: var(--pc-hot); color: #fff; }
.bd-chip.r-holo { background: linear-gradient(90deg, #ff9fd2, #fff3a8, #a8fff0, #a8dcff, #d8c8ff); }

.bd-code { font: 13px/1 var(--pc-loud); letter-spacing: 0.08em; color: rgba(246, 239, 255, 0.6); }
.bd-wears { font-size: 14px; color: var(--pc-lav); }
.bd-meta { font-size: 13px; color: rgba(246, 239, 255, 0.7); }
.bd-hint { font-size: 12px; color: rgba(246, 239, 255, 0.5); }

.bd-dinfo .bd-btn { width: 100%; max-width: 320px; flex: none; margin-top: 4px; }

.bd-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }

.bd-group h4 {
  margin: 0 0 8px;
  font: 13px/1 var(--pc-loud);
  letter-spacing: 0.08em;
  color: var(--pc-butter);
}

.bd-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.bd-row + .bd-row { margin-top: 6px; }

.bd-row canvas { width: 44px; height: auto; border-radius: 4px; display: block; }

.bd-row b { display: block; font-size: 15px; font-weight: 400; color: #fff; }
.bd-row small { display: block; font-size: 12px; color: rgba(246, 239, 255, 0.6); }

.bd-row .bd-btn {
  flex: none;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
}

.bd-empty {
  padding: 18px;
  text-align: center;
  color: rgba(246, 239, 255, 0.7);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.bd-table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.bd-table th, .bd-table td {
  padding: 8px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bd-table th { font: 11px/1.2 var(--pc-loud); letter-spacing: 0.06em; color: var(--pc-lav); }
.bd-table td:first-child { text-align: left; font-family: var(--pc-loud); letter-spacing: 0.06em; }

.bd-rules { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; color: rgba(246, 239, 255, 0.85); }
.bd-rules b { color: var(--pc-butter); font-weight: 400; }

.bd-say {
  margin-top: 14px !important;
  padding: 10px 14px;
  font-size: 14px;
  color: #3a1a5c;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 2px var(--pc-hot);
}

.bd-toast {
  position: fixed;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 70;
  transform: translateX(-50%);
  padding: 10px 16px;
  font-size: 15px;
  color: var(--pc-night);
  background: var(--pc-butter);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: bd-toast 2.2s ease-out forwards;
  pointer-events: none;
}

@keyframes bd-toast {
  0% { opacity: 0; transform: translate(-50%, 20px); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Desktop: a two-page spread */
@media (min-width: 760px) {
  .bd {
    padding-left: max(28px, env(safe-area-inset-left));
    padding-right: max(28px, env(safe-area-inset-right));
    align-items: center;
  }

  .bd--in { padding-left: 0; padding-right: 0; }

  .bd-top, .bd-tabs, .bd-book, .bd-foot { width: min(100%, 1060px); }

  .bd-title b { font-size: 30px; }

  .bd-tabs { justify-content: center; gap: 12px; overflow: visible; }
  .bd-tab { width: 60px; height: 60px; }

  .bd-book {
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    flex: none;
  }

  .bd-side {
    width: 36%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 22px 18px;
    border-radius: 18px 0 0 18px;
    background: linear-gradient(200deg, #3a1d6e, #2a1356 60%, #24104a);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset -16px 0 24px -12px rgba(0, 0, 0, 0.45);
    text-align: center;
  }

  .bd-cover {
    display: block;
    width: min(100%, 230px);
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    transform: rotate(-2deg);
  }

  .bd-name { font-size: 26px; }
  .bd-prog { width: 80%; }

  .bd-stage {
    margin-top: auto;
    width: 100%;
    justify-content: center;
    align-items: flex-end;
  }

  .bd-stage canvas { width: 150px; }
  .bd-bubble { display: block; }
  .bd-line { display: none; }

  .bd-page {
    flex: 1;
    padding: 22px 26px 16px 34px;
    border-radius: 0 18px 18px 0;
  }

  .bd-rings { left: 10px; }
  .bd-grid { gap: 16px 18px; width: min(100%, 540px); margin: 0 auto; }
  .bd-grid.is-nine { width: min(100%, 360px); gap: 10px 12px; }
  .bd-pagehead { font-size: 16px; }

  .bd-foot { justify-content: center; }
  .bd-foot .bd-btn { flex: 0 1 240px; }

  .bd-sheet { align-items: center; }

  .bd-sheet-in {
    border-radius: 24px;
    max-height: 88%;
    padding: 26px;
  }

  .bd-detail {
    flex-direction: row;
    align-items: center;
    gap: 26px;
    width: min(100%, 720px);
  }

  .bd-sheet-in.bd-detail { width: min(94vw, 720px); }
  /* 280 px, or smaller on a short screen (landscape phones): the card plus the room its 3D overhang needs must fit the sheet */
  .bd-dcard { --dcw: min(280px, calc((88vh - 52px) / 1.86)); flex: none; }
  .bd-dinfo { text-align: left; align-items: flex-start; }
}

@media (min-width: 760px) and (max-height: 820px) {
  .bd-page { padding-top: 14px; }
  .bd-grid { width: min(100%, 460px); }
  .bd-grid.is-nine { width: min(100%, 300px); }
}

/* Tablets: the side page is ~260 px wide, too narrow for the bear and his bubble side by side
   (the bubble squeezed into one word per line). Stack the bubble over the bear. */
@media (min-width: 760px) and (max-width: 1100px) {
  .bd-stage { flex-direction: column-reverse; align-items: center; gap: 8px; }
  .bd-stage canvas { width: 110px; }
  .bd-bubble { max-width: 100%; text-align: center; }
}

/* ---------- Unboxing ---------- */

.ub {
  --cw: min(60vw, 268px, 38vh);
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--pc-text);
  font-family: var(--pc-cute);
  background:
    radial-gradient(ellipse 60% 45% at 50% 45%, rgba(185, 166, 255, 0.28), transparent 70%),
    rgba(14, 6, 32, 0.9);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  animation: bd-fade 0.25s ease-out;
  transition: background-color 0.6s;
}

.ub.is-dark { background-color: rgba(2, 0, 8, 0.97); }

.ub-label {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 7px;
  font: 15px/1 var(--pc-loud);
  letter-spacing: 0.12em;
  color: var(--pc-hot);
}

.ub-label::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pc-hot);
  box-shadow: 0 0 10px var(--pc-hot);
  animation: ub-blink 1s steps(1) infinite;
}

@keyframes ub-blink { 50% { opacity: 0.25; } }

.ub-skip {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 5;
  min-width: 64px;
  min-height: 44px;
  padding: 8px 14px;
  font: 14px/1 var(--pc-cute);
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.ub-stage {
  position: relative;
  width: min(86vw, 420px);
  height: min(80vh, 640px);
  display: grid;
  place-items: center;
}

.ub-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(22px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 17px;
  color: rgba(246, 239, 255, 0.85);
  animation: ub-hint 1.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ub-hint { 50% { opacity: 0.45; transform: translateY(-3px); } }

.ub-rays {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 180vmax;
  height: 180vmax;
  margin: -90vmax 0 0 -90vmax;
  pointer-events: none;
  opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.16) 0deg 6deg, transparent 6deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  transition: opacity 0.6s;
  animation: ub-spin 14s linear infinite;
}

.ub.is-holo.is-hot .ub-rays {
  opacity: 1;
  background: repeating-conic-gradient(from 0deg,
    rgba(255, 159, 210, 0.35) 0deg 5deg, transparent 5deg 12deg,
    rgba(255, 243, 168, 0.3) 12deg 17deg, transparent 17deg 24deg,
    rgba(168, 255, 240, 0.3) 24deg 29deg, transparent 29deg 36deg);
}

.ub.is-fansign.is-hot .ub-rays { opacity: 0.55; }
.ub.is-pob.is-hot .ub-rays { opacity: 0.3; }

@keyframes ub-spin { to { transform: rotate(360deg); } }

/* Album box */
.ub-boxwrap {
  --bw: min(58vw, 270px);
  --bd: calc(var(--bw) * 0.13);
  position: absolute;
  width: var(--bw);
  height: var(--bw);
  perspective: 1200px;
}

.ub-box {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(8deg) rotateY(-24deg);
}

.ub-box > div {
  position: absolute;
  backface-visibility: hidden;
}

.ub-front, .ub-backf {
  inset: 0;
  overflow: hidden;
  border-radius: 4px;
}

.ub-front { transform: translateZ(calc(var(--bd) / 2)); }
.ub-backf { transform: rotateY(180deg) translateZ(calc(var(--bd) / 2)); background: #24104a; }

.ub-front canvas { display: block; width: 100%; height: 100%; }

.ub-side {
  top: 0;
  width: var(--bd);
  height: 100%;
  left: calc(50% - var(--bd) / 2);
  display: grid;
  place-items: center;
  writing-mode: vertical-rl;
  font: calc(var(--bw) * 0.05) / 1 var(--pc-loud);
  letter-spacing: 0.2em;
  color: #fff;
}

.ub-side.r { transform: rotateY(90deg) translateZ(calc(var(--bw) / 2)); }
.ub-side.l { transform: rotateY(-90deg) translateZ(calc(var(--bw) / 2)); }

.ub-cap {
  left: 0;
  width: 100%;
  height: var(--bd);
  top: calc(50% - var(--bd) / 2);
  background: #3a1d6e;
}

.ub-cap.t { transform: rotateX(90deg) translateZ(calc(var(--bw) / 2)); background: #4b2a8a; }
.ub-cap.b { transform: rotateX(-90deg) translateZ(calc(var(--bw) / 2)); }

/* shrink wrap: two halves that tear away */
.ub-wrap {
  position: absolute;
  inset: -2px;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 20%, rgba(255, 255, 255, 0.45) 32%, transparent 40%, transparent 62%, rgba(255, 255, 255, 0.25) 70%, transparent 76%),
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
  transition: transform 0.55s cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.55s;
}

.ub-wrap.l { clip-path: polygon(0 0, 55% 0, 45% 100%, 0 100%); }
.ub-wrap.r { clip-path: polygon(55% 0, 100% 0, 100% 100%, 45% 100%); }

.ub.is-torn .ub-wrap.l { transform: translate(-60%, -20%) rotate(-28deg); opacity: 0; }
.ub.is-torn .ub-wrap.r { transform: translate(60%, -30%) rotate(24deg); opacity: 0; }

.ub-tear {
  position: absolute;
  left: 50%;
  top: -4%;
  width: 4px;
  height: 108%;
  margin-left: -2px;
  pointer-events: none;
  background: linear-gradient(#fff, var(--pc-butter));
  box-shadow: 0 0 12px #fff;
  transform: scaleY(0);
  transform-origin: 50% 0;
  opacity: 0;
}

.ub.is-tearing .ub-tear { animation: ub-tear 0.32s ease-in forwards; }

@keyframes ub-tear {
  0% { opacity: 1; transform: scaleY(0); }
  90% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1); }
}

.ub-boxwrap.drop { animation: ub-drop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both; }

@keyframes ub-drop {
  from { transform: translateY(-80vh) rotate(-14deg); }
}

.ub-boxwrap.shake { animation: ub-shake 0.32s ease-out; }

@keyframes ub-shake {
  25% { transform: rotate(-5deg) scale(1.03); }
  55% { transform: rotate(4deg) scale(1.02); }
  80% { transform: rotate(-2deg); }
}

.ub-boxwrap.open { animation: ub-open 0.55s cubic-bezier(0.5, 0, 0.7, 0.4) forwards; }

@keyframes ub-open {
  30% { transform: scale(1.08) translateY(-4%); }
  100% { transform: scale(0.5) translateY(70%); opacity: 0; }
}

/* inclusions */
.ub-inc {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 128px;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.ub-inc canvas {
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

.ub-inc.go { animation: ub-inc 1.05s cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }

@keyframes ub-inc {
  0% { opacity: 0; transform: translate(0, 40px) scale(0.3) rotate(0); }
  25% { opacity: 1; transform: translate(calc(var(--dx) * 0.6), calc(var(--dy) * 0.6)) scale(1.05) rotate(var(--rot)); }
  75% { opacity: 1; transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); }
  100% { opacity: 0; transform: translate(calc(var(--dx) * 1.3), calc(var(--dy) + 60px)) scale(0.8) rotate(var(--rot)); }
}

/* sealed pouch */
.ub-pouch {
  --glow: #ffffff;
  position: absolute;
  width: min(48vw, 212px);
  aspect-ratio: 320 / 440;
  border-radius: 8px;
  clip-path: polygon(0 3%, 4% 0, 8% 3%, 12% 0, 16% 3%, 20% 0, 24% 3%, 28% 0, 32% 3%, 36% 0, 40% 3%, 44% 0, 48% 3%, 52% 0, 56% 3%, 60% 0, 64% 3%, 68% 0, 72% 3%, 76% 0, 80% 3%, 84% 0, 88% 3%, 92% 0, 96% 3%, 100% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(115deg, transparent 25%, rgba(255, 255, 255, 0.55) 38%, transparent 46%),
    linear-gradient(160deg, #f2f0ff, #b9b4d8 40%, #e9e6ff 60%, #a6a0cc);
  display: grid;
  place-items: center;
  opacity: 0;
}

.ub-pouch canvas { width: 100%; height: 100%; display: block; }

.ub-pouchglow {
  position: absolute;
  width: min(48vw, 212px);
  aspect-ratio: 320 / 440;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 30px 6px var(--glow), 0 0 80px 20px var(--glow);
  transition: opacity 0.35s;
}

.ub.is-glow .ub-pouchglow { opacity: 1; animation: ub-pulse 0.9s ease-in-out infinite; }

.ub.is-holo .ub-pouchglow {
  box-shadow: none;
  scale: 1.14;
  background: conic-gradient(from var(--a, 0deg), #ff9fd2, #fff3a8, #a8fff0, #a8dcff, #d8c8ff, #ff9fd2);
  filter: blur(22px);
  animation: ub-pulse 0.6s ease-in-out infinite, ub-spin 3s linear infinite;
}

@keyframes ub-pulse { 50% { transform: scale(1.06); } }

.ub-pouch.in { animation: ub-pouch-in 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) forwards; }

@keyframes ub-pouch-in {
  from { opacity: 0; transform: translateY(40%) scale(0.6) rotate(8deg); }
  to { opacity: 1; transform: none; }
}

.ub-pouch.jitter { animation: ub-jitter 0.18s linear infinite; opacity: 1; }

@keyframes ub-jitter {
  25% { transform: translate(-2px, 1px) rotate(-1deg); }
  75% { transform: translate(2px, -1px) rotate(1deg); }
}

.ub-pouch.out { animation: ub-pouch-out 0.5s ease-in forwards; opacity: 1; }

@keyframes ub-pouch-out {
  to { transform: translateY(60%) scale(0.9); opacity: 0; }
}

/* card reveal */
.ub-card {
  position: absolute;
  width: var(--cw);
  opacity: 0;
  z-index: 2;
}

/* The 3D card: the viewer's box is the card's box (the flat card it hands off to has the same one) */
.ub-card--3d { aspect-ratio: 300 / 465; }
.pc3d { width: 100%; aspect-ratio: 300 / 465; }
/* Until the pouch opens the live card is invisible (opacity 0): it must not catch a press either, or a hold on
   the box would be taken for "a drag on the card" and never skip. */
.ub-card--3d:not(.rise):not(.shown) { pointer-events: none; }

.ub-card.rise { animation: ub-rise 0.55s cubic-bezier(0.2, 1.2, 0.4, 1) forwards; }

@keyframes ub-rise {
  from { opacity: 1; transform: translateY(26%) scale(0.78); }
  to { opacity: 1; transform: translateY(-6%) scale(1); }
}

.ub-card.shown { opacity: 1; transform: translateY(-6%); }

.ub-card.file { transition: transform 0.6s cubic-bezier(0.5, 0, 0.3, 1), opacity 0.6s; }

.ub-stamp {
  position: absolute;
  z-index: 4;
  top: calc(50% - var(--cw) * 0.868 - 34px);
  left: 50%;
  font: 54px/1 var(--pc-loud);
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  -webkit-text-stroke: 2px var(--pc-night);
  text-shadow: 0 0 18px var(--glow, #fff), 0 4px 0 var(--pc-night);
  transform: translateX(-50%) rotate(-8deg);
  opacity: 0;
  pointer-events: none;
}

.ub-stamp.go { animation: ub-stamp 0.42s cubic-bezier(0.3, 1.6, 0.5, 1) forwards; }
.ub-stamp.gone { display: none; }
.ub-stamp.r-album { font-size: 42px; }

@keyframes ub-stamp {
  from { opacity: 0; transform: translateX(-50%) rotate(-8deg) scale(2.4); }
  to { opacity: 1; transform: translateX(-50%) rotate(-8deg) scale(1); }
}

.ub-stamp.r-holo {
  background: linear-gradient(90deg, #ff9fd2, #fff3a8, #a8fff0, #a8dcff, #d8c8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ub-info {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(50% + var(--cw) * 0.682 + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.ub.is-revealed .ub-info { opacity: 1; transform: none; }

.ub-info b {
  font: 24px/1.1 var(--pc-loud);
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0 2px 0 var(--pc-night), 0 0 14px rgba(0, 0, 0, 0.6);
}

.ub-info small { font: 13px/1 var(--pc-loud); letter-spacing: 0.1em; color: rgba(246, 239, 255, 0.65); }

.ub-new {
  font: 15px/1 var(--pc-loud);
  letter-spacing: 0.08em;
  color: var(--pc-night);
  background: var(--pc-butter);
  border-radius: 999px;
  padding: 6px 12px 5px;
  box-shadow: 0 0 18px rgba(255, 224, 102, 0.6);
}

.ub-new.dup { background: #fff; }

.ub-newrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }

/* "put it on the bear ♡": the only live control in .ub-info (which ignores the pointer), and only once the card is up */
.ub .ub-wear {
  position: relative;
  min-height: 40px;
  padding: 8px 14px;
  font: 15px/1 var(--pc-cute);
  color: #fff;
  background: rgba(255, 79, 163, 0.28);
  border: 2px solid var(--pc-hot);
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(255, 79, 163, 0.45);
  cursor: pointer;
  visibility: hidden;
}

.ub-wear::after { content: ""; position: absolute; inset: -4px -2px; } /* a 48 px thumb target */
.ub.is-revealed .ub-wear { visibility: visible; pointer-events: auto; }
.ub .ub-wear:hover { background: rgba(255, 79, 163, 0.45); }
.ub .ub-wear.on { color: var(--pc-night); background: var(--pc-hot); cursor: default; }

.ub-say {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 64px));
  width: min(92vw, 400px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.ub-say canvas { width: 84px; height: auto; flex: none; margin: -14px -6px 0 -10px; }

.ub-say p {
  flex: 1;
  margin: 0;
  min-height: 3.2em;
  display: flex;
  align-items: center;
  padding: 9px 14px;
  font-size: 15px;
  line-height: 1.35;
  color: #3a1a5c;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 0 0 3px var(--pc-hot), 0 0 24px rgba(255, 79, 163, 0.45);
}

.ub.is-said .ub-say { opacity: 1; }

/* burst */
.ub-burst {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 44%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ub-burst i {
  position: absolute;
  left: 0;
  top: 0;
  font-style: normal;
  font: var(--fs, 20px) / 1 var(--pc-loud);
  color: var(--c, #fff);
  text-shadow: 0 0 8px var(--c, #fff);
  animation: ub-bit 1.1s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

@keyframes ub-bit {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}

/* honey drops flying to the counter */
.ub-honey {
  position: absolute;
  z-index: 5;
  top: calc(max(16px, env(safe-area-inset-top)) + 40px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px 6px;
  font: 17px/1 var(--pc-loud);
  letter-spacing: 0.04em;
  color: var(--pc-night);
  background: var(--pc-butter);
  border-radius: 999px;
  box-shadow: 0 0 22px rgba(255, 224, 102, 0.55);
  opacity: 0;
  transition: opacity 0.3s;
}

.ub-drop {
  position: absolute;
  z-index: 6;
  font: 22px/1 var(--pc-loud);
  font-style: normal;
  color: var(--pc-butter);
  text-shadow: 0 0 10px rgba(255, 200, 60, 0.9);
  pointer-events: none;
  opacity: 0;
  animation: ub-drop 0.9s cubic-bezier(0.5, 0, 0.6, 1) forwards;
}

@keyframes ub-drop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  15% { opacity: 1; transform: translate(calc(-50% + var(--wob) * 0.3), calc(-50% - 30px)) scale(1.2); }
  100% { opacity: 0.2; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.6); }
}

.ub.is-revealed .ub-honey.on { opacity: 1; }

/* the binder page the card files into */
.ub-page {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: min(84vw, 340px);
  padding: 14px 14px 12px 24px;
  border-radius: 16px;
  transform: translate(-50%, -50%) scale(0.9);
  background: linear-gradient(160deg, #3a1d6e, #24104a);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.ub.is-filing .ub-page { opacity: 1; transform: translate(-50%, -50%); }

.ub-page .bd-pagehead { margin-bottom: 8px; }
.ub-page .bd-grid { gap: 8px; }
.ub-page .bd-pocket:hover { transform: none; }

.ub-page .bd-pagehead span.tick { animation: ub-tick 0.5s cubic-bezier(0.3, 1.8, 0.5, 1); display: inline-block; }

@keyframes ub-tick {
  40% { transform: scale(1.7); color: #fff; }
}

.ub-full {
  margin-top: 10px;
  text-align: center;
  font: 20px/1 var(--pc-loud);
  letter-spacing: 0.06em;
  color: var(--pc-butter);
  text-shadow: 0 0 14px rgba(255, 224, 102, 0.6);
  animation: ub-stamp-s 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

@keyframes ub-stamp-s { from { transform: scale(2); opacity: 0; } }

.ub-shake { animation: ub-screen 0.45s ease-out; }

@keyframes ub-screen {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
}

@media (min-width: 760px) {
  .ub { --cw: min(300px, 40vh); }
  .ub-stamp { font-size: 68px; top: calc(50% - var(--cw) * 0.868 - 44px); }
}

/* Landscape phones (wide, under 480 px tall) have no room under the card: the name, the code and the NEW chip
   go beside it on the right, and the bear with his bubble to its left, so nothing prints over the card or over
   each other. The card keeps the middle (the box, the pouch and the filing page all sit there). */
@media (orientation: landscape) and (max-height: 480px) {
  .ub-stage { width: min(96vw, 820px); }
  .ub-info {
    top: 50%;
    left: calc(50% + var(--cw) * 0.5 + 18px);
    right: 0;
    align-items: flex-start;
    text-align: left;
    transform: translateY(calc(-50% + 10px));
  }
  .ub.is-revealed .ub-info { transform: translateY(-50%); }
  .ub-newrow { justify-content: flex-start; }
  .ub-say {
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(calc(50vw - var(--cw) * 0.5 - 28px), 340px);
    transform: none;
  }
  .ub-stamp { font-size: 46px; top: calc(50% - var(--cw) * 0.868 - 24px); }
}

/* Reduced motion: no flying, shaking or spinning; quick fades instead */
.pc.rm .pc-tilt, .pc.rm .pc-flip, .pc.rm::before { transition-duration: 0.2s; transition-timing-function: ease-out; }

.ub.rm *, .ub.rm *::before, .bd.rm .bd-stage canvas {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

.ub.rm .ub-rays { animation: none; }
.ub.rm .ub-card.file { transition: opacity 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .bd-stage canvas, .ub-rays, .ub-hint { animation: none; }
  .ub-boxwrap.drop, .ub-boxwrap.shake, .ub-pouch.jitter, .ub-shake { animation: none; }
  .pc-tilt, .pc::before { transition-duration: 0.3s; transition-timing-function: ease-out; }
}
