:root {
    --felt-color: #0d4f30; /* Deep forest green */
    --gold-accent: #ffc425;
    --card-bg: #ffffff;
    --card-red: #cc0000;
    --card-border: #333;
    --hit-color: #007bff;
    --stand-color: #dc3545;
    --deal-color: #28a745;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden; 
}

/* Casino Felt Background and Texture */
.casino-felt {
    background-color: var(--felt-color);
    background-image: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.5) 100%);
    border: 10px solid #5d4037; 
    border-radius: 50px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
    padding: 40px;
    position: relative;
}

.game-table {
    width: 90%;
    max-width: 900px;
    text-align: center;
}

h1 {
    color: var(--gold-accent);
    margin-bottom: 25px;
    font-size: 2.5em;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

/* Info Bar & Messages */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 5px solid var(--gold-accent);
}

#game-message {
    font-size: 1.1em;
    font-weight: bold;
    color: #aaffaa; 
}

.bank-info {
    font-size: 1.1em;
    font-weight: 500;
}
#bank-amount {
    color: var(--gold-accent);
    font-weight: bold;
}

/* --- Card and Hand Styling --- */

.hand {
    min-height: 110px;
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px 0;
    position: relative; 
}

.card {
    background-color: var(--card-bg);
    color: var(--card-border);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    width: 70px;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    font-size: 1.8em;
    font-weight: bold;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    /* Added backface visibility for better flip effects */
    transform-style: preserve-3d;
}

.card.red {
    color: var(--card-red);
}

/* Card Content Details */
.card-value-top { align-self: flex-start; font-size: 0.5em; line-height: 1; }
.card-value-bottom { align-self: flex-end; transform: rotate(180deg); font-size: 0.5em; line-height: 1; }
.card-suit-center {
    font-size: 1.5em;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

/* Card Back */
.back {
    background-color: #3f51b5; 
    color: #fff;
    font-size: 2em;
    position: absolute; /* Needed for flip */
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    /* Ensuring the back looks good without inner HTML */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    transform: rotateY(0deg);
}

.back:before {
    content: 'BJ'; 
    font-size: 0.8em;
    font-weight: bolder;
    border: 2px solid white;
    padding: 2px 5px;
    border-radius: 4px;
}

/* --- ANIMATIONS & VFX --- */

/* 1. Card Deal Animation (Shooter) - Using simpler transform */
@keyframes dealCard {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.8) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: translate(var(--end-x), var(--end-y)) scale(1) rotate(var(--rotation, 0deg));
    }
}

.card.animate-deal {
    position: absolute; 
    /* Start position is relative to the hand container, which is near the center */
    top: 50%;
    left: 50%; 
    z-index: 10;
    /* Animation duration is crucial for timing */
    animation: dealCard 0.4s ease-out forwards;
}

/* 2. Card Flip Animation */
.card-flip {
    transition: transform 0.6s;
    /* The face side, which is the default card structure */
    transform: rotateY(0deg); 
}

.card-flip.flipped {
    transform: rotateY(180deg);
}

/* For the dealer's hidden card flip */
.card-flip .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(0deg);
}

.card-flip.flipped .card-face {
    transform: rotateY(180deg);
}

/* Controls (VFX) */
.center-controls button:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
}

/* Button styles remain the same for consistency */
.center-controls {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    margin: 20px 0;
}
.bet-controls, .action-controls {
    padding: 15px;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.4);
}
#bet-input {
    width: 80px; padding: 8px; margin-right: 10px; border-radius: 5px; border: 2px solid var(--gold-accent); text-align: center; background-color: #333; color: #fff; font-weight: bold; font-size: 1em;
}
.center-controls button {
    padding: 12px 25px; margin: 5px; border: none; border-radius: 25px; font-size: 1.1em; font-weight: 700; cursor: pointer; box-shadow: