main {
    max-width: 800px;
    margin: 0px auto 2rem;
    padding: 0 1.5rem;
    text-align: center;
}

h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.card-container {
    perspective: 1000px;
    width: 100%;
    max-width: 400px;
    min-height: 220px; /* min au lieu de height fixe */
    margin: 2.5rem auto 1rem;
}

.card {
    width: 100%;
    min-height: 220px; /* hauteur minimale */
    height: auto; /* s'adapte au contenu */
    background: var(--card-bg, #1e1e1e);
    color: var(--text);
    border-radius: 16px;
    padding: 1.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: stretch; /* 🧩 au lieu de center pour éviter le scroll coupé */
    justify-content: center;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card .front,
.card .back {
    position: absolute;
    backface-visibility: hidden;
    width: 100%;
    height: 100%;
    display: flex; /* 🧩 permet de garder le centrage adaptatif */
    flex-direction: column;
    justify-content: flex-start; /* 🧩 texte en haut quand ça scroll */
    align-items: center; /* 🧩 centré horizontalement */
    padding: 1rem;
    overflow-y: auto; /* scroll si texte trop long */
    overflow-x: hidden;
    font-size: clamp(1rem, 1.5rem, 1.5rem);
    line-height: 1.4;
    word-wrap: break-word;
    hyphens: auto;
    text-align: center;
}

.card .back {
    transform: rotateY(180deg);
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    margin: 1rem auto 2rem;
}

.progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.audio-button {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 2rem auto 0;
    display: flex;
    justify-content: center;
}

.close-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    display: inline-block;
    color: var(--text-dark);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(139, 95, 191, 0.2);
    transition: all 0.3s ease;
    z-index: 100;
    text-decoration: none;
}

.close-icon:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
    text-decoration: none;
}

.close-icon svg {
    display: block;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.buttons .row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 0.6rem 1.4rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background: var(--primary-hover);
}

button.back {
    background: var(--gray);
}

@media (max-width: 600px) {
    .card-container {
        max-width: 280px;
        min-height: 180px;
    }

    .card {
        min-height: 180px;
        font-size: 1.1rem;
        padding: 1rem;
    }

    .card .front,
    .card .back {
        font-size: clamp(0.9rem, 1.1rem, 1.1rem);
    }

    .fab {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
    
    .close-icon {
        top: 15px;
        right: 15px;
        padding: 6px;
    }
}
