/* ===== Mémory bilingue : palette du site =====
   Turquoise : 85ECE4 · 55E0D6 · 30D5C9 · 0CC9BB · 00A094
   Bleu      : 91B0EE · 6590E4 · 4275DB · 205BD0 · 0C42AC
   Vert      : 95F68B · 6AF05C · 46EB35 · 22E50E · 14D200
*/
:root {
    --tq1: #85ECE4; --tq2: #55E0D6; --tq3: #30D5C9; --tq4: #0CC9BB; --tq5: #00A094;
    --bl1: #91B0EE; --bl2: #6590E4; --bl3: #4275DB; --bl4: #205BD0; --bl5: #0C42AC;
    --vt1: #95F68B; --vt2: #6AF05C; --vt3: #46EB35; --vt4: #22E50E; --vt5: #14D200;
    --rose: #D6458F;
    --rouge1: #F58A6B; --rouge2: #D9553A; --rouge3: #A83A25;
    /* couleurs utilisées par le pied de page (legal.css) */
    --colorBackLogo: rgb(149, 246, 139);
    --colorTextP: rgb(12, 66, 172);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Roboto", Arial, sans-serif;
}
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;            /* colonne : le pied de page reste en bas de l'écran */
    flex-direction: column;
    background-color: var(--bl1);
}

.jeuMB {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 20px 70px;   /* place en bas pour le lien « Accueil » des petits écrans */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.titreMB {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    font-weight: 900;
    letter-spacing: 2px;
    text-align: center;
    color: var(--bl5);
    text-shadow: 0 2px 0 var(--tq1);
}

/* ----- Carte de réglages ----- */
.carteMB {
    width: 100%;
    max-width: 620px;
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    background-image:
        linear-gradient(160deg, var(--tq1), var(--tq2)),
        linear-gradient(135deg, var(--bl4), var(--vt3));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    border: 4px solid transparent;
    border-radius: 28px;
    box-shadow: 0 10px 30px rgba(12, 66, 172, 0.35);
}
#ecranChoix { margin: 0 auto; }
.consigneMB {
    font-size: 1.2rem;
    color: var(--bl5);
}
.reglageMB {
    width: 100%;
    border: none;
}
.reglageMB legend {
    width: 100%;
    margin-bottom: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--bl5);
}
.puces {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.puceMB {
    position: relative;
    cursor: pointer;
}
.puceMB input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}
.puceMB span {
    display: block;
    padding: 9px 15px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bl5);
    background-color: rgba(255, 255, 255, 0.7);
    border: 3px solid var(--bl3);
    border-radius: 30px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.puceMB span.themeMB { text-transform: capitalize; }   /* « école » devient « École » */
.puceMB small {
    font-size: 0.8em;
    font-weight: 400;
}
.puceMB input:checked + span {
    color: #fff;
    background: linear-gradient(135deg, var(--bl4), var(--bl3));
    border-color: var(--bl5);
}
.puceMB input:focus-visible + span {
    outline: 4px solid var(--vt4);
    outline-offset: 2px;
}
.raccourcis {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 20px;
}
.voixMB {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bl5);
    cursor: pointer;
}
.voixMB input {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 6px;
    accent-color: var(--bl4);
}
.erreurChoix {
    min-height: 1.4em;
    font-weight: 700;
    color: var(--rouge3);
}

/* ----- Boutons ----- */
.boutonMB {
    display: inline-block;
    padding: 12px 34px;
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-align: center;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--bl4), var(--bl3));
    border: none;
    border-radius: 34px;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--bl5);
    transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
}
.boutonMB:hover {
    background: linear-gradient(135deg, var(--vt5), var(--vt3));
    color: var(--bl5);
    box-shadow: 0 5px 0 var(--tq5);
}
.boutonMB:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--tq5);
}
.boutonMB:focus-visible,
.lienMB:focus-visible,
.carte:focus-visible {
    outline: 4px solid var(--vt4);
    outline-offset: 3px;
}
.boutonMB.secondaire {
    background: linear-gradient(135deg, var(--tq5), var(--tq4));
    box-shadow: 0 5px 0 var(--bl5);
}
.lienMB {
    font-size: 1rem;
    font-weight: 700;
    color: var(--bl5);
    background: none;
    border: none;
    text-decoration: underline;
    cursor: pointer;
}

/* ----- Écran de jeu ----- */
#ecranJeu {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.infosMB {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
    padding: 8px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--bl5);
    background-color: rgba(255, 255, 255, 0.55);
    border: 3px solid var(--tq3);
    border-radius: 30px;
}

/* La grille sert de « conteneur » : la taille du texte des cartes se calcule sur sa largeur */
.grilleMB {
    --cols: 4;
    width: 100%;
    container-type: inline-size;
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 10px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.35);
    border: 5px solid var(--bl4);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(12, 66, 172, 0.4);
    transition: box-shadow 0.6s, border-color 0.6s;
}
.grilleMB[data-total="12"] { --cols: 4; }
.grilleMB[data-total="16"] { --cols: 4; }
.grilleMB[data-total="18"] { --cols: 6; }
.grilleMB[data-total="24"] { --cols: 6; }
.grilleMB.complet {
    border-color: var(--vt4);
    box-shadow: 0 0 0 6px rgba(70, 235, 53, 0.45), 0 10px 30px rgba(12, 66, 172, 0.4);
}

/* Une carte = un bouton avec deux faces : le dos (« ? ») et la face (le mot) */
.carte {
    position: relative;
    aspect-ratio: 5 / 4;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 16px;
}
.dos,
.face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-radius: 16px;
}
.dos {
    font-size: clamp(1.6rem, calc(100cqw / var(--cols) * 0.3), 3.2rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 3px rgba(12, 66, 172, 0.6);
    background: linear-gradient(145deg, var(--bl2), var(--bl4));
    transition: filter 0.2s, transform 0.2s;
}
.carte:not(.retournee):hover .dos {
    filter: brightness(1.15);
    transform: scale(1.04);
}
.face {
    display: none;
    padding: 6px;
    text-align: center;
    color: var(--bl5);
}
.carte.retournee .dos { display: none; }
.carte.retournee .face {
    display: flex;
    animation: ouvreMB 0.25s ease-out;
}
.langue-en .face {
    background: #fff;
    border-color: var(--bl3);
}
.langue-fr .face {
    background: var(--tq1);
    border-color: var(--tq5);
}
.etiquette {
    position: absolute;
    top: 5px;
    left: 9px;
    font-size: clamp(0.6rem, calc(100cqw / var(--cols) * 0.075), 0.85rem);
    font-weight: 900;
    letter-spacing: 1px;
    opacity: 0.6;
}
/* Genre du mot français : pastille de couleur en haut à droite (bleu = masculin, rose = féminin) */
.genre {
    position: absolute;
    top: 5px;
    right: 7px;
    padding: 1px 7px;
    font-size: clamp(0.55rem, calc(100cqw / var(--cols) * 0.07), 0.8rem);
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
    border-radius: 10px;
}
.genre-m { background-color: var(--bl4); }
.genre-f { background-color: var(--rose); }
.mot {
    font-size: clamp(0.8rem, calc(100cqw / var(--cols) * 0.15), 1.9rem);
    font-weight: 900;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.carte.trouvee { cursor: default; }
.carte.trouvee .face {
    background: var(--vt1);
    border-color: var(--vt5);
}
.carte.erreur .face {
    background: var(--rouge1);
    border-color: var(--rouge2);
}
@keyframes ouvreMB {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* ----- Message et fin de partie ----- */
.panneauMB {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
#messageMB {
    width: 100%;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    color: var(--bl5);
    background-color: rgba(255, 255, 255, 0.55);
    border: 3px dashed var(--tq5);
    border-radius: 24px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
#messageMB.ok {
    background-color: var(--vt1);
    border: 3px solid var(--vt5);
}
#messageMB.ko {
    color: #fff;
    background-color: var(--rouge2);
    border: 3px solid var(--rouge3);
}
.finMB {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.recapMB {
    width: 100%;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
    padding: 14px;
    font-size: 1.05rem;
    color: var(--bl5);
    background-color: rgba(255, 255, 255, 0.55);
    border: 3px solid var(--tq3);
    border-radius: 20px;
}
.recapEn { font-weight: 900; }
.recapFr { font-weight: 700; color: var(--tq5); }
.boutonsFin {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

/* ----- Téléphone : 3 colonnes, cartes carrées, textes plus lisibles ----- */
@media (max-width: 520px) {
    .jeuMB { padding: 12px 12px 70px; }
    .carteMB { padding: 20px 14px; }
    .grilleMB { gap: 8px; padding: 8px; }
    .grilleMB[data-total] { --cols: 3; }
    .carte { aspect-ratio: 1 / 1; }
    .face { padding: 4px; }
    .mot { font-size: clamp(0.6rem, calc(100cqw / var(--cols) * 0.12), 1.2rem); }
}
@media (prefers-reduced-motion: reduce) {
    .carte.retournee .face { animation: none; }
    .dos, .grilleMB, .boutonMB { transition: none; }
}
