
:root{
  --bg:#e8e5df;--ink:#141414;--muted:#6f6f6b;
  --pack:#2b3ff0;
  --ease-out:cubic-bezier(.23,1,.32,1);
  --spring:linear(0,0.055,0.193,0.378,0.577,0.767,0.93,1.056,1.142,1.19,1.205,1.195,1.167,1.13,1.089,1.05,1.016,0.99,0.972,0.961,0.958,0.96,0.965,0.973,0.981,0.989,0.996,1.002,1.006,1.008,1);
  /* pouch is 0.69:1; cards are 5:7 and a little narrower than the pouch so they fit inside it */
  --ph:min(420px,58vh,58svh,120vw);--pw:calc(var(--ph)*.69);--cw:calc(var(--pw)*.84);--ch:calc(var(--cw)*1.4);
  --crimp:calc(var(--ph)*.068);--d:16px;
  --rainbow:repeating-linear-gradient(110deg,#ff7aa8 0%,#ffcf6b 5%,#a8ff8a 10%,#6be2ff 15%,#9b8cff 20%,#ff7aa8 25%);
  /* thresholded noise: sparse white specks for glitter */
  --glitter:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.8' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 14 0 0 0 -8.6'/></filter><rect width='160' height='160' filter='url(%23g)'/></svg>");
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
html{overscroll-behavior:none;touch-action:manipulation;-webkit-text-size-adjust:100%}   /* no pull-to-refresh halfway through a tear */
body{overflow:hidden;background:radial-gradient(120% 90% at 50% 38%,#f3f1ec,var(--bg) 58%,#d8d4cb);color:var(--ink);
  font-family:-apple-system,"SF Pro Text",system-ui,sans-serif;-webkit-font-smoothing:antialiased}
i{font-style:normal}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

/* ---------- stage: one 3D context so the pack's front face can hide the cards inside it ---------- */
.stage{position:fixed;inset:0;overflow:hidden;perspective:1400px;perspective-origin:50% 40%;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.scene{position:absolute;inset:0;transform-style:preserve-3d;pointer-events:none}   /* its own box is a plane at z=0 that would swallow presses on anything tilted behind it */
.hit,.card{pointer-events:auto}
.pack,.card{position:absolute;left:50%;top:50%;transform-style:preserve-3d;will-change:transform}
.pack{width:var(--pw);height:var(--ph);margin:calc(var(--ph)/-2) 0 0 calc(var(--pw)/-2)}
.ground{position:absolute;left:50%;top:50%;width:calc(var(--pw)*.95);height:calc(var(--pw)*.16);margin:calc(var(--pw)*-.08) 0 0 calc(var(--pw)*-.475);
  border-radius:50%;background:radial-gradient(closest-side,rgb(30 25 15/.3),transparent);filter:blur(6px)}

/* ---------- pouch skin: shared by both faces and the tear strip so the strip matches pixel for pixel ---------- */
.skin{position:absolute;inset:0;backface-visibility:hidden;transform:translateZ(calc(var(--d)/2));--tooth:calc(var(--pw)/26);
  background:
    var(--shade,none) 0 0/100% 100%,   /* crumpled shadow above the bottom seal, drawn for each pack in script */
    linear-gradient(90deg,transparent 91%,rgb(0 0 0/.14) 97.6%) 0 50%/100% calc(100% - 2*var(--crimp)) no-repeat,   /* the right side turns away from the light */
    repeating-linear-gradient(90deg,rgb(0 0 0/.18) 0 1px,rgb(255 255 255/.08) 1px 2px,transparent 2px 5px) 0 0/100% var(--crimp) no-repeat,   /* heat-seal ridges */
    repeating-linear-gradient(90deg,rgb(0 0 0/.18) 0 1px,rgb(255 255 255/.08) 1px 2px,transparent 2px 5px) 0 100%/100% var(--crimp) no-repeat,
    var(--pack);
  mask:   /* crimped teeth, and a filled body that sits a little narrower than its flat seals */
    conic-gradient(from 135deg at 50% 0,#0000,#000 1deg 89deg,#0000 90deg) 0 0/var(--tooth) calc(var(--tooth)/2) repeat-x,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'><path d='M0 0H100V5.6C100 8 97.6 7.6 97.6 10V90C97.6 92.4 100 92 100 94.4V100H0V94.4C0 92 2.4 92.4 2.4 90V10C2.4 7.6 0 8 0 5.6Z'/></svg>") 0 50%/100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at 50% 100%,#0000,#000 1deg 89deg,#0000 90deg) 0 100%/var(--tooth) calc(var(--tooth)/2) repeat-x}
.skin.back{transform:rotateY(180deg) translateZ(calc(var(--d)/2))}
/* light on the foil, laid over the print so it reads as a reflection, not as part of the design. a glint runs down the left edge and
   slides as the pack turns; a shine sits where the foil swells out under the top seal, its hot spot moving along it as the pack turns
   and brightening as the top tips toward the light */
.skin::before,.skin::after{content:"";position:absolute;inset:0;z-index:1;pointer-events:none}
.skin::before{background:linear-gradient(90deg,transparent 2.4%,rgb(255 255 255/.7) 3%,rgb(255 255 255/.28) 5%,transparent 9%);
  mask:linear-gradient(transparent 7%,#000 13% 48%,transparent 84%);translate:calc(var(--gx,0)*1%) 0;opacity:var(--gl,.8)}
.skin::after{background:var(--shine,none) 0 0/100% 100%;opacity:var(--gt,.85);
  mask:linear-gradient(90deg,rgb(0 0 0/.45),#000 40% 60%,rgb(0 0 0/.45)) calc(var(--gm,50)*1%) 0/250% 100%}
.scene.flat{transform-style:flat;perspective:1400px;perspective-origin:50% 40%}   /* once out of the pack each card is its own layer, stacked in order, so cards can never cut through each other */
.rim{position:absolute}   /* rounded sides, built in script */
/* the rainbow flow pours out of the tear. it sits between the faces, so the wrapper hides where it starts and only the torn part lets it out.
   it is a layer of its own that rides with the pack until the pack drops away */
.flow{position:absolute;left:50%;top:50%;width:var(--pw);height:var(--ph);margin:calc(var(--ph)/-2) 0 0 calc(var(--pw)/-2);transform-style:preserve-3d;pointer-events:none}
.rays{position:absolute;left:0;width:100%;top:calc(10.5% - var(--pw)*.6);height:calc(var(--pw)*.76);overflow:visible;opacity:0;transform:translateZ(-6px)}

/* print */
.tag{position:absolute;left:9%;top:calc(var(--crimp) + .9%);font:700 calc(var(--pw)*.029)/1 system-ui,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:rgb(255 255 255/.74)}
.mark{position:absolute;left:9%;top:15%;font:800 calc(var(--pw)*.17)/1 ui-rounded,"SF Pro Rounded",system-ui,sans-serif;letter-spacing:-.045em;color:#fff}
.series{position:absolute;right:9%;top:17.5%;font:600 calc(var(--pw)*.036)/1 system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:rgb(255 255 255/.7)}
.foot{position:absolute;bottom:calc(var(--crimp) + 3.4%);font:500 calc(var(--pw)*.042)/1 system-ui,sans-serif;color:rgb(255 255 255/.78)}
.foot.l{left:9%}.foot.r{right:9%}
/* the mascot: a chrome sparkle, modelled and rendered like the card characters. its colours shift a little as the pack tilts; eyes and mouth are live layers so it can blink and grimace */
.orb{position:absolute;left:8%;width:84%;top:26.5%;aspect-ratio:1;transition:scale .35s var(--spring)}
.body,.shade{position:absolute;inset:0;width:100%;height:100%}
.orb .body{filter:hue-rotate(calc(var(--sh,0)*1deg))}
.shade{translate:0 3.5%;filter:brightness(0) blur(calc(var(--pw)*.024));opacity:.34}
.eye{position:absolute;transition:opacity .09s,scale .14s var(--ease-out)}
.pupil{display:block;width:100%;height:auto;transition:scale .2s var(--ease-out)}
.smile{position:absolute;height:auto;transition:opacity .08s,scale .2s var(--ease-out)}
/* each character's own expression when its card is hovered */
.joy{position:absolute;height:auto;opacity:0;scale:.7;transition:opacity .09s,scale .34s var(--spring)}
.glad .joy{opacity:1;scale:1}
.glad .eye,.glad .smile{opacity:0;scale:.7}
/* pain while it is being torn: eyes screw shut into > <, a wobbly grimace, a bead of sweat, and the face trembles */
.ouch{position:absolute;height:auto;opacity:0;scale:.6;transition:opacity .08s,scale .24s var(--spring)}
.drip{position:absolute;height:auto;opacity:0;scale:.7;translate:0 -45%;transition:opacity .18s,scale .3s var(--spring),translate .5s var(--ease-out)}
.held .orb{scale:1.06 .92;animation:tremble 90ms steps(2) infinite}   /* scrunches up */
.held .eye{scale:1 0}
.held .smile{opacity:0;scale:.3}
.held .ouch{opacity:1;scale:1}
.hurt .drip{opacity:1;scale:1;translate:0 0}   /* only while it hurts: let go and it gets over it */
@keyframes tremble{50%{translate:1.2px -.8px}}
@media (hover:hover) and (pointer:fine){.pack:has(.hit:hover) .pupil{scale:1.06}.pack:has(.hit:hover) .smile{scale:1.1}}
.fin{position:absolute;left:45%;width:10%;top:0;bottom:0;
  background:repeating-linear-gradient(rgb(0 0 0/.14) 0 1px,transparent 1px 4px),linear-gradient(90deg,rgb(0 0 0/.3),rgb(255 255 255/.18) 45%,rgb(0 0 0/.22))}
.mark.sm{left:0;right:0;top:20%;text-align:center;font-size:calc(var(--pw)*.1)}
.blurb{position:absolute;left:10%;right:10%;top:40%;margin:0;text-align:center;font:500 calc(var(--pw)*.044)/1.5 system-ui,sans-serif;color:rgb(255 255 255/.85)}
.code{position:absolute;left:31%;right:31%;bottom:calc(var(--crimp) + 6%);height:10%;padding:6px 8px;border-radius:4px;
  background:repeating-linear-gradient(90deg,#111 0 2px,#0000 2px 3px,#111 3px 4px,#0000 4px 7px,#111 7px 10px,#0000 10px 12px) content-box,#fff}

/* tear strip: slices along its length, each bent a little further than the last so the loose end curls toward you and shows the silver inside of the foil */
.flap{position:absolute;inset:0;transform-style:preserve-3d;visibility:hidden}
.flap.on{visibility:visible}
.ply{position:absolute;inset:0;transform-style:preserve-3d;transform-origin:0 0}
.ply .front{transform:translateZ(.4px)}
.skin.foil{transform:rotateY(180deg) translateZ(.4px);background:linear-gradient(97deg,#e3e8f2,#fff 12%,#cfd7e6 26%,#fff 44%,#dbe1ee 58%,#fff 76%,#d3dbe9)}
.skin.foil::before,.skin.foil::after{display:none}
.tone{position:absolute;inset:0;z-index:3;background:#0b0d1c;opacity:0}
/* the torn edge: the bright metal layer of the foil, thin and uneven, casting a little shadow onto the print on the pack's side */
.lips{position:absolute;inset:0;z-index:2;filter:drop-shadow(0 1.5px 1.2px rgb(0 0 0/.42))}
.lip{position:absolute;inset:0;z-index:2;clip-path:polygon(0 0);background:linear-gradient(100deg,#f4f6fb,#fff 14%,#bfc8da 27%,#fff 42%,#c9d1e1 58%,#fbfcff 72%,#b9c2d4 86%,#eef1f7)}
.hit{position:absolute;inset:-24px -16px -8px;margin:0;padding:0;border:0;border-radius:14px;   /* reaches past the edges: people grab a pack by its top */background:none;appearance:none;cursor:grab;touch-action:none;
  transform:translateZ(calc(var(--d)/2 + 1px));-webkit-tap-highlight-color:transparent}
.hit:focus-visible{outline:2px solid #0a84ff;outline-offset:8px}
.held .hit,.tug .hit{cursor:grabbing}
.tug .orb{scale:.95 1.07}   /* being pulled about doesn't hurt: it just stretches along */
.card:focus{outline:none}
.card:focus-visible .face{outline:2px solid #0a84ff;outline-offset:3px}

/* ---------- cards ---------- */
.card{width:var(--cw);height:var(--ch);margin:calc(var(--ch)/-2) 0 0 calc(var(--cw)/-2);touch-action:none;--px:50;--py:50;--hyp:0}
.face,.slab{position:absolute;inset:0;border-radius:calc(var(--cw)*.05)}
.slab{background:var(--edge);pointer-events:none}   /* stacked copies = real edge thickness when tilted */
.slab:nth-child(1){transform:translateZ(-1.5px)}
.slab:nth-child(2){transform:translateZ(-3px)}
.slab:nth-child(3){transform:translateZ(-4.5px);box-shadow:0 26px 40px -16px rgb(20 16 40/.5)}
.face{overflow:hidden;isolation:isolate;container-type:inline-size;background:var(--frame);color:var(--text)}
.win{position:absolute;left:6%;right:6%;top:4.3%;height:60%;border-radius:4cqw;overflow:hidden;box-shadow:inset 0 2px 5px rgb(0 0 0/.35),inset 0 0 0 1px rgb(0 0 0/.12)}
.drop{position:absolute;left:28%;right:28%;bottom:7%;height:8%;border-radius:50%;background:radial-gradient(closest-side,rgb(0 0 0/.5),transparent);filter:blur(1.5px);opacity:0;transition:opacity .4s}
.out .drop{opacity:1}
.name{position:absolute;left:7%;top:68.5%;font:700 9.5cqw/1 ui-rounded,"SF Pro Rounded",system-ui,sans-serif;letter-spacing:-.02em}
.type{position:absolute;right:7%;top:69.5%;padding:1.6cqw 2.6cqw;border-radius:9cqw;background:rgb(127 127 127/.16);font:600 3.6cqw/1 system-ui,sans-serif;letter-spacing:.1em;text-transform:uppercase}
.rule{position:absolute;left:7%;right:7%;top:83%;height:1px;background:currentColor;opacity:.15}
.no,.rar{position:absolute;bottom:5.5%;font:500 3.8cqw/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}
.no{left:7%;opacity:.6}.rar{right:7%;font-weight:600;opacity:.8}
/* character lies flat while stacked in the pack, then stands up off the card once it is out */
.pop{position:absolute;left:11%;width:78%;top:5.5%;aspect-ratio:1;transform:translateZ(.5px);transition:transform .7s var(--spring);pointer-events:none}
.out .pop{transform:translateZ(calc(var(--cw)*.14))}
.pop .body{filter:drop-shadow(0 3px 5px rgb(0 0 0/.3))}

/* foil: rainbow follows the tilt, glitter specks catch it, glare sits where the light hits */
.holo,.glare{position:absolute;inset:0;z-index:2;border-radius:inherit;pointer-events:none}
.holo{background:var(--rainbow) calc(var(--px)*1%) calc(var(--py)*1%)/400% 400%;mix-blend-mode:color-dodge;opacity:calc(.3 + var(--hyp)*.6);filter:brightness(.7) contrast(1.5) saturate(1.4)}
.holo::after{content:"";position:absolute;inset:0;border-radius:inherit;background:inherit;mask:var(--glitter) 0 0/140px 140px;filter:brightness(1.8)}
.glare{background:radial-gradient(farthest-corner circle at calc(var(--px)*1%) calc(var(--py)*1%),rgb(255 255 255/.8),rgb(255 255 255/.12) 38%,rgb(0 0 0/.3));mix-blend-mode:overlay;opacity:calc(.25 + var(--hyp)*.55)}
/* glaze: a thick clear coat over the whole card. two studio windows reflect in it and slide across as it tilts, a hot spot follows the light, and the coat pools bright along the top edge */
.glaze{position:absolute;inset:0;z-index:3;border-radius:inherit;pointer-events:none;
  box-shadow:inset 0 0 0 1px rgb(255 255 255/.28),inset 0 2px 1.5px rgb(255 255 255/.8),inset 0 -2px 4px rgb(0 0 0/.18);
  background:radial-gradient(42% 26% at calc(var(--px)*1%) calc(var(--py)*1%),rgb(255 255 255/calc(.1 + var(--hyp)*.5)),#0000),linear-gradient(rgb(255 255 255/.24),#0000 16%)}
.glaze::before{content:"";position:absolute;inset:0;border-radius:inherit;mask:linear-gradient(#000 30%,#0000 88%);
  background:linear-gradient(112deg,#0000 44%,rgb(255 255 255/.4) 44.4%,rgb(255 255 255/.13) 52%,#0000 52.4%,#0000 54%,rgb(255 255 255/.22) 54.3%,rgb(255 255 255/.05) 56.4%,#0000 56.7%) calc((100 - var(--px))*1%) 0/220% 100%}
.common{--frame:linear-gradient(165deg,#fdfcf9,#ebe8e1);--text:#1b1a17;--edge:#cfcac0}
.common .holo{inset:4.3% 6% 35.7%;border-radius:4cqw;mask:var(--glitter) 0 0/110px 110px;opacity:calc(.55 + var(--hyp)*.45)}   /* glitter on the art only */
.common .holo::after{display:none}
.rare{--frame:linear-gradient(165deg,#272d63,#11142e);--text:#eef0ff;--edge:#0b0d20}
.ultra{--frame:linear-gradient(135deg,#f9e7a8,#d6a43a 28%,#fff2c4 50%,#c38a26 72%,#f4d57e);--text:#3a2600;--edge:#94661a}
.ultra .holo{mix-blend-mode:overlay;opacity:calc(.5 + var(--hyp)*.5);
  background:repeating-conic-gradient(from calc(var(--px)*1deg) at 50% 40%,#0000 0 3deg,rgb(255 255 255/.45) 4deg 5deg,#0000 6deg 10deg),var(--rainbow) calc(var(--px)*1%) calc(var(--py)*1%)/400% 400%}
.blip{--frame:linear-gradient(165deg,#ffe8dc,#f9c9b3);--edge:#dba68f}
.cubit{--frame:linear-gradient(165deg,#ecf8cd,#c9e6a2);--edge:#a4c37a}
.blip .win{background:repeating-radial-gradient(circle at 50% 62%,#ffb59c 0 7%,#ffa384 7% 14%)}
.cubit .win{background:repeating-linear-gradient(30deg,rgb(255 255 255/.14) 0 1px,#0000 1px 16px),repeating-linear-gradient(150deg,rgb(255 255 255/.14) 0 1px,#0000 1px 16px),linear-gradient(#1f8a6f,#0f5446)}
.facet .win{background:radial-gradient(circle at 50% 42%,#7d66ff,#2c1f86 55%,#160f4a)}
.ringo .win{background:radial-gradient(circle,#fff 0 1px,#0000 1.6px) 0 0/26px 26px,radial-gradient(circle,rgb(255 255 255/.6) 0 .8px,#0000 1.3px) 13px 9px/19px 19px,linear-gradient(165deg,#0a1033,#1f34c8)}
.nova .win{background:radial-gradient(circle at 50% 56%,rgb(255 232 160/.95),#0000 55%),repeating-conic-gradient(from 0deg at 50% 56%,#ff5fa2 0 7.5deg,#ff8f5c 7.5deg 15deg)}

/* confetti */
.fx{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}   /* all the confetti on one canvas: 240 moving elements would each be a layer of their own */

/* ---------- chrome ---------- */
.again{position:fixed;left:50%;bottom:max(24px,5vh);translate:-50% 0;white-space:nowrap;-webkit-tap-highlight-color:transparent;font:inherit;font-size:15px;padding:12px 18px;border-radius:12px;background:#fff;color:var(--ink);cursor:pointer;
  border:1px solid rgb(0 0 0/.1);box-shadow:0 1px 0 rgb(255 255 255/.9) inset,0 -1px 0 rgb(0 0 0/.04) inset,0 1px 2px rgb(0 0 0/.06),0 10px 24px -12px rgb(0 0 0/.25);
  transition:opacity .3s var(--ease-out),scale .16s var(--ease-out)}
@starting-style{.again{opacity:0}}
.again:active{scale:.97}
.again:focus-visible{outline:2px solid #0a84ff;outline-offset:3px}
.mute{-webkit-tap-highlight-color:transparent;position:fixed;right:16px;top:16px;width:44px;height:44px;display:grid;place-items:center;padding:0;border:0;border-radius:50%;background:rgb(255 255 255/.72);color:var(--ink);cursor:pointer;transition:scale .16s cubic-bezier(.23,1,.32,1),background-color .16s}
.mute:active{scale:.94}
.mute:focus-visible{outline:2px solid #0a84ff;outline-offset:3px}
.mute .off,.mute[aria-pressed="true"] .on{display:none}
.mute[aria-pressed="true"] .off{display:block}
@media (hover:hover) and (pointer:fine){.mute:hover{background:#fff}}
@media (pointer:coarse){   /* phones: a card's thickness needs only one edge layer at this size, and the pack's colour shimmer is a filter redrawn on every tilt */
  .slab:nth-child(-n+2){display:none}
  .orb .body{filter:none}
}

@media (prefers-reduced-motion:reduce){
  .held .orb{animation:none}
  .card .face,.card .pop{transition:opacity .25s ease}
  @starting-style{.card .face,.card .pop{opacity:0}}
}
