:root {
  --fond: #0d0b09;
  --fond-panneau: rgba(28, 23, 18, 0.82);
  --fond-panneau-clair: rgba(40, 33, 25, 0.9);
  --bordure: #4a3c2a55;
  --bordure-forte: #5a4a33;
  --texte: #ede4d3;
  --texte-attenue: #b8ab93;
  --accent: #d3a256;
  --accent-vif: #e8bd72;
  --accent-texte: #211408;
  --danger: #c46a5a;
  --succes: #6fae7f;
  --rayon: 14px;
  --ombre-forte: 0 12px 32px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #000;
  color: var(--texte);
  font-family: "Georgia", "Iowan Old Style", serif;
  display: flex;
  justify-content: center;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: var(--fond);
  box-shadow: var(--ombre-forte);
}

/* ---------- Scène ---------- */

#scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#scene-fond {
  position: absolute;
  inset: -4%;
  background-image: url("assets/scenes/salon.webp");
  background-size: cover;
  background-position: center 30%;
  animation: derive-scene 50s ease-in-out infinite alternate;
}

@keyframes derive-scene {
  from { transform: scale(1); }
  to   { transform: scale(1.08); }
}

#scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(6, 5, 4, 0.82) 0%, rgba(6, 5, 4, 0.15) 22%, rgba(6, 5, 4, 0) 42%),
    linear-gradient(to top, rgba(6, 5, 4, 0.75) 0%, rgba(6, 5, 4, 0) 34%),
    radial-gradient(120% 90% at 50% 40%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45) 100%);
}

/* ---------- En-tête ---------- */

#entete {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* Au-dessus du tiroir de dialogue (30) : le bouton du carnet reste
     cliquable, donc le carnet fermable, meme quand le chat est ouvert. */
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: max(0.9rem, env(safe-area-inset-top)) 0.9rem 0.6rem;
}

.entete-titre {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.entete-titre h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-vif);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entete-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.bouton-icone {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(211, 162, 86, 0.35);
  background: rgba(20, 16, 12, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--accent-vif);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.bouton-icone[hidden] { display: none; }
.bouton-icone svg { width: 18px; height: 18px; }
.bouton-icone:hover { background: rgba(35, 28, 20, 0.75); border-color: var(--accent); }
.bouton-icone:active { transform: scale(0.93); }
.bouton-icone[aria-expanded="true"] { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }

.pastille-compteur {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-texte);
  font-family: system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--fond);
}

/* ---------- Panneaux flottants (infos / journal) ---------- */

.panneau-flottant {
  position: absolute;
  top: 62px;
  right: 0.9rem;
  left: 0.9rem;
  max-width: 340px;
  margin-left: auto;
  max-height: 52vh;
  overflow-y: auto;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
  padding: 0.9rem 1rem;
  box-shadow: var(--ombre-forte);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 36; /* au-dessus du tiroir de dialogue (30), sous les modales (50) */
  text-align: left;
  font-family: system-ui, sans-serif;
  animation: panneau-entree 0.18s ease both;
}

#panneau-infos { left: 0.9rem; right: 0.9rem; max-width: none; }
#panneau-infos p { margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--texte); }
.lien-retour {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--accent-vif);
  text-decoration: none;
}
.lien-retour:hover { text-decoration: underline; }

.panneau-flottant.masque { display: none; }

@keyframes panneau-entree {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panneau-flottant h2 {
  margin: 0 0 0.6rem 0;
  font-size: 0.92rem;
  font-family: Georgia, serif;
  color: var(--accent-vif);
}

#liste-journal {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

#liste-journal li {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--texte);
  padding-left: 0.7rem;
  border-left: 2px solid var(--accent);
}

.journal-vide {
  font-size: 0.85rem;
  color: var(--texte-attenue);
  font-style: italic;
  border-left-color: var(--bordure-forte) !important;
}

/* ---------- Arrivées ---------- */

#couche-arrivee {
  position: absolute;
  top: 62px;
  left: 0.9rem;
  right: 0.9rem;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-arrivee {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.9rem 0.5rem 0.5rem;
  background: rgba(20, 16, 12, 0.88);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--ombre-forte);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  max-width: 100%;
}
.toast-arrivee.visible { opacity: 1; transform: translateY(0); }

.toast-arrivee-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--accent);
}
.toast-arrivee-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.toast-arrivee-texte {
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--texte);
  min-width: 0;
}
.toast-arrivee-texte strong {
  display: block;
  color: var(--accent-vif);
  font-family: Georgia, serif;
  font-size: 0.9rem;
}
.toast-arrivee-texte span {
  display: block;
  color: var(--texte-attenue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Découverte d'un indice ---------- */

/* Éclat doré qui balaie la scène quand un fait est révélé. */
#eclat-decouverte {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(232, 189, 114, 0.55), rgba(232, 189, 114, 0) 70%),
    radial-gradient(90% 60% at 50% 50%, rgba(232, 189, 114, 0.18), rgba(232, 189, 114, 0) 70%);
}
#eclat-decouverte.actif { animation: eclat-decouverte 1.1s ease-out both; }
@keyframes eclat-decouverte {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Le carnet "sonne" : balancement + deux anneaux qui se propagent. */
.bouton-icone.pulse-decouverte { animation: carnet-decouverte 1.4s ease-out both; }
@keyframes carnet-decouverte {
  0%   { transform: rotate(0); box-shadow: 0 0 0 0 rgba(232, 189, 114, 0.85); }
  10%  { transform: rotate(-14deg) scale(1.12); }
  25%  { transform: rotate(11deg) scale(1.12); }
  40%  { transform: rotate(-7deg) scale(1.06); }
  50%  { transform: rotate(0) scale(1); box-shadow: 0 0 0 16px rgba(232, 189, 114, 0); }
  51%  { box-shadow: 0 0 0 0 rgba(232, 189, 114, 0.85); }
  100% { transform: none; box-shadow: 0 0 0 16px rgba(232, 189, 114, 0); }
}

.pastille-compteur.pop { animation: pastille-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pastille-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.9); background: var(--accent-vif); }
  100% { transform: scale(1); }
}

.toast-arrivee.toast-decouverte {
  position: relative;
  align-items: flex-start;
  border-radius: 16px;
  border-color: var(--accent-vif);
  padding: 0.55rem 0.95rem 0.55rem 0.55rem;
  background: linear-gradient(120deg, rgba(48, 36, 20, 0.95), rgba(20, 16, 12, 0.92));
  box-shadow: var(--ombre-forte), 0 0 22px rgba(232, 189, 114, 0.4);
  overflow: hidden;
}
/* Reflet qui traverse la bannière à son apparition. */
.toast-decouverte::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 236, 196, 0.35) 50%, transparent 65%);
  transform: translateX(-120%);
}
.toast-decouverte.visible::after { animation: reflet-decouverte 1s ease-out 0.15s both; }
@keyframes reflet-decouverte { to { transform: translateX(120%); } }

.toast-decouverte-icone {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-texte);
}
.toast-decouverte-icone svg { width: 17px; height: 17px; }
.toast-decouverte.visible .toast-decouverte-icone { animation: icone-decouverte 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both; }
@keyframes icone-decouverte {
  from { transform: scale(0) rotate(-40deg); }
  to   { transform: scale(1) rotate(0); }
}

.toast-decouverte .toast-arrivee-texte span {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  color: var(--texte);
}

@media (prefers-reduced-motion: reduce) {
  #eclat-decouverte.actif,
  .bouton-icone.pulse-decouverte,
  .pastille-compteur.pop,
  .toast-decouverte.visible::after,
  .toast-decouverte.visible .toast-decouverte-icone { animation: none; }
}

/* Interrupteur des effets sonores (panneau d'infos). */
.interrupteur-son {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.35rem 0.7rem 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--bordure-forte);
  background: rgba(20, 16, 12, 0.55);
  color: var(--accent-vif);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.interrupteur-son:hover { border-color: var(--accent); }
.interrupteur-son svg { width: 17px; height: 17px; flex-shrink: 0; }
.interrupteur-son .son-coupe { display: none; }
.interrupteur-son[aria-checked="false"] { color: var(--texte-attenue); }
.interrupteur-son[aria-checked="false"] .son-ondes { display: none; }
.interrupteur-son[aria-checked="false"] .son-coupe { display: inline; }

/* ---------- Personnages dans la scène ---------- */

#couche-personnages {
  position: absolute;
  left: 0;
  right: 0;
  /* Suit la hauteur reelle du tiroir de dialogue (voir observateurTiroir
     dans app.js) : les personnages remontent avec le tiroir au lieu de se
     faire recouvrir quand il s'ouvre ou que la conversation s'allonge. */
  bottom: var(--decalage-personnages, 152px);
  height: 58%;
  z-index: 10;
  transition: bottom 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.perso-scene {
  position: absolute;
  bottom: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transform: translateX(-50%);
  transition: filter 0.3s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    left 0.5s cubic-bezier(0.22, 1, 0.36, 1), width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  filter: brightness(0.5) saturate(0.65);
  z-index: 1;
}
.perso-scene img {
  display: block;
  width: 100%;
  filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.6));
}
.perso-scene:hover { filter: brightness(0.8) saturate(0.85); }
.perso-scene.actif {
  filter: brightness(1) saturate(1);
  transform: translateX(-50%) scale(1.06);
  z-index: 5;
}
.perso-scene.actif:hover { filter: brightness(1.05) saturate(1); }

.perso-scene.nouveau::after {
  content: "";
  position: absolute;
  top: 4%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-vif);
  box-shadow: 0 0 0 3px rgba(232, 189, 114, 0.35);
  animation: pouls-arrivee 1.6s ease-in-out infinite;
}

@keyframes pouls-arrivee {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

.perso-scene.apparition {
  animation: entree-scene 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes entree-scene {
  from { opacity: 0; transform: translateX(-50%) translateY(36px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.perso-scene.actif.apparition {
  animation-name: entree-scene-actif;
}
@keyframes entree-scene-actif {
  from { opacity: 0; transform: translateX(-50%) translateY(36px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.06); }
}

/* ---------- Tiroir de dialogue ---------- */

#tiroir-dialogue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, rgba(18, 14, 10, 0.72), rgba(13, 11, 9, 0.97) 30%, var(--fond) 100%);
  border-top: 1px solid var(--bordure-forte);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding-bottom: env(safe-area-inset-bottom);
}

#poignee-tiroir {
  width: 100%;
  background: none;
  border: none;
  padding: 0.5rem 0 0.35rem;
  display: flex;
  justify-content: center;
  cursor: pointer;
}
.poignee-barre {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--bordure-forte);
  transition: background 0.2s;
}
#poignee-tiroir:hover .poignee-barre { background: var(--accent); }

#selecteur-personnages {
  display: flex;
  gap: 0.55rem;
  padding: 0 0.9rem 0.6rem;
  overflow-x: auto;
  scrollbar-width: none;
}
#selecteur-personnages::-webkit-scrollbar { display: none; }
#selecteur-personnages.masque { display: none; }

.onglet-personnage {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  padding: 0;
  border: 2px solid var(--bordure-forte);
  background: var(--fond-panneau-clair);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.onglet-personnage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.onglet-personnage:hover { transform: translateY(-2px); }
.onglet-personnage.actif { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(211, 162, 86, 0.25); }

.onglet-personnage.nouveau::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-vif);
  box-shadow: 0 0 0 2px var(--fond);
  animation: pouls-arrivee 1.6s ease-in-out infinite;
}

#dialogue-entete {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.1rem 1rem 0.7rem;
}

#dialogue-portrait {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  background: var(--fond-panneau-clair);
}
#dialogue-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

.dialogue-identite { min-width: 0; display: flex; flex-direction: column; }
#chat-nom { font-size: 1.05rem; color: var(--texte); }
#chat-role {
  font-family: system-ui, sans-serif;
  font-size: 0.74rem;
  color: var(--texte-attenue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messages {
  overflow-y: auto;
  padding: 0 1rem;
  max-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1), padding 0.35s ease;
}

#tiroir-dialogue.ouvert #messages {
  max-height: 42vh;
  padding: 0.4rem 1rem 0.8rem;
}

.message { display: flex; align-items: flex-end; gap: 0.5rem; }
.message-joueur { justify-content: flex-end; }
.message-personnage { justify-content: flex-start; }
.message-systeme { justify-content: center; }

.avatar-message {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--fond-panneau-clair);
  border: 1px solid var(--bordure-forte);
}
.avatar-message img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-initiales {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  color: var(--accent);
  background: var(--fond-panneau-clair);
}
#dialogue-portrait .avatar-initiales { font-size: 1rem; }
.avatar-message .avatar-initiales { font-size: 0.68rem; }
.onglet-personnage .avatar-initiales { font-size: 0.95rem; }
.toast-arrivee-avatar .avatar-initiales { font-size: 0.8rem; }

.bulle {
  max-width: 72%;
  padding: 0.5rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.message-joueur .bulle {
  background: var(--accent);
  color: var(--accent-texte);
  border-bottom-right-radius: 3px;
}
.message-personnage .bulle {
  background: rgba(38, 31, 23, 0.92);
  border: 1px solid var(--bordure-forte);
  border-bottom-left-radius: 3px;
}
.message-systeme .bulle {
  background: transparent;
  color: var(--texte-attenue);
  font-family: system-ui, sans-serif;
  font-size: 0.76rem;
  font-style: italic;
  max-width: 90%;
  text-align: center;
}

.message-personnage.en-attente .bulle {
  color: var(--texte-attenue);
  font-style: italic;
}

#form-message {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
}

#input-message {
  flex: 1;
  background: rgba(38, 31, 23, 0.85);
  border: 1px solid var(--bordure-forte);
  border-radius: 999px;
  color: var(--texte);
  padding: 0.62rem 1rem;
  font-family: system-ui, sans-serif;
  /* 16px minimum : en dessous, iOS Safari zoome sur la page au focus du champ. */
  font-size: 1rem;
  min-width: 0;
}
#input-message:focus { outline: none; border-color: var(--accent); }
#input-message::placeholder { color: var(--texte-attenue); }

#btn-envoyer {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-texte);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
#btn-envoyer svg { width: 17px; height: 17px; }
#btn-envoyer:disabled { opacity: 0.45; cursor: not-allowed; }
#btn-envoyer:hover:not(:disabled) { filter: brightness(1.1); }
#btn-envoyer:active:not(:disabled) { transform: scale(0.92); }

/* ---------- Collègue : appel / lettre ---------- */

.bouton-icone.sonne {
  border-color: var(--accent);
  animation: anneau-sonnerie 1.4s ease-out infinite;
}
.bouton-icone.sonne svg { animation: secousse-telephone 1.4s ease-in-out infinite; }

@keyframes anneau-sonnerie {
  0%   { box-shadow: 0 0 0 0 rgba(232, 189, 114, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(232, 189, 114, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 189, 114, 0); }
}
@keyframes secousse-telephone {
  0%, 45%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(-14deg); }
  20%, 40% { transform: rotate(14deg); }
}

.toast-aide {
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
}
.toast-aide .carte-aide-icone { width: 100%; height: 100%; border: none; }
.toast-aide .carte-aide-icone svg { width: 16px; height: 16px; }

#liste-aide,
#liste-documents {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.carte-aide {
  font-family: system-ui, sans-serif;
  background: rgba(38, 31, 23, 0.85);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
  padding: 0.8rem 0.9rem;
}

.carte-aide-icone {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent-vif);
}
.carte-aide-icone svg { width: 15px; height: 15px; }

.carte-aide-entete {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  color: var(--texte-attenue);
}

.carte-appel .carte-aide-texte {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--texte);
}

.lettre-papier {
  padding: 1rem 1.1rem;
  border-radius: 3px;
  background: linear-gradient(180deg, #efe3c6, #e3d2ac);
  color: #3b2c19;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(90, 70, 40, 0.25);
}
.lettre-papier p { margin: 0; }
.lettre-papier .lettre-signature {
  margin-top: 0.9rem;
  text-align: right;
  font-style: italic;
}

.carte-aide.scellee {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1.2rem 1rem;
  text-align: center;
  border-color: var(--accent);
}
.carte-aide.scellee .carte-aide-icone {
  width: 52px;
  height: 52px;
  margin-bottom: 0.4rem;
  animation: anneau-sonnerie 1.4s ease-out infinite;
}
.carte-aide.scellee .carte-aide-icone svg { width: 24px; height: 24px; }
.carte-aide.scellee strong { font-family: Georgia, serif; font-size: 1.05rem; color: var(--accent-vif); }
.carte-aide-expediteur { font-size: 0.82rem; color: var(--texte-attenue); }

.bouton-principal {
  margin-top: 0.7rem;
  background: var(--accent);
  color: var(--accent-texte);
  border: none;
  border-radius: var(--rayon);
  padding: 0.55rem 1.4rem;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: filter 0.15s;
}
.bouton-principal:hover { filter: brightness(1.08); }

@media (prefers-reduced-motion: reduce) {
  .bouton-icone.sonne,
  .bouton-icone.sonne svg,
  .carte-aide.scellee .carte-aide-icone { animation: none; }
}

/* ---------- Modale d'accusation ---------- */

.modale {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modale.masque { display: none; }

#modale-accusation-fond,
#modale-aide-fond {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 4, 0.68);
  backdrop-filter: blur(2px);
  animation: fondu-entree 0.2s ease both;
}
@keyframes fondu-entree { from { opacity: 0; } to { opacity: 1; } }

.modale-contenu {
  position: relative;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #201811, #16110c);
  border: 1px solid var(--bordure-forte);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 1.2rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom));
  box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.6);
  animation: modale-entree 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes modale-entree {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modale-contenu h2 {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
  color: var(--accent-vif);
}
.modale-souligne {
  margin: 0 0 1rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--texte-attenue);
}

#form-accusation {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.champ-accusation {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.accusation-label {
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--texte-attenue);
}

#select-accusation, #select-methode, #input-heure-mort, #input-detail-poison {
  background: rgba(38, 31, 23, 0.85);
  color: var(--texte);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
  padding: 0.6rem 0.7rem;
  font-size: 1rem; /* 16px minimum : évite le zoom automatique d'iOS au focus */
  font-family: system-ui, sans-serif;
}
#select-accusation:focus, #select-methode:focus, #input-heure-mort:focus, #input-detail-poison:focus {
  outline: none;
  border-color: var(--accent);
}

.champ-accusation[hidden] { display: none; }

.modale-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.bouton-discret {
  background: transparent;
  color: var(--texte-attenue);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
  padding: 0.55rem 1rem;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
}
.bouton-discret:hover { color: var(--texte); border-color: var(--texte-attenue); }

#btn-accuser {
  background: var(--accent);
  color: var(--accent-texte);
  border: none;
  border-radius: var(--rayon);
  padding: 0.55rem 1.2rem;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: filter 0.15s;
}
#btn-accuser:disabled { opacity: 0.5; cursor: not-allowed; }
#btn-accuser:hover:not(:disabled) { filter: brightness(1.08); }

#resultat-accusation {
  margin: 0.7rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}
#resultat-accusation.correcte { color: var(--succes); }
#resultat-accusation.incorrecte { color: var(--danger); }
#resultat-accusation.partiel { color: var(--accent-vif); }

.invite-compte {
  margin: 0.45rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--texte-attenue);
}
.invite-compte[hidden] { display: none; }
.invite-compte a { color: var(--accent-vif); white-space: nowrap; }

/* Popin d'invitation a creer un compte (apres une victoire sans compte). Le dialog natif
   se place dans la couche du dessus : il recouvre aussi la modale d'accusation. */
dialog.popin-compte {
  width: min(92vw, 25rem);
  padding: 0; /* le padding est sur le formulaire : un clic dans la marge du dialog fermerait la popin */
  color: var(--texte);
  text-align: center;
  background: linear-gradient(180deg, #201811, #16110c);
  border: 1px solid var(--bordure-forte);
  border-radius: 20px;
  box-shadow: var(--ombre-forte);
  animation: modale-entree 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
dialog.popin-compte::backdrop {
  background: rgba(6, 5, 4, 0.68);
  backdrop-filter: blur(2px);
}
.popin-compte form { padding: 1.7rem 1.4rem 1.3rem; }
.popin-compte-surtitre {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--succes);
}
.popin-compte h2 {
  margin: 0.4rem 0 0;
  font-size: 1.3rem;
  line-height: 1.25;
  color: var(--accent-vif);
}
.popin-compte-texte {
  margin: 0.8rem 0 1.2rem;
  font-family: system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--texte-attenue);
}
.popin-compte-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.popin-compte .bouton-principal {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1.4rem;
  text-align: center;
  text-decoration: none;
}
.popin-compte-lien {
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
  color: var(--accent-vif);
}
@media (prefers-reduced-motion: reduce) {
  dialog.popin-compte { animation: none; }
}

@media (min-width: 640px) {
  #app { margin: 1.2vh auto; height: 97.6dvh; height: 97.6vh; border-radius: 22px; overflow: hidden; }
}

/* ---------- Parchemin de synopsis (ouverture d'une partie) ---------- */

@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/playfair-display-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

.bouton-relire {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.35rem 0.7rem 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--bordure-forte);
  background: rgba(20, 16, 12, 0.55);
  color: var(--accent-vif);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.bouton-relire:hover { border-color: var(--accent); }
a.bouton-relire { text-decoration: none; }
.bouton-relire[hidden] { display: none; }
/* Le pseudo (jusqu'a 30 caracteres, sans espace possible) ne doit jamais faire deborder la pastille. */
#lien-compte-jeu { border-radius: 18px; }
#libelle-compte-jeu { min-width: 0; overflow-wrap: anywhere; }
.bouton-relire svg { width: 17px; height: 17px; flex-shrink: 0; }

.modale-synopsis {
  --hauteur-rouleau: 26px;
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) 1.3rem max(1rem, env(safe-area-inset-bottom));
}
.modale-synopsis.masque { display: none; }

#synopsis-fond {
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 70% at 50% 45%, rgba(24, 14, 6, 0.55), rgba(4, 3, 2, 0.92));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fondu-entree 0.35s ease both;
}

.parchemin {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.6));
  animation: parchemin-apparition 0.5s ease both;
}
@keyframes parchemin-apparition {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* Le papier se révèle de haut en bas pendant que le rouleau du bas descend. */
.parchemin-papier {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  color: #3a2410;
  border-inline: 1px solid rgba(120, 80, 30, 0.35);
  background-image:
    radial-gradient(120% 55% at 50% 0%, rgba(255, 247, 224, 0.75), transparent 62%),
    radial-gradient(ellipse 60% 40% at 12% 92%, rgba(150, 98, 38, 0.24), transparent 70%),
    radial-gradient(ellipse 50% 35% at 92% 52%, rgba(140, 92, 32, 0.18), transparent 70%),
    radial-gradient(ellipse 40% 25% at 70% 8%, rgba(150, 98, 38, 0.14), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .15 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #f4e6c3 0%, #edd8aa 55%, #e3c88f 100%);
  box-shadow: inset 14px 0 20px -12px rgba(110, 70, 25, 0.55), inset -14px 0 20px -12px rgba(110, 70, 25, 0.55);
  clip-path: inset(0 0 100% 0);
  animation: parchemin-deroule 1s cubic-bezier(0.22, 1, 0.36, 1) 0.12s forwards;
}
@keyframes parchemin-deroule {
  to { clip-path: inset(0 0 0 0); }
}

.rouleau {
  position: absolute;
  left: -9px;
  right: -9px;
  z-index: 3;
  height: var(--hauteur-rouleau);
  border-radius: 13px;
  background: linear-gradient(180deg, #f6e6bb 0%, #dcbd7f 28%, #b98d4c 64%, #7b5527 100%);
  box-shadow: 0 5px 9px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.rouleau::before, .rouleau::after {
  content: "";
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, #4f3212, #8c6431 55%, #3f280e);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.rouleau::before { left: -5px; }
.rouleau::after { right: -5px; }
.rouleau-haut { top: 0; }
.rouleau-bas {
  top: calc(100% - var(--hauteur-rouleau));
  animation: rouleau-descend 1s cubic-bezier(0.22, 1, 0.36, 1) 0.12s backwards;
}
@keyframes rouleau-descend {
  from { top: 0; }
}

/* Seul le texte défile : le bouton reste visible même sur un écran court. */
.parchemin-contenu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: calc(var(--hauteur-rouleau) + 1.5rem) 1.5rem 0.2rem;
  scrollbar-width: thin;
  scrollbar-color: #b58a4a transparent;
  animation: fondu-entree 0.5s ease 0.55s both;
}
.parchemin-pied {
  flex: none;
  padding: 0.5rem 1.5rem calc(var(--hauteur-rouleau) + 1.1rem);
  animation: fondu-entree 0.5s ease 0.55s both;
}

.synopsis-surtitre {
  margin: 0;
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #7a1a20;
}

#synopsis-titre {
  margin: 0.35rem 0 0;
  text-align: center;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.55rem, 7vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  color: #2b170a;
  text-wrap: balance;
}

.synopsis-ornement {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: 220px;
  margin: 0.8rem auto 1.1rem;
  color: #9a6b2e;
}
.synopsis-ornement::before, .synopsis-ornement::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor);
}
.synopsis-ornement::after { background: linear-gradient(270deg, transparent, currentColor); }
.synopsis-ornement i {
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  transform: rotate(45deg);
}

#synopsis-texte p {
  margin: 0 0 0.85rem;
  font-size: 1.02rem;
  line-height: 1.65;
  hyphens: auto;
}
#synopsis-texte p:first-child::first-letter {
  float: left;
  padding: 0.16rem 0.5rem 0 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 0.82;
  color: #7a1a20;
}

#btn-commencer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1.2rem;
  border: 1.5px solid #c9a25a;
  border-radius: 12px;
  background: linear-gradient(180deg, #86202a 0%, #65101a 55%, #520a10 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 3px rgba(0, 0, 0, 0.14), 0 6px 14px rgba(82, 10, 16, 0.32);
  color: #f3e3bd;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
#btn-commencer:hover { filter: brightness(1.1); transform: translateY(-2px); }
#btn-commencer:active { transform: translateY(0); }
#btn-commencer:focus-visible { outline: 3px solid #7a1a20; outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  #synopsis-fond, .parchemin, .parchemin-papier, .rouleau-bas, .parchemin-contenu, .parchemin-pied { animation: none; }
  .parchemin-papier { clip-path: none; }
  #btn-commencer { transition: none; }
}
