:root {
  --bg: #05060f;
  --panel: #0d1124;
  --panel-2: #141a33;
  --line: #232b4d;
  --text: #e6e9f5;
  --muted: #8b93b8;
  --accent: #7c9cff;
  --t0: #9ca3af;
  --t1: #4ade80;
  --t2: #60a5fa;
  --t3: #c084fc;
  --t4: #fbbf24;
  --t5: #f43f5e;
  --display: 'Orbitron', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Starfield ---------- */
/* ---------- Animated background ----------
 * Layers, back to front: drifting nebula clouds, three parallax star fields, a twinkle field,
 * and occasional shooting stars (added by JS). Every loop is seamless:
 *  - star fields slide exactly one tile, so the end frame matches the start
 *  - nebulae move with "alternate", easing back and forth with no jump
 */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse at 15% -10%, #1d2260 0, transparent 55%),
    radial-gradient(ellipse at 100% 110%, #3a0f4d 0, transparent 50%),
    var(--bg);
}
.px { position: absolute; inset: 0; will-change: transform; backface-visibility: hidden; }
.sky-neb {
  position: absolute; border-radius: 50%; filter: blur(60px); will-change: transform, opacity;
  animation: neb-drift 30s ease-in-out infinite alternate;
}
.sky-neb.n1 { width: 58vmax; height: 42vmax; left: -12vmax; top: -10vmax; background: radial-gradient(closest-side, rgba(84, 100, 235, .44), transparent); }
.sky-neb.n2 { width: 52vmax; height: 44vmax; right: -14vmax; bottom: -12vmax; background: radial-gradient(closest-side, rgba(185, 64, 205, .38), transparent); animation-duration: 36s; animation-delay: -12s; }
.sky-neb.n3 { width: 42vmax; height: 32vmax; left: 32%; top: 28%; background: radial-gradient(closest-side, rgba(40, 165, 205, .24), transparent); animation-duration: 42s; animation-delay: -24s; }
@keyframes neb-drift {
  0%   { transform: translate(0, 0) scale(1) rotate(0deg); opacity: .7; }
  50%  { transform: translate(7vmax, 4vmax) scale(1.18) rotate(10deg); opacity: 1; }
  100% { transform: translate(-5vmax, 7vmax) scale(.92) rotate(-8deg); opacity: .65; }
}

/* Star fields: oversized by one tile and slid by exactly one tile -> seamless */
.stars {
  position: absolute; top: 0; left: 0; will-change: transform;
  width: calc(100% + var(--tw)); height: calc(100% + var(--th));
  background-size: var(--tw) var(--th);
  animation: star-drift var(--dur) linear infinite;
}
/* Right to left: slide exactly one tile width, so the loop is seamless */
@keyframes star-drift { to { transform: translateX(calc(-1 * var(--tw))); } }
.stars.s1 {
  --tw: 230px; --th: 210px; --dur: 66s; opacity: .6;
  background-image:
    radial-gradient(1px 1px at 23px 41px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #cfd8ff, transparent),
    radial-gradient(1px 1px at 60px 170px, #ffe9c4, transparent),
    radial-gradient(1px 1px at 200px 20px, #fff, transparent);
}
.stars.s2 {
  --tw: 370px; --th: 330px; --dur: 41s; opacity: .78;
  background-image:
    radial-gradient(1.8px 1.8px at 90px 60px, #fff, transparent),
    radial-gradient(1.4px 1.4px at 260px 190px, #dbe4ff, transparent),
    radial-gradient(1.8px 1.8px at 330px 300px, #fff, transparent);
}
.stars.s3 {
  --tw: 560px; --th: 500px; --dur: 25s; opacity: .95;
  background-image:
    radial-gradient(2.5px 2.5px at 140px 380px, #fff, transparent),
    radial-gradient(2.2px 2.2px at 470px 120px, #e9e2ff, transparent);
}
/* Twinkle field: fades in and out (moves only with scroll parallax) */
.stars.tw {
  --tw: 410px; --th: 390px; animation: twinkle 3.6s ease-in-out infinite alternate;
  width: 100%; height: calc(100% + var(--th)); opacity: .3;
  background-image:
    radial-gradient(2px 2px at 50px 300px, #fff, transparent),
    radial-gradient(2px 2px at 300px 70px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 380px 250px, #cfe0ff, transparent);
}
.stars.tw2 { animation-duration: 5.2s; animation-delay: -2.5s; background-position: 200px 160px; }
@keyframes twinkle { from { opacity: .08; } to { opacity: 1; } }

/* Shooting star (spawned occasionally by JS) */
.shooting-star {
  position: absolute; width: 140px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(220, 230, 255, .9));
  filter: drop-shadow(0 0 6px rgba(200, 215, 255, .8));
}
.shooting-star::after {
  content: ""; position: absolute; right: -2px; top: -2px; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px 3px rgba(210, 225, 255, .9);
}

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 24, .7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.logo {
  font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: .12em;
  display: flex; align-items: center;
}
.logo-space {
  background: linear-gradient(90deg, #8fb3ff, #d48bff 60%, #ff8fb1);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-dle { color: #fff; text-shadow: 0 0 14px rgba(255, 255, 255, .25); }
.logo .dev-tag { margin-left: 10px; }
.brand { display: flex; align-items: baseline; gap: 16px; min-width: 0; }
.tagline { font-size: 13px; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.dev-tag {
  font-size: 11px; letter-spacing: .1em; padding: 2px 6px; border-radius: 4px;
  background: var(--t5); color: #fff; -webkit-text-fill-color: #fff;
}
.stats { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-family: var(--display); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-value.sp { color: #ffd166; }

/* ---------- Now-playing toast ----------
 * Condensed: icon + title. Expanded (new song, or hover): adds "Now playing" and the artist.
 * Everything that changes size transitions (max-width, grid rows, padding), so it grows and
 * shrinks smoothly instead of snapping.
 */
.music-toast {
  position: fixed; left: 24px; top: 86px; z-index: 25;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 7px; border-radius: 999px;
  background: rgba(13, 17, 36, .82); border: 1px solid rgba(124, 156, 255, .35);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45), 0 0 18px -6px rgba(124, 156, 255, .5);
  cursor: default; user-select: none;
  transition: padding .45s cubic-bezier(.16, 1, .3, 1), border-radius .45s cubic-bezier(.16, 1, .3, 1), border-color .3s ease, box-shadow .3s ease;
}
.music-toast.expanded, .music-toast:hover {
  padding: 10px 18px 10px 10px; border-radius: 18px;
  border-color: rgba(124, 156, 255, .6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 24px -4px rgba(124, 156, 255, .6);
}
/* Animated "music" icon: equalizer bars in a glowing badge */
.mt-icon {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: linear-gradient(135deg, #5b6cff, #a24bff 60%, #ff6fa8);
  box-shadow: 0 0 12px rgba(162, 75, 255, .6);
  transition: width .45s cubic-bezier(.16, 1, .3, 1), height .45s cubic-bezier(.16, 1, .3, 1);
}
.music-toast.expanded .mt-icon, .music-toast:hover .mt-icon { width: 40px; height: 40px; }
.mt-icon i {
  display: block; width: 3px; height: 40%; border-radius: 2px; background: #fff;
  animation: eq 1s ease-in-out infinite alternate;
}
.mt-icon i:nth-child(2) { animation-duration: .7s; animation-delay: -.3s; }
.mt-icon i:nth-child(3) { animation-duration: .9s; animation-delay: -.6s; }
.mt-icon i:nth-child(4) { animation-duration: .6s; animation-delay: -.15s; }
@keyframes eq { from { height: 22%; } to { height: 62%; } }

.mt-text {
  display: grid; grid-template-rows: 0fr auto 0fr; min-width: 0;
  max-width: 190px;
  transition: grid-template-rows .45s cubic-bezier(.16, 1, .3, 1), max-width .45s cubic-bezier(.16, 1, .3, 1);
}
.music-toast.expanded .mt-text, .music-toast:hover .mt-text { grid-template-rows: 1fr auto 1fr; max-width: 340px; }
.mt-eyebrow, .mt-artist-wrap { overflow: hidden; min-height: 0; }
.mt-eyebrow span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #a9bcff;
  opacity: 0; transition: opacity .3s ease;
}
.mt-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-artist { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .3s ease; }
.music-toast.expanded .mt-eyebrow span, .music-toast:hover .mt-eyebrow span,
.music-toast.expanded .mt-artist, .music-toast:hover .mt-artist { opacity: 1; transition-delay: .12s; }
.music-toast.expanded .mt-title, .music-toast:hover .mt-title { font-size: 14px; }

/* ---------- Tabs ---------- */
.tabs { position: relative; display: flex; justify-content: center; gap: 6px; padding: 16px 16px 0; }
.tab {
  position: relative; z-index: 1;
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 8px 18px; cursor: pointer; color: var(--muted); font-weight: 600;
  transition: color .3s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab-ink {
  position: absolute; left: 0; top: 0; z-index: 0;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 0 18px rgba(124, 156, 255, .18);
  transition: transform .5s cubic-bezier(.16, 1, .3, 1), width .5s cubic-bezier(.16, 1, .3, 1);
}

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.view { display: none; }
.view.active { display: block; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 18px; cursor: pointer; font-weight: 600;
  transition: border-color .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease, filter .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.96); }
.btn.primary:hover { box-shadow: 0 6px 24px rgba(140, 90, 255, .45); filter: brightness(1.1); }
.modal-close { transition: color .2s ease, transform .3s ease; }
.modal-close:hover { transform: rotate(90deg); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, #5b6cff, #a24bff); border-color: transparent; }
.btn.danger { border-color: #7f1d1d; color: #fca5a5; }
.btn.danger:hover { background: #2a0d12; }
.muted { color: var(--muted); }

/* ---------- Pack ---------- */
.pack-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 20px; }
.pack-stage .pack { animation: float 3.5s ease-in-out infinite; }
.pack {
  position: relative;
  width: 230px; aspect-ratio: 5 / 8; border-radius: 18px;
  padding: 0; border: none; background: none;
  box-shadow: 0 0 40px rgba(124, 92, 255, .45), 0 20px 50px rgba(0, 0, 0, .6);
  cursor: pointer;
  transition: box-shadow .35s ease, filter .3s, scale .35s cubic-bezier(.34, 1.56, .64, 1);
}
.pack:hover:not(.disabled):not(.busy) { scale: 1.05; box-shadow: 0 0 70px rgba(160, 110, 255, .75), 0 24px 60px rgba(0,0,0,.6); }
.pack.busy { animation: none; pointer-events: none; box-shadow: 0 0 80px var(--gc, #a78bfa); }
.pack.disabled { filter: grayscale(.75) brightness(.55); cursor: not-allowed; animation: none; }

/* The pack is two copies of the same face, clipped along a zig-zag perforation so the top can tear off */
.pack-half {
  position: absolute; inset: 0; border-radius: 18px; overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .25);
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,.25), transparent 35%),
    linear-gradient(150deg, #2b1f7a 0%, #1a4c9a 40%, #6a1d84 75%, #b32a6b 100%);
}
.pack-upper {
  clip-path: polygon(0 0, 100% 0, 100% 15%, 95% 18%, 90% 15%, 85% 18%, 80% 15%, 75% 18%, 70% 15%, 65% 18%, 60% 15%, 55% 18%, 50% 15%, 45% 18%, 40% 15%, 35% 18%, 30% 15%, 25% 18%, 20% 15%, 15% 18%, 10% 15%, 5% 18%, 0 15%);
  transform-origin: 80% 15%;
}
.pack-lower {
  clip-path: polygon(0 15%, 5% 18%, 10% 15%, 15% 18%, 20% 15%, 25% 18%, 30% 15%, 35% 18%, 40% 15%, 45% 18%, 50% 15%, 55% 18%, 60% 15%, 65% 18%, 70% 15%, 75% 18%, 80% 15%, 85% 18%, 90% 15%, 95% 18%, 100% 15%, 100% 100%, 0 100%);
}
.pack-lower::after {
  content: ""; position: absolute; left: 3%; right: 3%; top: 16.5%;
  border-top: 1px dashed rgba(255, 255, 255, .28);
}
.pack-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 22px 12px; color: var(--text);
}
.pack-glow {
  position: absolute; left: 50%; top: 16.5%; z-index: 3;
  width: 120%; aspect-ratio: 3 / 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse at center, #fff 0 12%, var(--gc, #c4b5fd) 35%, transparent 70%);
  opacity: 0; transform: translate(-50%, -50%) scale(.2);
}
/* Shine stripe: starts and ends fully off the pack, so the loop restarts invisibly */
.pack-shine {
  position: absolute; top: -25%; bottom: -25%; left: 0; width: 35%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.32), transparent);
  transform: translateX(-320%) skewX(-20deg);
  animation: shine 3.6s ease-in-out infinite;
}
.pack.disabled .pack-shine { display: none; }
.pack-top, .pack-count { font-family: var(--display); font-size: 12px; letter-spacing: .3em; opacity: .85; position: relative; }
.pack-emblem { font-size: 72px; line-height: 1; text-shadow: 0 0 30px #fff, 0 0 60px #b48cff; position: relative; animation: emblem 2.6s ease-in-out infinite; }
.pack-title { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: .14em; position: relative; }
@keyframes shine { 0% { transform: translateX(-320%) skewX(-20deg); } 55%, 100% { transform: translateX(420%) skewX(-20deg); } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes emblem { 50% { transform: scale(1.08); text-shadow: 0 0 40px #fff, 0 0 80px #c9a8ff; } }
/* ---------- First-join tutorial ---------- */
.tut { position: fixed; inset: 0; z-index: 48; pointer-events: none; }
.tut-ring {
  position: fixed; border-radius: 16px; pointer-events: none;
  border: 2px solid #5eead4;
  box-shadow: 0 0 0 4px rgba(94, 234, 212, .2), 0 0 24px rgba(94, 234, 212, .55);
  animation: tut-pulse 1.6s ease-in-out infinite;
}
/* Info steps dim everything except the highlighted area */
.tut.mode-info .tut-ring { box-shadow: 0 0 0 4px rgba(94, 234, 212, .2), 0 0 24px rgba(94, 234, 212, .55), 0 0 0 9999px rgba(3, 4, 12, .62); animation: none; }
@keyframes tut-pulse {
  50% { box-shadow: 0 0 0 8px rgba(94, 234, 212, .12), 0 0 34px rgba(94, 234, 212, .75); }
}
.tut-bubble {
  position: fixed; max-width: min(340px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 14px;
  background: #0f1a2e; border: 1px solid rgba(94, 234, 212, .6); color: var(--text);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .55), 0 0 22px -6px rgba(94, 234, 212, .6);
  font-size: 15px; line-height: 1.5; pointer-events: auto;
  animation: tut-bob 2.2s ease-in-out infinite;
}
.tut.mode-point .tut-bubble { max-width: min(260px, calc(100vw - 24px)); font-weight: 600; text-align: center; pointer-events: none; }
.tut-bubble b { color: #5eead4; }
/* Arrow: points down at the target when above it, up when below */
.tut-bubble::after {
  content: ""; position: absolute; left: calc(var(--ax, 50%) - 8px); bottom: -8px;
  width: 14px; height: 14px; transform: rotate(45deg);
  background: #0f1a2e; border-right: 1px solid rgba(94, 234, 212, .6); border-bottom: 1px solid rgba(94, 234, 212, .6);
}
.tut-bubble.below::after { bottom: auto; top: -8px; border: none; border-left: 1px solid rgba(94, 234, 212, .6); border-top: 1px solid rgba(94, 234, 212, .6); }
.tut-ok { margin-top: 12px; padding: 7px 16px; }
@keyframes tut-bob { 50% { translate: 0 -4px; } }
/* Per-card "Tap" badge while a card is still face down */
.tut-tap {
  position: absolute; left: 50%; bottom: 10%; z-index: 6; pointer-events: none;
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px;
  font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #06231f;
  background: #5eead4; box-shadow: 0 0 16px rgba(94, 234, 212, .7);
  transform: translateX(-50%);
  animation: tut-tap-bounce 1.1s ease-in-out infinite;
  transition: opacity .25s ease;
}
.tut-hand { font-size: 14px; }
.card:not(.facedown) .tut-tap { opacity: 0; animation: none; }
@keyframes tut-tap-bounce { 50% { translate: 0 -6px; } }

/* Pack storage: pips (one per stored pack), count, refill timer */
.pack-status { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 28px; }
.pack-pips { display: flex; gap: 8px; }
.pip {
  width: 16px; height: 24px; border-radius: 4px;
  border: 1.5px solid #39417a; background: rgba(13, 17, 36, .6);
  transition: background-color .4s ease, border-color .4s ease, box-shadow .4s ease;
}
.pip.full {
  border-color: rgba(255, 255, 255, .55);
  background: linear-gradient(150deg, #2b1f7a, #1a4c9a 40%, #6a1d84 75%, #b32a6b);
  box-shadow: 0 0 10px rgba(160, 110, 255, .55);
}
.pack-line { font-size: 18px; font-weight: 600; }
.pack-line .ready { color: #a7f3d0; }
.pack-line .of { color: var(--muted); font-weight: 500; }
.pack-line .empty-msg { color: #fca5a5; }
.pack-timer { font-size: 14px; color: var(--muted); }
.pack-timer .timer { font-size: 15px; }
/* Count badge on the pack itself */
.pack-badge {
  position: absolute; top: -10px; right: -10px; z-index: 4;
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 14px; color: #0a0d1d;
  background: linear-gradient(135deg, #a7f3d0, #5eead4); border: 2px solid #0a0d1d;
  box-shadow: 0 0 14px rgba(94, 234, 212, .6);
  transition: opacity .25s ease, background .3s ease;
}
.pack-badge.empty { background: #4b5280; color: #cfd3ef; box-shadow: none; }
.pack.busy .pack-badge { opacity: 0; }
.fx-float small.dupe { color: #9ca3af; text-shadow: none; }
.timer { font-family: var(--display); color: #ffd166; font-variant-numeric: tabular-nums; }
.pack-hint { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Reveal ---------- */
.reveal-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.reveal-tally strong { color: #ffd166; font-family: var(--display); }
.reveal-tally span { color: #f9a8d4; }
.reveal-actions { display: flex; gap: 8px; }
/* Card width follows the window height so both rows fit without scrolling:
 * two rows = 3.2 × width, plus ~310px for the header, pack bar, bonus row and hint. */
.reveal-grid {
  --cw: min(200px, max(124px, calc((100vh - 310px) / 3.2)));
  display: grid; gap: 16px; justify-content: center;
  grid-template-columns: repeat(5, minmax(0, var(--cw)));
}
@supports (height: 100dvh) {
  .reveal-grid { --cw: min(200px, max(124px, calc((100dvh - 310px) / 3.2))); }
}
.reveal-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.reveal-share { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.share-btn {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-weight: 700;
  color: #8fb3ff; text-decoration: underline; text-underline-offset: 3px;
  display: inline-block; transition: color .2s ease;
}
.share-btn:hover { color: #c4b5fd; }
.share-btn.copied { color: #5eead4; text-decoration: none; }
.reveal-tally strong { display: inline-block; }
.reveal-mult { display: inline-block; font-style: normal; font-family: var(--display); font-weight: 700; color: #5eead4; text-shadow: 0 0 10px rgba(94, 234, 212, .6); }
.reveal-mult:empty { display: none; }

/* ---------- Bonuses ---------- */
.bonus-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: -8px 0 16px; min-height: 0; }
.bonus-row:empty { display: none; }
.bonus-wrap { position: relative; z-index: 20; display: inline-flex; }
.bonus-wrap.open { z-index: 30; }
.bonus-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, rgba(94, 234, 212, .16), rgba(124, 156, 255, .16));
  border: 1px solid rgba(94, 234, 212, .55);
  box-shadow: 0 0 16px -4px rgba(94, 234, 212, .7);
  cursor: pointer;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease, background-color .25s ease;
}
.bonus-chip:hover { transform: translateY(-2px); box-shadow: 0 0 22px -2px rgba(94, 234, 212, .85); }
.bonus-chip:active { transform: scale(.96); }
.bonus-chip b { font-family: var(--display); color: #5eead4; }
.bc-caret { font-size: 10px; color: #5eead4; opacity: .8; transition: transform .25s ease; }
.bonus-wrap.open .bc-caret { transform: rotate(180deg); }

/* Pop-up explaining a bonus */
.bonus-pop {
  position: absolute; top: calc(100% + 12px); width: 320px; max-width: calc(100vw - 24px);
  padding: 14px 16px; border-radius: 14px; text-align: left;
  background: #0d1426; border: 1px solid rgba(94, 234, 212, .45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .6), 0 0 26px -6px rgba(94, 234, 212, .5);
  transform-origin: var(--ax, 50%) 0;
}
.bonus-pop::before {
  content: ""; position: absolute; top: -7px; left: calc(var(--ax, 50%) - 6px);
  width: 12px; height: 12px; transform: rotate(45deg);
  background: #0d1426; border-left: 1px solid rgba(94, 234, 212, .45); border-top: 1px solid rgba(94, 234, 212, .45);
}
.bp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bp-icon { font-size: 18px; }
.bp-name { font-family: var(--display); font-weight: 700; font-size: 15px; flex: 1; }
.bp-mult { font-family: var(--display); font-weight: 700; color: #5eead4; font-size: 15px; }
.bp-desc { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.bp-why {
  margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  background: rgba(94, 234, 212, .08); border-left: 3px solid #5eead4; color: #d7fbf5;
}
.bp-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.bp-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bp-list li {
  --rc: var(--t0);
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--rc);
  transition: background-color .2s ease, transform .2s ease, border-color .2s ease;
}
.bp-list li.t1 { --rc: var(--t1); } .bp-list li.t2 { --rc: var(--t2); } .bp-list li.t3 { --rc: var(--t3); }
.bp-list li.t4 { --rc: var(--t4); } .bp-list li.t5 { --rc: var(--t5); }
.bp-list li:hover, .bp-list li:focus-visible { background: #1a2246; transform: translateX(3px); outline: none; border-color: rgba(94, 234, 212, .4); border-left-color: var(--rc); }
.bp-cat { font-size: 16px; }
.bp-cname { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; line-height: 1.25; }
.bp-cname small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.bp-tier { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--rc); }
.bp-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.bp-foot b { color: var(--text); }
.fx-bonus {
  position: absolute; white-space: nowrap; padding: 6px 14px; border-radius: 999px;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .04em;
  color: #ecfeff; background: rgba(8, 40, 44, .85); border: 1px solid #5eead4;
  box-shadow: 0 0 24px rgba(94, 234, 212, .6);
}
.fx-bonus b { color: #5eead4; }
.fx-bonus-pay { font-size: 20px; color: #5eead4; text-shadow: 0 0 14px rgba(94, 234, 212, .8), 0 2px 4px rgba(0,0,0,.8); }
#bonus-table td { white-space: normal; vertical-align: top; }
#bonus-table .bt-name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 2px; }
/* Undiscovered bonuses look like locked cards: dim, striped, name hidden */
#bonus-table tr.locked td { background: repeating-linear-gradient(45deg, rgba(11, 14, 31, .6) 0 8px, rgba(14, 18, 38, .6) 8px 16px); }
#bonus-table tr.locked .bt-name { color: #4a5285; letter-spacing: .1em; }
#bonus-table tr.locked .bt-desc { color: #4a5285; font-style: italic; }
#bonus-table tr.locked .bt-mult, #bonus-table tr.locked td:last-child { opacity: .6; }
.bt-q {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; border-radius: 5px;
  font-family: var(--display); font-size: 11px; color: #4a5285; border: 1px solid #2a3260; letter-spacing: 0;
}
.bonus-found { font-family: 'Inter', system-ui, sans-serif; font-size: 12px; font-weight: 600; letter-spacing: 0; color: #5eead4; margin-left: 8px; vertical-align: middle; }
#bonus-table .bt-name { white-space: nowrap; font-weight: 600; }
#bonus-table .bt-desc { color: var(--muted); min-width: 260px; }
#bonus-table .bt-mult { font-family: var(--display); color: #5eead4; white-space: nowrap; }
.reveal-grid .card.flipping { z-index: 3; }

/* ---------- Card ---------- */
.card {
  --rc: var(--t0);
  position: relative; width: 100%; aspect-ratio: 5 / 8;
  perspective: 1200px;
  container-type: inline-size;
  cursor: pointer;
}
.card.t1 { --rc: var(--t1); } .card.t2 { --rc: var(--t2); } .card.t3 { --rc: var(--t3); }
.card.t4 { --rc: var(--t4); } .card.t5 { --rc: var(--t5); }

.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: translateY(var(--lift, 0)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .45s cubic-bezier(.16, 1, .3, 1);
  font-size: 7cqw; /* base size for all card text; the art takes whatever space is left */
}
.card.tilting { --lift: -6px; z-index: 2; }
.card.tilting .card-inner { transition-duration: .12s; }
.card.facedown .card-inner { transform: rotateY(180deg); }
.card.facedown:hover .card-inner { transform: rotateY(180deg) translateY(-6px) scale(1.03); }

/* Glare that follows the mouse */
.card-front::before {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; border-radius: inherit;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .2), transparent 55%);
  opacity: 0; transition: opacity .35s ease;
}
.card.tilting .card-front::before { opacity: 1; }

.card-face {
  position: absolute; inset: 0;
  border-radius: 7cqw;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.card-front {
  display: flex; flex-direction: column;
  padding: 5cqw;
  background: linear-gradient(170deg, #161c38, #0a0d1d 70%);
  border: 2px solid var(--rc);
  box-shadow: inset 0 0 20px rgba(0,0,0,.6);
}
.card-back {
  transform: rotateY(180deg);
  border: 2px solid #3b3f7a;
  background:
    radial-gradient(circle at 50% 50%, rgba(160,120,255,.35), transparent 50%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #1b1650, #0b1030 60%, #2a0f3d);
  display: grid; place-items: center;
}
.back-inner { display: flex; flex-direction: column; align-items: center; gap: 4cqw; }
.back-emblem { font-size: 3.2em; text-shadow: 0 0 20px #fff, 0 0 40px #9f7aff; }
.back-title { font-family: var(--display); font-weight: 800; letter-spacing: .15em; font-size: 1em; opacity: .85; }

/* Rarity glow on front */
.card.t2 .card-front { box-shadow: 0 0 12px -2px var(--rc), inset 0 0 20px rgba(0,0,0,.6); }
.card.t3 .card-front { box-shadow: 0 0 18px -2px var(--rc), inset 0 0 24px rgba(192,132,252,.15); }
.card.t4 .card-front { box-shadow: 0 0 26px -2px var(--rc), inset 0 0 30px rgba(251,191,36,.18); }
.card.t4 .card-front::after,
.card.t5 .card-front::after {
  content: ""; position: absolute; top: -15%; bottom: -15%; left: 0; width: 45%; pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.17), transparent);
  transform: translateX(-260%) skewX(-18deg);
  animation: foil 3.6s ease-in-out infinite;
}
@property --ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.card.t5 .card-front {
  border-color: transparent;
  background:
    linear-gradient(170deg, #1d1530, #0c0a1d 70%) padding-box,
    conic-gradient(from var(--ang), #f43f5e, #fbbf24, #4ade80, #60a5fa, #c084fc, #f43f5e) border-box;
  box-shadow: 0 0 30px -2px rgba(244,63,94,.7), inset 0 0 30px rgba(244,63,94,.2);
  animation: spin-border 4s linear infinite;
}
@keyframes spin-border { to { --ang: 360deg; } }
@keyframes foil { 0% { transform: translateX(-260%) skewX(-18deg); } 60%, 100% { transform: translateX(360%) skewX(-18deg); } }

.card-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.cat-badge {
  font-size: .68em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--cat); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tier-tag {
  font-size: .62em; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: #0a0d1d; background: var(--rc); padding: .15em .5em; border-radius: 1em; white-space: nowrap;
}
.card-name {
  font-weight: 700; font-size: 1.2em; line-height: 1.15; margin-top: .45em;
  min-height: 2.3em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-hint { color: var(--muted); font-weight: 600; letter-spacing: .04em; transition: color .25s ease; }
.card:hover .card-hint { color: var(--text); }
.card-sub { font-size: .66em; color: var(--muted); margin-bottom: .35em; }
.card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: .3em;
  font-size: .62em; padding: .4em 0; border-top: 1px solid rgba(255,255,255,.08); border-bottom: 1px solid rgba(255,255,255,.08);
}
.card-stats label { display: block; color: var(--muted); text-transform: uppercase; font-size: .85em; letter-spacing: .05em; }
.card-stats span { font-weight: 600; }
.card-fact {
  flex: 1; margin: .45em 0 .2em; font-size: .64em; line-height: 1.35; color: #c6cbe6; font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot {
  margin-top: .35em; padding-top: .45em; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .7em; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--rc);
}
.card-sp { color: #ffd166; font-family: var(--display); }

.badge-new, .badge-count {
  position: absolute; z-index: 5; top: -8px;
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.badge-new { left: -6px; background: #ec4899; color: #fff; letter-spacing: .05em; opacity: 0; transition: opacity .3s .4s; }
.card.revealed .badge-new { opacity: 1; }
.badge-count { right: -6px; background: var(--accent); color: #0a0d1d; }

/* ---------- Art (placeholders until real images) ---------- */
.art {
  position: relative; flex: 1 1 auto; min-height: 0;
  margin-top: 3cqw; border-radius: 4cqw; overflow: hidden;
  display: grid; place-items: center;
  background:
    radial-gradient(1px 1px at 12% 20%, #fff, transparent),
    radial-gradient(1px 1px at 80% 30%, #fff, transparent),
    radial-gradient(1px 1px at 30% 80%, #dbe4ff, transparent),
    radial-gradient(1px 1px at 65% 70%, #fff, transparent),
    radial-gradient(1px 1px at 90% 85%, #fff, transparent),
    radial-gradient(ellipse at 50% 50%, hsl(var(--h) 60% 12%), #03040b 75%);
}
.art > i { display: block; position: relative; }

/* Planet */
.art-planet > i {
  width: 52%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, hsl(var(--h) 75% 78%), hsl(var(--h) 60% 48%) 45%, hsl(var(--h) 60% 14%) 100%);
  box-shadow: inset -10px -8px 18px rgba(0,0,0,.65), 0 0 22px hsl(var(--h) 70% 50% / .35);
}
.art-planet.banded > i {
  background:
    repeating-linear-gradient(calc(var(--tilt) * .3), transparent 0 7%, hsl(calc(var(--h) + 20) 60% 30% / .35) 7% 11%, transparent 11% 16%),
    radial-gradient(circle at 35% 30%, hsl(var(--h) 75% 78%), hsl(var(--h) 60% 48%) 45%, hsl(var(--h) 60% 14%) 100%);
}
.art-planet.ringed::after {
  content: ""; position: absolute; width: 88%; height: 20%;
  border-radius: 50%; border: 3px solid hsl(var(--h) 45% 75% / .75);
  transform: rotate(-16deg);
  box-shadow: 0 0 8px hsl(var(--h) 45% 75% / .4);
}

/* Star */
.art-star > i {
  width: 34%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 22%, hsl(var(--h) 100% 75%) 45%, hsl(var(--h) 100% 52%) 72%);
  box-shadow: 0 0 22px 8px hsl(var(--h) 100% 62% / .8), 0 0 60px 22px hsl(var(--h) 100% 50% / .35);
}
.art-star::before, .art-star::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 92%; height: 2px; transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, hsl(var(--h) 100% 85% / .9), transparent);
}
.art-star::after { transform: translate(-50%, -50%) rotate(90deg); width: 70%; }

/* Galaxy */
/* A square disc squashed into perspective; the arms spin inside a circular mask, so rotation is seamless */
.art-galaxy > i {
  width: 80%; aspect-ratio: 1; border-radius: 50%;
  transform: rotate(var(--tilt)) scaleY(.42);
  background: radial-gradient(circle, #fff 0 5%, hsl(var(--h) 80% 80%) 12%, hsl(var(--h) 70% 55% / .55) 34%, transparent 70%);
}
.art-galaxy > i::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, hsl(var(--h) 85% 72% / .45) 0 10deg, transparent 10deg 30deg);
  -webkit-mask: radial-gradient(circle closest-side, #000 25%, transparent 100%);
  mask: radial-gradient(circle closest-side, #000 25%, transparent 100%);
  animation: rotate 40s linear infinite;
}
.art-galaxy.elliptical > i {
  width: 62%; transform: rotate(var(--tilt)) scaleY(.7);
  background: radial-gradient(circle, #fff 0 6%, hsl(var(--h) 80% 75%) 18%, hsl(var(--h) 60% 50% / .45) 45%, transparent 72%);
}
.art-galaxy.elliptical > i::before { display: none; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* Black hole */
.art-blackhole::before {
  content: ""; position: absolute; width: 92%; height: 16%; border-radius: 50%;
  transform: rotate(calc(var(--tilt) * .4));
  background: radial-gradient(ellipse at center, hsl(var(--h) 100% 85%), hsl(var(--h) 100% 55% / .75) 45%, transparent 72%);
}
.art-blackhole > i {
  width: 40%; aspect-ratio: 1; border-radius: 50%; background: #000; z-index: 1;
  box-shadow: 0 0 0 2px hsl(var(--h) 100% 78%), 0 0 16px 5px hsl(var(--h) 100% 58%), 0 0 42px 14px hsl(var(--h) 90% 42% / .55);
}

/* Nebula */
.art-nebula {
  background:
    radial-gradient(circle at 30% 40%, hsl(var(--h) 90% 60% / .75), transparent 42%),
    radial-gradient(circle at 70% 62%, hsl(calc(var(--h) + 60) 90% 58% / .6), transparent 46%),
    radial-gradient(circle at 55% 30%, hsl(calc(var(--h) + 160) 80% 55% / .4), transparent 40%),
    radial-gradient(1px 1px at 12% 80%, #fff, transparent),
    radial-gradient(1px 1px at 85% 20%, #fff, transparent),
    #04050d;
}
.art-nebula > i { width: 5%; aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: 0 0 10px 3px #fff; }
.art-nebula.ringneb {
  background:
    radial-gradient(circle at 50% 50%, transparent 18%, hsl(var(--h) 90% 62% / .85) 26%, hsl(calc(var(--h) + 50) 90% 55% / .5) 34%, transparent 46%),
    radial-gradient(circle at 50% 50%, hsl(calc(var(--h) + 180) 80% 60% / .35), transparent 22%),
    #04050d;
}
.art-nebula.darkneb {
  background:
    radial-gradient(circle at 50% 25%, hsl(var(--h) 85% 55% / .85), transparent 62%),
    radial-gradient(circle at 15% 70%, hsl(calc(var(--h) + 40) 80% 45% / .6), transparent 50%),
    radial-gradient(circle at 85% 75%, hsl(calc(var(--h) - 30) 80% 45% / .5), transparent 45%),
    #05060f;
}
.art-nebula.darkneb > i {
  position: absolute; left: 22%; bottom: -12%;
  width: 56%; height: 78%; aspect-ratio: auto;
  border-radius: 38% 62% 25% 75% / 55% 35% 65% 45%;
  background: #020206;
  transform: rotate(var(--tilt));
  filter: blur(2.5px);
  box-shadow: 0 0 14px 2px hsl(var(--h) 90% 60% / .55);
}

/* Constellation */
.art-constellation { background: radial-gradient(ellipse at 50% 50%, #0d1838, #03040b 80%); }
.art-constellation svg { width: 100%; height: 100%; }
.c-lines polyline, .c-lines line { fill: none; stroke: rgba(150, 220, 255, .55); stroke-width: .9; stroke-dasharray: 2 1.5; }
.c-stars circle { fill: #fff; filter: drop-shadow(0 0 2px #9fe8ff); }
.c-stars circle.bright { filter: drop-shadow(0 0 3px #bdf2ff) drop-shadow(0 0 6px rgba(159, 232, 255, .6)); }

/* Uniques */
.art-unique > i {
  width: 14%; aspect-ratio: 1; border-radius: 50%; background: #fff; z-index: 1;
  box-shadow: 0 0 12px 4px hsl(var(--h) 100% 80%), 0 0 34px 12px hsl(var(--h) 100% 60% / .6);
}
.art-unique::before {
  content: ""; position: absolute; width: 5%; height: 96%;
  background: linear-gradient(transparent, hsl(var(--h) 100% 75%) 30%, #fff 50%, hsl(var(--h) 100% 75%) 70%, transparent);
  transform: rotate(calc(var(--tilt) * .5));
  filter: blur(1px);
}
.art-unique.quasar::after {
  content: ""; position: absolute; width: 70%; height: 14%; border-radius: 50%;
  background: radial-gradient(ellipse, hsl(var(--h) 100% 80%), hsl(var(--h) 100% 55% / .5) 50%, transparent 72%);
  transform: rotate(calc(var(--tilt) * .5 + 90deg));
}
.art-unique.pulsar::before { animation: sweep 2.4s linear infinite; }
/* Includes the starting tilt in both frames, so each turn ends exactly where the next begins */
@keyframes sweep {
  from { transform: rotate(calc(var(--tilt) * .5)); }
  to { transform: rotate(calc(var(--tilt) * .5 + 360deg)); }
}

/* ---------- Tags (cosmetic labels) ---------- */
.card-tag {
  display: inline-flex; align-items: center; gap: .3em; white-space: nowrap;
  font-weight: 800; text-transform: uppercase; letter-spacing: .08em; line-height: 1;
  padding: .32em .65em; border-radius: 1em;
}
.art .card-tag { position: absolute; left: 4cqw; bottom: 4cqw; z-index: 2; font-size: .56em; }
.tag-icon { color: #cffafe; background: rgba(8, 47, 73, .8); border: 1px solid rgba(103, 232, 249, .65); box-shadow: 0 0 8px rgba(103, 232, 249, .3); }
.tag-topfive {
  color: #241700; border: 1px solid #fde68a;
  background: linear-gradient(135deg, #fff3c4, #fbbf24 45%, #f59e0b 55%, #fff3c4);
  box-shadow: 0 0 10px rgba(251, 191, 36, .55);
}
/* Prismatic, seamlessly looping (the gradient's ends match and it moves exactly one tile) */
.tag-pinnacle {
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); border: 1px solid rgba(255, 255, 255, .8);
  background: linear-gradient(90deg, #f43f5e, #fbbf24, #4ade80, #60a5fa, #c084fc, #f43f5e);
  background-size: 200% 100%;
  box-shadow: 0 0 14px rgba(255, 255, 255, .45), 0 0 22px rgba(244, 63, 94, .35);
  animation: tag-prism 4s linear infinite;
}
@keyframes tag-prism { from { background-position: 0 0; } to { background-position: 200% 0; } }
.tag-legend { line-height: 2; }
.tag-legend .card-tag { font-size: 11px; margin: 0 2px; }

/* Locked */
.art-locked { background: repeating-linear-gradient(45deg, #0b0e1f 0 8px, #0e1226 8px 16px); }
.art-locked span { font-family: var(--display); font-size: 2.4em; color: #2a3260; }
.card.locked { cursor: default; }
.card.locked .card-front { opacity: .55; background: #090b18; box-shadow: none; animation: none; border-color: color-mix(in srgb, var(--rc) 45%, #1b2040); }
.card.locked .card-front::after { display: none; }
.card.locked .card-name { color: #4a5285; }
.card.locked .card-sub { flex: 1; }

/* ---------- Collection ---------- */
.cat-progress { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.cat-pill {
  flex: 1 1 auto; min-width: 140px;
  text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 6px 8px;
}
.cat-pill:hover { border-color: var(--cat); }
.cat-pill.active { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 12%, var(--panel)); }
.cp-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cp-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: #1b2142; overflow: hidden; }
.cp-bar span { display: block; height: 100%; background: var(--cat); border-radius: 4px; box-shadow: 0 0 8px var(--cat); transition: width .9s cubic-bezier(.16, 1, .3, 1); }
.cat-pill { transition: border-color .25s ease, background-color .25s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.cat-pill:hover { transform: translateY(-2px); }
.cat-pill:active { transform: scale(.97); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.toolbar input, .toolbar select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.toolbar input { flex: 1 1 180px; min-width: 0; transition: border-color .25s ease, box-shadow .25s ease; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 156, 255, .18); }

/* ---------- Animated dropdowns ---------- */
.dd { position: relative; }
.dd-native { display: none; }
.dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 150px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; text-align: left;
  transition: border-color .25s ease, box-shadow .25s ease, background-color .25s ease;
}
.dd-btn:hover { border-color: #3a4680; background: #10152c; }
.dd-btn:focus-visible, .dd.open .dd-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 156, 255, .18); }
.dd-label { display: inline-block; white-space: nowrap; }
.dd-caret { flex: none; color: var(--muted); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), color .25s ease; }
.dd.open .dd-caret { transform: rotate(180deg); color: var(--accent); }
.dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 100%;
  list-style: none; margin: 0; padding: 6px; border-radius: 12px;
  background: #0f1430; border: 1px solid #2d3766;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .55), 0 0 0 1px rgba(124, 156, 255, .06);
  transform-origin: top center;
}
.dd-menu li {
  position: relative; padding: 8px 12px 8px 28px; border-radius: 8px; white-space: nowrap; cursor: pointer;
  transition: background-color .15s ease, color .15s ease, padding-left .2s ease;
}
.dd-menu li.active { background: #1c2450; padding-left: 32px; }
.dd-menu li.sel { color: #a9bcff; font-weight: 600; }
.dd-menu li.sel::before { content: "✓"; position: absolute; left: 10px; color: var(--accent); }
.dd-menu li.sel.active::before { left: 13px; }
.col-summary { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 16px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Info ---------- */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; overflow-x: auto; }
.panel h2 { font-family: var(--display); font-size: 16px; letter-spacing: .06em; margin: 0 0 10px; }
.panel p { margin: 0 0 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tier-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.tier-dot.t0 { background: var(--t0); } .tier-dot.t1 { background: var(--t1); } .tier-dot.t2 { background: var(--t2); }
.tier-dot.t3 { background: var(--t3); } .tier-dot.t4 { background: var(--t4); } .tier-dot.t5 { background: var(--t5); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(3, 4, 12, .82); backdrop-filter: blur(5px);
  padding: 16px;
}
.modal-box {
  position: relative; display: flex; gap: 28px; align-items: flex-start;
  width: 100%; max-width: 780px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px;
}
.modal-close {
  position: absolute; top: 10px; right: 14px; background: none; border: none;
  font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-card { flex: 0 0 280px; }
.modal-card .card { cursor: default; }
.modal-card .card-fact { -webkit-line-clamp: 6; }
.modal-info { flex: 1; min-width: 0; }
.modal-info h2 { margin: 4px 0 8px; font-size: 26px; line-height: 1.15; }
.mi-cat { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.mi-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mi-tag { font-size: 12px; }
.mi-tag-desc { font-size: 12px; color: var(--muted); }
.mi-tier {
  display: inline-block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 10px; border-radius: 999px; color: #0a0d1d; background: var(--t0);
}
.mi-tier.t1 { background: var(--t1); } .mi-tier.t2 { background: var(--t2); } .mi-tier.t3 { background: var(--t3); }
.mi-tier.t4 { background: var(--t4); } .mi-tier.t5 { background: linear-gradient(90deg, #f43f5e, #fbbf24, #c084fc); }
.mi-fact { font-size: 16px; color: #d4d8f0; margin: 16px 0; }
.mi-stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 14px; font-size: 14px; }
.mi-stats dt { color: var(--muted); }
.mi-stats dd { margin: 0; font-weight: 600; }
.max-tag { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: help; }
.mi-scale { font-size: 13px; color: var(--muted); margin: 0; }

/* ---------- Flash ---------- */
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 66; opacity: 0; }

/* ---------- FX layer (bursts, sparks, floating SP, lightning) ---------- */
/* Layers: spotlight 55 < spotlit card 60 < fx 65 < flash 66 */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
/* One smooth gradient from a white-hot core out to soft gold, fading to nothing at the edge */
.fx-orb {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle closest-side,
    #fff 0 16%, #fffdf0 24%, #fef3c7 32%, #fde68a 40%,
    rgba(251, 191, 36, .75) 52%, rgba(251, 191, 36, .32) 70%, rgba(251, 191, 36, .1) 85%, rgba(251, 191, 36, 0) 100%);
}
.fx-orb::before {
  content: ""; position: absolute; inset: -15%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 244, 200, .55) 0 5deg, transparent 5deg 30deg);
  -webkit-mask: radial-gradient(circle closest-side, #000 20%, transparent 100%);
  mask: radial-gradient(circle closest-side, #000 20%, transparent 100%);
  animation: rotate 6s linear infinite;
}
.fx-bolts {
  position: absolute; inset: 0; width: 100%; height: 100%;
  filter: drop-shadow(0 0 6px #f43f5e) drop-shadow(0 0 14px #e879f9);
}
.fx-bolts polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Mythic spotlight: darkness with a moving pool of light (registered props so they can animate) */
@property --sx { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --sy { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --sr { syntax: '<length>'; inherits: false; initial-value: 200px; }
.spot {
  position: fixed; inset: 0; z-index: 55; opacity: 0;
  background: radial-gradient(circle at var(--sx) var(--sy),
    rgba(255, 235, 255, .12) 0, rgba(255, 235, 255, .05) calc(var(--sr) * .85),
    rgba(3, 2, 10, .92) calc(var(--sr) + 70px));
}
.spot-beam {
  position: absolute; opacity: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 235, 255, 0), rgba(255, 235, 255, .2));
  clip-path: polygon(40% 0, 60% 0, 100% 100%, 0 100%);
  filter: blur(6px);
}
.reveal-grid .card.spotlit { z-index: 60; }
.fx-ring {
  position: absolute; border-radius: 50%;
  border: 3px solid var(--c);
  box-shadow: 0 0 24px var(--c), inset 0 0 24px var(--c);
}
.fx-spark {
  position: absolute; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 8px var(--c), 0 0 2px #fff;
}
.fx-float {
  position: absolute; white-space: nowrap;
  font-family: var(--display); font-weight: 800; font-size: 17px;
  color: #ffd166; text-shadow: 0 0 12px rgba(255, 209, 102, .7), 0 2px 4px rgba(0,0,0,.8);
}
.fx-float small { font-size: 11px; color: #f9a8d4; text-shadow: 0 0 10px rgba(236, 72, 153, .8); margin-left: 4px; }

/* ---------- Home dashboard (under the pack) ---------- */
.home {
  display: grid; gap: 20px; margin-top: 40px;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-areas: "progress rarest" "progress recent";
}
.home .panel { padding: 24px; }
.home .panel h2 { font-size: 18px; margin-bottom: 14px; }
.home-progress { grid-area: progress; }
.home-rarest { grid-area: rarest; }
.home-recent { grid-area: recent; }
.ring-wrap { position: relative; width: 190px; margin: 8px auto 20px; }
.ring { width: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: #1b2142; }
.ring-fg {
  stroke: url(#ring-grad); stroke-linecap: round;
  transition: stroke-dashoffset 1.4s cubic-bezier(.16, 1, .3, 1);
  filter: drop-shadow(0 0 6px rgba(180, 140, 255, .5));
}
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ring-text b { font-family: var(--display); font-size: 32px; }
.ring-text span { font-size: 14px; color: var(--muted); }
.home-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.home-totals div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.home-totals span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.home-totals b { font-family: var(--display); font-size: 21px; }
.home-totals div:first-child b { color: #ffd166; }
.home-cats { display: flex; flex-direction: column; gap: 13px; }
.hc-row { display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; font-size: 15px; }
.hc-name { font-weight: 500; }
.hc-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.hc-bar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: #1b2142; overflow: hidden; }
.hc-bar span { display: block; height: 100%; border-radius: 4px; background: var(--cat); box-shadow: 0 0 8px var(--cat); transition: width 1.1s cubic-bezier(.16, 1, .3, 1); }
.strip {
  display: flex; gap: 14px; overflow-x: auto; padding: 10px 6px 12px; margin: 0 -6px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.strip { gap: 16px; padding: 12px 6px 14px; }
.strip .card { flex: 0 0 178px; width: 178px; }
.strip-empty { color: var(--muted); margin: 18px 0; font-size: 15px; }
.ai-panel p { margin: 0; line-height: 1.6; }
.credits { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; line-height: 1.5; }
.credits dt { color: var(--muted); font-weight: 600; }
.credits dd { margin: 0; overflow-wrap: anywhere; }
.credits a { color: #8fb3ff; text-decoration: underline; text-underline-offset: 3px; transition: color .2s ease; }
.credits a:hover { color: #c4b5fd; }
.panel .settings-row + .settings-row { margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; }
  .tagline { font-size: 11px; }
  .music-toast { left: 16px; top: 92px; }
}
@media (max-width: 960px) {
  .reveal-grid { grid-template-columns: repeat(3, minmax(0, 200px)); }
  .home { grid-template-columns: minmax(0, 1fr); grid-template-areas: "progress" "rarest" "recent"; }
}
@media (max-width: 640px) {
  .pack { width: 180px; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .logo { font-size: 20px; }
  .stats { gap: 14px; }
  .stat-value { font-size: 15px; }
  .reveal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .col-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .info-grid { grid-template-columns: 1fr; }
  .modal-box { flex-direction: column; align-items: center; padding: 22px 18px; }
  .modal-card { flex-basis: auto; width: 240px; }
}
.settings-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Header mute button (pushes itself to the far right, even when the stats are hidden) */
.topbar .brand { margin-right: auto; }
.mute-btn {
  display: grid; place-items: center; width: 40px; height: 40px; margin-left: 18px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer;
  transition: border-color .25s ease, color .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.mute-btn:hover { border-color: var(--accent); box-shadow: 0 0 14px -2px rgba(124, 156, 255, .5); }
.mute-btn.muted { color: var(--muted); }

/* Volume slider */
.vol { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }
.vol-val { min-width: 3.2em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.vol input[type="range"] {
  --fill: 70%;
  -webkit-appearance: none; appearance: none; width: 150px; height: 6px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(90deg, #7c9cff 0 var(--fill), #232b4d var(--fill) 100%);
}
.vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 3px rgba(124, 156, 255, .45); transition: transform .2s ease;
}
.vol input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.vol input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(124, 156, 255, .45); }

/* First visit: nothing but the pack until the first one is opened */
body.first-run .stats,
body.first-run .tabs,
body.first-run #home,
body.first-run .pack-hint { display: none !important; }
/* While a pack is open, the tab bar steps aside so the cards fit without scrolling */
body.in-pack .tabs { display: none; }
body.in-pack main { padding-top: 18px; padding-bottom: 20px; }
body.first-run .pack-stage { padding-top: 12vh; }

/* In-game "Animations: Off" setting */
body.no-motion *, body.no-motion *::before, body.no-motion *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important;
}
