/* =========================================================
   JEUX — Classe commune pour tous les aperçus
   ========================================================= */
.jeu-preview,
.memory-preview,
.dominos-preview,
.motsmelanges-preview,
.motscroises-preview,
.definitions-preview,
.familles-preview,
.kim-preview {
    border: 1px solid #eee;
    border-radius: 0.4rem;
    padding: 0.5rem;
    background: #fff;
}

/* =========================================================
   IMPRESSION — Styles communs pour tous les jeux
   ========================================================= */
@media print {
    /* Reset des previews pour l'impression */
    .jeu-preview,
    .memory-preview,
    .dominos-preview,
    .motsmelanges-preview,
    .motscroises-preview,
    .definitions-preview,
    .familles-preview,
    .kim-preview {
        border: none;
        border-radius: 0;
        padding: 0;
        background: #fff;
    }

    /* Infos de preview masquées à l'impression */
    .memory-preview-info,
    .jeu-preview-info {
        display: none;
    }

    /* Pages de jeux */
    .memory-cards-page,
    .dominos-cards-page,
    .motsmelanges-page,
    .motscroises-page,
    .def-card-page,
    .familles-page,
    .kim-card-page {
        page-break-after: always;
    }
}

/* === Panneau de config === */
.domino-card-preview span,
.memory-card-preview span {
    display: block;
}

.memory-config {
    margin-top: 0.5rem;
    border-top: 1px solid #eee;
    padding-top: 0.5rem;
}

.memory-words-list {
    max-height: 360px;
    overflow-y: auto;
    margin-top: 0.5rem;
    border: 1px solid #eee;
    border-radius: 0.4rem;
    padding: 0.4rem;
    background: #fafafa;
}

.memory-words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.25rem 0.75rem;
}

.memory-word-item {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    font-size: 0.9rem;
}

/* === Aperçu général Memory === */
/* .memory-preview est défini au début du fichier */

/* Une page d'étiquettes (12 cartes max) */
.memory-cards-page {
    margin-bottom: 1rem;
}

/* Grille : 3 colonnes × 4 lignes = 12 cartes */
.memory-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);  /* 3 colonnes à l'écran */
    grid-auto-rows: auto;
    gap: 0;                                  /* étiquettes collées */
    margin: 0 auto;
    padding: 0;
}

/* Carte Memory */
/* === Écran === */
.memory-card-preview {
    box-sizing: border-box;
    border: 1px solid #000;
    margin: 0;
    padding: 0.3cm 0.2cm;

    width: 100%;
    aspect-ratio: 3 / 2;

    font-family: Arial, sans-serif;
    font-size: 14px;   /* écran uniquement */
    font-weight: 600;
    text-align: center;

    display: flex;
    align-items: center;
    justify-content: center;

    page-break-inside: avoid;
}

/* Sections de choix de mots dans les jeux */
.memory-words-section {
    padding: 0.4rem;
    border: 1px solid #eee;
    border-radius: 0.4rem;
    background: #fafafa;
}



.memory-words-section-others {
    margin-top: 0.5rem;
    background: #f5f8ff;
}

.memory-words-section-title {
    margin: 0 0 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.memory-words-section-separator {
    height: 0.5rem;
}

.memory-other-corpus-block {
    border: 1px solid #dde3ff;
    border-radius: 0.4rem;
    margin-top: 0.4rem;
    background: #fff;
}

.memory-other-corpus-header {
    width: 100%;
    text-align: left;
    padding: 0.35rem 0.5rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.memory-other-corpus-header:hover {
    background: #eef2ff;
}

.memory-other-corpus-body {
    padding: 0.35rem 0.5rem 0.5rem;
}

/* === Impression directe navigateur : 12 cartes par page (3 x 4) === */
@media print {

    @page {
        size: A4 landscape;
        margin: 1cm;
    }

    body {
        margin: 0;
        padding: 0;
    }

    /* .memory-preview et .memory-preview-info sont gérés au début du fichier */

    .memory-cards-grid {
        display: grid;
        /* 3 colonnes ~8.5 cm chacune (3 × 8.5 = 25.5 < 27.7 cm utiles) */
        grid-template-columns: repeat(3, 8.5cm);
        grid-auto-rows: 4.5cm;  /* 4 lignes → 4 × 4.5 = 18 cm < 19 cm utiles */
        gap: 0;
        margin: 0;
        padding: 0;
    }

    .memory-card-preview {
        /* on neutralise l’aspect-ratio de l’écran */
        aspect-ratio: auto;

        width: 8.5cm;
        height: 4.5cm;

        padding: 0.3cm 0.2cm;

        font-family: Arial, sans-serif;
        font-size: 14pt;        /* police plus grande pour l’impression */
        font-weight: 600;

        display: flex;
        align-items: center;
        justify-content: center;

        page-break-inside: avoid;
    }
}

.memory-category-block {
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.memory-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.memory-category-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.memory-category-actions .btn.tiny {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
}

/* ========================= */
/*         DOMINOS           */
/* ========================= */

/* .dominos-preview est défini au début du fichier */

.dominos-cards-page {
    margin-bottom: 1rem;
}

.dominos-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 colonnes à l'écran */
    grid-auto-rows: auto;
    gap: 0;
    margin: 0 auto;
    padding: 0;
}

.domino-card-preview {
    box-sizing: border-box;
    border: 1px solid #000;
    margin: 0;
    padding: 0;
    width: 100%;
    aspect-ratio: 3.5 / 1.5; /* forme domino à l'écran */

    display: flex;
    page-break-inside: avoid;

    font-family: Arial, sans-serif;
    font-size: 12px;   /* un peu plus petit */
    font-weight: 600;
}

.domino-half {
    flex: 1;
    display: flex;
    flex-direction: column;    /* une ligne au-dessus, une en-dessous */
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
    padding: 0.15cm 0.2cm;     /* un peu de place mais pas trop */
    line-height: 1.1;
    /* surtout PAS de overflow:hidden ici → on laisse respirer */
}



.domino-left {
    border-right: 1px solid #000;
}

.domino-right {
    border-right: none;
}

.domino-verso-full {
    border-right: none !important;
}

.domino-subline {
    font-size: 0.65em;   /* encore un chouïa plus petit */
    margin-top: 1px;
    line-height: 1.0;
}



@media print {
    .dominos-cards-grid {
        grid-template-columns: repeat(2, 9cm);
        grid-auto-rows: 3.5cm;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    .domino-card-preview {
        width: 9cm;
        height: 3.5cm;
        font-size: 11pt;   /* un peu moins que 12pt */
        display: flex;
        page-break-inside: avoid;
    }

    .domino-half {
        padding: 0.15cm 0.2cm;  /* cohérent avec la version écran */
    }
}


/* ========================= */
/*      MOTS MÉLANGÉS        */
/* ========================= */

/* .motsmelanges-preview est défini au début du fichier */

.motsmelanges-page {
    margin-bottom: 1rem;
    page-break-after: always;
}

.motsmelanges-title {
    text-align: center;
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.motsmelanges-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

/* Grille de lettres */

.motsmelanges-grid {
    display: inline-block;
    border: 1px solid #000;
    padding: 0.2cm;
}

.motsmelanges-row {
    display: flex;
}

.motsmelanges-cell {
    width: 0.9cm;
    height: 0.9cm;
    border: 1px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-family: Arial, sans-serif;  
    font-size: 12pt;
    text-transform: uppercase;
}


/* Mots "entourés" dans la correction */

.motsmelanges-cell-solution {
    border: 2px solid #e60000;
    border-radius: 999px; /* effet pastille autour de la lettre */
}

/* Liste des mots */

.motsmelanges-wordlist {
    min-width: 6cm;
}

.motsmelanges-wordlist h4 {
    margin-top: 0;
    margin-bottom: 0.25rem;
}

.motsmelanges-wordlist-ul {
    list-style: none;
    padding-left: 0;
  margin: 0.2rem 0 0;
}

.motsmelanges-wordlist-ul li {
    margin-bottom: 0.15rem;
     position: relative;
  padding-left: 1.4em;
  margin: 0.2em 0;
}



.motsmelanges-wordlist-ul li::before {
  content: "☐";
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1;
}

/* Impression directe éventuelle */

@media print {
    .motsmelanges-page {
        page-break-after: always;
    }

    .motsmelanges-grid {
        padding: 0.2cm;
    }

    .motsmelanges-cell {
        width: 0.9cm;
        height: 0.9cm;
        font-size: 12pt;
        font-family: Arial, sans-serif;  
    }
}

/* ========================= */
/*        MOTS CROISÉS       */
/* ========================= */

/* .motscroises-preview est défini au début du fichier */

.motscroises-page {
    margin-bottom: 1rem;
    page-break-after: always;
}

.motscroises-title {
    text-align: center;
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

/* Grille pleine largeur (cells plus grandes) */
.motscroises-grid-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.motscroises-grid {
    display: inline-block;
    border: 2px solid #000;
    padding: 0.2cm;
}

.motscroises-row {
    display: flex;
}

.motscroises-cell {
    width: 1.5cm;   /* ← plus large qu'avant */
    height: 1.5cm;
    border: 1px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: Arial, sans-serif;
    font-size: 14pt;
    text-transform: uppercase;
    box-sizing: border-box;
    position: relative;
    background: #fff;
}

/* cases hors grille : transparentes, sans bordure */
.motscroises-cell-empty {
    background: #fff;
    border: none;
}

/* Numéro de la case */
.motscroises-cell .mc-num {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.6em;
    font-weight: 600;
}

.motscroises-cell .mc-letter {
    font-size: 1em;
}

/* Définitions sous la grille, en 2 colonnes */
.motscroises-clues-row {
    display: flex;
    gap: 2rem;
    justify-content: space-between;
    align-items: flex-start;
}

.motscroises-clues-block {
    flex: 1 1 0;
    min-width: 0;
}

.motscroises-clues-block h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
}

.motscroises-clues-block ul {
    list-style: none;      /* ← pas de numérotation 1,2,3 automatique */
    margin: 0;
    padding-left: 0;
    font-size: 0.85rem;
}

.motscroises-clues-block li {
    margin-bottom: 0.2rem;
}

/* Impression : garder ces réglages */
@media print {
    .motscroises-page {
        page-break-after: always;
    }

    .motscroises-cell {
        width: 1.5cm;
        height: 1.5cm;
        font-size: 14pt;
    }
}


.mc-def-block {
    margin-bottom: 0.75rem;
}

.mc-def-row {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
}

.mc-definition {
    flex: 1;
    min-height: 4.5rem;
    resize: vertical;
}

.mc-wiktionary {
    flex: 0 0 auto;
    padding: 0.25rem 0.35rem;
    font-size: 0.9rem;
}

#mc-random-letters {
    width: 3rem;
    padding: 0.1rem 0.2rem;
    font-size: 0.85rem;
}

/* ========================= */
/*   LISTE DES MOTS (JEUX)   */
/* ========================= */

.jeu-wordlist-page {
    margin-bottom: 1rem;
    page-break-after: always;
    padding: 1cm;                 /* marges internes pour le PDF */
    box-sizing: border-box;
    background: #fff;
}

.jeu-wordlist-title {
    text-align: center;
    margin: 0 0 0.5rem 0;
    font-size: 14pt;              /* Arial 14 */
    font-family: Arial, sans-serif;
}

.jeu-wordlist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14pt;              /* Arial 14 partout */
    font-family: Arial, sans-serif;
}

.jeu-wordlist-table th,
.jeu-wordlist-table td {
    border: 1px solid #000;
    padding: 0.15cm 0.25cm;
    text-align: left;
    vertical-align: top;
}

.jeu-wordlist-table th {
    background: #f0f0f0;
    font-weight: 600;
}

.jeu-wordlist-table td:first-child {
    width: 30%;
    font-weight: 600;
}

/* ========================= */
/*        JEU FAMILLES       */
/* ========================= */

/* .familles-preview est défini au début du fichier */

.familles-page {
    margin-bottom: 1rem;
    page-break-after: always;
}

.familles-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 6.5cm); /* 4 colonnes de largeur fixe */
    grid-auto-rows: 9cm;                      /* hauteur fixe */
    gap: 0;
    margin: 0 auto;
    padding: 0;
    justify-content: center;
}

.famille-card {
    box-sizing: border-box;
    margin: 0;
    padding: 0.4cm 0.35cm;
    border-radius: 0.25cm;

    width: 6.5cm;
    height: 9cm;                /* taille FIXE pour html2canvas et l'impression */
    overflow: hidden;           /* évite qu'une carte déforme la grille */

    font-family: Arial, sans-serif;
    font-size: 13px;            /* police plus grande */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    page-break-inside: avoid;
}

/* Version noir et blanc */
.famille-card-bw {
    border: 1px solid #000;
    background: #fff;
}

/* Version couleur – base neutre, couleur par famille via .famille-card-color-X */
.famille-card-color {
    border: 2px solid #555;
    background: #ffffff;
}

/* Avant tu avais:  .famille-card-color-0 .famille-card-header-box { background: ... } */

.famille-card-color-0 .famille-card-header-box { border-color: #ffb866; }
.famille-card-color-1 .famille-card-header-box { border-color: #ff8fb6; }
.famille-card-color-2 .famille-card-header-box { border-color: #6bbcff; }
.famille-card-color-3 .famille-card-header-box { border-color: #6ecb7f; }
.famille-card-color-4 .famille-card-header-box { border-color: #b78cff; }
.famille-card-color-5 .famille-card-header-box { border-color: #ffdf6b; }



.famille-card-header {
    text-align: center;
    margin-bottom: 0.25cm;
}

/* Petit label "Famille" au-dessus du cadre */
.famille-card-header-label {
    font-size: 0.9em;
    display: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    margin-bottom: 2px;
    position: relative;
    z-index: 2;
}

/* Boîte qui encadre corpus + nom de famille */
.famille-card-header-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.15cm 0.3cm;
    border: 2px solid #000;
    border-radius: 0.3cm;
    position: relative;
    z-index: 1;
    background: transparent;  /* important pour ne pas cacher le texte */
}

.famille-card-corpus,
.famille-card-family {
    font-weight: 700;
    font-size: 1.3em;   /* police plus grande */
}

/* Corpus tout en haut, sans parenthèses */
.famille-card-corpus {
    margin-bottom: 2px;
    font-style: normal;
}

.famille-card-family {
    text-transform: uppercase;
}

/* Corps : membre principal encadré */
.famille-card-member {
    text-align: center;
    font-size: 1.4em;
    font-weight: 700;
    margin: 0.25cm 0;
    padding: 0.2cm 0.3cm;

    /* on reset TOUT puis on remet seulement haut/bas */
    border: none !important;
    border-top: 2px solid #000 !important;
    border-bottom: 2px solid #000 !important;

    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Liste des membres en bas, en colonne */
.famille-card-members-list {
    font-size: 0.95em;
    font-style: italic;
    text-align: left;
    line-height: 1.2;
    margin-top: 0.25cm;
}

.famille-card-members-list-item {
    display: block;
}

.famille-card-members-list-item + .famille-card-members-list-item {
    margin-top: 1px;
}

.famille-card-members-list strong {
    font-weight: 700;
}

/* Carte "Règles du jeu" */
.famille-rules-card {
    font-size: 0.9em;       /* un peu plus petit pour que ça tienne */
    line-height: 1.3;
}

.famille-rules-title {
    font-weight: 700;
    font-size: 1.1em;
    text-align: center;
    margin-bottom: 0.25cm;
}

.famille-rules-subtitle {
    font-style: italic;
    text-align: center;
    margin-bottom: 0.25cm;
}

.famille-rules-list {
    padding-left: 0.4cm;
    margin: 0;
}

.famille-rules-list li {
    margin-bottom: 0.08cm;
}

/* Verso : texte centré sur deux lignes, couleur UNIQUE pour tous les versos */
.famille-card-verso {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;

    font-family: Arial, sans-serif;
    font-weight: 700;
    font-size: 13pt;

    width: 6.5cm;
    height: 9cm;
    box-sizing: border-box;
}

.famille-card-verso-inner span {
    display: block;
}

/* Noir et blanc */
.famille-card-verso-bw {
    border: 1px solid #000;
    background: #fff;
}

/* Couleur unique pour tous les versos en mode couleur */
.famille-card-verso-color {
    border: 2px solid #555;
    background: #e4f0ff;   /* une seule couleur, pour toutes les familles */
}

/* =========================
   RÉCAP FAMILLES (sélection)
   ========================= */

.familles-recap {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;           /* passe à la ligne si nécessaire */
}

.familles-recap > * {
  flex: 1 1 220px;           /* largeur mini cohérente avec memory */
  max-width: 320px;
}

/* Carte famille */
.familles-recap .famille-recap-card {
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  background: #fff;
}

/* Titre = nom de la famille */
.familles-recap .famille-recap-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.15;
}

/* Meta : nombre de membres */
.familles-recap .famille-recap-meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.15rem;
}

/* Liste des membres */
.familles-recap .famille-recap-members {
  font-size: 0.8rem;
  margin-top: 0.35rem;
  line-height: 1.25;
  white-space: normal;
}

/* État vide */
.familles-recap .muted {
  font-size: 0.85rem;
}


.familles-recap {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.familles-cat-actions .btn.ghost {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
}

.memory-other-corpus-body .familles-cat-head > .btn.ghost.tiny {
  font-size: 0.68rem;
  padding: 0.05rem 0.2rem;
  background: transparent;
  border: none;
}

.familles-recap .famille-recap-corpus{
  font-size: 0.78rem;
  opacity: 0.75;
  font-weight: 700;
}

.familles-recap .famille-recap-family{
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.15;
}


/* Impression : on garde les mêmes tailles physiques */
@media print {
    .familles-page {
        page-break-after: always;
    }

    .famille-card-family {
    font-size: 0.85em;
  }
    .familles-cards-grid {
        grid-template-columns: repeat(4, 6.5cm);
        grid-auto-rows: 9cm;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    .famille-card,
    .famille-card-verso {
        width: 6.5cm;
        height: 9cm;
        font-size: 12pt;
        page-break-inside: avoid;
    }

    /* --- Familles : mode images --- */
.familles-card-recto {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.familles-recto-title {
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.35rem;
}

.familles-center {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  /* un peu plus haut : on pousse légèrement vers le haut */
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.familles-thumbs {
  flex: 0 0 auto;
  display: grid;
  gap: 0.25rem;

  /* auto-fit => s’adapte au nombre */
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  align-items: stretch;
}

.familles-thumb {
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 6px;
  overflow: hidden;

  /* rend les vignettes “carrées” et homogènes */
  aspect-ratio: 1 / 1;

  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.familles-thumb.is-target {
  border: 3px solid red; /* ✅ bordure épaisse rouge */
}

.familles-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.familles-center-fallback,
.familles-thumb-fallback {
  font-size: 0.7rem;
  text-align: center;
  padding: 0.25rem;
}

}

/* ========================= */
/*   JEU DES DÉFINITIONS     */
/* ========================= */

.definitions-config {
    margin-top: 0.5rem;
}

/* .definitions-preview est défini au début du fichier */

/* Une page = 9 cartes désormais (3×3) */
.def-card-page {
    margin-bottom: 1rem;
    page-break-after: always;
}

/* Grille 3 × 3, cartes carrées 6 × 6 cm */
.def-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 6cm);
    grid-template-rows: repeat(3, 6cm);
    gap: 0;
    margin: 0 auto;
    padding: 0;
}

/* Carte commune (recto ou verso) */
.def-card {
    box-sizing: border-box;
    border: 1px solid #000;
    width: 6cm;
    height: 6cm;
    margin: 0;
    padding: 0.3cm;

    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #000;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;

    position: relative;
}

/* ========================= */
/*          RECTO            */
/* ========================= */

.def-card-title {
    font-weight: 700;
    margin-bottom: 0.2cm;
}

.def-card-text {
    white-space: pre-line;
    word-wrap: break-word;
    font-size: 13px;
}

/* Mode N&B */
.def-card-bw {
    background: #ffffff;
}

.def-card-bw .def-card-title,
.def-card-bw .def-card-text {
    background: transparent;
}

/* Mode COULEUR : toute la carte recto colorée */
.def-card-color-def {
    background: #fff7d6;
}

.def-card-color-def .def-card-title {
    border-bottom: 1px solid #000;
}

/* ========================= */
/*          VERSO            */
/* ========================= */

.def-card-word-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Cadre intérieur (par défaut noir) */
.def-card-word-side::before {
    content: "";
    position: absolute;
    inset: 0.4cm;
    border: 2px solid #000;
    pointer-events: none;
}

/* Mode couleur : cadre intérieur coloré */
.def-card-word-side-color::before {
    border-color: #ffe8b3;
}

/* Nom du corpus en haut à gauche INSIDE le cadre intérieur */
.def-card-corpus-label {
    position: absolute;
    top: 0.6cm;       /* décalé pour entrer dans le cadre intérieur */
    left: 0.6cm;

    font-size: 12px;  /* plus grand maintenant */
    font-weight: 600;
    text-align: left;
}

/* MOT + mot centré, police plus grande */
.def-card-word-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;

    width: 100%;
    height: 100%;

    font-size: 18px;     /* ← police agrandie comme demandé */
    font-weight: 700;
}

.def-card-word-main div:first-child {
    font-size: 15px;     /* le mot "MOT" légèrement plus petit */
    margin-bottom: 0.1cm;
}

/* Impression PDF */
@media print {
    /* .definitions-preview et .def-card-page sont gérés au début du fichier */

    .def-cards-grid {
        grid-template-columns: repeat(3, 6cm);
        grid-template-rows: repeat(3, 6cm);
    }

    .def-card {
        width: 6cm;
        height: 6cm;
        font-size: 12pt;
        page-break-inside: avoid;
    }
}

/* ========================= */
/*        JEU DE KIM         */
/* ========================= */

/* .kim-preview est défini au début du fichier */

/* Une page = 9 cartes (3×3) */
.kim-card-page {
    margin-bottom: 1rem;
    page-break-after: always;
}

/* Grille 3 × 3, cartes 6 × 6 cm */
.kim-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 6cm);
    grid-template-rows: repeat(3, 6cm);
    gap: 0;
    margin: 0 auto;
    padding: 0;
}

/* Carte commune (recto ou verso) */
.kim-card {
    box-sizing: border-box;
    border: 1px solid #000;
    width: 6cm;
    height: 6cm;
    margin: 0;
    padding: 0.3cm;

    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #000;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;

    position: relative;
}

/* === RECTO : MOT === */
/* Cadre intérieur : uniquement haut/bas */
.kim-card-word-frame {
    width: 100%;
    padding: 0.2cm 0.3cm;

    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    /* pas de bordures gauche / droite */

    display: flex;
    justify-content: center;
    align-items: center;
}

.kim-card-word {
    font-size: 18px;
    font-weight: 700;
    word-wrap: break-word;
}

/* === Carte "Règles du jeu" (recto) === */

.kim-card-rules {
    justify-content: flex-start;
    align-items: stretch;
}

.kim-card-rules-title {
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.2cm;
    font-size: 13px;
    text-align: center;
}

.kim-card-rules-subtitle {
    font-style: italic;
    margin-bottom: 0.15cm;
    font-size: 11px;
    text-align: center;
}

.kim-card-text {
    font-size: 11px;
    white-space: pre-line;
    text-align: left;
}

/* === VERSO : "Jeu de Kim / nom du corpus" === */

.kim-card-verso-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    height: 100%;
}

.kim-card-verso-main span {
    display: block;
}

.kim-card-verso-main span:nth-child(1) {
    font-size: 14px;
    font-weight: 700;
}

.kim-card-verso-main span:nth-child(2) {
    margin-top: 0.1cm;
    font-size: 12px;
}

.kim-card-verso-main span:nth-child(3) {
    margin-top: 0.05cm;
    font-size: 12px;
    font-style: italic;
}


/* Impression PDF */
@media print {
    /* .kim-preview et .kim-card-page sont gérés au début du fichier */

    .kim-cards-grid {
        grid-template-columns: repeat(3, 6cm);
        grid-template-rows: repeat(3, 6cm);
    }

    .kim-card {
        width: 6cm;
        height: 6cm;
        font-size: 12pt;
        page-break-inside: avoid;
    }
}



/* ========================= */
/*       JEU DE L'INTRUS     */
/* ========================= */

/* Cartes d'impression / aperçu */
.intrus-card {
    width: 8cm;
    height: 9cm;
    border: 1px solid #000;
    box-sizing: border-box;
    padding: 0.3cm;
    display: flex;
    flex-direction: column;
  justify-content: flex-start;
    align-items: center;
    font-family: Arial, sans-serif;
    text-align: center;
}

.intrus-recto-list {
  flex: 1;
  width: 100%;
  min-height: 0;
}

.intrus-recto-list.is-image-mode {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.2cm;
}

.intrus-recto-list.is-image-mode .intrus-word {
  margin-bottom: 0;      /* ✅ plus de marge texte */
  font-size: 0;          /* ✅ évite hauteur de ligne fantôme */
  font-weight: normal;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grille d'impression : 2 colonnes × 3 lignes max */
.intrus-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);  /* 2 colonnes */
    gap: 0.3cm;
}

/* Grille de preview (panneau création) – on garde la même base, mais responsive */
.intrus-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8cm, 1fr));
    gap: 0.5rem;
    align-items: flex-start;
}

/* Texte interne */
.intrus-recto-title,
.intrus-verso-label {
    font-size: 10pt;
    text-transform: uppercase;
    margin-bottom: 0.2cm;
}

.intrus-recto-list .intrus-word,
.intrus-verso-word {
    font-size: 12pt;
    font-weight: 600;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 0.15cm;   /* léger espacement entre les mots */

}

/* Verso : cadre haut / bas uniquement */
.intrus-verso-frame {
    width: 100%;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 0.3cm 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.intrus-card-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.intrus-card-actions {
    display: flex;
    justify-content: center;
    gap: 0.2rem;
}

.intrus-debug {
    font-size: 8pt;
    opacity: 0.4;
    margin-top: 0.15cm;
}



.memory-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.memory-filters-label {
    font-size: 0.85rem;
    color: #4b5563;
    margin-right: 0.25rem;
}

.memory-presentation {
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 0.75rem;
}

.memory-game-title { margin: 0 0 0.5rem 0; }
.memory-mode-label, .memory-filter-label { font-weight: 600; margin-bottom: 0.25rem; }

.memory-words-card {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.memory-words-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.memory-words-card-header h3 { margin: 0; }

.memory-block {
  background: #fff;
  border: 1px solid #e5e7f0;
  border-radius: 14px;
  padding: 0.9rem;
  margin-top: 0.75rem;
}

.memory-block-title {
  margin: 0;
  font-size: 1.05rem;
}

.memory-inline-radios {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}

.memory-selection-block .memory-selection-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.memory-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.memory-selection-stack {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}


.memory-list-card {
  border: 1px solid #e5e7f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fbfbfe;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.memory-list-card-header {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e5e7f0;
  background: #f6f7ff;
}

.memory-list-card h4 {
  margin: 0;
  font-size: 0.98rem;
}

@media (max-width: 920px) {
  .memory-selection-grid {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   LOTO (html2canvas) — A4 portrait fixe
   ========================================================= */

.loto-page{
  width: 793px;            /* A4 portrait approx */
  height: 1122px;
  box-sizing: border-box;
  padding: 20px;
  background: #fff;
  page-break-after: always;
}

/* =========================================================
   TEXTE / DÉFINITION (communs)
   ========================================================= */

.loto-text{ font-weight: 700; text-align: center; }
.loto-def { font-size: 10pt; line-height: 1.2; }

/* =========================================================
   WRAPPERS INTERNES (communs : cellule + jeton)
   - Doivent occuper 100% et pouvoir rétrécir (min-height:0)
   ========================================================= */

.loto-cell,
.loto-token{
  overflow: hidden;
  box-sizing: border-box;
}

.loto-cardcell,
.loto-token-inner,
.loto-cardcell-inner{
  width: 100%;
  height: 100%;
  min-height: 0;            /* clé anti “contenu qui pousse” */
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Optionnel : petite marge intérieure (utile pour images) */
.loto-cell .loto-cardcell,
.loto-token .loto-token-inner{
  padding: 4px;
}

/* Images : ne déforment pas et ne poussent jamais la case */
.loto-cell img,
.loto-token img{
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* =========================================================
   JETONS — 3 colonnes × 5 lignes (plein page)
   ========================================================= */

.loto-tokens-page{ height: 100%; }

.loto-tokens-grid{
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 10px;                /* ou 0.25cm */
  box-sizing: border-box;
}

.loto-token{
  border: 1px solid #000;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   CARTONS — 3 par page (1/3 page chacun) — grille 3 × 6
   ========================================================= */

.loto-cards-page{ height: 100%; }

.loto-cards-sheet{
  height: 100%;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  box-sizing: border-box;
}

/* IMPORTANT : empêcher le flex-item (grid) de s’agrandir à cause du contenu */
.loto-card{
  border: 1px solid #000;
  border-radius: 12px;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;

  display: flex;
  flex-direction: column;

  min-height: 0;            /* clé */
}

.loto-card-head{
  font-weight: 700;
  font-size: 11pt;
  margin: 0 0 8px 0;
  flex: 0 0 auto;
}

.loto-card-grid{
  flex: 1 1 0;              /* prend l’espace restant sans pousser */
  min-height: 0;            /* clé */
  height: 100%;

  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  box-sizing: border-box;

  align-content: stretch;
}

.loto-cell{
  border: 1px solid #000;
  border-radius: 8px;
  padding: 2px;

  display: flex;
  align-items: center;
  justify-content: center;

  min-height: 0;            /* clé */
  height: 100%;
}

.loto-cell-black{ background: #000; }

/* Champ "Nombre de cartes" : compact */
#loto-cards-count{
  width: 4.5em;        /* largeur suffisante pour 2–3 chiffres */
  padding: 4px 6px;
  font-size: 0.95rem;
  text-align: center;
}
