:root {
  --nuit: #0e1a30;
  --nuit-2: #16264a;
  --nuit-3: #1f3360;
  --papier: #f5ecd9;
  --papier-2: #ebdfc4;
  --encre: #2a2118;
  --encre-douce: #6b5c49;
  --rouge: #c0392b;
  --rouge-fonce: #8e2a20;
  --or: #e0ad4a;
  --or-pale: #f3d99a;
  --sapin: #2f6b4f;
  --ok: #2f8a57;
  --ko: #c0392b;
  --rayon: 14px;
  --ombre: 0 6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 70% at 50% -10%, var(--nuit-3) 0%, var(--nuit) 60%) fixed, var(--nuit);
  color: var(--papier);
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
#neige { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 0 16px 96px; }
h1, h2, h3, .serif { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--or); }
button { font: inherit; cursor: pointer; }
.cache { display: none !important; }

/* ---------------------------------------------------------------- en-tête */
.entete { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 8px; gap: 12px; }
.entete h1 { margin: 0; font-size: 1.55rem; line-height: 1.1; }
.entete h1 small { display: block; font-family: "Outfit", sans-serif; font-weight: 400; font-size: .8rem; color: var(--or-pale); opacity: .85; letter-spacing: .04em; text-transform: uppercase; }
.puce-profil { display: flex; align-items: center; gap: 6px; background: var(--nuit-2); border: 1px solid rgba(255,255,255,.12); color: var(--papier); padding: 6px 12px 6px 8px; border-radius: 999px; font-size: .9rem; }
.puce-profil .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; }

/* ---------------------------------------------------------------- écrans d'accueil */
.ecran-centre { min-height: 88vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 18px; }
.ecran-centre h1 { font-size: 2.2rem; margin: 0; }
.ecran-centre p { margin: 0; color: var(--or-pale); }
.chaplin-grand { font-size: 4.5rem; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); animation: flotte 4s ease-in-out infinite; }
@keyframes flotte { 50% { transform: translateY(-8px) rotate(-3deg); } }
.champ { width: 100%; max-width: 320px; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--nuit-3); background: var(--papier); color: var(--encre); font: inherit; font-size: 1.1rem; text-align: center; }
.champ:focus { outline: none; border-color: var(--or); }
.btn { border: 0; border-radius: 12px; padding: 12px 20px; background: var(--rouge); color: #fff; font-weight: 600; box-shadow: 0 3px 0 var(--rouge-fonce); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.btn.or { background: var(--or); color: var(--encre); box-shadow: 0 3px 0 #a87a26; }
.btn.discret { background: transparent; color: var(--encre-douce); box-shadow: none; padding: 8px 10px; text-decoration: underline; font-weight: 400; }
.btn:disabled { opacity: .5; }
.profils { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 360px; }
.profils button { background: var(--papier); color: var(--encre); border: 0; border-radius: 18px; padding: 20px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--ombre); font-family: "Fraunces", serif; font-size: 1.2rem; font-weight: 600; }
.profils .av { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; }
.erreur { color: #ff9b8f; min-height: 1.4em; }

/* ---------------------------------------------------------------- calendrier */
.compte-rebours { background: var(--nuit-2); border-radius: var(--rayon); padding: 14px 16px; margin: 8px 0 16px; text-align: center; border: 1px dashed rgba(224,173,74,.45); }
.compte-rebours b { color: var(--or); font-family: "Fraunces", serif; font-size: 1.4rem; }
.grille { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 78px; gap: 10px; grid-auto-flow: dense; margin-top: 6px; }
.porte { position: relative; perspective: 600px; border: 0; padding: 0; background: transparent; border-radius: 10px; }
.porte.l2 { grid-column: span 2; }
.porte.h2 { grid-row: span 2; }
.porte .dedans { position: absolute; inset: 0; border-radius: 10px; background: #0a1324; box-shadow: inset 0 0 0 2px rgba(224,173,74,.35), inset 0 6px 14px rgba(0,0,0,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; text-align: center; }
.porte .dedans .emo { font-size: 1.7rem; }
.porte .dedans .tit { font-size: .66rem; color: var(--or-pale); line-height: 1.15; max-height: 2.3em; overflow: hidden; }
.porte .battant { position: absolute; inset: 0; border-radius: 10px; transform-origin: left center; transition: transform .7s cubic-bezier(.3,1.4,.5,1); backface-visibility: hidden; display: flex; align-items: center; justify-content: center; font-family: "Fraunces", serif; font-weight: 700; font-style: italic; font-size: 2rem; color: var(--encre); box-shadow: 0 4px 0 rgba(0,0,0,.25), 0 8px 16px rgba(0,0,0,.25); }
.porte.h2 .battant, .porte.l2 .battant { font-size: 2.8rem; }
.porte:nth-child(4n+1) .battant { background: var(--papier); }
.porte:nth-child(4n+2) .battant { background: #d9473a; color: var(--papier); }
.porte:nth-child(4n+3) .battant { background: #2f6b4f; color: var(--papier); }
.porte:nth-child(4n) .battant { background: var(--or); }
.porte .battant::after { content: ""; position: absolute; inset: 5px; border: 1.5px dashed rgba(0,0,0,.22); border-radius: 7px; }
.porte:nth-child(4n+2) .battant::after, .porte:nth-child(4n+3) .battant::after { border-color: rgba(255,255,255,.35); }
.porte.ouverte .battant { transform: rotateY(-108deg); box-shadow: none; }
.porte.ouverte.anim .battant { transition-duration: .9s; }
.porte.aujourdhui:not(.ouverte) .battant { animation: halo 2s ease-in-out infinite; }
@keyframes halo { 50% { box-shadow: 0 0 0 4px var(--or-pale), 0 0 26px 6px rgba(243,217,154,.6); } }
.porte.fermee .battant { filter: saturate(.75) brightness(.92); }
.porte.secoue { animation: secoue .45s; }
@keyframes secoue { 20%, 60% { transform: translateX(-6px) rotate(-2deg); } 40%, 80% { transform: translateX(6px) rotate(2deg); } }
.porte .fait { position: absolute; top: -6px; right: -6px; z-index: 3; background: var(--or); color: var(--encre); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: .75rem; box-shadow: 0 2px 4px rgba(0,0,0,.4); }

.parchemin { margin: 22px 0 8px; background: var(--papier); color: var(--encre); border-radius: var(--rayon); padding: 14px 14px 16px; box-shadow: var(--ombre); }
.parchemin h3 { margin: 0 0 8px; font-size: 1rem; }
.lettres { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.lettres span { aspect-ratio: 3/4; border-radius: 5px; background: var(--papier-2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: "Fraunces", serif; font-weight: 700; font-size: 1.05rem; position: relative; }
.lettres span small { position: absolute; bottom: 1px; font-size: .5rem; color: var(--encre-douce); font-family: "Outfit", sans-serif; font-weight: 400; }
.lettres span.trouvee { background: var(--rouge); color: #fff; }
.lettres span.trouvee small { color: rgba(255,255,255,.75); }

/* ---------------------------------------------------------------- toast */
#toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 30px); opacity: 0; background: var(--papier); color: var(--encre); padding: 10px 16px; border-radius: 12px; box-shadow: var(--ombre); transition: .25s; z-index: 50; max-width: 90vw; text-align: center; pointer-events: none; }
#toast.vu { transform: translate(-50%, 0); opacity: 1; }

/* ---------------------------------------------------------------- navigation */
nav.bas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: rgba(14,26,48,.92); backdrop-filter: blur(10px); border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
nav.bas a { flex: 1; max-width: 140px; text-decoration: none; color: rgba(245,236,217,.6); display: flex; flex-direction: column; align-items: center; font-size: .72rem; padding: 4px 0; gap: 1px; }
nav.bas a span { font-size: 1.35rem; }
nav.bas a.actif { color: var(--or); }

/* ---------------------------------------------------------------- page case */
.case-tete { padding: 14px 0 6px; display: flex; align-items: center; gap: 12px; }
.case-tete .retour { background: var(--nuit-2); color: var(--papier); border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; flex: none; }
.case-tete .num { font-family: "Fraunces", serif; font-style: italic; font-weight: 700; font-size: 2.6rem; color: var(--or); line-height: 1; }
.case-tete h2 { margin: 0; font-size: 1.3rem; line-height: 1.15; }
.case-tete .sous { font-size: .8rem; color: var(--or-pale); opacity: .8; }
.carte { background: var(--papier); color: var(--encre); border-radius: var(--rayon); padding: 16px; margin: 12px 0; box-shadow: var(--ombre); animation: monte .45s both; }
.carte:nth-child(2) { animation-delay: .06s; } .carte:nth-child(3) { animation-delay: .12s; } .carte:nth-child(4) { animation-delay: .18s; }
@keyframes monte { from { opacity: 0; transform: translateY(14px); } }
.carte p:first-child { margin-top: 0; } .carte p:last-child { margin-bottom: 0; }
.carte.chaplin { position: relative; padding-left: 64px; background: var(--papier); }
.carte.chaplin::before { content: "🐈‍⬛"; position: absolute; left: 12px; top: 12px; font-size: 2.1rem; }
.carte ul.temoins, .carte ol.indices { padding-left: 18px; margin: 8px 0 0; }
.carte ul.temoins li, .carte ol.indices li { margin: 6px 0; }
.carte .q { font-weight: 600; margin-bottom: 10px; }
.carte .q.grand { font-size: 2.1rem; letter-spacing: .08em; text-align: center; font-weight: 400; }
.carte img.photo { width: 100%; border-radius: 10px; display: block; margin-bottom: 10px; }
.chiffre { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--encre); color: var(--or-pale); padding: 10px 12px; border-radius: 8px; letter-spacing: .12em; margin-bottom: 8px; word-break: break-word; font-size: .95rem; }
.ligne-rep { display: flex; gap: 8px; }
.ligne-rep input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 10px; border: 2px solid var(--papier-2); background: #fffaf0; font: inherit; color: var(--encre); }
.ligne-rep input:focus { outline: none; border-color: var(--or); }
.choix { display: grid; gap: 8px; }
.choix button { text-align: left; background: #fffaf0; border: 2px solid var(--papier-2); border-radius: 10px; padding: 10px 12px; color: var(--encre); }
.choix button.faux { border-color: var(--ko); background: #fbe3df; text-decoration: line-through; color: var(--encre-douce); }
.choix button.juste { border-color: var(--ok); background: #dff3e6; font-weight: 600; }
.outils { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .85rem; color: var(--encre-douce); }
.resolu { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #dff3e6; color: #1c4f33; font-size: .95rem; }
.resolu.abandon { background: var(--papier-2); color: var(--encre-douce); }
.indice-txt { margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--or); background: #fff4dc; border-radius: 0 8px 8px 0; font-size: .92rem; }
.secoue { animation: secoue .45s; }
.masque { filter: blur(6px); pointer-events: none; user-select: none; opacity: .6; }
.lettre-gagnee { text-align: center; background: var(--rouge); color: #fff; }
.lettre-gagnee .grosse { font-family: "Fraunces", serif; font-size: 3.6rem; font-weight: 700; line-height: 1; margin: 6px 0; animation: pop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(0) rotate(-20deg); } }

/* gratter / pixel */
.gratte { position: relative; border-radius: 10px; overflow: hidden; touch-action: none; }
.gratte img { width: 100%; display: block; }
.gratte canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.consigne { text-align: center; font-size: .85rem; color: var(--encre-douce); margin-top: 6px; }
canvas.pixel { width: 100%; border-radius: 10px; display: block; margin-bottom: 10px; image-rendering: pixelated; background: var(--papier-2); }

/* mélodie */
.lecteur { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lecteur button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--sapin); color: #fff; font-size: 1.3rem; flex: none; }
.lecteur .barres { display: flex; gap: 3px; align-items: flex-end; height: 30px; }
.lecteur .barres i { width: 5px; background: var(--sapin); border-radius: 2px; height: 6px; transition: height .1s; }
select.sel { width: 100%; padding: 11px; border-radius: 10px; border: 2px solid var(--papier-2); background: #fffaf0; font: inherit; color: var(--encre); }

/* chrono */
.chrono { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chrono .elt { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 3px solid transparent; background: var(--papier-2); padding: 0; display: grid; place-items: center; color: var(--encre); font-size: .85rem; }
.chrono .elt img { width: 100%; height: 100%; object-fit: cover; }
.chrono .elt.sel { border-color: var(--or); transform: scale(.95); }
.chrono .elt b { position: absolute; top: 4px; left: 4px; background: var(--encre); color: var(--or-pale); border-radius: 50%; width: 22px; height: 22px; font-size: .75rem; display: grid; place-items: center; }

/* calcul */
.plaques { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.plaques button, .ops button { border: 0; border-radius: 8px; padding: 8px 12px; background: var(--encre); color: var(--or-pale); font-weight: 600; min-width: 42px; }
.ops { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.ops button { background: var(--sapin); color: #fff; }

/* votes */
.vote { padding: 10px 0; border-top: 1px solid var(--papier-2); }
.vote:first-of-type { border-top: 0; }
.vote .boutons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.vote .boutons button { border: 2px solid var(--papier-2); background: #fffaf0; border-radius: 999px; padding: 5px 12px; color: var(--encre); }
.vote .boutons button.mien { background: var(--encre); color: var(--or-pale); border-color: var(--encre); }
.barre { display: flex; align-items: center; gap: 8px; font-size: .85rem; margin: 3px 0; }
.barre i { height: 10px; border-radius: 5px; background: var(--rouge); display: block; }

/* memory */
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.memory button { aspect-ratio: 1; border: 0; border-radius: 8px; padding: 0; perspective: 400px; background: transparent; }
.memory .c { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.memory button.vu .c { transform: rotateY(180deg); }
.memory .f, .memory .d { position: absolute; inset: 0; border-radius: 8px; backface-visibility: hidden; display: grid; place-items: center; overflow: hidden; }
.memory .f { background: var(--rouge); color: var(--or-pale); font-family: "Fraunces", serif; font-size: 1.4rem; }
.memory .d { transform: rotateY(180deg); background: var(--papier-2); font-size: 2rem; }
.memory .d img { width: 100%; height: 100%; object-fit: cover; }
.memory button.trouve .d { box-shadow: inset 0 0 0 3px var(--ok); }
.tableau-scores { margin-top: 10px; font-size: .9rem; }
.tableau-scores div { display: flex; justify-content: space-between; padding: 3px 0; }

/* jeu flocons */
.jeu-zone { position: relative; border-radius: 10px; overflow: hidden; background: linear-gradient(#16264a, #2a4478); touch-action: none; }
.jeu-zone canvas { display: block; width: 100%; }
.jeu-zone .hud { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; justify-content: space-between; color: #fff; font-weight: 600; text-shadow: 0 1px 2px #000; pointer-events: none; }
.jeu-zone .voile { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(14,26,48,.6); }

/* défi & mur */
.mission { background: #fff4dc; border-left: 4px solid var(--or); padding: 10px 12px; border-radius: 0 10px 10px 0; margin-bottom: 10px; }
.mur { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.mur .m { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--encre); display: grid; place-items: center; color: var(--or-pale); font-size: 1.8rem; }
.mur .m img { width: 100%; height: 100%; object-fit: cover; }
.mur .m small { position: absolute; bottom: 3px; left: 4px; font-size: .9rem; }
.faits { font-size: .85rem; color: var(--encre-douce); margin-top: 6px; }
label.televerser { display: inline-block; }
label.televerser input { display: none; }

/* bons */
.bon { border: 2px dashed var(--rouge); border-radius: 12px; padding: 14px; margin: 10px 0; background: #fffaf0; position: relative; }
.bon::before { content: "JOKER"; position: absolute; top: -10px; left: 12px; background: var(--rouge); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 4px; letter-spacing: .1em; }
.bon.utilise { opacity: .55; border-color: var(--encre-douce); }
.bon.utilise::before { content: "UTILISÉ"; background: var(--encre-douce); }

/* coffre */
.coffre-visuel { font-size: 5rem; text-align: center; margin: 6px 0; }
.coffre-visuel.ouvre { animation: ouvre 1.2s both; }
@keyframes ouvre { 30% { transform: scale(1.2) rotate(-8deg); } 60% { transform: scale(1.3) rotate(8deg); } 100% { transform: scale(1); } }
.film { position: relative; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; background: #000; }
.film img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 1.2s; }
.film img.vu { opacity: 1; animation: zoom 5s linear both; }
@keyframes zoom { to { transform: scale(1.06); } }
.film .leg { position: absolute; bottom: 10px; right: 12px; font-family: "Fraunces", serif; font-size: 1.8rem; font-weight: 700; color: #fff; text-shadow: 0 2px 8px #000; }
.message-noel { font-family: "Fraunces", serif; font-size: 1.08rem; line-height: 1.6; }

/* classement */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 20px 0 14px; }
.podium .marche { flex: 1; max-width: 110px; text-align: center; }
.podium .marche .socle { border-radius: 10px 10px 0 0; background: var(--papier); color: var(--encre); padding-top: 8px; font-family: "Fraunces", serif; font-weight: 700; font-size: 1.6rem; }
.podium .av { width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; box-shadow: var(--ombre); }
.podium .nom { font-weight: 600; } .podium .pts { font-size: .85rem; color: var(--or-pale); margin-bottom: 6px; }
.ligne-cl { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--papier-2); }
.ligne-cl:first-child { border-top: 0; }
.ligne-cl .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ligne-cl .d { flex: 1; font-size: .82rem; color: var(--encre-douce); }
.ligne-cl .d b { color: var(--encre); font-size: 1rem; }
.ligne-cl .p { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.3rem; }

/* piège */
.piege { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.yeux { display: flex; gap: 26px; }
.yeux i { width: 54px; height: 54px; border-radius: 50%; background: #f3d34a; position: relative; box-shadow: 0 0 30px rgba(243,211,74,.6); animation: cligne 3s infinite; }
.yeux i::after { content: ""; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 10px; margin-left: -5px; border-radius: 50%; background: #111; }
@keyframes cligne { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

#confettis { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.compte-rebours.apercu { border-color: #4a8fd8; border-style: solid; }
.compte-rebours .btn.discret { color: var(--or-pale); }
