/* Shitpost Gacha — museum-grade presentation for objects of no value.
   Velvet card room, gold leaf, metal-framed numbered cards. */
:root {
  --velvet: #3B0F1D;
  --velvet-hi: #5E1B2F;
  --velvet-lo: #26080F;
  --gold: #E7C46E;
  --gold-hi: #FFE7A6;
  --gold-lo: #A97B2C;
  --ivory: #F8F1E2;
  --ivory-2: #EFE4CC;
  --ink: #24151B;
  --ink-soft: #6B5560;
  --on-velvet: #F3DCCB;
  --on-velvet-soft: #C79E92;
  --line: rgba(231, 196, 110, .28);

  --n-1: #DDE2E4; --n-2: #8E989E;
  --r-1: #7FA8FF; --r-2: #1F4FB8;
  --sr-1: #D3A2FF; --sr-2: #6A2BB8;
  --ssr-1: #FFE7A6; --ssr-2: #B9852C;

  --display: 'Unbounded', system-ui, sans-serif;
  --text: 'Bricolage Grotesque', system-ui, sans-serif;
  --card-w: min(78vw, 320px);
  --radius-card: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh; overflow-x: clip;
  color: var(--on-velvet); font-family: var(--text); font-size: 16px; line-height: 1.45;
  background-color: var(--velvet);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 32%, var(--velvet-hi), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 120%, var(--velvet-lo), transparent 60%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, transparent 2px 5px);
  background-attachment: fixed;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--on-velvet-soft); margin: 0; font-size: .9rem; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1320px; margin: 0 auto; padding: 14px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem;
  background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold) 45%, var(--gold-lo));
  box-shadow: 0 0 0 2px var(--velvet), 0 0 0 3px var(--gold-lo), 0 6px 14px rgba(0,0,0,.35);
}
.brand-words { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-words b { font-family: var(--display); font-weight: 900; font-size: 1.05rem; color: var(--gold); letter-spacing: -.01em; }
.brand-words small { color: var(--on-velvet-soft); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { display: flex; gap: 6px; flex: none; }
.stat {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px 5px 9px; border-radius: 999px;
  background: rgba(0,0,0,.22); border: 1px solid var(--line);
  font-family: var(--display); font-weight: 700; font-size: .9rem; color: var(--gold-hi);
}
.stat b { font-weight: 700; min-width: 1.1em; text-align: right; }

/* tabs: bottom bar on phones, inline nav on desktop */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--velvet-lo); border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 120px; border: 0; background: none; cursor: pointer; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px;
  font-family: var(--display); font-weight: 500; font-size: .7rem; color: var(--on-velvet-soft);
}
.tabs button span { font-size: 1.25rem; line-height: 1; filter: grayscale(.6); }
.tabs button.on { color: var(--gold-hi); background: rgba(231,196,110,.12); }
.tabs button.on span { filter: none; }

main { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.tab[hidden] { display: none !important; }
.tab-title { font-family: var(--display); font-weight: 900; font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.05; margin: 0; color: var(--gold); letter-spacing: -.02em; }
.tab-lede { margin: 8px 0 0; color: var(--on-velvet-soft); max-width: 36ch; }
.panel-title { font-family: var(--display); font-weight: 700; font-size: .8rem; color: var(--gold); margin: 0 0 10px; letter-spacing: .01em; }

/* ---------- pull layout ---------- */
.roll-layout { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.center { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }

.filters .panel-title { display: none; }
.chip-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.chip-list::-webkit-scrollbar { display: none; }
.filters { display: flex; flex-direction: column; gap: 6px; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: rgba(0,0,0,.18); color: var(--on-velvet);
  border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .85rem;
}
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.chip small { font-weight: 600; opacity: .7; }

.side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.session { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.session .muted { grid-column: 1 / -1; }
.world { font-size: .88rem; color: var(--on-velvet-soft); margin-bottom: 8px; }
.world b { color: var(--gold-hi); font-family: var(--display); font-weight: 700; }
.world .meter { margin-top: 6px; height: 8px; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid rgba(231,196,110,.12); font-size: .85rem; }
.feed li:first-child { border-top: 0; }
.feed .gem { grid-row: span 2; align-self: center; }
.feed .f-name { font-weight: 700; color: var(--on-velvet); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .f-meta { color: var(--on-velvet-soft); font-size: .78rem; }
.feed .f-meta b { color: var(--gold); font-weight: 700; }

/* ---------- stage ---------- */
.stage {
  position: relative; width: 100%; display: flex; align-items: center; justify-content: center;
  min-height: calc(var(--card-w) * 1.4 + 12px);
}
.stage::before { /* spotlight on the table */
  content: ''; position: absolute; left: 50%; top: 50%; width: calc(var(--card-w) * 1.9); aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 220, 160, .14), transparent 62%);
}
.rays { position: absolute; left: 50%; top: 50%; width: calc(var(--card-w) * 2.2); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; opacity: 0; }
.rays.on { opacity: 1; animation: rays-spin 6s linear infinite, rays-in .6s ease-out; }
.rays.r-SR { background: repeating-conic-gradient(from 0deg, rgba(211,162,255,.2) 0 6deg, transparent 6deg 18deg); -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%); }
.rays.r-SSR { background: repeating-conic-gradient(from 0deg, rgba(255,231,166,.26) 0 6deg, transparent 6deg 16deg); -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%); mask: radial-gradient(circle, #000 20%, transparent 70%); }
@keyframes rays-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes rays-in { from { opacity: 0; } }

/* ---------- card ---------- */
.flip { position: relative; width: var(--card-w); aspect-ratio: 5 / 7; perspective: 1400px; border: 0; padding: 0; background: none; cursor: pointer; z-index: 1; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.25,1.3,.45,1); }
.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.front { transform: rotateY(180deg); }

.back {
  border-radius: var(--radius-card); padding: 10px;
  background: linear-gradient(135deg, var(--gold-hi), var(--gold) 30%, var(--gold-lo) 55%, var(--gold) 80%, var(--gold-hi));
  box-shadow: 0 18px 30px rgba(0,0,0,.45);
}
.back-in {
  width: 100%; height: 100%; border-radius: 10px; position: relative; overflow: hidden;
  display: grid; place-items: center; text-align: center;
  background-color: var(--velvet);
  background-image:
    repeating-radial-gradient(circle at 50% 50%, transparent 0 10px, rgba(231,196,110,.16) 10px 11px),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(231,196,110,.08) 0 5deg, transparent 5deg 10deg);
  box-shadow: inset 0 0 0 1px var(--gold-lo), inset 0 0 0 6px var(--velvet), inset 0 0 0 7px var(--gold-lo);
}
.emblem {
  width: 46%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; align-content: center; gap: 2px;
  background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold) 45%, var(--gold-lo));
  box-shadow: 0 0 0 4px var(--velvet), 0 0 0 5px var(--gold), 0 10px 20px rgba(0,0,0,.4);
  color: var(--velvet); font-family: var(--display); font-weight: 900; font-size: .72rem; line-height: 1.1;
}
.emblem span { font-size: 2.2rem; line-height: 1; }
.back-hint { position: absolute; bottom: 16px; left: 0; right: 0; font-family: var(--display); font-weight: 500; font-size: .78rem; color: var(--gold); }

.charging .flip-inner { animation: shake .7s ease-in-out; }
.tease-SR .back { box-shadow: 0 0 0 3px var(--sr-1), 0 0 50px 16px rgba(160, 90, 240, .7); }
.tease-SSR .back { animation: gold-flare .3s ease-in-out infinite alternate; }
@keyframes shake {
  0%, 100% { transform: rotate(0); } 15% { transform: rotate(-5deg) scale(1.03); } 30% { transform: rotate(4deg); }
  45% { transform: rotate(-3deg) scale(1.05); } 60% { transform: rotate(2deg); } 80% { transform: rotate(-1deg) scale(1.02); }
}
@keyframes gold-flare {
  from { box-shadow: 0 0 0 3px var(--gold-hi), 0 0 40px 12px rgba(255, 210, 120, .6); }
  to { box-shadow: 0 0 0 5px #fff, 0 0 80px 30px rgba(255, 220, 140, .9); }
}

.card {
  --f1: var(--n-1); --f2: var(--n-2);
  position: relative; width: 100%; height: 100%; border-radius: var(--radius-card); padding: 9px; text-align: left; color: var(--ink);
  background: linear-gradient(135deg, var(--f1), var(--f2) 38%, var(--f1) 58%, var(--f2) 85%, var(--f1));
  box-shadow: 0 18px 30px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.5);
  container-type: inline-size;
}
.card.r-R { --f1: var(--r-1); --f2: var(--r-2); }
.card.r-SR { --f1: var(--sr-1); --f2: var(--sr-2); }
.card.r-SSR { --f1: var(--ssr-1); --f2: var(--ssr-2); }
.card-in {
  position: relative; height: 100%; border-radius: 10px; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto auto;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255,255,255,.7), transparent 60%),
    var(--ivory);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}
.plate {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4.5cqw 4.5cqw 3cqw; border-bottom: 1px solid rgba(36,21,27,.14);
}
.plate-name { font-family: var(--display); font-weight: 700; font-size: 4.4cqw; line-height: 1.15; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gem {
  --g1: var(--n-1); --g2: var(--n-2);
  flex: none; display: inline-grid; place-items: center; min-width: 2.2em; height: 2.2em; padding: 0 .45em; border-radius: 999px;
  font-family: var(--display); font-weight: 900; font-size: 3.6cqw; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.35);
  background: radial-gradient(circle at 35% 30%, var(--g1), var(--g2) 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), 0 1px 2px rgba(0,0,0,.3);
}
.gem.r-R { --g1: var(--r-1); --g2: var(--r-2); }
.gem.r-SR { --g1: var(--sr-1); --g2: var(--sr-2); }
.gem.r-SSR { --g1: var(--ssr-1); --g2: var(--ssr-2); color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.feed .gem, .session .gem { font-size: .62rem; }

.body { position: relative; display: flex; align-items: center; padding: 3cqw 6cqw; min-height: 0; }
.body p {
  position: relative; z-index: 1; margin: 0; font-weight: 800; letter-spacing: -.012em; line-height: 1.17;
  font-size: 8.6cqw; text-wrap: pretty; overflow-wrap: break-word;
}
.body p.len-m { font-size: 7.4cqw; }
.body p.len-l { font-size: 6.4cqw; line-height: 1.2; }
.body p.len-xl { font-size: 5.6cqw; line-height: 1.22; }
.body .who { color: #B0285A; }
.watermark { position: absolute; right: 2cqw; bottom: -2cqw; font-size: 34cqw; opacity: .07; line-height: 1; pointer-events: none; filter: grayscale(1); }
.typeline {
  display: flex; align-items: center; gap: 2.4cqw; padding: 2.6cqw 4.5cqw; font-size: 3.4cqw; font-weight: 700; color: var(--ink-soft);
  border-top: 1px solid rgba(36,21,27,.14); white-space: nowrap; overflow: hidden;
}
.typeline i { width: 1.6cqw; height: 1.6cqw; background: var(--gold-lo); transform: rotate(45deg); flex: none; }
.card-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 2.6cqw 4.5cqw 3.6cqw; background: var(--ivory-2); font-family: var(--display); font-size: 3cqw; font-weight: 500; color: var(--ink-soft);
}
.card-foot .status { font-weight: 700; white-space: nowrap; }
.card-foot .status.first { color: #8A5A0E; }
.stars { color: #C48A1A; letter-spacing: .1em; font-size: 4cqw; }

.ribbon {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 2cqw 4cqw; text-align: center;
  font-family: var(--display); font-weight: 700; font-size: 3.3cqw; color: var(--ink);
  background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi) 30%, var(--gold) 70%, var(--gold-lo));
  box-shadow: 0 -1px 0 rgba(0,0,0,.15);
}

/* legendary foil */
.card.r-SSR .card-in::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .32; z-index: 3;
  background: linear-gradient(115deg, transparent 20%, #ff9ad0 35%, #ffe08a 45%, #8fe3ff 55%, #c9a2ff 65%, transparent 80%);
  background-size: 260% 260%;
  background-position: calc(var(--mx, 30) * 1%) calc(var(--my, 30) * 1%);
  animation: foil 5s ease-in-out infinite alternate;
}
.card.r-SSR.tilting .card-in::after { animation: none; }
@keyframes foil { to { background-position: 100% 100%; } }

.sticker {
  position: absolute; z-index: 5; top: -10px; right: -10px; pointer-events: none;
  font-family: var(--display); font-weight: 900; font-size: .75rem; color: var(--ink);
  background: var(--gold-hi); border-radius: 999px; padding: 5px 10px; transform: rotate(10deg);
  box-shadow: 0 0 0 2px var(--velvet), 0 6px 12px rgba(0,0,0,.35);
}
.sticker.first { background: linear-gradient(90deg, #fff3c4, var(--gold)); }

/* rarity stamp */
.stamp {
  position: absolute; z-index: 6; left: 50%; top: 42%; pointer-events: none; white-space: nowrap;
  font-family: var(--display); font-weight: 900; font-size: clamp(1.8rem, 8vw, 2.8rem); letter-spacing: -.02em;
  transform: translate(-50%, 0) rotate(-6deg);
  color: var(--gold-hi); text-shadow: 0 3px 0 var(--velvet-lo), 0 0 24px rgba(255, 210, 120, .7);
  animation: stamp .5s cubic-bezier(.2,1.6,.4,1) both, stamp-out .4s ease-in 1.7s forwards;
}
.stamp.s-SR { color: #fff; text-shadow: 0 3px 0 var(--sr-2), 0 0 24px rgba(200, 140, 255, .8); }
.stamp.s-FIRST { top: 30%; font-size: clamp(1.4rem, 6vw, 2.1rem); }
@keyframes stamp { from { transform: translate(-50%, -30px) rotate(-6deg) scale(2.2); opacity: 0; } }
@keyframes stamp-out { to { opacity: 0; transform: translate(-50%, -20px) rotate(-6deg) scale(.9); } }

.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 7; }
.confetti i { position: absolute; left: 50%; top: 45%; width: 8px; height: 12px; border-radius: 2px; animation: pop 1.4s cubic-bezier(.15,.8,.3,1) forwards; }
@keyframes pop { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

/* ---------- pack ---------- */
.pack {
  position: relative; width: calc(var(--card-w) * .82); aspect-ratio: 5 / 8; border: 0; padding: 0; cursor: pointer; z-index: 1; background: none;
  filter: drop-shadow(0 20px 26px rgba(0,0,0,.5));
}
.pack-half {
  position: absolute; left: 0; right: 0; overflow: hidden;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,0) 0 18px, rgba(255,255,255,.12) 18px 22px),
    linear-gradient(160deg, var(--velvet-hi), var(--velvet) 50%, var(--velvet-lo));
  box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 7px var(--velvet), inset 0 0 0 8px var(--gold-lo);
  transition: transform .55s cubic-bezier(.3,.9,.4,1.2), opacity .55s;
}
.pack-top { top: 0; height: 18%; border-radius: 14px 14px 0 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 92% 86%, 84% 100%, 76% 86%, 68% 100%, 60% 86%, 52% 100%, 44% 86%, 36% 100%, 28% 86%, 20% 100%, 12% 86%, 4% 100%, 0 90%); }
.pack-bottom { bottom: 0; height: 84%; border-radius: 0 0 14px 14px; display: grid; place-items: center; align-content: center; gap: 12px; text-align: center; }
.pack-bottom .emblem { width: 52%; }
.pack-label { font-family: var(--display); font-weight: 900; color: var(--gold); font-size: 1rem; line-height: 1.15; }
.pack-label small { display: block; font-weight: 500; font-size: .7rem; color: var(--on-velvet-soft); margin-top: 4px; }
.pack.wiggle { animation: shake .6s ease-in-out infinite; }
.pack.torn .pack-top { transform: translate(30px, -140px) rotate(24deg); opacity: 0; }
.pack.torn .pack-bottom { transform: translateY(40px) scale(.96); opacity: 0; transition-delay: .25s; }

.ten { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; max-width: 640px; }
.ten .flip { width: 100%; }
.ten-summary { grid-column: 1 / -1; text-align: center; font-family: var(--display); font-weight: 700; font-size: .9rem; color: var(--gold-hi); margin: 8px 0 0; }

/* ---------- mini cards (pack, session, collection) ---------- */
.mini .card { padding: 4px; border-radius: 9px; box-shadow: 0 6px 12px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.5); }
.mini .card-in { border-radius: 6px; display: grid; grid-template-rows: auto 1fr auto; place-items: center; text-align: center; padding: 8cqw 4cqw; gap: 2cqw; }
.mini .gem { font-size: 11cqw; }
.mini .m-emoji { font-size: 26cqw; line-height: 1; }
.mini .m-name { font-family: var(--display); font-weight: 700; font-size: 9cqw; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini .m-first { position: absolute; top: 3%; left: 6%; font-size: 14cqw; z-index: 4; color: #8A5A0E; }
.mini .back { padding: 4px; border-radius: 9px; }
.mini .back-in { border-radius: 6px; box-shadow: inset 0 0 0 1px var(--gold-lo); }
.mini .emblem { width: 56%; font-size: 0; box-shadow: 0 0 0 2px var(--velvet), 0 0 0 3px var(--gold); }
.mini .emblem span { font-size: 1.1rem; }
.mini .sticker { font-size: .55rem; padding: 3px 6px; top: -7px; right: -6px; }
.session .mini { width: 100%; aspect-ratio: 5 / 7; border: 0; padding: 0; background: none; cursor: pointer; position: relative; }
.session .mini .card-in { padding: 6cqw 2cqw; }
.session .mini .m-name, .session .mini .gem { display: none; }

/* ---------- console + buttons ---------- */
.console {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 20;
  width: calc(100% + 32px); padding: 10px 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--velvet-lo); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
}
.roll-row { display: flex; gap: 10px; width: 100%; max-width: 460px; }
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; border-radius: 14px; cursor: pointer; padding: 10px 16px; line-height: 1.05;
  font-family: var(--display); font-weight: 700; font-size: .92rem;
  transition: transform 90ms, box-shadow 90ms, filter 90ms;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-cost { font-family: var(--text); font-weight: 700; font-size: .72rem; opacity: .8; }
.btn-pull {
  flex: 1.4; color: var(--ink); font-size: 1.05rem; padding: 11px 14px 9px; white-space: nowrap;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  box-shadow: 0 4px 0 #6E4C17, 0 10px 22px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.7);
}
.btn-pull:active:not(:disabled) { box-shadow: 0 2px 0 #6E4C17, 0 6px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.7); }
.btn-pack {
  flex: 1; color: var(--gold-hi); font-size: .9rem; padding: 11px 12px 9px; white-space: nowrap;
  background: linear-gradient(180deg, var(--velvet-hi), var(--velvet));
  box-shadow: 0 4px 0 var(--velvet-lo), 0 10px 22px rgba(0,0,0,.35), inset 0 0 0 1px var(--gold-lo);
}
.btn-gift { animation: gift-glow 1.2s ease-in-out infinite alternate; }
@keyframes gift-glow { to { box-shadow: 0 4px 0 #6E4C17, 0 0 30px 6px rgba(255, 220, 140, .8); } }
.btn-ghost { background: rgba(0,0,0,.2); color: var(--gold-hi); border: 1px solid var(--line); font-size: .85rem; padding: 9px 14px; }
.btn-light { background: var(--ivory); color: var(--ink); font-size: .85rem; padding: 10px 14px; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.btn-x { background: #000; color: #fff; font-size: .85rem; padding: 10px 14px; box-shadow: 0 3px 0 rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,255,255,.2); }
.btn-brag { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--ink); font-size: .85rem; padding: 10px 14px; box-shadow: 0 3px 0 #6E4C17; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.actions[hidden] { display: none; }
.actions .btn { flex-direction: row; gap: 6px; }

.pity { width: 100%; max-width: 460px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .76rem; color: var(--on-velvet-soft); white-space: nowrap; }
.pity .pips { flex: 1; justify-content: center; }
.pity b { color: var(--on-velvet); font-weight: 700; }
.pips { display: flex; gap: 3px; }
.pips i { flex: 0 1 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.14); }
.pips i.on { background: linear-gradient(90deg, var(--sr-1), var(--sr-2)); }
.gift-note { flex: 1; text-align: center; font-family: var(--display); font-weight: 700; color: var(--gold-hi); font-size: .85rem; }

/* ---------- first pull panel ---------- */
.first-panel {
  width: 100%; max-width: 460px; border-radius: 16px; padding: 14px;
  background: linear-gradient(135deg, rgba(255,231,166,.16), rgba(169,123,44,.12)); border: 1px solid var(--gold);
  display: flex; flex-direction: column; gap: 10px;
}
.first-panel[hidden] { display: none; }
.first-panel h3 { margin: 0; font-family: var(--display); font-weight: 900; color: var(--gold-hi); font-size: 1.05rem; line-height: 1.2; }
.first-panel p { margin: 0; font-size: .9rem; color: var(--on-velvet); }
.sign-form { display: flex; gap: 8px; }
.handle-input {
  display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0;
  background: var(--ivory); color: var(--ink); border-radius: 12px; padding: 0 12px;
  font-family: var(--display); font-weight: 700;
}
.handle-input input { border: 0; background: none; outline: none; width: 100%; min-width: 0; font-family: var(--text); font-weight: 800; font-size: 1rem; padding: 10px 0; color: var(--ink); }
.handle-input:focus-within { outline: 3px solid var(--gold-hi); outline-offset: 2px; }
.form-error { margin: 0; min-height: 1.2em; color: #FFB4C8; font-weight: 700; font-size: .88rem; }

/* ---------- friend + fortune ---------- */
.solo-layout { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 10px; text-align: center; }
.solo-copy { display: flex; flex-direction: column; align-items: center; }
.solo-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.friend-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; margin-top: 16px; }
.friend-form .handle-input { font-size: 1.2rem; padding: 2px 14px; }
.next-fortune { color: var(--on-velvet-soft); font-weight: 700; margin: 12px 0 0; }

/* ---------- collection ---------- */
.dex-layout { display: flex; flex-direction: column; gap: 16px; padding-top: 10px; }
.dex-head { display: flex; flex-direction: column; gap: 10px; }
.dex-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; color: var(--on-velvet-soft); }
.dex-stats b { font-family: var(--display); font-weight: 700; color: var(--gold-hi); font-size: 1.05rem; margin-right: 4px; }
.meter { height: 10px; border-radius: 999px; background: rgba(0,0,0,.3); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); transition: width .6s; }
.dex-tools { display: flex; flex-direction: column; gap: 10px; }
.dex-tools .chip-list { min-width: 0; }
.dex-tools .btn { white-space: nowrap; flex: none; }
.sort-row .chip { background: none; }
.sort-row .chip[aria-pressed="true"] { background: rgba(231,196,110,.18); color: var(--gold-hi); border-color: var(--gold); }
.dex-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 16px; text-align: center; border: 1px dashed var(--line); border-radius: 16px; }
.dex-empty b { font-family: var(--display); font-weight: 900; color: var(--gold); font-size: 1.2rem; }
.dex-empty p { margin: 0; color: var(--on-velvet-soft); }
.dex-empty .btn { flex: none; margin-top: 6px; }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dex-grid .mini { position: relative; aspect-ratio: 5 / 7; border: 0; padding: 0; background: none; cursor: pointer; }
.dex-grid .mini:disabled { cursor: default; }
.v-count {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); z-index: 4; white-space: nowrap;
  background: var(--velvet-lo); color: var(--gold-hi); border: 1px solid var(--gold-lo); border-radius: 999px;
  font-family: var(--display); font-weight: 700; font-size: .6rem; padding: 2px 7px;
}

/* ---------- dialog ---------- */
.detail {
  width: min(94vw, 860px); max-height: 92dvh; border: 1px solid var(--gold-lo); border-radius: 22px; padding: 22px 16px 18px;
  background: radial-gradient(ellipse at 30% 20%, var(--velvet-hi), var(--velvet) 60%); color: var(--on-velvet);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.detail::backdrop { background: rgba(20, 4, 9, .72); backdrop-filter: blur(3px); }
.detail-body { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.detail-card { width: min(70vw, 300px); aspect-ratio: 5 / 7; }
.detail-side { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.detail-side .first-panel { max-width: none; }
.detail-side .actions { justify-content: flex-start; }
.variants { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.variants:empty { display: none; }
.variant {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: rgba(0,0,0,.2); border-radius: 10px; padding: 8px 10px; font-size: .84rem; color: var(--on-velvet);
}
.variant[aria-pressed="true"] { border-color: var(--gold); background: rgba(231,196,110,.14); }
.variant .v-no { font-family: var(--display); font-size: .68rem; color: var(--gold); }
.variant .v-tag { grid-row: span 2; font-size: .72rem; font-weight: 700; color: var(--gold-hi); }
.variant:disabled { cursor: default; opacity: .55; }
.close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; z-index: 2;
  border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--gold-hi); font-weight: 700;
}

/* ---------- empty / footer / toast ---------- */
.empty {
  position: relative; z-index: 1; width: var(--card-w); aspect-ratio: 5 / 7; border-radius: var(--radius-card);
  border: 1px dashed var(--gold-lo); background: rgba(0,0,0,.25); display: grid; place-items: center; align-content: center; gap: 10px; text-align: center; padding: 24px;
}
.empty b { font-family: var(--display); font-weight: 900; font-size: 1.3rem; color: var(--gold); line-height: 1.15; }
.empty p { margin: 0; color: var(--on-velvet-soft); }
.foot { max-width: 1320px; margin: 30px auto 0; padding: 0 16px 16px; text-align: center; font-size: .82rem; color: var(--on-velvet-soft); }
.foot a { color: var(--gold); font-weight: 700; }
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; max-width: 92vw;
  background: var(--ivory); color: var(--ink); border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: .92rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .2s, transform .2s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- tablet ---------- */
@media (min-width: 700px) {
  .dex-grid { grid-template-columns: repeat(5, 1fr); }
  .dex-tools { flex-direction: row; align-items: center; justify-content: space-between; }
  .dex-tools .chip-list { flex: 1; margin: 0; padding-left: 0; }
  .detail-body { flex-direction: row; align-items: flex-start; }
  .detail-card { width: 300px; flex: none; }
}

/* ---------- desktop: a real card table ---------- */
@media (min-width: 1100px) {
  :root { --card-w: min(340px, calc((100dvh - 330px) * .714)); }
  body { padding-bottom: 0; }
  .top { padding: 20px 28px 10px; }
  .brand-words b { font-size: 1.2rem; }
  .tabs {
    position: static; background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 999px;
    padding: 4px; gap: 2px; justify-content: center;
  }
  .tabs button { flex-direction: row; gap: 8px; max-width: none; flex: none; padding: 9px 16px; font-size: .82rem; border-radius: 999px; }
  .tabs button span { font-size: 1rem; }
  .tabs button.on { background: var(--gold); color: var(--ink); }
  main { padding: 0 28px; }

  .roll-layout {
    display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; gap: 28px; align-items: start; padding-top: 16px;
  }
  .filters, .side { position: sticky; top: 16px; }
  .filters { background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 16px; padding: 16px 14px; gap: 0; }
  .filters .panel-title { display: block; }
  .filters .panel-title:not(:first-child) { margin-top: 18px; }
  .filters .chip-list { flex-direction: column; overflow: visible; margin: 0; padding: 0; gap: 2px; }
  .filters .chip { border: 0; background: none; border-radius: 10px; padding: 7px 10px; font-size: .88rem; justify-content: flex-start; }
  .filters .chip:hover { background: rgba(255,255,255,.06); }
  .filters .chip[aria-pressed="true"] { background: var(--gold); color: var(--ink); }

  .center { gap: 18px; }
  .console {
    position: sticky; bottom: 14px; width: 100%; max-width: 520px; padding: 12px 18px 14px;
    background: rgba(38, 8, 15, .92); backdrop-filter: blur(6px);
    border: 1px solid var(--line); border-radius: 18px;
  }
  .session { grid-template-columns: repeat(4, 1fr); }
  .session .mini .gem { display: inline-grid; }
  .ten { gap: 14px; }

  .solo-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; text-align: left;
    max-width: 1040px; margin: 0 auto; padding-top: 40px; min-height: calc(100dvh - 200px);
  }
  .solo-copy { align-items: flex-start; }
  .tab-lede { font-size: 1.1rem; }
  .dex-layout { padding-top: 16px; }
  .dex-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 16px; }
  .toast { bottom: 28px; }
}

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

/* ---------- single card page (/gacha/c/1234-5678) ---------- */
.card-page-body { padding-bottom: 0; }
.card-page {
  max-width: 1080px; margin: 0 auto; padding: 8px 16px 0;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.cp-stage { min-height: calc(var(--card-w) * 1.4 + 24px); }
.cp-stage .flip { cursor: default; }
.cp-info { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
.cp-rarity { margin: 0; font-family: var(--display); font-weight: 700; font-size: .85rem; color: var(--on-velvet-soft); }
.cp-rarity.r-R { color: var(--r-1); }
.cp-rarity.r-SR { color: var(--sr-1); }
.cp-rarity.r-SSR { color: var(--gold-hi); }
.cp-no { margin: 0; font-family: var(--display); font-weight: 500; color: var(--gold); font-size: .95rem; }
.cp-facts { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cp-facts li { padding: 10px 14px; border-radius: 12px; background: rgba(0,0,0,.2); border: 1px solid var(--line); font-size: .95rem; }
.cp-facts b { font-family: var(--display); font-weight: 700; color: var(--gold-hi); }
.cp-cta { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.cp-cta .btn-pull { text-decoration: none; padding: 14px 18px 12px; }
.cp-cta .actions { justify-content: flex-start; }

/* invite dialog */
.invite { width: min(94vw, 460px); }
.invite h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 900; color: var(--gold); font-size: 1.4rem; line-height: 1.15; }
.invite p { margin: 0 0 10px; color: var(--on-velvet); }
.invite .link-box {
  display: block; width: 100%; margin: 6px 0 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0,0,0,.3); color: var(--gold-hi); font-family: var(--display); font-size: .78rem; overflow-wrap: anywhere;
}
.invite .actions { justify-content: flex-start; }
.invite .muted { margin-top: 12px; }
.stat-invite { cursor: pointer; font-family: var(--display); color: var(--ink); background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-color: var(--gold); }

@media (min-width: 900px) {
  .card-page-body { --card-w: min(360px, calc((100dvh - 200px) * .714)); }
  .card-page { flex-direction: row; align-items: center; justify-content: center; gap: 64px; min-height: calc(100dvh - 170px); }
  .cp-stage { width: auto; flex: none; padding: 0 30px; }
}
@media (max-width: 420px) {
  .invite-label { display: none; }
  .stats { gap: 4px; }
  .stat { padding: 5px 9px 5px 7px; }
}
