body {
    font-family: 'Arial', sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top to see paytable */
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    background-image: url('game_background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

#game-container {
    background-color: rgba(23, 37, 42, 0.9); /* Dark tealish blue, semi-transparent */
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.3);
    width: 90%;
    max-width: 800px;
    text-align: center;
    position: relative; /* For positioning audio controls */
}

header {
    position: relative; /* For positioning audio controls inside header */
    margin-bottom: 20px;
}

header h1 {
    color: #00ffff; /* Cyan */
    text-shadow: 0 0 10px #00ffff;
    margin-bottom: 0; /* Adjusted due to audio controls */
}

#audio-controls {
    position: absolute;
    top: 0px;
    right: 0px;
}

#mute-button {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
}

#mute-button img {
    width: 30px;
    height: 30px;
    filter: drop-shadow(0 0 3px #00ffff);
}

#info-panel {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background-color: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
}

.info-box {
    font-size: 1.2em;
    color: #f5f5f5;
}

#cards-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 25px;
    min-height: 180px; /* For large cards */
    perspective: 1000px; /* For 3D flip effect */
}

.card-placeholder { /* Will be replaced by actual cards */
    width: 100px;
    height: 150px;
    background-color: rgba(255,255,255,0.1);
    border: 2px dashed #555;
    border-radius: 10px;
}

.card {
    width: 100px;
    height: 150px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s, opacity 0.3s, box-shadow 0.2s ease-out;
    opacity: 0; /* Initially hidden for deal-in animation */
    transform: translateY(20px); /* Start slightly offset for deal-in animation */
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 10px;
    box-shadow: 3px 3px 8px rgba(0,0,0,0.5);
}

.card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.card-back {
    background-image: url('card_back.png');
    background-size: cover;
    background-position: center;
    border: 2px solid #333;
}

.card-front {
    background-color: #fff; /* White card face */
    color: #333; /* Dark text for card face */
    transform: rotateY(180deg);
    border: 2px solid #888;
}

.card:hover:not(.is-dealt) { /* Allow hover effect only after dealt and if not held perhaps */
    /* transform: translateY(-5px); no, this interferes with deal-in*/
    box-shadow: 0 0 15px #00ffffaa;
}

.card.held .card-inner {
    border: 3px solid #00ffff; /* Cyan border for held */
    box-shadow: 0 0 15px #00ffff, 3px 3px 8px rgba(0,0,0,0.5);
}

/* Animation for dealing cards in */
.card.deal-in {
    opacity: 1;
    transform: translateY(0);
}

.card .rank {
    font-size: 2.8em; /* Large rank */
    font-weight: bold;
    line-height: 1;
}

.card .suit {
    font-size: 2.2em; /* Large suit */
    line-height: 1;
}

.suit.hearts, .suit.diamonds {
    color: #ff4757; /* Red */
}

.suit.spades, .suit.clubs {
    color: #2f3542; /* Black */
}

.card .held-text {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%) rotateY(180deg); /* Counter-rotate and position */
    background-color: rgba(0, 255, 255, 0.8); /* Cyan */
    color: #1a1a2e;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    visibility: hidden; /* Initially hidden, shown when card is flipped and held */
}

.card.is-flipped.held .held-text {
    visibility: visible;
}

/* Styles for winning card animations */
@keyframes cardZoomPopEffect {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  50% {
    transform: scale(1.15) translateY(-5px); /* Pop up slightly and zoom */
  }
}

@keyframes cardFlashOutlineEffect {
  0%, 100% {
    outline: none;
  }
  50% {
    outline: 3px solid gold; /* Golden outline flash */
    outline-offset: 2px; /* Optional: moves outline slightly away from card edge */
  }
}

.card.winning-card-animation {
  animation: cardZoomPopEffect 0.8s ease-in-out;
  /* z-index: 10; Ensure it pops above others if overlapping slightly. Already on .card:hover */
}

.card.winning-card-animation .card-inner {
  animation: cardFlashOutlineEffect 0.8s ease-in-out;
}

#controls {
    margin-bottom: 25px;
}

.control-button {
    background-color: #4a00e0; /* Purple */
    color: white;
    border: none;
    padding: 12px 25px;
    margin: 5px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    background-image: url('button_background.png'); /* If available */
    background-size: cover;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.control-button:hover {
    background-color: #8e2de2; /* Lighter Purple */
    transform: scale(1.05);
}
.control-button:active {
    transform: scale(0.98);
}

.control-button.deal-button {
    background-color: #1abc9c; /* Teal */
}
.control-button.deal-button:hover {
    background-color: #16a085; /* Darker Teal */
}

.control-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

#pay-table-container {
    margin-top: 20px;
    background-color: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
}

#pay-table-container h2 {
    color: #00ffff;
    margin-bottom: 10px;
}

#pay-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

#pay-table th, #pay-table td {
    border: 1px solid #444;
    padding: 8px;
    text-align: left;
}

#pay-table th {
    background-color: #333;
    color: #00ffff;
}

#pay-table td {
    color: #f0f0f0;
}

#pay-table tr.highlight-hand td {
    background-color: #8e2de2; /* Purple highlight for winning hand */
    color: white;
    font-weight: bold;
}
#pay-table td.highlight-bet {
    background-color: #00ffff;
    color: #1a1a2e;
    font-weight: bold;
}

#floating-win-message {
    position: absolute;
    top: 45%; /* Adjusted to be slightly more centered with cards */
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5); /* Initial state for animation */
    background-color: rgba(20, 20, 40, 0.85); /* Dark blue, semi-transparent */
    color: #ffd700; /* Gold */
    font-size: 2.8em; /* Large text */
    font-weight: bold;
    text-align: center;
    padding: 25px 45px;
    border-radius: 20px;
    border: 4px solid #ffd700; /* Gold border */
    text-shadow: 
        2px 2px 0px #000, /* Black outline for readability */
        0 0 15px #ffd700,  /* Gold glow */
        0 0 25px #ff8c00; /* Orange deeper glow */
    z-index: 100; /* Above cards, below bonus game overlay */
    opacity: 0;
    transition: opacity 0.3s ease-out, transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Pop effect */
    pointer-events: none; /* Don't interfere with clicks */
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5); /* Outer gold shadow */
}

#floating-win-message.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#floating-win-message .floating-win-amount {
    display: block;
    font-size: 1.6em; /* Larger for amount */
    color: #ffeb3b; /* Brighter yellow for amount */
    margin-top: 10px;
    text-shadow: 
        2px 2px 0px #000,
        0 0 10px #ffeb3b,
        0 0 20px #ffae42;
}

#floating-win-message.hidden { /* Ensure it's hidden initially and after use */
    display: none;
    opacity: 0; /* Fallback if display:none isn't immediate */
}

#bonus-game-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

#bonus-game-area.hidden {
    display: none;
}

#bonus-game-area h2 {
    font-size: 2.5em;
    color: #ffeb3b; /* Yellow */
    text-shadow: 0 0 10px #ffeb3b;
    margin-bottom: 20px;
}

#bonus-message, #bonus-result-message {
    font-size: 1.5em;
    color: #fff;
    margin-bottom: 30px;
}

#bonus-items-container {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 600px;
}

.bonus-item {
    width: 120px;
    height: 120px;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.bonus-item:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}