/* =========================================================
 * cardpedia/cardpedia.css — Cardpedia page
 *   1. Page chrome (light, site style) around a dark card-table stage
 *   2. Stage bar: brand, tabs, coin / pack pills
 *   3. Cards: seven CSS-only rarity frames, art, typographic no-image face
 *   4. Pack + reveal ceremony
 *   5. Album, Deck of the Season, Missions
 *   6. Card detail + odds modals, toast
 * No image assets: everything except card art is CSS.
 * ========================================================= */

@property --ang {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

:root {
  --stage: #0b0d12;
  --stage-2: #12151c;
  --ink: #eef0f5;
  --ink-sub: #9aa1ae;
  --line: rgba(255, 255, 255, 0.09);
  --gold: #f3c74e;
  --serif: Georgia, 'Times New Roman', serif;
}

/* ---------- 1. Page ---------- */
html, body {
  background: var(--bg);
}
body {
  padding-top: var(--safe-top);
  -webkit-user-select: none;
  user-select: none;
}
.cp-page {
  padding: 12px 12px calc(32px + var(--safe-bottom));
}
.stage {
  position: relative;
  max-width: 1180px;
  min-height: 640px;
  margin: 0 auto;
  border-radius: 22px;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(ellipse 60% 48% at 50% 34%, rgba(255, 236, 200, 0.13), rgba(255, 236, 200, 0.03) 55%, transparent 75%),
    radial-gradient(ellipse 120% 80% at 50% 120%, #000 0%, transparent 60%),
    linear-gradient(#10131a, var(--stage) 60%);
  box-shadow: 0 18px 50px rgba(10, 12, 20, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.stage button {
  color: inherit;
  font: inherit;
}
.cp-page .game-copy {
  margin-top: 32px;
}
@media (max-width: 640px) {
  .cp-page {
    padding: 0 0 calc(32px + var(--safe-bottom));
  }
  .stage {
    border-radius: 0;
    min-height: calc(100svh - var(--safe-top));
  }
  .cp-page .game-copy {
    padding: 0 20px;
  }
}

/* ---------- 2. Stage bar ---------- */
.stage-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.brand {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #f6e7c1;
  text-shadow: 0 0 18px rgba(243, 199, 78, 0.35);
}
.tabs {
  display: flex;
  gap: 4px;
  margin-right: auto;
}
.tab {
  background: transparent;
  border: 0;
  position: relative;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-sub);
}
.tab[aria-selected='true'] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}
.tab .dot {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}
.pills {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill b {
  font-size: 15px;
}
.pill small {
  color: var(--ink-sub);
  font-size: 12px;
}
.coin-ico {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #f3c74e 45%, #a8780f);
  box-shadow: inset 0 0 0 2px rgba(120, 80, 0, 0.45);
}
.pack-ico {
  width: 12px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(135deg, #6c7cff, #b26bff);
}
.pill.bump {
  animation: bump 0.45s ease;
}
@keyframes bump {
  40% { transform: scale(1.15); background: rgba(243, 199, 78, 0.25); }
}
#btn-mute {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  font-size: 17px;
}
@media (max-width: 640px) {
  .stage-bar { padding: 8px 10px; gap: 6px; }
  .brand { font-size: 15px; letter-spacing: 0.16em; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tab { flex: 1; padding: 0 4px; font-size: 13px; }
  .pills { margin-left: auto; gap: 6px; }
  .pill { height: 32px; padding: 0 9px; font-size: 13px; }
}

.view {
  position: relative;
  z-index: 1;
  padding: 20px 16px 28px;
}
.view[hidden] {
  display: none;
}
.view h2.v-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  color: #f6e7c1;
}
.v-sub {
  margin-top: 4px;
  color: var(--ink-sub);
  font-size: 14px;
  line-height: 1.5;
}
#loading {
  position: absolute;
  inset: 70px 0 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-sub);
  font-family: var(--serif);
  letter-spacing: 0.08em;
}
#loading[hidden] {
  display: none;
}

/* Generic stage buttons */
.cbtn {
  color: var(--ink);
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  font-size: 15px;
  font-weight: 700;
}
.cbtn:active {
  transform: scale(0.97);
}
.cbtn.primary {
  border: 0;
  color: #241a02;
  background: linear-gradient(180deg, #ffe48a, #e2a92a);
  box-shadow: 0 6px 24px rgba(243, 199, 78, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.cbtn:disabled {
  opacity: 0.45;
  transform: none;
}
.cbtn.small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

/* ---------- 3. Cards ---------- */
/* .cpc is the frame (its background) and a size container: everything inside scales with it */
.cpc {
  --frame: #555;
  --glow: none;
  --tier-ink: #fff;
  position: relative;
  container-type: inline-size;
  aspect-ratio: 5 / 7;
  border-radius: 6.5%/4.6%;
  background: var(--frame);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 6px 18px rgba(0, 0, 0, 0.45), var(--glow);
  color: #fff;
  text-align: left;
}
.cpc-in {
  position: absolute;
  inset: 3.6cqw;
  display: flex;
  flex-direction: column;
  border-radius: 4.5cqw;
  overflow: hidden;
  background: linear-gradient(#171a22, #0d0f14);
  box-shadow: inset 0 0 0 0.6cqw rgba(0, 0, 0, 0.55);
}
.cpc-art {
  position: relative;
  flex: 0 0 64%;
  overflow: hidden;
  background: #1c2029;
}
.cpc-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cpc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3cqw 4.5cqw 3.5cqw;
  min-height: 0;
}
.cpc-name {
  font-family: var(--serif);
  font-size: 7.6cqw;
  font-weight: 700;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.cpc-row {
  display: flex;
  align-items: center;
  gap: 2.5cqw;
  font-size: 5.2cqw;
  color: #b8bfcc;
  white-space: nowrap;
  overflow: hidden;
}
.cpc-tier {
  flex-shrink: 0;
  padding: 0.6cqw 2.4cqw;
  border-radius: 2cqw;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #111;
  background: var(--frame);
}
.cpc-cat {
  overflow: hidden;
  text-overflow: ellipsis;
}
.cpc-stats {
  display: flex;
  justify-content: space-between;
  font-size: 5.6cqw;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.cpc-stats i {
  font-style: normal;
  font-weight: 800;
  font-size: 0.8em;
  margin-right: 1cqw;
  color: #ff8a6b;
}
.cpc-stats span + span i {
  color: #7fb6ff;
}

/* Rarity frames: C slate · UC bronze · R silver · SR gold · SSR prismatic · UR obsidian + red gem · LR rainbow foil */
.t-C {
  --frame: linear-gradient(160deg, #6a7480, #474e58 55%, #5b646f);
}
.t-UC {
  --frame: linear-gradient(135deg, #5e3816, #b97a40 28%, #f0c08a 44%, #9a6232 60%, #5a3518 85%);
}
.t-R {
  --frame: linear-gradient(135deg, #6b737c, #c9cfd6 28%, #ffffff 44%, #9aa2ab 60%, #646c75 85%);
}
.t-SR {
  --frame: linear-gradient(135deg, #7a540a, #e0b244 26%, #fff2b8 44%, #c9961f 60%, #7a540a 86%);
  --glow: 0 0 18px rgba(255, 196, 60, 0.42);
}
.t-SSR {
  --frame: conic-gradient(from 210deg, #1fd6c4, #3d8bff, #8b5cff, #d97bff, #5be0ff, #1fd6c4);
  --glow: 0 0 22px rgba(120, 110, 255, 0.5), 0 0 6px rgba(40, 220, 200, 0.6);
}
.t-UR {
  --frame: linear-gradient(160deg, #2a2a34, #07070a 40%, #1b1b23 70%, #3a3a46);
  --glow: 0 0 22px rgba(225, 25, 50, 0.5);
}
.cpc.t-UR .cpc-in {
  box-shadow: inset 0 0 0 0.6cqw #b3121f, inset 0 0 6cqw rgba(179, 18, 31, 0.25);
}
.cpc.t-UR::after { /* the red gem set into the top edge */
  content: '';
  position: absolute;
  z-index: 2;
  top: 0.4cqw;
  left: 50%;
  width: 9cqw;
  height: 9cqw;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 1.5cqw;
  background: radial-gradient(circle at 35% 30%, #ffd0d4, #ff2a3d 35%, #7a0010 80%);
  box-shadow: 0 0 0 0.8cqw #111, 0 0 3cqw rgba(255, 40, 60, 0.9);
}
.t-UR .cpc-tier {
  color: #ffd9dc;
  background: linear-gradient(#c8162a, #6e0612);
}
.t-LR {
  --frame: conic-gradient(from var(--ang), #ff3d5a, #ffa33d, #fff35c, #57ff8a, #3de1ff, #5b6cff, #d65bff, #ff3d5a);
  --glow: 0 0 26px rgba(255, 255, 255, 0.35), 0 0 12px rgba(255, 120, 200, 0.5);
  animation: foil-spin 4s linear infinite;
}
.t-LR .cpc-in::after { /* foil sheen sweeping over the face */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.28) 45%, rgba(160, 255, 240, 0.18) 50%, rgba(255, 160, 240, 0.18) 55%, transparent 70%);
  background-size: 250% 100%;
  mix-blend-mode: screen;
  animation: sheen 3.2s ease-in-out infinite;
}
@keyframes foil-spin {
  to { --ang: 360deg; }
}
@keyframes sheen {
  0% { background-position: 120% 0; }
  60%, 100% { background-position: -120% 0; }
}

/* Typographic face: cards with no picture (and the hidden art of undiscovered cards) */
.face {
  --h: 220;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 2cqw, transparent 2cqw 4.5cqw),
    radial-gradient(circle at 28% 22%, hsl(var(--h) 55% 38%), hsl(var(--h) 45% 16%) 62%, hsl(var(--h) 40% 9%));
}
.face::before { /* engraved ring behind the letter */
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  width: 66cqw;
  height: 66cqw;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 0.8cqw solid hsl(var(--h) 60% 70% / 0.25);
  box-shadow: 0 0 0 2.4cqw hsl(var(--h) 60% 70% / 0.06), inset 0 0 8cqw rgba(0, 0, 0, 0.35);
}
.face-letter {
  position: absolute;
  left: 0;
  right: 0;
  top: 46%;
  transform: translateY(-52%);
  text-align: center;
  font-family: var(--serif);
  font-size: 46cqw;
  line-height: 1;
  font-weight: 700;
  color: hsl(var(--h) 70% 92%);
  text-shadow: 0 1cqw 0 rgba(0, 0, 0, 0.35), 0 0 10cqw hsl(var(--h) 80% 60% / 0.45);
}
.face-glyph {
  position: absolute;
  top: 4cqw;
  left: 5cqw;
  font-size: 9cqw;
  line-height: 1;
  color: hsl(var(--h) 70% 80% / 0.8);
}
.face-glyph.r {
  left: auto;
  right: 5cqw;
}
.face-cat {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4cqw;
  text-align: center;
  font-size: 5cqw;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: hsl(var(--h) 50% 82% / 0.85);
}
/* Undiscovered: name shown, art and stats hidden */
.cpc.locked .face {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 2cqw, transparent 2cqw 4.5cqw),
    radial-gradient(circle at 50% 40%, #252a35, #0c0e13 70%);
}
.cpc.locked .face::before {
  border-color: rgba(255, 255, 255, 0.08);
}
.cpc.locked .face-letter {
  color: rgba(255, 255, 255, 0.13);
  text-shadow: none;
}
.cpc.locked .cpc-stats {
  color: #5d6472;
}
.cpc.locked .cpc-name {
  color: #c9ced8;
}
.cpc.locked {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 6px 18px rgba(0, 0, 0, 0.45);
}
.cpc.locked > .cpc-in {
  filter: saturate(0.6);
}
.cpc-count {
  position: absolute;
  z-index: 3;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #f3c74e;
  color: #241a02;
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.cpc-fav {
  position: absolute;
  z-index: 3;
  top: 6cqw;
  left: 6cqw;
  font-size: 9cqw;
  color: #ff6b8a;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}
button.cpc-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: inherit;
  cursor: pointer;
}
button.cpc-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  border-radius: 10px;
}

/* ---------- 4. Pack + reveal ---------- */
.table {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 430px;
  justify-content: center;
}
.pack-btn {
  position: relative;
  width: 210px;
  height: 300px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
}
.pack {
  --pk: linear-gradient(150deg, #1d2140, #3a2a6a 40%, #1a1f3a 70%, #2b3270);
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: var(--pk);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(255, 255, 255, 0.12), inset 0 0 40px rgba(130, 120, 255, 0.25);
  overflow: hidden;
  animation: pack-float 3.6s ease-in-out infinite;
}
.pack::before { /* foil grain */
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 3px, transparent 3px 9px),
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.22) 48%, transparent 60%);
  background-size: auto, 260% 100%;
  animation: sheen 4s ease-in-out infinite;
}
.pack-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 36px;
  background: inherit;
  border-bottom: 2px dashed rgba(255, 255, 255, 0.35);
  background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  transition: transform 0.55s cubic-bezier(0.3, 0.6, 0.2, 1.4), opacity 0.55s;
}
.pack-word {
  position: absolute;
  left: 0;
  right: 0;
  top: 96px;
  text-align: center;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #f6e7c1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 20px rgba(243, 199, 78, 0.4);
}
.pack-emblem {
  position: absolute;
  left: 50%;
  top: 150px;
  width: 64px;
  height: 64px;
  transform: translateX(-50%) rotate(45deg);
  border: 2px solid rgba(246, 231, 193, 0.7);
  border-radius: 8px;
  box-shadow: 0 0 0 6px rgba(246, 231, 193, 0.12), 0 0 24px rgba(243, 199, 78, 0.35);
}
.pack-emblem::after {
  content: 'C';
  position: absolute;
  inset: 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  color: #f6e7c1;
}
.pack-type {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}
.pack.gold {
  --pk: linear-gradient(150deg, #7a540a, #e0b244 30%, #fff2b8 46%, #c9961f 62%, #7a540a);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 50px rgba(255, 196, 60, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}
.pack.gold .pack-word, .pack.gold .pack-emblem::after, .pack.gold .pack-type {
  color: #3a2600;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.pack.gold .pack-emblem {
  border-color: rgba(58, 38, 0, 0.7);
}
.pack.rainbow {
  --pk: conic-gradient(from var(--ang), #ff3d5a, #ffa33d, #fff35c, #57ff8a, #3de1ff, #5b6cff, #d65bff, #ff3d5a);
  animation: pack-float 3.6s ease-in-out infinite, foil-spin 5s linear infinite;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 60px rgba(255, 255, 255, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}
.pack.rainbow .pack-word, .pack.rainbow .pack-type {
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
@keyframes pack-float {
  0%, 100% { transform: translateY(0) rotateX(4deg) rotateY(-6deg); }
  50% { transform: translateY(-8px) rotateX(2deg) rotateY(6deg); }
}
.pack-btn:focus-visible .pack {
  outline: 3px solid #fff;
  outline-offset: 4px;
}
.pack-btn:disabled {
  cursor: default;
}
.pack-btn:disabled .pack {
  filter: grayscale(0.85) brightness(0.55);
  animation: none;
}
.tearing .pack {
  animation: pack-shake 0.5s ease both;
}
.tearing .pack-top {
  transform: translate(80px, -110px) rotate(28deg);
  opacity: 0;
}
.torn .pack {
  animation: none;
  transform: translateY(60px) scale(0.85);
  opacity: 0;
  transition: transform 0.35s ease-in, opacity 0.35s;
}
@keyframes pack-shake {
  20% { transform: rotate(-3deg) scale(1.03); }
  40% { transform: rotate(3deg) scale(1.05); }
  60% { transform: rotate(-2deg) scale(1.06); }
  80% { transform: rotate(1deg) scale(1.07); filter: brightness(1.4); }
  100% { transform: scale(1.08); filter: brightness(1.8); }
}
.pack-hint {
  margin-top: 22px;
  text-align: center;
  color: var(--ink-sub);
  font-size: 14px;
  min-height: 20px;
}
.pack-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.pity {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 520px;
  margin: 18px auto 0;
}
.meter {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-sub);
}
.meter b {
  color: var(--ink);
}
.meter .bar {
  height: 6px;
  margin-top: 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.meter .bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #a87400, #ffe08a);
}
.meter.rb .bar i {
  background: linear-gradient(90deg, #ff3d5a, #ffa33d, #fff35c, #57ff8a, #3de1ff, #5b6cff, #d65bff);
}
.odds-strip {
  max-width: 760px;
  margin: 16px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-sub);
}
.odds-strip span {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}
.odds-strip b {
  margin-right: 4px;
}
.linkish {
  min-height: 44px;
  padding: 0 10px;
  background: none;
  border: 0;
  color: #f6e7c1;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Reveal */
.reveal {
  width: 100%;
}
.reveal[hidden] {
  display: none;
}
.reveal-head {
  text-align: center;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.06em;
  color: #f6e7c1;
  min-height: 26px;
}
.reveal-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 16px auto 0;
  max-width: 1000px;
}
.rslot {
  position: relative;
  width: 172px;
  perspective: 1100px;
  animation: deal 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.1) both;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes deal {
  from { transform: translate(calc((2 - var(--i)) * 60px), -160px) rotate(calc((var(--i) - 2) * 8deg)) scale(0.6); opacity: 0; }
}
.flip {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.2, 1.15);
  cursor: pointer;
}
.rslot.up .flip {
  transform: rotateY(180deg);
}
.flip > .back, .flip > .front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip > .front {
  transform: rotateY(180deg);
}
.flip > .front .cpc {
  width: 100%;
}
.back {
  border-radius: 6.5%/4.6%;
  background:
    radial-gradient(circle at 50% 50%, transparent 24%, rgba(246, 231, 193, 0.18) 25%, transparent 26%),
    repeating-linear-gradient(45deg, rgba(246, 231, 193, 0.06) 0 6px, transparent 6px 14px),
    repeating-linear-gradient(-45deg, rgba(246, 231, 193, 0.06) 0 6px, transparent 6px 14px),
    linear-gradient(150deg, #1d2140, #2e2458 50%, #1a1f3a);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 0 5px #0e1020, inset 0 0 0 7px rgba(246, 231, 193, 0.4), 0 10px 24px rgba(0, 0, 0, 0.5);
}
.back::after {
  content: 'C';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 700;
  color: rgba(246, 231, 193, 0.75);
}
.rslot:not(.up) .flip:hover .back {
  filter: brightness(1.15);
}
/* SR+ "charge" before the flip: the back lights up in the tier's colour */
.rslot.charge {
  --cg: 255, 196, 60;
  animation: charge-shake 0.12s linear infinite;
}
.rslot.charge.c-SSR { --cg: 140, 110, 255; }
.rslot.charge.c-UR { --cg: 235, 30, 55; }
.rslot.charge.c-LR { --cg: 255, 255, 255; }
.rslot.charge .back {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 0 5px #0e1020, inset 0 0 0 7px rgba(var(--cg), 0.9), 0 0 40px rgba(var(--cg), 0.85), 0 0 90px rgba(var(--cg), 0.5);
  transition: box-shadow 0.4s;
}
@keyframes charge-shake {
  25% { transform: translate(1px, -1px) rotate(0.6deg); }
  75% { transform: translate(-1px, 1px) rotate(-0.6deg); }
}
.burst {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 4px rgba(var(--cg, 255, 255, 255), 0.9);
  animation: burst 0.7s ease-out forwards;
}
@keyframes burst {
  to { transform: scale(14); opacity: 0; }
}
.rslot.up.hi .front .cpc {
  animation: land-hi 0.6s ease;
}
@keyframes land-hi {
  40% { transform: scale(1.08); }
}
.tag {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.3s;
}
.rslot.up .tag {
  opacity: 1;
}
.tag.new {
  color: #8dffb0;
}
.tag.dup {
  color: #f3c74e;
}
.reveal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}
.reveal-sum {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-sub);
  min-height: 20px;
}
.reveal-sum b {
  color: #f3c74e;
}

/* LR moment: the room goes dark, rays turn behind the card, white flash */
.lr-fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
  background: radial-gradient(circle at 50% 45%, transparent 10%, rgba(0, 0, 0, 0.75) 60%);
}
.lr-fx::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160vmax;
  height: 160vmax;
  margin: -80vmax 0 0 -80vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.09) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 45%);
  mask: radial-gradient(circle, #000 0, transparent 45%);
  animation: rays 9s linear infinite;
}
.lr-fx::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
}
.stage.lr-on .lr-fx {
  opacity: 1;
}
.stage.lr-flash .lr-fx::after {
  animation: flash 0.7s ease-out;
}
@keyframes rays {
  to { transform: rotate(360deg); }
}
@keyframes flash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}
.stage.lr-on .rslot.lr-card {
  z-index: 3;
}
.spark {
  position: absolute;
  z-index: 5;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  background: hsl(var(--sh) 100% 70%);
  box-shadow: 0 0 8px hsl(var(--sh) 100% 70%);
  animation: spark 1.1s ease-out forwards;
}
@keyframes spark {
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
@media (max-width: 640px) {
  .table { min-height: 380px; }
  .reveal-row { gap: 10px; }
  .rslot { width: calc((100vw - 52px) / 3); max-width: 150px; }
  .pity { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 641px) and (max-width: 980px) {
  .rslot { width: 140px; }
}

/* ---------- 5. Album ---------- */
.album-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
}
.owned-total {
  font-size: 14px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.owned-total b {
  color: var(--ink);
  font-size: 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.chip {
  min-height: 40px;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}
.chip small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed='true'] {
  border-color: rgba(243, 199, 78, 0.7);
  background: rgba(243, 199, 78, 0.12);
}
.chip .sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -1px;
  background: var(--frame);
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.filters input[type='search'], .filters select {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #171a22;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.filters input[type='search'] {
  flex: 1 1 200px;
  -webkit-user-select: text;
  user-select: text;
}
.toggle {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #171a22;
  font-size: 14px;
  font-weight: 700;
}
.toggle[aria-pressed='true'] {
  border-color: rgba(255, 107, 138, 0.8);
  background: rgba(255, 107, 138, 0.14);
}
.scope-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: var(--ink-sub);
}
.scope-note[hidden] {
  display: none;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.grid .cell {
  position: relative;
}
.empty {
  grid-column: 1 / -1;
  padding: 40px 10px;
  text-align: center;
  color: var(--ink-sub);
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}

/* Deck of the Season */
.deck-rule {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 3px solid #f3c74e;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  line-height: 1.55;
  color: #cfd4de;
}
.deck-rule p + p {
  margin-top: 6px;
}
.suit {
  margin-top: 26px;
}
.suit h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  font-size: 19px;
  color: #f6e7c1;
}
.suit h3 .sym {
  font-size: 24px;
}
.suit h3 .sym.red {
  color: #ff5a6e;
}
.suit h3 small {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-sub);
}
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.dslot {
  position: relative;
}
.dslot .rank {
  position: absolute;
  z-index: 4;
  top: 10%;
  left: 8%;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(10, 12, 18, 0.85);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.dslot .rank.red {
  color: #ff7a8a;
}
.dslot.undiscovered .cpc {
  filter: grayscale(1) brightness(0.5) contrast(0.9);
}
.dslot.undiscovered .flag {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 32%;
  transform: translate(-50%, -50%) rotate(-8deg);
  padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #e7e9ee;
}
.dslot .raw {
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.dslot .raw b {
  color: #dfe3ea;
  font-weight: 700;
}
.joker-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 210px));
}
.dslot .jlabel {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f3c74e;
}
@media (max-width: 640px) {
  .deck-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .joker-grid { grid-template-columns: repeat(2, 1fr); }
  .dslot .rank { font-size: 13px; min-width: 24px; }
  .dslot .raw { font-size: 10.5px; }
  .dslot.undiscovered .flag { font-size: 8.5px; letter-spacing: 0.06em; padding: 2px 5px; }
}

/* Missions */
.missions {
  list-style: none;
  max-width: 640px;
  margin-top: 16px;
  display: grid;
  gap: 10px;
}
.mission {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.mission.claimed {
  opacity: 0.55;
}
.mission .m-txt {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
}
.mission .m-txt small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-sub);
}
.mission .bar {
  height: 5px;
  margin-top: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.mission .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a87400, #ffe08a);
}
.wallet-note {
  max-width: 640px;
  margin-top: 22px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(243, 199, 78, 0.07);
  border: 1px solid rgba(243, 199, 78, 0.25);
  font-size: 14px;
  line-height: 1.5;
  color: #e9dcb8;
}
.rates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.rates span {
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 6. Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 10px) 12px calc(var(--safe-bottom) + 10px);
  background: rgba(4, 5, 9, 0.82);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--ink);
}
.modal[hidden] {
  display: none;
}
.m-box {
  position: relative;
  width: 100%;
  max-width: 860px;
  max-height: 100%;
  overflow: auto;
  border-radius: 20px;
  background: linear-gradient(#171a23, #0e1016);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  padding: 22px;
  -webkit-user-select: text;
  user-select: text;
}
.m-x {
  position: sticky;
  float: right;
  top: 0;
  z-index: 3;
  width: 44px;
  height: 44px;
  margin: -10px -10px 0 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 18px;
}
.d-wrap {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}
.d-card .cpc {
  width: 100%;
}
.d-info h2 {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.15;
  color: #fff;
  padding-right: 40px;
}
.d-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.d-tags span {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 700;
}
.tierchip, .d-tags .tierchip {
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 800;
  color: #111;
  background: var(--frame);
}
.tierchip.t-UR, .d-tags .tierchip.t-UR {
  color: #ffd9dc;
  background: linear-gradient(#c8162a, #6e0612);
}
.statbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.stat {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.stat .k {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #ff8a6b;
}
.stat.def .k {
  color: #7fb6ff;
}
.stat .v {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stat .raw {
  font-size: 12.5px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.stat .raw b {
  color: #dfe3ea;
}
.d-sl {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-sub);
}
.d-text {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.6;
  color: #dde1e8;
}
.d-src, .d-attr {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-sub);
  line-height: 1.5;
}
.d-src a, .d-attr a, .d-text a {
  color: #cfd8ff;
}
.d-locked {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-sub);
  font-size: 14px;
}
.d-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
a.cbtn {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
@media (max-width: 700px) {
  .m-box { padding: 16px; }
  .d-wrap { grid-template-columns: 1fr; gap: 14px; }
  .d-card { width: min(240px, 70vw); margin: 0 auto; }
  .d-info h2 { font-size: 22px; padding-right: 0; }
}
.odds-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.odds-table th, .odds-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}
.odds-table th:first-child, .odds-table td:first-child {
  text-align: left;
}
.odds-table th {
  font-size: 11.5px;
  color: var(--ink-sub);
  font-weight: 700;
}
.m-box h3 {
  margin-top: 18px;
  font-size: 15px;
  color: #f6e7c1;
}
.m-box p.small {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-sub);
}
.m-box code {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #dfe3ea;
}
.game-copy code {
  font-size: 13px;
  overflow-wrap: anywhere;
}
#toast {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #f6e7c1;
  color: #241a02;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Reduced motion: no foil spin, sheen, float, deal or shake; reveals are instant (game.js) */
@media (prefers-reduced-motion: reduce) {
  .t-LR, .t-LR .cpc-in::after, .pack, .pack::before, .pack.rainbow, .rslot, .rslot.charge, .lr-fx::before {
    animation: none !important;
  }
  .flip, .pack-top, .tag {
    transition: none !important;
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.odds-strip b[class^='t-'], .odds-table .tierchip {
  animation: none;
}

    /* Desktop share panel (fine-pointer browsers; built by game.js openSharePanel) */
    .share-panel {
      position: fixed;
      inset: 0;
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0, 0, 0, 0.45);
      animation: sp-fade 0.15s ease-out;
    }
    .sp-box {
      width: 100%;
      max-width: 360px;
      max-height: 100%;
      overflow-y: auto;
      padding: 14px 16px 16px;
      border-radius: var(--sp-radius, 16px);
      background: var(--sp-card, #fff);
      color: var(--sp-text, var(--text, #2d3436));
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    }
    .sp-head { display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
    .sp-x {
      width: 44px;
      height: 44px;
      margin-right: -10px;
      border: 0;
      background: none;
      color: inherit;
      font: inherit;
      font-size: 20px;
      cursor: pointer;
    }
    .sp-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
    .sp-row {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 44px;
      padding: 0 10px;
      border: 0;
      border-radius: 999px;
      background: var(--sp-row, #f1f2f6);
      color: inherit;
      font: inherit;
      font-size: 15px;
      font-weight: 600;
      text-decoration: none;
      cursor: pointer;
    }
    .sp-row:hover, .sp-row:focus-visible { outline: 2px solid var(--sp-accent, var(--primary, #ff7f50)); outline-offset: -2px; }
    .sp-copy { grid-column: 1 / -1; background: var(--sp-accent, var(--primary, #ff7f50)); color: #fff; }
    .sp-qr { margin: 14px 0 0; text-align: center; }
    .sp-qr svg { display: block; width: 132px; height: 132px; margin: 0 auto; border-radius: 6px; }
    .sp-qr figcaption { margin-top: 6px; font-size: 13px; opacity: 0.75; }
    @keyframes sp-fade { from { opacity: 0; } }
    @media (prefers-reduced-motion: reduce) { .share-panel { animation: none; } }
    .share-panel { --sp-card: linear-gradient(#171a23, #0e1016); --sp-text: #eef0f5; --sp-row: rgba(255, 255, 255, 0.08); --sp-accent: #f3c74e; --sp-radius: 20px; }
