/* ============================================================
    VARIABLES CSS GLOBALES — charte graphique rouge/noir/blanc
============================================================ */
:root {
    --rouge-clair:  #FF6B6B;   /* rouge primaire */
    --rouge:        #E8001C;   /* rouge primaire */
    --rouge-sombre: #77000e;   /* rouge foncé pour hover */
    --noir:         #0A0A0A;   /* fond principal */
    --noir-card:    #141414;   /* fond des cartes */
    --noir-border:  #7c7c7c;   /* bordures subtiles */
    --blanc:        #FFFFFF;   /* texte principal */
    --gris-clair:   #B0B0B0;   /* texte secondaire */
    --vert-valide:  #22C55E;   /* couleur coche / bonne réponse */
    --barre-h:      56px;      /* hauteur de la barre d'infos en bas */
    --radius:       20px;      /* rayon de bordure standard */
    --transition:   0.25s ease;
    --font-size-standard: clamp(20px, 5.55vw, 24px);
    --spacing:      10px;
}

/* ============================================================
    RESET & BASE
============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    /*background-color: var(--noir);*/
    background: linear-gradient(to bottom, var(--noir) 0%, var(--noir) 30%, #3b0000 90%, var(--rouge-sombre) 100%);
    background-attachment: fixed;
    color: var(--blanc);
    font-family: 'DM Sans', sans-serif;
    font-size: var(--font-size-standard);
    line-height: 1.3;
    -webkit-tap-highlight-color: transparent; /* supprime le flash bleu sur mobile */
}

/* Page active : */
.actif {
    display: flex !important;
}

/* Element affiché en flex : */
.display-flex {
    display: flex !important;
}

/* Zone de jeu : padding-bottom de la même hauteur que la barre du bas */
#app {
    padding-bottom: calc(var(--barre-h) + 16px);
    position: relative;
}

/* ============================================================
    LOGO — commun à tous les écrans
============================================================ */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container img {
    margin: 5px 0 0 0;
    max-width: 120px;
    width: 90%;
    height: auto;
    object-fit: contain;
    transition: 0.5s ease;
}

.logo-container img.logo-grand {
    margin: 10px 0 0 0;
    max-width: 190px;
}


/* ============================================================
    ANIMATION D'ENTRÉE GÉNÉRIQUE (fade + slide up)
============================================================ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Classe d'animation appliquée dynamiquement aux écrans */
.animate-in {
    animation: fadeSlideUp 0.45s ease both;
}

/* Décalage en cascade pour les éléments enfants */
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.12s; }
.animate-in:nth-child(3) { animation-delay: 0.20s; }
.animate-in:nth-child(4) { animation-delay: 0.28s; }
.animate-in:nth-child(5) { animation-delay: 0.36s; }


/* ============================================================
    ENCART DES ERREURS
============================================================ */

/* Message d'erreur (paramètre "niveau" absent ou inconnu, ou json invalide) */
#encart-erreur {
    display: none;
    margin: 24px;
    padding: 20px;
    background-color: rgba(232, 0, 28, 0.15);
    border: 1px solid var(--rouge);
    border-radius: var(--radius);
    color: var(--blanc);
    text-align: center;
    font-size: 14px;
    animation: fadeIn 0.4s ease;
}

#encart-erreur strong {
    color: var(--rouge);
    font-size: 16px;
    display: block;
    margin-bottom: 8px;
}

/* largeur maximale des écrans : */
.screen
{
    max-width: 520px;
    margin: 0 auto;
}

/* ============================================================
    ÉCRAN MENU
============================================================ */
#screen-menu {
    display: none; /* affiché via JS */
    flex-direction: column;
    align-items: center;
}

#liste-niveaux {
    display:flex;
    flex-flow: row wrap;
    gap: 20px;
    padding: 0 12px;
    align-items: stretch;
}

section {
    display:flex;
    flex-flow: column nowrap;
    flex-grow: 1;
    gap: 5px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius : 25px;
}

section h2 {
    text-align: center;
    font-weight: normal;
    margin-top: -8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.content-zone {
    display:flex;
    flex-flow: row nowrap;
    gap: 10px;
}

.score-zone {
    flex-grow: 0;
    width: 6.8rem;
    display: flex;
    flex-flow: column nowrap;
}

.score-title {
    font-size: 14px !important;
}

.score-number {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.8rem;
    font-weight: 200;
    color: var(--rouge);
    line-height: 0.9;
    margin-bottom: -14px;
    animation: fadeSlideUp 0.5s 0.2s ease both;
}

.btn-zone {
    width: 6.8rem;
    flex-grow: 1;
    display: flex;
    flex-flow: column nowrap;
    justify-content: flex-end;
    align-items: stretch;
    gap: var(--spacing);
}

.btn-menu {
    font-size: 0.8rem !important;
    padding: 6px 2px !important;
}



/* ============================================================
    ÉCRAN AFFICHES
============================================================ */
#screen-affiches {
    display: none; /* affiché via JS */
    flex-direction: column;
    align-items: center;
}

.btn-retour-menu {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px;
    cursor: pointer;
}

/* Message de bienvenue */
.bienvenue {
    text-align: center;
    padding: 8px 24px 24px;
    animation: fadeSlideUp 0.5s 0.1s ease both;
}

.bienvenue p {
    margin-top: 8px;
    font-weight: 500;
}


/* Grille des affiches — 2 par ligne sur mobile */
#grille-affiches {
    display: flex;
    flex-flow: row wrap;
    gap: 12px;
    padding: 0 12px;
    width: 100%;
    justify-content: center;
    animation: fadeIn 0.5s 0.2s ease both;
}

/* Carte d'affiche individuelle */
.carte-affiche {
    position: relative;
    /* Sur mobile : 2 par ligne avec gap pris en compte */
    width: 160px;
    flex-grow: 1;
    /* Ratio carré */
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--noir-border);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    background-color: var(--noir-card);
}

.carte-affiche-vide {
    position: relative;
    width: 160px;
    flex-grow: 1;
}

/* Effet au survol/tap */
.carte-affiche:hover,
.carte-affiche:active {
    transform: scale(1.03);
    border-color: var(--rouge);
    box-shadow: 0 8px 32px rgba(232, 0, 28, 0.35);
}

/* Image de l'affiche */
.carte-affiche img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s;
}

/* Overlay foncé sur la carte */
.carte-affiche .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    pointer-events: none;
}

/* Coche verte (question terminée) — coin inférieur droit */
.carte-affiche .coche {
    position: absolute;
    bottom: 15px;
    right: 15px;
    scale: 1.5;
    width: 32px;
    height: 32px;
    background-color: var(--vert-valide);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.carte-affiche .coche svg {
    width: 18px;
    height: 18px;
    stroke: var(--blanc);
    stroke-width: 3;
    fill: none;
}

/* Coche visible quand la question est terminée */
.carte-affiche.terminee .coche {
    opacity: 1;
    transform: scale(1);
}

/* ============================================================
    ÉCRAN QUESTION
============================================================ */
#screen-question {
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 0 12px;
}

/* Texte de la question */
.question-texte {
    font-size: 1.2rem;
    letter-spacing: 1px;
    color: var(--blanc);
    text-align: center;
    padding: 10px 0px;
    animation: fadeSlideUp 0.4s 0.1s ease both;
}

/* Conteneur des 4 boutons réponses */
#conteneur-reponses {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeSlideUp 0.45s 0.18s ease both;
}

/* Bouton de réponse individuel */
.btn-reponse, .btn-menu {
    background-color: var(--noir-card);
    color: var(--blanc);
    border: 2px solid var(--noir-border);
    border-radius: 30px;
    padding: 12px 12px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}

/* Effet ripple au clic */
.btn-reponse::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    opacity: 0;
    transition: opacity 0.15s;
}

.btn-reponse:hover:not(:disabled)::after { opacity: 1; }

.btn-reponse:active:not(:disabled) {
    transform: scale(0.97);
}

/* État désactivé */
.btn-reponse:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Bonne réponse mise en évidence */
.btn-reponse.bonne-reponse {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: var(--vert-valide);
    color: var(--vert-valide);
    opacity: 1 !important; /* annule l'opacité disabled */
}

/* Animation pulsante sur la bonne réponse (écran récapitulatif) */
@keyframes pulseVert {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.btn-reponse.bonne-reponse.animer {
    animation: pulseVert 1.2s ease infinite;
}

/* Mauvaise réponse sélectionnée */
.btn-reponse.mauvaise-reponse {
    background-color: rgba(232, 0, 28, 0.15);
    border-color: var(--rouge);
    color: var(--rouge-clair);
}

/* Zone des messages de feedback */
#zone-feedback {
    min-height: 60px;
    margin: 24px 0;
    animation: fadeIn 0.3s ease;
}

.message-feedback {
    font-weight: 600;
    text-align: center;
    animation: fadeSlideUp 0.35s ease both;
}

.message-feedback.gagne {
    color: var(--vert-valide);
}

.message-feedback.essai {
    font-size: 1.2rem;
    color: #FFA500;
}

.message-feedback.perdu {
    color: var(--rouge-clair);
}

/* Bouton de retour aux affiches */
#btn-retour,
a.final-btn-retour
{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: rgba(255,255,255, 0.15);
    color: var(--gris-clair);
    border: 2px solid var(--noir-border);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background-color var(--transition);
    animation: fadeSlideUp 0.5s 0.3s ease both;
    text-decoration: none;
}

#btn-retour:hover,
a.final-btn-retour:hover
{
    color: var(--blanc);
    border-color: var(--blanc);
    background-color: rgba(255,255,255,0.05);
}

/* ============================================================
    ÉCRAN FINAL
============================================================ */
#screen-final {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 0 12px;
    margin-bottom: 10px;
    text-align: center;
}

.final-titre {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 30px 0px;
    animation: fadeSlideUp 0.5s 0.1s ease both;
}

.final-label,
.score-title
{
    font-size: 1rem;
    color: var(--gris-clair);
    margin-top: 4px;
    animation: fadeSlideUp 0.5s 0.3s ease both;
}

.final-score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 5rem;
    font-weight: 200;
    color: var(--rouge);
    line-height: 1;
    animation: fadeSlideUp 0.5s 0.2s ease both;
    margin-bottom : 30px;
}


/* Canvas des confettis (superposé, pointer-events none) */
#canvas-confettis {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* ============================================================
    BARRE D'INFORMATIONS (fixe en bas)
============================================================ */
#barre-infos {
    display: none; /* Barre masquée par défaut, sinon : display:flex; */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--barre-h);
    background-color: rgba(10, 10, 10, 0.70);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid var(--noir-border);
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 100;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding-right: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);       
}

.info-item:last-child {
    align-items: flex-end;
    padding-right: 0;
    border-right: 0;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);  
}

.info-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gris-clair);
    font-weight: 600;
}

.info-valeur {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 30px;
    color: var(--blanc);
    line-height: 1;
    transition: color 0.3s;
}

/* Mise en valeur lors d'une mise à jour du score */
.info-valeur.flash {
    color: var(--rouge);
}