/* Card Styles */
.card {
    width: 120px;
    height: 168px;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    transform-style: preserve-3d;
    user-select: none;
}

#player-1 .player-hand .card {
    width: 120px;
    height: 168px;
}

.card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 1px solid #333;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card-front {
    background: #ffffff;
    transform: rotateY(0deg);
}

.card-back {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.card.flipped .card-back {
    transform: rotateY(0deg);
}

/* Card Back Pattern */
.card-back::before {
    content: '';
    width: 80%;
    height: 80%;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.1) 3px,
        transparent 3px,
        transparent 6px
    );
    border-radius: 4px;
}

/* Card Front Elements */
.card-corner {
    position: absolute;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

.card-corner.top-left {
    top: 6px;
    left: 6px;
}

.card-corner.bottom-right {
    bottom: 6px;
    right: 6px;
    transform: rotate(180deg);
}

.card-suit {
    font-size: 16px;
    line-height: 1;
}

.card-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
}

/* Suit Colors */
.card.hearts,
.card.diamonds {
    color: #dc3545;
}

.card.clubs,
.card.spades {
    color: #000;
}

/* Suit Symbols */
.suit-hearts::before { content: '♥'; }
.suit-diamonds::before { content: '♦'; }
.suit-clubs::before { content: '♣'; }
.suit-spades::before { content: '♠'; }

/* Card Rank Display */
.rank-a::before { content: 'A'; }
.rank-2::before { content: '2'; }
.rank-3::before { content: '3'; }
.rank-4::before { content: '4'; }
.rank-5::before { content: '5'; }
.rank-6::before { content: '6'; }
.rank-7::before { content: '7'; }
.rank-8::before { content: '8'; }
.rank-9::before { content: '9'; }
.rank-10::before { content: '10'; font-size: 16px; }
.rank-j::before { content: 'J'; }
.rank-q::before { content: 'Q'; }
.rank-k::before { content: 'K'; }

/* Face Card Designs */
.card.face-card .card-center {
    font-size: 28px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card.face-card .face-symbol {
    font-size: 40px;
}

/* Card States */
.card.selected {
    transform: translateY(-10px) scale(1.1);
    box-shadow: 0 10px 20px rgba(255, 215, 0, 0.5);
    border: 2px solid #ffd700;
}

.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Card Animation Classes */
.card-deal {
    animation: cardDeal 0.5s ease-out;
}

.card-flip {
    animation: cardFlip 0.6s ease-in-out;
}

.card-remove {
    animation: cardRemove 0.4s ease-in;
}

@keyframes cardDeal {
    0% {
        transform: translateX(-100px) translateY(-50px) scale(0);
        opacity: 0;
    }
    70% {
        transform: translateX(0) translateY(0) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg) scale(1.1); }
    100% { transform: rotateY(180deg); }
}

@keyframes cardRemove {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
        opacity: 0.7;
    }
    100% {
        transform: scale(0) rotate(20deg);
        opacity: 0;
    }
}

/* Special Card Highlights */
.card.winning-card {
    animation: winningGlow 2s infinite;
}

.card.losing-card {
    animation: losingPulse 1s ease-in-out 3;
}

@keyframes winningGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
}

@keyframes losingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Placeholder Card */
.card-placeholder {
    width: 120px;
    height: 168px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
    text-align: center;
}

/* Deck Back Design */
.card-back {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
    position: relative;
    overflow: hidden;
}

.card-back::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    border-radius: 50%;
}

/* Responsive Card Sizes */
@media (max-width: 768px) {
    .card {
        width: 100px;
        height: 140px;
    }

    #player-1 .player-hand .card {
        width: 100px;
        height: 140px;
    }

    .card-corner {
        font-size: 16px;
    }

    .card-center {
        font-size: 28px;
    }

    .card.face-card .card-center {
        font-size: 24px;
    }

    .card.face-card .face-symbol {
        font-size: 32px;
    }
}

@media (max-width: 480px) {
    .card {
        width: 90px;
        height: 126px;
    }

    #player-1 .player-hand .card {
        width: 90px;
        height: 126px;
    }

    .card-corner {
        font-size: 14px;
    }

    .card-center {
        font-size: 24px;
    }
}

/* Stack Effect for Multiple Cards */
.card-stack {
    position: relative;
}

.card-stack .card:nth-child(1) {
    z-index: 3;
}

.card-stack .card:nth-child(2) {
    position: absolute;
    top: 2px;
    left: 2px;
    z-index: 2;
}

.card-stack .card:nth-child(3) {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 1;
}

/* Hand Value Display */
.hand-value {
    display: inline-block;
    background: rgba(0, 0, 0, 0.7);
    color: #ffd700;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 5px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.hand-value.bust {
    background: rgba(220, 53, 69, 0.7);
    color: white;
    border-color: rgba(220, 53, 69, 0.5);
}

.hand-value.twenty-one {
    background: rgba(40, 167, 69, 0.7);
    color: white;
    border-color: rgba(40, 167, 69, 0.5);
    animation: winningGlow 1.5s infinite;
}

.hand-value.fourteen {
    background: rgba(255, 193, 7, 0.7);
    color: black;
    border-color: rgba(255, 193, 7, 0.5);
    animation: winningGlow 1.5s infinite;
}