.perspective-1000 {
    perspective: 1000px;
}

.card {
    width: 90px;
    height: 130px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: default;
}

/* Responsive cards */
@media (max-width: 640px) {
    .card {
        width: 70px;
        height: 100px;
    }
}

/* IMPORTANTE: La lógica del giro */
/* Estado normal: Vemos la cara frontal. */
/* Estado .flipped: Rotamos 180 grados y vemos el dorso. */
.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* Oculta la cara de atrás cuando se gira */
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.card-front {
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    z-index: 2;
    border: 2px solid white;
    /* La cara frontal está en 0deg */
    transform: rotateY(0deg); 
}

.card-back {
    background: linear-gradient(45deg, #b91c1c 25%, #991b1b 25%, #991b1b 50%, #b91c1c 50%, #b91c1c 75%, #991b1b 75%, #991b1b 100%);
    background-size: 20px 20px;
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    /* La cara trasera está girada 180deg por defecto para estar "detrás" */
    transform: rotateY(180deg);
}

/* Efectos visuales de estado */
.active-player {
    box-shadow: 0 0 25px rgba(251, 191, 36, 0.3);
    border-color: rgba(251, 191, 36, 0.6) !important;
    background: rgba(255,255,255,0.15) !important;
    transform: scale(1.02);
}

.active-player::after {
    content: '🎲 TU TURNO';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #fbbf24;
    color: #000;
    padding: 2px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    box-shadow: 0 0 10px #fbbf24;
    z-index: 20;
    white-space: nowrap;
}

.winner-pulse {
    animation: winnerGlow 2s infinite;
    border-color: #fbbf24 !important;
}

@keyframes winnerGlow {
    0% { box-shadow: 0 0 10px #fbbf24; }
    50% { box-shadow: 0 0 30px #fbbf24, 0 0 50px rgba(251, 191, 36, 0.5); }
    100% { box-shadow: 0 0 10px #fbbf24; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px) rotateY(180deg); } /* Entran giradas */
    to { opacity: 1; transform: translateY(0); } /* El JS decide si añade .flipped o no después */
}

/* Utilidad para el botón de "Nueva Partida" */
@keyframes bounce-slight {
    0%, 100% { transform: translateY(-2%); }
    50% { transform: translateY(2%); }
}

.animate-bounce-slight {
    animation: bounce-slight 2s infinite;
}