:root {
  /* Plan : en haut, le ciel et le village (une maison par joueur, fenêtre allumée tant qu'il est en vie) ;
     dessous, la parole du conteur en grand ; puis un seul panneau d'action. Colonne unique, alignée à gauche.
     Le thème suit la partie : nuit bleue, jour de brume. */
  --fond: #0e1426;
  --carte: #17203a;
  --trait: #2c3859;
  --texte: #e8ebf3;
  --sourd: #9aa4bd;
  --lanterne: #e7c787;
  --sur-lanterne: #1d1606;
  --garance: #e58374;
  --sauge: #98bda5;
  --rose: #e2a0b2;
  --conte: 'IM Fell English', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --capitales: 'IM Fell English SC', 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --interface: 'Hanken Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
:root[data-moment="jour"] {
  --fond: #e8edeb;
  --carte: #f7f9f7;
  --trait: #c7d1d0;
  --texte: #1a2430;
  --sourd: #566272;
  --lanterne: #1f4a5e;
  --sur-lanterne: #f3f8f8;
  --garance: #a8392d;
  --sauge: #2f6249;
  --rose: #a34664;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 400 16px/1.45 var(--interface);
  -webkit-text-size-adjust: 100%;
  transition: background-color 1.6s ease, color 1.6s ease;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--lanterne); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#app {
  position: relative;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- le ciel ---------- */
.ciel { position: relative; flex: none; height: 150px; transition: height .5s ease; }
:root[data-ecran="accueil"] .ciel { height: 212px; }
#ciel { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ciel-haut {
  position: absolute; inset: 0 0 auto 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 0 16px;
}
#jalon { font: 400 17px/1 var(--capitales); letter-spacing: .04em; color: #eef1f7; text-shadow: 0 1px 8px rgba(8, 12, 30, .55); }
:root[data-moment="jour"] #jalon { color: #1a2430; text-shadow: 0 1px 8px rgba(255, 255, 255, .6); }
.outils { display: flex; gap: 2px; }
.outil {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: #eef1f7;
}
:root[data-moment="jour"] .outil { color: #1a2430; }
.outil:hover { background: rgba(255, 255, 255, .1); }
.titre-accueil {
  position: absolute; left: 16px; top: 46px;
  font: 400 clamp(40px, 11.5vw, 56px)/.95 var(--conte);
  color: #f3efe4; letter-spacing: -.01em;
  text-shadow: 0 2px 18px rgba(8, 12, 30, .5);
}

/* ---------- le corps ---------- */
#corps > * { flex-shrink: 0; }
#corps { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 22px; display: flex; flex-direction: column; gap: 18px; }

.conte { min-height: 5.4em; }
.parole {
  font: 400 clamp(20px, 5.4vw, 24px)/1.32 var(--conte);
  text-wrap: pretty;
  max-width: 30em;
  animation: venir .7s ease both;
}
.onde { display: flex; align-items: center; gap: 8px; margin-top: 10px; height: 16px; color: var(--sourd); font-size: 13px; visibility: hidden; }
.onde.parle { visibility: visible; }
.onde i { display: block; width: 3px; height: 4px; border-radius: 2px; background: var(--lanterne); }
.onde.parle i { animation: battre 1s ease-in-out infinite; }
.onde.parle i:nth-child(2) { animation-delay: .18s; }
.onde.parle i:nth-child(3) { animation-delay: .36s; }
.barres { display: flex; align-items: center; gap: 3px; height: 16px; }
@keyframes battre { 0%, 100% { height: 4px; } 50% { height: 15px; } }
@keyframes venir { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.aparte {
  border-left: 3px solid var(--lanterne); padding: 8px 12px; background: var(--carte);
  font-size: 15px; border-radius: 0 8px 8px 0;
}
.aparte b { font-weight: 600; }

.panneau { display: flex; flex-direction: column; gap: 14px; }
.panneau h2 { font: 400 26px/1.1 var(--capitales); letter-spacing: .02em; text-wrap: balance; }
.panneau .consigne { color: var(--sourd); max-width: 34em; }
.panneau .consigne strong { color: var(--texte); font-weight: 600; }
.petit { font-size: 13.5px; color: var(--sourd); }

.sablier { height: 3px; background: var(--trait); border-radius: 2px; overflow: hidden; }
.sablier i { display: block; height: 100%; width: 100%; background: var(--lanterne); transform-origin: left center; }
.sablier.presse i { background: var(--garance); }

/* ---------- joueurs ---------- */
.liste { display: flex; flex-direction: column; border-top: 1px solid var(--trait); }
.joueur {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 6px; min-height: 56px;
  background: none; border: 0; border-bottom: 1px solid var(--trait);
  text-align: left;
}
button.joueur:hover { background: color-mix(in srgb, var(--lanterne) 7%, transparent); }
.joueur[aria-pressed="true"] { background: var(--carte); box-shadow: inset 3px 0 0 var(--lanterne); }
.joueur:disabled { opacity: .45; cursor: default; }
.pastille {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--trait); font: 400 17px/1 var(--capitales);
}
.joueur .nom { font-weight: 500; }
.joueur .infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.joueur .sous { font-size: 13.5px; color: var(--sourd); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.joueur .droite { flex: none; display: flex; align-items: center; gap: 6px; color: var(--sourd); font-size: 13.5px; }
.joueur.mort .nom { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--sourd); }
.joueur.mort .pastille { opacity: .5; }
.marque { display: inline-flex; align-items: center; gap: 4px; }
.marque.loups { color: var(--garance); }
.marque.amour { color: var(--rose); }
.marque.cap { color: var(--lanterne); }
.marque.su { color: var(--sauge); }
.coche { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--trait); display: grid; place-items: center; color: transparent; }
[aria-pressed="true"] .coche { background: var(--lanterne); border-color: var(--lanterne); color: var(--sur-lanterne); }
.coche .ico, .reglage .coche .ico { color: inherit; }
.meutiers { display: flex; gap: 4px; }
.meutiers span { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--garance); color: var(--fond); font-size: 12.5px; font-weight: 600; display: grid; place-items: center; }

.jetons { display: flex; flex-wrap: wrap; gap: 8px; }
.jeton {
  padding: 9px 14px; border-radius: 22px; border: 1px solid var(--trait); background: none; font-weight: 500;
}
.jeton[aria-pressed="true"] { background: var(--lanterne); border-color: var(--lanterne); color: var(--sur-lanterne); }

/* ---------- boutons ---------- */
.bouton {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 13px 18px;
  border: 0; border-radius: 10px;
  background: var(--lanterne); color: var(--sur-lanterne);
  font-weight: 600; font-size: 16.5px;
  transition: transform .12s ease, opacity .2s;
}
.bouton:active { transform: scale(.985); }
.bouton:disabled { background: none; color: var(--sourd); box-shadow: inset 0 0 0 1px var(--trait); cursor: default; }
.bouton.discret { background: none; color: var(--texte); border: 1px solid var(--trait); font-weight: 500; }
.bouton.danger { background: var(--garance); color: var(--fond); }
.actions { display: flex; flex-direction: column; gap: 10px; }
.lien { background: none; border: 0; padding: 6px 0; color: var(--lanterne); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; text-align: left; }

/* ---------- carte de rôle ---------- */
.carte-role {
  position: relative; border: 1px solid var(--trait); border-radius: 14px; background: var(--carte);
  padding: 24px 22px; display: flex; flex-direction: column; gap: 10px; min-height: 230px; width: 100%; text-align: left;
}
.carte-role .ico { color: var(--lanterne); }
.carte-role.loups .ico, .carte-role.loups .camp { color: var(--garance); }
.carte-role h3 { font: 400 34px/1 var(--capitales); letter-spacing: .02em; }
.carte-role .camp { font-size: 14px; font-weight: 600; color: var(--sauge); }
.carte-role .pouvoir { font-size: 16px; max-width: 30em; }
.carte-role.dos {
  justify-content: center; align-items: center; text-align: center; color: var(--sourd);
  background:
    repeating-linear-gradient(45deg, transparent 0 9px, color-mix(in srgb, var(--lanterne) 9%, transparent) 9px 10px),
    repeating-linear-gradient(-45deg, transparent 0 9px, color-mix(in srgb, var(--lanterne) 9%, transparent) 9px 10px),
    var(--carte);
}
.carte-role.dos .ico { color: var(--lanterne); }
.carte-role.dos strong { font: 400 22px/1.1 var(--capitales); color: var(--texte); }

.encart { border: 1px solid var(--trait); border-radius: 12px; padding: 16px; display: flex; gap: 14px; align-items: flex-start; background: var(--carte); }
.encart .ico { flex: none; color: var(--lanterne); }
.encart.loups .ico { color: var(--garance); }
.encart.amour .ico { color: var(--rose); }
.encart p + p { margin-top: 6px; }
.encart .gros { font: 400 22px/1.2 var(--conte); }

/* ---------- vote ---------- */
.urne { display: flex; flex-direction: column; gap: 12px; }
.voix-ligne { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; }
.voix-ligne .qui { font-weight: 600; }
.voix-ligne .nb { font-variant-numeric: tabular-nums; font-weight: 600; }
.voix-ligne .jauge { grid-column: 1 / -1; height: 6px; background: var(--trait); border-radius: 3px; overflow: hidden; }
.voix-ligne .jauge i { display: block; height: 100%; background: var(--sourd); border-radius: 3px; }
.voix-ligne.tete .jauge i { background: var(--garance); }
.urne.election .voix-ligne.tete .jauge i { background: var(--lanterne); }
.voix-ligne .de { grid-column: 1 / -1; font-size: 13.5px; color: var(--sourd); }
.sentence { padding: 12px 14px; border-left: 3px solid var(--garance); background: var(--carte); border-radius: 0 8px 8px 0; }
.sentence strong { font-weight: 600; }

.deces { display: flex; flex-direction: column; border-top: 1px solid var(--trait); }
.deces .joueur { animation: venir .6s ease both; }

.minuteur { font: 500 46px/1 var(--interface); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.propos { display: flex; flex-direction: column; gap: 10px; }
.propos p { padding-left: 12px; border-left: 2px solid var(--trait); animation: venir .5s ease both; }
.propos b { font-weight: 600; }

/* ---------- pied ---------- */
#pied { flex: none; display: flex; border-top: 1px solid var(--trait); background: var(--fond); transition: background-color 1.6s ease; }
#pied button {
  flex: 1; min-height: 54px; background: none; border: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14.5px; font-weight: 500; color: var(--sourd);
}
#pied button:hover { color: var(--texte); }
#pied button + button { border-left: 1px solid var(--trait); }

/* ---------- feuille ---------- */
#voile { position: absolute; inset: 0; background: rgba(5, 8, 20, .55); z-index: 5; animation: fondre .25s ease both; }
#feuille {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; max-height: 86%;
  display: flex; flex-direction: column;
  background: var(--carte); border-radius: 18px 18px 0 0; border-top: 1px solid var(--trait);
  animation: monter .3s cubic-bezier(.2, .8, .2, 1) both;
}
.feuille-tete { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; }
.feuille-tete h2 { font: 400 24px/1.1 var(--capitales); letter-spacing: .02em; }
.feuille-tete .outil { color: var(--texte); }
.feuille-corps { overflow-y: auto; padding: 6px 18px 24px; display: flex; flex-direction: column; gap: 16px; }
.feuille-corps .carte-role { background: var(--fond); }
.fil { display: flex; flex-direction: column; gap: 14px; }
.fil h3 { font: 400 18px/1.2 var(--capitales); letter-spacing: .03em; color: var(--lanterne); }
.fil p { max-width: 36em; }
.fil.recit p { font: 400 18px/1.36 var(--conte); }
.fil ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.regles dl { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.regles dt { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.regles dd { margin: 2px 0 0; color: var(--sourd); }
.regles ul { margin: 0; padding-left: 18px; color: var(--sourd); display: flex; flex-direction: column; gap: 6px; }
@keyframes monter { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fondre { from { opacity: 0; } to { opacity: 1; } }

/* ---------- accueil ---------- */
.accueil { display: flex; flex-direction: column; gap: 26px; }
.chapo { font: 400 20px/1.32 var(--conte); max-width: 26em; text-wrap: pretty; }
.maquette { font-size: 14.5px; color: var(--sourd); border-left: 3px solid var(--lanterne); padding: 2px 0 2px 12px; max-width: 36em; }
.bloc { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.bloc > legend, .bloc > h2 { font: 400 23px/1.1 var(--capitales); letter-spacing: .02em; padding: 0; margin-bottom: 6px; }
.reglage { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--trait); min-height: 56px; }
.reglage.colonne { flex-direction: column; align-items: stretch; gap: 8px; }
.reglage .libelle { display: flex; flex-direction: column; min-width: 0; }
.reglage .libelle span { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.reglage .libelle small { font-size: 13.5px; color: var(--sourd); }
.reglage .ico { color: var(--lanterne); flex: none; }
.reglage.loups .ico { color: var(--garance); }
.champ {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--trait); background: var(--carte);
}
.champ.court { width: 11em; }
select.champ { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--sourd) 50%), linear-gradient(135deg, var(--sourd) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
.pas { display: flex; align-items: center; gap: 4px; }
.pas button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--trait); background: none; font-size: 22px; line-height: 1; display: grid; place-items: center; }
.pas button:disabled { opacity: .35; cursor: default; }
.pas output { min-width: 2.2em; text-align: center; font: 500 22px/1 var(--interface); font-variant-numeric: tabular-nums; }
.bascule { flex: none; position: relative; width: 50px; height: 30px; border-radius: 15px; border: 1px solid var(--trait); background: none; padding: 0; transition: background-color .2s; }
.bascule::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--sourd); transition: transform .2s, background-color .2s; }
.bascule[aria-checked="true"] { background: var(--lanterne); border-color: var(--lanterne); }
.bascule[aria-checked="true"]::after { transform: translateX(20px); background: var(--sur-lanterne); }
.segments { display: flex; border: 1px solid var(--trait); border-radius: 8px; overflow: hidden; }
.segments button { flex: 1; min-height: 44px; padding: 8px 6px; background: none; border: 0; font-size: 14.5px; font-weight: 500; color: var(--sourd); }
.segments button + button { border-left: 1px solid var(--trait); }
.segments button[aria-pressed="true"] { background: var(--lanterne); color: var(--sur-lanterne); }
.segments button:disabled { opacity: .4; cursor: default; }
.alerte { color: var(--garance); font-size: 14.5px; }
.lancer { position: sticky; bottom: -22px; margin: 0 -16px -22px; padding: 14px 16px 18px; background: linear-gradient(to top, var(--fond) 72%, transparent); }

/* ---------- fin ---------- */
.verdict h2 { font: 400 clamp(34px, 10vw, 44px)/1 var(--conte); letter-spacing: -.01em; }
.verdict .issue { font-weight: 600; margin-top: 8px; }
.verdict .issue.gagne { color: var(--sauge); }
.verdict .issue.perd { color: var(--garance); }
details.fil-partie { border-top: 1px solid var(--trait); padding-top: 12px; }
details.fil-partie summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details.fil-partie .fil { margin-top: 12px; }

.toast { position: absolute; left: 16px; right: 16px; bottom: 70px; z-index: 7; padding: 12px 14px; border-radius: 10px; background: var(--texte); color: var(--fond); font-size: 14.5px; animation: venir .3s ease both; }

@media (min-width: 560px) {
  #app { border-left: 1px solid var(--trait); border-right: 1px solid var(--trait); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.actions.colle { position: sticky; bottom: -22px; margin: 0 -16px -22px; padding: 14px 16px 18px; background: linear-gradient(to top, var(--fond) 74%, transparent); }

/* les chiffres de la police de conte se lisent mal (le 1 ressemble à un I) : on les compose dans la police d'interface */
.chiffre { font-family: var(--interface); font-size: .86em; font-weight: 500; letter-spacing: 0; }

.recits .joueur:last-child { border-bottom: 0; }
.recits .joueur .sous { display: block; }
.apercu { font: 400 18.5px/1.36 var(--conte); border-left: 3px solid var(--lanterne); padding: 2px 0 2px 12px; max-width: 30em; text-wrap: pretty; }

/* ---------- ajouts de la version serveur ---------- */
@font-face { font-family: 'IM Fell English'; font-style: normal; font-weight: 400; font-display: swap; src: url(polices/im-fell-english.woff2) format('woff2'); }
@font-face { font-family: 'IM Fell English SC'; font-style: normal; font-weight: 400; font-display: swap; src: url(polices/im-fell-english-sc.woff2) format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url(polices/hanken-grotesk-400.woff2) format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url(polices/hanken-grotesk-500.woff2) format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url(polices/hanken-grotesk-600.woff2) format('woff2'); }

/* installée sur l'écran d'accueil d'un iPhone, l'appli s'étend sous la barre d'état et jusqu'en bas */
.ciel { height: calc(150px + env(safe-area-inset-top, 0px)); }
:root[data-ecran="accueil"] .ciel { height: calc(212px + env(safe-area-inset-top, 0px)); }
.ciel-haut { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.titre-accueil { top: calc(46px + env(safe-area-inset-top, 0px)); }
#pied { padding-bottom: env(safe-area-inset-bottom, 0px); }

#bandeau {
  flex: none; padding: 8px 16px; background: var(--garance); color: var(--fond);
  font-size: 14px; font-weight: 600; text-align: center;
}

.invitation { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.invitation strong { color: var(--texte); font-weight: 600; }
.grand-code { font: 400 clamp(60px, 21vw, 88px)/1 var(--conte); letter-spacing: .1em; color: var(--lanterne); }
.champ.code { width: 7em; text-transform: uppercase; letter-spacing: .28em; font-weight: 600; font-size: 20px; text-align: center; padding-left: calc(12px + .28em); }
.joueur.absent .nom { color: var(--sourd); }
.joueur.absent .pastille { opacity: .5; }
span.jeton { display: inline-flex; align-items: center; gap: 6px; }
span.jeton .ico { color: var(--lanterne); }
.encart .actions { margin-top: 12px; }
.salon .lancer { display: flex; flex-direction: column; gap: 10px; }
.accueil > .actions { align-items: flex-start; }
.aparte .lien { padding: 0; font-size: inherit; }

/* l'écran du conteur, sur une tablette ou un ordinateur : plus large, parole plus grande */
:root[data-conteur="oui"] #app { max-width: 880px; }
@media (min-width: 700px) {
  :root[data-conteur="oui"]:not([data-ecran="accueil"]) .ciel { height: 230px; }
  :root[data-conteur="oui"] #corps { padding: 28px 36px 32px; gap: 26px; }
  :root[data-conteur="oui"] .parole { font-size: 36px; line-height: 1.26; max-width: 22em; }
  :root[data-conteur="oui"] .panneau h2 { font-size: 34px; }
  :root[data-conteur="oui"] .jeton { font-size: 19px; padding: 10px 18px; }
  :root[data-conteur="oui"] .grand-code { font-size: 120px; }
}
