@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #1a1a1a;
    background-image: radial-gradient(circle, #4a4a4a, #1a1a1a);
    font-family: 'Press Start 2P', cursive;
}

.slot-machine-container {
    display: flex;
    align-items: center;
}

.arm {
    width: 25px; /* Slightly wider */
    height: 180px; /* Taller */
    background: linear-gradient(
        to right,
        #a0a0a0 0%, #d4d4d4 20%, #a0a0a0 40%,
        #d4d4d4 60%, #a0a0a0 80%, #d4d4d4 100%
    ); /* More detailed metallic gradient */
    border-radius: 0 12px 12px 0; /* Slightly larger radius */
    margin-left: -7px; /* Adjust margin for wider arm */
    position: relative;
    box-shadow:
        3px 0px 5px rgba(0,0,0,0.4), /* Main shadow */
        inset 1px 0px 3px rgba(255,255,255,0.5), /* Inner highlight */
        inset -1px 0px 3px rgba(0,0,0,0.3); /* Inner shadow */
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    transform-origin: 0 100%; /* Set pivot point to bottom-left */
}

.arm:hover {
    transform: translateX(5px); /* Move arm slightly to the right on hover, no rotation */
}

.knob {
    width: 45px; /* Slightly larger */
    height: 45px; /* Slightly larger */
    background: radial-gradient(
        circle at 25% 25%,
        #ff9999 0%, /* Highlight */
        #ff6a6a 40%, /* Mid-tone */
        #c00 70%, /* Darker red */
        #800000 100% /* Deepest shadow */
    ); /* More realistic spherical gradient */
    border-radius: 50%;
    position: absolute;
    top: -22px; /* Adjust top for new arm height */
    right: -15px; /* Adjust right for new arm width */
    border: 3px solid #fff;
    box-shadow:
        0 0 15px rgba(255, 0, 0, 0.9), /* Stronger glow */
        inset 0 0 10px rgba(255,255,255,0.5); /* Inner highlight */
}

.machine {
    text-align: center;
    background: linear-gradient(to bottom, #c0c0c0, #a0a0a0);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4), inset 0 0 15px rgba(0,0,0,0.5);
    border: 5px solid #444;
    position: relative; /* Added for pseudo-element positioning */
    overflow: hidden; /* Ensure pseudo-element stays within bounds */
    z-index: 1; /* Ensure content is above pseudo-element */
    min-width: 400px; /* Added to prevent shrinking */
}

.machine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        60deg,
        rgba(255, 255, 255, 0) 20%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 80%
    );
    transform: rotate(45deg);
    animation: shine 8s infinite linear;
    z-index: -1; /* Place behind machine content */
}

@keyframes shine {
    0% { transform: rotate(45deg) translate(-100%, -100%); }
    100% { transform: rotate(45deg) translate(100%, 100%); }
}

.screen {
    background: #111;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.reels {
    display: flex;
    justify-content: center;
}

.reel {
    width: 100px;
    height: 100px;
    background-color: #fff;
    margin: 0 10px;
    /* font-size: 80px; Removed as we are using images */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    border: 2px solid #555;
    /* text-shadow: 0 0 5px rgba(255,255,255,0.5); Removed as we are using images */
    overflow: hidden;
}

.reel img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensures the image fits within the reel without cropping */
}

#credits-display {
    color: #33ff33; /* Bright green for a classic digital look */
    font-size: 20px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

#freeSpinsDisplay {
    color: #00bfff; /* Sky blue for free spins */
    font-size: 20px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    visibility: hidden; /* Hidden by default */
}

#result {
    margin-top: 25px;
    font-size: 22px;
    font-weight: bold;
    min-height: 30px;
    color: #ffdd00;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.7);
    min-width: 350px; /* Ensure space for longest text */
    white-space: nowrap; /* Prevent text wrapping */
}

#refillCreditsButton {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background: linear-gradient(to bottom, #d9534f, #c9302c); /* Red gradient */
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 4px 0 #9f2421, 0 6px 8px rgba(0,0,0,0.3);
    transition: all 0.1s ease-in-out;
    font-family: 'Press Start 2P', cursive;
    margin-top: 15px; /* Space from result */
    visibility: hidden; /* Hidden by default, reserves space */
}

#refillCreditsButton:hover {
    background: linear-gradient(to bottom, #e0635e, #d0403b);
}

#refillCreditsButton:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #9f2421;
}

.spinning-text {
    animation: pulse 1s ease-in-out infinite;
}

.spinning {
    animation: spin 0.1s linear infinite;
}

.arm.pull-animation {
    animation: pull-arm 0.5s ease-in-out;
}

@keyframes spin {
    0% { transform: translateY(-15px); text-shadow: 0 0 10px yellow; }
    50% { transform: translateY(15px); text-shadow: none; }
    100% { transform: translateY(-15px); text-shadow: 0 0 10px yellow; }
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; }
}

@keyframes pull-arm {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(50px) rotate(20deg); } /* Rotate down and pull */
    100% { transform: translateY(0) rotate(0deg); }
}

/* -- Mobile Responsiveness -- */
@media (max-width: 768px) {
    .slot-machine-container {
        /* No flex-direction: column; needed, will inherit row from desktop */
        align-items: center; /* Keep machine centered vertically with arm */
    }

    .machine {
        padding: 15px; /* Smaller padding for mobile */
        max-width: 280px; /* Constrain width more for mobile */
        min-width: 280px; /* Ensure a consistent minimum width */
    }

    .screen {
        padding: 10px; /* Smaller screen padding */
    }

    .reels {
        /* No change needed for reels display */
    }

    .reel {
        width: 70px; /* Smaller reels */
        height: 70px;
        margin: 0 5px;
        font-size: 50px; /* Smaller font for images if they scale with font-size */
    }

    #credits-display {
        font-size: 16px; /* Smaller font */
    }

    #result {
        font-size: 18px; /* Smaller font */
        min-width: unset; /* Remove fixed min-width for mobile, let it adjust */
        white-space: normal; /* Allow text wrapping for mobile */
    }

    #refillCreditsButton {
        font-size: 14px; /* Smaller font */
        padding: 8px 15px;
    }

    .arm {
        width: 20px; /* Scaled down vertical arm */
        height: 120px;
        border-radius: 0 10px 10px 0;
        margin-left: -5px; /* Adjust margin for scaled arm */
        transform-origin: 0 100%; /* Pivot from bottom-left for vertical arm */
    }

    .knob {
        top: -18px; /* Adjust for scaled arm height */
        right: -12px; /* Adjust for scaled arm width */
        width: 35px;
        height: 35px;
    }
    
    .arm.pull-animation {
        animation: pull-arm-mobile 0.5s ease-in-out;
    }

    @keyframes pull-arm-mobile {
        0% { transform: translateY(0) rotate(0deg); }
        50% { transform: translateY(30px) rotate(15deg); } /* Scaled down rotation and pull */
        100% { transform: translateY(0) rotate(0deg); }
    }
}

.win-animation {
    animation: win-pop 1s ease-out forwards;
}

@keyframes win-pop {
    0% { transform: scale(1); color: #ffdd00; text-shadow: 2px 2px 3px rgba(0,0,0,0.7); }
    50% { transform: scale(1.2); color: #ff00ff; text-shadow: 0 0 15px #ff00ff, 0 0 20px #ff00ff; }
    100% { transform: scale(1); color: #ffdd00; text-shadow: 2px 2px 3px rgba(0,0,0,0.7); }
}