@import url('https://fonts.googleapis.com/css2?family=Righteous&family=Rye&family=Bangers&display=swap'); /* Added Rye for western feel */

body {
    font-family: 'Rye', cursive; /* Western font */
    background-color: #5D4037; /* Dark brown background */
    color: #FFEB3B; /* Yellow text */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-image: url('background_gold_rush.png'); /* New gold rush background */
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

#slot-machine {
    background-color: rgba(121, 85, 72, 0.92); /* Brown, slightly transparent */
    border: 6px solid #A1887F; /* Lighter brown border */
    border-radius: 15px; /* Less rounded, more rustic */
    padding: 20px;
    box-shadow: 
        0 0 35px rgba(0, 0, 0, 0.7), /* Dark shadow */
        inset 0 0 15px rgba(0,0,0,0.5), /* Inner shadow for depth */
        /* Base Glow - subtle gold when off */
        0 0 4px #FFD700,
        0 0 7px #FFB300,
        inset 0 0 10px rgba(255, 255, 255, 0.2);
    text-align: center;
    width: 90%;
    max-width: 900px;
    transition: box-shadow 0.4s ease-in-out;
}

#slot-machine.neon-glow-active {
    box-shadow: 
        0 0 35px rgba(0, 0, 0, 0.8), 
        inset 0 0 15px rgba(0,0,0,0.5),
        /* Active Neon Glow - bright gold rush! */
        0 0 10px #fff, /* white core */
        0 0 20px #FFD700, /* Gold */
        0 0 35px #FFA000, /* Amber */
        0 0 50px #FF6F00, /* Bright Orange */
        0 0 70px #FF6F00,
        inset 0 0 20px rgba(255, 224, 130, 0.7); /* Light gold inner glow */
}

header h1 {
    font-size: 3em; /* Larger, more impactful */
    color: #FFC107; /* Amber */
    text-shadow: 
        3px 3px 0px #4E342E, /* Dark Brown offset */
        -2px -2px 0px #795548, /* Lighter Brown offset */
        0 0 15px #FFF, 0 0 5px #000; /* White glow and subtle dark */
    margin-bottom: 20px;
    font-family: 'Rye', cursive; /* Western style font */
}

#reels-container {
    display: flex;
    justify-content: center;
    gap: 10px; 
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(62, 39, 35, 0.6); /* Dark wood color */
    border-radius: 15px;
    border: 3px solid #5D4037; /* Wood border */
    position: relative;
}

.reel {
    display: flex;
    flex-direction: column;
    gap: 5px; 
    background-color: rgba(93, 64, 55, 0.4); /* Wood color, more transparent reel background */
    padding: 5px;
    border-radius: 10px;
    overflow: hidden; 
    box-shadow: inset 0 0 10px rgba(0,0,0,0.6);
}

.symbol-cell {
    width: 100px; 
    height: 100px; 
    background-color: rgba(188, 170, 164, 0.3); /* Dusty, light stone color */
    border: 2px solid #795548; /* Brown border */
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: outline 0.2s, box-shadow 0.2s, transform 0.2s;
}

.symbol-cell img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    transition: transform 0.1s ease-out, opacity 0.1s ease-out;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.3)); /* Subtle shadow for pop */
}

.reel.spinning .symbol-cell img {
    animation: spinSymbol 0.1s linear infinite;
}

@keyframes spinSymbol {
    0% { transform: translateY(-15px) scale(0.9); opacity: 0.7; }
    50% { transform: translateY(0px) scale(1); opacity: 1; }
    100% { transform: translateY(15px) scale(0.9); opacity: 0.7; }
}

.winning-symbol img { 
    outline: 4px solid #FFD700; /* Bright gold outline */
    outline-offset: 2px;
    box-shadow: 0 0 20px #FFD700, 0 0 30px #FFA000; /* Gold and Amber glow */
    transform: scale(1.1); 
    animation: symbolWinPulse 0.6s ease-out;
}

@keyframes symbolWinPulse {
    0% {
        transform: scale(1.0);
        box-shadow: none;
        filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.3));
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 25px #FFF, 0 0 35px #FFD700, 0 0 50px #FFB300; /* White, Gold, Amber glow */
        filter: drop-shadow(3px 3px 5px rgba(0,0,0,0.1));
        opacity: 1;
    }
    100% {
        transform: scale(1.1); 
        box-shadow: 0 0 20px #FFD700, 0 0 30px #FFA000;
        filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.3));
        opacity: 1;
    }
}

#controls {
    display: flex;
    flex-wrap: wrap; 
    justify-content: space-around;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(62, 39, 35, 0.7); /* Dark wood tint */
    border-radius: 10px;
}

.info-display {
    font-size: 1.2em; 
    color: #fff; /* White text on brown */
    margin: 5px 10px; 
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    font-family: 'Righteous', cursive; /* A clearer font for info */
}

.info-display span:first-child {
    font-weight: bold;
    color: #FFC107; /* Amber for labels */
}

.bet-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bet-adj-button {
    background-color: #607D8B; /* Blue Grey */
    color: white;
    border: 2px solid #455A64; /* Darker Blue Grey border */
    border-radius: 8px; /* More rounded */
    width: 32px;
    height: 32px;
    font-size: 1.4em; /* Bigger font */
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.bet-adj-button:hover {
    background-color: #78909C; /* Lighter Blue Grey */
    transform: scale(1.1);
}

#action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px; 
    margin-top: 10px;
}

#paytable-button, #spin-button {
    padding: 14px 28px; 
    font-size: 1.5em; 
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4), inset 0 -3px 3px rgba(255,255,255,0.25), inset 0 3px 3px rgba(0,0,0,0.25);
    transition: background 0.3s ease, transform 0.1s ease;
    font-family: 'Rye', cursive; /* Western font for buttons */
    letter-spacing: 1px;
}

#paytable-button {
    background: linear-gradient(145deg, #795548, #4E342E); /* Brown to Dark Brown gradient */
}
#paytable-button:hover {
    background: linear-gradient(145deg, #8D6E63, #5D4037); /* Lighter Browns */
    transform: translateY(-2px);
}

#spin-button {
    background: linear-gradient(145deg, #FFC107, #FFA000); /* Amber to Orange gradient for GO button */
}

#spin-button:hover {
    background: linear-gradient(145deg, #FFD54F, #FFB300); /* Lighter Golds */
    transform: translateY(-2px);
}

#paytable-button:active, #spin-button:active {
    transform: translateY(1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.4), inset 0 -2px 2px rgba(255,255,255,0.25), inset 0 2px 2px rgba(0,0,0,0.25);
}

#spin-button:disabled {
    background: #B0C4DE; /* LightSteelBlue */
    cursor: not-allowed;
    opacity: 0.7;
}

#message-display {
    margin-top: 15px;
    font-size: 1.3em; 
    color: #FFEB3B; /* Yellow for readability */
    text-shadow: 1px 1px 1px #4E342E;
    min-height: 25px; 
    font-weight: bold;
    font-family: 'Righteous', cursive;
}

/* Payline Visualization */
#payline-overlay-container {
    position: absolute;
    top: 10px; 
    left: 10px; 
    right: 10px; 
    bottom: 10px; 
    pointer-events: none; 
    z-index: 10;
    overflow: visible; 
}

.payline-path {
    position: absolute;
    height: 5px; /* Thicker line */
    background-color: rgba(255, 235, 59, 0.9); /* Yellow, more opaque */
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 215, 0, 1), 0 0 5px white; /* Gold glow */
    border-radius: 3px;
    transform-origin: 0 50%; 
}

.payline-path.active {
    opacity: 1;
}

/* Floating Win Text Container */
#floating-text-container {
    position: absolute;
    top: 30%; 
    left: 50%;
    transform: translateX(-50%);
    width: 380px; 
    height: 160px; 
    pointer-events: none; 
    z-index: 101; 
    display: flex;
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
}

.floating-win-text {
    font-size: 3.5em; /* Even larger */
    color: #FF9800; /* Orange */
    font-weight: bold;
    font-family: 'Rye', cursive; /* Thematic font */
    text-shadow: 
        2px 2px 0 #fff, /* White outline */
        4px 4px 0 #4E342E, /* Dark brown shadow for pop */
        0 0 15px #FFD700; /* Gold glow */
    animation: floatUpAndFade 1.5s ease-out forwards;
    position: relative; 
    padding: 5px 15px;
    background-color: rgba(0,0,0,0.1); 
    border-radius: 10px;
}

@keyframes floatUpAndFade {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.4); 
    }
    15% {
        opacity: 1;
        transform: translateY(0px) scale(1); 
    }
    80% {
        opacity: 1;
        transform: translateY(-70px) scale(1.15); 
    }
    100% {
        opacity: 0;
        transform: translateY(-140px) scale(0.7); 
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85); 
    display: flex; 
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #6D4C41; /* Brown modal background */
    margin: auto;
    padding: 25px;
    border: 4px solid #A1887F; /* Lighter brown border */
    border-radius: 20px;
    width: 85%;
    max-width: 750px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
    color: #fff; /* White text */
    position: relative;
}

.close-button {
    color: #f0f0f0;
    position: absolute; 
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

.close-button:hover,
.close-button:focus {
    color: #FFC107; /* Amber hover */
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    text-align: center;
    color: #FFC107; /* Amber title */
    font-family: 'Rye', cursive;
    font-size: 2.5em;
    margin-bottom: 25px;
    text-shadow: 2px 2px 0 #4E342E; /* Dark brown shadow */
}

#paytable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 15px; 
    font-family: 'Righteous', cursive; /* Clearer font for paytable text */
}

.paytable-symbol-entry {
    background-color: rgba(255,255,255,0.1); /* Light tint for contrast */
    border: 2px solid #BCAAA4; /* Light stone border */
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.paytable-symbol-entry img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(3px 3px 4px rgba(0,0,0,0.5));
}

.paytable-symbol-entry h4 {
    margin: 8px 0;
    color: #FFECB3; /* Light Gold symbol name */
    font-size: 1.3em;
    text-shadow: 1px 1px 1px #000;
}

.paytable-symbol-entry p {
    font-size: 1em;
    margin: 4px 0;
    color: #fff;
}

.paytable-note {
    font-size: 1em;
    text-align: center;
    margin-top: 25px;
    color: #FFECB3; /* Light Gold */
    font-family: 'Righteous', cursive;
}

/* Fullscreen Animation Overlay */
#fullscreen-animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(62, 39, 35, 0.7); /* Dark Brown overlay, slightly transparent */
    display: flex;
    justify-content: flex-start; /* Start cart from the left */
    align-items: center;
    z-index: 200; 
    pointer-events: none; 
    opacity: 0; 
    transition: opacity 0.5s ease-in-out; 
    overflow: hidden; /* Hide cart before it enters */
}

#fullscreen-animation-overlay.active {
    opacity: 1;
}

/* Renamed to animated-mine-cart */
#fullscreen-animation-overlay img.animated-mine-cart {
    position: absolute;
    height: 30vh; /* Responsive height */
    max-height: 250px; 
    width: auto;
    animation: driveAcrossScreen 3s ease-in-out forwards; /* New animation name */
}

/* New keyframes for mine cart animation */
@keyframes driveAcrossScreen {
    0% { 
        left: -30%; /* Start off-screen to the left */
        transform: translateY(20px) rotate(-2deg);
    }
    20% {
        transform: translateY(0px) rotate(1deg); /* Bouncing on tracks */
    }
    40% {
        transform: translateY(10px) rotate(-1deg);
    }
    60% {
        transform: translateY(0px) rotate(2deg);
    }
    80% {
        transform: translateY(5px) rotate(0deg);
    }
    100% { 
        left: 110%; /* End off-screen to the right */
        transform: translateY(15px) rotate(3deg);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .symbol-cell {
        width: 80px;
        height: 80px;
    }
    #paytable-button, #spin-button {
        padding: 12px 22px;
        font-size: 1.3em;
    }
    header h1 {
        font-size: 2.5em;
    }
    .info-display {
        font-size: 1.1em;
    }
    .bet-adj-button {
        width: 30px;
        height: 30px;
        font-size: 1.2em;
    }
    #paytable-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .floating-win-text {
        font-size: 3em;
    }
    #fullscreen-animation-overlay img.animated-mine-cart {
        max-height: 200px;
    }
}

@media (max-width: 600px) {
    #slot-machine {
        padding: 15px;
        border-width: 4px;
    }
    #reels-container {
        gap: 5px;
    }
    .symbol-cell {
        width: 60px; 
        height: 60px;
    }
    #controls {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    .info-display {
        margin: 4px 5px;
    }
    header h1 {
        font-size: 2em;
    }
    #paytable-button, #spin-button {
        font-size: 1.2em;
        padding: 10px 18px;
    }
    .modal-content {
        width: 90%;
        padding: 20px;
    }
    #paytable-grid {
       grid-template-columns: 1fr; 
    }
    .paytable-symbol-entry img {
        width: 60px;
        height: 60px;
    }
    .floating-win-text {
        font-size: 2.5em;
    }
    #fullscreen-animation-overlay img.animated-mine-cart {
        max-height: 150px;
    }
}

@media (max-width: 450px) {
    .symbol-cell {
        width: 48px; /* Adjusted for 6 reels to fit better */
        height: 48px;
    }
    header h1 {
        font-size: 1.7em;
    }
    #paytable-button, #spin-button {
        padding: 9px 14px;
        font-size: 1.1em;
    }
    .info-display {
        font-size: 1em;
    }
    .bet-adj-button {
        width: 26px;
        height: 26px;
        font-size: 1em;
    }
     .floating-win-text {
        font-size: 2em;
    }
    #fullscreen-animation-overlay img.animated-mine-cart {
        max-height: 120px;
    }
}