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

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

body {
    background: url('../assets/bck2.webp') center center / cover no-repeat fixed;
    background-color: #1a0a00;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 10px;
    gap: 8px;
}

#logo {
    width: 180px;
    max-width: 50%;
    height: auto;
    flex-shrink: 0;
}

#grid-wrapper {
    position: relative;
    background: rgba(30, 18, 10, 0.85);
    border-radius: 12px;
    padding: 10px;
    border: 3px solid #C8943E;
    box-shadow:
        /* Outer layered border effect */
        0 0 0 4px rgba(0, 0, 0, 0.5),
        0 0 0 7px #8B6914,
        /* Ambient glow */
        0 0 25px rgba(0, 0, 0, 0.6),
        /* Inner darkening at edges */
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        /* Warm gold tint around edges */
        inset 0 0 60px rgba(139, 105, 20, 0.15);
    transition: all 0.4s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

#grid-wrapper.free-spins-mode {
    border-color: #ffd700;
    box-shadow:
        /* Outer layered border - brighter gold for free spins */
        0 0 0 4px rgba(0, 0, 0, 0.5),
        0 0 0 7px #DAA520,
        /* Golden glow */
        0 0 30px rgba(255, 215, 0, 0.4),
        0 0 50px rgba(255, 215, 0, 0.2),
        /* Inner darkening */
        inset 0 0 30px rgba(0, 0, 0, 0.4),
        /* Stronger gold tint for free spins */
        inset 0 0 60px rgba(255, 200, 50, 0.2);
}

#reels-container {
    display: grid;
    gap: 10px;
    transition: grid-template-columns 0.4s ease-out;
    align-content: center;
}

.reel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: reelSlideIn 0.4s ease-out;
}

@keyframes reelSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.symbol {
    aspect-ratio: 1;
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    background-color: rgba(20, 12, 6, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(200, 148, 62, 0.25);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    /* Add padding inside the cell so symbol doesn't touch edges */
    padding: 5px;
    background-origin: content-box;
}

.symbol.spinning {
    /* Symbols are visible and cycling during spin */
}

.symbol.stopping {
    animation: symbolBounce 0.2s ease-out;
}

@keyframes symbolBounce {
    0% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    70% { transform: translateY(3px); }
    100% { transform: translateY(0); }
}

.symbol.winning {
    animation: winPulse 0.5s ease-in-out 3;
    border-color: #ffd700;
    border-width: 2px;
    box-shadow:
        0 0 15px rgba(255, 215, 0, 0.8),
        inset 0 0 10px rgba(255, 200, 50, 0.3);
    z-index: 10;
}

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

#multiplier-display {
    position: absolute;
    top: -15px;
    right: -15px;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #1a0a00;
    font-weight: bold;
    font-size: 18px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
}

#multiplier-display.visible {
    opacity: 1;
    transform: scale(1);
}

#multiplier-display.pulse {
    animation: multiplierPulse 0.4s ease-out;
}

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

#free-spins-display {
    position: absolute;
    top: -15px;
    left: -15px;
    background: linear-gradient(135deg, #b8501a, #6e2a0c);
    color: #fff3d6;
    font-weight: bold;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 20px;
    border: 2px solid #ffd700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: none;
}

#free-spins-display.visible {
    display: block;
    animation: freeSpinsBadge 0.5s ease-out;
}

@keyframes freeSpinsBadge {
    from { transform: scale(0) rotate(-180deg); }
    to { transform: scale(1) rotate(0deg); }
}

#controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(30, 15, 5, 0.9), rgba(50, 25, 10, 0.85));
    border-radius: 10px;
    border: 2px solid #8b5a2b;
    flex-shrink: 0;
}

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

.control-label {
    color: #c9a86c;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-value {
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    min-width: 70px;
    text-align: center;
}

#bet-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bet-btn {
    background: linear-gradient(135deg, #5a3d2b, #3d2817);
    color: #ffd700;
    border: 2px solid #8b5a2b;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.bet-btn:hover {
    background: linear-gradient(135deg, #6b4e3c, #4e3928);
    transform: scale(1.05);
}

.bet-btn:active {
    transform: scale(0.95);
}

#bet-amount {
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

#spin-btn {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #1a0a00;
    border: 3px solid #fff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

#spin-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

#spin-btn:active:not(:disabled) {
    transform: scale(0.95);
}

#spin-btn:disabled {
    background: linear-gradient(135deg, #666, #444);
    color: #999;
    cursor: not-allowed;
    border-color: #888;
}

#win-display .control-value {
    color: #00ff00;
    transition: transform 0.2s;
}

#win-display .control-value.counting {
    animation: winCount 0.1s ease-in-out infinite;
}

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

/* Overlay for announcements */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 100;
}

#overlay.visible {
    display: flex;
    animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#overlay-content {
    text-align: center;
    animation: overlayBounce 0.5s ease-out;
}

@keyframes overlayBounce {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

#overlay h2 {
    color: #ffd700;
    font-size: 48px;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    margin-bottom: 20px;
}

#overlay p {
    color: #fff;
    font-size: 24px;
    margin-bottom: 30px;
}

#overlay .scatter-icons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

#overlay .scatter-icon {
    width: 80px;
    height: 80px;
    background: url('../assets/sym_2_scatter_map.webp') center/contain no-repeat;
    animation: scatterSpin 1s ease-in-out infinite;
}

@keyframes scatterSpin {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
}

#overlay button {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #1a0a00;
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s;
}

#overlay button:hover {
    transform: scale(1.05);
}

/* Big win overlay */
#big-win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 100;
}

#big-win-overlay.visible {
    display: flex;
    animation: overlayFadeIn 0.3s ease-out;
}

#big-win-content {
    text-align: center;
}

#big-win-content h2 {
    color: #ffd700;
    font-size: 60px;
    text-shadow:
        0 0 30px rgba(255, 215, 0, 0.8),
        0 0 60px rgba(255, 215, 0, 0.5);
    animation: bigWinText 0.5s ease-out infinite alternate;
    margin-bottom: 20px;
}

@keyframes bigWinText {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

#big-win-amount {
    color: #fff;
    font-size: 72px;
    font-weight: bold;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
}

/* Screen shake for expansion */
@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: screenShake 0.2s ease-in-out;
}

/* Responsive design - Mobile */
@media (max-width: 768px) {
    #game-container {
        padding: 6px;
        gap: 6px;
    }

    #logo {
        width: 140px;
    }

    #grid-wrapper {
        padding: 8px;
        border-radius: 10px;
    }

    #reels-container {
        gap: 6px;
    }

    .reel {
        gap: 6px;
    }

    .symbol {
        border-radius: 8px;
        padding: 4px;
    }

    #controls {
        gap: 12px;
        padding: 6px 12px;
    }

    .control-label {
        font-size: 10px;
    }

    .control-value {
        font-size: 14px;
        min-width: 55px;
    }

    #bet-amount {
        font-size: 14px;
        min-width: 45px;
    }

    #spin-btn {
        width: 52px;
        height: 52px;
        font-size: 11px;
    }

    #multiplier-display {
        font-size: 13px;
        padding: 5px 9px;
        top: -10px;
        right: -10px;
    }

    #free-spins-display {
        font-size: 11px;
        padding: 5px 9px;
        top: -10px;
        left: -10px;
    }

    #overlay h2 {
        font-size: 32px;
    }

    #overlay p {
        font-size: 16px;
    }

    #overlay .scatter-icon {
        width: 55px;
        height: 55px;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 4px;
        gap: 5px;
    }

    #logo {
        width: 110px;
    }

    #grid-wrapper {
        padding: 8px;
    }

    #reels-container {
        gap: 5px;
    }

    .reel {
        gap: 5px;
    }

    .symbol {
        border-radius: 6px;
        padding: 3px;
    }

    #controls {
        gap: 10px;
        padding: 5px 10px;
    }

    #spin-btn {
        width: 48px;
        height: 48px;
        font-size: 10px;
    }

    .bet-btn {
        width: 26px;
        height: 26px;
        font-size: 16px;
    }
}

/* Symbol size: the original used fixed 125px on desktop and per-reel-count sizes on mobile
   (.reels-N .symbol). Token mode computes the same thing in JS (game.js fitGrid) into --sym:
   capped at 125px, fixed on desktop, shrinking with the reel count on narrow screens. */
#reels-container .symbol {
    width: var(--sym, 125px);
    height: var(--sym, 125px);
}
