body {
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', Arial, sans-serif;
    background-image: url("images/table.png");
    background-size: cover;
    font-weight: bold;
    color: white;
    text-align: center;
    margin: 0;
    padding: 10px;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

header h1 {
    color: goldenrod;
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.7);
    margin: 10px 0;
    font-size: 2.5em;
}

#message-el {
    font-style: italic;
    font-size: 1.2em;
    min-height: 1.5em;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 5px;
    margin: 0;
    max-width: 200px;
    text-align: left;
}

.game-container {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    max-width: 1200px;
    gap: 15px;
}

.game-table {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    background-color: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    gap: 15px;
}

.dealer-section, .player-section {
    flex: 1;
    padding: 10px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dealer-section {
    background-color: rgba(139, 0, 0, 0.5);
    position: relative;
}

.dealer-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
}

.player-section {
    background-color: rgba(0, 100, 0, 0.5);
}

.control-panel {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.betting-section {
    background-color: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chip-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    padding: 5px;
}

.chip-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    font-size: 1.2em;
    font-weight: bold;
    border: 4px solid #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: 20px 20px;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.2) 20%, transparent 20%);
    position: relative;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Specific colors for each chip denomination */
.chip-btn[data-amount="5"] {
    background-color: #ff4444; /* Red for $5 */
}

.chip-btn[data-amount="10"] {
    background-color: #4444ff; /* Blue for $10 */
}

.chip-btn[data-amount="25"] {
    background-color: #44ff44; /* Green for $25 */
}

.chip-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.chip-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* Added chip animation */
.chip-btn.chip-clicked {
    animation: chipBounce 0.3s ease;
}

@keyframes chipBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.chip-btn:disabled {
    background-color: #666666;
    color: #999999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    text-shadow: none;
}

#bet-display {
    font-size: 1.3em;
    font-weight: bold;
    color: goldenrod;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 100px;
    text-align: center;
    border: 2px solid goldenrod;
}

.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
    justify-content: center;
    align-items: center;
}

button {
    color: #016f32;
    width: 110px;
    background: goldenrod;
    padding: 10px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1em;
    min-height: 44px;
}

button:hover {
    background-color: #e6c046;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background-color: #a9a9a9;
    color: #6e6e6e;
    cursor: not-allowed;
}

.highlight-button {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

@keyframes dealCard {
    0% {
        transform: translateY(-100px) rotateY(180deg);
        opacity: 0;
    }
    100% {
        transform: translateY(0) rotateY(0);
        opacity: 1;
    }
}

@keyframes flipCard {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

@keyframes flipHiddenCard {
    0% { transform: rotateY(0deg); }
    50% {
        transform: rotateY(90deg);
        background-image: repeating-linear-gradient(45deg, #1b579e 0, #1b579e 5px, #2063a8 0, #2063a8 10px);
    }
    100% { transform: rotateY(0deg); background-image: none; }
}

@keyframes shuffle {
    0% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-20px) rotate(-5deg); }
    50% { transform: translateX(20px) rotate(5deg); }
    75% { transform: translateX(-10px) rotate(-3deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

.shuffle-animation {
    animation: shuffle 0.3s ease-in-out 3;
}

.deck {
    width: 80px;
    height: 120px;
    background-color: #2063a8;
    background-image: repeating-linear-gradient(45deg, #1b579e 0, #1b579e 5px, #2063a8 0, #2063a8 10px);
    border: 3px solid white;
    border-radius: 8px;
    padding: 10px auto;
    position: relative;
    margin: 10px auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.deck::before, .deck::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #2063a8;
    background-image: repeating-linear-gradient(45deg, #1b579e 0, #1b579e 5px, #2063a8 0, #2063a8 10px);
    border: 3px solid white;
    border-radius: 8px;
    left: 0;
    top: 0;
}

.deck::before {
    transform: translate(3px, 3px);
    z-index: -1;
}

.deck::after {
    transform: translate(6px, 6px);
    z-index: -2;
}

#dealer-cards-el, #cards-el {
    font-size: 1.2em;
    font-weight: bold;
    margin: 5px 0;
}

.hidden {
    display: none;
}

.rules-toggle {
    margin: 20px auto;
    max-width: 1200px;
}

#rules {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    text-align: left;
}

#rules h3 {
    margin-top: 0;
}

#rules ul {
    padding-left: 20px;
}

#rules li {
    margin: 8px 0;
    font-size: 1em;
}

#bet-el, #player-el {
    font-size: 1.1em;
    margin: 5px;
}

.cards-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    min-height: 120px;
}

.card {
    width: 80px;
    height: 120px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px RGBA(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5px;
    position: relative;
    color: black;
    font-weight: bold;
    transform-style: preserve-3d;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.card.red {
    color: #d40000;
}

.card-back {
    background-color: #2063a8;
    background-image: repeating-linear-gradient(45deg, #1b579e 0, #1b579e 5px, #2063a8 0, #2063a8 10px);
    border: 3px solid white;
}

.card.reveal {
    animation: flipCard 0.5s ease-out forwards;
}

.card-back.reveal {
    animation: flipHiddenCard 0.5s ease-out forwards;
}

.card.new-card {
    animation: dealCard 0.5s ease-out forwards;
}

.card.stand-effect {
    animation: standEffect 0.5s ease-out;
}

@keyframes standEffect {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.card-suit {
    font-size: 18px;
}

.card-suit.top {
    align-self: flex-start;
}

.card-suit.bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card-value {
    font-size: 28px;
    align-self: center;
}

.history-section {
    margin: 15px auto;
    max-width: 1200px;
    background-color: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 5px;
}

.history-section h2 {
    margin: 5px 0 10px;
    font-size: 1.5em;
}

.history-stats-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
}

.history-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

.stats-container {
    flex: 1;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.3);
    font-size: 0.9em;
}

.history-item.win {
    background-color: rgba(0, 128, 0, 0.3);
    border-left: 4px solid green;
}

.history-item.lose {
    background-color: rgba(128, 0, 0, 0.3);
    border-left: 4px solid darkred;
}

.history-item.tie {
    background-color: rgba(64, 64, 64, 0.3);
    border-left: 4px solid gray;
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0.8;
    animation: fall 3s linear forwards;
}

@keyframes fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 0.8; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Enhanced Dealer Avatar */
.dealer-avatar {
    width: 80px;
    height: 120px;
    position: relative;
    transition: transform 0.3s ease;
}

.dealer-avatar .head {
    width: 30px;
    height: 30px;
    background-color: #f0d9b5;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
}

.dealer-avatar .eyes {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    display: flex;
    justify-content: space-between;
}

.dealer-avatar .eye {
    width: 6px;
    height: 6px;
    background-color: #333;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.dealer-avatar .mouth {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 4px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.dealer-avatar .body {
    width: 40px;
    height: 50px;
    background-color: #333;
    position: absolute;
    top: 35px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 5px;
}

.dealer-avatar .tie {
    width: 20px;
    height: 15px;
    background-color: #ff0000;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.dealer-avatar .arm-left,
.dealer-avatar .arm-right {
    width: 12px;
    height: 40px;
    background-color: #333;
    position: absolute;
    top: 40px;
    transform-origin: top center;
    transition: transform 0.3s ease;
}

.dealer-avatar .arm-left {
    left: 10px;
}

.dealer-avatar .arm-right {
    right: 10px;
}

.dealer-avatar.waving .arm-right {
    animation: wave 1s infinite;
}

.dealer-avatar.dealing .arm-right {
    animation: deal 0.5s ease-out;
}

.dealer-avatar.happy .mouth {
    width: 16px;
    height: 8px;
    border-radius: 0 0 8px 8px;
    background-color: #fff;
}

.dealer-avatar.happy .eye {
    transform: translateY(-2px);
}

.dealer-avatar.sad .mouth {
    width: 12px;
    height: 8px;
    border-radius: 8px 8px 0 0;
}

.dealer-avatar.sad .eye {
    transform: translateY(2px);
}

.dealer-avatar.surprised .mouth {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #fff;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-30deg); }
    75% { transform: rotate(30deg); }
    100% { transform: rotate(0deg); }
}

@keyframes deal {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-45deg) translateX(10px); }
    100% { transform: rotate(0deg); }
}

@keyframes wink {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

.dealer-avatar.winking .eye.right {
    animation: wink 0.5s ease-in-out;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .game-table {
        flex-direction: column;
    }
    
    .dealer-container {
        flex-direction: column;
        gap: 10px;
    }
    
    #message-el {
        max-width: 100%;
        text-align: center;
    }
    
    .control-panel {
        flex-direction: column;
    }
    
    .history-stats-container {
        flex-direction: column;
    }
    
    button {
        width: 90px;
        font-size: 0.9em;
    }
    
    .card, .deck {
        width: 60px;
        height: 90px;
    }
    
    .card-value {
        font-size: 20px;
    }
    
    .card-suit {
        font-size: 14px;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .stats-container {
        font-size: 0.85em;
    }
    
    .dealer-avatar {
        width: 60px;
        height: 90px;
    }
    
    .dealer-avatar .head {
        width: 24px;
        height: 24px;
    }
    
    .dealer-avatar .eyes {
        top: 6px;
        width: 16px;
    }
    
    .dealer-avatar .eye {
        width: 5px;
        height: 5px;
    }
    
    .dealer-avatar .mouth {
        bottom: 4px;
        width: 10px;
        height: 3px;
    }
    
    .dealer-avatar .body {
        width: 32px;
        height: 40px;
        top: 28px;
    }
    
    .dealer-avatar .tie {
        width: 16px;
        height: 12px;
    }
    
    .dealer-avatar .arm-left,
    .dealer-avatar .arm-right {
        width: 10px;
        height: 32px;
        top: 32px;
    }
    
    .chip-btn {
        width: 60px;
        height: 60px;
        font-size: 1.1em;
    }
    
    #bet-display {
        font-size: 1.1em;
        padding: 8px 15px;
        min-width: 80px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 5px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    #message-el {
        font-size: 1em;
        padding: 6px;
    }
    
    .game-table {
        padding: 10px;
        gap: 10px;
    }
    
    .dealer-container {
        gap: 8px;
    }
    
    .control-panel {
        gap: 10px;
    }
    
    .betting-section {
        padding: 8px;
    }
    
    button {
        width: 100%;
        max-width: 120px;
        padding: 8px;
        font-size: 0.85em;
    }
    
    .controls-section {
        gap: 8px;
    }
    
    .card, .deck {
        width: 50px;
        height: 75px;
    }
    
    .card-value {
        font-size: 18px;
    }
    
    .card-suit {
        font-size: 12px;
    }
    
    #dealer-cards-el, #cards-el {
        font-size: 1em;
    }
    
    #bet-el, #player-el {
        font-size: 1em;
    }
    
    .history-section {
        margin: 10px auto;
    }
    
    .history-section h2 {
        font-size: 1.2em;
    }
    
    .history-item {
        font-size: 0.8em;
        padding: 6px;
    }
    
    .stats-container {
        font-size: 0.75em;
    }
    
    .rules-toggle {
        margin: 15px auto;
    }
    
    #rules {
        padding: 10px;
    }
    
    #rules li {
        font-size: 0.9em;
    }
    
    .dealer-avatar {
        width: 50px;
        height: 75px;
    }
    
    .dealer-avatar .head {
        width: 20px;
        height: 20px;
    }
    
    .dealer-avatar .eyes {
        top: 5px;
        width: 14px;
    }
    
    .dealer-avatar .eye {
        width: 4px;
        height: 4px;
    }
    
    .dealer-avatar .mouth {
        bottom: 3px;
        width: 8px;
        height: 2px;
    }
    
    .dealer-avatar .body {
        width: 26px;
        height: 32px;
        top: 23px;
    }
    
    .dealer-avatar .tie {
        width: 14px;
        height: 10px;
    }
    
    .dealer-avatar .arm-left,
    .dealer-avatar .arm-right {
        width: 8px;
        height: 26px;
        top: 26px;
    }
    
    .chip-btn {
        width: 50px;
        height: 50px;
        font-size: 1em;
    }
    
    #bet-display {
        font-size: 1em;
        padding: 6px 12px;
        min-width: 70px;
    }
}