:root {
  --nuit: #0d1b2a;
  --nuit-2: #132a3e;
  --sapin: #1f4d3a;
  --rouge: #b3262e;
  --rouge-fonce: #8e1c23;
  --or: #e8b04b;
  --or-clair: #f5d48a;
  --creme: #f8f1e4;
  --papier: #fffaf0;
  --encre: #2a2320;
  --encre-douce: #6b5d55;
  --vert-ok: #2e7d4f;
  --rayon: 18px;
  --titre: 'Fraunces', Georgia, serif;
  --texte: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--texte);
  font-size: 17px;
  line-height: 1.55;
  color: var(--encre);
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 22%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 12%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 83% 26%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 6%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 40%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 74% 44%, #fff6 50%, transparent 51%),
    linear-gradient(180deg, #08131f 0%, var(--nuit) 45%, var(--nuit-2) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#neige { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* En-tête */
.entete {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 18px 6px;
  max-width: 560px; width: 100%; margin: 0 auto;
}
.marque {
  font-family: var(--titre); font-weight: 800; font-size: 18px;
  color: var(--creme); text-decoration: none; letter-spacing: .2px;
}
.marque span { color: var(--or); font-weight: 600; }
.lien-gagnants {
  color: var(--creme); text-decoration: none; font-weight: 700; font-size: 14px;
  padding: 7px 14px; border: 1px solid #ffffff33; border-radius: 99px;
}
.lien-gagnants:active { background: #ffffff14; }

/* Guirlande de progression */
.guirlande { position: relative; z-index: 2; max-width: 560px; width: 100%; margin: 0 auto; padding: 0 6px; }
.guirlande[hidden], .guirlande-aide[hidden] { display: none; }
.guirlande svg { width: 100%; height: auto; display: block; overflow: visible; }
.guirlande .fil { fill: none; stroke: #c9d6c5; stroke-width: 1.2; opacity: .55; }
.guirlande .boule { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.guirlande .zone { fill: transparent; }
.guirlande .bille { transition: fill .4s, stroke .3s; transform-box: fill-box; transform-origin: 50% 0; }
.guirlande .boule.vide .bille { fill: #ffffff14; stroke: #ffffff66; stroke-width: 1.2; }
.guirlande .boule.faite .bille { fill: var(--or); stroke: #ffffff55; stroke-width: 1; }
.guirlande .boule.faite.r .bille { fill: var(--rouge); }
.guirlande .boule.faite.v .bille { fill: #3f8c63; }
.guirlande .boule.actuelle .bille { stroke: var(--or-clair); stroke-width: 2.5; }
.guirlande .boule.actuelle { animation: balance 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.guirlande .boule:hover .bille, .guirlande .boule:focus-visible .bille { stroke: var(--or-clair); stroke-width: 2; }
.guirlande .num { font: 800 12px var(--texte); text-anchor: middle; dominant-baseline: central; fill: #ffffffcc; pointer-events: none; }
.guirlande .boule.faite .num { fill: #fff; }
.guirlande-aide { position: relative; z-index: 2; max-width: 560px; margin: 2px auto 0; padding: 0 16px; text-align: center; font-size: 13px; font-weight: 700; color: #dfe8f0cc; }
.guirlande .attache { fill: #c9d6c5; opacity: .8; }
@keyframes balance { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* Contenu */
main {
  position: relative; z-index: 1; flex: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 8px 16px 24px;
}
.ecran { animation: apparait .45s ease both; }
@keyframes apparait { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.carte {
  position: relative;
  background: var(--papier);
  border-radius: var(--rayon);
  padding: 26px 22px 24px;
  box-shadow: 0 1px 0 #ffffff inset, 0 18px 40px -12px #000a, 0 2px 6px #0004;
  margin-top: 8px;
}
.carte::before {
  /* liseré rouge et or façon papier cadeau */
  content: ''; position: absolute; inset: 7px; border-radius: 12px; pointer-events: none;
  border: 1.5px dashed #b3262e40;
}

.surtitre {
  margin: 0 0 6px; font-size: 13px; font-weight: 800; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--rouge);
}
h1, h2 { font-family: var(--titre); color: var(--encre); margin: 0 0 14px; line-height: 1.12; }
h1 { font-size: clamp(34px, 10vw, 46px); font-weight: 800; }
h1 em { font-style: normal; color: var(--rouge); }
h2 { font-size: clamp(26px, 7.5vw, 32px); font-weight: 800; }
p { margin: 0 0 14px; }
.intro { font-size: 17.5px; }

.regles { list-style: none; padding: 14px 16px; margin: 0 0 22px; background: var(--creme); border-radius: 12px; font-size: 15px; color: var(--encre-douce); }
.regles li { display: flex; gap: 10px; padding: 4px 0; }
.regles span { color: #7aa6c2; flex: none; }

/* Boutons */
.bouton {
  display: block; width: 100%; text-align: center; text-decoration: none;
  font: 800 18px var(--texte); letter-spacing: .3px;
  color: #fff; background: var(--rouge);
  border: 0; border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 4px 0 var(--rouge-fonce);
  cursor: pointer; transition: transform .08s, box-shadow .08s, background .2s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.bouton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.bouton:disabled { opacity: .6; cursor: default; }
.bouton-discret {
  margin-top: 12px; background: transparent; color: var(--encre-douce);
  box-shadow: none; font-size: 16px; padding: 12px; border: 1.5px solid #2a232022;
}
.bouton-discret:active { transform: none; box-shadow: none; background: #0000000a; }

/* Énigme */
.question { font-size: 18px; margin-bottom: 18px; }
.question p:last-child { margin-bottom: 0; }
.enigme-image { display: block; width: 100%; height: auto; border-radius: 12px; margin: 0 0 16px; }
/* Grille de mots à déplacer */
.grille {
  --cols: 8; --rows: 8;
  position: relative; container-type: inline-size;
  width: 100%; aspect-ratio: var(--cols) / var(--rows);
  margin: 0 0 18px; border-radius: 12px; overflow: hidden;
  background-color: var(--nuit-2);
  background-image:
    linear-gradient(to right, #ffffff26 1px, transparent 1px),
    linear-gradient(to bottom, #ffffff26 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) calc(100% / var(--rows));
  background-position: -1px -1px;
  box-shadow: 0 0 0 1px #ffffff26 inset, 0 8px 20px -10px #000a;
  touch-action: none;
}
.grille[hidden] { display: none; }
.mot {
  position: absolute; display: grid; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
  border-radius: 6px; outline: none;
  transition: box-shadow .15s, background-color .15s;
}
.mot span {
  display: grid; place-items: center; min-width: 0;
  font: 800 calc(100cqw / var(--cols) * .86) / 1 var(--titre);
  color: #fff; text-shadow: 0 2px 4px #0007;
}
.mot span.rouge { color: #ff4a50; }
.mot:hover, .mot:focus-visible { background-color: #ffffff12; box-shadow: 0 0 0 2px #e8b04b88 inset; }
.mot.saisi { cursor: grabbing; background-color: #ffffff1c; box-shadow: 0 0 0 2px var(--or) inset, 0 10px 24px #0008; }
.consigne-grille { margin: -10px 0 18px; font-size: 14px; color: var(--encre-douce); text-align: center; }

/* Jeu de caisses */
.jeu[hidden], .form-reponse[hidden] { display: none; }
.jeu-infos { display: flex; justify-content: space-between; font-size: 14px; font-weight: 800; color: var(--encre-douce); margin-bottom: 8px; }
.plateau {
  position: relative; margin: 0 auto; width: 100%;
  aspect-ratio: var(--cols) / var(--rows);
  container-type: inline-size;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.plateau > div { position: absolute; }
/* Sol de l'atelier : dalles de béton */
.tuile.sol { background: #a3a7a6; box-shadow: 0 0 0 .5px #00000026 inset, 0 0 0 1.5px #ffffff14 inset; }
/* Murs en briques rouges */
.tuile.mur {
  background-color: #b4432e;
  background-image:
    linear-gradient(180deg, #e2d3bd 0 1.5px, transparent 1.5px),
    linear-gradient(180deg, transparent calc(50% - .75px), #e2d3bd calc(50% - .75px) calc(50% + .75px), transparent calc(50% + .75px)),
    linear-gradient(90deg, #e2d3bd 1.5px, transparent 1.5px),
    linear-gradient(90deg, #e2d3bd 1.5px, transparent 1.5px),
    linear-gradient(160deg, #ffffff1a, transparent 60%);
  background-size: 100% 100%, 100% 100%, 50% 50%, 50% 50%, 100% 100%;
  background-position: 0 0, 0 0, 0 0, 25% 100%;
  background-repeat: no-repeat, no-repeat, repeat-x, repeat-x, no-repeat;
}
/* Emplacements de rangement : marquage jaune au sol */
.tuile.cible { z-index: 1; }
.tuile.cible::before {
  content: ''; position: absolute; inset: 14%;
  border: 2.5px dashed #f2c230; border-radius: 4px;
  background: repeating-linear-gradient(135deg, #f2c23033 0 4px, transparent 4px 8px);
}
.caisse, .joueur { z-index: 2; transition: left .13s ease-out, top .13s ease-out; }
/* Caisses en bois */
.caisse::before {
  content: ''; position: absolute; inset: 8%;
  border: calc(100cqw / var(--cols) * .09) solid #7a4f24; border-radius: 3px;
  background:
    linear-gradient(45deg, transparent 43%, #8a5a2b 43% 57%, transparent 57%),
    repeating-linear-gradient(180deg, #c99256 0 31%, #a87140 31% 34%),
    #c99256;
  box-shadow: 0 3px 0 #0000004d;
  transition: box-shadow .3s, border-color .3s;
}
.caisse.rangee::before { border-color: #2e7d4f; box-shadow: 0 3px 0 #0000004d, 0 0 0 2px #f2c230, 0 0 12px 2px #f2c230aa; }
.joueur svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px #0006); }
.joueur.gauche svg { transform: scaleX(-1); }

.jeu-commandes {
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px);
  gap: 8px; justify-content: center; margin: 14px 0 4px;
}
.fleche {
  font-size: 22px; color: #fff; background: var(--sapin); border: 0; border-radius: 14px;
  box-shadow: 0 4px 0 #143326; cursor: pointer; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.fleche:active { transform: translateY(3px); box-shadow: 0 1px 0 #143326; }
.fleche[data-dir="haut"] { grid-column: 2; grid-row: 1; }
.fleche[data-dir="gauche"] { grid-column: 1; grid-row: 2; }
.fleche[data-dir="bas"] { grid-column: 2; grid-row: 2; }
.fleche[data-dir="droite"] { grid-column: 3; grid-row: 2; }
.jeu-actions { display: flex; gap: 10px; }
.jeu-actions .bouton { flex: 1; font-size: 15px; padding: 11px 8px; }

.form-reponse { display: flex; flex-direction: column; gap: 10px; }
input[type="text"] {
  width: 100%; font: 600 18px var(--texte); color: var(--encre);
  padding: 15px 16px; border-radius: 14px;
  border: 2px solid #2a232022; background: #fff;
  outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
input[type="text"]:focus { border-color: var(--or); box-shadow: 0 0 0 4px #e8b04b33; }
.retour { min-height: 1.5em; margin: 12px 0 0; font-weight: 700; text-align: center; }
.retour.non { color: var(--rouge); }
.retour.oui { color: var(--vert-ok); }
.indice { margin: 12px 0 0; padding: 12px 14px; background: #fdf3d6; border-left: 4px solid var(--or); border-radius: 8px; font-size: 16px; }

.secoue { animation: secoue .4s; }
@keyframes secoue { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }

.carte-bravo { text-align: center; }
.etoile-bravo { text-align: center; font-size: 54px; line-height: 1; color: var(--or); margin: 0 0 6px; text-shadow: 0 0 22px #e8b04b88; animation: brille 1.8s ease-in-out infinite; }
@keyframes brille { 50% { transform: scale(1.08) rotate(8deg); } }

/* Formulaire gagnant */
.form-gagnant { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.form-gagnant label { font-weight: 800; font-size: 15px; margin-top: 8px; }
.case { display: flex; gap: 12px; align-items: flex-start; font-weight: 600 !important; font-size: 15px !important; color: var(--encre-douce); margin: 14px 0 10px !important; }
.case input { width: 22px; height: 22px; flex: none; accent-color: var(--rouge); margin: 1px 0 0; }

/* Gagnants */
.resume { color: var(--encre-douce); }
.liste-gagnants { list-style: none; margin: 0 0 8px; padding: 0; counter-reset: rang; }
.liste-gagnants li {
  counter-increment: rang;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px dashed #2a232022;
}
.liste-gagnants li::before {
  content: counter(rang);
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font: 800 14px var(--texte); color: var(--encre-douce); background: var(--creme);
}
.liste-gagnants li:nth-child(1)::before { background: var(--or); color: #fff; }
.liste-gagnants li:nth-child(2)::before { background: #b9c3cc; color: #fff; }
.liste-gagnants li:nth-child(3)::before { background: #c98a5a; color: #fff; }
.liste-gagnants .nom { font-weight: 800; flex: 1; overflow-wrap: anywhere; }
.liste-gagnants .date { font-size: 13px; color: var(--encre-douce); white-space: nowrap; }
.liste-gagnants li.moi { background: #fdf3d6; border-radius: 10px; }
.liste-gagnants li.liste-vide { display: block; border: 0; }
.liste-gagnants li.liste-vide::before { display: none; }
.liste-vide { text-align: center; color: var(--encre-douce); padding: 18px 0; }

/* Pied de page : le village */
.pied { position: relative; z-index: 1; margin-top: auto; line-height: 0; pointer-events: none; }
.village { width: 100%; height: 96px; display: block; }
.village .silhouette { fill: #060e17; }
.village .fenetres { fill: #f5c96a; opacity: .85; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 600px) {
  main { padding-top: 20px; }
  .carte { padding: 34px 34px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Scène avec bulle de bande dessinée */
.scene-bd { position: relative; display: flex; align-items: flex-end; gap: 4px; margin: 4px 0 18px; padding: 14px 10px 0; background: linear-gradient(180deg, #e9f1f6, #f7efe1); border-radius: 14px; overflow: hidden; }
.scene-bd img { width: 40%; max-width: 180px; height: auto; display: block; flex: none; }
.bulle {
  position: relative; align-self: flex-start; flex: 1; margin-left: 14px;
  background: #fff; border: 3px solid var(--encre); border-radius: 50% / 42%;
  padding: 20px 10px; margin-top: 10px; text-align: center;
  white-space: nowrap; font: 800 clamp(15px, 4.4vw, 24px) / 1.2 'Comic Sans MS', 'Comic Neue', var(--texte);
  letter-spacing: .5px; color: var(--encre); word-spacing: 1px;
}
.bulle::before, .bulle::after { content: ''; position: absolute; clip-path: polygon(55% 0, 100% 40%, 0 100%); }
.bulle::before { left: -26px; bottom: 6px; width: 44px; height: 30px; background: var(--encre); }
.bulle::after { left: -18px; bottom: 11px; width: 36px; height: 22px; background: #fff; }

/* ===== Thème pizzeria (énigme 4) ===== */
/* Sol en tomettes */
.theme-pizzeria .tuile.sol {
  background:
    linear-gradient(135deg, #ffffff14, transparent 60%),
    #c7724a;
  box-shadow: 0 0 0 1px #8f4a2c inset, 0 0 0 2.5px #d98b62 inset;
}
/* Murs en carrelage blanc */
.theme-pizzeria .tuile.mur {
  background-color: #f2ede4;
  background-image:
    linear-gradient(90deg, #b9b1a3 1px, transparent 1px),
    linear-gradient(180deg, #b9b1a3 1px, transparent 1px),
    linear-gradient(160deg, #ffffff99, transparent 55%);
  background-size: 50% 50%, 50% 50%, 100% 100%;
  background-position: 0 0, 0 0, 0 0;
  background-repeat: repeat, repeat, no-repeat;
  box-shadow: 0 0 0 1px #9f9686 inset;
}
/* Les fours : dôme en briques avec la bouche rougeoyante */
.theme-pizzeria .tuile.cible::before {
  inset: 6% 6% 4%; border: 0; border-radius: 50% 50% 8% 8% / 62% 62% 8% 8%;
  background:
    radial-gradient(ellipse 34% 30% at 50% 78%, #ffb347 0 35%, #e2572b 60%, #2a1510 62% 100%) no-repeat,
    repeating-linear-gradient(180deg, #a84f33 0 22%, #7c3622 22% 26%);
  background-size: 100% 100%, 100% 100%;
  box-shadow: 0 2px 0 #5e2a1a, 0 0 0 1.5px #5e2a1a inset;
}
.theme-pizzeria .tuile.cible::after {
  /* la cheminée */
  content: ''; position: absolute; left: 62%; top: 0; width: 12%; height: 18%;
  background: #7c3622; border-radius: 2px;
}
/* Les pizzas */
.theme-pizzeria .caisse::before {
  inset: 9%; border: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 36%, #b8322c 0 7%, transparent 8%),
    radial-gradient(circle at 64% 32%, #b8322c 0 7%, transparent 8%),
    radial-gradient(circle at 46% 64%, #b8322c 0 7%, transparent 8%),
    radial-gradient(circle at 70% 62%, #b8322c 0 6%, transparent 7%),
    radial-gradient(ellipse 7% 4% at 52% 44%, #3f8c45 0 90%, transparent 100%),
    radial-gradient(ellipse 6% 4% at 30% 58%, #3f8c45 0 90%, transparent 100%),
    radial-gradient(circle, #f6d27a 0 52%, #e0533a 58% 66%, #e3a65b 70% 100%);
  box-shadow: 0 3px 0 #0000004d, 0 0 0 1.5px #b77a3c inset;
}
.theme-pizzeria .caisse.rangee::before {
  box-shadow: 0 3px 0 #0000004d, 0 0 0 2px #ffb347, 0 0 14px 4px #ff8a3d;
}

/* Pièces de puzzle (énigme 5) : morceaux de papier */
.grille.puzzle .mot {
  background: #fbf3e2;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #c9b48e inset, 0 3px 8px #0006;
}
.grille.puzzle .mot span {
  font-size: calc(100cqw / var(--cols) * .62);
  color: var(--encre); text-shadow: none;
}
.grille.puzzle .mot:hover, .grille.puzzle .mot:focus-visible { background: #fff8ea; box-shadow: 0 0 0 2px var(--or) inset, 0 3px 8px #0006; }
.grille.puzzle .mot.saisi { background: #fff8ea; box-shadow: 0 0 0 2px var(--or) inset, 0 12px 26px #0009; }

/* Équations en images (énigme 6) */
.equations { background: var(--nuit-2); border-radius: 14px; padding: 14px 10px; margin: 4px 0 18px; display: grid; gap: 10px; }
.eq { display: flex; align-items: center; justify-content: center; gap: clamp(2px, 1.2vw, 8px); color: #fff; font: 800 clamp(20px, 6.2vw, 28px) / 1 var(--titre); }
.eq img { width: clamp(34px, 11vw, 48px); height: auto; display: block; }
.eq .res { min-width: 1.6em; text-align: left; }
.eq.question-eq { margin-top: 4px; padding-top: 12px; border-top: 1.5px dashed #ffffff40; }
.eq.question-eq .res { color: var(--or); }

/* Sudoku en dessins (énigme 7) */
.sudoku-legende { font-size: 15px; color: var(--encre-douce); margin-bottom: 10px; text-align: center; }
.sudoku-symboles { display: flex; justify-content: center; gap: 10px; margin-top: 6px; }
.sudoku-symboles img { width: 30px; height: 30px; }
.sudoku {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  width: 100%; max-width: 340px; margin: 0 auto; aspect-ratio: 1;
  background: var(--nuit-2); padding: 6px; border-radius: 14px;
}
.sudoku-case {
  display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px;
  background: #fffaf0; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; transition: background-color .15s, transform .08s;
}
.sudoku-case:active { transform: scale(.94); }
.sudoku-case img { width: 72%; height: 72%; pointer-events: none; }
.sudoku-case.donnee { background: #e6dccb; cursor: default; }
.sudoku-case.donnee:active { transform: none; }
.sudoku-case.conflit { background: #f8d3cf; box-shadow: 0 0 0 2.5px var(--rouge) inset; }
.sudoku-zone .bouton-discret { margin-top: 14px; }
.sudoku { position: relative; }
.sudoku::before, .sudoku::after { content: ''; position: absolute; background: var(--or); border-radius: 2px; pointer-events: none; }
.sudoku::before { left: calc(50% - 1.5px); top: 6px; bottom: 6px; width: 3px; }
.sudoku::after { top: calc(50% - 1.5px); left: 6px; right: 6px; height: 3px; }

/* Mots mêlés (énigme 8) */
.mm-grille {
  --n: 7;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px;
  width: 100%; aspect-ratio: 1; padding: 6px; border-radius: 14px;
  background: var(--nuit-2); container-type: inline-size;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.mm-case {
  display: grid; place-items: center; border-radius: 7px;
  background: #fffaf0; color: var(--encre);
  font: 800 calc(100cqw / var(--n) * .52) / 1 var(--titre);
  cursor: pointer; transition: background-color .15s, color .15s, transform .1s;
}
.mm-case.trouve { background: #9fd3b0; color: #1d4a31; }
.mm-case.select { background: var(--or); color: #fff; transform: scale(1.05); }
.mm-case.secret { background: var(--or); color: #fff; box-shadow: 0 0 12px #e8b04baa; animation: brille 1.8s ease-in-out infinite; }
.mm-aide { font-size: 14px; color: var(--encre-douce); text-align: center; margin: 10px 0 8px; }
.mm-liste { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.mm-liste li { font-weight: 800; font-size: 14px; letter-spacing: .5px; padding: 5px 10px; border-radius: 99px; background: var(--creme); color: var(--encre); }
.mm-liste li.fait { background: #9fd3b0; color: #2e7d4f; text-decoration: line-through; }

/* Jeu de mémoire (énigme 9) */
.memory {
  --colonnes: 4;
  display: grid; grid-template-columns: repeat(var(--colonnes), 1fr); gap: 8px;
  width: 100%; margin: 0 auto 6px;
}
.carte-memory {
  aspect-ratio: 3 / 4; padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 600px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: opacity .35s, transform .35s;
}
.carte-interieur {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, .7, .3, 1);
}
.carte-memory.visible .carte-interieur { transform: rotateY(180deg); }
.carte-dos, .carte-face {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 8px #0000004d;
}
/* Verso : le blason de la commune */
.carte-dos {
  background:
    radial-gradient(circle at 50% 45%, #1d3b57 0 45%, transparent 75%),
    repeating-linear-gradient(45deg, #ffffff0c 0 6px, transparent 6px 12px),
    var(--nuit);
  border: 3px solid var(--or);
}
.carte-dos img {
  width: 74%; height: auto; padding: 12%; box-sizing: border-box;
  background: #fbf3e2; border-radius: 50%; box-shadow: 0 0 0 2px var(--or), 0 3px 6px #0006;
}
/* Recto : le symbole de Noël */
.carte-face { background: #fffaf0; border: 3px solid #e6dccb; transform: rotateY(180deg); }
.carte-face img { width: 72%; height: auto; }
.carte-memory.partie { opacity: 0; transform: scale(.6); pointer-events: none; }
.carte-memory:active .carte-interieur { filter: brightness(.95); }

/* Le facteur du Père Noël (énigme 10) */
.facteur-etapes { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; }
.facteur-etape { background: var(--creme); border-radius: 14px; padding: 12px 12px 14px; border: 2px solid transparent; transition: border-color .3s, background-color .3s; }
.facteur-etape.livree { border-color: #9fd3b0; background: #eef7f0; }
.facteur-indice { margin: 0 0 10px; font-size: 16px; display: flex; gap: 10px; align-items: flex-start; }
.facteur-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--rouge); color: #fff; font: 800 14px var(--texte); margin-top: 1px; }
.facteur-etape.livree .facteur-num { background: var(--vert-ok); }
.facteur-choix { display: grid; gap: 6px; }
.facteur-rue {
  font: 700 15px var(--texte); text-align: left; color: var(--encre);
  padding: 10px 12px; border-radius: 10px; border: 1.5px solid #2a232022; background: #fff;
  cursor: pointer; touch-action: manipulation; transition: background-color .2s, border-color .2s, opacity .2s;
}
.facteur-rue::before { content: '✉  '; color: var(--encre-douce); }
.facteur-rue.bonne { background: var(--vert-ok); border-color: var(--vert-ok); color: #fff; }
.facteur-rue.bonne::before { content: '✔  '; color: #fff; }
.facteur-rue.mauvaise { opacity: .45; text-decoration: line-through; }
.facteur-rue:disabled { cursor: default; }
.facteur-etape.livree .facteur-rue:not(.bonne) { opacity: .35; }
.facteur-mot { text-align: center; margin: 0 0 18px; }
.facteur-mot-titre { display: block; font-size: 14px; font-weight: 800; color: var(--encre-douce); margin-bottom: 8px; }
.facteur-lettres { display: inline-flex; gap: 6px; }
.facteur-lettre {
  width: 42px; height: 50px; display: grid; place-items: center; border-radius: 10px;
  background: var(--nuit-2); color: #ffffff55; font: 800 26px var(--titre);
  transition: background-color .3s, color .3s, transform .3s;
}
.facteur-lettre.trouvee { background: var(--or); color: #fff; transform: translateY(-3px); box-shadow: 0 4px 12px #e8b04b88; }
.facteur-form { display: flex; gap: 8px; }
.facteur-form input[type="text"] { flex: 1; min-width: 0; padding: 12px 12px; font-size: 16px; border-radius: 10px; }
.facteur-livrer {
  flex: none; font: 800 15px var(--texte); color: #fff; background: var(--rouge);
  border: 0; border-radius: 10px; padding: 0 14px; box-shadow: 0 3px 0 var(--rouge-fonce);
  cursor: pointer; touch-action: manipulation;
}
.facteur-livrer:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.facteur-livrer:disabled { background: var(--vert-ok); box-shadow: none; }
.facteur-etape.livree input[type="text"] { background: #eef7f0; border-color: #9fd3b0; color: #24563a; font-weight: 800; }
.facteur-msg { margin: 8px 0 0; font-size: 14px; font-weight: 700; min-height: 0; }
.facteur-msg:empty { display: none; }
.facteur-msg.non { color: var(--rouge); }
.facteur-msg.oui { color: var(--vert-ok); }
