/* Pass de l'avent — pensé mobile d'abord, animations en CSS pur. */

:root {
  --bg: #0b0910;
  --bg2: #140f1d;
  --panel: #191424;
  --row: #221b31;
  --border: #302741;
  --ink: #f6f2fb;
  --muted: #a79fb8;
  --accent: #d6a83a;
  --bronze: #b06e42;
  --bronze-2: #7a4a2a;
  --argent: #b9c0ca;
  --argent-2: #7e868f;
  --or: #e3bb52;
  --or-2: #9b7420;
  --icone: #a97bff;
  --icone-2: #5c2bb0;
  --good: #3ecf8e;
  --mid: #f5b83d;
  --bad: #ff6a3d;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1d44 0%, transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg) 40%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe));
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- en-tête / pass */

header {
  position: sticky; top: 0; z-index: 5;
  padding: 14px 16px 12px;
  background: rgba(11, 9, 16, .86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.titre-pass { display: flex; align-items: baseline; gap: 10px; }
.titre-pass h1 { margin: 0; font-size: 19px; letter-spacing: .02em; }
.titre-pass .serie { margin-left: auto; font-size: 13px; color: var(--muted); }
.titre-pass .serie b { color: var(--mid); }

.xp-ligne { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }
.xp-ligne b { color: var(--ink); }
.jauge { position: relative; height: 10px; background: #241d33; border-radius: 6px; margin-top: 5px; overflow: hidden; }
.jauge i { display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--or-2), var(--or)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.jauge .brille { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  transform: translateX(-100%); animation: brille 2.6s ease-in-out infinite; }
@keyframes brille { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ---------------------------------------------------------------- grille des 26 cases */

main { max-width: 620px; margin: 0 auto; padding: 16px; }
h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 24px 0 10px; }
h2:first-child { margin-top: 0; }

.grille { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 520px) { .grille { grid-template-columns: repeat(5, 1fr); } }

.case {
  position: relative; aspect-ratio: 3 / 4; border-radius: 12px; border: 1px solid var(--border);
  background: linear-gradient(170deg, #241d33, #171124); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 4px;
  color: var(--ink); overflow: hidden;
}
.case .num { font-size: 20px; font-weight: 800; line-height: 1; }
.case .pied { font-size: 9px; color: var(--muted); text-align: center; line-height: 1.15; }
.case .cadenas { font-size: 15px; opacity: .55; }
.case.verrouille { opacity: .62; }
.case.ouvrable {
  border-color: var(--or); box-shadow: 0 0 0 1px rgba(227, 187, 82, .35), 0 0 22px rgba(227, 187, 82, .3);
  animation: respire 2.2s ease-in-out infinite;
}
@keyframes respire { 50% { box-shadow: 0 0 0 1px rgba(227, 187, 82, .6), 0 0 34px rgba(227, 187, 82, .5); } }
.case.ouvrable .num { color: var(--or); }

.case.ouvert::before, .case.remis::before, .case.choix::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(160deg, var(--c1), var(--c2)); opacity: .9;
}
.case.ouvert > *, .case.remis > *, .case.choix > * { position: relative; z-index: 1; }
.case.bronze { --c1: var(--bronze); --c2: var(--bronze-2); }
.case.argent { --c1: var(--argent); --c2: var(--argent-2); color: #1b1726; }
.case.argent .pied { color: #2d2740; }
.case.or { --c1: var(--or); --c2: var(--or-2); color: #241b05; }
.case.or .pied { color: #3a2c08; }
.case.icone { --c1: var(--icone); --c2: var(--icone-2); }
.case.icone::after {
  content: ""; position: absolute; inset: -40%; z-index: 0;
  background: conic-gradient(from 0deg, transparent 0 85%, rgba(255,255,255,.55) 92%, transparent 100%);
  animation: tourne 6s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
.case .vignette { position: absolute; inset: 0; z-index: 0; object-fit: cover; width: 100%; height: 100%; opacity: .34; }
.case .badge { position: absolute; top: 4px; right: 5px; z-index: 2; font-size: 10px; }
.case .pastille {
  position: absolute; top: -4px; left: -4px; z-index: 3; background: var(--bad); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg);
}
.case.choix { outline: 2px dashed var(--mid); outline-offset: -4px; }

/* ---------------------------------------------------------------- paliers bonus */

.paliers { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.palier {
  flex: 0 0 150px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; opacity: .55;
}
.palier.debloque { opacity: 1; border-color: var(--or); }
.palier .seuil { font-size: 12px; color: var(--muted); }
.palier .seuil b { color: var(--or); }
.palier .nom { font-weight: 600; font-size: 14px; margin-top: 2px; }
.palier .desc { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------- défis */

.defi { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.defi .q { font-weight: 600; }
.defi .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.defi .choix-defi { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.defi button, .champ button {
  background: var(--row); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
}
.defi button:hover { border-color: var(--or); }
.defi.resolu { border-color: var(--good); }
.defi .verdict { font-size: 13px; margin-top: 8px; }
.defi .verdict.ok { color: var(--good); }
.defi .verdict.ko { color: var(--bad); }
.champ { display: flex; gap: 8px; margin-top: 8px; }
input[type="text"], textarea {
  flex: 1; background: #120e1c; color: var(--ink); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; font: inherit; resize: vertical;
}

/* ---------------------------------------------------------------- fiche d'une case */

.voile {
  position: fixed; inset: 0; z-index: 20; background: rgba(6, 4, 10, .82);
  backdrop-filter: blur(4px); display: grid; place-items: end center; padding: 0;
  animation: fondu .25s ease;
}
@keyframes fondu { from { opacity: 0; } }
.fiche {
  width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #1b1527, #120d1c);
  border: 1px solid var(--border); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(24px + var(--safe));
  animation: monte .32s cubic-bezier(.2, .9, .2, 1);
}
@media (min-width: 620px) { .voile { place-items: center; } .fiche { border-radius: 18px; } }
@keyframes monte { from { transform: translateY(40px); opacity: .4; } }
.fiche .ferme { float: right; background: none; border: 0; font-size: 22px; color: var(--muted); line-height: 1; }
.fiche h3 { margin: 2px 0 2px; font-size: 22px; }
.fiche .rarete { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.fiche .rarete.icone { color: var(--icone); }
.fiche .rarete.or { color: var(--or); }
.fiche img.illu { width: 100%; border-radius: 12px; margin: 12px 0; display: block; }
.fiche .desc { margin: 6px 0; }
.fiche .mot {
  border-left: 3px solid var(--or); padding: 6px 0 6px 12px; margin: 14px 0;
  font-style: italic; color: #e8dec4;
}
.fiche .bandeau {
  display: inline-block; background: rgba(245, 184, 61, .14); border: 1px solid var(--mid);
  color: var(--mid); border-radius: 999px; padding: 3px 11px; font-size: 13px; margin-bottom: 6px;
}
.fiche .bandeau.remis { background: rgba(62, 207, 142, .14); border-color: var(--good); color: var(--good); }
.fiche .attente { text-align: center; padding: 26px 10px; }
.fiche .attente .gros { font-size: 42px; }
.fiche .attente p { color: var(--muted); }
.fiche .attente button.secours {
  background: var(--row); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 18px; margin-top: 6px;
}
.fiche .attente button.secours:hover { border-color: var(--or); }
.fiche .attente p.apres { font-size: 12px; margin-top: 10px; }

/* carte retournable des packs à choix */
/* Le nombre de colonnes est posé en ligne par le script : un pack peut avoir de deux à
   six cartes, et une colonne vide ressemblerait à une carte qui n'a pas chargé. La
   largeur est bornée parce qu'à deux colonnes sur un grand écran, deux cartes au format
   2/3 deviennent deux affiches qu'il faut faire défiler pour voir en entier. */
.pack { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
        margin: 14px auto 6px; max-width: 420px; }
.option { perspective: 800px; background: none; border: 0; padding: 0; }
.option .inner {
  position: relative; aspect-ratio: 2 / 3; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}
.option.face .inner { transform: rotateY(180deg); }
.option .dos, .option .face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 12px;
  border: 1px solid var(--border); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 8px; text-align: center;
}
.option .dos { background: linear-gradient(150deg, #2b2141, #1a1328); font-size: 26px; }
.option .face { transform: rotateY(180deg); background: linear-gradient(160deg, #3a2f52, #221a33); }
.option .face .t { font-size: 12px; font-weight: 700; line-height: 1.2; }
.option .face .d { font-size: 10px; color: var(--muted); line-height: 1.2; }
.option.gardee .face { border-color: var(--good); box-shadow: 0 0 18px rgba(62, 207, 142, .35); }

/* fil de commentaires */
.fil { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.msg { margin: 8px 0; display: flex; }
.msg .bulle { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: var(--row); font-size: 15px; }
.msg .bulle small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.elle { justify-content: flex-end; }
.msg.elle .bulle { background: #3a2f52; }
.msg.octave .bulle { background: var(--row); }
.fil.chat { max-height: 46vh; overflow-y: auto; border-top: 0; margin-top: 10px; }

/* bulle flottante du fil général */
.bulle-chat {
  position: fixed; right: 14px; bottom: calc(14px + var(--safe)); z-index: 15;
  width: 54px; height: 54px; border-radius: 999px; border: 1px solid var(--border);
  background: linear-gradient(180deg, #2a2140, #1b1527); color: var(--ink);
  font-size: 24px; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.bulle-chat .pastille {
  position: absolute; top: -2px; right: -2px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 19px; height: 19px;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg);
}
.bulle-chat.anime { animation: respire 2.4s ease-in-out infinite; }
@keyframes respire { 50% { transform: scale(1.08); } }

.primaire {
  width: 100%; margin-top: 14px; padding: 12px; border-radius: 12px; border: 0;
  background: linear-gradient(90deg, var(--or-2), var(--or)); color: #241b05; font-weight: 700;
}
.primaire:disabled { opacity: .5; }

/* ---------------------------------------------------------------- révélation */

.walkout { position: fixed; inset: 0; z-index: 30; background: #05030a; display: grid; place-items: center; overflow: hidden; }
.walkout .lumieres { position: absolute; inset: 0;
  background: conic-gradient(from 200deg at 50% 120%, transparent 0 20%, rgba(169, 123, 255, .45) 35%, transparent 50%, rgba(227, 187, 82, .4) 65%, transparent 80%);
  animation: balaye 3.4s linear infinite; }
@keyframes balaye { to { transform: rotate(360deg); } }
.walkout .carte {
  position: relative; z-index: 1; width: min(74vw, 300px); aspect-ratio: 2 / 3; border-radius: 18px;
  background: linear-gradient(160deg, var(--c1, #a97bff), var(--c2, #5c2bb0));
  display: grid; place-items: center; text-align: center; padding: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .6);
  animation: surgit 1.4s cubic-bezier(.2, .9, .2, 1) both;
}
@keyframes surgit {
  0% { transform: translateY(60px) scale(.7) rotateY(180deg); opacity: 0; }
  60% { transform: translateY(0) scale(1.04) rotateY(0deg); opacity: 1; }
  100% { transform: scale(1); }
}
.walkout .carte .r { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; opacity: .85; }
.walkout .carte .t { font-size: 25px; font-weight: 800; line-height: 1.15; margin-top: 8px; }
.walkout .carte .xp { margin-top: 10px; font-size: 14px; opacity: .9; }
.walkout .toucher { position: absolute; bottom: 42px; z-index: 2; color: #cfc6e0; font-size: 13px; animation: clignote 1.8s ease-in-out infinite; }
@keyframes clignote { 50% { opacity: .35; } }
.walkout.simple .lumieres { display: none; }
.walkout.simple .carte { animation: flip .8s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes flip { from { transform: rotateY(180deg) scale(.85); opacity: 0; } }

.confettis { position: fixed; inset: 0; z-index: 31; pointer-events: none; overflow: hidden; }
.confettis i { position: absolute; top: -12px; width: 7px; height: 12px; border-radius: 2px; animation: tombe linear forwards; }
@keyframes tombe { to { transform: translateY(105vh) rotate(540deg); opacity: .2; } }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe)); transform: translateX(-50%);
  z-index: 40; background: #241d33; border: 1px solid var(--or); color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: monte-toast .3s ease, fondu-toast .4s ease 2.6s forwards;
}
@keyframes monte-toast { from { transform: translate(-50%, 20px); opacity: 0; } }
@keyframes fondu-toast { to { opacity: 0; } }

/* ---------------------------------------------------------------- écrans d'exception */

.accueil { max-width: 420px; margin: 18vh auto; padding: 0 24px; text-align: center; }
.accueil .gros { font-size: 58px; }
.accueil h1 { font-size: 24px; margin: 10px 0 6px; }
.accueil p { color: var(--muted); }
/* Mot d'accueil en haut d'une fiche : « tu viens d'une boule qui n'a pas répondu ». */
.fiche .patience {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  background: rgba(214, 168, 58, .12); border: 1px solid rgba(214, 168, 58, .35);
  color: var(--accent); font-size: 14px;
}

/* Écran scellé : un cachet de cire, et pas un mot de plus. */
.scelle .cire {
  width: 112px; height: 112px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 34px/1 "Segoe UI", system-ui, sans-serif; color: #4a2f10;
  background: radial-gradient(circle at 34% 30%, #f0cd73, var(--accent) 48%, #8c6418);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45), inset 0 2px 6px rgba(255, 255, 255, .45);
  animation: respire 4.5s ease-in-out infinite;
}
.scelle .dodos { color: var(--accent); font-weight: 600; margin-top: 14px; }

@keyframes respire {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

.pied-page { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 16px 0; }
.chargement { text-align: center; color: var(--muted); padding: 30vh 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
