@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: 'Courier Prime';
  src: url('/fonts/courier-prime-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* Tokens: carbon-paper night, kraft envelope, wax seal */
:root {
  --carbone: #161c4f;
  --carbone-2: #1f2766;
  --carbone-3: #2f3988;
  --papier: #f1ece0;
  --papier-press: #ddd5c3;
  --papier-dim: #aab0d8;
  --kraft: #b8895a;
  --kraft-dark: #9b6e42;
  --cire: #c32a2a;
  --cire-dark: #9e1f1f;
  --encre: #17140f;
  --erreur: #ffb3a8;

  --font: 'Archivo', system-ui, -apple-system, sans-serif;
  --font-typed: 'Courier Prime', 'Courier New', monospace;

  --r-paper: 4px;
  --r-ctl: 12px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--carbone);
  color: var(--papier);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: max(var(--s-4), env(safe-area-inset-top)) max(var(--s-4), env(safe-area-inset-right))
    max(var(--s-4), env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left));
}

.grow {
  flex: 1;
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 32px;
  font-size: 15px;
  color: var(--papier-dim);
}
.bar strong {
  color: var(--papier);
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.06em;
}
.bar-droite {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.pilote {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--papier);
  color: var(--encre);
  font-size: 14px;
  font-weight: 650;
}

/* ---------- type ---------- */

.titre {
  margin: 0;
  font-size: clamp(48px, 15vw, 64px);
  line-height: 0.92;
  font-weight: 850;
  font-stretch: 125%;
  letter-spacing: -0.01em;
}
.accroche {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--papier);
  max-width: 22ch;
}
.consigne {
  margin: 0;
  font-size: 27px;
  line-height: 1.18;
  font-weight: 750;
  font-stretch: 105%;
  max-width: 18ch;
}
.statut {
  margin: 0;
  font-size: 17px;
  color: var(--papier-dim);
  text-align: center;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
}
.petit {
  margin: 0;
  font-size: 15px;
  color: var(--papier-dim);
}
.erreur {
  margin: 0;
  min-height: 22px;
  font-size: 15px;
  color: var(--erreur);
}

/* ---------- controls ---------- */

.champ {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.champ label {
  font-size: 15px;
  color: var(--papier-dim);
}
.input {
  height: 56px;
  width: 100%;
  padding: 0 var(--s-4);
  border-radius: var(--r-ctl);
  border: 1.5px solid var(--carbone-3);
  background: var(--carbone-2);
  font-size: 20px;
  font-weight: 600;
}
.input::placeholder {
  color: #6e76ad;
  font-weight: 500;
}
.input:focus {
  outline: none;
  border-color: var(--papier);
}
.input-code {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-stretch: 125%;
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0 var(--s-5);
  border-radius: var(--r-ctl);
  border: 0;
  background: var(--papier);
  color: var(--encre);
  font-size: 18px;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active {
  background: var(--papier-press);
  transform: translateY(1px);
}
.btn:disabled {
  background: var(--carbone-2);
  color: var(--papier-dim);
  cursor: default;
  transform: none;
}
.btn-ghost {
  background: transparent;
  color: var(--papier);
  border: 1.5px solid var(--carbone-3);
}
.btn-ghost:active {
  background: var(--carbone-2);
}
.btn:focus-visible,
.lien:focus-visible,
.pli:focus-visible,
.retirer:focus-visible {
  outline: 3px solid var(--kraft);
  outline-offset: 3px;
}
.lien {
  align-self: center;
  border: 0;
  background: none;
  padding: var(--s-3);
  color: var(--papier-dim);
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
/* Driver's main action stays under the thumb even when the list is long */
.bas {
  position: sticky;
  bottom: 0;
  margin-bottom: calc(-1 * max(var(--s-4), env(safe-area-inset-bottom)));
  padding: var(--s-3) 0 max(var(--s-4), env(safe-area-inset-bottom));
  background: var(--carbone);
}
.avis {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-left: 3px solid var(--kraft);
  background: var(--carbone-2);
  font-size: 16px;
}

/* ---------- sealed envelope (the secret question) ---------- */

.pli {
  position: relative;
  width: 100%;
  min-height: 300px;
  border-radius: var(--r-paper);
  background: var(--kraft);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 18px 40px -18px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* flap */
.pli::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 58%;
  background: var(--kraft-dark);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.cachet {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  background: var(--cire);
  box-shadow: inset 0 0 0 6px var(--cire), inset 0 0 0 9px var(--cire-dark), 0 3px 0 rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  font-weight: 850;
  font-stretch: 70%;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: rgba(241, 236, 224, 0.82);
}
.pli-indice {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--s-4);
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--encre);
  opacity: 0.75;
}
.pli-contenu {
  position: absolute;
  inset: 0;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  background: var(--papier);
  color: var(--encre);
  visibility: hidden;
}
.pli.is-open::before,
.pli.is-open .cachet,
.pli.is-open .pli-indice {
  visibility: hidden;
}
.pli.is-open .pli-contenu {
  visibility: visible;
}
.pli-role {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  opacity: 0.7;
}
.pli-question {
  margin: 0;
  font-family: var(--font-typed);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.35;
}
.pli-note {
  margin: auto 0 0;
  font-size: 15px;
  line-height: 1.35;
  opacity: 0.7;
}
/* ---------- lobby ---------- */

.qr {
  align-self: center;
  width: min(196px, 56vw);
  padding: var(--s-3);
  border-radius: var(--r-paper);
  background: var(--papier);
}
.qr img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}
.code-grand {
  margin: 0;
  text-align: center;
  font-size: clamp(48px, 16vw, 64px);
  line-height: 1;
  font-weight: 850;
  font-stretch: 125%;
  letter-spacing: 0.06em;
}
.code-gauche {
  text-align: left;
}
.code-aide {
  margin: calc(var(--s-3) * -1) 0 0;
  text-align: center;
  font-size: 16px;
  color: var(--papier-dim);
}

.joueurs {
  display: flex;
  flex-direction: column;
}
.joueurs-titre {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 var(--s-2);
  font-size: 15px;
  font-weight: 500;
  color: var(--papier-dim);
}
.joueurs ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.joueur {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 52px;
  border-bottom: 1px solid var(--carbone-2);
}
.joueur-nom {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.joueur.absent .joueur-nom {
  color: var(--papier-dim);
}
.joueur-tag {
  font-size: 14px;
  color: var(--papier-dim);
  white-space: nowrap;
}
.retirer {
  border: 0;
  background: none;
  padding: var(--s-2) var(--s-1) var(--s-2) var(--s-3);
  color: var(--papier-dim);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- accusation (pilot, under the revealed question) ---------- */

.choix {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.choix .btn {
  justify-content: flex-start;
  font-size: 20px;
}
.choix .btn-egalite {
  margin-top: var(--s-3);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding-top: var(--s-2);
  padding-bottom: var(--s-2);
  gap: 2px;
}
.btn-egalite small {
  font-size: 14px;
  font-weight: 500;
  color: var(--papier-dim);
}

/* ---------- reveal: the verdict ---------- */

.verdict {
  position: relative;
  border-radius: var(--r-paper);
  background: var(--papier);
  color: var(--encre);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.verdict.choc {
  animation: choc 180ms ease-out 300ms;
}
.verdict-intro {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  opacity: 0.7;
}
.verdict-nom {
  position: relative;
  margin: calc(var(--s-3) * -1) 0 0;
  font-size: clamp(40px, 13vw, 54px);
  line-height: 1;
  font-weight: 850;
  font-stretch: 112%;
  overflow-wrap: anywhere;
}
/* The verdict stamp sits on its own line: the name stays readable */
.tampon {
  align-self: flex-start;
  margin: calc(var(--s-2) * -1) 0 0 -2px;
  padding: 2px 10px 3px;
  border: 4px solid var(--cire);
  border-radius: 6px;
  color: var(--cire);
  font-size: 23px;
  line-height: 1.1;
  font-weight: 850;
  font-stretch: 95%;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transform: rotate(-4deg);
  opacity: 0.9;
  mix-blend-mode: multiply;
  pointer-events: none;
  white-space: nowrap;
}
.tampon.frappe {
  animation: frappe 320ms cubic-bezier(0.5, 0, 0.75, 0) both;
}
@keyframes frappe {
  0% {
    transform: rotate(-12deg) scale(2.4);
    opacity: 0;
  }
  100% {
    transform: rotate(-4deg) scale(1);
    opacity: 0.9;
  }
}
@keyframes choc {
  0%,
  100% {
    transform: translate(0, 0);
  }
  30% {
    transform: translate(-3px, 2px);
  }
  60% {
    transform: translate(2px, -1px);
  }
}
.verdict-accuse {
  margin: var(--s-2) 0 0;
  font-size: 17px;
  font-weight: 600;
}
.verdict hr {
  width: 100%;
  margin: 0;
  border: 0;
  border-top: 1px dashed rgba(23, 20, 15, 0.3);
}
.piece {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.piece-label {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.65;
}
.piece-texte {
  margin: 0;
  font-family: var(--font-typed);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.35;
}

.gorgees-qui {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 750;
}
/* ---------- rules (lobby) ---------- */

.regles {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  border-left: 3px solid var(--kraft);
  background: var(--carbone-2);
}
.regles-titre {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
}
.regles ol {
  margin: 0;
  padding-left: 1.3em;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: 15px;
  line-height: 1.4;
  color: var(--papier);
}
.regles li::marker {
  font-family: var(--font-typed);
  font-weight: 700;
  color: var(--kraft);
}

/* ---------- Normal / Hardcore ---------- */

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: var(--r-ctl);
  background: var(--carbone-2);
}
.mode {
  min-height: 44px;
  border: 0;
  border-radius: calc(var(--r-ctl) - 3px);
  background: transparent;
  color: var(--papier-dim);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.mode.actif {
  background: var(--carbone-3);
  color: var(--papier);
}
.mode:last-child.actif {
  background: var(--cire);
  color: #fff;
}
.mode:focus-visible {
  outline: 3px solid var(--kraft);
  outline-offset: 2px;
}

/* ---------- the real question, revealed to everyone ---------- */

.revelee {
  border-radius: var(--r-paper);
  background: var(--papier);
  color: var(--encre);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.55);
}
.revelee-label {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  opacity: 0.7;
}
.revelee-question {
  margin: 0;
  font-family: var(--font-typed);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.3;
}
.accuser {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.accuser-titre {
  margin: 0;
  font-size: 21px;
  font-weight: 750;
}
.centre {
  text-align: center;
}

/* ---------- verdict extras ---------- */

.piece-appel {
  font-size: 15px;
  font-weight: 750;
  opacity: 1;
  color: var(--cire-dark);
}
.liens {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 var(--s-4);
}

/* ---------- end of game ---------- */

.bilan {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.bilan-carte {
  border-radius: var(--r-paper);
  background: var(--papier);
  color: var(--encre);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bilan-titre {
  margin: 0;
  font-family: var(--font-typed);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cire-dark);
}
.bilan-nom {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
  font-stretch: 112%;
  overflow-wrap: anywhere;
}
.bilan-detail {
  margin: 0;
  font-size: 15px;
  opacity: 0.75;
}

/* ---------- home ---------- */

.accueil-haut {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding-top: var(--s-6);
}
.mini-pli {
  width: 88px;
  height: 60px;
  min-height: 0;
  margin-bottom: var(--s-3);
  border-radius: 3px;
  cursor: default;
}
.mini-pli .cachet {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  font-size: 0;
  box-shadow: inset 0 0 0 3px var(--cire), inset 0 0 0 4.5px var(--cire-dark), 0 2px 0 rgba(0, 0, 0, 0.25);
}

.reprendre {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  border-radius: var(--r-ctl);
  background: var(--carbone-2);
}

/* ---------- connection banner ---------- */

.conn {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--cire);
  color: var(--papier);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.conn[hidden] {
  display: none;
}

.noscript {
  padding: 24px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* "Terminer la partie" waiting for its second tap */
.lien-alerte {
  color: var(--erreur);
  font-weight: 650;
}

/* Long first names shrink instead of breaking mid-word */
.verdict-nom.long {
  font-size: clamp(32px, 10vw, 44px);
  overflow-wrap: normal;
}
.verdict-nom.tres-long {
  font-size: clamp(26px, 8vw, 34px);
}
.mode small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
}
.mode:has(small) {
  min-height: 52px;
}
