/* NeoGenesis : « La Mémoire du village » (memoire.html), la zone du jeu.
   Tout est placé sous .mm-jeu : rien ici ne touche :root, html, body ni un élément du site.
   Couleurs : SEULEMENT les jetons du site (css/style.css), donc juste dans les quatre thèmes (sombre, cyber, clair, forêt).
   Deux exceptions nommées, reprises du site (B829/B830) : la pastille sombre #0b1222 sous une icône néon en thème clair
   (le néon se délave sur blanc), et la teinte hue-rotate des icônes en cyber et en forêt. Une troisième, de contraste :
   le ✓ d'une paire trouvée en thème clair (#065f46), comme les corrections du thème clair de css/style.css.
   Néon rationné : une lueur au survol ou au focus seulement ; rien ne brille au repos. Aucun rouge : une paire ratée
   n'est pas une faute. Le mouvement (retournement) disparaît avec prefers-reduced-motion et le mode calme (data-calm). */

.mm-jeu { margin: 0 0 1.4rem; }
.mm-charge { padding: 2rem 0; color: var(--muted); }

/* ---------- boutons ---------- */
.mm-jeu .mm-btn, .mm-jeu .mm-btn2 {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.2rem; border-radius: 999px;
  font: inherit; font-weight: 800; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.mm-jeu .mm-btn { background: var(--cyan); color: var(--on-accent); border: 1px solid transparent; }
.mm-jeu .mm-btn:hover { filter: brightness(1.08); box-shadow: 0 0 14px rgba(var(--cyan-rgb), .35); }
.mm-jeu .mm-btn2 { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 700; }
.mm-jeu .mm-btn2:hover { border-color: var(--cyan); }
.mm-jeu :focus-visible { outline: 3px solid var(--cyan) !important; outline-offset: 3px !important; }

/* ---------- choisir une partie ---------- */
.mm-vue { display: grid; gap: 1rem; }
.mm-reprise, .mm-form {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem 1.1rem;
}
.mm-reprise { display: grid; gap: .55rem; justify-items: start; border-left: 4px solid var(--cyan); }
.mm-jeu h3 { font-size: 1.1rem; font-weight: 800; margin: 0; line-height: 1.3; }
.mm-reprise-t { margin: 0; color: var(--text); line-height: 1.5; }
.mm-form { display: grid; gap: 1rem; }
.mm-champ { border: 0; margin: 0; padding: 0; min-width: 0; }
.mm-champ legend { font-weight: 700; padding: 0; margin: 0 0 .5rem; color: var(--text); }
.mm-choix-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); gap: .5rem; }
.mm-choix-mode { grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.mm-choix {
  display: flex; align-items: flex-start; gap: .6rem; min-height: 44px; box-sizing: border-box;
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); cursor: pointer;
}
.mm-choix:hover { border-color: var(--cyan); }
.mm-choix:has(input:checked) { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
.mm-choix input { flex: none; width: 1.15rem; height: 1.15rem; margin: .15rem 0 0; accent-color: var(--cyan); }
.mm-choix-t { display: grid; gap: .1rem; min-width: 0; }
.mm-choix-t b { font-weight: 700; color: var(--text); }
.mm-choix-t small { font-size: .84rem; color: var(--muted); line-height: 1.4; }
.mm-form-b { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- la partie ---------- */
.mm-barre { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.mm-info { margin: 0; font-weight: 700; color: var(--text); }
.mm-tour {
  margin: 0; display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; box-sizing: border-box;
  padding: .3rem .85rem; border-radius: 999px; background: var(--panel); border: 2px solid var(--violet); color: var(--text); font-weight: 700;
}
.mm-tour[data-main="1"] { border-color: var(--amber-text); }
.mm-outils { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
.mm-consigne { margin: 0; font-size: .86rem; color: var(--muted); line-height: 1.5; }
.mm-etat { margin: 0; min-height: 1.5em; color: var(--text); line-height: 1.5; text-align: center; }
.mm-panne { margin: 0; font-size: .88rem; color: var(--err-text); line-height: 1.5; }

/* La fin : une phrase douce, sans nombre. Pas de --hearth : il est réservé aux moments humains, pas à un état de jeu. */
.mm-fin {
  display: grid; justify-items: center; gap: .6rem; text-align: center;
  background: var(--grad-soft); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem 1rem 1.2rem;
}
.mm-fin-ico { font-size: 1.6rem; line-height: 1; }
.mm-fin-t { margin: 0; font-size: 1.05rem; line-height: 1.55; color: var(--text); max-width: 40rem; }
.mm-fin-b { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }

/* ---------- le plateau ---------- */
/* Jamais de débordement horizontal : la grille prend la largeur disponible (minmax(0,1fr)), le moteur choisit le nombre
   de colonnes (memoire-moteur.js, colonnes()) pour que chaque carte garde au moins 60 px. */
.mm-plateau-boite { width: 100%; min-width: 0; }
.mm-plateau {
  --mm-cols: 4; --mm-ecart: 8px;
  display: grid; grid-template-columns: repeat(var(--mm-cols), minmax(0, 1fr)); gap: var(--mm-ecart);
  margin: 0 auto; width: 100%;
}
.mm-carte {
  position: relative; display: block; width: 100%; min-width: 44px; min-height: 44px; aspect-ratio: 10 / 11;
  margin: 0; padding: 0; border: 0; border-radius: 12px; background: none; color: inherit; font: inherit;
  cursor: pointer; perspective: 700px; -webkit-tap-highlight-color: transparent;
}
.mm-int {
  position: absolute; inset: 0; display: block; border-radius: 12px;
  transform-style: preserve-3d; transition: transform .38s ease;
}
.mm-carte.mm-ouverte .mm-int { transform: rotateY(180deg); }
.mm-dos, .mm-face {
  position: absolute; inset: 0; box-sizing: border-box; border-radius: 12px;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}

/* Le dos : un losange discret sur un dégradé doux. La bordure en --dim fait au moins 4,8:1 sur le fond de chaque thème
   (la carte se distingue de la page, WCAG 1.4.11). */
.mm-dos {
  display: flex; align-items: center; justify-content: center;
  background-color: var(--bg-3); background-image: var(--grad-soft);
  border: 2px solid var(--dim);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mm-dos::before {
  content: ""; width: 30%; aspect-ratio: 1; border: 2px solid rgba(var(--cyan-rgb), .5); border-radius: 5px; transform: rotate(45deg);
}
.mm-dos::after {
  content: ""; position: absolute; width: 9%; aspect-ratio: 1; border-radius: 50%; background: rgba(var(--cyan-rgb), .55);
}
.mm-carte:hover:not(.mm-ouverte) .mm-dos,
.mm-carte:focus-visible:not(.mm-ouverte) .mm-dos { border-color: var(--cyan); box-shadow: 0 0 14px rgba(var(--cyan-rgb), .45); }

/* La face : l'icône néon du site et son nom, toujours lisible. */
.mm-face {
  transform: rotateY(180deg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%;
  padding: 9% 5% 8%; overflow: hidden;
  background: var(--bg-2); border: 2px solid var(--cyan);
}
.mm-ico { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.mm-ico img { display: block; height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; object-fit: contain; }
/* Un nom tient sur une ligne à 320 px et avec la loupe du site (mesuré). S'il doit malgré tout se couper : d'abord à une
   syllabe, avec un trait d'union (hyphens, selon la langue de <html>), et seulement en dernier recours n'importe où
   (overflow-wrap), pour que rien ne soit jamais rogné. */
.mm-nom {
  flex: none; max-width: 100%; font-size: .8rem; font-weight: 700; line-height: 1.15; color: var(--text);
  text-align: center; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto;
}
.mm-plateau.mm-petit .mm-nom { font-size: .72rem; }
/* Cartes sous 56 px : n'arrive qu'avec la loupe du site sur un écran de 320 px (zoom 1,6 : cartes de 51 px CSS, 81 px
   réels). Le nom reste plus grand à l'écran que sans loupe (.62rem × 1,6 ≈ 16 px), et il tient sur une ligne : sur deux
   lignes, il prenait la place de l'icône (15 px CSS au lieu de 28). */
.mm-plateau.mm-mini .mm-nom { font-size: .62rem; }

/* Deux cartes qui ne vont pas ensemble : un filet pointillé, rien d'alarmant ; elles se retournent au prochain geste. */
.mm-carte.mm-attente .mm-face { border-style: dashed; border-color: var(--muted); }
/* Une paire trouvée reste visible, calme, avec un ✓ (pas seulement une couleur), en haut à GAUCHE : les icônes du site
   portent déjà leur petite étincelle en haut à droite. */
.mm-carte.mm-trouvee { cursor: default; }
.mm-carte.mm-trouvee .mm-face { border-color: var(--line); background-image: linear-gradient(var(--panel-2), var(--panel-2)); }
.mm-carte.mm-trouvee .mm-face::after {
  content: "✓"; position: absolute; top: 4px; left: 6px; font-size: .78rem; font-weight: 800; line-height: 1; color: var(--ok-text);
}
.mm-carte.mm-trouvee:hover .mm-face { border-color: var(--dim); }
/* Thème clair : --ok-text (#047857) ne fait que 4,19:1 sur le fond d'une paire trouvée (--bg-2 voilé de --panel-2), sous
   4,5:1 pour un ✓ de 12,5 px. Un vert plus profond, comme les autres corrections du thème clair du site (#0b5d75) : 5,87:1.
   Dans une carte étroite (320 px, ou avec la loupe), la branche droite du ✓ passe sur le coin de la pastille sombre de
   l'icône (#0b1222) : un halo du fond de la carte l'en détache. Sombre, cyber et forêt restent sur --ok-text
   (8,8 / 8,85 / 7,28), sans pastille sous l'icône. */
:root[data-theme="light"] .mm-carte.mm-trouvee .mm-face::after {
  color: #065f46; text-shadow: 0 0 1px var(--bg-2), 0 0 2px var(--bg-2), 0 0 3px var(--bg-2);
}

/* Les icônes néon dans les thèmes du site (mêmes règles que l'accueil, accueil.html:51-53, et authnav.js:624-625). */
:root[data-theme="light"] .mm-jeu .mm-ico img { background: #0b1222; border-radius: 8px; padding: 2px; box-sizing: border-box; }
:root[data-theme="cyber"] .mm-jeu .mm-ico img { filter: hue-rotate(140deg); }
:root[data-theme="forest"] .mm-jeu .mm-ico img { filter: hue-rotate(-100deg); }

/* ---------- calme : aucun mouvement ---------- */
@media (prefers-reduced-motion: reduce) {
  .mm-jeu *, .mm-jeu *::before, .mm-jeu *::after { animation: none !important; transition: none !important; }
}
:root[data-calm="1"] .mm-jeu *, :root[data-calm="1"] .mm-jeu *::before, :root[data-calm="1"] .mm-jeu *::after {
  animation: none !important; transition: none !important;
}

/* ---------- couleurs forcées (contraste élevé de Windows) ---------- */
@media (forced-colors: active) {
  .mm-dos, .mm-face { border-color: ButtonText; }
  .mm-carte.mm-ouverte .mm-face { border-color: Highlight; }
  .mm-carte.mm-trouvee .mm-face { border-color: GrayText; }
  .mm-dos::before { border-color: ButtonText; }
  .mm-dos::after { background: ButtonText; }
}

/* ---------- téléphone ---------- */
@media (max-width: 560px) {
  .mm-outils { margin-left: 0; width: 100%; }
  .mm-outils .mm-btn2 { flex: 1 1 auto; }
  .mm-reprise, .mm-form { padding: .9rem .85rem 1rem; }
}
