/* =========================================================
   Card Pack Opening  -  Pokemon TCG Pocket style presentation
   Pure CSS 3D + blend modes + a 2D canvas particle layer.
   No external assets, no CDN, no runtime network access.
   ========================================================= */

.cg-app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px 0 60px;
}

/* ---------------------------------------------------------
   Stage
   --------------------------------------------------------- */
.cg-stage {
    position: relative;
    min-height: 660px;
    padding: 26px 18px 42px;
    border-radius: 18px;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(ellipse 80% 55% at 50% 0%, #223061 0%, rgba(34, 48, 97, 0) 70%),
        radial-gradient(ellipse 60% 50% at 50% 100%, #1b1440 0%, rgba(27, 20, 64, 0) 70%),
        linear-gradient(180deg, #0d1226 0%, #070912 100%);
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55), 0 18px 50px rgba(0, 0, 0, 0.3);
    color: #eaf0ff;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* faint starfield */
.cg-stage::before {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background-image: var(--cg-glitter, none);
    background-size: 260px 260px;
    opacity: 0.30;
    pointer-events: none;
    z-index: 0;
}

.cg-screen {
    position: relative;
    z-index: 2;
    display: none;
    text-align: center;
}

.cg-screen-active {
    display: block;
}

.cg-hidden {
    display: none !important;
}

.cg-result-actions {
    position: relative;
    z-index: 3;
    margin-top: 18px;
}

.cg-header {
    margin-bottom: 26px;
}

.cg-title {
    margin: 6px 0 6px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    text-shadow: 0 2px 18px rgba(120, 170, 255, 0.45);
}

.cg-sub {
    margin: 0;
    font-size: 14px;
    color: #93a2c9;
}

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */
.cg-btn {
    display: inline-block;
    margin: 0 6px;
    padding: 11px 24px;
    border: 1px solid rgba(150, 180, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #dce6ff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.cg-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(180, 205, 255, 0.6);
    transform: translateY(-2px);
}

.cg-btn-primary {
    background: linear-gradient(135deg, #4d7bff, #8a4dff);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 22px rgba(90, 110, 255, 0.45);
}

.cg-btn-primary:hover {
    background: linear-gradient(135deg, #5d89ff, #9a5dff);
}

.cg-link-btn {
    position: absolute;
    top: 0;
    left: 4px;
    z-index: 5;
    padding: 0;
    border: none;
    background: none;
    color: #8fa8dd;
    font-size: 13px;
    cursor: pointer;
}

.cg-link-btn:hover {
    color: #cfe0ff;
    text-decoration: underline;
}

/* ---------------------------------------------------------
   Pack themes (shared palette hooks)
   --------------------------------------------------------- */
.cg-theme-grove { --pk1: #2f7d43; --pk2: #0c2a15; --pk-accent: #7ef29a; }
.cg-theme-abyss { --pk1: #1f6689; --pk2: #06202f; --pk-accent: #6fd8ff; }
.cg-theme-vault { --pk1: #6234a0; --pk2: #190c33; --pk-accent: #c89bff; }

/* ---------------------------------------------------------
   Screen 1 - pack selection
   --------------------------------------------------------- */
.cg-pack-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    perspective: 1200px;
}

.cg-pack-choice {
    position: relative;
    width: 210px;
    height: 300px;
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    transform-style: preserve-3d;
    background: linear-gradient(165deg, var(--pk1), var(--pk2));
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5);
    transform:
        rotateX(calc(var(--ry, 0) * 1deg))
        rotateY(calc(var(--rx, 0) * 1deg))
        translateZ(0);
    transition: box-shadow 0.25s ease;
}

.cg-pack-choice.cg-tilting {
    transition: none;
}

.cg-pack-choice:hover {
    box-shadow: 0 22px 46px rgba(0, 0, 0, 0.62), 0 0 30px rgba(var(--pk-glow, 120, 160, 255), 0.35);
}

/* diagonal foil weave */
.cg-pack-choice .cg-choice-foil {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background:
        repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.10) 0 6px, rgba(255, 255, 255, 0) 6px 16px),
        repeating-linear-gradient(65deg, rgba(0, 0, 0, 0.14) 0 8px, rgba(0, 0, 0, 0) 8px 18px);
    pointer-events: none;
}

/* pointer-following sheen */
.cg-pack-choice .cg-choice-glare {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: radial-gradient(circle at var(--px, 50%) var(--py, 50%),
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0.14) 26%,
        rgba(255, 255, 255, 0) 58%);
    mix-blend-mode: soft-light;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.cg-pack-choice:hover .cg-choice-glare {
    opacity: 1;
}

.cg-pack-choice .cg-choice-icon {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    font-size: 68px;
    line-height: 1;
    text-align: center;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

.cg-pack-choice .cg-choice-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 14px 18px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.62) 55%);
    pointer-events: none;
}

.cg-pack-choice h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.cg-pack-choice p {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
}

/* ---------------------------------------------------------
   Screen 2 - the pack + tear
   --------------------------------------------------------- */
.cg-pack-stage {
    position: relative;
    height: 470px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1400px;
}

.cg-pack {
    position: relative;
    width: 250px;
    height: 360px;
    cursor: grab;
    touch-action: none;
    transform-style: preserve-3d;
    transform:
        rotateX(calc(var(--ry, 0) * 1deg))
        rotateY(calc(var(--rx, 0) * 1deg));
}

.cg-pack.cg-grabbing {
    cursor: grabbing;
}

.cg-pack-body,
.cg-pack-torn {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(165deg, var(--pk1), var(--pk2));
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.6);
}

/* the strip that peels away; hidden until a tear starts */
.cg-pack-torn {
    opacity: 0;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

.cg-pack.cg-torn-active .cg-pack-torn {
    opacity: 1;
}

.cg-pack-foil {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background:
        repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.11) 0 7px, rgba(255, 255, 255, 0) 7px 18px),
        repeating-linear-gradient(65deg, rgba(0, 0, 0, 0.16) 0 9px, rgba(0, 0, 0, 0) 9px 20px);
    pointer-events: none;
}

/* travelling metallic sheen on the wrapper */
.cg-pack-sheen {
    position: absolute;
    top: -30%;
    left: -70%;
    width: 46%;
    height: 160%;
    background: linear-gradient(78deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.42) 48%,
        rgba(255, 255, 255, 0.62) 52%,
        rgba(255, 255, 255, 0) 100%);
    animation: cg-pack-sheen 3.6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes cg-pack-sheen {
    0%   { transform: translateX(0) rotate(6deg); }
    55%  { transform: translateX(560px) rotate(6deg); }
    100% { transform: translateX(560px) rotate(6deg); }
}

.cg-pack-icon {
    position: absolute;
    top: 88px;
    left: 0;
    right: 0;
    font-size: 88px;
    line-height: 1;
    text-align: center;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
    pointer-events: none;
}

.cg-pack-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 42px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

/* glow that spills out of the opening */
.cg-pack-glow {
    position: absolute;
    top: 12%;
    left: 50%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffffff 0%, rgba(190, 225, 255, 0.85) 30%, rgba(140, 190, 255, 0) 70%);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}

/* the bright rip running along the tear */
.cg-tear-line {
    position: absolute;
    left: 0;
    top: 0;
    height: 5px;
    width: 0;
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.95) 22%,
        #ffffff 60%,
        rgba(215, 235, 255, 0.98) 100%);
    box-shadow: 0 0 16px 5px rgba(180, 220, 255, 0.9), 0 0 34px 12px rgba(120, 180, 255, 0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 4;
}

/* swipe prompt */
.cg-swipe-hint {
    position: relative;
    z-index: 3;
    margin-top: 2px;
    font-size: 14px;
    color: #a8bce8;
    transition: opacity 0.3s ease;
}

.cg-swipe-hint.cg-hide {
    opacity: 0;
}

.cg-swipe-arrow {
    display: inline-block;
    margin-right: 8px;
    font-size: 22px;
    font-weight: 700;
    color: #cfe2ff;
    animation: cg-swipe-nudge 1.4s ease-in-out infinite;
}

@keyframes cg-swipe-nudge {
    0%, 100% { transform: translateX(-8px); opacity: 0.35; }
    50%      { transform: translateX(10px); opacity: 1; }
}

/* ---------------------------------------------------------
   Stage FX - god rays, flash, particle canvas
   --------------------------------------------------------- */
.cg-rays {
    position: absolute;
    top: 46%;
    left: 50%;
    width: 1500px;
    height: 1500px;
    margin: -750px 0 0 -750px;
    background: repeating-conic-gradient(from 0deg,
        rgba(255, 255, 255, 0) 0deg 3.4deg,
        rgba(255, 255, 255, 0.55) 3.4deg 5.4deg,
        rgba(255, 255, 255, 0) 5.4deg 9deg);
    -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, 0.95) 6%, rgba(0, 0, 0, 0.55) 22%, rgba(0, 0, 0, 0) 58%);
    mask-image: radial-gradient(circle, rgba(0, 0, 0, 0.95) 6%, rgba(0, 0, 0, 0.55) 22%, rgba(0, 0, 0, 0) 58%);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.6s ease;
    animation: cg-rays-spin 26s linear infinite;
}

.cg-rays.cg-rays-on {
    opacity: 0.30;
}

.cg-rays.cg-rays-hot {
    opacity: 0.62;
    animation-duration: 13s;
}

@keyframes cg-rays-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.cg-fx-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
}

.cg-flash {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    z-index: 7;
}

.cg-flash.cg-flash-fire {
    animation: cg-flash-anim 0.62s ease-out;
}

@keyframes cg-flash-anim {
    0%   { opacity: 0; }
    12%  { opacity: 0.92; }
    100% { opacity: 0; }
}

/* ---------------------------------------------------------
   Screen 3 - reveal
   --------------------------------------------------------- */
.cg-counter {
    position: relative;
    z-index: 3;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #9fb4e2;
}

.cg-counter em {
    font-style: normal;
    color: #fff;
}

.cg-card-stack {
    position: relative;
    height: 470px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1400px;
}

.cg-reveal-hint {
    position: relative;
    z-index: 3;
    font-size: 13px;
    color: #8fa4d2;
    animation: cg-pulse 1.8s ease-in-out infinite;
}

.cg-reveal-hint.cg-hide {
    opacity: 0;
}

@keyframes cg-pulse {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}

/* ---------------------------------------------------------
   The card
   --------------------------------------------------------- */
/* relative, not absolute: only one card is ever mounted at a time,
   so this inherits the stack's flex centring reliably */
.cg-card-slot {
    position: relative;
    width: 250px;
    height: 350px;
    transform-style: preserve-3d;
}

/* tilt wrapper */
.cg-card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform:
        rotateX(calc(var(--ry, 0) * 1deg))
        rotateY(calc(var(--rx, 0) * 1deg));
    transition: transform 0.4s cubic-bezier(.2, .6, .3, 1);
}

.cg-card.cg-tilting {
    transition: none;
}

/* flip wrapper */
.cg-card-flip {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 0.85s cubic-bezier(.3, .8, .25, 1);
}

.cg-card-slot.cg-flipped .cg-card-flip {
    transform: rotateY(180deg);
}

.cg-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    box-sizing: border-box;
}

/* ---- card back ---- */
.cg-face-back {
    background:
        radial-gradient(circle at 50% 42%, rgba(120, 165, 255, 0.42) 0%, rgba(120, 165, 255, 0) 55%),
        repeating-linear-gradient(45deg, #1a2450 0 9px, #141c3d 9px 18px);
    border: 5px solid #2c3a72;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.cg-face-back::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 96px;
    height: 96px;
    margin: -48px 0 0 -48px;
    border-radius: 50%;
    border: 4px solid rgba(160, 195, 255, 0.5);
    background: radial-gradient(circle, rgba(150, 190, 255, 0.34) 0%, rgba(150, 190, 255, 0) 70%);
}

/* ---- card front ---- */
.cg-face-front {
    transform: rotateY(180deg);
    isolation: isolate;
    padding: 12px;
    background: linear-gradient(168deg, #1b2344 0%, #0d1226 100%);
    border: 5px solid var(--rc, #8892a8);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), var(--rglow, 0 0 0 rgba(0,0,0,0));
}

.cg-card-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.cg-card-pips {
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 3;
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--rc, #cfd6e6);
    text-shadow: 0 0 10px var(--rc, #cfd6e6);
}

.cg-card-art {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background:
        radial-gradient(circle at 50% 45%, var(--ra, rgba(120, 150, 210, 0.5)) 0%, rgba(10, 14, 30, 0) 68%),
        linear-gradient(180deg, #101736 0%, #0a0e1f 100%);
    box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.6);
}

.cg-card-emoji {
    font-size: 96px;
    line-height: 1;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.6));
}

.cg-card-plate {
    flex: 0 0 auto;
    margin-top: 8px;
    padding: 8px 6px 6px;
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.cg-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.cg-card-rname {
    margin-top: 2px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--rc, #a9b4cc);
}

/* ---------------------------------------------------------
   Foil / holo layers  (driven by --px/--py/--bx/--by from JS)
   --------------------------------------------------------- */
.cg-lay {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 2;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    /* cheap anti-aliasing for layers composited on a rotated plane */
    outline: 1px solid transparent;
}

/* Rainbow refraction. The 1px scanline layer blended over the rainbow is
   what makes this read as physical foil rather than a plain CSS gradient -
   without it the whole effect looks generic. */
.cg-lay-holo {
    background-image:
        repeating-linear-gradient(90deg, #6a6a6a 0 1px, rgba(0, 0, 0, 0) 1px 3px),
        repeating-linear-gradient(
            -22deg,
            hsl(0, 100%, 62%)   0%,
            hsl(45, 100%, 62%)  6%,
            hsl(100, 100%, 62%) 12%,
            hsl(175, 100%, 62%) 18%,
            hsl(240, 100%, 66%) 24%,
            hsl(300, 100%, 64%) 30%,
            hsl(360, 100%, 62%) 36%
        );
    background-size: 3px 3px, 260% 260%;
    background-position: center, var(--bx, 50%) var(--by, 50%);
    background-blend-mode: overlay, normal;
    mix-blend-mode: color-dodge;
    filter: brightness(0.9) contrast(2.1) saturate(1.05);
}

/* sparkle dust */
.cg-lay-glitter {
    background-image: var(--cg-glitter, none);
    background-size: 190px 190px;
    background-position: var(--bx, 50%) var(--by, 50%);
    mix-blend-mode: color-dodge;
    filter: brightness(1.15) contrast(1.5);
}

/* Pointer glare. Under mix-blend-mode:overlay mid-grey is a no-op, so this
   must END DARK rather than at transparent - that lets it brighten near the
   cursor AND darken the far side. That push-pull is what sells a curved,
   reflective surface; fading to transparent loses half the illusion. */
.cg-lay-glare {
    background: radial-gradient(farthest-corner circle at var(--px, 50%) var(--py, 50%),
        hsla(0, 0%, 100%, 0.78) 10%,
        hsla(0, 0%, 100%, 0.55) 22%,
        hsla(0, 0%, 0%, 0.5) 90%);
    mix-blend-mode: overlay;
}

/* gold shimmer reserved for the top tier */
.cg-lay-gold {
    background-image: repeating-linear-gradient(
        -22deg,
        #7a4d00 0%,
        #ffd76a 7%,
        #fff6cf 12%,
        #ffd76a 17%,
        #7a4d00 24%
    );
    background-size: 240% 240%;
    background-position: var(--bx, 50%) var(--by, 50%);
    mix-blend-mode: color-dodge;
    filter: brightness(0.95) contrast(1.9) saturate(1.2);
}

/* which layers switch on, per foil class */
.cg-face-front[data-foil="holo"]    .cg-lay-holo    { opacity: 0.42; }
.cg-face-front[data-foil="holo"]    .cg-lay-glare   { opacity: 0.75; }

.cg-face-front[data-foil="rainbow"] .cg-lay-holo    { opacity: 0.72; }
.cg-face-front[data-foil="rainbow"] .cg-lay-glitter { opacity: 0.55; }
.cg-face-front[data-foil="rainbow"] .cg-lay-glare   { opacity: 0.9; }

.cg-face-front[data-foil="gold"]    .cg-lay-gold    { opacity: 0.8; }
.cg-face-front[data-foil="gold"]    .cg-lay-glitter { opacity: 0.7; }
.cg-face-front[data-foil="gold"]    .cg-lay-glare   { opacity: 0.95; }

/* plain tiers still get a soft pointer sheen */
.cg-face-front[data-foil="none"]    .cg-lay-glare   { opacity: 0.34; }

/* ---------------------------------------------------------
   Rarity palettes
   --------------------------------------------------------- */
/* NB: --rglow is concatenated into a box-shadow list, so its "off"
   value must be a valid shadow, not `none`. */
.cg-r-d1    { --rc: #9fb0c9; --ra: rgba(120, 150, 200, 0.45); --rglow: 0 0 0 rgba(0, 0, 0, 0); }
.cg-r-d2    { --rc: #6fd48a; --ra: rgba(80, 200, 130, 0.45);  --rglow: 0 0 0 rgba(0, 0, 0, 0); }
.cg-r-d3    { --rc: #58a6ff; --ra: rgba(70, 140, 255, 0.5);   --rglow: 0 0 26px rgba(88, 166, 255, 0.5); }
.cg-r-d4    { --rc: #b98cff; --ra: rgba(150, 100, 255, 0.5);  --rglow: 0 0 30px rgba(185, 140, 255, 0.6); }
.cg-r-s1    { --rc: #ff8ad4; --ra: rgba(255, 120, 200, 0.5);  --rglow: 0 0 34px rgba(255, 138, 212, 0.65); }
.cg-r-s2    { --rc: #7ef0e0; --ra: rgba(110, 240, 220, 0.5);  --rglow: 0 0 38px rgba(126, 240, 224, 0.7); }
.cg-r-crown { --rc: #ffd76a; --ra: rgba(255, 200, 90, 0.55);  --rglow: 0 0 44px rgba(255, 215, 106, 0.8); }

/* breathing glow on the high tiers */
.cg-r-s1 .cg-face-front,
.cg-r-s2 .cg-face-front,
.cg-r-crown .cg-face-front {
    animation: cg-card-breathe 2.4s ease-in-out infinite;
}

@keyframes cg-card-breathe {
    0%, 100% { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), var(--rglow, 0 0 0 rgba(0,0,0,0)); }
    50%      { box-shadow: 0 18px 46px rgba(0, 0, 0, 0.6), var(--rglow, 0 0 0 rgba(0,0,0,0)), var(--rglow, 0 0 0 rgba(0,0,0,0)); }
}

/* ---------------------------------------------------------
   Card entrance / exit motion
   --------------------------------------------------------- */
.cg-card-slot.cg-enter {
    animation: cg-card-enter 0.5s cubic-bezier(.2, .8, .3, 1) both;
}

@keyframes cg-card-enter {
    0%   { opacity: 0; transform: translateY(52px) scale(0.82); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.cg-card-slot.cg-leave {
    animation: cg-card-leave 0.42s cubic-bezier(.5, 0, .75, 0) both;
}

@keyframes cg-card-leave {
    0%   { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(-150%, -26px) scale(0.86) rotate(-16deg); }
}

/* the "something good is coming" pre-reveal pop */
.cg-card-slot.cg-hype .cg-card-flip {
    animation: cg-hype 0.72s ease-in-out;
}

@keyframes cg-hype {
    0%   { transform: scale(1) rotateY(0deg); }
    35%  { transform: scale(1.07) rotateY(0deg); }
    70%  { transform: scale(0.99) rotateY(0deg); }
    100% { transform: scale(1) rotateY(0deg); }
}

/* ---------------------------------------------------------
   Screen 4 - summary fan
   --------------------------------------------------------- */
.cg-summary-fan {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 14px;
    min-height: 320px;
    margin-bottom: 26px;
    perspective: 1200px;
}

.cg-mini {
    position: relative;
    width: 150px;
    height: 210px;
    border-radius: 11px;
    overflow: hidden;
    isolation: isolate;
    box-sizing: border-box;
    padding: 8px;
    background: linear-gradient(168deg, #1b2344 0%, #0d1226 100%);
    border: 3px solid var(--rc, #8892a8);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55), var(--rglow, 0 0 0 rgba(0,0,0,0));
    cursor: default;
    opacity: 0;
    transform: translateY(24px);
    animation: cg-mini-in 0.45s ease forwards;
    transition: transform 0.22s ease;
}

.cg-mini:hover {
    transform: translateY(-10px) scale(1.04);
    z-index: 2;
}

@keyframes cg-mini-in {
    to { opacity: 1; transform: translateY(0); }
}

.cg-mini-art {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 128px;
    border-radius: 6px;
    background:
        radial-gradient(circle at 50% 45%, var(--ra, rgba(120, 150, 210, 0.5)) 0%, rgba(10, 14, 30, 0) 68%),
        linear-gradient(180deg, #101736 0%, #0a0e1f 100%);
    font-size: 58px;
    line-height: 1;
}

.cg-mini-name {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
}

.cg-mini-pips {
    margin-top: 3px;
    font-size: 11px;
    color: var(--rc, #a9b4cc);
    text-shadow: 0 0 8px var(--rc, #a9b4cc);
}

.cg-mini .cg-lay {
    border-radius: 6px;
    opacity: 0;
}

.cg-mini[data-foil="holo"]    .cg-lay-holo  { opacity: 0.34; }
.cg-mini[data-foil="rainbow"] .cg-lay-holo  { opacity: 0.6; }
.cg-mini[data-foil="gold"]    .cg-lay-gold  { opacity: 0.72; }

.cg-mini .cg-lay-holo,
.cg-mini .cg-lay-gold {
    animation: cg-mini-foil 4.5s ease-in-out infinite;
}

@keyframes cg-mini-foil {
    0%, 100% { background-position: 12% 20%; }
    50%      { background-position: 88% 80%; }
}

/* ---------------------------------------------------------
   History
   --------------------------------------------------------- */
.cg-history {
    margin-top: 34px;
}

.cg-history h3 {
    margin-bottom: 14px;
    font-size: 17px;
    text-align: center;
    color: #4a5570;
}

.cg-history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.cg-history-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: #6b7590;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.cg-history-chip .cg-chip-pips {
    opacity: 0.85;
    font-size: 10px;
}

.cg-history-chip.cg-c-d1    { background: #6b7590; }
.cg-history-chip.cg-c-d2    { background: #3f9e5d; }
.cg-history-chip.cg-c-d3    { background: #2f74c8; }
.cg-history-chip.cg-c-d4    { background: #7b4ec4; }
.cg-history-chip.cg-c-s1    { background: #c94f9c; }
.cg-history-chip.cg-c-s2    { background: #2aa79a; }
.cg-history-chip.cg-c-crown { background: linear-gradient(135deg, #c99a1e, #ffe08a); color: #3d2c00; }

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 720px) {
    .cg-stage { min-height: 600px; padding: 20px 10px 34px; }
    .cg-title { font-size: 23px; }
    .cg-pack-choice { width: 150px; height: 218px; }
    .cg-pack-choice .cg-choice-icon { top: 40px; font-size: 48px; }
    .cg-pack { width: 200px; height: 288px; }
    .cg-pack-stage, .cg-card-stack { height: 380px; }
    .cg-card-slot { width: 200px; height: 280px; }
    .cg-card-emoji { font-size: 74px; }
    .cg-mini { width: 118px; height: 168px; }
    .cg-mini-art { height: 96px; font-size: 44px; }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .cg-pack-sheen,
    .cg-rays,
    .cg-swipe-arrow,
    .cg-reveal-hint,
    .cg-mini .cg-lay-holo,
    .cg-mini .cg-lay-gold,
    .cg-r-s1 .cg-face-front,
    .cg-r-s2 .cg-face-front,
    .cg-r-crown .cg-face-front {
        animation: none !important;
    }

    .cg-card,
    .cg-card-flip {
        transition-duration: 0.01ms !important;
    }
}
