/* ========================================================
   Slot games styles
   --------------------------------------------------------
   Perf notes (rewrite):
   - Reel cell height is a CSS variable (--cell-h) so a single
     @keyframes reelSpin drives every size and variant. Four
     duplicated keyframe blocks collapsed into one.
   - drop-shadow on cells is disabled during the spin animation:
     you don't see the glow on blur-fast cells, and drop-shadow
     is one of the pricier filters to re-rasterize every frame.
   - .spin-btn::before sheen animates transform (composited)
     instead of `left` (which triggers layout per frame).
   - .machine and .reel use `contain: layout paint` — browser
     can treat their subtree as independent, no outside ripple.
   - .reel__strip has both will-change: transform and a
     translateZ(0) to guarantee an own compositor layer on
     older WebKit.
   - Numeric HUD/paytable values use tabular-nums so digit
     width doesn't jitter between spins.
   ======================================================== */

/* -------- Page shell -------- */
.game-page { padding: 4rem 0 6rem; }
.game-page__head {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 3rem;
}
.game-page__tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--star-gold);
    margin-bottom: 1rem;
}
.game-page__head h1 {
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    font-weight: 300;
    font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1;
    margin: 0 0 1rem;
}
.game-page__head h1 em {
    font-style: italic;
    background: linear-gradient(120deg, var(--star-gold), var(--nebula-pink) 60%, var(--aether));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.game-page__head p {
    color: var(--cream-dim);
    margin: 0 auto;
    max-width: 56ch;
}

/* -------- HUD (stardust / last win / spins) -------- */
.hud {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.hud__chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: rgba(245,238,227,0.04);
    border: 1px solid rgba(245,238,227,0.1);
    border-radius: 999px;
}
.hud__label {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}
.hud__value {
    font-family: 'Space Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    color: var(--star-gold);
    font-weight: 700;
    min-width: 3ch;
    text-align: right;
}

/* -------- Machine frame -------- */
.machine {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    position: relative;
    border-radius: var(--r-xl);
    background:
            radial-gradient(ellipse at 50% 0%, rgba(245,184,90,0.15), transparent 60%),
            linear-gradient(160deg, #1B1A38 0%, #0B0B1E 100%);
    border: 1px solid rgba(245,184,90,0.2);
    box-shadow: 0 40px 80px -20px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden;
    contain: layout paint;
}
.machine::before, .machine::after {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    opacity: 0.5;
}
.machine::before {
    top: -80px; left: -80px;
    background: radial-gradient(circle, rgba(230,111,210,0.3), transparent);
}
.machine::after {
    bottom: -80px; right: -80px;
    background: radial-gradient(circle, rgba(123,217,230,0.3), transparent);
}

/* -------- Reels container -------- */
.reels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(180deg, #0B0B1E 0%, #13122B 100%);
    border-radius: var(--r-lg);
    border: 1px solid rgba(245,238,227,0.08);
    position: relative;
    z-index: 1;
    box-shadow: inset 0 8px 30px rgba(0,0,0,0.6);
}
.reels--five {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    padding: 0.75rem;
}

/* -------- Single reel -------- */
.reel {
    --cell-h: 260px;
    height: var(--cell-h);
    position: relative;
    overflow: hidden;
    border-radius: var(--r-md);
    background: linear-gradient(180deg, rgba(245,238,227,0.04) 0%, rgba(245,238,227,0.01) 100%);
    border: 1px solid rgba(245,238,227,0.08);
    contain: layout paint;
}
.reels--five .reel { --cell-h: 220px; }

/* Top & bottom fade masks */
.reel::before, .reel::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 30px;
    z-index: 3;
    pointer-events: none;
}
.reel::before {
    top: 0;
    background: linear-gradient(180deg, rgba(11,11,30,0.95) 0%, transparent 100%);
}
.reel::after {
    bottom: 0;
    background: linear-gradient(0deg, rgba(11,11,30,0.95) 0%, transparent 100%);
}

/* Strip (translates via transform) */
.reel__strip {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    flex-direction: column;
    will-change: transform;
    transform: translateZ(0);
}
.reel__cell {
    height: var(--cell-h);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 20px rgba(245,184,90,0.3));
}
.reels--five .reel__cell { font-size: 4rem; }

/* Skip the pricey drop-shadow on fast-moving cells. */
.reel.is-spinning .reel__cell { filter: none; }

/* Unified spin keyframes — offset derived from --cell-h on the target. */
.reel.is-spinning .reel__strip {
    animation: reelSpin 0.4s linear infinite;
}
.reels--five .reel.is-spinning .reel__strip {
    animation-duration: 0.35s;
}
@keyframes reelSpin {
    0%   { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(0, calc(-1 * var(--cell-h)), 0); }
}

.reel__center-line {
    position: absolute;
    left: 10%; right: 10%;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--star-gold), transparent);
    transform: translateY(-50%);
    z-index: 2;
    opacity: 0.35;
    pointer-events: none;
}

.reel.is-winner {
    animation: winnerPulse 0.8s ease-in-out 3;
}
@keyframes winnerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,184,90,0); }
    50%      { box-shadow: 0 0 0 3px rgba(245,184,90,0.6), 0 0 40px rgba(245,184,90,0.4); }
}

/* -------- Controls -------- */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}
.spin-btn {
    position: relative;
    padding: 1.1rem 3rem;
    border-radius: 999px;
    background: var(--grad-gold);
    color: var(--ink);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    box-shadow: var(--shadow-glow-gold);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
    overflow: hidden;
}
/* Hover sheen — transform-based so it stays composited. */
.spin-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s var(--ease);
    pointer-events: none;
}
.spin-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 25px 70px -15px rgba(245,184,90,0.7);
}
.spin-btn:hover:not(:disabled)::before { transform: translateX(100%); }
.spin-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ctrl-btn {
    padding: 0.9rem 1.5rem;
    border-radius: 999px;
    border: 1px solid rgba(245,238,227,0.2);
    color: var(--cream);
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.ctrl-btn:hover {
    border-color: var(--cream);
    background: rgba(245,238,227,0.05);
}

/* -------- Message line -------- */
.message {
    margin-top: 1.5rem;
    text-align: center;
    min-height: 30px;
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--cream-dim);
    transition: color 0.3s var(--ease), transform 0.3s var(--ease);
}
.message.is-win {
    color: var(--star-gold);
    transform: scale(1.05);
}

/* -------- Paytable -------- */
.paytable {
    max-width: 720px;
    margin: 3rem auto 0;
    padding: 2rem;
    border-radius: var(--r-lg);
    background: rgba(245,238,227,0.02);
    border: 1px solid rgba(245,238,227,0.06);
}
.paytable h3 {
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--star-gold);
    margin: 0 0 1.25rem;
    font-weight: 400;
}
.paytable__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.9rem;
}
.paytable__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(245,238,227,0.02);
    border-radius: var(--r-md);
    border: 1px solid rgba(245,238,227,0.06);
}
.paytable__symbols { font-size: 1.3rem; letter-spacing: -2px; }
.paytable__reward {
    font-family: 'Space Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    color: var(--star-gold);
    margin-left: auto;
    font-weight: 700;
}

/* -------- Burst (stardust confetti) -------- */
.burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 4;
}
.burst__p {
    position: absolute;
    top: 50%; left: 50%;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--star-gold);
    box-shadow: 0 0 8px var(--star-gold);
    opacity: 0;
}
.burst.is-on .burst__p {
    animation: burst 1.4s var(--ease) forwards;
}
@keyframes burst {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(0); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, 0px))) scale(1); }
}

/* -------- Responsible reminder -------- */
.play-note {
    max-width: 720px;
    margin: 2.5rem auto 0;
    padding: 1.25rem 1.5rem;
    border-radius: var(--r-md);
    background: rgba(230,111,210,0.08);
    border: 1px solid rgba(230,111,210,0.2);
    color: var(--cream-dim);
    font-size: 0.92rem;
    line-height: 1.55;
    text-align: center;
}
.play-note strong { color: var(--nebula-pink); }

/* -------- Nebula Fortune variant -------- */
.game-page--nebula .game-page__head h1 em {
    background: linear-gradient(135deg, var(--nebula-pink), var(--aether));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.game-page--nebula .burst {
    background: radial-gradient(circle, rgba(230,111,210,0.18), transparent 60%);
}

.paytable--wide { max-width: 720px; }
.paytable__hint {
    margin: 0 0 1.25rem;
    color: var(--cream-dim);
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}

/* Override the base auto-fill grid — 5-reel paytable is a single vertical list. */
.paytable__grid.paytable__grid--five {
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.paytable__grid--five .paytable__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.1rem;
    gap: 1rem;
}
.paytable__grid--five .paytable__symbols {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}
.paytable__grid--five .paytable__reward {
    font-family: 'Space Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    color: var(--star-gold);
    white-space: nowrap;
}
/* -------- Mobile (merged) -------- */
@media (max-width: 640px) {
    .reel              { --cell-h: 180px; }
    .reel__cell        { font-size: 3.2rem; }
    .reels--five .reel { --cell-h: 120px; }
    .reels--five .reel__cell { font-size: 2.5rem; }

    .machine  { padding: 1.25rem; }
    .reels    { padding: 0.75rem; gap: 0.4rem; }
    .spin-btn { padding: 1rem 2rem; }

    .paytable__grid--five .paytable__row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    .paytable__grid--five .paytable__reward { font-size: 0.88rem; }
}