:root {
  --bg: #1a0b2e; --ink: #fff4fb; --dim: #c9b3dd; --line: rgba(255, 200, 240, .16);
  --panel: rgba(36, 16, 58, .82); --panel2: rgba(58, 24, 88, .9);
  --pink: #ff5fb0; --pink2: #ff9ad0; --gold: #ffcf5a;
  --common: #a9b4c2; --uncommon: #55d98a; --rare: #44b0ff; --epic: #b766ff; --legendary: #ffb52e; --mythic: #ff4fa3;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 500 16px/1.45 'Baloo 2', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
.backdrop {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(26, 11, 46, .55), rgba(26, 11, 46, .92) 60%), url(art/backdrop.webp) center/cover no-repeat, var(--bg);
}
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
h2 { font-size: 20px; font-weight: 800; }
b.sym, .sym { color: var(--gold); }
.fine { color: var(--dim); font-size: 14px; }
.center { text-align: center; }

.primary {
  background: linear-gradient(180deg, #ff8ac8, #ff3d9a); color: #fff; font-weight: 800;
  padding: 10px 20px; border-radius: 999px; box-shadow: 0 4px 0 #b3165f, 0 8px 24px rgba(255, 61, 154, .35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25); transition: transform .08s;
}
.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #b3165f; }
.primary.big { font-size: 22px; padding: 14px 34px; }
.ghost { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); padding: 9px 18px; border-radius: 999px; font-weight: 700; }
.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.small { padding: 5px 12px; font-size: 14px; }
.icon { width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); display: grid; place-items: center; }
.icon svg { width: 20px; height: 20px; }
.icon.off { opacity: .45; }

/* ---------------- header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); background: rgba(20, 8, 36, .78); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font: 900 22px 'Cinzel Decorative', serif; white-space: nowrap; }
.brand img { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(255, 95, 176, .6)); }
.brand b { color: var(--pink2); }
.purse { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 6px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pill img { width: 24px; height: 24px; }
.pill.mined { color: #8ff0b6; padding-left: 10px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #55d98a; box-shadow: 0 0 8px #55d98a; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.sound { display: flex; gap: 6px; }
.paper { color: var(--ink); text-decoration: none; white-space: nowrap; }
.purse[hidden] + .paper { margin-left: auto; }

.tabs { display: flex; gap: 4px; justify-content: center; padding: 10px 12px 0; flex-wrap: wrap; }
.tabs button { background: transparent; padding: 8px 18px; border-radius: 999px; font-weight: 800; color: var(--dim); font-size: 17px; }
.tabs button.on { background: var(--panel2); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.panel h2 { margin-bottom: 10px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 10px; flex-wrap: wrap; }
.count { color: var(--dim); font-weight: 700; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------------- gate */
.gate { text-align: center; padding: 24px 0; }
.gate-logo { width: 180px; height: 120px; object-fit: contain; filter: drop-shadow(0 0 24px rgba(255, 95, 176, .7)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.gate h1 { font: 900 clamp(38px, 7vw, 68px) 'Cinzel Decorative', serif; text-shadow: 0 0 30px rgba(255, 95, 176, .6); }
.gate h1 b { color: var(--pink2); }
.lead { max-width: 640px; margin: 8px auto 20px; font-size: 19px; color: #f3dcf0; }
.gate-cards { display: flex; justify-content: center; margin: 10px 0 28px; height: 300px; }
.gate-cards .card { width: 170px; margin: 0 -26px; transform-origin: bottom center; }
.gate-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: center; }

/* ---------------- the card */
.card {
  --c: var(--common); position: relative; aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden;
  background: #120720; box-shadow: 0 0 0 3px var(--c), 0 0 0 5px rgba(0, 0, 0, .6), 0 10px 26px rgba(0, 0, 0, .55);
  container-type: inline-size; user-select: none;
}
.card[data-r=uncommon] { --c: var(--uncommon); }
.card[data-r=rare] { --c: var(--rare); }
.card[data-r=epic] { --c: var(--epic); box-shadow: 0 0 0 3px var(--c), 0 0 0 5px rgba(0, 0, 0, .6), 0 0 26px rgba(183, 102, 255, .55); }
.card[data-r=legendary] { --c: var(--legendary); box-shadow: 0 0 0 3px var(--c), 0 0 0 5px rgba(0, 0, 0, .6), 0 0 34px rgba(255, 181, 46, .65); }
.card[data-r=mythic] { --c: var(--mythic); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c), 0 0 44px rgba(255, 79, 163, .85), 0 0 80px rgba(120, 160, 255, .45); }
.card > img.art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .gems { position: absolute; top: 4cqw; left: 4cqw; display: flex; gap: 1.6cqw; }
.card .gems i { width: 6cqw; height: 6cqw; transform: rotate(45deg); background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 0 6px var(--c); }
.card .rtag { position: absolute; top: 3cqw; right: 3cqw; font: 800 6.5cqw/1 'Baloo 2'; padding: 1.5cqw 3cqw 1cqw; border-radius: 99px; background: rgba(0, 0, 0, .55); color: var(--c); letter-spacing: .04em; text-transform: uppercase; }
.card .plate {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12cqw 5cqw 4cqw;
  background: linear-gradient(transparent, rgba(10, 3, 20, .85) 45%, rgba(10, 3, 20, .95));
}
.card .name { font: 900 11cqw/1 'Cinzel Decorative', serif; color: #fff; text-shadow: 0 2px 6px #000; }
.card .title { font-size: 6.6cqw; color: var(--c); font-weight: 700; margin-top: 1cqw; }
.card .nums { display: flex; justify-content: space-between; margin-top: 2.5cqw; font: 800 6.6cqw/1 'Baloo 2'; font-variant-numeric: tabular-nums; }
.card .nums span { background: rgba(255, 255, 255, .1); border-radius: 99px; padding: 1.5cqw 3cqw 1cqw; }
.card .nums em { font-style: normal; color: var(--dim); font-weight: 700; margin-right: 1.5cqw; }
.card .slotted-mark { position: absolute; top: 14cqw; right: 3cqw; font: 800 5.5cqw/1 'Baloo 2'; background: #2b9b5b; padding: 1.5cqw 3cqw 1cqw; border-radius: 99px; }
/* foil for Epic and up */
.card[data-r=epic]::after, .card[data-r=legendary]::after, .card[data-r=mythic]::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: .35;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .7) 45%, rgba(255, 180, 230, .5) 50%, rgba(140, 200, 255, .6) 55%, transparent 70%);
  background-size: 300% 300%; animation: foil 4s linear infinite;
}
.card[data-r=mythic]::after { opacity: .55; animation-duration: 2.6s; background-image: linear-gradient(115deg, transparent 25%, #ff7ac8 38%, #ffe37a 46%, #7affc8 54%, #7ab8ff 62%, transparent 75%); }
@keyframes foil { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------------- summon */
.welcome {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(255, 95, 176, .35), rgba(183, 102, 255, .3)); border: 1px solid var(--pink); border-radius: var(--r); padding: 14px 18px; margin-bottom: 16px; font-size: 18px;
}
.packs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.pack {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; overflow: hidden;
}
.pack::before { content: ''; position: absolute; inset: -40% -20% auto; height: 70%; background: radial-gradient(closest-side, var(--glow), transparent); opacity: .5; pointer-events: none; }
.pack[data-p=sweetheart] { --glow: #ff5fb0; }
.pack[data-p=starlight] { --glow: #6c7bff; }
.pack[data-p=goddess] { --glow: #ffcf5a; }
.pack img { width: 76%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .5)); transition: transform .25s; position: relative; }
.pack:hover img { transform: translateY(-6px) rotate(-2deg) scale(1.03); }
.pack h3 { margin: 0; font: 900 22px 'Cinzel Decorative', serif; }
.pack .guar { color: var(--dim); font-size: 14px; min-height: 20px; }
.pack .price { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 20px; }
.pack .price img { width: 26px; height: 26px; filter: none; transform: none !important; }
.pack .row { display: flex; gap: 8px; margin-top: 4px; }
.oddsbar { display: flex; width: 100%; height: 8px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .08); margin: 4px 0; }
.oddsbar i { display: block; height: 100%; }

/* ---------------- collection */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 14px; border-radius: 99px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.chip.on { background: var(--c, var(--pink)); color: #170826; border-color: transparent; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.dex .slot { cursor: pointer; transition: transform .15s; position: relative; }
.dex .slot:hover { transform: translateY(-4px); }
.dex .locked .card > img.art { filter: brightness(0) saturate(0); opacity: .75; }
.dex .locked .card .plate { opacity: .55; }
.dex .badge { position: absolute; top: -8px; right: -8px; z-index: 2; background: var(--pink); border-radius: 99px; font-weight: 800; padding: 1px 9px; font-size: 14px; box-shadow: 0 2px 6px #000; }
.dex .no { position: absolute; bottom: -2px; left: 50%; transform: translate(-50%, 100%); font-size: 12px; color: var(--dim); }

/* ---------------- mine */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; }
.stat small { color: var(--dim); font-weight: 700; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat.claim { background: linear-gradient(160deg, rgba(85, 217, 138, .25), var(--panel)); }
.stat.claim b { color: #8ff0b6; }
.stat.claim button { margin-top: 6px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; }
.mslot { aspect-ratio: 2 / 3; border-radius: 14px; border: 2px dashed rgba(255, 200, 240, .3); display: grid; place-items: center; text-align: center; color: var(--dim); font-weight: 700; padding: 8px; position: relative; }
.mslot .card { width: 100%; cursor: pointer; }
.mslot.full { border: 0; }
.mslot.full::after { content: ''; position: absolute; inset: -6px; border-radius: 18px; box-shadow: 0 0 18px rgba(85, 217, 138, .55); pointer-events: none; animation: pulse 2s infinite; }
.mslot.lockd { border-style: solid; background: rgba(0, 0, 0, .25); }
.mslot.lockd button { margin-top: 6px; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.roster .item { display: flex; flex-direction: column; gap: 6px; }
.roster .item .card { cursor: pointer; }

/* ---------------- treasury */
.addr { font-family: ui-monospace, monospace; font-size: 13px; background: rgba(0, 0, 0, .35); padding: 8px 10px; border-radius: 10px; word-break: break-all; margin: 6px 0; }
input {
  font: inherit; color: var(--ink); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
.formrow { display: flex; gap: 8px; margin-top: 8px; }
.formrow input { flex: 1; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table td, .table th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--dim); font-size: 14px; }
.table .num { text-align: right; }
.plus { color: #8ff0b6; } .minus { color: #ff9ab8; }
.test-panel { border-color: var(--gold); }

/* ---------------- opening stage */
.stage {
  position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 45%, #3a1460, #12051f 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
}
.rays {
  position: absolute; inset: -50%; opacity: 0; transition: opacity .6s; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .09) 0 6deg, transparent 6deg 18deg);
  animation: spin 30s linear infinite;
}
.rays.on { opacity: 1; }
.rays.mythic { background: repeating-conic-gradient(from 0deg, rgba(255, 120, 200, .22) 0 6deg, rgba(255, 230, 120, .12) 6deg 12deg, transparent 12deg 18deg); animation-duration: 12s; }
@keyframes spin { to { transform: rotate(360deg); } }
.pack-img { width: min(46vh, 70vw); cursor: pointer; filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .6)); position: relative; }
.pack-img.shake { animation: shake .55s ease-in-out infinite; }
.pack-img.burst { animation: burst .45s ease-in forwards; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-4deg) scale(1.02); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg) scale(1.04); } 80% { transform: rotate(3deg); } }
@keyframes burst { to { transform: scale(1.5); opacity: 0; filter: brightness(3); } }
.deal { display: flex; gap: clamp(8px, 1.6vw, 22px); justify-content: center; flex-wrap: wrap; padding: 0 16px; position: relative; }
.flipper { width: clamp(120px, 16vw, 210px); aspect-ratio: 2 / 3; perspective: 1200px; cursor: pointer; opacity: 0; transform: translateY(60vh) rotate(-20deg); }
.flipper.in { animation: dealIn .5s cubic-bezier(.2, .9, .3, 1.2) forwards; }
@keyframes dealIn { to { opacity: 1; transform: none; } }
.flipper { position: relative; transition: opacity .5s, filter .5s; }
.flipper .inner { position: relative; width: 100%; height: 100%; transition: transform 1.05s cubic-bezier(.45, 0, .2, 1.25); transform-style: preserve-3d; }
.flipper.lift .inner { transform: translateY(-16px) scale(1.04); transition-duration: .35s; }
/* the build-up before a Legendary or Mythic */
.deal.focus .flipper:not(.charge) { opacity: .25 !important; filter: blur(2px); }
.flipper.charge { z-index: 3; }
.flipper.charge::before {
  content: ''; position: absolute; inset: -40%; border-radius: 50%; pointer-events: none; z-index: -1;
  background: radial-gradient(closest-side, var(--glow), transparent); opacity: .25; transform: scale(.6);
  transition: opacity .6s, transform .6s;
}
.flipper.charge[data-stage="2"]::before { opacity: .5; transform: scale(.9); }
.flipper.charge[data-stage="3"]::before { opacity: .8; transform: scale(1.2); }
.flipper.charge[data-stage="4"]::before { opacity: 1; transform: scale(1.6); }
.flipper.charge .back { box-shadow: 0 0 0 3px var(--glow), 0 0 30px var(--glow); }
.flipper.charge[data-stage="1"] .back { animation: quake 0.18s linear infinite; --q: 1.5px; }
.flipper.charge[data-stage="2"] .back { animation: quake 0.12s linear infinite; --q: 3px; filter: brightness(1.25); }
.flipper.charge[data-stage="3"] .back { animation: quake 0.08s linear infinite; --q: 5px; filter: brightness(1.6); box-shadow: 0 0 0 4px var(--glow), 0 0 60px var(--glow), 0 0 120px var(--glow); }
.flipper.charge[data-stage="4"] .back { animation: quake 0.05s linear infinite; --q: 8px; filter: brightness(2.2) saturate(1.4); box-shadow: 0 0 0 5px #fff, 0 0 80px var(--glow), 0 0 180px var(--glow); }
@keyframes quake {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(var(--q), calc(var(--q) * -1)) rotate(-1deg); }
  50% { transform: translate(calc(var(--q) * -1), var(--q)) rotate(1deg); }
  75% { transform: translate(var(--q), var(--q)) rotate(-.5deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
.flipper.open .inner { transform: rotateY(180deg); }
.flipper .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipper .face.front { transform: rotateY(180deg); }
.flipper .back { border-radius: 14px; overflow: hidden; background: url(art/card-back.webp) center/cover; box-shadow: 0 0 0 3px #3a1d55, 0 10px 26px rgba(0, 0, 0, .6); }
.flipper .back::after { content: ''; position: absolute; inset: 0; border-radius: 14px; box-shadow: inset 0 0 30px var(--hint, transparent), 0 0 26px var(--hint, transparent); animation: pulse 1.2s infinite; }
.flipper:not(.open):hover .inner { transform: translateY(-8px); }
.flipper .face.front .card { width: 100%; height: 100%; }
.stage-actions { display: flex; gap: 12px; margin-top: 28px; min-height: 48px; position: relative; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

.spotlight { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(10, 3, 20, .7); backdrop-filter: blur(6px); cursor: pointer; }
.spotlight .card { width: min(56vh, 80vw); animation: rise .8s cubic-bezier(.2, 1.2, .4, 1) both; }
.spotlight .who { margin-top: 18px; font: 900 clamp(26px, 4vw, 44px) 'Cinzel Decorative', serif; text-shadow: 0 0 20px var(--c); animation: rise .8s .2s both; }
.spotlight .sub { color: var(--dim); animation: rise .8s .35s both; }
@keyframes rise { from { opacity: 0; transform: scale(.6) translateY(40px); } }

/* ---------------- modal + toast */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(8, 2, 16, .72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; }
.sheet { background: var(--panel2); border: 1px solid var(--line); border-radius: 22px; padding: 20px; width: min(860px, 100%); max-height: 90vh; overflow: auto; position: relative; }
.sheet .x { position: absolute; top: 10px; right: 12px; }
.detail { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.detail .card { width: 100%; }
.detail h2 { font: 900 30px 'Cinzel Decorative', serif; }
.copies { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.copy { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 12px; font-variant-numeric: tabular-nums; }
.copy .tag { font-size: 13px; color: #8ff0b6; font-weight: 800; }
.oddsTable td:first-child { font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; background: #2a1144; border: 1px solid var(--pink); padding: 10px 18px; border-radius: 99px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: calc(100% - 32px); text-align: center; }
.toast.bad { border-color: #ff6b8a; }

/* ---------------- phone */
@media (max-width: 860px) {
  .packs { grid-template-columns: 1fr; }
  .pack img { width: 50%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat.claim { grid-column: span 2; }
  .twocol { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .detail .card { width: min(260px, 100%); margin: 0 auto; }
}
@media (max-width: 560px) {
  .brand span { display: none; }
  .pill.mined, .purse:not([hidden]) + .paper { display: none; }
  .tabs button { padding: 6px 11px; font-size: 15px; }
  .dex { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .roster { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .slots { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .gate-cards { height: 210px; }
  .gate-cards .card { width: 120px; margin: 0 -30px; }
  .flipper { width: calc((100vw - 64px) / 3); }
}
