/* =========================================================================
   Chengyu Huang — shared layout, motion and state styles.
   graphic.css layers the graphic-realism look (inks, paper, print marks,
   trading-card frames, the page wipe and the opening) on top of this file.
   ========================================================================= */

:root {
  color-scheme: dark;
  --bg: #0a0920;
  --ink: #f8efe3;
  --muted: rgba(248, 239, 227, 0.72);
  --faint: rgba(248, 239, 227, 0.46);
  --line: rgba(248, 239, 227, 0.18);
  --line-strong: rgba(248, 239, 227, 0.42);
  --glass: rgba(16, 13, 40, 0.56);
  --glass-strong: rgba(12, 10, 32, 0.86);
  --page: #16133a;
  --page-2: #1d1947;
  --cover: #0f0c29;
  --shadow: rgba(3, 2, 12, 0.6);
  --hot: #ff3d7f;
  --amber: #ffb35c;
  --gold: #e8c46a;
  --teal: #19c6b6;
  --mint: #3ee6c0;
  --cyan: #4fd6ff;
  --blue: #5a93ff;
  --violet: #9269ff;
  --green: #a3e05a;
  --paper: #fff4e4;
  --print-ink: #120f2a;
  --cut: 12px;
  --radius: 14px;
  --display: "Archivo", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --body: "Inter", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-punch: cubic-bezier(0.34, 1.45, 0.52, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --chamfer: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3eadf;
  --ink: #1b1535;
  --muted: rgba(27, 21, 53, 0.74);
  --faint: rgba(27, 21, 53, 0.5);
  --line: rgba(27, 21, 53, 0.16);
  --line-strong: rgba(27, 21, 53, 0.38);
  --glass: rgba(255, 250, 243, 0.64);
  --glass-strong: rgba(253, 248, 240, 0.92);
  --page: #fbf6ee;
  --page-2: #f2e9dc;
  --cover: #231d52;
  --shadow: rgba(62, 40, 30, 0.26);
  --hot: #e8286a;
  --amber: #ef8a2c;
  --gold: #a8781f;
  --teal: #0f9d90;
  --mint: #0fa383;
  --cyan: #0a8fc2;
  --blue: #2f64e0;
  --violet: #6a45e0;
  --green: #4f9a1a;
  --paper: #fffaf2;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  /* Fallback backdrop, visible before (or without) the WebGL background. */
  background:
    radial-gradient(60% 55% at 64% 48%, rgba(236, 59, 118, 0.45), transparent 70%),
    radial-gradient(50% 60% at 82% 18%, rgba(255, 192, 115, 0.3), transparent 70%),
    radial-gradient(70% 70% at 20% 80%, rgba(14, 143, 148, 0.35), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition:
    background-color 620ms ease,
    color 520ms ease;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(60% 55% at 64% 48%, rgba(242, 138, 166, 0.5), transparent 70%),
    radial-gradient(50% 60% at 82% 18%, rgba(249, 211, 163, 0.6), transparent 70%),
    radial-gradient(70% 70% at 20% 80%, rgba(53, 179, 166, 0.25), transparent 70%),
    var(--bg);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
p {
  margin-top: 0;
}

svg {
  display: block;
}

#foil-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 900ms ease;
}

body.intro-ready #foil-canvas {
  opacity: 1;
}

/* Shared focus ring for chamfered (clip-path) controls: drawn inside. */
:is(.hud-button, .primary-action, .secondary-action, .tab-button, .icon-button, .case-link, .dialog-close, .pack-strip):focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--gold);
}

.binder-card:focus-visible,
.profile-card:focus-visible .card-face {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 1200;
  display: flex;
  gap: 0.5rem;
}

.hud-button {
  --cut: 9px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.4rem;
  padding: 0 0.9rem;
  border: 0;
  background: var(--glass);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  clip-path: var(--chamfer);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  font: 700 0.72rem/1 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 260ms ease,
    color 260ms ease;
}

.hud-button:hover {
  background: var(--ink);
  color: var(--bg);
}

.lang-toggle {
  gap: 0.15rem;
  padding: 0 0.35rem;
}

.lang-option {
  display: grid;
  place-items: center;
  min-width: 1.9rem;
  height: 1.7rem;
  opacity: 0.55;
  transition:
    background-color 240ms ease,
    color 240ms ease,
    opacity 240ms ease;
}

.lang-option[data-lang-option="zh"] {
  font-family: "Noto Sans SC", var(--display);
  font-size: 0.84rem;
  letter-spacing: 0;
}

.lang-option.is-active {
  background: var(--gold);
  color: var(--print-ink);
  opacity: 1;
}

.lang-toggle:hover .lang-option.is-active {
  background: var(--bg);
  color: var(--ink);
}

.theme-toggle-icon {
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
}

.theme-icon {
  display: none;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon--system path,
.theme-icon--dark path {
  fill: currentColor;
}

:root:not([data-theme-mode]) .theme-icon--system,
:root[data-theme-mode="system"] .theme-icon--system,
:root[data-theme-mode="dark"] .theme-icon--dark,
:root[data-theme-mode="light"] .theme-icon--light {
  display: block;
}

.theme-toggle-text {
  white-space: nowrap;
}

/* ---------- Stage layout: headline left, pack right ---------- */

@property --tear-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.pack-stage {
  --tear-progress: 0;
  --pack-tilt-x: 0deg;
  --pack-tilt-y: 0deg;
  --pack-print:
    repeating-linear-gradient(90deg, rgba(255, 244, 228, 0.24) 0 1px, rgba(10, 6, 30, 0.2) 1px 3px),
    linear-gradient(180deg, #5a1466, #2a0d4a);
  /* PACK SIZE CONTROLS: tweak these values to resize the pack/opened lip. */
  --pack-width: min(30vw, 23rem, calc(64svh * 0.72));
  --pack-hover-scale: 1.035;
  --pack-exit-distance: 16rem;
  /* Where the tear has reached, from the right edge of the pack leftward. */
  --tear-front: calc((1 - var(--tear-progress)) * 100%);
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "copy focus"
    "cta focus";
  column-gap: clamp(1rem, 4vw, 4rem);
  padding: clamp(5rem, 9vh, 7rem) clamp(1.25rem, 6vw, 6.5rem) clamp(3rem, 7vh, 5rem);
  overflow-x: clip;
  isolation: isolate;
  transition: --tear-progress 460ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pack-stage.is-dragging {
  transition: none;
}

.stage-copy {
  grid-area: copy;
  align-self: end;
  position: relative;
  z-index: 3;
  pointer-events: none;
}

.kicker,
.binder-label {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.3rem;
  color: var(--gold);
  font: 700 0.78rem/1 var(--display);
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.kicker::before,
.binder-label::before {
  content: "";
  width: 2.6rem;
  height: 1px;
  background: currentColor;
}

.binder-label {
  gap: 0.55rem;
  letter-spacing: 0.22em;
  white-space: nowrap;
}

.binder-label::before {
  width: 1.4rem;
}

h1 {
  margin: 0;
  max-width: 8ch;
  padding-bottom: 0.04em;
  font-family: var(--display);
  font-size: clamp(3.6rem, 8.6vw, 9.4rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  background: linear-gradient(172deg, var(--paper) 34%, var(--amber) 66%, var(--hot) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0.08em 0.14em rgba(4, 2, 16, 0.4));
}

:root[data-theme="light"] h1 {
  background: linear-gradient(172deg, var(--ink) 40%, #5a2a8c 70%, var(--hot) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: none;
}

.stage-copy::after {
  content: "";
  display: block;
  width: 7.5rem;
  height: 3px;
  margin-top: 1.7rem;
  background: linear-gradient(90deg, var(--hot), transparent);
  transform: skewX(-30deg);
  transform-origin: left;
}

.stage-copy .kicker,
.stage-copy h1,
.stage-copy::after {
  opacity: 0;
}

body.intro-ready .stage-copy .kicker {
  animation: riseIn 900ms var(--ease-out) 650ms both;
}

body.intro-ready .stage-copy h1 {
  animation: revealUp 1300ms var(--ease-out) 820ms both;
}

body.intro-ready .stage-copy::after {
  animation: slashIn 900ms var(--ease-out) 1500ms both;
}

.pack-stage[data-stage="revealed"] .stage-copy {
  opacity: 0.86;
  transition: opacity 900ms ease;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes revealUp {
  from {
    opacity: 1;
    clip-path: inset(100% -10% -20% -10%);
    transform: translateY(0.3em);
  }
  to {
    opacity: 1;
    clip-path: inset(-20% -10% -20% -10%);
    transform: none;
  }
}

@keyframes slashIn {
  from {
    opacity: 0;
    transform: skewX(-30deg) scaleX(0);
  }
  to {
    opacity: 1;
    transform: skewX(-30deg) scaleX(1);
  }
}

.stage-focus {
  grid-area: focus;
  position: relative;
  display: grid;
  place-items: center;
  justify-self: center;
  align-self: center;
}

/* ---------- Printer's marks around the pack (SVG) ---------- */

.stage-sigil {
  position: absolute;
  z-index: 0;
  width: calc(var(--pack-width) * 2.9);
  aspect-ratio: 1;
  color: var(--gold);
  pointer-events: none;
}

.pack-stage[data-stage="opened"] .stage-sigil,
.pack-stage[data-stage="pack-exit"] .stage-sigil {
  animation: sigilKick 1600ms var(--ease-out) both;
}

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

@keyframes fadeTo {
  to {
    opacity: var(--to, 1);
  }
}

@keyframes sigilKick {
  0% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
  18% {
    transform: scale(1.1) rotate(4deg);
    filter: brightness(2.2);
  }
  100% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

/* ---------- Booster pack ---------- */

.pack-zone {
  position: relative;
  z-index: 2;
  width: var(--pack-width);
  aspect-ratio: 0.72;
  cursor: pointer;
}

.pack-stage[data-stage="sealed"] .pack-zone {
  opacity: 0;
  transform: translate3d(0, 24vh, 0) rotate(9deg) scale(0.9);
}

body.intro-ready .pack-stage[data-stage="sealed"] .pack-zone {
  animation: packDropIn 1600ms var(--ease-out) 150ms both;
}

body.intro-complete .pack-stage[data-stage="sealed"] .pack-zone {
  animation: none;
  opacity: 1;
  transform: none;
}

.pack-shell {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  transform-style: preserve-3d;
  filter:
    drop-shadow(0 2.4rem 2.2rem rgba(4, 2, 16, 0.55))
    drop-shadow(0 0 3rem rgba(255, 70, 130, 0.22));
  transition: transform 280ms var(--ease-out);
}

:root[data-theme="light"] .pack-shell {
  filter:
    drop-shadow(0 2.2rem 2rem rgba(70, 30, 40, 0.3))
    drop-shadow(0 0 2.5rem rgba(232, 40, 106, 0.18));
}

.pack-stage[data-stage="sealed"] .pack-shell {
  animation: packFloat 6s ease-in-out infinite;
}

.pack-stage[data-stage="sealed"].is-pack-hovered .pack-shell,
.pack-stage[data-stage="sealed"] .pack-zone:hover .pack-shell {
  animation: none;
  transform:
    perspective(54rem)
    rotateX(var(--pack-tilt-x))
    rotateY(var(--pack-tilt-y))
    rotateZ(-2deg)
    scale(var(--pack-hover-scale));
}

.pack-stage[data-stage="tearing"] .pack-shell {
  transform:
    translateX(calc(var(--tear-progress) * -0.65rem))
    translateY(calc(var(--tear-progress) * 0.25rem))
    rotate(calc(-3deg + var(--tear-progress) * -4deg))
    scale(calc(1 - var(--tear-progress) * 0.025));
}

.pack-stage[data-stage="opened"] .pack-shell {
  animation: packJolt 560ms var(--ease-out) both;
}

.pack-stage[data-stage="pack-exit"] .pack-shell,
.pack-stage[data-stage="revealed"] .pack-shell {
  opacity: 0;
  transform:
    translateY(calc(1.6rem + var(--pack-exit-distance)))
    rotate(-16deg)
    scale(0.8);
  pointer-events: none;
  transition:
    transform 1050ms cubic-bezier(0.5, 0, 0.75, 0),
    opacity 700ms ease 320ms;
}

@keyframes packFloat {
  0%,
  100% {
    transform: perspective(54rem) rotateX(2deg) rotateY(-9deg) rotateZ(-4deg) translateY(0);
  }
  50% {
    transform: perspective(54rem) rotateX(-2deg) rotateY(7deg) rotateZ(-1deg) translateY(-0.8rem);
  }
}

@keyframes packDropIn {
  0% {
    opacity: 0;
    transform: translate3d(0, 24vh, 0) rotate(9deg) scale(0.9);
  }
  55% {
    opacity: 1;
    transform: translate3d(0, -1.2rem, 0) rotate(-4deg) scale(1.03);
  }
  80% {
    transform: translate3d(0, 0.3rem, 0) rotate(1deg) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes packJolt {
  0% {
    transform: rotate(-4deg) scale(1);
  }
  18% {
    transform: translate(-0.4rem, -0.9rem) rotate(4deg) scale(1.06);
  }
  38% {
    transform: translate(0.3rem, 0.4rem) rotate(-10deg) scale(0.94);
  }
  100% {
    transform: translateY(1.6rem) rotate(-8deg) scale(0.88);
  }
}

.pack {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  container-type: inline-size;
  background:
    radial-gradient(60% 45% at 50% 46%, #ff7b3a, transparent 70%),
    linear-gradient(170deg, #3a0f5c, #d11d6b 60%, #ff7b3a);
  /* Crimped top and bottom; the top is torn away along a ragged line,
     right to left, as far as the tear has run. */
  clip-path: polygon(
    min(0%, var(--tear-front)) 1.3%,
    min(2.27%, var(--tear-front)) 0%,
    min(4.55%, var(--tear-front)) 1.3%,
    min(6.82%, var(--tear-front)) 0%,
    min(9.09%, var(--tear-front)) 1.3%,
    min(11.36%, var(--tear-front)) 0%,
    min(13.64%, var(--tear-front)) 1.3%,
    min(15.91%, var(--tear-front)) 0%,
    min(18.18%, var(--tear-front)) 1.3%,
    min(20.45%, var(--tear-front)) 0%,
    min(22.73%, var(--tear-front)) 1.3%,
    min(25%, var(--tear-front)) 0%,
    min(27.27%, var(--tear-front)) 1.3%,
    min(29.55%, var(--tear-front)) 0%,
    min(31.82%, var(--tear-front)) 1.3%,
    min(34.09%, var(--tear-front)) 0%,
    min(36.36%, var(--tear-front)) 1.3%,
    min(38.64%, var(--tear-front)) 0%,
    min(40.91%, var(--tear-front)) 1.3%,
    min(43.18%, var(--tear-front)) 0%,
    min(45.45%, var(--tear-front)) 1.3%,
    min(47.73%, var(--tear-front)) 0%,
    min(50%, var(--tear-front)) 1.3%,
    min(52.27%, var(--tear-front)) 0%,
    min(54.55%, var(--tear-front)) 1.3%,
    min(56.82%, var(--tear-front)) 0%,
    min(59.09%, var(--tear-front)) 1.3%,
    min(61.36%, var(--tear-front)) 0%,
    min(63.64%, var(--tear-front)) 1.3%,
    min(65.91%, var(--tear-front)) 0%,
    min(68.18%, var(--tear-front)) 1.3%,
    min(70.45%, var(--tear-front)) 0%,
    min(72.73%, var(--tear-front)) 1.3%,
    min(75%, var(--tear-front)) 0%,
    min(77.27%, var(--tear-front)) 1.3%,
    min(79.55%, var(--tear-front)) 0%,
    min(81.82%, var(--tear-front)) 1.3%,
    min(84.09%, var(--tear-front)) 0%,
    min(86.36%, var(--tear-front)) 1.3%,
    min(88.64%, var(--tear-front)) 0%,
    min(90.91%, var(--tear-front)) 1.3%,
    min(93.18%, var(--tear-front)) 0%,
    min(95.45%, var(--tear-front)) 1.3%,
    min(97.73%, var(--tear-front)) 0%,
    min(100%, var(--tear-front)) 1.3%,
    max(0%, var(--tear-front)) 6.18%,
    max(3.85%, var(--tear-front)) 7.46%,
    max(7.69%, var(--tear-front)) 6.41%,
    max(11.54%, var(--tear-front)) 7.4%,
    max(15.38%, var(--tear-front)) 6.33%,
    max(19.23%, var(--tear-front)) 7.61%,
    max(23.08%, var(--tear-front)) 5.99%,
    max(26.92%, var(--tear-front)) 7.71%,
    max(30.77%, var(--tear-front)) 5.98%,
    max(34.62%, var(--tear-front)) 7.65%,
    max(38.46%, var(--tear-front)) 6%,
    max(42.31%, var(--tear-front)) 7.41%,
    max(46.15%, var(--tear-front)) 6.25%,
    max(50%, var(--tear-front)) 7.93%,
    max(53.85%, var(--tear-front)) 6.04%,
    max(57.69%, var(--tear-front)) 7.51%,
    max(61.54%, var(--tear-front)) 6.39%,
    max(65.38%, var(--tear-front)) 8.01%,
    max(69.23%, var(--tear-front)) 6.35%,
    max(73.08%, var(--tear-front)) 7.63%,
    max(76.92%, var(--tear-front)) 6.63%,
    max(80.77%, var(--tear-front)) 7.38%,
    max(84.62%, var(--tear-front)) 6.55%,
    max(88.46%, var(--tear-front)) 7.55%,
    max(92.31%, var(--tear-front)) 6.05%,
    max(96.15%, var(--tear-front)) 7.43%,
    max(100%, var(--tear-front)) 6.17%,
    100% 98.7%,
    97.73% 100%,
    95.45% 98.7%,
    93.18% 100%,
    90.91% 98.7%,
    88.64% 100%,
    86.36% 98.7%,
    84.09% 100%,
    81.82% 98.7%,
    79.55% 100%,
    77.27% 98.7%,
    75% 100%,
    72.73% 98.7%,
    70.45% 100%,
    68.18% 98.7%,
    65.91% 100%,
    63.64% 98.7%,
    61.36% 100%,
    59.09% 98.7%,
    56.82% 100%,
    54.55% 98.7%,
    52.27% 100%,
    50% 98.7%,
    47.73% 100%,
    45.45% 98.7%,
    43.18% 100%,
    40.91% 98.7%,
    38.64% 100%,
    36.36% 98.7%,
    34.09% 100%,
    31.82% 98.7%,
    29.55% 100%,
    27.27% 98.7%,
    25% 100%,
    22.73% 98.7%,
    20.45% 100%,
    18.18% 98.7%,
    15.91% 100%,
    13.64% 98.7%,
    11.36% 100%,
    9.09% 98.7%,
    6.82% 100%,
    4.55% 98.7%,
    2.27% 100%,
    0% 98.7%
  );
}

.pack-foil-shader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Heat-sealed crimp at the bottom of the wrapper (the top one is the seal
   strip, .pack-rip, which tears off). */
.pack::after {
  content: "";
  position: absolute;
  z-index: 4;
  left: 0;
  width: 100%;
  height: 7%;
  background:
    repeating-linear-gradient(90deg, rgba(255, 244, 228, 0.28) 0 1px, rgba(10, 6, 30, 0.22) 1px 3px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.pack::after {
  bottom: 0;
  border-top: 1px solid rgba(10, 6, 30, 0.4);
}

.pack-shine,
.card-foil,
.detail-foil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 18%, rgba(255, 255, 255, 0.36) 28%, transparent 38%),
    linear-gradient(35deg, rgba(79, 214, 255, 0.18), rgba(255, 61, 127, 0.14), rgba(255, 179, 92, 0.18));
  mix-blend-mode: screen;
  opacity: 0.55;
  transform: translateX(-24%);
  animation: foilSweep 5.4s ease-in-out infinite;
}

.pack-shine {
  z-index: 3;
  opacity: 0.4;
}

@keyframes foilSweep {
  0%,
  100% {
    transform: translateX(-32%) skewX(-8deg);
  }
  50% {
    transform: translateX(32%) skewX(-8deg);
  }
}

.pack-brand {
  position: absolute;
  z-index: 5;
  top: 11%;
  left: 7%;
  right: 7%;
  font-family: var(--display);
  font-size: 23cqi;
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.8;
  text-transform: uppercase;
  color: #fff4e4;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5),
    0 -1px 0 rgba(40, 10, 40, 0.5),
    0 0.08em 0.2em rgba(20, 4, 30, 0.55);
}

.pack-label {
  position: absolute;
  z-index: 5;
  left: 7%;
  right: 7%;
  bottom: 11%;
  padding: 4cqi 4.5cqi;
  border-top: 1px solid rgba(232, 196, 106, 0.8);
  background: linear-gradient(180deg, rgba(14, 8, 30, 0.72), rgba(14, 8, 30, 0.88));
  color: #fff4e4;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.pack-title {
  font-family: var(--display);
  font-size: 7cqi;
  font-stretch: 78%;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pack-subtitle {
  margin-top: 1.6cqi;
  color: rgba(255, 244, 228, 0.72);
  font-size: max(0.68rem, 3.5cqi);
  font-weight: 600;
  line-height: 1.3;
}

.pack-strip {
  --cut: 6px;
  position: absolute;
  z-index: 6;
  top: 21%;
  right: 5%;
  padding: 1.1cqi 2.2cqi;
  border: 0;
  background: #fff4e4;
  color: var(--print-ink);
  clip-path: var(--chamfer);
  font: 800 max(0.56rem, 2.9cqi)/1 var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  animation: stripNudge 3.8s var(--ease-in-out) 2.8s infinite;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.pack-strip::before {
  content: "\2190";
  margin-right: 0.35rem;
}

.pack-strip:hover,
.pack-stage.is-dragging .pack-strip {
  animation: none;
  background: var(--amber);
  transform: translateX(calc(var(--tear-progress) * -0.7rem));
}

.pack-stage.is-dragging .pack-strip {
  cursor: grabbing;
}

@keyframes stripNudge {
  0%,
  70%,
  100% {
    transform: translateX(0);
  }
  78% {
    transform: translateX(-0.45rem);
  }
  86% {
    transform: translateX(0.1rem);
  }
  92% {
    transform: translateX(-0.25rem);
  }
}

/* The seal: the crimped strip across the top, with the tear tab on it. It
   peels up from its left end as the tab is pulled, then flies off. */
.pack-rip {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  width: 100%;
  height: 8.2%;
  container-type: inline-size;
  pointer-events: none;
  background: var(--pack-print);
  clip-path: polygon(0% 15.85%, 2.27% 0%, 4.55% 15.85%, 6.82% 0%, 9.09% 15.85%, 11.36% 0%, 13.64% 15.85%, 15.91% 0%, 18.18% 15.85%, 20.45% 0%, 22.73% 15.85%, 25% 0%, 27.27% 15.85%, 29.55% 0%, 31.82% 15.85%, 34.09% 0%, 36.36% 15.85%, 38.64% 0%, 40.91% 15.85%, 43.18% 0%, 45.45% 15.85%, 47.73% 0%, 50% 15.85%, 52.27% 0%, 54.55% 15.85%, 56.82% 0%, 59.09% 15.85%, 61.36% 0%, 63.64% 15.85%, 65.91% 0%, 68.18% 15.85%, 70.45% 0%, 72.73% 15.85%, 75% 0%, 77.27% 15.85%, 79.55% 0%, 81.82% 15.85%, 84.09% 0%, 86.36% 15.85%, 88.64% 0%, 90.91% 15.85%, 93.18% 0%, 95.45% 15.85%, 97.73% 0%, 100% 15.85%, 100% 75.19%, 96.15% 90.64%, 92.31% 73.79%, 88.46% 92.11%, 84.62% 79.89%, 80.77% 90.03%, 76.92% 80.89%, 73.08% 93.02%, 69.23% 77.49%, 65.38% 97.72%, 61.54% 77.92%, 57.69% 91.54%, 53.85% 73.62%, 50% 96.69%, 46.15% 76.18%, 42.31% 90.41%, 38.46% 73.16%, 34.62% 93.34%, 30.77% 72.88%, 26.92% 93.97%, 23.08% 73.06%, 19.23% 92.76%, 15.38% 77.14%, 11.54% 90.25%, 7.69% 78.12%, 3.85% 90.92%, 0% 75.33%);
  transform-origin: 0% 90%;
  transform:
    translateY(calc(var(--tear-progress) * -0.35rem))
    rotate(calc(var(--tear-progress) * -7deg));
}

.pack-stage[data-stage="opened"] .pack-rip,
.pack-stage[data-stage="pack-exit"] .pack-rip,
.pack-stage[data-stage="revealed"] .pack-rip {
  transform: translate(-5rem, -6.5rem) rotate(-34deg);
  opacity: 0;
  transition:
    transform 900ms var(--ease-out) 140ms,
    opacity 600ms ease 420ms;
}

.pack-card-edge {
  position: absolute;
  z-index: 0;
  inset: 5rem 1.8rem 3rem;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(232, 196, 106, 0.4), transparent 40%),
    linear-gradient(160deg, #241c5c, #0d0a24);
  box-shadow: inset 0 0 0 2px rgba(232, 196, 106, 0.7);
  transform: translateY(calc(4.5rem - var(--tear-progress) * 4.9rem));
  opacity: calc(var(--tear-progress) * 0.95);
  transition:
    transform 760ms cubic-bezier(0.2, 0.9, 0.18, 1),
    opacity 300ms ease;
}

.pack-stage[data-stage="opened"] .pack-card-edge,
.pack-stage[data-stage="revealed"] .pack-card-edge {
  transform: translateY(-3.4rem);
  opacity: 1;
}

/* ---------- Actions ---------- */

.primary-action,
.secondary-action,
.case-link {
  --cut: 12px;
  position: relative;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  overflow: hidden;
  padding: 1rem 1.6rem;
  border: 0;
  background: linear-gradient(100deg, var(--amber), #ff6f61 52%, var(--hot));
  color: #1b0f22;
  clip-path: var(--chamfer);
  font: 800 0.92rem/1 var(--display);
  letter-spacing: 0.16em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 220ms var(--ease-out),
    filter 220ms ease;
}

.primary-action::after,
.secondary-action::after,
.case-link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 45%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 700ms var(--ease-out);
}

.primary-action:hover::after,
.secondary-action:hover::after,
.case-link:hover::after {
  transform: translateX(120%);
}

.primary-action:hover,
.secondary-action:hover,
.case-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.06) saturate(1.1);
}

.primary-action:active,
.secondary-action:active,
.case-link:active {
  transform: translateY(1px);
}

.action-icon {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  transition: transform 260ms var(--ease-out);
}

.primary-action:hover .action-icon {
  transform: translateX(0.3rem);
}

.primary-action {
  grid-area: cta;
  align-self: start;
  justify-self: start;
  margin-top: 2.2rem;
  opacity: 0;
}

body.intro-ready .primary-action {
  animation: riseIn 900ms var(--ease-out) 1450ms both;
}

body.intro-complete .primary-action {
  animation: none;
  opacity: 1;
}

.pack-stage:is([data-stage="tearing"], [data-stage="opened"], [data-stage="pack-exit"], [data-stage="revealed"]) .primary-action {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.6rem);
  transition:
    opacity 300ms ease,
    transform 300ms ease;
}

/* ---------- Profile card ---------- */

.profile-card {
  --profile-entry-y: 6rem;
  --profile-entry-tilt: 8deg;
  --profile-entry-scale: 0.82;
  --profile-scale: 1;
  --profile-rotate-x: 0deg;
  --profile-rotate-y: 0deg;
  --profile-rotate-z: var(--profile-entry-tilt);
  --foil-x: 50%;
  --foil-y: 28%;
  --holo-x: 50%;
  --holo-y: 50%;
  position: absolute;
  z-index: 4;
  width: min(32vw, 23.5rem, calc(66svh * 0.7));
  aspect-ratio: 0.7;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0;
  outline: 0;
  pointer-events: none;
  transform:
    translateY(var(--profile-entry-y))
    perspective(60rem)
    rotateX(var(--profile-rotate-x))
    rotateY(var(--profile-rotate-y))
    rotateZ(var(--profile-rotate-z))
    scale(calc(var(--profile-entry-scale) * var(--profile-scale)));
  transform-style: preserve-3d;
  transition: opacity 500ms ease;
  will-change: transform, opacity;
}

.pack-stage[data-stage="pack-exit"] .profile-card,
.pack-stage[data-stage="revealed"] .profile-card {
  --profile-entry-y: 0;
  --profile-entry-tilt: 0deg;
  --profile-entry-scale: 1;
  opacity: 1;
  pointer-events: auto;
  animation: cardRise 1400ms var(--ease-out) both;
}

@keyframes cardRise {
  0% {
    opacity: 0;
    translate: 0 40%;
    rotate: -16deg;
    scale: 0.55;
  }
  45% {
    opacity: 1;
    translate: 0 -7%;
    rotate: 4deg;
    scale: 1.08;
  }
  72% {
    translate: 0 1.5%;
    rotate: -1.4deg;
    scale: 0.985;
  }
  100% {
    opacity: 1;
    translate: 0 0;
    rotate: 0deg;
    scale: 1;
  }
}

body.profile-docked .pack-stage[data-stage="revealed"] .profile-card {
  --profile-entry-y: 0;
  --profile-entry-scale: 1;
  position: fixed;
  z-index: 1000;
  top: auto;
  bottom: clamp(-11rem, -15vw, -8.5rem);
  left: clamp(-6rem, -6.5vw, -4.25rem);
  width: min(72vw, 23rem);
  transform-origin: 18% 88%;
  transform: perspective(60rem) rotateX(0deg) rotateY(0deg) rotateZ(-47deg) scale(1);
  transition:
    opacity 500ms ease,
    bottom 820ms var(--ease-punch),
    left 820ms var(--ease-punch),
    transform 820ms var(--ease-punch);
}

body.profile-docked .pack-stage {
  z-index: 1000;
  pointer-events: none;
}

body.profile-docked .pack-stage[data-stage="revealed"] .profile-card {
  pointer-events: auto;
}

body.profile-docking .pack-stage[data-stage="revealed"] .profile-card {
  top: var(--dock-top);
  bottom: auto;
  left: var(--dock-left);
  width: var(--dock-width);
  transform: var(--dock-transform);
  transition:
    top 1000ms cubic-bezier(0.2, 0.9, 0.18, 1),
    left 1000ms cubic-bezier(0.2, 0.9, 0.18, 1),
    width 1000ms cubic-bezier(0.2, 0.9, 0.18, 1),
    transform 1000ms cubic-bezier(0.2, 0.9, 0.18, 1);
}

body.profile-docked.profile-corner-open .pack-stage[data-stage="revealed"] .profile-card,
body.profile-docked .pack-stage[data-stage="revealed"] .profile-card:hover {
  bottom: clamp(1rem, 3vw, 2rem);
  left: clamp(1rem, 2.4vw, 2rem);
  transform: perspective(60rem) rotateX(0deg) rotateY(0deg) rotateZ(-3deg) scale(1);
}

.profile-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 950ms var(--ease-punch);
}

.profile-card[data-flipped="true"] .profile-card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #0b0a1c;
  box-shadow:
    0 2.2rem 3.2rem rgba(3, 2, 12, 0.55),
    inset 0 0 0 1px rgba(255, 244, 228, 0.18);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.card-front {
  transform: rotateY(180deg);
}

.card-paint {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.is-unpainted {
  background:
    radial-gradient(60% 45% at 50% 42%, rgba(255, 210, 122, 0.55), transparent 70%),
    linear-gradient(160deg, #2d1b6b, #0b0a24);
}

/* Card back: a printed plate, an ink frame and "GDC". */
.card-back-sigil {
  position: absolute;
  inset: 0;
  color: #e8c46a;
}

.card-back-sigil svg {
  width: 100%;
  height: 100%;
}

.card-back-sigil .back-frame {
  fill: none;
  stroke: #e8c46a;
  stroke-width: 1.4;
  opacity: 0.9;
}

.card-back-sigil .back-frame--inner {
  opacity: 0.4;
}

.card-back .card-foil {
  opacity: 0.35;
}

.card-back-frame {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.back-code {
  position: relative;
  z-index: 2;
  margin-top: -6%;
  font-family: var(--display);
  font-size: clamp(3.4rem, 13vw, 5.6rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: 0.18em;
  color: #fff4e4;
  text-indent: 0.18em;
  text-shadow: 0 0.06em 0.3em rgba(10, 6, 30, 0.8);
}

.back-title {
  --cut: 7px;
  position: absolute;
  bottom: 13%;
  left: 50%;
  z-index: 2;
  padding: 0.5rem 0.8rem;
  background: #e8c46a;
  color: #120f2a;
  clip-path: var(--chamfer);
  font: 800 0.72rem/1 var(--display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  translate: -50% 0;
  animation: revealPulse 2.4s ease-in-out infinite;
}

@keyframes revealPulse {
  0%,
  100% {
    scale: 1;
    filter: brightness(1);
  }
  50% {
    scale: 1.06;
    filter: brightness(1.15);
  }
}

/* Card front: full-art portrait with a name plate. */
.card-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: inherit;
  color: #fff4e4;
}

.card-frame::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 3;
  border: 1px solid rgba(255, 244, 228, 0.45);
  border-radius: 8px;
  pointer-events: none;
}

.portrait-window {
  position: absolute;
  inset: 0;
}

.portrait-window::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 5, 22, 0.5), transparent 20%, transparent 46%, rgba(8, 5, 22, 0.94) 80%);
}

.portrait-mark {
  position: absolute;
  z-index: 1;
  top: 21%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(4.6rem, 18vw, 8.4rem);
  font-stretch: 70%;
  font-weight: 900;
  line-height: 0.8;
  color: #fff4e4;
  mix-blend-mode: overlay;
  opacity: 0.95;
}

.card-meta,
.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  font: 700 0.7rem/1 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card-meta {
  position: absolute;
  z-index: 2;
  top: 1.1rem;
  left: 1.2rem;
  right: 1.2rem;
  color: rgba(255, 244, 228, 0.82);
}

.card-meta-rarity {
  --cut: 5px;
  padding: 0.3rem 0.5rem;
  background: #e8c46a;
  color: #120f2a;
  clip-path: var(--chamfer);
}

.profile-text {
  position: absolute;
  z-index: 2;
  left: 1.3rem;
  right: 1.3rem;
  bottom: 1.3rem;
}

.profile-name {
  margin-bottom: 0.5rem;
  color: #e8c46a;
  font: 700 0.78rem/1 var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.profile-role {
  margin-bottom: 0.6rem;
  font-family: var(--display);
  font-size: clamp(1.4rem, 5.4vw, 2.1rem);
  font-stretch: 68%;
  font-weight: 900;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 0.08em 0.3em rgba(8, 5, 22, 0.6);
}

.profile-text .profile-tools,
.profile-text .tagline {
  display: inline-block;
  margin: 0 0.8rem 0 0;
  color: rgba(255, 244, 228, 0.74);
  font-size: 0.82rem;
  font-weight: 600;
}

.profile-text .tagline {
  color: #fff4e4;
}

.card-front .card-foil,
.foil-stars,
.foil-beam {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.card-front .card-foil {
  z-index: 3;
  background:
    radial-gradient(circle at var(--foil-x) var(--foil-y), rgba(255, 255, 255, 0.55), transparent 16%),
    radial-gradient(circle at calc(100% - var(--foil-x)) calc(100% - var(--foil-y)), rgba(79, 214, 255, 0.22), transparent 31%),
    linear-gradient(115deg, rgba(255, 61, 127, 0.16), rgba(255, 179, 92, 0.18), rgba(25, 198, 182, 0.18), rgba(79, 214, 255, 0.18), rgba(146, 105, 255, 0.16)),
    repeating-linear-gradient(72deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 10px);
  background-position:
    center,
    center,
    var(--holo-x) var(--holo-y),
    center;
  background-size:
    100% 100%,
    100% 100%,
    180% 180%,
    100% 100%;
  mix-blend-mode: color-dodge;
  opacity: 0.28;
  transform: none;
  animation: holoHue 6.4s linear infinite;
}

.foil-stars {
  z-index: 4;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.96), rgba(79, 214, 255, 0.7), rgba(255, 179, 92, 0.86), rgba(255, 61, 127, 0.7));
  mix-blend-mode: screen;
  opacity: 0.6;
  -webkit-mask-image:
    url("../assets/shader/dotsImageBlackbgBig.jpg"),
    url("../assets/shader/lightbeamTiltRepeat.jpg");
  mask-image:
    url("../assets/shader/dotsImageBlackbgBig.jpg"),
    url("../assets/shader/lightbeamTiltRepeat.jpg");
  -webkit-mask-mode: luminance, luminance;
  mask-mode: luminance, luminance;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
  -webkit-mask-size: auto 100%, 82% 82%;
  mask-size: auto 100%, 82% 82%;
  -webkit-mask-position: center, -90% 50%;
  mask-position: center, -90% 50%;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  animation:
    starBeamSweep 3.8s linear infinite,
    starTwinkle 3s ease-in-out infinite;
}

.foil-beam {
  display: none;
}

.card-glare {
  position: absolute;
  inset: -18%;
  z-index: 6;
  border-radius: inherit;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 28%), rgba(255, 255, 255, 0.42), transparent 34%);
  mix-blend-mode: screen;
  opacity: 0.42;
  pointer-events: none;
}

@keyframes holoHue {
  to {
    filter: hue-rotate(360deg);
  }
}

@keyframes starTwinkle {
  0%,
  100% {
    opacity: 0.4;
    filter: brightness(0.9);
  }
  45% {
    opacity: 0.85;
    filter: brightness(1.35);
  }
  70% {
    opacity: 0.6;
    filter: brightness(1.08);
  }
}

@keyframes starBeamSweep {
  0% {
    -webkit-mask-position: center, -90% 50%;
    mask-position: center, -90% 50%;
  }
  100% {
    -webkit-mask-position: center, 190% 50%;
    mask-position: center, 190% 50%;
  }
}

/* Flip burst, all of it behind the card (the card and this layer share a 3D
   space): printed paper — chips, strips, halftone dots and registration
   marks with ink edges and hard shadows — a vermilion starburst, an ink
   shock ring and comic speed lines. */
.flip-particles {
  position: absolute;
  /* The burst needs its own stage, well beyond the card's edges. */
  inset: -55% -90%;
  z-index: 12;
  overflow: visible;
  pointer-events: none;
  transform-style: preserve-3d;
  contain: layout style;
}

.flip-particles::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(36%, 12.5rem);
  aspect-ratio: 1;
  border: 4px solid var(--ink);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) translateZ(-4rem) scale(0.1);
}

.flip-particles::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: min(62%, 30rem);
  aspect-ratio: 1;
  background:
    radial-gradient(circle, rgba(22, 18, 14, 0.3) 32%, transparent 36%) 0 0 / 9px 9px,
    var(--hot);
  clip-path: polygon(50% 0%, 56.9% 19.8%, 71.7% 5%, 72.4% 21.9%, 89.1% 18.8%, 77.9% 36.5%, 98.7% 38.9%, 86% 50%, 98.7% 61.1%, 77.9% 63.5%, 89.1% 81.2%, 72.4% 78.1%, 71.7% 95%, 56.9% 80.2%, 50% 100%, 42% 85.1%, 28.3% 95%, 30.7% 74.2%, 10.9% 81.2%, 17.6% 65.6%, 1.3% 61.1%, 19% 50%, 1.3% 38.9%, 17.6% 34.4%, 10.9% 18.8%, 30.7% 25.8%, 28.3% 5%, 42% 14.9%);
  opacity: 0;
  transform: translate(-50%, -50%) translateZ(-6rem) scale(0.1) rotate(-14deg);
}

.flip-particles.is-bursting::before {
  animation: burstRing 760ms var(--ease-out) forwards;
}

.flip-particles.is-bursting::after {
  animation: burstStar 720ms var(--ease-out) forwards;
}

.flip-particles span {
  --edge: #16120e;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: calc(var(--size) * 0.64);
  border: 2px solid var(--edge);
  background: var(--ink-color);
  box-shadow: 2px 2px 0 var(--edge);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.3);
  animation: paperBurst 1500ms var(--delay) forwards;
  will-change: transform, opacity;
}

.flip-particles span[data-kind="strip"] {
  width: calc(var(--size) * 2.2);
  height: calc(var(--size) * 0.46);
}

.flip-particles span[data-kind="dot"] {
  height: var(--size);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(22, 18, 14, 0.35) 30%, transparent 34%) 0 0 / 5px 5px,
    var(--ink-color);
}

.flip-particles span[data-kind="mark"] {
  height: var(--size);
  border: 0;
  background:
    linear-gradient(var(--ink), var(--ink)) center / 100% 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 2px 100% no-repeat,
    radial-gradient(circle, transparent 0 32%, var(--ink) 34% 45%, transparent 47%);
  box-shadow: none;
}

.flip-particles span[data-kind="line"] {
  width: 3px;
  height: var(--size);
  border: 0;
  background: var(--ink);
  box-shadow: none;
  animation: speedLine 560ms var(--delay) forwards;
}

@keyframes burstRing {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(-4rem) scale(0.1);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(-4rem) scale(3.1);
    border-width: 1px;
  }
}

/* The starburst sits behind the card: both share the card's 3D space. */
@keyframes burstStar {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(-6rem) scale(0.1) rotate(-14deg);
  }
  14% {
    opacity: 1;
    transform: translate(-50%, -50%) translateZ(-6rem) scale(1.25) rotate(0deg);
  }
  34% {
    transform: translate(-50%, -50%) translateZ(-6rem) scale(1.1) rotate(3deg);
  }
  62% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(-6rem) scale(1.4) rotate(8deg);
  }
}

/* Out fast, then paper falls and flutters. */
@keyframes paperBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(var(--z)) scale(0.3) rotate(0deg) rotateX(0deg);
    animation-timing-function: cubic-bezier(0.1, 0.8, 0.25, 1);
  }
  8% {
    opacity: 1;
  }
  32% {
    transform:
      translate(calc(-50% + var(--x) * 0.8), calc(-50% + var(--y) * 0.8))
      translateZ(var(--z))
      scale(1)
      rotate(calc(var(--spin) * 0.4))
      rotateX(calc(var(--flip) * 0.3));
    animation-timing-function: cubic-bezier(0.4, 0, 0.8, 0.6);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--x)), calc(-50% + var(--y) + var(--fall)))
      translateZ(var(--z))
      scale(0.9)
      rotate(var(--spin))
      rotateX(var(--flip));
  }
}

@keyframes speedLine {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(var(--z)) rotate(var(--angle)) translateY(-2.5rem) scaleY(0.2);
    animation-timing-function: cubic-bezier(0.1, 0.8, 0.25, 1);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(var(--z)) rotate(var(--angle)) translateY(calc(var(--reach) * -1)) scaleY(1);
  }
}

/* ---------- Binder peek ---------- */

.binder-peek {
  position: fixed;
  z-index: 8;
  left: 0;
  bottom: 9vh;
  display: grid;
  grid-template-columns: 2.6rem 16.5rem;
  min-height: 16rem;
  filter: drop-shadow(0 1.6rem 2rem rgba(3, 2, 12, 0.45));
  transform: translateX(-108%);
  transition: transform 1000ms var(--ease-punch) 450ms;
}

.pack-stage[data-stage="revealed"] .binder-peek {
  transform: translateX(0);
}

body.binder-open .pack-stage[data-stage="revealed"] .binder-peek {
  transform: translateX(-108%);
  pointer-events: none;
  transition-delay: 0ms;
}

.binder-spine {
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--hot), #b8205a);
  color: #fff4e4;
  font: 800 0.8rem/1 var(--display);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

:root[lang^="zh"] .binder-spine {
  transform: none;
  letter-spacing: 0.4em;
}

.binder-cover {
  --cut: 16px;
  position: relative;
  padding: 1.4rem 1.4rem 1.3rem;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(232, 196, 106, 0.12), transparent 42%),
    var(--glass-strong);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.binder-cover::before {
  content: "";
  position: absolute;
  inset: 0.55rem;
  border: 1px solid rgba(232, 196, 106, 0.45);
  pointer-events: none;
}

.binder-cover p {
  margin-bottom: 0.9rem;
  color: var(--gold);
  font: 700 0.72rem/1 var(--display);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.binder-hover-hint {
  display: none;
}

.binder-cover h2 {
  min-height: 5.6rem;
  margin-bottom: 0.4rem;
  font-family: var(--display);
  font-size: 2.6rem;
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.86;
  text-transform: uppercase;
}

/* ---------- Binder: an open spread with sleeves ---------- */

.binder-stage {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.9rem;
  width: 100%;
  height: 100svh;
  min-height: 0;
  padding:
    clamp(1rem, 3svh, 1.8rem)
    clamp(1rem, 4vw, 4rem)
    clamp(1rem, 3.4svh, 2rem);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(6, 5, 20, 0.2), rgba(6, 5, 20, 0.5));
}

:root[data-theme="light"] .binder-stage {
  background: linear-gradient(180deg, rgba(243, 234, 223, 0.15), rgba(243, 234, 223, 0.4));
}

body.binder-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.binder-open .binder-layout {
  animation: spreadIn 1100ms var(--ease-out) both;
}

body.binder-open .binder-tabs {
  animation: riseIn 800ms var(--ease-out) 200ms both;
}

@keyframes spreadIn {
  from {
    opacity: 0;
    transform: translateY(3rem) perspective(80rem) rotateX(8deg) scale(0.97);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

body.binder-open .pack-stage .stage-copy,
body.binder-open .pack-stage .pack-zone,
body.binder-open .pack-stage .primary-action,
body.binder-open .pack-stage .binder-peek,
body.binder-open .pack-stage .stage-sigil {
  visibility: hidden;
  opacity: 0;
}

body.profile-docked .binder-stage {
  padding-left: clamp(1rem, 4vw, 4rem);
}

body:not(.binder-open) .binder-stage {
  display: none;
}

.binder-tabs {
  position: relative;
  z-index: 6;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  width: calc(100% - 12.5rem);
  max-width: 88rem;
  padding: 0.2rem 0;
  scrollbar-width: none;
}

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

.tab-button,
.icon-button,
.dialog-close {
  --cut: 9px;
  border: 0;
  background: var(--glass);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  clip-path: var(--chamfer);
  cursor: pointer;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition:
    background 260ms ease,
    color 260ms ease;
}

.tab-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.72rem 1.05rem;
  color: var(--muted);
  font: 700 0.76rem/1 var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tab-index {
  color: var(--gold);
  font-size: 0.66rem;
}

.tab-button:hover {
  color: var(--ink);
  background: var(--glass-strong);
}

.tab-button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.tab-button[aria-pressed="true"] .tab-index {
  color: var(--hot);
}

.binder-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 21rem) minmax(0, 1fr);
  gap: 0.55rem;
  width: 100%;
  max-width: 88rem;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  padding: 0.8rem;
  border-radius: 22px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 1.5px) 0 0 / 5px 5px,
    linear-gradient(150deg, rgba(35, 28, 86, 0.9), color-mix(in srgb, var(--cover) 88%, transparent) 55%, rgba(7, 6, 26, 0.94));
  box-shadow:
    0 2.6rem 5rem rgba(3, 2, 12, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 2px 0 rgba(255, 255, 255, 0.08);
}

/* Pages are tinted film: the painting keeps glowing through them. */
.binder-left,
.binder-page-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 1.4px) 0 0 / 4px 4px,
    linear-gradient(180deg, color-mix(in srgb, var(--page-2) 78%, transparent), color-mix(in srgb, var(--page) 88%, transparent));
}

:root[data-theme="light"] :is(.binder-left, .binder-page-wrap) {
  background:
    radial-gradient(circle at 1px 1px, rgba(60, 40, 20, 0.05) 1px, transparent 1.4px) 0 0 / 4px 4px,
    linear-gradient(180deg, color-mix(in srgb, var(--page) 86%, transparent), color-mix(in srgb, var(--page-2) 92%, transparent));
}

.binder-left {
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(1.4rem, 3vw, 2.6rem) clamp(1.3rem, 2.6vw, 2.2rem);
  overflow: hidden;
  border-radius: 14px 5px 5px 14px;
  box-shadow: inset -2.2rem 0 2.4rem -2.2rem rgba(0, 0, 0, 0.55);
}

.section-number {
  position: absolute;
  z-index: -1;
  right: -0.4rem;
  bottom: -1.2rem;
  font-family: var(--display);
  font-size: clamp(9rem, 16vw, 15rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.8;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--section-color, var(--gold));
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}

.binder-left h2 {
  margin-bottom: 1rem;
  font-family: var(--display);
  font-size: clamp(2.3rem, 4vw, 3.9rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.86;
  text-transform: uppercase;
  overflow-wrap: break-word;
}

.binder-left h2::after {
  content: "";
  display: block;
  width: 3.4rem;
  height: 3px;
  margin-top: 1rem;
  background: var(--section-color, var(--hot));
  transform: skewX(-30deg);
  transform-origin: left;
}

.binder-left p:not(.binder-label) {
  max-width: 17rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.65;
}

.binder-left.is-changing h2 {
  animation: revealUp 900ms var(--ease-out) both;
}

.binder-left.is-changing p:not(.binder-label),
.binder-left.is-changing .section-number {
  animation: riseIn 800ms var(--ease-out) 120ms both;
}

.binder-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.9rem;
  aspect-ratio: 1;
}

.icon-button svg,
.dialog-close svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
}

.icon-button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--bg);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.page-indicator {
  min-width: 3.6rem;
  color: var(--ink);
  text-align: center;
  font: 700 0.9rem/1 var(--display);
  letter-spacing: 0.16em;
}

.binder-page-wrap {
  z-index: 0;
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: 5px 14px 14px 5px;
  box-shadow: inset 2.2rem 0 2.4rem -2.2rem rgba(0, 0, 0, 0.55);
  container-type: size;
}

.binder-sheet {
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* Metal rings bridge the spine between the two pages. */
.binder-rings {
  position: absolute;
  z-index: 8;
  top: 14%;
  bottom: 14%;
  left: -2.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.binder-rings span {
  width: 3.8rem;
  height: 1.05rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #fbf8ff, #a8a3bb 42%, #f2eff8 58%, #6f6a84);
  box-shadow:
    0 0.35rem 0.6rem rgba(0, 0, 0, 0.5),
    inset 0 1px 0 #fff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.binder-page {
  --page-pad: clamp(1rem, 4cqh, 2.4rem);
  --page-pad-x: calc(var(--page-pad) + 1.2rem);
  --page-gap: clamp(1rem, 3cqw, 2.4rem);
  /* Card size follows the layout (not the number of cards on this page), so
     every page of the binder keeps the same sleeve size. */
  --card-w: min(
    22rem,
    calc((100cqh - 2 * var(--page-pad) - (var(--layout-rows, 1) - 1) * var(--page-gap) - 1.4rem) / var(--layout-rows, 1) * 63 / 88),
    calc((100cqw - 2 * var(--page-pad-x) - (var(--layout-columns, 3) - 1) * var(--page-gap)) / var(--layout-columns, 3))
  );
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--binder-columns, 3), var(--card-w));
  justify-content: center;
  align-content: center;
  gap: var(--page-gap);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: var(--page-pad) var(--page-pad-x);
  overflow: hidden;
  background:
    radial-gradient(55% 60% at 50% 55%, color-mix(in srgb, var(--section-color, var(--hot)) 16%, transparent), transparent 72%),
    linear-gradient(118deg, transparent 30%, rgba(255, 244, 228, 0.045) 42%, transparent 54%);
  cursor: pointer;
  touch-action: pan-y;
  transform-origin: left center;
}

.binder-page::before,
.binder-page::after {
  content: "";
  position: absolute;
  top: 50%;
  z-index: 9;
  width: 1rem;
  height: 1rem;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.binder-page:hover::before,
.binder-page:hover::after {
  opacity: 0.6;
}

.binder-page::before {
  left: 1rem;
  transform: translateY(-50%) rotate(-135deg);
}

.binder-page::after {
  right: 1rem;
  transform: translateY(-50%) rotate(45deg);
}

.binder-page.is-turning {
  animation: pageTurn 820ms var(--ease-out);
}

.binder-page.is-turning[data-turn="prev"] {
  animation-name: pageTurnBack;
}

@keyframes pageTurn {
  0% {
    transform: perspective(70rem) rotateY(-14deg) translateX(-1rem);
    filter: brightness(0.7);
  }
  100% {
    transform: none;
    filter: brightness(1);
  }
}

@keyframes pageTurnBack {
  0% {
    transform: perspective(70rem) rotateY(10deg) translateX(1rem);
    filter: brightness(0.7);
  }
  100% {
    transform: none;
    filter: brightness(1);
  }
}

/* A clear plastic sleeve: back film, lip line and a glossy front sheet. */
.pocket {
  position: relative;
  width: var(--card-w);
  aspect-ratio: 63 / 88;
}

.pocket::before,
.pocket::after {
  content: "";
  position: absolute;
  inset: -7px -7px -9px;
  border-radius: 15px;
  pointer-events: none;
}

.pocket::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 1.15rem 0 -1.08rem rgba(255, 255, 255, 0.3);
}

.pocket::after {
  z-index: 3;
  background:
    linear-gradient(118deg, transparent 16%, rgba(255, 255, 255, 0.16) 23%, transparent 31%, transparent 64%, rgba(255, 255, 255, 0.07) 71%, transparent 78%);
}

:root[data-theme="light"] .pocket::before {
  background: linear-gradient(180deg, rgba(40, 30, 60, 0.05), rgba(40, 30, 60, 0.02));
  box-shadow:
    inset 0 0 0 1px rgba(40, 30, 60, 0.14),
    inset 0 1.15rem 0 -1.08rem rgba(255, 255, 255, 0.9);
}

.pocket.is-empty::before {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 10px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
}

/* ---------- Project cards (full art) ---------- */

.binder-card {
  --mx: 50%;
  --my: 40%;
  --card-tilt-x: 0deg;
  --card-tilt-y: 0deg;
  --rest-tilt: 0deg;
  --deal-x: 0%;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0.95rem 0.95rem 0.9rem;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff5e8;
  text-align: left;
  container-type: inline-size;
  cursor: pointer;
  box-shadow: 0 0.9rem 1.6rem rgba(3, 2, 12, 0.45);
  transform: rotate(var(--rest-tilt));
  animation: cardSlide 950ms var(--ease-out) backwards;
  animation-delay: var(--stagger, 0ms);
  transition:
    transform 360ms var(--ease-out),
    box-shadow 360ms ease;
}

.binder-page[data-turn="next"] .binder-card {
  --deal-x: 26%;
}

.binder-page[data-turn="prev"] .binder-card {
  --deal-x: -26%;
}

.binder-page.is-quiet .binder-card {
  animation: none;
}

.binder-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(180deg, rgba(6, 4, 18, 0.62) 0, transparent 22%, transparent 44%, rgba(6, 4, 18, 0.9) 80%);
  pointer-events: none;
}

.binder-card::after {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: 6;
  border: 1px solid rgba(255, 244, 228, 0.42);
  border-radius: 7px;
  pointer-events: none;
}

.binder-card:hover {
  z-index: 2;
  transform:
    perspective(42rem)
    translateY(-0.7rem)
    rotateX(var(--card-tilt-x))
    rotateY(var(--card-tilt-y));
  box-shadow: 0 1.8rem 2.6rem rgba(3, 2, 12, 0.55);
}

.binder-card:active {
  transform: scale(0.985);
}

@keyframes cardSlide {
  0% {
    opacity: 0;
    transform: translate(var(--deal-x), -34%) rotate(-5deg);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: rotate(var(--rest-tilt));
  }
}

.card-art {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.card-art > * {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-topline {
  position: relative;
  z-index: 5;
  min-width: 0;
  color: rgba(255, 245, 232, 0.86);
  font-size: clamp(0.54rem, 3.8cqi, 0.7rem);
}

.card-topline > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-copy {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 0.35rem;
  margin-top: auto;
}

.card-copy strong {
  font-family: var(--display);
  font-size: clamp(1.05rem, 11.5cqi, 2.1rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.88;
  text-transform: uppercase;
  text-shadow: 0 0.06em 0.3em rgba(6, 4, 18, 0.6);
  overflow-wrap: anywhere;
}

.card-copy span {
  color: color-mix(in srgb, var(--accent) 70%, #fff);
  font-size: clamp(0.66rem, 4.6cqi, 0.86rem);
  font-weight: 700;
  line-height: 1.2;
}

.tag-row,
.detail-tags {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag-row {
  margin-top: 0.7rem;
}

.tag-row span,
.detail-tags span {
  padding: 0.24rem 0.42rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: clamp(0.56rem, 3.9cqi, 0.68rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.tag-row span {
  color: rgba(255, 245, 232, 0.8);
  background: rgba(10, 8, 24, 0.3);
}

/* ===== Rarity foil system (MTG-style, escalating per tier) ===== */

.rarity-edge,
.rarity-foil,
.rarity-sparkle,
.rarity-glare {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

/* Balatro-style edition shader over the full art (screen: black is a no-op). */
.rarity-shader {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: screen;
}

.rarity-uncommon .rarity-shader {
  opacity: 0.22;
}

.rarity-rare .rarity-shader,
.rarity-mythic .rarity-shader {
  opacity: 0.34;
}

.binder-card[data-edition="polychrome"] .rarity-shader {
  opacity: 0.2;
}

.binder-card[data-edition="laser"] .rarity-shader {
  opacity: 0.28;
}

.rarity-edge {
  z-index: 7;
  padding: 2px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  background: linear-gradient(115deg, transparent 0 36%, rgba(255, 255, 255, 0.85) 50%, transparent 64% 100%);
  background-size: 320% 320%, 100% 100%;
  background-position: 200% 200%, center;
  animation: edgeGlint 6s ease-in-out infinite;
}

@keyframes edgeGlint {
  0% {
    background-position: 200% 200%, center;
  }
  45%,
  100% {
    background-position: -120% -120%, center;
  }
}

.rarity-common .rarity-edge {
  opacity: 0.55;
}

.rarity-uncommon .rarity-edge {
  opacity: 0.95;
  background:
    linear-gradient(115deg, transparent 0 32%, rgba(235, 245, 255, 0.95) 50%, transparent 68% 100%),
    linear-gradient(160deg, rgba(168, 186, 204, 0.5), rgba(228, 238, 248, 0.2), rgba(168, 186, 204, 0.5));
  animation-duration: 4.4s;
}

.rarity-uncommon .rarity-foil {
  opacity: 0.4;
  mix-blend-mode: screen;
  background: linear-gradient(120deg, transparent 28%, rgba(178, 198, 219, 0.2) 42%, rgba(255, 255, 255, 0.3) 50%, rgba(178, 198, 219, 0.2) 58%, transparent 72%);
  background-size: 260% 260%;
  background-position: var(--mx) var(--my);
  animation: sheenDrift 6.5s ease-in-out infinite;
}

@keyframes sheenDrift {
  0%,
  100% {
    filter: brightness(0.9);
  }
  50% {
    filter: brightness(1.25);
  }
}

.rarity-rare .rarity-edge {
  opacity: 1;
  background:
    linear-gradient(115deg, transparent 0 30%, rgba(255, 244, 200, 0.95) 50%, transparent 70% 100%),
    linear-gradient(160deg, rgba(232, 196, 106, 0.85), rgba(255, 228, 160, 0.3), rgba(232, 196, 106, 0.85));
  animation-duration: 3.4s;
}

.rarity-rare .rarity-foil,
.rarity-mythic .rarity-foil {
  mix-blend-mode: color-dodge;
  background:
    radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.42), transparent 38%),
    linear-gradient(115deg, rgba(255, 61, 127, 0.24), rgba(255, 179, 92, 0.24), rgba(25, 198, 182, 0.24), rgba(79, 214, 255, 0.24), rgba(146, 105, 255, 0.24)),
    repeating-linear-gradient(72deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 9px);
  background-size: 100% 100%, 240% 240%, 100% 100%;
  background-position: center, var(--mx) var(--my), center;
  animation: holoHue 7s linear infinite;
}

.rarity-rare .rarity-foil {
  opacity: 0.14;
}

.rarity-rare .rarity-glare,
.rarity-mythic .rarity-glare {
  z-index: 7;
  mix-blend-mode: screen;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.42), transparent 36%);
  transition: opacity 240ms ease;
}

.rarity-rare:hover .rarity-glare {
  opacity: 0.6;
}

.rarity-mythic .rarity-edge {
  padding: 2.5px;
  opacity: 1;
  background:
    linear-gradient(115deg, transparent 0 28%, rgba(255, 255, 255, 0.95) 50%, transparent 72% 100%),
    conic-gradient(from 20deg, #ff3d7f, #ffb35c, #e8c46a, #9269ff, #ff3d7f);
  animation:
    edgeGlint 2.6s ease-in-out infinite,
    mythicEdgeShift 5.5s linear infinite;
}

@keyframes mythicEdgeShift {
  to {
    filter: hue-rotate(360deg);
  }
}

.rarity-mythic .rarity-foil {
  opacity: 0.18;
  animation-duration: 4.5s;
}

.rarity-mythic .rarity-sparkle {
  z-index: 3;
  opacity: 0.6;
  mix-blend-mode: screen;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.96), rgba(79, 214, 255, 0.72), rgba(255, 179, 92, 0.88), rgba(255, 61, 127, 0.72));
  -webkit-mask-image:
    url("../assets/shader/dotsImageBlackbgBig.jpg"),
    url("../assets/shader/lightbeamTiltRepeat.jpg");
  mask-image:
    url("../assets/shader/dotsImageBlackbgBig.jpg"),
    url("../assets/shader/lightbeamTiltRepeat.jpg");
  -webkit-mask-mode: luminance, luminance;
  mask-mode: luminance, luminance;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
  -webkit-mask-size: auto 50%, 120% 120%;
  mask-size: auto 50%, 120% 120%;
  -webkit-mask-position: center, -90% 50%;
  mask-position: center, -90% 50%;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  animation:
    starBeamSweep 3.4s linear infinite,
    starTwinkle 2.8s ease-in-out infinite;
}

.rarity-mythic:hover .rarity-glare {
  opacity: 0.75;
}

.rarity-label {
  --cut: 4px;
  flex: none;
  padding: 0.24rem 0.4rem;
  background: rgba(10, 8, 24, 0.55);
  color: rgba(255, 245, 232, 0.86);
  clip-path: var(--chamfer);
}

.rarity-uncommon .rarity-label {
  background: #cdd8e4;
  color: #141226;
}

.rarity-rare .rarity-label {
  background: #e8c46a;
  color: #141226;
}

.rarity-mythic .rarity-label {
  background: linear-gradient(100deg, #ffb35c, #ff6f61, #ff3d7f);
  color: #141226;
}

.accent-mint {
  --accent: var(--mint);
}

.accent-gold {
  --accent: var(--amber);
}

.accent-violet {
  --accent: var(--violet);
}

.accent-red {
  --accent: var(--hot);
}

.accent-blue {
  --accent: var(--blue);
}

.accent-green {
  --accent: var(--green);
}

.accent-mono {
  --accent: #b9b4c8;
}

/* ---------- Detail dialog: a two-page spread ---------- */

.card-dialog {
  --detail-backdrop-bg: rgba(5, 3, 16, 0.62);
  --detail-backdrop-filter: blur(10px);
  width: min(94vw, 62rem);
  max-height: min(90svh, 46rem);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: var(--page);
  color: var(--ink);
  box-shadow:
    0 3rem 6rem rgba(3, 2, 12, 0.6),
    inset 0 0 0 1px var(--line);
  transform-origin: center center;
}

:root[data-theme="light"] .card-dialog {
  --detail-backdrop-bg: rgba(243, 234, 223, 0.6);
  --detail-backdrop-filter: blur(10px) saturate(0.96);
}

.card-dialog::backdrop {
  background: var(--detail-backdrop-bg);
  -webkit-backdrop-filter: var(--detail-backdrop-filter);
  backdrop-filter: var(--detail-backdrop-filter);
}

.card-dialog.is-detail-entering::backdrop {
  animation: detailBackdropIn 560ms cubic-bezier(0.2, 0.9, 0.18, 1) both;
}

.card-dialog.is-detail-closing::backdrop {
  animation: detailBackdropOut 440ms cubic-bezier(0.45, 0, 0.22, 1) both;
}

@keyframes detailBackdropIn {
  from {
    background: rgba(0, 0, 0, 0);
    -webkit-backdrop-filter: blur(0);
    backdrop-filter: blur(0);
  }
  to {
    background: var(--detail-backdrop-bg);
    -webkit-backdrop-filter: var(--detail-backdrop-filter);
    backdrop-filter: var(--detail-backdrop-filter);
  }
}

@keyframes detailBackdropOut {
  from {
    background: var(--detail-backdrop-bg);
    -webkit-backdrop-filter: var(--detail-backdrop-filter);
    backdrop-filter: var(--detail-backdrop-filter);
  }
  to {
    background: rgba(0, 0, 0, 0);
    -webkit-backdrop-filter: blur(0);
    backdrop-filter: blur(0);
  }
}

.dialog-close {
  position: absolute;
  z-index: 4;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 2.6rem;
  aspect-ratio: 1;
}

.dialog-close:hover {
  background: var(--ink);
  color: var(--bg);
}

.dialog-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  min-height: min(80svh, 36rem);
  max-height: inherit;
}

.detail-hero {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: clamp(1.3rem, 3vw, 2.2rem);
  background: var(--accent);
  color: #fff5e8;
}

.detail-hero-art,
.detail-hero-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.detail-hero-art > * {
  display: block;
  width: 100%;
  height: 100%;
}

.detail-hero-image {
  object-fit: cover;
  object-position: center;
}

.detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 4, 18, 0.1) 30%, rgba(6, 4, 18, 0.88));
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 2;
  border: 1px solid rgba(255, 244, 228, 0.4);
  border-radius: 10px;
  pointer-events: none;
}

.detail-foil {
  z-index: 1;
  opacity: 0.26;
}

.detail-hero.rarity-common .detail-foil {
  opacity: 0.14;
}

.detail-hero.rarity-uncommon .detail-foil {
  opacity: 0.28;
}

.detail-hero.rarity-mythic .detail-foil {
  opacity: 0.6;
  animation-duration: 3s;
}

.detail-heading {
  position: relative;
  z-index: 3;
}

.detail-heading p {
  margin-bottom: 0.9rem;
  color: #e8c46a;
  font: 700 0.72rem/1.3 var(--display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.detail-heading h2 {
  margin-bottom: 0.6rem;
  font-family: var(--display);
  font-size: clamp(2.6rem, 6.4vw, 5.2rem);
  font-stretch: 62%;
  font-weight: 900;
  line-height: 0.84;
  text-transform: uppercase;
  text-shadow: 0 0.06em 0.3em rgba(6, 4, 18, 0.6);
}

.detail-heading span {
  color: color-mix(in srgb, var(--accent) 70%, #fff);
  font-weight: 800;
}

.detail-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 4.6rem clamp(1.4rem, 3.4vw, 3rem) clamp(1.4rem, 3vw, 2.4rem);
}

.detail-body p {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.detail-body p:first-child {
  color: var(--ink);
  font-size: 1.08rem;
}

.detail-tags {
  margin: 0.6rem 0 1.8rem;
}

.detail-tags span {
  color: var(--accent);
}

:root[data-theme="light"] .detail-tags span {
  color: color-mix(in srgb, var(--accent) 70%, #000);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.2rem;
  margin-top: auto;
}

.detail-actions .case-link {
  align-self: flex-start;
}

.case-link.disabled {
  background: transparent;
  color: var(--faint);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  pointer-events: none;
}

/* ---------- Language ---------- */

:root[lang^="zh"] h1 {
  max-width: 4.3em;
  font-size: clamp(3rem, 6.6vw, 7rem);
  line-height: 1.04;
  letter-spacing: 0.02em;
}

:root[lang^="zh"] :is(.binder-left h2, .binder-cover h2, .detail-heading h2, .profile-role, .card-copy strong) {
  line-height: 1.06;
  letter-spacing: 0.02em;
}

:root[lang^="zh"] .binder-left h2 {
  font-size: clamp(2rem, 3.4vw, 3.3rem);
}

:root[lang^="zh"] .binder-cover h2 {
  font-size: 2.1rem;
}

:root[lang^="zh"] .profile-role {
  font-size: clamp(1.2rem, 4.6vw, 1.7rem);
}

:root[lang^="zh"] :is(.kicker, .binder-label, .tab-button, .primary-action, .secondary-action, .case-link, .pack-strip, .back-title, .card-meta-rarity, .pack-title, .hud-button) {
  letter-spacing: 0.1em;
}

:root.is-switching-language :is([data-zh], #sectionTitle, #sectionDescription, .tab-label, .card-copy, .card-topline, .tag-row, .detail-heading, .detail-body) {
  animation: languageSwap 560ms var(--ease-out);
}

@keyframes languageSwap {
  from {
    opacity: 0;
    filter: blur(6px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* ---------- Pointer-dependent hints ---------- */

@media (hover: hover) and (pointer: fine) {
  .binder-cover .secondary-action {
    display: none;
  }

  .binder-cover .binder-hover-hint {
    display: block;
    position: relative;
    z-index: 1;
    max-width: 12rem;
    margin: 1rem 0 0;
    color: var(--muted);
    font: 500 0.84rem/1.45 var(--body);
    letter-spacing: 0;
    text-transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .pack-stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding-left: clamp(1.25rem, 5vw, 4rem);
    padding-right: clamp(1.25rem, 5vw, 4rem);
  }
}

@media (max-width: 900px) {
  .binder-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.45rem;
  }

  .binder-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: 1rem;
    padding: 1.1rem 1.3rem 1rem;
    border-radius: 14px 14px 5px 5px;
    box-shadow: inset 0 -2rem 2.4rem -2.2rem rgba(0, 0, 0, 0.5);
  }

  .binder-left .binder-label {
    grid-column: 1 / -1;
    margin-bottom: 0.7rem;
  }

  .binder-left h2 {
    margin-bottom: 0.3rem;
    font-size: clamp(1.9rem, 6vw, 3rem);
  }

  .binder-left h2::after {
    display: none;
  }

  .binder-left p:not(.binder-label) {
    grid-column: 1 / -1;
    max-width: 38rem;
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .binder-controls {
    grid-column: 2;
    grid-row: 2;
    margin-top: 0;
  }

  .section-number {
    font-size: 7rem;
    bottom: -0.8rem;
  }

  .binder-page-wrap {
    border-radius: 5px 5px 14px 14px;
    box-shadow: inset 0 2rem 2.4rem -2.2rem rgba(0, 0, 0, 0.5);
  }

  .binder-rings {
    top: -1.6rem;
    bottom: auto;
    left: 12%;
    right: 12%;
    flex-direction: row;
  }

  .binder-rings span {
    width: 1.05rem;
    height: 3.2rem;
    background: linear-gradient(90deg, #fbf8ff, #a8a3bb 42%, #f2eff8 58%, #6f6a84);
  }

  .binder-page {
    --page-pad: clamp(1.4rem, 4cqh, 2.2rem);
    --page-pad-x: clamp(1rem, 3cqw, 2rem);
  }

  body.profile-docked .pack-stage[data-stage="revealed"] .profile-card {
    --profile-entry-y: 0;
    --profile-entry-scale: 1;
    bottom: -11rem;
    left: -5.5rem;
    width: min(78vw, 20rem);
  }

  body.profile-docked.profile-corner-open .pack-stage[data-stage="revealed"] .profile-card,
  body.profile-docked .pack-stage[data-stage="revealed"] .profile-card:hover {
    bottom: 1rem;
    left: 1rem;
  }
}

@media (max-width: 760px) {
  html,
  body,
  #app {
    max-width: 100%;
    overflow-x: clip;
  }

  body.binder-open {
    overflow: hidden;
  }

  .pack-stage {
    --pack-width: min(64vw, 17rem, calc(46svh * 0.72));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "copy"
      "focus"
      "cta";
    padding: max(4.2rem, calc(env(safe-area-inset-top) + 3.6rem)) 1.1rem max(1.4rem, env(safe-area-inset-bottom));
  }

  .stage-copy {
    align-self: start;
  }

  .kicker {
    margin-bottom: 0.9rem;
    font-size: 0.68rem;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 4.6rem);
  }

  :root[lang^="zh"] h1 {
    max-width: none;
    font-size: clamp(2.3rem, 11vw, 3.4rem);
  }

  .stage-copy::after {
    display: none;
  }

  .primary-action {
    justify-self: center;
    margin-top: 0.6rem;
  }

  .profile-card {
    width: min(68vw, 18rem, calc(48svh * 0.7));
  }

  .hud {
    top: max(0.7rem, env(safe-area-inset-top));
    right: max(0.7rem, env(safe-area-inset-right));
    gap: 0.35rem;
  }

  .hud-button {
    min-height: 2.2rem;
    padding: 0 0.62rem;
  }

  .lang-toggle {
    padding: 0 0.25rem;
  }

  .lang-option {
    min-width: 1.7rem;
    height: 1.55rem;
  }

  .theme-toggle-text {
    display: none;
  }

  body.profile-docked .pack-stage[data-stage="revealed"] .profile-card {
    --profile-entry-scale: 1;
    bottom: clamp(-9.2rem, -37vw, -6.8rem);
    left: clamp(-5rem, -24vw, -3.8rem);
    width: min(64vw, 14.5rem);
  }

  body.profile-docked.profile-corner-open .pack-stage[data-stage="revealed"] .profile-card,
  body.profile-docked .pack-stage[data-stage="revealed"] .profile-card:hover {
    bottom: max(0.7rem, env(safe-area-inset-bottom));
    left: max(0.7rem, env(safe-area-inset-left));
  }

  .binder-peek {
    left: 1rem;
    right: auto;
    bottom: max(1rem, env(safe-area-inset-bottom));
    grid-template-columns: 2.2rem minmax(0, 1fr);
    width: calc(100vw - 2rem);
    min-height: 10.5rem;
  }

  .binder-cover {
    display: grid;
    align-content: start;
    gap: 0.55rem;
    padding: 1rem;
  }

  .binder-cover p {
    margin-bottom: 0;
  }

  .binder-cover h2 {
    min-height: 0;
    font-size: clamp(1.7rem, 9vw, 2.2rem);
  }

  .binder-cover .secondary-action {
    justify-self: start;
    padding: 0.8rem 1rem;
    white-space: nowrap;
  }

  .binder-stage {
    gap: 0.6rem;
    padding:
      max(3.4rem, calc(env(safe-area-inset-top) + 3rem))
      0.7rem
      max(0.7rem, env(safe-area-inset-bottom));
  }

  body.binder-open .binder-peek {
    display: none;
  }

  .binder-tabs {
    width: 100%;
  }

  .tab-button {
    padding: 0.62rem 0.8rem;
    font-size: 0.7rem;
  }

  .binder-layout {
    padding: 0.5rem;
    border-radius: 16px;
  }

  .binder-left {
    padding: 0.9rem 1rem 0.9rem;
  }

  .binder-left h2 {
    font-size: clamp(1.8rem, 9vw, 2.5rem);
  }

  :root[lang^="zh"] .binder-left h2 {
    font-size: clamp(1.5rem, 7.2vw, 2.1rem);
  }

  .binder-left p:not(.binder-label) {
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .binder-left .binder-label {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    margin-bottom: 0;
  }

  .binder-left h2 {
    grid-column: 1 / -1;
    margin-top: 0.6rem;
  }

  .binder-controls {
    grid-column: 2;
    grid-row: 1;
    gap: 0.4rem;
  }

  .icon-button {
    width: 2.45rem;
  }

  .page-indicator {
    min-width: 2.8rem;
    font-size: 0.82rem;
  }

  .section-number {
    display: none;
  }

  .binder-rings span {
    width: 0.8rem;
    height: 2.6rem;
  }

  .binder-page {
    --page-pad: 1.1rem;
    --page-pad-x: 1rem;
    --page-gap: 1.2rem;
  }

  .binder-card {
    padding: 0.7rem;
  }

  .card-dialog {
    width: calc(100vw - 1.4rem);
    max-height: calc(100svh - 1.4rem);
  }

  .dialog-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(15rem, 42svh) auto;
    min-height: 0;
    max-height: calc(100svh - 1.4rem);
    overflow-y: auto;
  }

  .detail-body {
    overflow: visible;
    padding: 1.3rem 1.2rem 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
