/* ===== Le Grand Cerfa ===== */
:root {
  --pixel: "Press Start 2P", "Courier New", monospace;
  --px: 3px; /* taille d'un pixel des personnages */
  --cadre: #0b1040;
  --papier: #f8f6ee;
  --encre: #1b1433;
  --pv-ok: #3ccf7e;
  --pv-moyen: #f2b33d;
  --pv-bas: #f0506e;
}

@media (min-width: 640px) {
  :root {
    --px: 4px;
  }
}

.cf {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 16px 16px;
}

.ecran {
  display: none;
}

.ecran.is-on {
  display: block;
  animation: apparait 0.35s ease;
}

@keyframes apparait {
  from {
    opacity: 0;
    translate: 0 10px;
  }
}

/* Types d'attaque */
.type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.type--liberte {
  background: #3b5bdb;
}

.type--savoir {
  background: #1f8a7a;
}

.type--proximite {
  background: #c0392b;
}

.type--energie {
  background: #b36f08;
}

.type--soutien {
  background: #5d6378;
}

/* Bouton façon jeu vidéo */
.btn-pixel {
  display: inline-block;
  margin: 8px auto 0;
  padding: 16px 28px;
  border: 0;
  border-radius: 4px;
  background: var(--ne-chamois);
  color: var(--ne-blue-dark);
  font: 1rem/1 var(--pixel);
  text-transform: uppercase;
  box-shadow: 0 6px 0 #6f6c4a, 0 12px 24px -8px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-pixel:hover {
  filter: brightness(1.06);
}

.btn-pixel:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #6f6c4a, 0 6px 14px -8px rgba(0, 0, 0, 0.6);
}

/* Écran titre */
#ecran-titre,
#ecran-intro,
#ecran-fin {
  text-align: center;
}

.cf-titre {
  margin: 14px 0 12px;
  font: 1.6rem/1.35 var(--pixel);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 4px 0 #0b1040;
}

.cf-titre span {
  display: block;
  font-size: 2.9rem;
  color: var(--ne-chamois);
  text-shadow: 0 5px 0 #0b1040, 0 0 30px rgba(176, 173, 133, 0.35);
}

.cf-accroche {
  max-width: 520px;
  margin: 0 auto 6px;
  color: var(--on-bg-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.cf-accroche strong {
  color: var(--on-bg);
}

.cf-equipe {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 18px 0 14px;
}

.cf-equipe figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cf-equipe figcaption {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--on-bg-muted);
}

.cf-equipe .vedette figcaption {
  color: var(--ne-chamois);
}

.cf-equipe canvas {
  animation: respire 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.4s);
}

@keyframes respire {
  50% {
    translate: 0 -4px;
  }
}

.cf-record {
  margin: 16px 0 0;
  color: var(--ne-chamois);
  font-size: 0.85rem;
  font-weight: 800;
}

.cf-regles {
  max-width: 520px;
  margin: 18px auto 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  text-align: left;
}

.cf-regles summary {
  font-weight: 800;
  cursor: pointer;
}

.cf-regles ul {
  margin: 10px 0 2px;
  padding-left: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
}

canvas.pixels {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* Présentation du fléau */
.cf-etape {
  margin: 10px 0 0;
  color: var(--ne-chamois);
  font: 0.7rem/1.4 var(--pixel);
  text-transform: uppercase;
}

.intro-sprite {
  display: flex;
  justify-content: center;
  margin: 14px 0 6px;
}

.intro-sprite canvas {
  animation: menace 1.6s ease-in-out infinite;
}

@keyframes menace {
  50% {
    scale: 1.04;
    rotate: -2deg;
  }
}

.cf-nom {
  margin: 6px 0 8px;
  font: 1.15rem/1.4 var(--pixel);
}

.intro-texte {
  max-width: 480px;
  margin: 0 auto 10px;
  font-size: 0.98rem;
  line-height: 1.5;
}

.intro-types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--on-bg-muted);
}

.bulle-david {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--papier);
  color: var(--encre);
  text-align: left;
}

.bulle-david-tete {
  flex: none;
}

.bulle-david p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Scène de combat */
.scene {
  position: relative;
  height: clamp(250px, 58vw, 380px);
  overflow: hidden;
  border-radius: 10px;
  border: 4px solid var(--cadre);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15), 0 20px 40px -16px rgba(0, 0, 0, 0.7);
  background: linear-gradient(180deg, #cfe0f5 0%, #e8eef8 56%, #b9a98a 56%, #a8987a 100%);
  image-rendering: pixelated;
}

/* Décors */
.scene[data-decor="bureau"] {
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 0, 0, 0.05) 46px 48px) 0 0 / 100% 56% no-repeat,
    linear-gradient(180deg, #f1e3c6 0%, #e7d5b0 56%, #9c7c55 56%, #8a6b46 100%);
}

.scene[data-decor="archives"] {
  background:
    repeating-linear-gradient(180deg, transparent 0 34px, #6e4420 34px 38px) 0 0 / 100% 56% no-repeat,
    repeating-linear-gradient(90deg, #c9b48a 0 14px, #b59c6c 14px 16px, #d8c49a 16px 26px, #a88a58 26px 28px) 0 0 / 100% 56% no-repeat,
    linear-gradient(180deg, #000 0 56%, #6b5537 56%, #5a462c 100%);
}

.scene[data-decor="couloir"] {
  background:
    radial-gradient(ellipse 18% 10% at 25% 6%, rgba(255, 255, 220, 0.5), transparent),
    radial-gradient(ellipse 18% 10% at 75% 6%, rgba(255, 255, 220, 0.35), transparent),
    linear-gradient(180deg, #5f6f68 0%, #7b8a82 56%, #3e4741 56%, #2f3631 100%);
}

.scene[data-decor="salle"] {
  background:
    repeating-linear-gradient(90deg, #3d6fb5 0 22px, #2d5a99 22px 24px, transparent 24px 34px) 0 48% / 100% 9% no-repeat,
    linear-gradient(180deg, #dfe7ef 0%, #c8d3de 56%, #8e9aa6 56%, #7a8693 100%);
}

.scene[data-decor="nuit"] {
  background:
    radial-gradient(circle at 80% 18%, rgba(242, 194, 48, 0.35) 0 3%, transparent 3.4%),
    radial-gradient(circle at 18% 12%, #ffffff 0 0.4%, transparent 0.6%),
    radial-gradient(circle at 42% 22%, #ffffff 0 0.3%, transparent 0.5%),
    radial-gradient(circle at 64% 8%, #ffffff 0 0.3%, transparent 0.5%),
    linear-gradient(180deg, #1a1036 0%, #33205e 56%, #1c1430 56%, #120c22 100%);
}

.scene[data-decor="ministere"] {
  background:
    linear-gradient(90deg, transparent 0 46%, #8d1c2c 46% 54%, transparent 54%) 0 100% / 100% 44% no-repeat,
    repeating-linear-gradient(90deg, transparent 0 60px, rgba(242, 194, 48, 0.25) 60px 64px) 0 0 / 100% 56% no-repeat,
    linear-gradient(180deg, #3a1020 0%, #5c1a2c 56%, #2a2030 56%, #1b1422 100%);
}

.socle {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.socle::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  z-index: 0;
  width: 150%;
  height: 26px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.socle--fleau {
  right: 9%;
  top: 30%;
  translate: 0 -50%;
}

.socle--heros {
  left: 9%;
  bottom: 8%;
}

.sprite {
  position: relative;
  z-index: 1;
}

.sprite canvas {
  display: block;
}

/* Les citoyens regardent vers le fléau, à droite. */
#sprite-heros canvas {
  transform: scaleX(1);
}

/* Cartes de PV */
.carte {
  position: absolute;
  z-index: 2;
  width: min(48%, 290px);
  padding: 8px 10px 7px;
  border-radius: 8px 8px 8px 0;
  background: var(--papier);
  color: var(--encre);
  border: 3px solid var(--cadre);
  box-shadow: 4px 4px 0 rgba(11, 16, 64, 0.35);
}

.carte--fleau {
  top: 10px;
  left: 10px;
}

.carte--heros {
  right: 10px;
  bottom: 12px;
  border-radius: 8px 8px 0 8px;
}

.carte-nom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 6px;
  font: 0.6rem/1.35 var(--pixel);
}

.carte-nom small {
  flex: none;
  font: inherit;
  font-size: 0.55rem;
  color: #4a5068;
}

.pv {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pv-label {
  padding: 2px 4px;
  border-radius: 3px;
  background: #e8a33d;
  color: #3b2200;
  font: 0.45rem/1 var(--pixel);
}

.pv-barre {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #3a3f58;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.pv-barre i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--pv-ok);
  transition: width 0.6s ease, background-color 0.3s ease;
}

.pv-barre i.moyen {
  background: var(--pv-moyen);
}

.pv-barre i.bas {
  background: var(--pv-bas);
}

.carte-chiffres {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin: 5px 0 0;
  font: 0.55rem/1.3 var(--pixel);
}

.carte-statuts {
  margin: 4px 0 0;
  min-height: 0;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 800;
  color: #8a2c3a;
}

.carte-chiffres .carte-statuts {
  margin: 0;
}

.carte-statuts:empty {
  display: none;
}

/* Animations de combat */
.sprite.elan-heros {
  animation: elan-heros 0.4s ease;
}

.sprite.elan-fleau {
  animation: elan-fleau 0.4s ease;
}

.sprite.touche {
  animation: touche 0.5s steps(2, jump-none) 1, secousse 0.4s ease;
}

.sprite.soin {
  animation: soin 0.8s ease;
}

.sprite.ko {
  animation: ko 0.7s ease forwards;
}

.sprite.entree-heros {
  animation: entree-heros 0.45s ease;
}

.sprite.entree-fleau {
  animation: entree-fleau 0.6s ease;
}

.sprite.enerve canvas {
  filter: drop-shadow(0 0 8px rgba(240, 80, 110, 0.9)) saturate(1.3);
}

@keyframes elan-heros {
  40% {
    translate: 34px -18px;
  }
}

@keyframes elan-fleau {
  40% {
    translate: -34px 18px;
  }
}

@keyframes touche {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.15;
  }
}

@keyframes secousse {
  20%,
  60% {
    translate: -6px 0;
  }
  40%,
  80% {
    translate: 6px 0;
  }
}

@keyframes soin {
  40% {
    filter: drop-shadow(0 0 12px #3ccf7e) brightness(1.25);
  }
}

@keyframes ko {
  to {
    translate: 0 40px;
    opacity: 0;
  }
}

@keyframes entree-heros {
  from {
    translate: -140px 0;
  }
}

@keyframes entree-fleau {
  from {
    translate: 140px 0;
    opacity: 0;
  }
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}

.flash.is-on {
  animation: flash 0.35s ease;
}

@keyframes flash {
  30% {
    opacity: 0.75;
  }
}

.flottants {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.flottant {
  position: absolute;
  translate: -50% 0;
  font: 1.1rem/1 var(--pixel);
  color: #ffffff;
  text-shadow: 3px 3px 0 #b0124f, -1px -1px 0 #b0124f;
  animation: monte-chiffre 1.1s ease-out forwards;
}

.flottant.soin {
  text-shadow: 3px 3px 0 #137a4b, -1px -1px 0 #137a4b;
}

.flottant.critique {
  font-size: 1.45rem;
  color: #f2c230;
}

@keyframes monte-chiffre {
  0% {
    opacity: 0;
    translate: -50% 10px;
    scale: 0.6;
  }
  15% {
    opacity: 1;
    scale: 1.15;
  }
  100% {
    opacity: 0;
    translate: -50% -46px;
    scale: 1;
  }
}

/* David entre en scène */
.david-entree {
  position: absolute;
  left: 50%;
  bottom: 8%;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  translate: -50% 0;
}

.david-entree.is-on {
  display: flex;
  animation: david 2.6s ease forwards;
}

.david-entree .bulle {
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--papier);
  color: var(--encre);
  border: 3px solid var(--cadre);
  font: 0.6rem/1.5 var(--pixel);
  text-align: center;
}

@keyframes david {
  0% {
    translate: -260% 0;
  }
  18%,
  82% {
    translate: -50% 0;
  }
  100% {
    translate: 260% 0;
  }
}

/* Pupitre : messages et menu */
.pupitre {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--papier);
  color: var(--encre);
  border: 4px solid var(--cadre);
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.7);
}

.message {
  min-height: 3.1em;
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}

.message.attend::after {
  content: " ▼";
  font-size: 0.7rem;
  color: #6b7080;
  animation: clignote 0.9s steps(2, jump-none) infinite;
}

@keyframes clignote {
  50% {
    opacity: 0;
  }
}

.menu.en-attente {
  visibility: hidden;
}

.attaques {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.attaque {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 64px;
  padding: 9px 10px;
  border: 2px solid var(--cadre);
  border-radius: 8px;
  background: #ffffff;
  color: var(--encre);
  text-align: left;
  box-shadow: 0 3px 0 var(--cadre);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.attaque:hover:not(:disabled) {
  background: #eef0fb;
}

.attaque:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--cadre);
}

.attaque:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.attaque-nom {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.2;
}

.attaque-infos {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a5068;
}

.attaque-infos .efficace {
  color: #137a4b;
  font-weight: 900;
}

.attaque-infos .faible {
  color: #8a2c3a;
}

.menu-bas {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  margin-top: 8px;
}

.btn-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--cadre);
  border-radius: 8px;
  background: #e6e8f3;
  color: var(--encre);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--cadre);
}

.btn-menu:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: none;
}

.btn-david {
  position: relative;
  overflow: hidden;
  background: #d8d6c4;
}

.btn-david:disabled {
  cursor: not-allowed;
  color: #5d6378;
}

.btn-david .jauge {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.btn-david .jauge i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #c9c59a, var(--ne-chamois));
  transition: width 0.6s ease;
}

.btn-david span:last-child {
  position: relative;
  z-index: 1;
}

.btn-david.prete {
  background: var(--ne-blue);
  color: #ffffff;
  animation: pret 1s ease-in-out infinite;
}

.btn-david.prete .jauge i {
  background: linear-gradient(90deg, var(--ne-blue), var(--ne-indigo));
}

@keyframes pret {
  50% {
    box-shadow: 0 3px 0 var(--cadre), 0 0 0 4px rgba(176, 173, 133, 0.7);
  }
}

/* Choix du citoyen */
.choix-titre {
  margin: 0 0 8px;
  font-weight: 800;
}

.choix-liste {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.choix {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 2px solid var(--cadre);
  border-radius: 8px;
  background: #ffffff;
  color: var(--encre);
  text-align: left;
  box-shadow: 0 3px 0 var(--cadre);
}

.choix:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.choix.actif {
  background: #eef0fb;
}

.choix canvas {
  flex: none;
}

.choix b {
  display: block;
  font-size: 0.88rem;
}

.choix small {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a5068;
}

/* Fin */
.fin-tete {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.fin-texte {
  max-width: 500px;
  margin: 0 auto 14px;
  font-size: 0.98rem;
  line-height: 1.5;
}

.fin-score {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 440px;
  margin: 0 auto 16px;
}

.fin-score div {
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}

.fin-score b {
  display: block;
  font: 1.05rem/1.3 var(--pixel);
  color: var(--ne-chamois);
}

.fin-score span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--on-bg-muted);
}

.fin-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.fin-partage {
  max-width: 440px;
  margin: 0 auto 18px;
  text-align: left;
}

.fin-partage h3 {
  margin: 0 0 8px;
  color: var(--ne-chamois);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fin-vrai {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}

.fin-vrai p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.fin-lien {
  color: var(--ne-chamois-light);
  font-size: 0.85rem;
  font-weight: 800;
}

@media (max-width: 480px) {
  .cf-titre {
    font-size: 1.15rem;
  }

  .cf-titre span {
    font-size: 2.1rem;
  }

  .carte {
    width: min(56%, 290px);
    padding: 6px 8px 5px;
  }

  .carte-nom {
    font-size: 0.5rem;
  }

  .carte-nom small {
    font-size: 0.45rem;
  }

  .socle--fleau {
    right: 5%;
    top: 34%;
  }

  .socle--heros {
    left: 5%;
  }

  .attaque {
    min-height: 58px;
    padding: 7px 8px;
  }

  .attaque-nom {
    font-size: 0.82rem;
  }

  .attaque-infos .mot {
    display: none;
  }

  .attaque-infos .efficace,
  .attaque-infos .faible {
    font-size: 0.9rem;
  }

  .message {
    font-size: 0.9rem;
  }
}
