        :root {
            --primary: #fb923c;
            --bg: #f1f5f9;
            --card-width: 520px;
        }

        body {
            margin: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: var(--bg);
            font-family: system-ui, -apple-system, sans-serif;
            overflow: hidden;
        }

        /* ===== CONTENEDOR DE LA PILA ===== */
        .stack {
            position: relative;
            width: var(--card-width); 
            height: 340px;
            perspective: 2500px;
        }

        /* ===== TARJETA BASE ===== */
        .flashcard {
            position: absolute;
            inset: 0;
            transform-style: preserve-3d;
            transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s ease;
            cursor: pointer;
        }

        /* Profundidad visual de la pila */
        .flashcard:nth-child(1) { z-index: 10; transform: translateY(0) scale(1); }
        .flashcard:nth-child(2) { z-index: 5; transform: translateY(12px) scale(0.96); opacity: 0.9; }
        .flashcard:nth-child(3) { z-index: 2; transform: translateY(24px) scale(0.92); opacity: 0.8; }

        .card-face {
            position: absolute;
            inset: 0;
            background: white;
            border-radius: 30px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.1);
            backface-visibility: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px;
            font-size: 1.5rem;
            font-weight: 700;
            text-align: center;
            border: 1px solid rgba(0,0,0,0.05);
        }

        .back {
            transform: rotateY(180deg);
            background: #fffaf5;
            color: #431407;
        }

        .flashcard.flipped { transform: rotateY(180deg); }

        /* ===== ANIMACIÓN "LO SÉ" (Retirar a la derecha) ===== */
        .flashcard.know {
            animation: pullRight 0.6s ease-out forwards;
            pointer-events: none;
        }

        @keyframes pullRight {
            0% { transform: translate(0, 0) rotate(0); opacity: 1; }
            100% { transform: translate(600px, 20px) rotate(15deg); opacity: 0; }
        }

        /* ===== ANIMACIÓN "NO LO SÉ" (Enviar atrás con swap de z-index) ===== */
        .flashcard.to-back {
            /* La animación dura 0.8s para que el swap de z-index sea visiblemente limpio */
            animation: sendBackStep 0.8s cubic-bezier(0.45, 0, 0.55, 1) forwards;
        }

        @keyframes sendBackStep {
            0% {
                transform: translate(0, 0) rotate(0);
                z-index: 20; /* Aseguramos que empiece por encima de todo */
            }
            45% {
                /* Se desplaza hasta que su borde derecho toca el borde izquierdo del mazo */
                transform: translate(calc(var(--card-width) * -1 - 20px), -10px) rotate(-8deg);
                z-index: 20; 
            }
            50% {
                /* JUSTO AQUÍ: Cambio instantáneo de capa antes de empezar a regresar */
                z-index: 1; 
            }
            100% {
                /* Regresa al centro pero ya está por debajo de las demás */
                transform: translate(0, 30px) scale(0.9);
                z-index: 1;
                opacity: 0;
            }
        }

        /* ===== BOTONES ===== */
        .controls { margin-top: 60px; display: flex; gap: 20px; }
        .btn {
            padding: 16px 35px;
            border-radius: 50px;
            border: none;
            font-size: 1.1rem;
            font-weight: 800;
            cursor: pointer;
            transition: all 0.2s ease;
            /* ELIMINA EL RECUADRO AZUL EN MÓVIL */
    -webkit-tap-highlight-color: transparent;
    
    /* OPCIONAL: Evita que el texto se seleccione al dar muchos toques rápidos */
    user-select: none;
        }
        .btn-again { background: white; color: var(--primary); border: 2px solid var(--primary); }
        .btn-know { background: var(--primary); color: white; }
        .btn:active { transform: scale(0.95); }

        @media(max-width: 600px){
            :root { --card-width: 90vw; }
            .stack { width: var(--card-width); height: 260px; }
        }

        /* Posicionamiento del Tema en la parte superior */
.card-topic {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.7;
}

/* El contenido central para que no choque con el tema */
.card-content {
    margin-top: 20px;
    padding: 0 10px;
}

/* El icono de rotación en el centro inferior */
.rotate-icon {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: #ccc;
    opacity: 0.6;
    transition: transform 0.3s ease;
}

.flashcard:hover .rotate-icon {
    transform: translateX(-50%) rotate(180deg);
    color: var(--primary);
}

/* Asegurar que el contenido de la cara use Flex vertical */
.card-face {
    flex-direction: column;
    justify-content: center; /* Mantiene la pregunta/respuesta al centro */
}

/* ===== Top Buttons (FIXED & PROFESSIONAL) ===== */
.top-buttons {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: space-between; /* Extremos */
    padding: 10px 15px;
    box-sizing: border-box;
    z-index: 99999; /* Por encima de la barra de progreso */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.top-buttons a {
    background-color: var(--primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px; /* Espacio entre icono y texto */
    border: 1px solid #e2e8f0;
            /* ELIMINA EL RECUADRO AZUL EN MÓVIL */
    -webkit-tap-highlight-color: transparent;
    
    /* OPCIONAL: Evita que el texto se seleccione al dar muchos toques rápidos */
    user-select: none;
}

.top-buttons a:hover {
    background-color: #e5670c;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(249, 115, 22, 0.3);
}

.cabeza{
    margin: 30px;
    color: #e5670c;
    font-size: 2rem;
}

/* =========================
   END SCREEN (FINAL STATE)
========================= */

.flashcard-end {
    text-align: center;
    /* Escritorio: Ancho mayor para dar espacio al anuncio */
    width: 100%;
    max-width: 800px; 
    
    padding: 40px;
    background: white;
    border-radius: 32px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
    animation: fadeUp 0.6s ease forwards;
    box-sizing: border-box; /* Crucial para que el padding no rompa el ancho */
}
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Contenedor del anuncio: Se adapta al ancho del padre */
.ad-slot {
    margin-bottom: 30px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.ad-box {
    width: 100%; /* Toma todo el ancho disponible del .flashcard-end */
    max-width: 728px; /* Ancho estándar de anuncios tipo Leaderboard */
    height: 150px; /* Un poco más alto para escritorio */
    background: #f1f5f9;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-weight: 700;
    border: 2px dashed #cbd5e1; /* Visualmente mejor para un placeholder de ad */
}

/* End text */
.flashcard-end h2 {
    font-size: 1.7rem;
    margin-bottom: 10px;
}

.flashcard-end p {
    font-size: 1.05rem;
    color: #555;
    margin-bottom: 26px;
}

/* Buttons */
.end-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.btn-reset {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-home {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-reset,
.btn-home {
    padding: 14px 34px;
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
            /* ELIMINA EL RECUADRO AZUL EN MÓVIL */
    -webkit-tap-highlight-color: transparent;
    
    /* OPCIONAL: Evita que el texto se seleccione al dar muchos toques rápidos */
    user-select: none;
}

.btn-reset:hover {
    background: var(--primary);
    color: white;
}

.btn-home:hover {
    background: #e67600;
}



/* Responsividad para móviles */
@media (max-width: 600px) {
    .flashcard-end {
        width: 95vw; /* Casi el total de la pantalla */
        padding: 24px 15px;
        border-radius: 24px;
    }

    .ad-box {
        height: 100px; /* Más bajo en móvil para no empujar el contenido */
        font-size: 0.9rem;
    }
    .cabeza{
        margin: 22px ;
        color: #e5670c;
        font-size: 18px;
    }

}

/* =========================
   FLASHCARD PROGRESS
========================= */

.flashcard-progress {
    width: 100%;
    max-width: 520px;
    margin-bottom: 18px;
    padding: 0 6px;
    box-sizing: border-box;
}

/* Texto: 3 / 20   15% */
.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 6px;
}

/* Fondo de la barra */
.progress-track {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

/* Barra activa */
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        #fb923c,
        #f97316
    );
    border-radius: 999px;
    transition: width 0.4s ease;
}
