/* Ice Gem Cascade — Crystal Cave Style */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Палітра гемового підземелля */
    --bg-deep:        #160628;
    --bg-mid:        #2a1448;
    --bg-light:      #3d1f6b;
    --pink:          #ff58c8;
    --pink-soft:     #ffa3dd;
    --purple:        #8e44ad;
    --purple-light:  #b06cd4;
    --crystal:       #c2a6ff;
    --shimmer:       #ffe5fa;
    --text-white:    #f4ecff;
    --text-muted:    #9a82bf;
    --gold:          #ffd86b;

    /* Розміри */
    --frame-radius:  1.375rem;
    --reel-radius:   0.625rem;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at 50% 0%, var(--bg-light) 0%, var(--bg-mid) 45%, var(--bg-deep) 100%);
    min-height: calc(100dvh - 3.5rem);
    color: var(--text-white);
}

/* ============ CAVE BACKDROP ============ */
#cave-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 18% 80%, rgba(255,88,200,0.18), transparent 60%),
        radial-gradient(ellipse at 82% 15%, rgba(142,68,173,0.28), transparent 65%),
        radial-gradient(ellipse at 50% 50%, rgba(194,166,255,0.08), transparent 70%);
}

#shimmer-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(1px 1px at 22% 28%,  rgba(255,229,250,0.95), transparent),
        radial-gradient(1px 1px at 68% 14%,  rgba(194,166,255,0.85), transparent),
        radial-gradient(2px 2px at 42% 68%,  rgba(255,88,200,0.85),  transparent),
        radial-gradient(1px 1px at 87% 56%,  rgba(255,229,250,0.85), transparent),
        radial-gradient(1px 1px at 12% 88%,  rgba(176,108,212,0.85), transparent),
        radial-gradient(2px 2px at 58% 92%,  rgba(255,229,250,0.7),  transparent),
        radial-gradient(1px 1px at 92% 24%,  rgba(255,88,200,0.7),   transparent),
        radial-gradient(1px 1px at 32% 48%,  rgba(255,229,250,0.6),  transparent);
    background-repeat: repeat;
    background-size: 22rem 22rem;
    animation: caveShimmer 5s ease-in-out infinite alternate;
}

@keyframes caveShimmer {
    0%   { opacity: 0.45; transform: translateY(0); }
    100% { opacity: 1;    transform: translateY(-0.25rem); }
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-deep);
    color: var(--text-white);
    z-index: 1000;
}

.screen.hidden { display: none; }

.loading-spinner {
    width: 3.25rem;
    height: 3.25rem;
    border: 0.1875rem solid rgba(255,88,200,0.15);
    border-top-color: var(--pink);
    border-radius: 50%;
    animation: spinAnim 1s linear infinite;
}

@keyframes spinAnim { to { transform: rotate(360deg); } }

#loading-screen p {
    margin-top: 1rem;
    color: var(--pink-soft);
    font-size: 0.9375rem;
    letter-spacing: 0.0625rem;
}

.login-content { text-align: center; }
.login-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 0.75rem rgba(255,88,200,0.6));
}
.login-content h2 { color: var(--pink); margin-bottom: 0.5rem; }
.login-content p { color: var(--text-muted); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 28.75rem;
    height: 100%;
    max-height: 51.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    position: relative;
    z-index: 1;
}

#game-container.hidden { display: none; }

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 0.375rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(255,88,200,0.14) 0%, rgba(142,68,173,0.08) 100%);
    border: 0.0625rem solid rgba(255,88,200,0.4);
    border-radius: 1.25rem;
    padding: 0.4375rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    box-shadow: 0 0 1.125rem rgba(255,88,200,0.2);
}

.balance-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.03125rem;
}

#balance-value {
    color: var(--pink-soft);
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 4.375rem;
    text-align: right;
    text-shadow: 0 0 0.625rem rgba(255,88,200,0.55);
}

.balance-currency {
    color: var(--crystal);
    font-size: 0.6875rem;
}

/* ============ PAYTABLE STRIP ============ */
.paytable-strip {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.4375rem 0.75rem;
    background:
        linear-gradient(180deg, #1c0b32 0%, #2a1448 100%) padding-box,
        linear-gradient(180deg, var(--pink), var(--purple) 50%, var(--crystal)) border-box;
    border: 0.0625rem solid transparent;
    border-radius: 0.625rem;
    margin-bottom: 0.125rem;
}

.pay-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.625rem;
}

.pay-symbols {
    font-size: 0.8125rem;
    letter-spacing: -0.125rem;
}

.pay-mult {
    color: var(--pink-soft);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.03125rem;
    white-space: nowrap;
}

.pay-sep {
    width: 0.0625rem;
    height: 1.125rem;
    background: linear-gradient(to bottom, transparent, rgba(255,88,200,0.5), transparent);
}

/* ============ SPIN MACHINE ============ */
#slot-machine {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1.25rem;
}

/* Crystal-cut machine frame */
.machine-frame {
    position: relative;
    background:
        linear-gradient(180deg, #1c0b32 0%, #100620 100%) padding-box,
        linear-gradient(135deg, var(--pink) 0%, var(--purple) 45%, var(--crystal) 70%, var(--pink) 100%) border-box;
    border: 0.1875rem solid transparent;
    border-radius: var(--frame-radius);
    padding: 1.125rem;
    box-shadow:
        0 0 0 0.0625rem rgba(0,0,0,0.8),
        0 0 2.8125rem rgba(255,88,200,0.3),
        0 0 5.625rem rgba(142,68,173,0.2),
        0 1.25rem 3.75rem rgba(0,0,0,0.6),
        inset 0 0.0625rem 0 rgba(255,255,255,0.06);
}

/* Faceted highlight strip */
.machine-frame::before {
    content: '';
    position: absolute;
    top: 0.375rem;
    left: 1.25rem;
    right: 1.25rem;
    height: 0.0625rem;
    background: linear-gradient(90deg, transparent, rgba(255,229,250,0.6), transparent);
    border-radius: 50%;
}

/* Cascade indicator */
.cascade-indicator {
    position: absolute;
    top: -0.625rem;
    right: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.1875rem 0.625rem;
    background: linear-gradient(160deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
    border: 0.0625rem solid rgba(255,88,200,0.5);
    border-radius: 0.75rem;
    box-shadow: 0 0 0.75rem rgba(255,88,200,0.3);
    z-index: 5;
}

.cascade-label {
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
}

#cascade-counter {
    color: var(--crystal);
    font-size: 0.8125rem;
    font-weight: 800;
    transition: all 0.2s ease;
}

#cascade-counter.active {
    color: var(--pink);
    text-shadow: 0 0 0.625rem rgba(255,88,200,0.7);
    animation: cascadePop 0.4s ease;
}

@keyframes cascadePop {
    0%   { transform: scale(0.8); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Reels container */
.reels-container {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 0.75rem;
    background: linear-gradient(180deg, #0a0418 0%, #170828 100%);
    border-radius: 0.875rem;
    border: 0.0625rem solid rgba(255,88,200,0.25);
    box-shadow:
        inset 0 0.25rem 1.25rem rgba(0,0,0,0.8),
        inset 0 0.0625rem 0 rgba(255,255,255,0.04);
    position: relative;
}

/* Center crystal glow */
.reels-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0.625rem;
    right: 0.625rem;
    height: 0.0625rem;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, rgba(255,88,200,0.25), transparent);
    pointer-events: none;
}

/* Individual reel — faceted gem cell */
.reel {
    width: 5.5rem;
    height: 6rem;
    background:
        linear-gradient(135deg, #1a0a30 0%, #2a1248 50%, #1a0a30 100%);
    border-radius: var(--reel-radius);
    overflow: hidden;
    position: relative;
    border: 0.0625rem solid rgba(255,88,200,0.3);
    box-shadow:
        inset 0 0 1.25rem rgba(0,0,0,0.7),
        inset 0 0.125rem 0.375rem rgba(0,0,0,0.5),
        0 0 0 0.0625rem rgba(0,0,0,0.5);
    clip-path: polygon(
        12% 0%, 88% 0%,
        100% 14%, 100% 86%,
        88% 100%, 12% 100%,
        0% 86%, 0% 14%
    );
}

/* Faceted gem facet highlight */
.reel::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255,229,250,0.08) 0%, transparent 40%),
        linear-gradient(-135deg, rgba(194,166,255,0.05) 0%, transparent 40%);
    pointer-events: none;
    z-index: 2;
}

.reel-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

.reel.spinning .reel-inner {
    animation: reelSpin 0.08s linear infinite;
}

@keyframes reelSpin {
    0%   { transform: translateY(-60%); }
    100% { transform: translateY(60%); }
}

/* Symbol */
.symbol {
    font-size: 3rem;
    filter: drop-shadow(0 0.125rem 0.375rem rgba(0,0,0,0.7));
    transition: transform 0.25s ease, opacity 0.2s ease;
    line-height: 1;
}

.reel.highlight {
    border-color: var(--pink);
    box-shadow:
        inset 0 0 1.5rem rgba(255,88,200,0.4),
        0 0 1.25rem rgba(255,88,200,0.55);
}

.reel.highlight .symbol {
    animation: symbolPulse 0.5s ease;
    filter: drop-shadow(0 0 0.875rem rgba(255,88,200,0.95));
}

@keyframes symbolPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.18); }
}

/* Shatter effect */
.reel.shattering .symbol {
    animation: symbolShatter 0.5s ease-in forwards;
}

@keyframes symbolShatter {
    0%   { transform: scale(1)   rotate(0deg);   opacity: 1; filter: drop-shadow(0 0 0.875rem rgba(255,88,200,0.95)); }
    40%  { transform: scale(1.3) rotate(8deg);   opacity: 1; filter: drop-shadow(0 0 1.25rem rgba(255,229,250,1)); }
    100% { transform: scale(0.2) rotate(-25deg); opacity: 0; filter: drop-shadow(0 0 0.5rem rgba(255,88,200,0)); }
}

/* Shatter layer for sparkles */
.shatter-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: visible;
}

.sparkle {
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 0.875rem;
    color: var(--shimmer);
    text-shadow: 0 0 0.5rem rgba(255,229,250,0.9);
    animation: sparkleBurst 0.55s ease-out forwards;
    pointer-events: none;
}

@keyframes sparkleBurst {
    0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.1); opacity: 0; }
}

/* Cascade-in animation */
.reel.cascade-in .symbol {
    animation: cascadeDrop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cascadeDrop {
    0%   { transform: translateY(-180%) scale(0.7); opacity: 0; }
    60%  { transform: translateY(15%)   scale(1.1); opacity: 1; }
    100% { transform: translateY(0)     scale(1);   opacity: 1; }
}

/* Win line */
.win-line {
    position: absolute;
    top: 50%;
    left: 0.5rem;
    right: 0.5rem;
    height: 0.125rem;
    background: linear-gradient(90deg, transparent, var(--pink) 20%, var(--crystal) 80%, transparent);
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 0.75rem var(--pink), 0 0 0.25rem var(--crystal);
    border-radius: 0.0625rem;
    pointer-events: none;
}

.win-line.active {
    opacity: 1;
    animation: winLinePulse 0.6s ease-in-out infinite;
}

@keyframes winLinePulse {
    0%, 100% { opacity: 1;   box-shadow: 0 0 0.75rem var(--pink); }
    50%      { opacity: 0.6; box-shadow: 0 0 1.625rem var(--crystal); }
}

/* ============ WIN DISPLAY ============ */
#win-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(160deg, rgba(28,11,50,0.97) 0%, rgba(58,20,100,0.97) 100%);
    padding: 1.125rem 2.5rem;
    border-radius: 1rem;
    border: 0.0625rem solid var(--pink);
    box-shadow:
        0 0 0 0.0625rem rgba(255,88,200,0.25),
        0 0 3.4375rem rgba(255,88,200,0.5),
        inset 0 0.0625rem 0 rgba(255,255,255,0.1);
    z-index: 100;
    text-align: center;
    animation: winPopup 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#win-display.hidden { display: none; }

@keyframes winPopup {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.win-label {
    display: block;
    color: var(--crystal);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1875rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    opacity: 0.95;
}

#win-amount {
    display: block;
    color: var(--pink-soft);
    font-size: 2.625rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 1.375rem rgba(255,88,200,0.7);
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: absolute;
    bottom: 11.875rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22,6,40,0.94);
    padding: 0.5rem 1.375rem;
    border-radius: 0.5rem;
    border: 0.0625rem solid rgba(255,88,200,0.35);
    z-index: 100;
    white-space: nowrap;
}

#message-display.hidden { display: none; }
#message-text { color: var(--text-white); font-size: 0.8125rem; }

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    flex-wrap: wrap;
}

.bet-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
    text-transform: uppercase;
}

.bet-buttons { display: flex; gap: 0.375rem; }

.bet-btn {
    width: 3rem;
    height: 2rem;
    background: rgba(255,255,255,0.04);
    border: 0.0625rem solid rgba(255,88,200,0.3);
    border-radius: 0.375rem;
    color: rgba(244,236,255,0.65);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bet-btn:hover {
    border-color: var(--pink);
    color: var(--text-white);
    background: rgba(255,88,200,0.1);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--pink) 0%, var(--purple) 100%);
    color: #1a0628;
    border-color: var(--pink-soft);
    box-shadow: 0 0.125rem 0.75rem rgba(255,88,200,0.45);
}

.bet-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.current-bet {
    background: rgba(0,0,0,0.4);
    padding: 0.25rem 0.875rem;
    border-radius: 0.375rem;
    border: 0.0625rem solid rgba(255,88,200,0.25);
}

#current-bet-value {
    color: var(--pink-soft);
    font-size: 1rem;
    font-weight: 700;
}

/* ============ SPIN BUTTON ============ */
#spin-button {
    width: 11.25rem;
    height: 3.25rem;
    background: linear-gradient(160deg, var(--pink) 0%, var(--purple) 55%, var(--crystal) 100%);
    border: 0.0625rem solid rgba(255,163,221,0.55);
    border-radius: 1.625rem;
    cursor: pointer;
    box-shadow:
        0 0.25rem 1.375rem rgba(255,88,200,0.5),
        0 0.0625rem 0 rgba(255,255,255,0.22) inset;
    transition: all 0.18s ease;
    margin: 0.5rem 0;
}

#spin-button:hover:not(:disabled) {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.5rem 1.875rem rgba(142,68,173,0.65);
}

#spin-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 0.125rem 0.625rem rgba(255,88,200,0.35);
}

#spin-button:disabled {
    background: linear-gradient(160deg, #2a1e3a 0%, #18101f 100%);
    border-color: rgba(255,255,255,0.08);
    box-shadow: none;
    cursor: not-allowed;
}

#spin-button.pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 0.25rem 1.375rem rgba(255,88,200,0.5); }
    50%      { box-shadow: 0 0.25rem 2.5rem rgba(255,229,250,0.85); }
}

.spin-text {
    color: #1a0628;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1875rem;
}

#spin-button:disabled .spin-text { color: #555; }

/* ============ GAME TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.25rem 0 0.375rem;
}

.title-gem {
    color: rgba(244,236,255,0.45);
    font-size: 0.6875rem;
    letter-spacing: 0.125rem;
    text-transform: uppercase;
}

.title-slot {
    color: var(--pink);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.125rem;
    text-shadow: 0 0 0.875rem rgba(255,88,200,0.6);
}

/* ============ PARTICLES ============ */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    font-size: 1.25rem;
    animation: particleFall 2s ease-out forwards;
    filter: drop-shadow(0 0 0.375rem rgba(255,88,200,0.55));
}

@keyframes particleFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(80vh) rotate(540deg) scale(0.3); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 25rem) {
    .reel { width: 4.5rem; height: 5rem; }
    .symbol { font-size: 2.5rem; }
    .bet-btn { width: 2.625rem; height: 1.875rem; font-size: 0.75rem; }
    #spin-button { width: 9.6875rem; height: 2.875rem; }
    .spin-text { font-size: 1.0625rem; }
    .pay-symbols { font-size: 0.6875rem; }
}

@media (max-height: 43.75rem) {
    .paytable-strip { padding: 0.3125rem 0.625rem; margin-bottom: 0; }
    #slot-machine { padding: 0.5rem 1rem; }
    .machine-frame { padding: 0.75rem; }
    .reels-container { padding: 0.625rem; gap: 0.4375rem; }
    .reel { height: 5rem; }
    .symbol { font-size: 2.625rem; }
}

/* === clone palette override === */
body { filter: hue-rotate(180deg) saturate(110%); }
