/* Jeu : les lettres fantômes */

.fantomes__reglages {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--espace-2) var(--espace-5);
  width: 100%;
  min-width: 0;
}

.fantomes__salles,
.fantomes__modes {
  justify-content: flex-start;
  justify-content: safe center;
  min-width: 0;
  max-width: 100%;
}

.fantomes__modes .icone {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.2em;
}

.fantomes__tete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--espace-3);
  width: 100%;
  max-width: 34rem;
}

.fantomes__consigne {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: var(--t-grand);
  line-height: 1.35;
  text-align: center;
  min-height: 2.7em;
  display: grid;
  place-items: center;
}

/* ---------- La pièce dans le noir ---------- */

.fantomes__cadre {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--espace-4);
  width: 100%;
  max-width: 34rem;
  padding: var(--espace-5) var(--espace-2) var(--espace-6);
  border-radius: var(--rayon-grand);
  /* couleur fixe voulue : une pièce dans la nuit, la même dans les deux thèmes */
  background: #0b0d22;
  box-shadow: inset 0 0 0 3px #2c3170;
  overflow: hidden;
  touch-action: none;
  transition: background 680ms ease;
}

.fantomes__cadre.est-allumee {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 3px var(--accent);
}

.fantomes__image {
  position: relative;
  z-index: 1;
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  opacity: 0.55;
  filter: grayscale(0.4);
  transition: opacity 400ms ease, filter 400ms ease;
}

.fantomes__image > .icone,
.fantomes__image .icone {
  width: 2.8rem;
  height: 2.8rem;
}

.fantomes__image.est-vide {
  height: 1rem;
}

.fantomes__cadre.est-allumee .fantomes__image {
  opacity: 1;
  filter: none;
}

.fantomes__lettres {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: clamp(0.05rem, 0.6vw, 0.3rem);
  max-width: 100%;
  padding-top: 2.6rem;
}

.fantomes__lettre {
  position: relative;
  min-width: clamp(1.45rem, 0.8rem + 2.4vw, 2.1rem);
  min-height: 3.6rem;
  padding: 0 0.04em;
  border: 0;
  border-radius: 10px;
  background: transparent;
  /* couleur fixe voulue : des lettres pâles dans le noir */
  color: #c9cbe6;
  font-family: var(--police-texte);
  font-weight: 700;
  font-size: clamp(2rem, 1rem + 4.6vw, 3.4rem);
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 160ms ease, color 160ms ease, text-shadow 160ms ease;
}

.fantomes__lettre.est-eclairee {
  opacity: 1;
  /* couleur fixe voulue : la lumière blanche de la lampe (pas jaune : le jaune dit le piège, code des couleurs du 22/10/2026) */
  color: #ffffff;
  text-shadow: 0 0 14px rgba(235, 240, 255, 0.8);
}

.fantomes__lettre:focus-visible {
  outline: 3px solid #ffffff;
  box-shadow: none;
}

/* Le fantôme trouvé : la lettre qu'on n'entend pas, surlignée en jaune (code des couleurs : le piège),
   avec le fantôme au-dessus (le signe de forme), et elle flotte un peu */
.fantomes__lettre.est-fantome {
  opacity: 1;
  background: var(--fn-piege);
  color: var(--fn-piege-texte);
  text-shadow: none;
  animation: fantomes-flotte 2.4s ease-in-out infinite;
}

.fantomes__cadre.est-allumee .fantomes__lettre {
  opacity: 1;
  color: var(--encre);
  text-shadow: none;
}

.fantomes__cadre.est-allumee .fantomes__lettre.est-fantome {
  color: var(--fn-piege-texte);
  text-shadow: none;
}

.fantomes__spectre {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 2.4rem;
  height: 2.4rem;
  margin-left: -1.2rem;
  pointer-events: none;
  animation: fantomes-sort 680ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fantomes__spectre .icone {
  width: 100%;
  height: 100%;
}

@keyframes fantomes-sort {
  from { transform: translateY(1.4rem) scale(0.3); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes fantomes-flotte {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ---------- La lampe ---------- */

.fantomes__lampe {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 60%);
  width: 9rem;
  height: 9rem;
  margin: -4.5rem 0 0 -4.5rem;
  border-radius: 50%;
  /* couleur fixe voulue : le rond blanc d'une lampe de poche (pas jaune : le jaune dit le piège) */
  background: radial-gradient(circle, rgba(240, 244, 255, 0.40) 0%, rgba(240, 244, 255, 0.15) 45%, rgba(240, 244, 255, 0) 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.fantomes__lampe.est-visible {
  opacity: 1;
}

/* Le premier mot : la lampe passe toute seule, pour montrer le geste */
.fantomes__cadre.est-guide .fantomes__lampe {
  opacity: 1;
  top: 68%;
  animation: fantomes-balaye 3.2s ease-in-out infinite;
}

@keyframes fantomes-balaye {
  0%, 100% { left: 18%; }
  50% { left: 82%; }
}

.fantomes__cadre.est-devine:not(.est-allumee) {
  box-shadow: inset 0 0 0 3px #3a3f78;
}

/* ---------- Sous la pièce ---------- */

.fantomes__phrase {
  max-width: 34rem;
  min-height: 1.6em;
  text-align: center;
  font-size: var(--t-texte);
}

.fantomes__truc {
  display: grid;
  gap: var(--espace-4);
  width: 100%;
  max-width: 34rem;
}

.fantomes__glyphe {
  font-family: var(--police-texte);
  font-weight: 700;
  font-size: 1.45rem;
}

.fantomes__glyphe b {
  /* La lettre fantôme : sur fond crème pointillé avec encre foncée fixe pour rester bien lisible sans ton sur ton */
  display: inline-block;
  padding: 0 0.14em;
  margin-right: 0.04em;
  border-radius: 6px;
  background: #f5ebd8;
  color: #171a33;
  opacity: 1;
  text-decoration: underline dotted;
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.12em;
}

@media (prefers-reduced-motion: reduce) {
  .fantomes__lettre.est-fantome,
  .fantomes__spectre,
  .fantomes__cadre.est-guide .fantomes__lampe {
    animation: none;
  }
  .fantomes__cadre.est-guide .fantomes__lampe {
    left: 18%;
  }
}

.fantomes__continuer {
  min-width: 14rem;
  font-size: 1.15rem;
  font-weight: 700;
}
