body {
    background-color: #0d0d0d;
    color: #e0e0e0;
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
    position: relative;
    gap: 0;
    min-height: calc(100vh - 20px);
}

.nav-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
    max-width: 800px;
    flex-wrap: wrap;
}

.nav-bar .button {
    background-color: rgba(106, 13, 173, 0.7);
    color: #e0e0e0;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-size: 16px;
}

.nav-bar .button:hover,
.nav-bar .button:focus {
    background-color: rgba(138, 43, 226, 0.7);
}

.nav-bar .button:nth-child(2),
.nav-bar .button:nth-child(3) {
    background-color: rgba(0, 128, 0, 0.7);
}

.nav-bar .button:nth-child(2):hover,
.nav-bar .button:nth-child(2):focus,
.nav-bar .button:nth-child(3):hover,
.nav-bar .button:nth-child(3):focus {
    background-color: rgba(0, 255, 0, 0.7);
}

.game-image {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin: 10px 0;
    display: block;
}

#gameCanvas {
    width: 100%;
    max-width: 800px;
    height: auto;
    aspect-ratio: 4 / 3;
    border: 2px solid #e0e0e0;
    background-color: #0a3d62;
    margin: 0;
}

#name-entry-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 10px 0;
}

#name-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#playerNameInput {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #e0e0e0;
    padding: 5px;
    width: 200px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
}

#startGameButton {
    background-color: rgba(106, 13, 173, 0.7);
    color: #e0e0e0;
    border: none;
    padding: 12px 24px; /* Increased padding from 8px 16px to 12px 24px */
    cursor: pointer;
    border-radius: 5px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 26px; /* Increased font-size from 14px to 16px */
}

#startGameButton:hover,
#startGameButton:focus {
    background-color: rgba(138, 43, 226, 0.7);
}

#controls {
    margin-top: 10px;
    text-align: center;
    width: 100%;
    max-width: 800px;
    position: relative;
}

#bet-controls {
    margin: 10px auto;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 5px;
    z-index: 10;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#balance-display,
#current-bet {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #e0e0e0;
    text-align: center;
    margin: 5px 0;
}

#chip-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.chip-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chip-button {
    width: 45px;
    height: 45px;
    cursor: pointer;
    border: 2px solid rgba(106, 13, 173, 0.7);
    border-radius: 50%;
    transition: transform 0.2s;
    min-height: 45px;
}

.chip-button:hover,
.chip-button:focus {
    transform: scale(1.1);
    border-color: rgba(138, 43, 226, 0.7);
}

.bet-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.bet-button, .game-button {
    background-color: rgba(106, 13, 173, 0.7);
    color: #e0e0e0;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 5px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    min-height: 40px;
    transition: background-color 0.2s;
}

.bet-button:hover, .bet-button:focus,
.game-button.active:hover, .game-button.active:focus {
    background-color: rgba(138, 43, 226, 0.7);
}

.bet-button:nth-child(1), /* 1/2 */
.bet-button:nth-child(2), /* 2X */
.bet-button:nth-child(3), /* Max */
.game-button#hitButton.active,
.game-button#standButton.active {
    background-color: rgba(0, 128, 0, 0.7);
}

.bet-button:nth-child(1):hover, .bet-button:nth-child(1):focus,
.bet-button:nth-child(2):hover, .bet-button:nth-child(2):focus,
.bet-button:nth-child(3):hover, .bet-button:nth-child(3):focus,
.game-button#hitButton.active:hover, .game-button#hitButton.active:focus,
.game-button#standButton.active:hover, .game-button#standButton.active:focus {
    background-color: rgba(0, 255, 0, 0.7);
}

.bet-button:nth-child(4), /* Clear Bet */
.game-button#doubleDownButton.active,
.game-button#splitButton.active {
    background-color: rgba(255, 0, 0, 0.7);
}

.bet-button:nth-child(4):hover, .bet-button:nth-child(4):focus,
.game-button#doubleDownButton.active:hover, .game-button#doubleDownButton.active:focus,
.game-button#splitButton.active:hover, .game-button#splitButton.active:focus {
    background-color: rgba(255, 99, 71, 0.7);
}

.bet-button.place-bet,
.game-button#insuranceButton.active {
    background-color: rgba(0, 128, 0, 0.7);
}

.bet-button.place-bet:hover, .bet-button.place-bet:focus,
.game-button#insuranceButton.active:hover, .game-button#insuranceButton.active:focus {
    background-color: rgba(0, 255, 0, 0.7);
}

#game-controls {
    margin: 10px auto;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 5px;
    z-index: 10;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

#game-controls button {
    background-color: rgba(106, 13, 173, 0.3);
    opacity: 0.5;
}

#game-controls button.active {
    opacity: 1;
    cursor: pointer;
}

#outcome-pane {
    margin: 10px auto;
    text-align: center;
    padding: 15px;
    border-radius: 5px;
    z-index: 10;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 24px;
    font-weight: bold;
    color: #e0e0e0;
    display: none;
}

#outcome-pane.win {
    background: rgba(0, 128, 0, 0.2); /* Reduced opacity from 0.7 to 0.5 */
}

#outcome-pane.loss {
    background: rgba(255, 0, 0, 0.2); /* Reduced opacity from 0.7 to 0.5 */
}

#mute-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    padding: 5px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 5px;
}

#mute-toggle:hover, #mute-toggle:focus {
    background: rgba(0, 255, 0, 0.7);
}

.magic-emoji {
    display: block;
    width: auto;
    height: 40px;
    margin: auto;
}

@media (min-width: 601px) {
    #gameCanvas {
        max-width: 640px; /* 80% of 800px */
        max-height: 480px; /* 80% of 600px */
    }
}

@media (max-width: 600px) {
    .nav-bar {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 5px;
        padding: 6px 10px;
        margin: 5px 0;
    }

    .nav-bar .button {
        padding: 6px 10px;
        font-size: 12px;
    }

    .game-image {
        max-width: 100%;
    }

    #gameCanvas {
        width: 100%;
        max-width: 100vw;
        height: auto;
    }

    #bet-controls,
    #game-controls,
    #outcome-pane {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        margin: 5px auto;
        padding: 15px;
        width: auto;
        max-width: 100%;
    }

    #balance-display,
    #current-bet {
        font-size: 14px;
        margin: 5px auto;
    }

    #chip-buttons {
        gap: 15px;
    }

    .chip-row {
        gap: 22.5px;
    }

    .chip-button {
        width: 90px;
        height: 90px;
        min-height: 90px;
    }

    .bet-button, .game-button {
        padding: 12px 24px;
        font-size: 21px;
        min-height: 66px;
    }

    #outcome-pane {
        font-size: 24px; 
    }

    #mute-toggle {
        top: 5px;
        left: 5px;
        font-size: 20px;
        padding: 3px;
    }

    #controls {
        font-size: 14px;
        padding: 0 10px;
    }

    #playerNameInput {
        width: calc(100% - 20px);
        font-size: 14px;
    }

    #startGameButton {
    padding: 12px 24px; /* Increased from 6px 12px to 12px 24px for a larger button */
    font-size: 18px; /* Increased from 12px to 18px for better readability */
    width: 100%; /* Ensures full width for better touch target */
    box-sizing: border-box; /* Prevents padding from affecting width */
}

    #game-controls button {
        width: auto;
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .magic-emoji {
        height: 30px;
    }

    #balance-display,
    #current-bet {
        font-size: 12px;
    }

    .chip-button {
        width: 75px;
        height: 75px;
        min-height: 75px;
    }

    .bet-button, .game-button {
        padding: 9px 18px;
        font-size: 18px;
        min-height: 60px;
    }

    #playerNameInput {
        font-size: 12px;
    }

    #startGameButton {
    font-size: 16px; /* Increased from 10px to 16px for better readability on smaller screens */
    padding: 10px 20px; /* Adjusted padding to fit smaller screens while keeping it large */
    width: 100%; /* Ensures full width for better touch target */
    box-sizing: border-box; /* Prevents padding from affecting width */
}

    #outcome-pane {
        font-size: 18px;
    }
}