/* CSS Variables */
:root {
    --felt-green: #0d5d2f;
    --felt-green-dark: #0a4a25;
    --felt-green-light: #0f6d3a;
    --card-white: #ffffff;
    --card-red: #d32f2f;
    --card-black: #212121;
    --gold: #ffd700;
    --gold-dark: #ffb300;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-dark: rgba(0, 0, 0, 0.5);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: var(--card-white);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Game Container */
.game-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    min-height: 600px;
    max-height: 1100px;
    background: var(--felt-green);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow-dark), inset 0 0 100px rgba(0, 0, 0, 0.3);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    gap: 20px;
    flex-wrap: wrap;
}

.game-header h1 {
    font-size: 2rem;
    text-shadow: 2px 2px 4px var(--shadow-dark);
    letter-spacing: 2px;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    min-width: 0;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
    min-width: fit-content;
}

.btn-stats {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.1) 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-stats:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px var(--shadow-dark);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
}

.btn-header {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: auto;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Status Bar */
.status-bar {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    text-align: center;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* Game Table */
.game-table {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0;
    min-height: 0;
    overflow: visible;
}

.dealer-section,
.player-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-section {
    gap: 12px;
}

.section-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px var(--shadow-dark);
    padding: 0 10px;
    width: 100%;
}

.section-label > span:first-child {
    text-align: center;
}

.section-label .score {
    position: static;
}

.score {
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
    min-width: 50px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Cards Container */
.cards-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 100px;
    align-items: flex-start;
    justify-content: center;
    padding: 5px;
    perspective: 1000px;
}

/* Card Styles */
.card {
    width: 70px;
    height: 100px;
    background: var(--card-white);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    box-shadow: 0 4px 8px var(--shadow), 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s ease,
                margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px var(--shadow-dark), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.card.red {
    color: var(--card-red);
}

.card.black {
    color: var(--card-black);
}

.card.hidden {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.1) 10px, rgba(255, 255, 255, 0.1) 20px);
    color: transparent;
}

.card.hidden::before,
.card.hidden::after {
    display: none;
}

.card-value {
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
}

.card-suit {
    font-size: 1.8rem;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-corner {
    font-size: 0.9rem;
    font-weight: bold;
}

/* Card Animation */
@keyframes dealCard {
    0% {
        opacity: 0;
        transform: translateY(-80px) translateX(-20px) rotate(-15deg) scale(0.8);
    }
    50% {
        opacity: 0.8;
        transform: translateY(10px) translateX(5px) rotate(5deg) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    }
}

@keyframes flipCard {
    0% {
        transform: rotateY(0deg) scaleX(1);
    }
    50% {
        transform: rotateY(90deg) scaleX(0.1);
    }
    100% {
        transform: rotateY(180deg) scaleX(1);
    }
}

@keyframes revealCard {
    0% {
        opacity: 0;
        transform: rotateY(180deg) scale(0.8);
    }
    50% {
        transform: rotateY(90deg) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}

.card.new-card {
    animation: dealCard 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card.flipping {
    animation: flipCard 0.8s ease-in-out;
}

.card.revealing {
    animation: revealCard 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
    flex-shrink: 0;
    padding: 0;
    position: relative;
    z-index: 10;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px var(--shadow);
    min-width: 100px;
    position: relative;
    z-index: 11;
    pointer-events: auto;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--card-black);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px var(--shadow-dark);
}

.btn-primary.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 6px var(--shadow);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 12px var(--shadow-dark), 0 0 20px rgba(255, 215, 0, 0.5);
    }
}

.btn-action {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    color: white;
}

.btn-action:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px var(--shadow-dark);
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
}

.btn-advice {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
}

.btn-advice:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px var(--shadow-dark);
    background: linear-gradient(135deg, #42a5f5 0%, #2196f3 100%);
}


/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--felt-green);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    border-radius: 20px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px var(--shadow-dark), inset 0 0 100px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.modal-header h2 {
    margin: 0;
    color: var(--gold);
    text-shadow: 2px 2px 4px var(--shadow-dark);
    font-size: 1.5rem;
    letter-spacing: 1px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--card-white);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item.stat-winrate {
    margin-top: 10px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 215, 0, 0.3);
}

.stat-label {
    font-size: 1.1rem;
    color: var(--card-white);
    text-shadow: 1px 1px 2px var(--shadow-dark);
    font-weight: 500;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--gold);
}

/* Responsive Design */
@media (max-width: 600px) {
    .game-container {
        padding: 15px;
        max-height: 100vh;
        border-radius: 0;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }

    .game-header h1 {
        font-size: 1.5rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .header-buttons {
        flex: 1 1 auto;
        justify-content: flex-end;
        min-width: 0;
        flex-wrap: wrap;
    }

    .btn-header {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .card {
        width: 55px;
        height: 80px;
        font-size: 0.9rem;
    }

    .card-value {
        font-size: 1rem;
    }

    .card-suit {
        font-size: 1.4rem;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
        min-width: 80px;
    }

    .controls {
        gap: 8px;
    }

    .section-label {
        font-size: 1rem;
    }

    .status-bar {
        font-size: 0.85rem;
        padding: 10px 15px;
    }
}

@media (max-height: 500px) {
    .game-table {
        gap: 15px;
        padding: 10px 0;
    }

    .card {
        width: 50px;
        height: 70px;
    }

    .cards-container {
        min-height: 80px;
    }
}

