@property --mx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --my { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg: #07041a;
  --bg-2: #120a2e;
  --ink: #efe6ff;
  --ink-dim: #b3a6d6;
  --gold: #e9c46a;
  --gold-2: #fff1b8;
  --violet: #8b6cff;
  --line: rgba(233, 196, 106, .25);
  --panel: rgba(25, 14, 58, .65);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --display: 'Cinzel', 'Cormorant Garamond', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #2a1660 0%, var(--bg-2) 40%, var(--bg) 80%) fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, h5 { font-family: var(--display); font-weight: 700; letter-spacing: .04em; margin: 0 0 .4em; }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); background: linear-gradient(180deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
a { color: var(--gold); }

/* --- starry background --- */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff8, transparent), radial-gradient(1px 1px at 80% 10%, #fff9, transparent),
    radial-gradient(1.5px 1.5px at 30% 70%, #fff7, transparent), radial-gradient(1px 1px at 60% 40%, #fff6, transparent),
    radial-gradient(1px 1px at 90% 80%, #fff8, transparent), radial-gradient(1.5px 1.5px at 45% 15%, #ffe9a9aa, transparent),
    radial-gradient(1px 1px at 20% 90%, #fff6, transparent), radial-gradient(1px 1px at 70% 60%, #fff5, transparent);
  background-size: 420px 420px;
  animation: drift 120s linear infinite;
  opacity: .8;
}
@keyframes drift { to { background-position: 420px 840px; } }

.dim { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 5; }
body.opening .dim { opacity: .45; }
body.epic-dim .dim { opacity: .92; transition-duration: 1.2s; }
body.opening .topbar { opacity: .3; pointer-events: none; }

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; }
.fx-flash { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.fx-ring { position: fixed; width: 100px; height: 100px; border-radius: 50%; border: 3px solid; pointer-events: none; z-index: 31; }

/* --- buttons & forms --- */
.btn {
  font-family: var(--display); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .85em 1.6em; border-radius: 999px; cursor: pointer; color: var(--ink);
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(233, 196, 106, .25); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: linear-gradient(135deg, #f6d77f, #c99733); color: #1c1030; border-color: transparent; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { padding: .5em 1em; font-size: .7rem; }
.icon-btn { background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: .3em; }

input, textarea {
  width: 100%; font: inherit; color: var(--ink); background: rgba(10, 5, 30, .6);
  border: 1px solid var(--line); border-radius: 12px; padding: .7em .9em; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 196, 106, .15); }
label { display: grid; gap: .3em; font-size: .9rem; color: var(--ink-dim); text-align: left; }
.error { color: #ff9a9a; min-height: 1.2em; margin: 0; font-size: .95rem; }

/* --- auth --- */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(420px, 100%); text-align: center; padding: 40px 32px; border-radius: 24px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 80px rgba(139, 108, 255, .15);
}
.logo-big { font-family: var(--display); font-size: 2.6rem; color: var(--gold); text-shadow: 0 0 30px rgba(233, 196, 106, .5); }
.tagline { color: var(--ink-dim); font-style: italic; margin: .5em 0 1.6em; }
#auth-form { display: grid; gap: 14px; }
.auth-switch { margin: 1.2em 0 0; color: var(--ink-dim); font-size: .95rem; }
.auth-switch button { background: none; border: 0; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: rgba(7, 4, 26, .7); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); transition: opacity .5s;
}
.logo { font-family: var(--display); font-size: 1.35rem; text-decoration: none; color: var(--gold); white-space: nowrap; }
nav { display: flex; gap: 4px; margin: 0 auto; }
nav a {
  font-family: var(--display); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; text-decoration: none;
  color: var(--ink-dim); padding: .5em 1em; border-radius: 999px; transition: color .2s, background .2s;
}
nav a:hover { color: var(--ink); }
nav a.active { color: #1c1030; background: linear-gradient(135deg, #f6d77f, #c99733); }
.user { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: .95rem; }

.view { max-width: 1100px; margin: 0 auto; padding: 32px 24px 80px; text-align: center; }

/* --- cards --- */
.tcard {
  --w: 220px;
  width: var(--w); aspect-ratio: 3 / 5; position: relative; flex: none;
  transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2, .8, .3, 1);
}
.tcard.tilting { transition: transform .08s linear; }
.tcard-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.3, 1.35, .5, 1); }
.tcard.revealed .tcard-inner { transform: rotateY(180deg); }
.tcard-face {
  position: absolute; inset: 0; border-radius: 6% / 3.6%; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(233, 196, 106, .25);
}
.tcard-front { transform: rotateY(180deg); }
.card-svg { width: 100%; height: 100%; display: block; }
.tcard-art { position: absolute; inset: 0; }
.tcard-art.reversed { transform: rotate(180deg); }
.shine, .glitter, .glare { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.glare { background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, .35), transparent 50%); mix-blend-mode: overlay; opacity: 0; transition: opacity .3s; }
.tcard.tilting .glare { opacity: 1; }

/* illustrated: paper grain over a painted scene */
.rarity-drawn .glitter {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply; opacity: .45;
}
.rarity-drawn .shine { background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 245, 220, .35), transparent 55%); mix-blend-mode: soft-light; }
.rarity-drawn .tcard-front { box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(243, 230, 200, .7), 0 0 26px rgba(244, 162, 97, .3); }

/* holographic */
.rarity-holo .shine {
  background:
    repeating-linear-gradient(115deg, #ff6ad5 0%, #c774e8 7%, #ad8cff 14%, #8795e8 21%, #94d0ff 28%, #7fffd4 35%, #fff36a 42%, #ff6ad5 49%);
  background-size: 400% 400%;
  background-position: var(--mx) var(--my);
  mix-blend-mode: color-dodge; opacity: .5; filter: brightness(.75) contrast(1.5) saturate(1.3);
  animation: holo-sweep 6s ease-in-out infinite alternate;
}
.rarity-holo .glitter {
  background-image:
    radial-gradient(circle, #fff 0 1px, transparent 1.6px), radial-gradient(circle, #fff 0 .8px, transparent 1.3px);
  background-size: 17px 19px, 23px 13px; background-position: 0 0, 7px 5px;
  mix-blend-mode: overlay; opacity: .55;
  mask-image: linear-gradient(115deg, transparent 20%, #000 45%, #000 55%, transparent 80%);
  mask-size: 300% 300%; mask-position: var(--mx) var(--my);
}
.rarity-holo .tcard-front { box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(200, 180, 255, .6), 0 0 30px rgba(170, 140, 255, .35); }
.tcard.tilting .shine, .tcard.tilting .glitter { animation-play-state: paused; }
@keyframes holo-sweep { 0% { --mx: 0%; --my: 20%; } 100% { --mx: 100%; --my: 80%; } }

/* epic */
.rarity-epic .tcard-front::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 3px; z-index: 2; pointer-events: none;
  background: conic-gradient(from var(--ang), #ffd86b, #ff8c42, #fff1b8, #b8860b, #ffe08a, #ffd86b);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin-ang 3s linear infinite;
}
.rarity-epic .shine {
  background: linear-gradient(115deg, transparent 25%, rgba(255, 220, 130, .7) 42%, rgba(255, 255, 255, .95) 50%, rgba(255, 190, 80, .7) 58%, transparent 75%);
  background-size: 300% 300%; background-position: var(--mx) var(--my);
  mix-blend-mode: color-dodge; opacity: .38; animation: holo-sweep 3.5s ease-in-out infinite alternate;
}
.rarity-epic .glitter {
  background-image: radial-gradient(circle, #fff6cf 0 1.2px, transparent 2px), radial-gradient(circle, #ffd86b 0 1px, transparent 1.8px);
  background-size: 21px 27px, 29px 17px; background-position: 0 0, 11px 9px;
  mix-blend-mode: screen; animation: twinkle 1.6s ease-in-out infinite alternate;
}
.rarity-epic .tcard-front { box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 40px rgba(255, 200, 90, .55), 0 0 90px rgba(255, 160, 60, .25); }
@keyframes spin-ang { to { --ang: 360deg; } }
@keyframes twinkle { from { opacity: .2; } to { opacity: .6; } }

/* --- packs --- */
.pack-header { margin-bottom: 8px; }
.gems { display: inline-flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
.gem { width: 16px; height: 16px; transform: rotate(45deg); border: 1px solid var(--gold); background: transparent; transition: all .4s; }
.gem.on { background: linear-gradient(135deg, #fff1b8, #e9c46a); box-shadow: 0 0 14px rgba(233, 196, 106, .8); }
.gem-label { font-family: var(--display); font-size: .8rem; letter-spacing: .12em; color: var(--ink-dim); margin-left: 6px; }
.pack-sub { color: var(--ink-dim); font-style: italic; margin: 0; min-height: 1.6em; }
.pack-sub b { color: var(--gold); font-style: normal; font-variant-numeric: tabular-nums; }

.pack-stage { position: relative; z-index: 20; min-height: 470px; display: grid; place-items: center; margin-top: 12px; overflow-x: clip; }
.pack-slot, .reveal-slot { grid-area: 1 / 1; display: grid; place-items: center; }
.stage-rays {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 760px; height: 760px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity 1s;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .0) 0deg 8deg, rgba(255, 255, 255, .14) 10deg 14deg, rgba(255, 255, 255, 0) 16deg 22deg);
  mask-image: radial-gradient(circle, #000 15%, transparent 65%); -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 65%);
  animation: spin 18s linear infinite;
}
.stage-rays.on { opacity: 1; }
.stage-rays.holo { background: repeating-conic-gradient(from 0deg, #ff6ad500 0deg 6deg, #ad8cff55 9deg 12deg, #7fffd400 15deg 20deg, #94d0ff44 24deg 26deg, #ff6ad500 30deg); }
.stage-rays.epic { background: repeating-conic-gradient(from 0deg, #ffd86b00 0deg 6deg, #ffd86b66 9deg 13deg, #ffd86b00 16deg 24deg); animation-duration: 10s; }
@keyframes spin { to { transform: rotate(360deg); } }

.pack {
  --charge: 0;
  position: relative; width: 240px; height: 360px; cursor: grab; user-select: none; touch-action: none; outline: none;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .6));
  animation: float 4s ease-in-out infinite;
  transition: translate 1.6s cubic-bezier(.3, 0, .2, 1);
}
.pack:focus-visible .hold-ring circle { stroke: #fff; }
.pack-half { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; }
.pack-half svg { width: 100%; height: 100%; display: block; }
.pack-sheen {
  position: absolute; inset: 0; mix-blend-mode: color-dodge; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .35) 45%, rgba(190, 160, 255, .3) 52%, transparent 65%);
  background-size: 250% 100%; animation: sheen 3.5s ease-in-out infinite;
}
@keyframes sheen { 0% { background-position: 120% 0; } 60%, 100% { background-position: -40% 0; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
.pack-glow {
  position: absolute; inset: -30px; border-radius: 40px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(233, 196, 106, calc(.15 + var(--charge) * .6)), transparent);
  filter: blur(10px); transition: background .4s;
}
.hold-ring { position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; translate: -50% -50%; pointer-events: none; opacity: calc(var(--charge) * 3); }
.hold-ring circle { fill: none; stroke: var(--gold-2); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transform: rotate(-90deg); transform-origin: center; filter: drop-shadow(0 0 6px var(--gold)); }
.pack.charging { animation: charge-shake .07s linear infinite; cursor: grabbing; }
@keyframes charge-shake {
  0% { transform: translate(calc(var(--charge) * 3px), 0) rotate(calc(var(--charge) * 1deg)); }
  50% { transform: translate(calc(var(--charge) * -3px), calc(var(--charge) * 2px)) rotate(calc(var(--charge) * -1deg)); }
  100% { transform: translate(0, calc(var(--charge) * -2px)) rotate(0); }
}
.pack.suspense { animation: suspense .5s ease-in-out infinite alternate; }
@keyframes suspense { from { transform: scale(1); } to { transform: scale(1.03); } }
.pack.sealed { cursor: not-allowed; filter: grayscale(.7) brightness(.6) drop-shadow(0 20px 40px rgba(0, 0, 0, .6)); animation: none; }
.pack-lock {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; white-space: nowrap; font-family: var(--display); letter-spacing: .2em;
  padding: .4em 1em; border: 1px solid var(--gold); color: var(--gold); background: rgba(7, 4, 26, .85); border-radius: 999px;
}

.pack.trembling { animation: tremble .09s linear infinite; }
.pack.violent { animation: tremble-hard .05s linear infinite; }
@keyframes tremble { 0% { transform: translate(2px, 0) rotate(.6deg); } 50% { transform: translate(-2px, 1px) rotate(-.6deg); } 100% { transform: translate(0, -1px); } }
@keyframes tremble-hard { 0% { transform: translate(6px, -2px) rotate(2deg); } 50% { transform: translate(-6px, 3px) rotate(-2deg); } 100% { transform: translate(2px, 0) rotate(1deg); } }
.pack.levitate { translate: 0 -34px; }
.pack.glow-drawn .pack-glow { background: radial-gradient(closest-side, rgba(244, 162, 97, .7), rgba(42, 157, 143, .35), transparent); filter: blur(22px); }
.pack.glow-holo .pack-glow { background: conic-gradient(from var(--ang), #ff6ad5, #ad8cff, #94d0ff, #7fffd4, #fff36a, #ff6ad5); filter: blur(28px); opacity: .9; animation: spin-ang 1.6s linear infinite; }
.pack.glow-epic .pack-glow { background: radial-gradient(closest-side, rgba(255, 215, 110, .95), rgba(255, 140, 40, .4), transparent); filter: blur(18px); inset: -60px; animation: pulse .35s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .7; scale: .95; } to { opacity: 1; scale: 1.08; } }
.pack.leak .pack-half { box-shadow: 0 0 0 2px rgba(255, 255, 255, .8), 0 0 30px 8px rgba(200, 180, 255, .9); }
.pack-cracks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.pack-cracks path { fill: none; stroke: #fff6cf; stroke-width: 2.5; stroke-dasharray: 300; stroke-dashoffset: 300; filter: drop-shadow(0 0 4px #ffd86b) drop-shadow(0 0 10px #ff9a2a); }
.pack.cracking .pack-cracks { opacity: 1; }
.pack.cracking .pack-cracks path { animation: crack 1.8s cubic-bezier(.6, 0, .9, .4) forwards; }
.pack.cracking .pack-cracks path:nth-child(2n) { animation-delay: .3s; }
.pack.cracking .pack-cracks path:nth-child(3n) { animation-delay: .6s; }
@keyframes crack { to { stroke-dashoffset: 0; } }

.reveal-wrap { position: relative; }
.reveal-wrap .tcard { --w: min(270px, 64vw); }
.reveal-wrap.epic-aura::before {
  content: ''; position: absolute; inset: -50px; border-radius: 50%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 210, 100, .55), rgba(255, 140, 40, .15), transparent);
  animation: pulse 1.4s ease-in-out infinite alternate;
}

.rarity-banner {
  position: absolute; left: 50%; top: 50%; z-index: 35; pointer-events: none; white-space: nowrap;
  font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 8vw, 4.2rem); letter-spacing: .12em; text-transform: uppercase;
}
.rarity-banner.drawn { color: #f3e6c8; font-style: italic; text-shadow: 0 0 18px rgba(244, 162, 97, .9), 0 3px 0 #6b3b1f; }
.rarity-banner.holo { background: linear-gradient(90deg, #ff6ad5, #ad8cff, #94d0ff, #7fffd4, #fff36a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 18px rgba(173, 140, 255, .9)); }
.rarity-banner.epic { background: linear-gradient(180deg, #fffbe6, #ffd86b 50%, #c98a12); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(255, 190, 70, 1)) drop-shadow(0 4px 0 #6b3d00); }

.reveal-info {
  position: relative; z-index: 20; max-width: 560px; margin: 8px auto 0; padding: 22px 26px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px);
}
.reveal-info h3 { font-size: 1.6rem; margin: .3em 0 .2em; }
.keywords { font-family: var(--display); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.tag { display: inline-block; font-size: .85rem; padding: .15em .8em; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim); }
.tag.new { color: #1c1030; background: var(--gold-2); border-color: transparent; font-weight: 600; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(0); } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

.rarity-pill {
  display: inline-block; font-family: var(--display); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  padding: .3em 1em; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim); background: rgba(255, 255, 255, .04);
}
.rarity-pill.drawn { color: #3b2716; border-color: transparent; background: linear-gradient(90deg, #f3e6c8, #f4c99b, #f3e6c8); font-weight: 700; }
.rarity-pill.holo { color: #fff; border-color: transparent; background: linear-gradient(90deg, #ff6ad5, #ad8cff, #94d0ff, #7fffd4); background-size: 200%; animation: slide 3s linear infinite; text-shadow: 0 1px 2px #0006; }
.rarity-pill.epic { color: #3a2200; border-color: transparent; background: linear-gradient(90deg, #fff1b8, #ffd86b, #ffb627, #ffd86b, #fff1b8); background-size: 200%; animation: slide 2s linear infinite; font-weight: 700; }
@keyframes slide { to { background-position: 200% 0; } }

/* --- reading --- */
.reading-intro { max-width: 620px; margin: 0 auto; }
.reading-intro p { color: var(--ink-dim); }
.question-form { display: grid; gap: 14px; margin-top: 18px; }
.question-form textarea { resize: vertical; min-height: 80px; text-align: center; font-size: 1.1rem; }
.question-form .btn { justify-self: center; }
.reading-table { scroll-margin-top: 80px; }
.table-question { font-style: italic; font-size: 1.25rem; color: var(--gold-2); margin: 0 0 14px; }
.table-hint { color: var(--ink-dim); min-height: 1.6em; margin: 6px 0; }

.slots { display: flex; justify-content: center; gap: clamp(10px, 3vw, 40px); }
.slot { display: grid; justify-items: center; gap: 8px; }
.slot-card {
  width: clamp(86px, 24vw, 160px); aspect-ratio: 3 / 5; border-radius: 6% / 3.6%;
  border: 1px dashed var(--line); background: rgba(255, 255, 255, .02); display: grid; place-items: center;
  transition: box-shadow .6s, border-color .6s;
}
.slot.filled .slot-card { border-color: transparent; }
.slot.lit .slot-card { box-shadow: 0 0 50px rgba(233, 196, 106, .45); }
.slot-card .tcard { --w: 100%; }
.slot-label { font-family: var(--display); font-size: .85rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); line-height: 1.2; }
.slot-label small { display: block; font-family: var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink-dim); font-style: italic; font-size: .85rem; }

.fan-area { position: relative; height: clamp(170px, 22vw, 240px); margin-top: 10px; }
.reading-table.done .fan-area { display: none; }
.deck-pile { position: absolute; left: 50%; top: 10px; width: clamp(70px, 10vw, 110px); translate: -50% 0; aspect-ratio: 3 / 5; }
.deck-pile .tcard { --w: 100%; position: absolute; inset: 0; translate: 0 calc(var(--i) * -0.6px); }
.fan { position: absolute; inset: 0; }
.fan .fan-card {
  --w: clamp(56px, 9vw, 96px);
  position: absolute; left: 50%; top: 20px; margin-left: calc(var(--w) / -2); cursor: pointer;
  transform: translate(0, 0) rotate(0deg); opacity: 0;
  transition: transform .7s cubic-bezier(.2, 1.2, .4, 1) var(--d), opacity .4s var(--d), filter .2s;
}
.fan.dealt .fan-card { transform: translate(var(--x), var(--y)) rotate(var(--a)); opacity: 1; }
.fan.dealt .fan-card:hover { transform: translate(var(--x), calc(var(--y) - 22px)) rotate(var(--a)) scale(1.06); transition-delay: 0s; filter: drop-shadow(0 0 14px rgba(233, 196, 106, .8)); z-index: 2; }
.fan.gone .fan-card { transform: translate(var(--x), calc(var(--y) + 200px)) rotate(var(--a)); opacity: 0; transition-delay: calc(var(--d) * .3); }
.flyer { position: fixed; z-index: 25; pointer-events: none; transform-origin: center; margin: 0; }

.interpretation { max-width: 900px; margin: 30px auto 0; text-align: left; scroll-margin-top: 80px; }
.interpretation h3 { text-align: center; font-size: 1.6rem; color: var(--gold); }
.interp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.interp-card, .interp-summary { padding: 20px 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.interp-card h4 { font-size: 1.15rem; margin: .1em 0 .2em; }
.interp-card p:last-child, .interp-summary p:last-child { margin-bottom: 0; }
.interp-pos { font-family: var(--display); font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-dim); }
.rev { font-family: var(--serif); font-size: .85rem; font-weight: 400; font-style: italic; color: #ff9fb0; letter-spacing: 0; }
.interp-summary { margin-top: 16px; background: linear-gradient(160deg, rgba(60, 35, 120, .7), rgba(25, 14, 58, .7)); }
.interp-summary h4 { color: var(--gold); }
.advice { font-size: 1.1rem; color: var(--gold-2); }
.reveal-block { opacity: 0; transform: translateY(18px); }
.interpretation.show .reveal-block { animation: rise .8s cubic-bezier(.2, .8, .3, 1) var(--delay) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* --- collection --- */
.collection-head { margin-bottom: 18px; }
.progress { max-width: 460px; margin: 0 auto; }
.progress .bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: linear-gradient(90deg, #c99733, #fff1b8); box-shadow: 0 0 12px var(--gold); transition: width 1s; }
.progress p { color: var(--ink-dim); margin: .5em 0 0; font-size: .95rem; }
.progress b { color: var(--gold); }
.collection-groups section { margin-top: 28px; }
.collection-groups h3 { font-size: 1rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); text-align: left; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px; }
.coll-cell { position: relative; padding: 0; border: 0; background: none; cursor: pointer; transition: transform .2s; }
.coll-cell .tcard { --w: 100%; }
.coll-cell:not(.unknown):hover { transform: translateY(-4px) scale(1.04); z-index: 1; }
.coll-cell.unknown { cursor: default; opacity: .35; filter: grayscale(.6); }
.coll-unknown { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 2rem; color: var(--gold); }
.coll-badges { position: absolute; left: 0; right: 0; bottom: -8px; display: flex; justify-content: center; gap: 3px; }
.badge { font-family: var(--display); font-size: .65rem; min-width: 20px; padding: 1px 5px; border-radius: 999px; background: #2a1d4f; border: 1px solid var(--line); color: var(--ink-dim); }
.badge.drawn { background: #f3e6c8; color: #3b2716; border: 0; font-weight: 700; }
.badge.holo { background: linear-gradient(90deg, #ff6ad5, #94d0ff); color: #fff; border: 0; }
.badge.epic { background: linear-gradient(90deg, #fff1b8, #ffb627); color: #3a2200; border: 0; font-weight: 700; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 1, 12, .85); backdrop-filter: blur(6px); }
.modal-body {
  position: relative; display: flex; gap: 32px; align-items: center; max-width: 820px; width: 100%; max-height: 100%; overflow: auto;
  padding: 32px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); text-align: left;
  animation: rise .5s cubic-bezier(.2, .8, .3, 1);
}
.modal-card .tcard { --w: min(280px, 70vw); }
.modal-text h3 { font-size: 1.7rem; margin-top: .4em; }
.modal-text h5 { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); margin: 1em 0 .2em; }
.modal-text p { margin: 0 0 .4em; }
.rarity-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.rarity-tabs .rarity-pill { cursor: pointer; opacity: .55; }
.rarity-tabs .rarity-pill.active { opacity: 1; outline: 2px solid var(--gold-2); outline-offset: 2px; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--ink); font-size: 2rem; cursor: pointer; line-height: 1; }

/* --- small screens --- */
@media (max-width: 760px) {
  body { font-size: 17px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  nav { order: 3; width: 100%; justify-content: center; }
  nav a { padding: .45em .8em; font-size: .72rem; }
  .user #username { display: none; }
  .user { margin-left: auto; }
  .view { padding: 20px 16px 60px; }
  .pack-stage { min-height: 420px; }
  .pack { width: 200px; height: 300px; }
  .interp-grid { grid-template-columns: 1fr; }
  .modal-body { flex-direction: column; padding: 24px 18px; }
  .modal-card .tcard { --w: min(220px, 60vw); }
  .collection-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .sky, .pack, .pack-sheen, .stage-rays { animation: none !important; }
}

/* --- language switch --- */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  background: none; border: 0; color: var(--ink-dim); font-family: var(--display); font-size: .7rem; letter-spacing: .1em;
  padding: .35em .7em; cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--gold); color: #1c1030; font-weight: 700; }
.auth-card { position: relative; }
.auth-lang { position: absolute; top: 14px; right: 14px; }

/* --- reading extras --- */
.deck-info { color: var(--ink-dim); font-size: .95rem; margin-top: 18px; }
.deck-info b { color: var(--gold); }
.slot-tag { min-height: 1.6em; }
.slot-tag .rarity-pill { font-size: .6rem; letter-spacing: .1em; padding: .25em .7em; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.interp-pos .rarity-pill { font-size: .58rem; padding: .15em .6em; vertical-align: middle; }
.interp-card.adv.drawn { border-color: rgba(244, 201, 155, .55); }
.interp-card.adv.holo { border-color: rgba(173, 140, 255, .6); box-shadow: 0 0 24px rgba(173, 140, 255, .15); }
.interp-card.adv.epic { border-color: rgba(255, 216, 107, .7); box-shadow: 0 0 30px rgba(255, 200, 90, .2); }

/* --- collection: showcase, tabs, catalogue --- */
.showcase { margin-bottom: 26px; }
.showcase-text { color: var(--ink-dim); margin: 0 auto 18px; max-width: 560px; }
.showcase-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(10px, 3vw, 28px); max-width: 860px; margin: 0 auto; }
.showcase-item { display: grid; justify-items: center; gap: 8px; cursor: pointer; }
.showcase-item small { color: var(--ink-dim); font-size: .85rem; }
.showcase-card { width: 100%; max-width: 180px; }
.showcase-card .tcard { --w: 100%; }
.coll-tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; margin-bottom: 16px; }
.coll-tabs button {
  background: none; border: 0; color: var(--ink-dim); font-family: var(--display); font-size: .78rem; letter-spacing: .12em;
  text-transform: uppercase; padding: .55em 1.2em; border-radius: 999px; cursor: pointer;
}
.coll-tabs button[aria-selected="true"] { background: linear-gradient(135deg, #f6d77f, #c99733); color: #1c1030; font-weight: 700; }
.rarity-counts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.catalog-text { color: var(--ink-dim); margin: 0 0 10px; }
.catalog-tabs { justify-content: center; }
.catalog-tabs .rarity-pill, .rarity-tabs .rarity-pill { cursor: pointer; font-size: .72rem; }
.rarity-tabs .rarity-pill.missing { border-style: dashed; }
.owned-line { color: var(--ink-dim); font-style: italic; margin: 8px 0 0; }

@media (max-width: 760px) {
  .showcase-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .showcase-card { max-width: 140px; }
  .user .lang-switch button { padding: .3em .55em; }
}
