:root {
  --ink: #f4e9d2;
  --ink-dim: #b9c7b4;
  --night: #0b0f24;
  --panel: #14182e;
  --panel2: #1c2240;
  --line: #2b3360;
  --gold: #f0c040;
  --gold-d: #a8741a;
  --red: #fe5f55;
  --blue: #009dff;
  --green: #2e6b4f;
  --C: #9fb4c7; --R: #3fa7ff; --E: #b25bff; --L: #ffb52e; --I: #ff3d6e;
  --px: 'Press Start 2P', monospace;
  --vt: 'VT323', monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --cw: min(64vw, 40vh, 340px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--vt); font-size: 20px; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
img { image-rendering: pixelated; image-rendering: crisp-edges; -webkit-user-drag: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--ink-dim); opacity: .7; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
#app { position: fixed; inset: 0; z-index: 2; }
.crt { position: fixed; inset: 0; pointer-events: none; z-index: 80;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply; }
body.no-crt .crt { display: none; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 70; background: #fff; opacity: 0; }
.toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--panel); border: 3px solid var(--gold); padding: 8px 14px; font-family: var(--px); font-size: 10px; letter-spacing: 1px; opacity: 0; transition: .25s; z-index: 90; pointer-events: none; box-shadow: 4px 4px 0 #000; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── HUD ───────────────────────────────────────── */
#hud { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + var(--safe-t)) 14px 10px; display: flex; align-items: center; gap: 14px; z-index: 20;
  background: linear-gradient(to bottom, rgba(6,10,24,.85), rgba(6,10,24,0)); }
.logo { display: flex; flex-direction: column; line-height: 1; font-family: var(--px); text-shadow: 3px 3px 0 #000; }
.logo .l1 { font-size: 16px; color: var(--gold); letter-spacing: 2px; }
.logo .l2 { font-size: 7px; color: var(--ink); margin-top: 5px; letter-spacing: 1px; }
.hud-stats { display: flex; gap: 12px; margin-left: auto; }
.stat { background: rgba(10,14,32,.85); border: 2px solid var(--line); padding: 4px 9px 5px; min-width: 70px; box-shadow: 3px 3px 0 #000; }
.stat .k { display: block; font-family: var(--px); font-size: 7px; color: var(--ink-dim); letter-spacing: 1px; }
.stat .v { font-size: 22px; line-height: 1; }
.stat .v b { color: var(--gold); font-weight: normal; }
.stat .bar { height: 4px; background: #000; margin-top: 3px; }
.stat .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #fff3b0); transition: width .5s; }
.hud-btns { display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; background: var(--panel); border: 2px solid var(--line); box-shadow: 3px 3px 0 #000; font-size: 18px; }
.icon-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 #000; }
@media (max-width: 560px) {
  .logo .l2 { display: none; } .logo .l1 { font-size: 12px; }
  .hud-stats { gap: 6px; } .stat { min-width: 58px; padding: 3px 6px; } .stat .v { font-size: 18px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  #hud { gap: 8px; padding-left: 10px; padding-right: 10px; }
}

/* ── buttons ───────────────────────────────────── */
.btn { font-family: var(--px); font-size: 11px; letter-spacing: 1px; padding: 12px 16px; background: var(--panel2); border: 3px solid #000; box-shadow: inset 0 -4px 0 rgba(0,0,0,.35), 4px 4px 0 #000; color: var(--ink); text-shadow: 2px 2px 0 #000; transition: transform .08s; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translate(3px,3px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.35), 1px 1px 0 #000; }
.btn.big { font-size: 14px; padding: 16px 22px; }
.btn.small { font-size: 9px; padding: 8px 10px; }
.btn.gold { background: linear-gradient(#ffd75e, #e09a12); color: #2a1500; text-shadow: 1px 1px 0 rgba(255,255,255,.5); }
.btn.red { background: linear-gradient(#ff7a6e, #c9302c); }
.btn.blue { background: linear-gradient(#3fb8ff, #0a6fcf); }

/* ── screens ───────────────────────────────────── */
.screen { position: absolute; inset: 0; }
.overlay { z-index: 40; background: rgba(5,8,20,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }

/* ── HOME / PACK ───────────────────────────────── */
#home { display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 40px; }
.pack-stage { perspective: 1100px; width: calc(var(--cw) * 1.02); height: calc(var(--cw) * 1.55); position: relative; touch-action: none; }
.home-hint { margin-top: 26px; font-family: var(--px); font-size: 10px; letter-spacing: 1px; text-shadow: 2px 2px 0 #000; animation: blink 1.2s steps(2) infinite; text-align: center; padding: 0 16px; line-height: 1.6; }
@keyframes blink { 50% { opacity: .35; } }
.tier-strip { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tier-chip { font-family: var(--px); font-size: 8px; padding: 5px 7px; background: rgba(8,12,28,.8); border: 2px solid currentColor; box-shadow: 2px 2px 0 #000; }

.pack { position: absolute; inset: 0; transform-style: preserve-3d; cursor: grab; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -6px; } }
.pack-body { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .12s ease-out; transform: rotateY(var(--ry,0deg)) rotateX(var(--rx,0deg)); }
.pack-foil { position: absolute; inset: 0;
  clip-path: polygon(0 3%, 3% 0, 6% 3%, 9% 0, 12% 3%, 15% 0, 18% 3%, 21% 0, 24% 3%, 27% 0, 30% 3%, 33% 0, 36% 3%, 39% 0, 42% 3%, 45% 0, 48% 3%, 51% 0, 54% 3%, 57% 0, 60% 3%, 63% 0, 66% 3%, 69% 0, 72% 3%, 75% 0, 78% 3%, 81% 0, 84% 3%, 87% 0, 90% 3%, 93% 0, 96% 3%, 100% 0, 100% 97%, 97% 100%, 94% 97%, 91% 100%, 88% 97%, 85% 100%, 82% 97%, 79% 100%, 76% 97%, 73% 100%, 70% 97%, 67% 100%, 64% 97%, 61% 100%, 58% 97%, 55% 100%, 52% 97%, 49% 100%, 46% 97%, 43% 100%, 40% 97%, 37% 100%, 34% 97%, 31% 100%, 28% 97%, 25% 100%, 22% 97%, 19% 100%, 16% 97%, 13% 100%, 10% 97%, 7% 100%, 4% 97%, 0 100%);
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.05) 0 6px, transparent 6px 14px),
    linear-gradient(160deg, #1b2a66 0%, #0e1440 45%, #2a0f4a 100%);
  overflow: hidden; }
.pack-art { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 25% 8% 9%; }
.pack-art .pk-brand { font-family: var(--px); color: var(--gold); font-size: calc(var(--cw) * .085); text-shadow: 3px 3px 0 #000, -1px -1px 0 #6b3d00; letter-spacing: 2px; }
.pack-art .pk-sub { font-family: var(--px); font-size: calc(var(--cw) * .036); margin-top: 6px; letter-spacing: 1px; color: #fff; text-shadow: 2px 2px 0 #000; }
.pack-art .pk-window { margin-top: 6%; background: radial-gradient(circle at 50% 40%, #3b2a7a, #120a2e 70%) !important; width: 66%; aspect-ratio: 5/7; position: relative; transform: rotate(-4deg); box-shadow: 6px 6px 0 rgba(0,0,0,.6); border: 3px solid #000; background: #000; }
.pack-art .pk-window img { width: 100%; height: 100%; display: block; opacity: .25; }
.pack-art .pk-window::after { content: '?'; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--px); font-size: calc(var(--cw)*.2); color: var(--gold); text-shadow: 4px 4px 0 #000; animation: qpulse 1.6s ease-in-out infinite; }
@keyframes qpulse { 50% { transform: scale(1.12); } }
.pack-art .pk-foot { margin-top: auto; display: flex; justify-content: space-between; width: 100%; font-family: var(--px); font-size: calc(var(--cw) * .032); color: var(--ink); text-shadow: 2px 2px 0 #000; }
.pack-art .pk-foot b { color: var(--gold); font-weight: normal; }
.pack-shine { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: .55;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.0) 38%, rgba(255,230,150,.65) 46%, rgba(120,200,255,.5) 52%, transparent 62%);
  background-size: 250% 100%; background-position: var(--sx, 50%) 0; }
.pack-shine.glint { animation: glint 3s ease-in-out infinite; }
@keyframes glint { 0%,60% { background-position: 150% 0; } 100% { background-position: -50% 0; } }
.pack-strip { position: absolute; left: 0; right: 0; top: 0; height: 13%; z-index: 3; transform-origin: 0% 100%; }
.pack-strip .strip-foil { position: absolute; inset: 0; clip-path: polygon(0 22%, 3% 0, 6% 22%, 9% 0, 12% 22%, 15% 0, 18% 22%, 21% 0, 24% 22%, 27% 0, 30% 22%, 33% 0, 36% 22%, 39% 0, 42% 22%, 45% 0, 48% 22%, 51% 0, 54% 22%, 57% 0, 60% 22%, 63% 0, 66% 22%, 69% 0, 72% 22%, 75% 0, 78% 22%, 81% 0, 84% 22%, 87% 0, 90% 22%, 93% 0, 96% 22%, 100% 0, 100% 100%, 0 100%); background: linear-gradient(#ffd75e, #c98a12); }
.pack-strip .strip-line { position: absolute; left: 4%; right: 4%; bottom: 5px; border-bottom: 3px dashed rgba(60,30,0,.7); }
.pack-strip .strip-text { position: absolute; inset: 22% 0 0; display: grid; place-items: center; font-family: var(--px); font-size: calc(var(--cw) * .03); color: #3a1d00; letter-spacing: 2px; }
.tear-progress { position: absolute; left: 0; top: 13%; height: 4px; width: 0; background: #fff; box-shadow: 0 0 12px 4px var(--hint, #fff); z-index: 4; }
.pack-leak { position: absolute; left: -10%; right: -10%; top: 9%; height: 8%; z-index: 2; opacity: 0; pointer-events: none; background: radial-gradient(ellipse at center, var(--hint, #fff) 0%, transparent 70%); filter: blur(4px); }
.pack-edge-glow { position: absolute; inset: -6px; z-index: -1; filter: blur(14px); opacity: .45; background: var(--hint, #fff); animation: edgepulse 2.4s ease-in-out infinite; }
@keyframes edgepulse { 50% { opacity: .2; } }
.pack.shake { animation: packshake .35s; }
@keyframes packshake { 20% { translate: -6px 2px; rotate: -3deg; } 40% { translate: 6px -2px; rotate: 3deg; } 60% { translate: -4px 0; rotate: -2deg; } 80% { translate: 3px 0; rotate: 1deg; } }

/* ── CARDS ─────────────────────────────────────── */
.card { --w: var(--cw); width: var(--w); height: calc(var(--w) * 1.4); position: absolute; transform-style: preserve-3d; font-size: calc(var(--w) / 17); }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,1.4,.4,1); transform: perspective(calc(var(--w) * 4)) rotateY(calc(var(--flip, 0deg) + var(--ry, 0deg))) rotateX(var(--rx, 0deg)); }
.card.down .inner { --flip: 180deg; }
.card .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--w) * .045); overflow: hidden; }
.card .back { transform: rotateY(180deg); background: #0f1830; border: calc(var(--w)*.012) solid #000; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.card .back img { width: 100%; height: 100%; display: block; }
.card .back .bk-logo { position: absolute; left: 0; right: 0; top: 12%; text-align: center; font-family: var(--px); color: var(--gold); font-size: 1.05em; text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
.card .back .bk-logo2 { position: absolute; left: 0; right: 0; bottom: 12%; text-align: center; font-family: var(--px); color: #fff; font-size: .5em; text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
.card .back .bk-glow { position: absolute; inset: 0; opacity: 0; background: radial-gradient(circle at center, var(--tc) 0%, transparent 70%); mix-blend-mode: screen; transition: opacity .3s; }
.card.charge .back .bk-glow { opacity: 1; animation: charge .5s ease-in-out infinite alternate; }
@keyframes charge { to { opacity: .4; } }

.card .front { background: var(--frame); border: calc(var(--w)*.012) solid #000; }
.card .f-wrap { position: absolute; inset: 3.2%; background: var(--plate); border-radius: calc(var(--w) * .03); overflow: hidden; box-shadow: inset 0 0 0 2px rgba(0,0,0,.6); }
.card .art { position: absolute; left: 6%; right: 6%; top: 15%; height: 54%; border: calc(var(--w)*.012) solid #000; background: #000; overflow: hidden; }
.card .art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card .top { position: absolute; left: 6%; right: 6%; top: 2.4%; height: 12%; display: flex; align-items: center; gap: .4em; }
.card .rating { font-family: var(--px); font-size: 1.55em; color: var(--rc, #fff); text-shadow: .12em .12em 0 #000; line-height: 1; }
.card .pos { font-family: var(--px); font-size: .62em; background: #000; color: #fff; padding: .25em .35em; }
.card .crest { margin-left: auto; height: 1.9em; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.6)); }
.card .tier-tag { position: absolute; right: 6%; top: calc(15% + 54% - 1.5em); z-index: 3; font-family: var(--px); font-size: .42em; padding: .35em .5em; background: var(--tc); color: #000; box-shadow: .15em .15em 0 #000; letter-spacing: .05em; }
.card .nick { position: absolute; left: 6%; right: 6%; top: 70.5%; text-align: center; font-family: var(--px); font-size: .44em; color: var(--tc); text-shadow: .15em .15em 0 #000; letter-spacing: .08em; }
.card .name { position: absolute; left: 4%; right: 4%; top: 73.5%; text-align: center; font-family: var(--vt); font-size: 1.5em; line-height: 1; color: #fff; text-shadow: .08em .08em 0 #000; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.card .stats { position: absolute; left: 6%; right: 6%; top: 82%; display: grid; grid-template-columns: repeat(6, 1fr); gap: .1em; text-align: center; }
.card .stats div { font-family: var(--vt); font-size: .82em; line-height: 1; color: var(--ink-dim); }
.card .stats b { display: block; font-family: var(--px); font-size: .56em; color: #fff; font-weight: normal; margin-top: .25em; }
.card .foot { position: absolute; left: 6%; right: 6%; bottom: 2.2%; display: flex; justify-content: space-between; align-items: center; font-family: var(--px); font-size: .4em; color: rgba(255,255,255,.75); }
.card .gem { width: .9em; height: .9em; background: var(--tc); transform: rotate(45deg); box-shadow: 0 0 0 .15em #000; display: inline-block; margin-right: .5em; }

/* holo + glare layers */
.card .holo, .card .glare { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.card .glare { background: radial-gradient(farthest-corner circle at var(--mx, 50%) var(--my, 30%), rgba(255,255,255,.55) 0%, rgba(255,255,255,.08) 30%, rgba(0,0,0,.25) 90%); mix-blend-mode: overlay; opacity: var(--glare, .35); }
.card .holo { opacity: 0; }

/* tier frames */
.card.t-C { --tc: var(--C); --rc: #e9f1f7; --frame: linear-gradient(160deg, #c8d4de, #7d8b98); --plate: linear-gradient(180deg, #2a3341, #151b25); }
.card.t-R { --tc: var(--R); --rc: #bfe4ff; --frame: linear-gradient(160deg, #8fd0ff, #1663b8 60%, #0b3b75); --plate: linear-gradient(180deg, #123058, #0a1a33); }
.card.t-E { --tc: var(--E); --rc: #f1d6ff; --frame: linear-gradient(160deg, #e3a8ff, #7a1fd1 55%, #3c0b6e); --plate: linear-gradient(180deg, #2c0f50, #150728); }
.card.t-L { --tc: var(--L); --rc: #fff1b8; --frame: linear-gradient(160deg, #fff3b0, #f0b429 35%, #b8740c 70%, #ffe08a); --plate: linear-gradient(180deg, #3d2605, #1a1002); }
.card.t-I { --tc: var(--I); --rc: #ffe3f0; --frame: conic-gradient(from var(--ang, 0deg), #ff3d6e, #ffb52e, #fff36b, #3dffb0, #3fa7ff, #b25bff, #ff3d6e); --plate: linear-gradient(180deg, #2a0630, #0d0214); animation: spinang 4s linear infinite; }
@property --ang { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@keyframes spinang { to { --ang: 360deg; } }

/* rare: metallic sheen */
.card.t-R .holo { opacity: .5; mix-blend-mode: color-dodge; background: linear-gradient(115deg, transparent 35%, rgba(140,210,255,.7) 48%, transparent 60%); background-size: 300% 300%; background-position: var(--mx,50%) var(--my,50%); }
/* epic: rainbow holo over the art */
.card.t-E .holo, .card.t-L .holo, .card.t-I .holo { opacity: .7; mix-blend-mode: color-dodge;
  background:
    repeating-linear-gradient(110deg, #ff0077 0%, #ffd400 6%, #00ff9d 12%, #00b3ff 18%, #b000ff 24%, #ff0077 30%),
    radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,.6), transparent 60%);
  background-size: 260% 260%, 100% 100%; background-position: var(--mx,50%) var(--my,50%), center;
  filter: brightness(.6) contrast(1.6) saturate(1.2); }
.card.t-E .holo { opacity: .3; }
.card.t-L .holo { opacity: .34; }
/* legendary: + sparkle */
.card.t-L .holo::after, .card.t-I .holo::after { content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle, #fff 0 1px, transparent 1.5px), radial-gradient(circle, #fff6c0 0 1px, transparent 1.5px);
  background-size: 23px 29px, 37px 31px; background-position: calc(var(--mx,50%) * .3) calc(var(--my,50%) * .3), calc(var(--mx,50%) * -.4) 7px;
  mix-blend-mode: screen; opacity: .9; animation: twinkle 1.4s steps(3) infinite; }
@keyframes twinkle { 50% { opacity: .35; } }
.card.t-I .holo { opacity: .36; }
.card.t-L .face.front, .card.t-I .face.front { box-shadow: 0 0 0 2px #000; }
.card.t-L, .card.t-I { filter: drop-shadow(0 0 calc(var(--w)*.05) var(--tc)); }
.card.t-E { filter: drop-shadow(0 0 calc(var(--w)*.025) var(--tc)); }
.card.dull { filter: none !important; }
.card.dull .holo::after { animation: none; }

.card .badge { position: absolute; z-index: 5; top: -0.6em; left: -0.6em; font-family: var(--px); font-size: .62em; padding: .45em .6em; background: #ff2f4f; color: #fff; border: .15em solid #000; box-shadow: .2em .2em 0 #000; transform: rotate(-10deg) translateZ(30px); animation: pop .4s cubic-bezier(.2,2,.4,1); }
.card .badge.dupe { background: #3a4466; }
@keyframes pop { from { transform: rotate(-10deg) scale(0); } }

/* ── OPENING ───────────────────────────────────── */
#opening { perspective: 1200px; z-index: 30; }
#opening .dim { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .4s; pointer-events: none; }
#opening .stage { position: absolute; inset: 0; transform-style: flat; }
#opening .stage .card { left: 50%; top: 50%; margin-left: calc(var(--w) / -2); margin-top: calc(var(--w) * -.7); will-change: transform; }
.banner { position: absolute; left: 0; right: 0; top: 13%; text-align: center; font-family: var(--px); font-size: clamp(22px, 6vw, 54px); letter-spacing: 3px; color: var(--bc, #fff); text-shadow: 4px 4px 0 #000, 0 0 24px var(--bc, #fff); opacity: 0; pointer-events: none; transform: scale(.5); z-index: 40; }
.banner.show { animation: bannerIn 1.6s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes bannerIn { 0% { opacity: 0; transform: scale(2.4); } 18% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1) translateY(-10px); } }
.reveal-hint { position: absolute; left: 0; right: 0; bottom: calc(120px + var(--safe-b)); text-align: center; font-family: var(--px); font-size: 10px; letter-spacing: 1px; text-shadow: 2px 2px 0 #000; opacity: .9; animation: blink 1.2s steps(2) infinite; pointer-events: none; }
.pack-counter { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.pack-counter i { width: 12px; height: 12px; background: rgba(255,255,255,.15); border: 2px solid #000; }
.pack-counter i.done { background: var(--gold); }
.pack-counter i.cur { background: #fff; animation: blink .6s steps(2) infinite; }
.stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) scale(3); font-family: var(--px); font-size: clamp(24px, 7vw, 64px); color: #fff; text-shadow: 5px 5px 0 #000; opacity: 0; z-index: 41; pointer-events: none; white-space: nowrap; text-align: center; }
.stamp small { display: block; font-size: .3em; margin-top: 10px; color: var(--ink-dim); letter-spacing: 2px; }
.stamp.go { animation: stamp .6s cubic-bezier(.2,1.8,.4,1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%,-50%) scale(3); } 35% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.95); } }
.beam { position: absolute; left: 50%; top: 50%; width: 200vmax; height: 200vmax; margin: -100vmax 0 0 -100vmax; pointer-events: none; opacity: 0; z-index: 1;
  background: repeating-conic-gradient(from 0deg, var(--bc, #fff) 0 6deg, transparent 6deg 18deg); mask: radial-gradient(circle, #000 0%, transparent 45%); -webkit-mask: radial-gradient(circle, #000 0%, transparent 45%); animation: spin 14s linear infinite; transition: opacity .6s; }
.beam.on { opacity: .35; }
@keyframes spin { to { rotate: 360deg; } }

/* ── SUMMARY ───────────────────────────────────── */
#summary { z-index: 35; display: grid; place-items: center; background: rgba(5,8,20,.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn .3s; }
.sum-panel { text-align: center; padding: 0 12px; }
.sum-title { font-family: var(--px); font-size: 16px; color: var(--gold); text-shadow: 3px 3px 0 #000; letter-spacing: 2px; }
.sum-row { display: flex; gap: 10px; justify-content: center; margin: 26px 0 18px; perspective: 900px; flex-wrap: wrap; }
.sum-row .card { position: relative; --w: min(17vw, 120px); animation: sumIn .5s cubic-bezier(.2,1.5,.4,1) backwards; }
@keyframes sumIn { from { transform: translateY(40px) rotate(8deg); opacity: 0; } }
.sum-line { font-size: 24px; margin-bottom: 20px; text-shadow: 2px 2px 0 #000; }
.sum-line b { color: var(--gold); font-weight: normal; }
.sum-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ── BINDER BUTTON ─────────────────────────────── */
#binderBtn { position: absolute; right: 16px; bottom: calc(16px + var(--safe-b)); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.binder-icon { width: 64px; height: 78px; background: linear-gradient(135deg, #6b2a17, #3d1409); border: 3px solid #000; box-shadow: 4px 4px 0 #000, inset 5px 0 0 #8a3a22, inset -3px -3px 0 rgba(0,0,0,.4); position: relative; display: grid; place-items: center; font-family: var(--px); font-size: 12px; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.binder-icon .rings { position: absolute; left: 4px; top: 10px; bottom: 10px; width: 6px; background: repeating-linear-gradient(to bottom, #d9d9d9 0 6px, transparent 6px 16px); }
.binder-icon.bump { animation: bump .35s cubic-bezier(.2,2,.4,1); }
@keyframes bump { 40% { transform: scale(1.18) rotate(-4deg); } }
.binder-label { font-family: var(--px); font-size: 7px; text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }

/* ── BINDER ────────────────────────────────────── */
#binder { display: flex; flex-direction: column; padding: calc(12px + var(--safe-t)) 10px calc(12px + var(--safe-b)); z-index: 55; }
.binder-top { display: flex; align-items: center; gap: 10px; }
.binder-title { flex: 1; text-align: center; font-family: var(--px); font-size: 14px; color: var(--gold); text-shadow: 3px 3px 0 #000; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.binder-title small { font-size: 9px; color: var(--ink); }
.binder-filter { font-family: var(--px); font-size: 10px; min-width: 80px; text-align: right; }
.binder-tabs { display: flex; gap: 4px; justify-content: center; margin: 10px 0 6px; flex-wrap: wrap; }
.binder-tab { width: 36px; height: 40px; display: grid; place-items: center; background: #2a1208; border: 2px solid #000; box-shadow: 2px 2px 0 #000; position: relative; }
.binder-tab img { width: 20px; }
.binder-tab.on { background: var(--gold); transform: translateY(-3px); }
.binder-tab.full::after { content: '★'; position: absolute; top: -8px; right: -6px; font-size: 13px; color: var(--gold); text-shadow: 1px 1px 0 #000; }
.binder-tab .dot { position: absolute; bottom: -5px; left: 50%; translate: -50% 0; width: 7px; height: 7px; background: #ff2f4f; border: 1px solid #000; }
.binder-book { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; perspective: 1800px; min-height: 0; }
.binder-pages { position: relative; height: 100%; max-height: 100%; aspect-ratio: 0.78; max-width: calc(100vw - 90px); transform-style: preserve-3d; }
.page { position: absolute; inset: 0; padding: 4% 4% 4% 7%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2.5%;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 2px, transparent 2px 6px),
    linear-gradient(135deg, #5b2414, #3a140a 60%, #2b0e06);
  border: 4px solid #000; box-shadow: 8px 8px 0 rgba(0,0,0,.6), inset 12px 0 0 rgba(0,0,0,.3); border-radius: 4px 12px 12px 4px; transform-origin: left center; backface-visibility: hidden; }
.page::before { content: ''; position: absolute; left: 2%; top: 6%; bottom: 6%; width: 2.4%; background: repeating-linear-gradient(to bottom, #cfcfcf 0 4%, #7a7a7a 4% 5%, transparent 5% 16%); border-radius: 4px; }
.page.turn-out-l { animation: turnOutL .45s ease-in forwards; }
.page.turn-in-r { animation: turnInR .45s ease-out; }
.page.turn-out-r { animation: turnOutR .45s ease-in forwards; }
.page.turn-in-l { animation: turnInL .45s ease-out; }
@keyframes turnOutL { to { transform: rotateY(-100deg); opacity: .2; } }
@keyframes turnInR { from { transform: rotateY(70deg); opacity: .2; } }
@keyframes turnOutR { to { transform: rotateY(80deg); opacity: .2; } }
@keyframes turnInL { from { transform: rotateY(-90deg); opacity: .2; } }
.pocket { position: relative; container-type: size; background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.03) 40%, rgba(255,255,255,.08)); border: 2px solid rgba(255,255,255,.18); border-radius: 4px; display: grid; place-items: center; }
.pocket::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.14) 40%, transparent 50%); border-radius: inherit; }
.pocket .card { --w: min(100cqw, 71cqh); position: relative; cursor: pointer; }
.pocket .card.fresh::before { content: 'NEW'; position: absolute; z-index: 9; top: -6px; right: -6px; font-family: var(--px); font-size: 7px; padding: 3px 4px; background: #ff2f4f; border: 2px solid #000; color: #fff; }
.pocket .card .inner { transition: transform .2s; }
.pocket .card:hover .inner { transform: translateY(-4px) rotate(-2deg) scale(1.04); }
.pocket .empty { width: min(100cqw, 71cqh); aspect-ratio: 5/7; border: 2px dashed color-mix(in srgb, var(--tc) 60%, transparent); border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(0,0,0,.35); }
.pocket .empty .q { font-family: var(--px); font-size: clamp(14px, 4vw, 26px); color: color-mix(in srgb, var(--tc) 70%, transparent); text-shadow: 2px 2px 0 #000; }
.pocket .empty .n { font-family: var(--px); font-size: clamp(6px, 1.6vw, 9px); color: rgba(255,255,255,.45); }
.pocket .empty .tn { font-family: var(--px); font-size: clamp(5px, 1.3vw, 7px); color: var(--tc); opacity: .75; }
.pocket .count { position: absolute; z-index: 9; bottom: -4px; right: -4px; font-family: var(--px); font-size: 8px; padding: 3px 4px; background: #000; color: var(--gold); border: 1px solid var(--gold); }
.page-arrow { font-size: 20px; width: 36px; height: 60px; background: var(--panel); border: 2px solid #000; box-shadow: 3px 3px 0 #000; flex: none; }

/* ── INSPECT ───────────────────────────────────── */
#inspect { z-index: 65; display: flex; flex-direction: column; align-items: center; justify-content: center; perspective: 1100px; background: rgba(3,5,14,.85); }
.inspect-stage { position: relative; width: min(78vw, 46vh, 380px); height: calc(min(78vw, 46vh, 380px) * 1.4); }
.inspect-stage .card { --w: min(78vw, 46vh, 380px); left: 0; top: 0; animation: inspIn .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes inspIn { from { transform: scale(.4) rotateY(-120deg); opacity: 0; } }
.inspect-info { margin-top: 22px; text-align: center; font-size: 22px; text-shadow: 2px 2px 0 #000; line-height: 1.3; }
.inspect-info b { font-family: var(--px); font-size: 11px; color: var(--gold); font-weight: normal; }

/* ── LEADERBOARD / MENU ────────────────────────── */
#board, #menu { display: grid; place-items: center; z-index: 56; padding: 16px; }
.board-panel { width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); border: 4px solid #000; box-shadow: 8px 8px 0 #000, inset 0 0 0 3px var(--line); padding: 18px; }
.board-head { display: flex; align-items: center; justify-content: space-between; }
.board-head h2 { margin: 0; font-family: var(--px); font-size: 16px; color: var(--gold); text-shadow: 3px 3px 0 #000; }
.board-sub { color: var(--ink-dim); margin: 8px 0 12px; font-size: 19px; }
.board-list { overflow-y: auto; touch-action: pan-y; display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel2); border: 2px solid #000; }
.row.me { border-color: var(--gold); }
.row .rk { font-family: var(--px); font-size: 13px; color: var(--ink-dim); text-align: center; }
.row:nth-child(1) .rk { color: var(--gold); } .row:nth-child(2) .rk { color: #d6e2ea; } .row:nth-child(3) .rk { color: #e0905a; }
.row .nm { font-size: 22px; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .nm small { display: block; font-size: 16px; color: var(--ink-dim); margin-top: 2px; }
.row .pb { height: 6px; background: #000; margin-top: 5px; } .row .pb i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #fff3b0); }
.row .sc { text-align: right; font-family: var(--px); font-size: 11px; line-height: 1.5; }
.row .sc small { display: block; font-family: var(--vt); font-size: 16px; color: var(--ink-dim); }
.row .crown { color: var(--gold); }
.menu-body { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; overflow-y: auto; touch-action: pan-y; }
.menu-body p { margin: 0; color: var(--ink-dim); font-size: 19px; line-height: 1.25; }
.menu-body .odds { width: 100%; border-collapse: collapse; font-size: 18px; }
.menu-body .odds td, .menu-body .odds th { border: 1px solid var(--line); padding: 3px 5px; text-align: center; }
.menu-body .odds th { font-family: var(--px); font-size: 8px; color: var(--ink-dim); font-weight: normal; }

/* ── ONBOARD ───────────────────────────────────── */
#onboard { z-index: 75; display: grid; place-items: center; background: rgba(3,6,16,.55); overflow-y: auto; }
.title-card { text-align: center; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-logo .t1 { font-family: var(--px); font-size: clamp(34px, 10vw, 72px); color: var(--gold); text-shadow: 5px 5px 0 #000, -2px -2px 0 #6b3d00; letter-spacing: 4px; animation: titleWob 3s ease-in-out infinite; }
.title-logo .t2 { font-family: var(--px); font-size: clamp(12px, 3.2vw, 22px); margin-top: 10px; text-shadow: 3px 3px 0 #000; letter-spacing: 3px; }
.title-logo .t3 { font-family: var(--px); font-size: clamp(7px, 1.8vw, 10px); margin-top: 10px; color: var(--ink-dim); letter-spacing: 2px; }
@keyframes titleWob { 50% { transform: rotate(-2deg) scale(1.03); } }
.title-cards { position: relative; height: calc(var(--tw) * 1.4 + 20px); width: 100%; --tw: min(26vw, 130px); perspective: 900px; margin: 8px 0; }
.title-cards .card { --w: var(--tw); left: 50%; top: 10px; margin-left: calc(var(--tw) / -2); animation: fanIn .8s cubic-bezier(.2,1.4,.4,1) backwards; }
@keyframes fanIn { from { transform: translateY(60px) rotate(0deg); opacity: 0; } }
.title-copy { font-size: 22px; line-height: 1.25; text-shadow: 2px 2px 0 #000; margin: 0; }
.title-copy b { color: var(--gold); font-weight: normal; }
#nameInput { font-family: var(--px); font-size: 14px; text-align: center; padding: 14px; width: min(320px, 86vw); background: #070a18; color: var(--gold); border: 3px solid var(--gold); box-shadow: 4px 4px 0 #000; outline: none; text-transform: uppercase; letter-spacing: 2px; user-select: text; -webkit-user-select: text; }
#nameInput::placeholder { color: #6d6450; }
.onboard-err { color: var(--red); min-height: 22px; font-size: 20px; }

/* screen shake */
.shake-s { animation: shakeS .15s linear; } .shake-m { animation: shakeM .3s linear; } .shake-l { animation: shakeL .4s linear; }
@keyframes shakeS { 25% { translate: -4px 2px; } 50% { translate: 4px -2px; } 75% { translate: -2px 0; } }
@keyframes shakeM { 20% { translate: -8px 4px; } 40% { translate: 7px -5px; } 60% { translate: -5px 3px; } 80% { translate: 3px -2px; } }
@keyframes shakeL { 15% { translate: -12px 6px; } 30% { translate: 11px -7px; } 45% { translate: -9px 5px; } 60% { translate: 7px -4px; } 75% { translate: -4px 2px; } 90% { translate: 2px -1px; } }

@media (prefers-reduced-motion: reduce) { .pack, .title-logo .t1 { animation: none; } }
.auto-btn { position: absolute; left: 16px; bottom: calc(22px + var(--safe-b)); z-index: 45; }
.auto-btn.on { background: linear-gradient(#ffd75e, #e09a12); color: #2a1500; text-shadow: none; }
.stat.sp b { color: #7fe3ff; }
@media (max-width: 420px) { .stat.sp { display: none; } }
.dialog { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: rgba(3,5,14,.7); animation: fadeIn .15s; padding: 16px; }
.dialog .board-panel { width: min(420px, 100%); text-align: center; gap: 14px; }
.dialog .dl-body { font-size: 21px; line-height: 1.25; }
.dialog .dl-body b { color: var(--gold); font-weight: normal; }
.dialog .dl-btns { display: flex; gap: 12px; justify-content: center; }
.pocket .scoutable { font-family: var(--px); font-size: clamp(5px, 1.3vw, 7px); background: #7fe3ff; color: #00222e; padding: 3px 4px; border: 1px solid #000; animation: blink 1s steps(2) infinite; }
.complete-banner { position: fixed; inset: 0; z-index: 77; display: grid; place-items: center; text-align: center; background: rgba(3,5,14,.92); padding: 16px; animation: fadeIn .4s; }
.complete-banner .cb1 { font-family: var(--px); font-size: clamp(22px, 6vw, 56px); color: var(--gold); text-shadow: 5px 5px 0 #000; }
.complete-banner .cb2 { font-size: 30px; margin: 18px 0 24px; text-shadow: 2px 2px 0 #000; }
@media (max-width: 420px) {
  .binder-tabs { gap: 3px; flex-wrap: nowrap; }
  .binder-tab { width: 31px; height: 34px; } .binder-tab img { width: 17px; }
  .page-arrow { width: 26px; font-size: 14px; }
  .binder-pages { max-width: calc(100vw - 70px); }
  .binder-title { font-size: 11px; }
}
