/* ===========================================================================
   20 ans de rhéto
   Le support ne change jamais : une feuille d'interro du collège, papier
   recyclé brunâtre, marge rouge, carreaux. Par-dessus, on a gribouillé 2006 :
   Comic Sans, stylo fluo fuchsia, stickers, étoiles.
   Palette du logo : brun #483030 · bleu #2f4a94 · rouge #a81830 · jaune #ffd800
   =========================================================================== */

:root {
  /* le papier */
  --paper:       #e7dcc3;
  --paper-hi:    #f3ece0;   /* zones plus claires : cartes, réponses */
  --desk:        #3b0a44;   /* autour de la feuille, sur grand écran */
  --ink:         #3a2f26;
  --ink-soft:    #7a6a58;

  /* les encres du logo */
  --blue:        #2f4a94;
  --red:         #a81830;
  --yellow:      #ffd800;

  /* 2006 */
  --fuchsia:     #ff2fc8;   /* le fluo */
  --fuchsia-ink: #c2007a;   /* le gel pen, lisible sur papier */
  --fuchsia-dp:  #8d0059;
  --cyan:        #00a8c8;
  --ok:          #1f8a4c;   /* stylo vert du prof */
  --ko:          #d0021b;   /* stylo rouge du prof */

  /* quadrillage */
  --grid:        rgba(47, 74, 148, .13);
  --cell:        22px;
  --marge:       30px;

  --radius:      14px;
  --tap:         56px;

  --font-comic: "Comic Sans MS", "Comic Sans", "Chalkboard SE", "Chalkboard", "Marker Felt", "Segoe Print", cursive;
  --font-body:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-comic);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- la feuille : grain + marge rouge + carreaux -------------------------- */

.screen, .board {
  background-color: var(--paper);
  background-image:
    /* grain de papier recyclé (SVG inline : aucune requête réseau) */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    /* la marge rouge */
    linear-gradient(to right,
      transparent var(--marge),
      rgba(168, 24, 48, .55) var(--marge),
      rgba(168, 24, 48, .55) calc(var(--marge) + 1.5px),
      transparent calc(var(--marge) + 1.5px)),
    /* les carreaux */
    repeating-linear-gradient(to right, var(--grid) 0 1px, transparent 1px var(--cell)),
    repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px var(--cell));
}

.screen {
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)) calc(var(--marge) + 14px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(58, 47, 38, .14) inset, 0 0 30px rgba(0, 0, 0, .35);
}

/* --- boutons : des stickers collés sur la feuille -------------------------- */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 20px;
  border: 3px solid #fff;
  border-radius: var(--radius);
  font-family: var(--font-comic);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: translateY(2px); }

.btn-primary {
  background: linear-gradient(180deg, #ff86e0 0%, var(--fuchsia) 50%, var(--fuchsia-dp) 100%);
  color: #fff;
  text-shadow: 0 2px 3px rgba(80, 0, 55, .55);
  box-shadow: 0 4px 0 var(--fuchsia-dp), 0 7px 16px rgba(58, 47, 38, .3);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--fuchsia-dp); }
.btn-primary[disabled] { filter: grayscale(.45) brightness(1.05); }

.btn-ghost {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-size: .95rem;
  font-weight: 400;
  text-decoration: underline;
  box-shadow: none;
  margin-top: 16px;
  min-height: 44px;
}

.error {
  color: var(--ko);
  background: rgba(208, 2, 27, .09);
  border: 2px dashed rgba(208, 2, 27, .5);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: .92rem;
  margin: 10px 0;
}

/* ===========================================================================
   ACCUEIL — l'en-tête du collège, à remplir
   =========================================================================== */

.home-inner { margin: auto 0; padding: 6px 0; }

.letterhead { text-align: center; margin-bottom: 4px; }
.logo { width: 100%; max-width: 310px; height: auto; display: block; margin: 0 auto; }
.logo-fallback { font-size: 58px; line-height: 1; }

.letterhead-year {
  margin: 2px 0 0;
  text-align: right;
  font-family: var(--font-body);
  font-size: .75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stamp-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 16px 0 4px; }

/* le tampon "Interrogation" */
.stamp {
  display: inline-block;
  padding: 3px 12px;
  border: 3px solid var(--red);
  border-radius: 5px;
  color: var(--red);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transform: rotate(-3deg);
  opacity: .9;
}
.stamp-note { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }

/* le titre écrit au gel pen fuchsia */
.title {
  margin: 12px 0 16px;
  font-size: 2.5rem;
  line-height: 1.1;
  font-weight: 700;
  color: var(--fuchsia-ink);
  text-shadow: 2px 2px 0 rgba(255, 47, 200, .22);
}

/* la consigne, surlignée au fluo jaune */
.consigne {
  margin: 0 0 22px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: .93rem;
  line-height: 1.45;
  color: var(--ink);
  background: rgba(255, 216, 0, .3);
  border-left: 4px solid var(--yellow);
}
.consigne strong { color: var(--red); }

/* --- les champs à remplir, sur leur ligne pointillée --- */

#form-home { display: none; }
#form-home.ready { display: block; }

.field-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 2px dotted rgba(58, 47, 38, .45);
  padding-bottom: 2px;
}

.field-label {
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink-soft);
}
.field-label::after { content: " :"; }

.field-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 46px;
  padding: 6px 2px;
  font-family: var(--font-comic);
  font-size: 1.25rem;
  color: var(--blue);
  background: transparent;
  border: 0;
  border-radius: 0;
}
.field-input:focus { outline: none; background: rgba(255, 47, 200, .1); }
.field-input::placeholder { color: rgba(58, 47, 38, .3); font-size: .9rem; }

.field-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.field-grid .field-line { flex: 1 1 130px; }

.loading { color: var(--ink-soft); font-size: .95rem; }

/* ===========================================================================
   QUIZ
   =========================================================================== */

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* le thème passé au surligneur fuchsia */
.theme-chip {
  font-size: .98rem;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(to bottom,
    transparent 10%, rgba(255, 47, 200, .45) 10%, rgba(255, 47, 200, .45) 92%, transparent 92%);
  padding: 2px 8px;
  transform: rotate(-1deg);
}

.counter {
  font-weight: 700;
  color: var(--fuchsia-ink);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
#q-index { font-size: 1.5rem; }
.counter-sep { margin: 0 2px; opacity: .6; }

.progress {
  height: 12px;
  background: var(--paper-hi);
  border: 2px solid var(--ink-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffe600, #ff9ae0, var(--fuchsia));
  transition: width .35s ease;
}

.quiz-body { flex: 1; }

/* les photos : comme une polaroid scotchée sur la feuille */
.image-wrap { margin-bottom: 18px; text-align: center; }
#q-image {
  max-width: 100%;
  max-height: 40vh;
  object-fit: contain;
  background: #fff;
  padding: 7px;
  border: 1px solid rgba(58, 47, 38, .3);
  box-shadow: 3px 4px 0 rgba(58, 47, 38, .18);
  transform: rotate(-1deg);
}

.question {
  margin: 0 0 18px;
  font-size: 1.3rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--ink);
}

.options { display: flex; flex-direction: column; gap: 11px; }

.option {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-family: var(--font-comic);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-hi);
  border: 2.5px solid var(--fuchsia-ink);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(194, 0, 122, .35);
  transition: transform .06s ease, background .15s ease, border-color .15s ease, opacity .2s ease;
}
.option:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(194, 0, 122, .35); }
.option:disabled { cursor: default; }
.option.waiting { opacity: .55; }

/* la pastille A / B / C / D, comme une gommette */
.opt-letter {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff86e0, var(--fuchsia-ink));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(58, 47, 38, .3);
}
.opt-text { flex: 1; }

/* la correction, au stylo vert et au stylo rouge */
.option.correct {
  background: #dff3e4;
  border-color: var(--ok);
  box-shadow: 3px 3px 0 rgba(31, 138, 76, .35);
}
.option.correct .opt-letter { background: linear-gradient(180deg, #5fd48c, var(--ok)); }
.option.correct .opt-text::after { content: " ✓"; color: var(--ok); font-weight: 700; }

.option.wrong {
  background: #fbe3e5;
  border-color: var(--ko);
  box-shadow: 3px 3px 0 rgba(208, 2, 27, .3);
}
.option.wrong .opt-letter { background: linear-gradient(180deg, #ff7b8a, var(--ko)); }
.option.wrong .opt-text { text-decoration: line-through; text-decoration-color: rgba(208, 2, 27, .65); }

.option.dimmed { opacity: .5; box-shadow: none; }

/* l'annotation du prof */
.feedback {
  margin-top: 18px;
  padding: 12px 14px;
  border: 2.5px dashed var(--ok);
  border-radius: var(--radius);
  background: rgba(31, 138, 76, .08);
}
.feedback.is-wrong { border-color: var(--ko); background: rgba(208, 2, 27, .07); }
.feedback-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ok);
}
.feedback.is-wrong .feedback-title { color: var(--ko); }
.feedback-explanation {
  margin: 6px 0 0;
  font-family: var(--font-body);
  color: var(--ink);
  font-size: .94rem;
}

.quiz-footer {
  position: sticky;
  bottom: 0;
  padding-top: 16px;
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(180deg, rgba(231, 220, 195, 0), var(--paper) 45%);
}

/* ===========================================================================
   RÉSULTAT — la copie corrigée et rendue
   =========================================================================== */

.result-inner { margin: auto 0; text-align: center; padding: 8px 0; }

.copie-header {
  text-align: left;
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 2.5px solid rgba(58, 47, 38, .35);
}
.copie-line { margin: 1px 0; font-size: 1.05rem; color: var(--blue); }
.copie-label {
  font-family: var(--font-body);
  font-size: .82rem;
  color: var(--ink-soft);
}
.copie-label::after { content: " :"; }

.grade-row { display: flex; justify-content: center; }

/* la note entourée au stylo rouge, avec une touche de paillettes 2006 */
.score-big {
  display: inline-block;
  padding: .12em .32em .18em;
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ko);
  border: 4px solid var(--ko);
  border-radius: 46% 54% 50% 50% / 56% 44% 56% 44%;
  transform: rotate(-4deg);
  text-shadow: 2px 2px 0 rgba(255, 47, 200, .25);
  font-variant-numeric: tabular-nums;
}
.score-total { font-size: .5em; }

.result-line { margin: 14px 0 2px; font-size: 1.1rem; font-weight: 700; color: var(--fuchsia-ink); }
.result-time { color: var(--ink-soft); font-weight: 400; font-size: 1rem; }

.result-subtitle {
  margin: 26px 0 10px;
  font-size: 1.1rem;
  color: var(--ink);
  text-align: left;
  background: linear-gradient(to bottom,
    transparent 12%, rgba(255, 216, 0, .45) 12%, rgba(255, 216, 0, .45) 90%, transparent 90%);
  display: inline-block;
  padding: 0 6px;
}
.result-subtitle::before { content: "★ "; color: var(--fuchsia-ink); }

.theme-scores { list-style: none; margin: 0 0 24px; padding: 0; }
.theme-score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 2px dotted rgba(58, 47, 38, .3);
  text-align: left;
}
.ts-label { font-size: .97rem; }
.ts-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fuchsia-ink);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 640px) {
  :root { --cell: 26px; --marge: 42px; }
  .title { font-size: 3rem; }
  .question { font-size: 1.45rem; }
}

/* ===========================================================================
   JOUEUR — salle d'attente
   =========================================================================== */

.lobby-inner { margin: auto 0; text-align: center; padding: 20px 0; }

.lobby-kicker { margin: 0; font-size: 1.1rem; color: var(--ink-soft); }
.lobby-name {
  margin: 6px 0 18px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.15;
}
.lobby-check {
  width: 92px;
  height: 92px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  font-size: 3rem;
  color: #fff;
  background: linear-gradient(180deg, #ff86e0, var(--fuchsia-ink));
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 5px 0 var(--fuchsia-dp), 0 10px 22px rgba(58, 47, 38, .3);
}
.lobby-wait { margin: 0 0 6px; font-size: 1.25rem; font-weight: 700; color: var(--fuchsia-ink); }
.lobby-count { margin: 0 0 22px; font-size: 1.05rem; color: var(--ink); }
.lobby-hint {
  margin: 0;
  font-family: var(--font-body);
  font-size: .92rem;
  color: var(--ink-soft);
  padding: 0 10px;
}

.dots span { animation: blink 1.4s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; } }

/* ===========================================================================
   JOUEUR — minuteur et état de la réponse
   =========================================================================== */

.answered-line {
  margin: 0 0 16px;
  text-align: center;
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.timer-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

.timer-bar {
  flex: 1;
  height: 14px;
  background: var(--paper-hi);
  border: 2px solid var(--ink-soft);
  border-radius: 999px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffe600, #ff9ae0, var(--fuchsia));
  transition: width .2s linear;
}
.timer-sec {
  flex: 0 0 auto;
  min-width: 2.2em;
  text-align: right;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fuchsia-ink);
  font-variant-numeric: tabular-nums;
}
.timer-sec.urgent { color: var(--ko); }

.option.chosen {
  border-color: var(--blue);
  border-width: 3px;
  background: rgba(47, 74, 148, .12);
  box-shadow: 3px 3px 0 rgba(47, 74, 148, .35);
}
.option.chosen .opt-letter { background: linear-gradient(180deg, #6e8fd8, var(--blue)); }

.sent-note {
  margin: 16px 0 0;
  padding: 10px 12px;
  text-align: center;
  font-weight: 700;
  color: var(--blue);
  background: rgba(47, 74, 148, .1);
  border: 2px dashed var(--blue);
  border-radius: var(--radius);
}

.play-footer {
  position: sticky;
  bottom: 0;
  padding: 12px 0 env(safe-area-inset-bottom);
  background: linear-gradient(180deg, rgba(231, 220, 195, 0), var(--paper) 40%);
}
.running-score {
  margin: 0;
  text-align: center;
  font-weight: 700;
  color: var(--fuchsia-ink);
  font-size: 1.02rem;
}

/* ===========================================================================
   ÉCRAN PROJETÉ — pupitre de l'animateur
   =========================================================================== */

.board-body { overflow: hidden; background: var(--desk); }

.board {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 2vh 3vw 2vh calc(4.5vw + 1.5vw);
  gap: 1.2vh;
  --marge: 4.5vw;
  --cell: 2.4vh;
  box-shadow: 0 0 90px rgba(58, 47, 38, .25) inset;
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  flex: 0 0 auto;
  padding-bottom: .8vh;
  border-bottom: .45vh solid var(--fuchsia-ink);
}

.board-brand { display: flex; align-items: center; gap: 1.6vw; }
.board-logo { height: 7.5vh; width: auto; object-fit: contain; }
.board-logo-fallback { font-size: 6vh; line-height: 1; }

.board-title {
  margin: 0;
  font-size: 4vh;
  line-height: 1.05;
  font-weight: 700;
  color: var(--fuchsia-ink);
  text-shadow: .25vh .25vh 0 rgba(255, 47, 200, .3);
}
.board-subtitle { margin: .2vh 0 0; font-size: 2vh; color: var(--ink-soft); }

.board-count { text-align: right; line-height: 1.05; }
.board-count-num {
  display: block;
  font-size: 6vh;
  font-weight: 700;
  color: var(--ko);
  font-variant-numeric: tabular-nums;
}
.board-count-label { font-size: 1.9vh; color: var(--ink-soft); }

.board-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.btn-host {
  width: auto;
  align-self: center;
  min-width: 34vw;
  font-size: 3vh;
  padding: 1.6vh 4vw;
  border-radius: 1.6vh;
}
.btn-inline { align-self: center; min-width: 22vw; font-size: 2.4vh; padding: 1.2vh 2.5vw; }

/* --- A. pas encore de session --- */

.setup-box { margin: auto; text-align: center; max-width: 60vw; }
.setup-title { margin: 0; font-size: 4.5vh; font-weight: 700; color: var(--fuchsia-ink); }
.setup-sub { margin: 1vh 0 3vh; font-size: 2.4vh; color: var(--ink-soft); }
.setup-token { margin-bottom: 2.5vh; }
.setup-label { display: block; font-size: 1.8vh; color: var(--ink-soft); margin-bottom: .6vh; }
.setup-input {
  width: 46vw;
  max-width: 100%;
  padding: 1.2vh 1.5vw;
  font-family: var(--font-comic);
  font-size: 2.4vh;
  color: var(--ink);
  background: var(--paper-hi);
  border: 2px solid var(--ink-soft);
  border-radius: 1vh;
}
.setup-input:focus { outline: none; border-color: var(--fuchsia-ink); }

/* --- B. salle d'attente --- */

.lobby-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.5vh;
  padding: 1vh 0;
}

.lobby-join { text-align: center; flex: 0 0 auto; }
.lobby-qr {
  width: 30vh;
  height: 30vh;
  background: #fff;
  padding: .8vh;
  border: 1px solid rgba(58, 47, 38, .3);
  box-shadow: .4vh .5vh 0 rgba(58, 47, 38, .18);
}
.lobby-url { margin: 1vh 0 0; font-size: 2.2vh; font-weight: 700; color: var(--blue); word-break: break-all; }
.lobby-pin-label { margin: 1.2vh 0 0; font-size: 1.8vh; color: var(--ink-soft); }
.lobby-pin {
  margin: 0;
  font-size: 4.6vh;
  font-weight: 700;
  letter-spacing: .8vh;
  color: var(--ko);
  font-variant-numeric: tabular-nums;
}

.lobby-people {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.lobby-people-title {
  margin: 0 0 1vh;
  font-size: 2.6vh;
  font-weight: 700;
  color: var(--fuchsia-ink);
}
.lobby-names {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: .8vh 1vw;
}
.lobby-chip {
  padding: .7vh 1.4vw;
  font-size: 2.2vh;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 216, 0, .35);
  border-radius: 1vh;
  transform: rotate(-.5deg);
}

/* --- C. question en direct --- */

.play-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  margin-bottom: 1.2vh;
}
.board-chip { font-size: 2.4vh; }
.play-counter { font-size: 2.6vh; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.play-waiting {
  text-align: right;
  font-size: 2.4vh;
  font-weight: 700;
  color: var(--fuchsia-ink);
}

.play-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 1.5vh; }

.play-image { text-align: center; }
.play-image img {
  max-height: 26vh;
  max-width: 100%;
  object-fit: contain;
  background: #fff;
  padding: .6vh;
  border: 1px solid rgba(58, 47, 38, .3);
  box-shadow: .3vh .4vh 0 rgba(58, 47, 38, .18);
}

.play-question {
  margin: 0;
  text-align: center;
  font-size: 4.4vh;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
}

.play-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2vh 1.4vw;
}

.popt {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 1.2vw;
  padding: 1.6vh 1.6vw;
  min-height: 9vh;
  background: var(--paper-hi);
  border: .3vh solid var(--fuchsia-ink);
  border-radius: 1.4vh;
  box-shadow: .35vh .35vh 0 rgba(194, 0, 122, .35);
  font-size: 2.8vh;
  font-weight: 700;
  color: var(--ink);
}
/* la barre de répartition des réponses, révélée avec la correction */
.popt::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--fill, 0%);
  background: rgba(255, 47, 200, .22);
  transition: width .6s ease;
}
.popt > * { position: relative; }

.popt-letter {
  flex: 0 0 auto;
  width: 5vh;
  height: 5vh;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff86e0, var(--fuchsia-ink));
  color: #fff;
  font-size: 2.6vh;
}
.popt-text { flex: 1; }
.popt-count {
  flex: 0 0 auto;
  font-size: 3vh;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.popt-correct {
  border-color: var(--ok);
  border-width: .5vh;
  background: #dff3e4;
  box-shadow: .35vh .35vh 0 rgba(31, 138, 76, .4);
}
.popt-correct::before { background: rgba(31, 138, 76, .25); }
.popt-correct .popt-letter { background: linear-gradient(180deg, #5fd48c, var(--ok)); }
.popt-correct .popt-text::after { content: " ✓"; color: var(--ok); }
.popt-correct .popt-count { color: var(--ok); }
.popt-out { opacity: .55; }

.play-explanation {
  margin: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 2.2vh;
  color: var(--ink);
  padding: 0 4vw;
}

.play-bottom {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2vw;
  padding-top: 1vh;
  border-top: .3vh dotted rgba(58, 47, 38, .35);
}
.play-answered { margin: 0; font-size: 2.4vh; font-weight: 700; color: var(--ink-soft); }
.play-top5 { display: flex; gap: 1vw; justify-content: center; flex-wrap: wrap; }
.t5 {
  display: flex;
  align-items: baseline;
  gap: .5vw;
  padding: .5vh 1vw;
  background: rgba(255, 216, 0, .32);
  border-radius: 1vh;
  font-size: 2.1vh;
}
.t5-rank { font-weight: 700; color: var(--fuchsia-ink); }
.t5-name { font-weight: 700; color: var(--ink); }
.t5-score { font-weight: 700; color: var(--ko); }
.play-bottom .btn-inline { justify-self: end; }

/* --- D. résultats finaux --- */

.podium {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5vw;
  align-items: end;
  padding: 1vh 0 1vh;
}
.pod {
  text-align: center;
  padding: 1.4vh 1vw;
  border-radius: 1.6vh;
  background: rgba(255, 216, 0, .28);
  border: .3vh solid rgba(58, 47, 38, .25);
}
.pod-1 { background: rgba(255, 47, 200, .3); border-color: var(--fuchsia-ink); padding-top: 2.6vh; padding-bottom: 2.6vh; order: 2; }
.pod-2 { order: 1; }
.pod-3 { order: 3; }
.pod-medal { font-size: 4.4vh; line-height: 1; }
.pod-name { font-size: 2.6vh; font-weight: 700; margin-top: .6vh; color: var(--ink); }
.pod-score { font-size: 3.6vh; font-weight: 700; color: var(--ko); font-variant-numeric: tabular-nums; }
.pod-score span { font-size: .45em; color: var(--ink-soft); }
.pod-time { font-size: 2vh; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.final-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6vh 2vw;
  align-content: start;
  overflow: hidden;
}
.frow {
  display: flex;
  align-items: center;
  gap: 1.2vw;
  padding: .35vh 1vw;
  border-bottom: .2vh dotted rgba(58, 47, 38, .3);
  font-size: 2.2vh;
  font-weight: 700;
}

/* on annonce ce qui ne tient pas à l'écran plutôt que de le couper en silence */
.final-more {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 2vh;
  color: var(--ink-soft);
  padding-top: .4vh;
}
.frank { min-width: 2em; color: var(--fuchsia-ink); font-variant-numeric: tabular-nums; }
.fname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.fscore { color: var(--ko); font-variant-numeric: tabular-nums; }
.fscore-total { font-size: .6em; color: var(--ink-soft); }

/* --- pied de page (QR), masqué pendant la partie --- */

.board-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1.6vw;
  position: relative;
  border-top: .45vh solid var(--fuchsia-ink);
  padding-top: 1.2vh;
}
.board-qr {
  height: 11vh;
  width: 11vh;
  background: #fff;
  padding: .5vh;
  border: 1px solid rgba(58, 47, 38, .3);
  box-shadow: .3vh .4vh 0 rgba(58, 47, 38, .18);
}
.board-join-title { margin: 0; font-size: 2.6vh; font-weight: 700; color: var(--fuchsia-ink); }
.board-url { margin: .3vh 0 0; font-size: 2.8vh; font-weight: 700; color: var(--blue); word-break: break-all; }
.board-offline {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
  font-size: 1.8vh;
  color: var(--ko);
}

@media (max-aspect-ratio: 1/1) {
  .play-options { grid-template-columns: 1fr; }
  .play-question { font-size: 3.2vh; }
  .lobby-grid { grid-template-columns: 1fr; }
  .final-list { grid-template-columns: 1fr; }
}

/* ===========================================================================
   MENTIONS — proclamation façon fin d'année
   =========================================================================== */

/* les couleurs d'encre selon la mention */
.m-felicitations { color: var(--ko); }
.m-plus-grande   { color: var(--fuchsia-ink); }
.m-grande        { color: var(--blue); }
.m-distinction   { color: var(--ok); }
.m-satisfaction  { color: var(--ink); }
.m-double        { color: var(--ink-soft); }

/* --- sur la copie du joueur --- */

.mention-label {
  margin: 16px 0 0;
  font-family: var(--font-body);
  font-size: .78rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.mention-line {
  margin: 2px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  transform: rotate(-1.5deg);
}
.mention-line.m-double::after { content: " 😬"; }
.mention-line.m-felicitations::after { content: " 🏆"; }

/* --- classement latéral pendant la partie --- */

.play-main.with-scores { display: grid; grid-template-columns: 1fr 30%; gap: 2vw; align-items: start; }
.play-qa { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1.5vh; }

.play-scores {
  min-width: 0;
  align-self: stretch;
  padding-left: 1.5vw;
  border-left: .3vh dotted rgba(58, 47, 38, .4);
}
.scores-title {
  margin: 0 0 1vh;
  font-size: 2.4vh;
  font-weight: 700;
  color: var(--fuchsia-ink);
  background: linear-gradient(to bottom,
    transparent 12%, rgba(255, 216, 0, .5) 12%, rgba(255, 216, 0, .5) 90%, transparent 90%);
  display: inline-block;
  padding: 0 .6vw;
}
.scores-list { display: flex; flex-direction: column; gap: .3vh; }
.srow {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  align-items: baseline;
  gap: .8vw;
  padding: .35vh .4vw;
  border-bottom: .15vh dotted rgba(58, 47, 38, .28);
  font-size: 2.1vh;
  font-weight: 700;
}
.srow-1 { background: rgba(255, 47, 200, .28); border-radius: .8vh; }
.srow-2 { background: rgba(255, 216, 0, .3); border-radius: .8vh; }
.srow-3 { background: rgba(47, 74, 148, .13); border-radius: .8vh; }
.srank { color: var(--fuchsia-ink); font-variant-numeric: tabular-nums; }
.sname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.sscore { color: var(--ko); font-variant-numeric: tabular-nums; }

/* --- proclamation finale --- */

.proclam {
  flex: 0 0 auto;
  margin: .5vh 0 0;
  text-align: center;
  font-size: 3vh;
  font-weight: 700;
  color: var(--fuchsia-ink);
  text-decoration: underline;
  text-decoration-color: var(--ko);
  text-underline-offset: .5vh;
}

.pod-mention {
  margin-top: .6vh;
  font-size: 1.9vh;
  font-weight: 700;
  line-height: 1.2;
}
.pod-1 .pod-mention { font-size: 2.1vh; }

.mention-counts {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 2vw;
  padding: 1vh 0;
  border-top: .2vh dotted rgba(58, 47, 38, .35);
  border-bottom: .2vh dotted rgba(58, 47, 38, .35);
  margin-bottom: 1vh;
}
.mcount { font-size: 2.2vh; font-weight: 700; }

.fmention {
  font-size: .78em;
  font-weight: 700;
  white-space: nowrap;
  opacity: .9;
}

/* ===========================================================================
   CLASSEMENT PAR CLASSE
   =========================================================================== */

/* --- liste déroulante des classes sur la feuille --- */

.field-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: right 12px top 50%, right 6px top 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 26px;
  cursor: pointer;
}
.field-select:invalid { color: rgba(58, 47, 38, .4); }

/* --- sur la copie du joueur --- */

.class-line {
  margin: 10px 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
}

/* --- panneau latéral pendant la partie --- */

.scores-title-2 { margin-top: 1.4vh; font-size: 2vh; }

.class-strip { display: flex; flex-direction: column; gap: .3vh; }

.cls {
  display: grid;
  grid-template-columns: 2.6em 1fr auto;
  align-items: center;
  gap: .7vw;
  font-size: 2vh;
  font-weight: 700;
}
.cls-name { color: var(--ink); }
.cls-bar {
  height: 1.2vh;
  background: rgba(58, 47, 38, .12);
  border-radius: 999px;
  overflow: hidden;
}
.cls-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffe600, var(--fuchsia));
  transition: width .6s ease;
}
.cls-avg { color: var(--ko); font-variant-numeric: tabular-nums; }
.cls-1 .cls-name { color: var(--fuchsia-ink); }

/* --- bloc de la proclamation --- */

.class-board {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.2vw;
  padding: 1.2vh 0;
  margin-bottom: 1vh;
  border-bottom: .2vh dotted rgba(58, 47, 38, .35);
}
.class-board .cls {
  grid-template-columns: none;
  grid-template-rows: auto auto auto auto;
  justify-items: center;
  gap: .4vh;
  padding: .8vh .5vw;
  background: rgba(255, 216, 0, .18);
  border-radius: 1vh;
  font-size: 2.2vh;
}
.class-board .cls-1 { background: rgba(255, 47, 200, .28); }
.class-board .cls-name { font-size: 2.8vh; }
.class-board .cls-bar { width: 80%; height: 1vh; }
.class-board .cls-avg { font-size: 3vh; }
.class-board .cls-n { font-size: 1.7vh; color: var(--ink-soft); font-weight: 400; }

/* ===========================================================================
   QR TOUJOURS ATTEIGNABLE + RELANCE D'UNE PARTIE
   =========================================================================== */

/* --- pastille "rejoindre" dans l'en-tête --- */

.join-badge {
  display: flex;
  align-items: center;
  gap: .8vw;
  padding: .5vh .9vw;
  background: rgba(255, 216, 0, .28);
  border: .25vh solid rgba(58, 47, 38, .3);
  border-radius: 1vh;
  cursor: pointer;
  font-family: var(--font-comic);
}
.join-badge:hover { background: rgba(255, 216, 0, .45); }
.join-badge-qr { height: 6.5vh; width: 6.5vh; background: #fff; padding: .3vh; }
.join-badge-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.join-badge-kicker { font-size: 1.7vh; color: var(--ink-soft); }
.join-badge-url { font-size: 2.1vh; font-weight: 700; color: var(--blue); }

/* --- QR plein écran --- */

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(43, 35, 27, .92);
  cursor: pointer;
}
.qr-overlay-inner { text-align: center; }
.qr-overlay-title {
  margin: 0 0 2vh;
  font-size: 5vh;
  font-weight: 700;
  color: var(--yellow);
}
.qr-overlay-img {
  width: 52vh;
  height: 52vh;
  background: #fff;
  padding: 1.5vh;
  border-radius: 1.5vh;
}
.qr-overlay-url { margin: 2vh 0 0; font-size: 4vh; font-weight: 700; color: #fff; }
.qr-overlay-hint { margin: 1vh 0 0; font-size: 2vh; color: rgba(255, 255, 255, .6); }

/* --- bouton "nouvelle partie" --- */

.reset-btn {
  display: block;
  margin-top: .6vh;
  margin-left: auto;
  padding: .5vh 1vw;
  font-family: var(--font-comic);
  font-size: 1.7vh;
  color: var(--ink-soft);
  background: transparent;
  border: .2vh solid rgba(58, 47, 38, .3);
  border-radius: .8vh;
  cursor: pointer;
}
.reset-btn:hover { color: var(--ink); border-color: rgba(58, 47, 38, .6); }
.reset-btn.reset-armed {
  color: #fff;
  background: var(--ko);
  border-color: var(--ko);
  font-weight: 700;
}

/* Bandeau d'avertissement quand la partie est volontairement raccourcie. */
.test-banner {
  flex: 0 0 auto;
  margin: 0 0 .8vh;
  padding: .6vh 1vw;
  text-align: center;
  font-size: 2.2vh;
  font-weight: 700;
  letter-spacing: .2vh;
  color: #fff;
  background: repeating-linear-gradient(45deg, var(--ko) 0 2vh, #8a0012 2vh 4vh);
  border-radius: .8vh;
}

/* ===========================================================================
   PODIUM DES CLASSES — hommage assumé au diaporama de 2003 :
   WordArt dégradé, biseaux Windows 98, étoiles clignotantes.
   =========================================================================== */

.btn-classes {
  flex: 0 0 auto;
  margin-top: .6vh;
  font-size: 2.6vh;
  min-width: 30vw;
}

.class-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  cursor: pointer;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, #2b1d6e 0%, #16003c 55%, #05000f 100%);
}

/* le ciel étoilé qui clignote */
.vp-stars {
  position: absolute;
  inset: -10%;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cg fill='%23ffffff'%3E%3Ccircle cx='20' cy='30' r='2'/%3E%3Ccircle cx='120' cy='18' r='1.4'/%3E%3Ccircle cx='190' cy='80' r='2.2'/%3E%3Ccircle cx='60' cy='120' r='1.6'/%3E%3Ccircle cx='170' cy='170' r='1.8'/%3E%3Ccircle cx='40' cy='200' r='1.3'/%3E%3Ccircle cx='100' cy='90' r='1.1'/%3E%3C/g%3E%3C/svg%3E");
  animation: twinkle 1.6s steps(2) infinite;
  opacity: .8;
}
@keyframes twinkle { 0%, 100% { opacity: .85; } 50% { opacity: .35; } }

/* les rayons de gloire derrière le podium */
.class-overlay::before {
  content: "";
  position: absolute;
  width: 160vh;
  height: 160vh;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 0, .10) 0deg 7deg,
    transparent 7deg 14deg);
  animation: spin 40s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .vp-stars, .class-overlay::before { animation: none; }
}

.vp-inner { position: relative; text-align: center; padding: 2vh 3vw; }

/* WordArt : dégradé jaune → magenta → cyan, contour noir, ombre portée */
.vp-title {
  margin: 0 0 3vh;
  font-family: var(--font-comic);
  font-size: 8vh;
  font-weight: 700;
  line-height: .95;
  letter-spacing: .3vh;
  background: linear-gradient(180deg, #ffff00 0%, #ff8a00 25%, #ff00d4 60%, #00e5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: rotate(-2deg) skewX(-7deg);
  filter:
    drop-shadow(.25vh 0 0 #000) drop-shadow(-.25vh 0 0 #000)
    drop-shadow(0 .25vh 0 #000) drop-shadow(0 -.25vh 0 #000)
    drop-shadow(.7vh .7vh 0 rgba(0, 0, 0, .55));
}

.vp-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2.5vw;
  margin-bottom: 3vh;
}

.vp-col { display: flex; flex-direction: column; align-items: center; }

.vp-name {
  font-size: 4vh;
  font-weight: 700;
  color: #fff;
  margin-bottom: .8vh;
  text-shadow: .3vh .3vh 0 #000, 0 0 2vh #ff00d4;
}

/* le bloc du podium, biseauté comme un bouton d'interface de 1999 */
.vp-block {
  width: 22vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: .8vh outset #d8d8d8;
  border-radius: .4vh;
  padding: 2vh 1vh;
  box-shadow: 1vh 1vh 0 rgba(0, 0, 0, .45);
  color: #2a1400;
  text-shadow: 0 .15vh 0 rgba(255, 255, 255, .6);
}

.vp-1 .vp-block {
  height: 32vh;
  background: linear-gradient(180deg, #fffbe6 0%, #ffd700 45%, #b8860b 100%);
  border-color: #ffe98a;
}
.vp-2 .vp-block {
  height: 27vh;
  background: linear-gradient(180deg, #ffffff 0%, #d9d9d9 45%, #7d7d7d 100%);
  border-color: #ededed;
}
.vp-3 .vp-block {
  height: 23vh;
  background: linear-gradient(180deg, #ffe3c9 0%, #cd7f32 55%, #7a4715 100%);
  border-color: #f0c39a;
}

.vp-medal { font-size: 5vh; line-height: 1; }
.vp-avg {
  font-size: 6vh;
  font-weight: 700;
  line-height: 1;
  margin-top: .5vh;
  font-variant-numeric: tabular-nums;
}
.vp-unit { font-size: 1.9vh; }
.vp-n { font-size: 1.7vh; opacity: .75; margin-top: .4vh; }

/* les classes suivantes, en petit */
.vp-rest { display: flex; justify-content: center; gap: 1.5vw; flex-wrap: wrap; }
.vp-row {
  display: flex;
  align-items: baseline;
  gap: .6vw;
  padding: .6vh 1.2vw;
  background: linear-gradient(180deg, #4a3a9e, #2a1d6e);
  border: .3vh outset #6f5fd0;
  border-radius: .4vh;
  font-size: 2.4vh;
  color: #fff;
}
.vp-row-rank { color: #ffe98a; font-weight: 700; }
.vp-row-name { font-weight: 700; }
.vp-row-avg { color: #00e5ff; font-weight: 700; }

.vp-hint {
  margin: 3vh 0 0;
  font-size: 2.2vh;
  color: #ffff8a;
  animation: blinkhint 1.2s steps(2) infinite;
}
@keyframes blinkhint { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .vp-hint { animation: none; } }

/* une marche sans classe reste visible, mais éteinte */
.vp-empty .vp-block {
  background: linear-gradient(180deg, #6a6a7d, #3a3a4d) !important;
  border-color: #8a8a9d !important;
  color: #cfcfe0;
  text-shadow: none;
}
.vp-empty .vp-name { opacity: .6; }
.vp-empty .vp-medal, .vp-empty .vp-avg { opacity: .5; }

/* ===========================================================================
   CODE DE LA PARTIE — saisi à la main quand on arrive par la racine du site
   =========================================================================== */

.code-block {
  margin: 0 0 20px;
  padding: 12px 14px;
  text-align: center;
  background: rgba(255, 47, 200, .1);
  border: 2.5px dashed var(--fuchsia-ink);
  border-radius: var(--radius);
}

.code-label {
  display: block;
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.code-input {
  width: 100%;
  max-width: 220px;
  min-height: 56px;
  padding: 6px 8px;
  text-align: center;
  font-family: var(--font-comic);
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: .35em;
  text-indent: .35em;         /* compense le letter-spacing sur le dernier chiffre */
  color: var(--fuchsia-ink);
  background: var(--paper-hi);
  border: 2px solid rgba(58, 47, 38, .35);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.code-input:focus { outline: none; border-color: var(--fuchsia-ink); }
.code-input::placeholder { color: rgba(58, 47, 38, .25); }

/* la note est à virgule : on explique d'où elle vient */
.result-detail {
  margin: 10px 0 0;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink-soft);
}

.lobby-rule {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: .85rem;
  line-height: 1.45;
  color: var(--ink);
  background: rgba(255, 216, 0, .25);
  border-left: 4px solid var(--yellow);
  text-align: left;
}
