/* UmamusumeDB 每日闪卡卡包 — Player-Facing Ritual Styles */
:root {
  --bg-obsidian: #050811;
  --bg-navy: #0a1124;
  --bg-indigo: #121e3d;
  --gold-bright: #fae3ab;
  --gold-main: #e6be6a;
  --gold-deep: #9c752f;
  --rose-foil: #efb8c8;
  --rose-deep: #b56d86;
  --prism-cyan: #a2e3ff;
  --text-primary: #f5f7fc;
  --text-secondary: #a8b6cf;
  --text-quiet: #697894;
  --glass-surface: rgba(13, 20, 40, 0.72);
  --glass-border: rgba(240, 214, 156, 0.18);
  --aura-rgb: 230, 190, 106;
  --aura-sub-rgb: 239, 184, 200;
}

body[data-aura="moon"] {
  --aura-rgb: 156, 218, 255;
  --aura-sub-rgb: 196, 178, 255;
}

body[data-aura="gold"] {
  --aura-rgb: 246, 205, 112;
  --aura-sub-rgb: 242, 162, 198;
}

body[data-aura="rose"] {
  --aura-rgb: 242, 152, 182;
  --aura-sub-rgb: 245, 204, 128;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg-obsidian);
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background:
    radial-gradient(ellipse 85% 58% at 50% 18%, rgba(var(--aura-rgb), 0.11) 0%, rgba(18, 30, 61, 0.42) 48%, rgba(5, 8, 17, 0.98) 100%),
    var(--bg-obsidian);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Hiragino Sans", "Noto Sans CJK JP", "Noto Sans JP", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.9s ease;
}

/* Subtle nocturnal racecourse track curves in deep background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 130% 62% at 50% 108%, transparent 58%, rgba(230, 190, 106, 0.045) 58.6%, transparent 59.4%),
    radial-gradient(ellipse 112% 54% at 50% 108%, transparent 58%, rgba(239, 184, 200, 0.035) 58.5%, transparent 59.3%);
}

/* Minimal Top Bar */
.topbar {
  position: relative;
  z-index: 20;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.top-link:hover,
.top-link:focus-visible {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(230, 190, 106, 0.35);
  outline: none;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pill-ghost,
.icon-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(12, 18, 36, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.11);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.pill-ghost:hover,
.icon-pill:hover,
.pill-ghost:focus-visible,
.icon-pill:focus-visible {
  color: var(--text-primary);
  border-color: rgba(230, 190, 106, 0.42);
  background: rgba(22, 32, 60, 0.85);
  outline: none;
}

.pill-ghost:active,
.icon-pill:active {
  transform: scale(0.96);
}

.icon-pill[aria-pressed="true"] {
  color: var(--gold-bright);
  border-color: rgba(230, 190, 106, 0.48);
  background: rgba(230, 190, 106, 0.12);
}

.icon-pill svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-btn {
  color: var(--gold-bright);
  border-color: rgba(230, 190, 106, 0.34);
  animation: softFadeIn 0.25s ease;
}

/* Main Stage Shell */
.stage-shell {
  position: relative;
  z-index: 5;
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(8px, 2.5dvh, 24px) 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.stage-shell[data-stage="sealed"] {
  justify-content: center;
}

/* Shared 3D Ritual Viewport (Pack + Emerging Card) */
.ritual-viewport {
  position: relative;
  width: 100%;
  min-height: clamp(400px, 56dvh, 520px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
  perspective-origin: 50% 42%;
}

.ambient-halo {
  position: absolute;
  width: min(88vw, 390px);
  height: min(88vw, 390px);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(var(--aura-rgb), 0.22) 0%,
    rgba(var(--aura-sub-rgb), 0.11) 38%,
    transparent 72%
  );
  filter: blur(18px);
  transform: scale(0.86);
  opacity: 0.72;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.9s ease, background 0.9s ease;
  z-index: 0;
}

.stage-shell[data-beat="3"] .ambient-halo,
.stage-shell[data-beat="4"] .ambient-halo {
  transform: scale(0.8);
  opacity: 0.55;
}

.stage-shell[data-beat="5"] .ambient-halo,
.stage-shell[data-beat="6"] .ambient-halo,
.stage-shell[data-stage="revealed"] .ambient-halo {
  transform: scale(1.16);
  opacity: 0.96;
}

.fx-canvas {
  position: absolute;
  inset: -40px -16px;
  width: calc(100% + 32px);
  height: calc(100% + 80px);
  pointer-events: none;
  z-index: 18;
}

/* ==========================================================================
   V4 — HOLOGRAPHIC PLASTIC FILM BAG (镭射塑料袋)
   Thin metallized pouch, not a rigid box.
   ========================================================================== */
.pack-scene {
  position: relative;
  z-index: 10;
  width: clamp(250px, 70vw, 310px);
  height: clamp(390px, 58dvh, 480px);
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
}

.stage-shell[data-stage="revealed"] .pack-scene.pack-parked {
  position: absolute;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.bag-ground-shadow {
  position: absolute;
  left: 50%;
  bottom: 7%;
  width: 88%;
  height: 36px;
  transform: translateX(-50%) translateX(var(--shadow-x, 8px)) scale(var(--shadow-s, 1), 1);
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.55) 0%, rgba(8, 6, 12, 0.28) 48%, transparent 74%);
  pointer-events: none;
  z-index: 0;
  filter: blur(4px);
}

.bag-object {
  --tear-pct: 0%;
  --pack-rx: -8deg;
  --pack-ry: -16deg;
  --pack-tx: 0px;
  --pack-ty: 0px;
  --pack-tz: 0px;
  --pack-scale: 1;
  --sheen-x: 42%;
  --sheen-y: 36%;
  --shadow-x: 8px;
  --shadow-s: 1;
  --film-shift-x: 40%;
  --film-shift-y: 38%;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  outline: none;
  transform-style: preserve-3d;
  z-index: 2;
}

.bag-object:focus-visible .bag {
  box-shadow: 0 0 0 3px rgba(250, 227, 171, 0.7);
}

.bag-rig {
  width: var(--bag-w, 268px);
  height: var(--bag-h, 400px);
  transform-style: preserve-3d;
  transform:
    translate3d(var(--pack-tx), var(--pack-ty), var(--pack-tz))
    rotateX(var(--pack-rx))
    rotateY(var(--pack-ry))
    scale(var(--pack-scale));
  will-change: transform;
}

.bag {
  --bag-w: 268px;
  --bag-h: 400px;
  width: var(--bag-w);
  height: var(--bag-h);
  position: relative;
  transform-style: preserve-3d;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.35));
}

/* Soft film edge — stuffed-envelope thickness, not a gold spine */
.bag-side {
  position: absolute;
  top: 5.2%;
  bottom: 5.2%;
  width: 6px;
  pointer-events: none;
  border-radius: 1px;
  background:
    linear-gradient(180deg, #6aa, #3a3a55 20%, #1a1a28 70%, #4a3a55);
  opacity: 0.85;
  z-index: 0;
}
.bag-side-right {
  right: -4px;
  background:
    linear-gradient(90deg, rgba(40, 36, 58, 0.2), rgba(180, 160, 210, 0.45) 40%, rgba(80, 200, 210, 0.35) 70%, rgba(20, 18, 28, 0.9));
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.12);
  border-radius: 0 3px 3px 0;
}
.bag-side-left {
  left: -3px;
  opacity: 0.45;
  background: linear-gradient(90deg, rgba(10, 10, 16, 0.8), rgba(80, 70, 90, 0.3));
}

.bag-back-film {
  position: absolute;
  inset: 5% 1.5% 5%;
  border-radius: 2px;
  background:
    linear-gradient(160deg, #1a1528 0%, #0c0c14 60%, #161022 100%);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.55);
  transform: translateZ(-3px);
}

/* Card travels inside the bag, behind the front film */
.bag-card-slot {
  position: absolute;
  left: 8%;
  width: 84%;
  top: 0;
  height: 100%;
  overflow: visible;
  transform: translateZ(1px);
  transform-style: preserve-3d;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
  opacity: 0;
}
.stage-shell[data-beat="3"] .bag-card-slot,
.stage-shell[data-beat="4"] .bag-card-slot,
.stage-shell[data-beat="5"] .bag-card-slot {
  opacity: 1;
}
.bag-card-slot .card-tilt-box {
  width: 100%;
  pointer-events: none;
  transform:
    translateY(var(--card-draw-y, 0%))
    translateZ(var(--card-draw-z, 1px))
    rotateX(var(--card-draw-rx, 4deg));
  transform-origin: center bottom;
  transition: none;
}

/* Front pouch — printed face under / in the laser film */
.bag-pouch {
  position: absolute;
  inset: 0;
  transform: translateZ(3px);
  transform-style: preserve-3d;
  overflow: hidden;
  border-radius: 2px 2px 3px 3px;
  background: linear-gradient(165deg, #1a274d 0%, #0d152e 42%, #090f21 78%, #12182c 100%);
  z-index: 3;
}

.bag-print {
  position: absolute;
  left: 0;
  right: 0;
  top: 7.2%;
  bottom: 6.8%;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.bag-ornament-svg {
  position: absolute;
  inset: 4% 6% 8%;
  width: auto;
  height: auto;
  pointer-events: none;
  z-index: 0;
}

.bag-face-copy {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14% 10% 11%;
  text-align: center;
}

.pack-kicker,
.bag-face-copy .pack-kicker {
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.32em;
  color: rgba(250, 227, 171, 0.82);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.pack-center-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pack-main-title {
  font-size: 1.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #fae3ab;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.45);
  -webkit-text-stroke: 0.3px rgba(80, 60, 20, 0.25);
}

.pack-date-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(5, 8, 18, 0.72);
  border: 1px solid rgba(250, 227, 171, 0.35);
  color: #fae3ab;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  font-weight: 600;
}

.pack-bottom-note {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(250, 227, 171, 0.7);
}

/* Laser / holographic film stack sitting on the print */
.bag-film {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  border-radius: inherit;
  overflow: hidden;
}

.bag-film-tex {
  position: absolute;
  inset: -8%;
  background-image: url("./textures/bag-film.webp");
  background-size: 170% 170%;
  background-position: var(--film-shift-x, 40%) var(--film-shift-y, 38%);
  mix-blend-mode: soft-light;
  opacity: 0.28;
  filter: saturate(0.75) contrast(1.05);
  transition: background-position 0.12s linear;
}

.bag-wrinkle {
  position: absolute;
  inset: -4%;
  background-image: url("./textures/bag-wrinkle.webp");
  background-size: 120% 120%;
  background-position: calc(var(--film-shift-x, 40%) * 0.4) calc(var(--film-shift-y, 38%) * 0.4);
  mix-blend-mode: multiply;
  opacity: 0.32;
  pointer-events: none;
}

.bag-spec {
  position: absolute;
  inset: -10%;
  background-image: url("./textures/bag-spec.webp");
  background-size: 180% 180%;
  background-position: var(--sheen-x, 42%) var(--sheen-y, 36%);
  mix-blend-mode: screen;
  opacity: 0.18;
  pointer-events: none;
}

.bag-sheen {
  position: absolute;
  inset: -40%;
  pointer-events: none;
  background: linear-gradient(
    118deg,
    transparent 30%,
    rgba(255, 90, 200, 0.08) 40%,
    rgba(160, 255, 240, 0.28) 47%,
    rgba(255, 230, 140, 0.24) 51%,
    rgba(140, 130, 255, 0.12) 57%,
    transparent 66%
  );
  background-size: 220% 220%;
  background-position: var(--sheen-x, 42%) var(--sheen-y, 36%);
  mix-blend-mode: color-dodge;
  opacity: 0.7;
  transform: translateZ(1px);
}

.bag-glaze {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, transparent 22%, transparent 70%, rgba(0, 0, 0, 0.18) 100%),
    radial-gradient(ellipse 80% 55% at 38% 32%, rgba(255, 255, 255, 0.16), transparent 62%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* Air pillow — the bag is slightly puffy from the card inside */
.bag-pillow {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 22%;
  bottom: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 45% 40%, rgba(255, 255, 255, 0.14), transparent 68%);
  mix-blend-mode: soft-light;
  pointer-events: none;
  z-index: 5;
  transform: translateZ(1px);
}

/* Heat-crimped seals — thin ribbed welds, silver film, not gold slabs */
.bag-crimp {
  position: absolute;
  left: 0;
  right: 0;
  height: 7.1%;
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(230, 230, 240, 0.28) 0 2px,
      rgba(40, 42, 58, 0.55) 2px 4px,
      rgba(180, 200, 220, 0.22) 4px 5px,
      rgba(20, 18, 28, 0.5) 5px 7px
    ),
    linear-gradient(180deg, #8a8aa0 0%, #3a3a4c 35%, #1c1c28 70%, #2a2a38 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45);
}
.bag-crimp-top {
  top: 0;
  border-radius: 2px 2px 0 0;
  clip-path: polygon(
    0 18%, 2.2% 0, 4.4% 18%, 6.6% 0, 8.8% 18%, 11% 0, 13.2% 18%, 15.4% 0,
    17.6% 18%, 19.8% 0, 22% 18%, 24.2% 0, 26.4% 18%, 28.6% 0, 30.8% 18%,
    33% 0, 35.2% 18%, 37.4% 0, 39.6% 18%, 41.8% 0, 44% 18%, 46.2% 0,
    48.4% 18%, 50.6% 0, 52.8% 18%, 55% 0, 57.2% 18%, 59.4% 0, 61.6% 18%,
    63.8% 0, 66% 18%, 68.2% 0, 70.4% 18%, 72.6% 0, 74.8% 18%, 77% 0,
    79.2% 18%, 81.4% 0, 83.6% 18%, 85.8% 0, 88% 18%, 90.2% 0, 92.4% 18%,
    94.6% 0, 96.8% 18%, 100% 0, 100% 100%, 0 100%
  );
}
.bag-crimp-bottom {
  bottom: 0;
  border-radius: 0 0 3px 3px;
  clip-path: polygon(
    0 0, 100% 0, 100% 82%, 97.8% 100%, 95.6% 82%, 93.4% 100%, 91.2% 82%,
    89% 100%, 86.8% 82%, 84.6% 100%, 82.4% 82%, 80.2% 100%, 78% 82%,
    75.8% 100%, 73.6% 82%, 71.4% 100%, 69.2% 82%, 67% 100%, 64.8% 82%,
    62.6% 100%, 60.4% 82%, 58.2% 100%, 56% 82%, 53.8% 100%, 51.6% 82%,
    49.4% 100%, 47.2% 82%, 45% 100%, 42.8% 82%, 40.6% 100%, 38.4% 82%,
    36.2% 100%, 34% 82%, 31.8% 100%, 29.6% 82%, 27.4% 100%, 25.2% 82%,
    23% 100%, 20.8% 82%, 18.6% 100%, 16.4% 82%, 14.2% 100%, 12% 82%,
    9.8% 100%, 7.6% 82%, 5.4% 100%, 3.2% 82%, 0 100%
  );
}

.tear-nick {
  position: absolute;
  left: 6px;
  top: 0;
  width: 16px;
  height: 14px;
  background: var(--bg-obsidian);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.crimp-caption {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(230, 230, 240, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  z-index: 1;
}

.bag-weld {
  position: absolute;
  top: 7%;
  bottom: 7%;
  width: 3px;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(200, 200, 220, 0.25), rgba(20, 18, 28, 0.4), rgba(180, 200, 210, 0.2));
  opacity: 0.7;
}
.bag-weld-left { left: 0; }
.bag-weld-right { right: 0; }

/* Torn mouth lip — thin curled plastic rim of the opening; sits under the exiting card */
.bag-mouth-lip {
  position: absolute;
  left: 0;
  right: 0;
  top: 6.4%;
  height: 10px;
  opacity: 0;
  pointer-events: none;
  z-index: 7;
  background:
    linear-gradient(180deg, rgba(220, 230, 255, 0.55) 0 2px, rgba(180, 80, 200, 0.35) 2px 4px, rgba(20, 16, 28, 0.85) 4px 10px);
  clip-path: polygon(
    0 40%, 4% 0, 8% 70%, 12% 10%, 17% 80%, 22% 5%, 27% 65%, 32% 15%,
    38% 90%, 44% 8%, 50% 72%, 56% 12%, 62% 85%, 68% 6%, 74% 70%, 80% 18%,
    86% 78%, 92% 10%, 100% 50%, 100% 100%, 0 100%
  );
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  transform: translateZ(4px);
}
.stage-shell[data-beat="2"] .bag-mouth-lip,
.stage-shell[data-beat="3"] .bag-mouth-lip,
.stage-shell[data-beat="4"] .bag-mouth-lip,
.stage-shell[data-beat="5"] .bag-mouth-lip {
  opacity: 1;
}

/* Peeling flap — the torn-off top of the bag */
.bag-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18%;
  transform-origin: 92% 100%;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 8;
  clip-path: polygon(0 0, 0 0, 0 0);
  transition: transform 0.85s cubic-bezier(0.22, 0.12, 0.18, 1);
}
.bag-flap-inner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(165deg, #1a274d 0%, #0d152e 100%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
}
.bag-flap-inner .bag-film {
  inset: 0;
}
.bag-flap-inner .bag-crimp-top {
  /* already in the flap inner */
}

.bag-torn-lip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 10px;
  background:
    linear-gradient(180deg, #c8c8dc 0 2px, #e8d0f0 2px 5px, #5a3060 5px 7px, rgba(12, 10, 18, 0.9) 7px 10px);
  clip-path: polygon(
    0 0, 100% 0,
    100% 40%, 96% 100%, 92% 30%, 88% 90%, 83% 25%, 78% 100%, 73% 22%,
    68% 85%, 63% 18%, 58% 95%, 53% 28%, 48% 80%, 43% 15%, 38% 100%,
    33% 20%, 28% 88%, 23% 25%, 18% 78%, 13% 18%, 8% 92%, 4% 30%, 0 40%
  );
  pointer-events: none;
}

/* Beat 1: film stretch as the tear runs */
.stage-shell[data-beat="1"] .bag-flap {
  transform: rotateX(-8deg) translateY(-2px);
  transition: transform 0.35s ease;
}
.stage-shell[data-beat="1"] .bag-pouch {
  filter: contrast(1.04);
}

/* Beat 2+: flap peels and curls like thin plastic */
.stage-shell[data-beat="2"] .bag-flap,
.stage-shell[data-beat="3"] .bag-flap,
.stage-shell[data-beat="4"] .bag-flap,
.stage-shell[data-beat="5"] .bag-flap,
.stage-shell[data-beat="6"] .bag-flap {
  transform: translateY(-36px) rotateX(-62deg) rotateZ(-12deg);
  transition: transform 0.9s cubic-bezier(0.22, 0.1, 0.18, 1);
}

/* Tear head highlight */
.bag-tear-seam {
  position: absolute;
  top: 5.2%;
  left: 0;
  height: 16px;
  width: 100%;
  pointer-events: none;
  z-index: 12;
  transform: translateZ(5px);
}
.tear-stretch {
  position: absolute;
  left: 0;
  width: var(--tear-pct);
  top: -8px;
  height: 28px;
  background: linear-gradient(90deg, transparent, rgba(255, 180, 230, 0.0) 70%, rgba(200, 255, 255, 0.55) 93%, rgba(255, 240, 180, 0.8) 100%);
  opacity: 0;
  filter: blur(0.4px);
}
.stage-shell[data-beat="1"] .tear-stretch {
  opacity: 1;
}
.tear-head {
  position: absolute;
  left: var(--tear-pct);
  top: -2px;
  width: 14px;
  height: 18px;
  margin-left: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(180, 255, 255, 0.6) 40%, transparent 70%);
  opacity: 0;
  box-shadow: 0 0 10px rgba(255, 220, 255, 0.8);
}
.stage-shell[data-beat="1"] .tear-head {
  opacity: 1;
}

/* Crumple aside as a floppy object */
.stage-shell[data-beat="5"] .bag-rig,
.stage-shell[data-beat="6"] .bag-rig {
  transition: transform 1s cubic-bezier(0.22, 0.1, 0.25, 1);
}
.bag-object.is-crumpled .bag {
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4)) saturate(1.05) brightness(0.92);
}
.bag-object.is-crumpled .bag-wrinkle {
  opacity: 0.85;
  background-size: 80% 80%;
}
.bag-object.is-crumpled .bag-pouch {
  border-radius: 8px 2px 14px 6px;
}
.bag-object.is-crumpled .bag-pillow {
  opacity: 0.3;
}

/* Sealed Controls Below Pack */
.sealed-controls {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.stage-shell[data-stage="opening"] .sealed-controls,
.stage-shell[data-stage="revealed"] .sealed-controls {
  display: none;
}

.tear-cta-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 156px;
  height: 46px;
  padding: 0 28px;
  border-radius: 999px;
  border: 1px solid rgba(250, 227, 171, 0.62);
  background: linear-gradient(135deg, #f8dfa5 0%, #e4b765 55%, #ebb1c3 100%);
  color: #0b1020;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding-left: calc(28px + 0.14em);
  cursor: pointer;
  box-shadow:
    0 10px 28px rgba(230, 190, 106, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.tear-cta-btn:hover,
.tear-cta-btn:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 14px 34px rgba(230, 190, 106, 0.38);
  outline: none;
}

.tear-cta-btn:active {
  transform: scale(0.97);
}

.gesture-hint {
  font-size: 0.79rem;
  color: var(--text-quiet);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   EMERGING & REVEALED HOLOGRAPHIC CARD STAGE
   ========================================================================== */
.card-rig {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform-style: preserve-3d;
}

/* When the tilt box lives inside the pack slot, the outer rig is just a parking spot */
.card-rig.is-empty {
  opacity: 0 !important;
  pointer-events: none !important;
}

.stage-shell[data-stage="revealed"] .card-rig:not(.is-empty) {
  position: relative;
  inset: auto;
  opacity: 1;
  pointer-events: auto;
  z-index: 12;
  transform: none;
}

.card-tilt-box {
  --tilt-rx: 0deg;
  --tilt-ry: 0deg;
  --glare-x: 50%;
  --glare-y: 50%;
  --glare-alpha: 0;
  position: relative;
  width: min(92vw, 376px);
  aspect-ratio: 690 / 960;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-rx)) rotateY(var(--tilt-ry));
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.card-tilt-box.is-tilting {
  transition: transform 0.06s linear;
}

/* Thin physical edge on the card itself */
.card-physical {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.card-thickness {
  position: absolute;
  background: linear-gradient(180deg, #d8c9a4 0%, #9a8154 55%, #3a2e1a 100%);
  pointer-events: none;
}

.card-thickness-left,
.card-thickness-right {
  top: 1%;
  width: 3px;
  height: 98%;
  transform-origin: center;
}

.card-thickness-left {
  left: 0;
  transform: rotateY(-90deg) translateZ(0);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.35);
}

.card-thickness-right {
  right: 0;
  transform: rotateY(90deg);
  box-shadow: -1px 0 0 rgba(0, 0, 0, 0.35);
}

.card-thickness-bottom {
  left: 1%;
  bottom: 0;
  width: 98%;
  height: 3px;
  transform: rotateX(-90deg);
}

.card-draw-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -4%;
  height: 18%;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.55) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
}

.stage-shell[data-beat="3"] .card-draw-shadow,
.stage-shell[data-beat="4"] .card-draw-shadow {
  opacity: 0.9;
}

.card-media-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(1.5px);
  border-radius: 10px;
}

/* Keep remaining hero/veil/sweep/glare/webgl rules from v2 (spliced below). */

.hero-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 22px 38px rgba(0, 0, 0, 0.72));
  transition: filter 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
}

/* Emerging card is a visible dark foil back, not a black shape lost on the background */
.stage-shell[data-beat="3"] .hero-card-img,
.stage-shell[data-beat="4"] .hero-card-img {
  filter: brightness(0.55) contrast(1.12) saturate(0.55) drop-shadow(0 16px 24px rgba(0, 0, 0, 0.85));
}

/* Veiled physical card silhouette matching exact inner card bounds (71.3% x 68.3%) */
.card-silhouette-veil {
  position: absolute;
  left: 14.3%;
  right: 14.3%;
  top: 15.8%;
  bottom: 15.9%;
  border-radius: 13px;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(135deg, rgba(250, 227, 171, 0.22) 0%, rgba(12, 19, 38, 0.92) 26%, rgba(7, 11, 24, 0.96) 74%, rgba(239, 184, 200, 0.20) 100%);
  border: 1px solid rgba(250, 227, 171, 0.36);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.75),
    inset 0 0 28px rgba(230, 190, 106, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.68s cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-shell[data-beat="3"] .card-silhouette-veil,
.stage-shell[data-beat="4"] .card-silhouette-veil {
  opacity: 1;
}

/* Subtle rim anticipation pulse during Beat 4 */
.stage-shell[data-beat="4"] .card-silhouette-veil {
  border-color: rgba(255, 244, 212, 0.68);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.8),
    0 0 26px rgba(250, 227, 171, 0.26),
    inset 0 0 32px rgba(239, 184, 200, 0.22);
}

.veil-emblem {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(250, 227, 171, 0.34);
  transform: rotate(45deg);
  position: relative;
}

.veil-emblem::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(239, 184, 200, 0.32);
}

/* Diagonal prism light curtain during Beat 5 reveal */
.card-light-sweep {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 14%;
  bottom: 14%;
  border-radius: 16px;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
}

.card-light-sweep::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    112deg,
    transparent 34%,
    rgba(255, 255, 255, 0.08) 43%,
    rgba(255, 251, 235, 0.78) 49%,
    rgba(162, 227, 255, 0.48) 53%,
    rgba(239, 184, 200, 0.34) 57%,
    transparent 65%
  );
  transform: translateX(-85%);
}

.stage-shell[data-beat="5"] .card-light-sweep {
  opacity: 1;
  animation: lightCurtainFade 1.05s ease forwards;
}

.stage-shell[data-beat="5"] .card-light-sweep::before {
  animation: lightCurtainSweep 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes lightCurtainSweep {
  0% { transform: translateX(-85%); }
  100% { transform: translateX(88%); }
}

@keyframes lightCurtainFade {
  0%, 65% { opacity: 1; }
  100% { opacity: 0; }
}

/* Interactive post-reveal tilt specular glare */
.card-glare-overlay {
  position: absolute;
  left: 14.3%;
  right: 14.3%;
  top: 15.8%;
  bottom: 15.9%;
  border-radius: 13px;
  pointer-events: none;
  opacity: var(--glare-alpha);
  background: radial-gradient(
    circle at var(--glare-x) var(--glare-y),
    rgba(255, 255, 255, 0.28) 0%,
    rgba(162, 227, 255, 0.14) 28%,
    rgba(239, 184, 200, 0.08) 46%,
    transparent 70%
  );
  mix-blend-mode: screen;
  transition: opacity 0.25s ease;
}

/* Lazy WebGL2 Live Card Pane */
.webgl-pane {
  position: absolute;
  inset: 4% 2%;
  border-radius: 16px;
  overflow: hidden;
  background: #060913;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.webgl-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #060913;
}

/* ==========================================================================
   POST-REVEAL CAPTION, ISSUE ID & ACTIONS (Hero Card First, Zero Sidebar)
   ========================================================================== */
.reveal-panel {
  width: 100%;
  max-width: 420px;
  margin-top: -6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 13px;
}

.stage-shell[data-stage="sealed"] .reveal-panel {
  display: none;
}

.stage-shell[data-stage="opening"]:not([data-beat="6"]) .reveal-panel {
  display: none;
}

.inspect-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.tilt-hint {
  font-size: 0.74rem;
  color: var(--text-quiet);
  letter-spacing: 0.04em;
}

.mode-pill-btn,
.mode-pill-link {
  appearance: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 27px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  cursor: pointer;
  transition: all 0.16s ease;
}

.mode-pill-btn:hover,
.mode-pill-link:hover,
.mode-pill-btn:focus-visible,
.mode-pill-link:focus-visible {
  color: var(--text-primary);
  border-color: rgba(230, 190, 106, 0.42);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.mode-pill-btn[aria-pressed="true"] {
  color: #090e1d;
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  font-weight: 600;
}

/* Staggered fade-in during Beat 6 (Name -> Issue ID -> Actions) */
.reveal-step {
  width: 100%;
}

.stage-shell[data-beat="6"] .step-name,
.stage-shell[data-beat="6"] .inspect-bar {
  opacity: 0;
  animation: stepRiseIn 0.46s cubic-bezier(0.22, 1, 0.36, 1) 0.02s forwards;
}

.stage-shell[data-beat="6"] .step-id {
  opacity: 0;
  animation: stepRiseIn 0.46s cubic-bezier(0.22, 1, 0.36, 1) 0.28s forwards;
}

.stage-shell[data-beat="6"] .step-actions {
  opacity: 0;
  animation: stepRiseIn 0.46s cubic-bezier(0.22, 1, 0.36, 1) 0.54s forwards;
}

@keyframes stepRiseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes softFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.char-title {
  font-size: clamp(1.22rem, 4.4vw, 1.48rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.char-sep {
  color: rgba(255, 255, 255, 0.28);
  font-weight: 400;
  margin: 0 3px;
}

.char-en {
  font-weight: 600;
  color: #dce4f5;
  font-size: 0.92em;
}

.char-outfit {
  margin-top: 3px;
  font-size: 0.88rem;
  color: var(--gold-main);
  font-weight: 500;
}

.weight-whisper {
  color: var(--text-quiet);
  font-size: 0.78rem;
  font-weight: 400;
}

/* Collector Issue ID Plaque */
.issue-plaque {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(9, 14, 28, 0.82);
  border: 1px solid rgba(230, 190, 106, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.issue-kicker {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

.issue-code {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  user-select: all;
  -webkit-user-select: all;
}

/* Primary Actions & Quiet Links */
.step-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.primary-actions {
  width: 100%;
  max-width: 356px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-action {
  appearance: none;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn-action:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.btn-action:active {
  transform: scale(0.97);
}

.btn-action:disabled {
  opacity: 0.65;
  cursor: progress;
}

.btn-primary-gold {
  border: 1px solid rgba(250, 227, 171, 0.6);
  background: linear-gradient(135deg, #f7dea2 0%, #dfb25b 100%);
  color: #0a0f1e;
  box-shadow: 0 8px 22px rgba(230, 190, 106, 0.2);
}

.btn-primary-gold:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary-glass {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.065);
  color: var(--text-primary);
}

.btn-secondary-glass:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(230, 190, 106, 0.38);
}

.quiet-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.78rem;
}

.quiet-link,
.quiet-link-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(168, 182, 207, 0.35);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.16s ease, text-decoration-color 0.16s ease;
}

.quiet-link:hover,
.quiet-link-btn:hover,
.quiet-link:focus-visible,
.quiet-link-btn:focus-visible {
  color: var(--gold-bright);
  text-decoration-color: var(--gold-bright);
  outline: none;
}

.daily-lock-note {
  font-size: 0.74rem;
  color: var(--text-quiet);
  letter-spacing: 0.03em;
}

/* Visually Quiet Footer */
.site-footer {
  position: relative;
  z-index: 10;
  padding: 14px 16px 20px;
  text-align: center;
  font-size: 0.73rem;
  color: var(--text-quiet);
}

.copyright-line {
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
  user-select: none;
  -webkit-user-select: none;
}

.copyright-line a {
  color: var(--text-secondary);
  text-decoration: none;
}

.copyright-line a:hover {
  text-decoration: underline;
}

.hidden-reset-wrap {
  margin-top: 6px;
}

.hidden-reset-btn {
  appearance: none;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  color: var(--text-quiet);
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.hidden-reset-btn:hover {
  color: var(--text-secondary);
  border-color: rgba(230, 190, 106, 0.4);
}

/* Mobile refinements */
@media (max-width: 420px) {
  .topbar {
    padding: 8px 14px 0;
  }
  .stage-shell {
    padding: 4px 14px 10px;
  }
  .ritual-viewport {
    min-height: clamp(320px, 46dvh, 400px);
  }
  .stage-shell[data-stage="revealed"] .ritual-viewport {
    min-height: 0;
  }
  .card-tilt-box {
    width: min(86vw, 300px);
  }
  .reveal-panel {
    gap: 8px;
    margin-top: 2px;
  }
  .primary-actions {
    /* Keep both actions on one row so the share view fits a phone screenshot */
    grid-template-columns: 1fr 1fr;
    max-width: 100%;
    gap: 8px;
  }
  .btn-action {
    height: 40px;
    font-size: 0.82rem;
  }
  .site-footer {
    padding: 6px 14px 12px;
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .bag-object,
  .bag-rig,
  .bag-sheen,
  .bag-flap,
  .bag-film-tex {
    animation: none !important;
    transition: none !important;
  }
  .ambient-halo,
  .card-tilt-box,
  .hero-card-img {
    transition-duration: 0.01ms !important;
  }
}

/* Production extras: streak / stamps / 7-day frame / error */
.holo-extras {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 0;
  color: #d5c49a;
  font-size: 0.92rem;
  font-weight: 600;
}
.pack-error-note {
  margin: 10px 0 0;
  color: #f3b4b4;
  font-size: 0.9rem;
}
.has-week-frame {
  position: relative;
}
.card-physical.has-week-frame::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 16px;
  pointer-events: none;
  border: 2px solid rgba(250, 227, 171, 0.85);
  box-shadow: 0 0 0 4px rgba(7, 11, 23, 0.45), 0 0 24px rgba(250, 227, 171, 0.28);
  z-index: 4;
}
