* { box-sizing: border-box; }
:root {
  --bg: #d7b07a;
  --wood: #7c3f19;
  --panel: #efe7c8;
  --accent: #c5522b;
  --accent-dark: #8f341c;
  --button-bg: #dcd98a;
  --button-bg-hover: #d5d17f;
  --text: #24160d;
  --score-bg: #e3de93;
  --green: #1f8f45;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(rgba(215, 176, 122, 0.16), rgba(215, 176, 122, 0.16)),
    url("../images/fond-bovins.webp") center center / cover no-repeat fixed,
    linear-gradient(45deg, #c7975b, #f3d796 35%, #b4783c 70%, #efd398);
  min-height: 100vh;
}
@media (max-width: 700px) and (orientation: portrait) {
  body {
    background:
      linear-gradient(rgba(215, 176, 122, 0.12), rgba(215, 176, 122, 0.12)),
      url("../images/fond-bovins-mobile.webp") center bottom / cover no-repeat scroll,
      linear-gradient(180deg, #f3d796, #c7975b);
  }
}

/* Téléphone paysage : même fond large que l’accueil, sans fixed pour éviter les saccades */
@media (max-width: 950px) and (max-height: 620px) and (orientation: landscape) {
  body {
    background:
      linear-gradient(rgba(215, 176, 122, 0.14), rgba(215, 176, 122, 0.14)),
      url("../images/fond-bovins.webp") center center / cover no-repeat scroll,
      linear-gradient(45deg, #c7975b, #f3d796 35%, #b4783c 70%, #efd398);
  }
}
.page { width: min(980px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 36px; }
.page.game-page { width: min(1060px, calc(100% - 28px)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 18px; }
.logo { width: clamp(72px, 9vw, 108px); height: auto; filter: drop-shadow(0 2px 0 rgba(124,63,25,.35)); }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1; }
.subtitle { margin: 8px 0 0; font-weight: 800; }
.panel, .card {
  background: rgba(239, 231, 200, .94);
  border: 4px solid var(--wood);
  border-radius: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.22);
}
.panel { padding: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card { padding: 18px; }
.card h2, .panel h2 { margin-top: 0; color: var(--accent-dark); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
a.button, button, .button {
  display: inline-block;
  border: 3px solid var(--accent);
  background: var(--button-bg);
  color: #111;
  padding: 10px 16px;
  font-weight: 900;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  text-decoration: none;
  font-family: inherit;
  font-size: 1rem;
}
a.button:hover, button:hover, .button:hover { background: var(--button-bg-hover); transform: translateY(-1px); }
.primary { background: #d38b50 !important; }
.primary:hover { background: #c97f43 !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 14px; }
label { display: block; font-weight: 900; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 2px solid var(--wood); border-radius: 7px; font: inherit; background: white;
}
.help { font-size: .92rem; font-weight: 700; opacity: .82; }
.notice { padding: 12px 14px; background: rgba(220,217,138,.5); border: 2px solid rgba(124,63,25,.45); border-radius: 10px; font-weight: 800; }
.error { padding: 12px 14px; background: rgba(197,82,43,.14); border: 2px solid var(--accent); border-radius: 10px; font-weight: 900; }
.success { padding: 12px 14px; background: rgba(31,143,69,.13); border: 2px solid var(--green); border-radius: 10px; font-weight: 900; }
.race-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 420px; overflow: auto; padding: 10px; background: rgba(255,255,255,.35); border: 2px solid rgba(124,63,25,.35); border-radius: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 800; padding: 7px 8px; background: rgba(255,255,255,.45); border-radius: 8px; }
.check input { width: auto; margin: .2rem 0 0; }
.token-box { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(255,255,255,.65); border: 2px solid rgba(124,63,25,.35); border-radius: 8px; padding: 9px 10px; }
table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.45); }
th, td { padding: 8px 10px; border-bottom: 1px solid rgba(124,63,25,.25); text-align: left; vertical-align: top; }
th { color: var(--accent-dark); background: rgba(220,217,138,.45); }
.teacher-results-table th, .teacher-results-table td { white-space: nowrap; }
.teacher-results-table .attempts-cell, .teacher-results-table .last-attempt-cell { white-space: normal; }
@media (max-width: 700px) { .topbar, .brand { display: block; } .logo { margin-top: 12px; } .form-grid { grid-template-columns: 1fr; } }

/* Jeu élève du mode classe */
.hidden { display: none !important; }
.classe-game {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}
.classe-races,
.classe-photo-panel {
  background: rgba(239, 231, 200, .94);
  border: 3px solid var(--wood);
  border-radius: 10px;
  box-shadow: 0 3px 0 rgba(0,0,0,.22);
  padding: 14px;
}
.classe-race-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.classe-race-buttons button {
  text-align: left;
  min-height: 38px;
  padding: 7px 9px;
}
.classe-race-buttons button.ok {
  background: #1f8f45 !important;
  border-color: #155e2e !important;
  color: #fff !important;
}
.classe-race-buttons button.ko {
  background: #c5522b !important;
  border-color: #8f341c !important;
  color: #fff !important;
}
.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
  margin-bottom: 8px;
}
.message {
  min-height: 28px;
  font-weight: 900;
  margin-bottom: 8px;
}
.message.ok { color: #1f8f45; }
.message.ko { color: #8f341c; }
.classe-photo-frame {
  width: 100%;
  aspect-ratio: 3 / 2;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #dfc178;
  border: 4px solid var(--wood);
  border-radius: 8px;
}
.classe-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.result-summary {
  display: grid;
  gap: 4px;
  font-size: 1.1rem;
}
.muted { opacity: .72; font-size: .92em; }
.error-text { color: #a20000; font-weight: 900; }
.results-table td,
.results-table th { white-space: nowrap; }

@media (max-width: 800px) {
  .classe-game { display: flex; flex-direction: column-reverse; }
  .classe-photo-frame { width: 100%; aspect-ratio: 3 / 2; }
  .classe-race-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .classe-race-buttons button { font-size: .78rem; line-height: 1.1; text-align: center; }
}

/* Correction stricte du ratio photo en mode classe */
.game-page .classe-photo-panel {
  width: 100%;
  min-width: 0;
}

.game-page .classe-photo-frame {
  width: 100% !important;
  aspect-ratio: 3 / 2 !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  position: relative;
  display: block !important;
  overflow: hidden;
  background: #dfc178;
  border: 4px solid var(--wood);
  border-radius: 8px;
}

.game-page .classe-photo-frame > img,
.game-page img#questionImage {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
  background: #dfc178;
}

@media (min-width: 901px) {
  .game-page .classe-game {
    grid-template-columns: 300px minmax(0, 820px);
    justify-content: center;
  }
}

@media (max-width: 800px) {
  .game-page .classe-photo-frame {
    width: 100% !important;
    aspect-ratio: 3 / 2 !important;
  }
}

/* Accès élèves imprimables */
.mini-token {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(124,63,25,.35);
  border-radius: 6px;
  padding: 3px 6px;
}

.print-title {
  text-align: center;
  margin: 8px 0 18px;
}

.access-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.access-card {
  border: 3px solid var(--wood);
  border-radius: 12px;
  background: rgba(239, 231, 200, .96);
  padding: 14px;
  break-inside: avoid;
  box-shadow: 0 3px 0 rgba(0,0,0,.16);
}

.access-card h2 {
  margin: 0 0 10px;
  color: var(--accent-dark);
}

.access-label {
  margin: 8px 0 4px;
  font-weight: 900;
}

.print-token {
  font-size: 1rem;
  word-break: break-all;
}

.small-url {
  font-size: .78rem;
  line-height: 1.25;
  word-break: break-all;
}

@media print {
  body {
    background: #fff !important;
  }
  .page {
    max-width: none;
    padding: 0;
  }
  .no-print {
    display: none !important;
  }
  .access-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10mm;
  }
  .access-card {
    box-shadow: none;
    background: #fffdf0;
    page-break-inside: avoid;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
}

/* Impression des accès élèves avec QR codes */
.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 10px;
}

.qr-code {
  width: 132px;
  height: 132px;
  background: #fff;
  padding: 6px;
  border: 2px solid rgba(124, 63, 25, 0.35);
  border-radius: 8px;
  image-rendering: crisp-edges;
}

.qr-missing {
  padding: 8px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(255,255,255,.65);
  color: var(--accent-dark);
  font-weight: 800;
}

.access-actions {
  margin: 8px 0 0;
  text-align: center;
}

.small-button {
  padding: 6px 10px;
  font-size: .86rem;
}

@media print {
  .access-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .qr-code {
    width: 125px;
    height: 125px;
  }

  .small-url {
    display: none;
  }
}

/* Gestion des accès élèves dans le tableau professeur */
.inline-form {
  display: inline;
  margin: 0;
}

button.danger,
.danger {
  border-color: #b00020 !important;
  background: #f4d5d5 !important;
  color: #7a0014 !important;
}

button.danger:hover,
.danger:hover {
  background: #efbcbc !important;
}

.students-table td:last-child {
  white-space: nowrap;
}

@media (max-width: 800px) {
  .students-table {
    font-size: .86rem;
  }
}

/* Tableau professeur : actualisation et panneau accès élèves repliable */
.live-status {
  margin: 12px 0 0;
  font-weight: 800;
  font-size: .92rem;
  color: var(--accent-dark);
}

.live-status-new {
  background: rgba(31, 143, 69, .13);
  border: 2px solid var(--green);
  border-radius: 8px;
  padding: 7px 10px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.section-title-row h2 {
  margin: 0;
}

.participation-badge {
  display: inline-block;
  padding: 6px 10px;
  border: 2px solid rgba(124, 63, 25, .42);
  border-radius: 999px;
  background: rgba(220, 217, 138, .55);
  font-weight: 900;
  white-space: nowrap;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapsible-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--accent-dark);
  font-size: 1.15rem;
  font-weight: 900;
  background: rgba(220, 217, 138, .42);
}

.collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel > summary::after {
  content: "Afficher";
  font-size: .9rem;
  color: #111;
  background: var(--button-bg);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 5px 10px;
}

.collapsible-panel[open] > summary::after {
  content: "Masquer";
}

.summary-hint {
  font-size: .86rem;
  color: var(--text);
  opacity: .78;
  font-weight: 800;
}

.details-content {
  padding: 18px;
  overflow-x: auto;
}

@media (max-width: 700px) {
  .section-title-row,
  .collapsible-panel > summary {
    display: block;
  }

  .participation-badge,
  .summary-hint {
    margin-top: 8px;
  }
}

/* Mode classe élève — liste de races compacte et stable */
.game-page .classe-game {
  grid-template-columns: 360px minmax(0, 820px);
}

.game-page .classe-races {
  max-height: calc(100dvh - 140px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-page .classe-races h2 {
  margin-top: 0;
  flex-shrink: 0;
}

.game-page .classe-race-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.game-page .classe-race-buttons button {
  min-height: 34px;
  padding: 5px 6px;
  font-size: .78rem;
  line-height: 1.05;
  text-align: center;
  hyphens: auto;
}

@media (max-width: 800px) {
  .game-page .classe-game {
    grid-template-columns: 1fr;
  }

  .game-page .classe-races {
    max-height: none;
  }

  .game-page .classe-race-buttons {
    max-height: none;
    overflow: visible;
  }
}

/* Tableau professeur : résultats groupés par élève */
.grouped-results-table td,
.grouped-results-table th {
  vertical-align: top;
}

.result-summary-row > td {
  border-bottom: 1px solid rgba(124, 63, 25, 0.22);
}

.attempt-details summary {
  cursor: pointer;
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid rgba(124, 63, 25, .42);
  border-radius: 999px;
  background: rgba(220, 217, 138, .55);
  font-weight: 900;
  color: var(--accent-dark);
}

.attempt-details[open] summary {
  margin-bottom: 8px;
}

.attempts-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  margin-top: 8px;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(124, 63, 25, .28);
  border-radius: 8px;
  overflow: hidden;
}

.attempts-table th,
.attempts-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(124, 63, 25, .18);
  font-size: .9rem;
}

.attempts-table tr:last-child td {
  border-bottom: 0;
}

.progress-good {
  color: #1f8f45;
  font-weight: 900;
}

.progress-bad {
  color: var(--accent-dark);
  font-weight: 900;
}

.attempt-status-en_cours td {
  background: rgba(220, 217, 138, .28);
}

.attempt-status-abandonnee td,
.attempt-status-annulee td {
  opacity: .75;
}

@media (max-width: 800px) {
  .grouped-results-table,
  .grouped-results-table thead,
  .grouped-results-table tbody,
  .grouped-results-table th,
  .grouped-results-table td,
  .grouped-results-table tr {
    display: block;
  }

  .grouped-results-table thead {
    display: none;
  }

  .result-summary-row {
    margin-bottom: 12px;
    border: 2px solid rgba(124, 63, 25, .32);
    border-radius: 10px;
    background: rgba(255, 255, 255, .38);
    padding: 8px;
  }

  .result-summary-row > td {
    border-bottom: 0;
    padding: 5px 0;
  }

  .attempts-table {
    min-width: 560px;
  }
}


/* Tableau professeur : détail des tentatives placé sur une ligne séparée */
.grouped-results-table {
  width: 100%;
  table-layout: auto;
}

.grouped-results-table .detail-toggle {
  padding: 5px 12px;
  border: 2px solid rgba(124, 63, 25, .42);
  border-radius: 999px;
  background: rgba(220, 217, 138, .55);
  color: var(--accent-dark);
  font-weight: 900;
  box-shadow: none;
}

.grouped-results-table .detail-toggle:hover {
  transform: none;
  background: rgba(220, 217, 138, .85);
}

.attempt-detail-row > td {
  padding: 0 10px 14px;
  background: rgba(255, 255, 255, .22);
  border-bottom: 1px solid rgba(124, 63, 25, .22);
}

.attempt-detail-box {
  margin: 6px 0 8px;
  padding: 12px;
  border: 2px solid rgba(124, 63, 25, .35);
  border-radius: 10px;
  background: rgba(255, 255, 255, .66);
}

.attempt-detail-title {
  margin-bottom: 8px;
  font-weight: 900;
  color: var(--accent-dark);
}

.attempt-table-scroll {
  overflow-x: auto;
}

.attempt-table-scroll .attempts-table {
  min-width: 0;
  width: 100%;
}

@media (max-width: 800px) {
  .attempt-detail-row {
    display: block;
    margin-top: -10px;
    margin-bottom: 12px;
  }

  .attempt-detail-row > td {
    display: block;
    padding: 0 8px 10px;
  }

  .attempt-table-scroll .attempts-table {
    min-width: 560px;
  }
}


/* Correctif v14c : résultats groupés stables et contenu contenu dans le panneau */
#resultsContainer {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.grouped-results-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.grouped-results-table th,
.grouped-results-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.grouped-results-table th:nth-child(1),
.grouped-results-table td:nth-child(1) { width: 8%; }
.grouped-results-table th:nth-child(2),
.grouped-results-table td:nth-child(2) { width: 14%; }
.grouped-results-table th:nth-child(3),
.grouped-results-table td:nth-child(3) { width: 10%; }
.grouped-results-table th:nth-child(4),
.grouped-results-table td:nth-child(4) { width: 11%; }
.grouped-results-table th:nth-child(5),
.grouped-results-table td:nth-child(5) { width: 18%; }
.grouped-results-table th:nth-child(6),
.grouped-results-table td:nth-child(6) { width: 14%; }
.grouped-results-table th:nth-child(7),
.grouped-results-table td:nth-child(7) { width: 10%; }
.grouped-results-table th:nth-child(8),
.grouped-results-table td:nth-child(8) { width: 12%; }

.attempt-detail-row > td {
  width: 100%;
  padding: 0 0 14px !important;
  background: rgba(255, 255, 255, .22);
}

.attempt-detail-box {
  display: block;
  width: calc(100% - 20px);
  max-width: calc(100% - 20px);
  margin: 8px 10px 12px;
  box-sizing: border-box;
}

.attempt-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.attempt-table-scroll .attempts-table {
  width: 100%;
  min-width: 660px;
  table-layout: auto;
}

.attempt-table-scroll .attempts-table th,
.attempt-table-scroll .attempts-table td {
  white-space: nowrap;
  overflow-wrap: normal;
}

@media (max-width: 800px) {
  .grouped-results-table,
  .grouped-results-table tbody,
  .grouped-results-table tr,
  .grouped-results-table td {
    width: 100% !important;
  }

  .attempt-detail-box {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* v15 : résultats pédagogiques — priorité aux races reconnues */
.grouped-results-table th,
.grouped-results-table td {
  vertical-align: top;
}

.progress-good {
  color: #1f7a3a;
  font-weight: 900;
}

.progress-bad {
  color: #9a2b1f;
  font-weight: 900;
}

/* Correctif v18 : le bouton Voir/Masquer ne doit jamais couper le texte */
.grouped-results-table .detail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  line-height: 1.1;
}

.grouped-results-table th:last-child,
.grouped-results-table td:last-child {
  width: 108px;
  min-width: 108px;
  text-align: center;
}

@media (max-width: 760px) {
  .grouped-results-table th:last-child,
  .grouped-results-table td:last-child {
    width: auto;
    min-width: 88px;
  }

  .grouped-results-table .detail-toggle {
    min-width: 78px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* v20 — impression élèves en bandes horizontales faciles à découper */
.access-strips {
  display: grid;
  gap: 8mm;
}

.access-strip {
  display: grid;
  grid-template-columns: 1.15fr 132px 1.25fr;
  gap: 14px;
  align-items: center;
  border: 2.5px solid var(--wood);
  border-radius: 10px;
  background: rgba(239, 231, 200, .96);
  padding: 10px 14px;
  break-inside: avoid;
  page-break-inside: avoid;
  box-shadow: 0 2px 0 rgba(0,0,0,.14);
}

.access-strip-id h2 {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 1.6rem;
}

.student-print-name {
  margin: 0;
  font-weight: 900;
  font-size: 1.05rem;
}

.student-blank-name {
  margin: 4px 0;
  font-size: .96rem;
}

.access-strip-qr {
  display: grid;
  place-items: center;
}

.access-strip-token .access-label {
  margin-top: 0;
}

.token-help {
  margin: 5px 0 0;
  font-size: .78rem;
  opacity: .78;
}

.student-name-form {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(90px, 1fr) auto;
  gap: 5px;
  align-items: center;
}

.student-name-form input {
  margin: 0;
  padding: 6px 8px;
  font-size: .85rem;
}

@media print {
  .access-strips {
    gap: 5mm;
  }

  .access-strip {
    box-shadow: none;
    background: #fffdf0;
    grid-template-columns: 1.2fr 28mm 1.2fr;
    gap: 7mm;
    padding: 5mm 6mm;
    border-width: 2px;
  }

  .access-strip-id h2 {
    font-size: 1.35rem;
  }

  .access-strip .qr-code {
    width: 28mm;
    height: 28mm;
    padding: 2mm;
  }

  .access-strip .print-token {
    font-size: 1.08rem;
    text-align: center;
    letter-spacing: .06em;
    word-break: normal;
  }

  .token-help {
    font-size: .72rem;
  }
}

@media (max-width: 720px) {
  .access-strip {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .student-name-form {
    grid-template-columns: 1fr;
  }
}

/* v22 — impression compacte des accès élèves : une bande découpable par élève */
.access-strip {
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 14px;
  align-items: center;
}

.access-strip-info {
  min-width: 0;
}

.access-strip-id {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
}

.access-strip-id h2 {
  flex: 0 0 auto;
  min-width: 58px;
  margin: 0;
}

.student-lines {
  flex: 1 1 auto;
  min-width: 0;
}

.access-strip-token {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.access-strip-token .access-label {
  margin: 0;
  white-space: nowrap;
}

.access-strip-token .print-token {
  flex: 1 1 auto;
  min-width: 0;
}

.old-token-note {
  margin: 6px 0 0;
}

@media print {
  @page {
    margin: 8mm 9mm;
  }

  .print-page {
    max-width: none;
    padding: 0;
  }

  .print-title {
    margin-bottom: 5mm;
  }

  .print-title h1 {
    font-size: 17pt;
    margin-bottom: 2mm;
  }

  .print-title p {
    margin: 0;
    font-size: 9pt;
  }

  .access-strips {
    gap: 3mm;
  }

  .access-strip {
    grid-template-columns: minmax(0, 1fr) 24mm;
    gap: 5mm;
    min-height: 28mm;
    padding: 3mm 5mm;
    border-width: 1.5px;
    border-radius: 6px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .access-strip-id {
    gap: 5mm;
    align-items: flex-start;
  }

  .access-strip-id h2 {
    min-width: 16mm;
    font-size: 14pt;
    line-height: 1.1;
  }

  .student-lines {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;
  }

  .student-blank-name {
    margin: 0;
    font-size: 9.5pt;
    white-space: nowrap;
  }

  .access-strip-token {
    margin-top: 2.5mm;
    gap: 3mm;
  }

  .access-strip-token .access-label {
    font-size: 9.5pt;
    font-weight: 900;
  }

  .access-strip .print-token {
    display: inline-block;
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    padding: 1.2mm 3mm;
    font-size: 10pt;
    letter-spacing: .04em;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .access-strip .qr-code {
    width: 22mm;
    height: 22mm;
    padding: 1mm;
  }

  .token-help {
    display: none;
  }

  .old-token-note {
    font-size: 9pt;
    margin: 2mm 0 0;
  }
}

@media (max-width: 720px) {
  .access-strip-id {
    display: block;
  }

  .access-strip-token {
    justify-content: center;
  }
}

/* v23 — affichage écran plus étroit pour la page d'impression des accès.
   Le CSS @media print ci-dessus reste prioritaire pour le PDF. */
@media screen {
  .print-page {
    width: min(820px, calc(100% - 28px));
  }

  .print-page .topbar {
    align-items: flex-start;
  }

  .print-page .topbar h1 {
    font-size: clamp(2.1rem, 4.4vw, 3.2rem);
  }

  .print-page .access-strips {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
  }

  .print-page .access-strip {
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 12px;
  }

  .print-page .qr-code {
    width: 96px;
    height: 96px;
    padding: 5px;
  }

  .print-page .access-strip-token .print-token {
    font-size: .92rem;
  }
}

/* ── Auto-inscription / top départ ───────────────────────────── */
.big-code {
  font-size: 1.12rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 8px;
}

.auto-session-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: center;
}

.session-qr-box {
  text-align: center;
}

.session-qr {
  width: 230px;
  height: 230px;
  background: #fff;
  border: 2px solid rgba(124,63,25,.35);
  border-radius: 12px;
  padding: 10px;
}

.waiting-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 2px dashed var(--wood);
  border-radius: 10px;
  background: rgba(255,255,255,.45);
}

.waiting-spinner {
  width: 28px;
  height: 28px;
  border: 4px solid rgba(124,63,25,.25);
  border-top-color: var(--accent-dark);
  border-radius: 50%;
  animation: classe-spin .9s linear infinite;
  flex-shrink: 0;
}

@keyframes classe-spin { to { transform: rotate(360deg); } }

.join-form, .join-success {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 720px) {
  .auto-session-grid {
    grid-template-columns: 1fr;
  }
  .session-qr {
    width: 140px;
    height: 140px;
  }
}


/* Rejoindre une séance : disposition plus claire et compacte */
.join-page-compact {
  width: min(900px, calc(100% - 28px));
}

.join-topbar {
  margin-bottom: 18px;
}

.join-error {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.join-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 22px;
}

.join-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.join-card-head h2 {
  margin: 2px 0 0;
  color: var(--accent-dark);
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.join-eyebrow {
  margin: 0;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent-dark);
  opacity: .82;
}

.join-session-code {
  flex: 0 0 auto;
  display: inline-block;
  padding: 8px 14px;
  border: 2px solid rgba(124,63,25,.45);
  border-radius: 10px;
  background: rgba(255,255,255,.62);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
}

.join-instructions,
.join-waiting,
.join-closed-box {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 2px solid rgba(124,63,25,.35);
  border-radius: 10px;
  background: rgba(220,217,138,.35);
  font-weight: 800;
  line-height: 1.35;
}

.join-closed-box {
  border-color: rgba(197,82,43,.65);
  background: rgba(255,255,255,.42);
  color: var(--accent-dark);
}

.join-ready {
  border-color: rgba(31,143,69,.55);
}

.join-fields-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.join-ident-field,
.join-code-field {
  display: block;
  margin: 0;
}

.join-ident-field input,
.join-code-field input {
  margin-top: 6px;
}

.join-code-field input {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.join-submit {
  min-width: 140px;
  min-height: 48px;
}

.join-help {
  margin-bottom: 0;
}

.join-actions {
  margin-top: 14px;
}

.join-success-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 14px;
}

.join-small-label {
  display: block;
  margin-bottom: 5px;
  color: var(--accent-dark);
  font-weight: 900;
}

.join-token-box {
  display: inline-block;
  width: auto;
  min-width: 180px;
  padding: 9px 14px;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .join-card {
    padding: 16px;
  }

  .join-card-head,
  .join-fields-row,
  .join-success-actions {
    display: block;
  }

  .join-session-code {
    margin-top: 10px;
  }

  .join-submit,
  .join-success-actions .button {
    width: 100%;
    margin-top: 12px;
  }
}


/* v29 — résultats prof plus compacts + pseudos élèves maîtrisés */
.grouped-results-table {
  table-layout: fixed;
}

.grouped-results-table th,
.grouped-results-table td {
  overflow-wrap: normal;
  word-break: normal;
}

.grouped-results-table th:nth-child(1),
.grouped-results-table td:nth-child(1) {
  width: 12%;
  max-width: 12%;
}

.grouped-results-table th:nth-child(2),
.grouped-results-table td:nth-child(2) { width: 13%; }
.grouped-results-table th:nth-child(3),
.grouped-results-table td:nth-child(3) { width: 9%; text-align: center; }
.grouped-results-table th:nth-child(4),
.grouped-results-table td:nth-child(4) { width: 10%; text-align: center; }
.grouped-results-table th:nth-child(5),
.grouped-results-table td:nth-child(5) { width: 17%; }
.grouped-results-table th:nth-child(6),
.grouped-results-table td:nth-child(6) { width: 15%; }
.grouped-results-table th:nth-child(7),
.grouped-results-table td:nth-child(7) { width: 112px; min-width: 112px; }

.grouped-results-table .student-ident-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: normal;
}

.attempt-detail-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.join-ident-field input {
  max-width: 100%;
}

.join-ident-field small,
.join-ident-limit {
  display: block;
  margin-top: 4px;
  font-size: .78rem;
  color: rgba(36,22,13,.72);
  font-weight: 700;
}

/* Création de séance : compteur et choix manuel des photos */
.selection-counter {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  padding: 10px 12px;
  border: 2px solid rgba(124,63,25,.45);
  border-radius: 10px;
  background: rgba(220,217,138,.82);
  font-weight: 900;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.selection-counter span {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(124,63,25,.25);
}

.selection-counter .limit-warning {
  color: #8f1f13;
  background: rgba(255,255,255,.75);
  border-color: rgba(197,82,43,.55);
}
.race-choice.is-disabled {
  opacity: .52;
  filter: grayscale(.2);
}
.race-choice.is-disabled input {
  cursor: not-allowed;
}
.photo-selection {
  display: grid;
  gap: 12px;
  max-height: 680px;
  overflow: auto;
  padding: 10px;
  background: rgba(255,255,255,.30);
  border: 2px solid rgba(124,63,25,.35);
  border-radius: 10px;
}
.photo-race-block {
  padding: 12px;
  border: 2px solid rgba(124,63,25,.45);
  border-radius: 10px;
  background: rgba(255,255,255,.42);
}
.photo-race-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.photo-race-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.small-button {
  padding: 5px 9px;
  border-width: 2px;
  border-radius: 7px;
  font-size: .82rem;
  box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.photo-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 9px;
}
.photo-thumb-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 8px;
  align-items: start;
  padding: 7px;
  border: 2px solid rgba(124,63,25,.25);
  border-radius: 9px;
  background: rgba(255,255,255,.62);
  font-weight: 800;
  cursor: pointer;
}
.photo-thumb-card:hover {
  border-color: var(--wood);
  background: rgba(255,255,255,.82);
}
.photo-thumb-card input {
  width: auto;
  margin: 4px 0 0;
}
.photo-thumb-img-wrap {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(124,63,25,.35);
  background: rgba(223,193,120,.55);
}
.photo-thumb-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb-caption {
  grid-column: 2;
  font-size: .74rem;
  line-height: 1.15;
  opacity: .82;
}
@media (max-width: 700px) {
  .photo-race-heading { display: block; }
  .photo-race-actions { margin-top: 8px; }
  .photo-thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Impression / affichage du QR code de séance */
.print-session-qr-page {
  max-width: 860px;
}

.session-qr-print-card {
  background: rgba(239, 231, 200, .94);
  border: 4px solid var(--wood);
  border-radius: 14px;
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  padding: 28px;
  text-align: center;
}

.session-qr-print-card h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  color: var(--accent-dark);
}

.session-qr-kicker,
.session-qr-instruction {
  margin: 0 0 12px;
  font-weight: 800;
}

.session-qr-print-img {
  width: min(56vw, 420px);
  height: min(56vw, 420px);
  max-width: 420px;
  max-height: 420px;
  background: #fff;
  border: 3px solid rgba(124,63,25,.35);
  border-radius: 14px;
  padding: 14px;
  margin: 14px auto 18px;
  display: block;
}

.session-qr-code-block {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(100%, 420px);
  padding: 12px 20px;
  border: 3px solid var(--accent);
  border-radius: 12px;
  background: rgba(255,255,255,.68);
}

.session-qr-code-block span {
  font-weight: 900;
  color: var(--accent-dark);
}

.session-qr-code-block strong {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  letter-spacing: .08em;
}

.session-qr-help {
  margin: 12px 0 0;
  font-size: .9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

@media print {
  .print-session-qr-page {
    max-width: none;
    padding: 0;
  }

  .session-qr-print-card {
    border: 2px solid #7c3f19;
    box-shadow: none;
    padding: 18mm 14mm;
    min-height: 245mm;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    page-break-inside: avoid;
  }

  .session-qr-print-img {
    width: 118mm;
    height: 118mm;
    max-width: none;
    max-height: none;
    padding: 4mm;
  }

  .session-qr-code-block {
    min-width: 110mm;
    padding: 4mm 8mm;
  }

  .session-qr-code-block strong {
    font-size: 30pt;
  }

  .session-qr-help {
    font-size: 9pt;
  }
}

/* ─────────────────────────────────────────────────────────────
   Accueil du mode classe — affichage plus harmonieux
   ───────────────────────────────────────────────────────────── */
.grid.home-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.home-grid .home-card {
  display: flex;
  flex-direction: column;
  min-height: 365px;
}

.home-grid .home-card h2 {
  margin-bottom: 18px;
}

.home-grid .home-card p {
  line-height: 1.42;
}

.home-grid .home-card > .actions:first-of-type {
  margin-top: auto;
}

.home-grid .home-card form + hr {
  width: 100%;
  border: 0;
  border-top: 2px solid rgba(124, 63, 25, .38);
  margin: 14px 0 10px;
}

.tutorial-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 2px dashed rgba(124, 63, 25, .45);
  border-radius: 10px;
  background: rgba(255, 255, 255, .38);
}

.tutorial-link {
  display: inline-block;
  font-weight: 900;
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 2px solid rgba(124, 63, 25, .45);
}

.tutorial-link::before {
  content: "Guide PDF — ";
}

.tutorial-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tutorial-box p {
  margin: 8px 0 0;
  font-size: .94rem;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .grid.home-grid {
    grid-template-columns: 1fr;
  }

  .home-grid .home-card {
    min-height: 0;
  }

  .home-grid .home-card > .actions:first-of-type {
    margin-top: 16px;
  }
}

/* v35 — correction de l'en-tête du mode classe sur petits écrans
   Objectif : garder le logo à droite du titre au lieu de le faire descendre
   entre le titre et les boutons. */
@media (max-width: 700px) {
  .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title logo"
      "actions actions";
    align-items: start;
    gap: 10px 12px;
    margin-bottom: 14px;
  }

  .topbar > div:first-child {
    grid-area: title;
    min-width: 0;
  }

  .topbar .brand {
    display: contents !important;
  }

  .topbar .brand .logo,
  .topbar .logo {
    grid-area: logo;
    justify-self: end;
    align-self: start;
    width: 72px;
    max-width: 72px;
    margin: 0 !important;
  }

  .topbar .brand .button,
  .topbar .brand button {
    grid-area: actions;
    justify-self: start;
    width: auto;
    max-width: 100%;
    margin-top: 2px;
  }

  .topbar h1 {
    font-size: clamp(1.85rem, 9vw, 2.55rem);
    line-height: 1.02;
  }

  .topbar .subtitle {
    margin-top: 6px;
    font-size: .92rem;
    line-height: 1.25;
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 8px 10px;
  }

  .topbar .brand .logo,
  .topbar .logo {
    width: 64px;
    max-width: 64px;
  }

  .topbar h1 {
    font-size: clamp(1.65rem, 9vw, 2.2rem);
  }

  .topbar .subtitle {
    font-size: .86rem;
  }
}

/* ─────────────────────────────────────────────────────────────
   Bandeau commun Défi Races Bovines — mode classe
   Harmonisation avec l'accueil, l'encyclopédie et les pages annexes.
   Placé en fin de fichier pour écraser les anciennes règles .topbar.
   ───────────────────────────────────────────────────────────── */
.topbar.app-header {
  width: 100% !important;
  margin: 0 0 18px !important;
  padding: 12px 18px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 18px !important;
  background: linear-gradient(135deg, #bd7c28, #d19a37) !important;
  border: 3px solid var(--wood) !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 0 rgba(0,0,0,.16) !important;
}

.topbar.app-header .brand {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  min-width: 0 !important;
  color: #fff8e8 !important;
}

.topbar.app-header .header-logo {
  width: 46px !important;
  max-width: 46px !important;
  height: auto !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.18));
}

.topbar.app-header .brand-text {
  min-width: 0 !important;
}

.topbar.app-header h1 {
  margin: 0 !important;
  color: #fff8e8 !important;
  font-size: clamp(1.15rem, 2vw, 1.55rem) !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  letter-spacing: 0 !important;
  text-shadow: 0 1px 0 rgba(0,0,0,.18);
}

.topbar.app-header .subtitle {
  margin: 2px 0 0 !important;
  color: #fff8e8 !important;
  font-size: .78rem !important;
  font-weight: 800 !important;
  line-height: 1.1 !important;
  opacity: .96 !important;
}

.topbar.app-header .header-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  margin-left: auto !important;
  flex: 0 0 auto !important;
}

.topbar.app-header .header-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 36px !important;
  padding: 7px 12px !important;
  border: 2px solid rgba(255,255,255,.75) !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,.16) !important;
  color: #fff8e8 !important;
  box-shadow: none !important;
  font: inherit !important;
  font-size: .88rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  cursor: pointer !important;
}

.topbar.app-header .header-link:hover {
  background: rgba(255,255,255,.28) !important;
  transform: translateY(-1px) !important;
}

.topbar.app-header button.header-link {
  appearance: none !important;
}

/* Les anciens boutons placés dans les en-têtes ne doivent plus hériter de l'ancien style massif. */
.topbar.app-header .button {
  box-shadow: none !important;
}

@media (max-width: 700px) {
  .page,
  .page.game-page,
  .join-page-compact,
  .print-page,
  .print-session-qr-page {
    width: min(100% - 16px, 980px) !important;
    padding-top: 8px !important;
  }

  .topbar.app-header,
  .topbar.app-header.join-topbar {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    gap: 8px !important;
    padding: 9px 10px !important;
    border-width: 2px !important;
    border-radius: 11px !important;
    margin-bottom: 12px !important;
  }

  .topbar.app-header .brand {
    display: flex !important;
    align-items: center !important;
    gap: 7px !important;
    width: 100% !important;
  }

  .topbar.app-header .header-logo {
    width: 34px !important;
    max-width: 34px !important;
  }

  .topbar.app-header h1 {
    font-size: 1.02rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar.app-header .subtitle {
    font-size: .62rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar.app-header .header-actions {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
    margin-left: 0 !important;
  }

  .topbar.app-header .header-link {
    min-height: 30px !important;
    padding: 6px 8px !important;
    border-width: 1.5px !important;
    border-radius: 7px !important;
    font-size: .78rem !important;
  }
}

@media (max-width: 420px) {
  .topbar.app-header .subtitle {
    display: none !important;
  }
}

@media (max-width: 950px) and (max-height: 620px) and (orientation: landscape) {
  .page,
  .page.game-page,
  .join-page-compact {
    width: min(100% - 16px, 1060px) !important;
    padding-top: 6px !important;
  }

  .topbar.app-header {
    display: flex !important;
    padding: 7px 10px !important;
    gap: 10px !important;
    border-width: 2px !important;
    margin-bottom: 8px !important;
  }

  .topbar.app-header .header-logo {
    width: 32px !important;
    max-width: 32px !important;
  }

  .topbar.app-header h1 {
    font-size: .96rem !important;
    max-width: 260px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar.app-header .subtitle {
    display: none !important;
  }

  .topbar.app-header .header-actions {
    display: flex !important;
    gap: 7px !important;
  }

  .topbar.app-header .header-link {
    min-height: 28px !important;
    padding: 5px 10px !important;
    border-width: 1.5px !important;
    font-size: .76rem !important;
  }
}


/* ─────────────────────────────────────────────────────────────
   Correctifs rejoindre.php — bandeau aligné, titre nettoyé,
   formulaire plus stable sur écran large et mobile.
   ───────────────────────────────────────────────────────────── */
.join-page-compact > .topbar.app-header.join-topbar,
.join-page-compact > .join-card,
.join-page-compact > .join-error {
  max-width: 760px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.join-page-compact > .topbar.app-header.join-topbar {
  margin-bottom: 16px !important;
}

.join-card-head h2 {
  margin: 3px 0 0 !important;
  line-height: 1.05 !important;
  overflow-wrap: anywhere !important;
}

.join-card-head h2::before,
.join-card-head h2::after {
  content: none !important;
  display: none !important;
}

.join-form-v2 .join-fields-row {
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 14px;
}

.join-form-v2 .join-submit {
  width: 100%;
}

.join-ident-field input,
.join-code-field input {
  font-size: 1rem;
}

.join-ident-field small,
.join-ident-limit {
  display: block;
  margin-top: 5px;
  line-height: 1.25;
}

.join-success-actions .button {
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .join-page-compact > .topbar.app-header.join-topbar,
  .join-page-compact > .join-card,
  .join-page-compact > .join-error {
    max-width: none !important;
  }

  .join-card-head {
    gap: 8px !important;
  }

  .join-card-head h2 {
    font-size: 1.55rem !important;
  }

  .join-instructions,
  .join-waiting,
  .join-closed-box {
    padding: 10px 12px !important;
    font-size: .92rem !important;
  }

  .join-form-v2 .join-fields-row {
    display: block !important;
  }

  .join-form-v2 .join-submit {
    width: 100% !important;
    margin-top: 12px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   Correctif rejoindre.php v3 — alignement du bouton S'inscrire.
   Le bouton s'aligne sur le champ de saisie, pas sur la ligne d'aide.
   ───────────────────────────────────────────────────────────── */
@media (min-width: 701px) {
  .join-form-v2 .join-fields-row {
    align-items: start !important;
  }

  .join-form-v2 .join-submit {
    align-self: start !important;
    margin-top: 26px !important;
    min-height: 48px !important;
    height: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   Correctif mobile portrait — bandeau mode classe
   Objectif : logo + titre en haut, boutons de navigation dessous,
   sans empilement inversé ni décalage sur téléphone.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) and (orientation: portrait) {
  .page,
  .page.game-page,
  .join-page-compact,
  .print-page,
  .print-session-qr-page {
    width: min(100% - 14px, 980px) !important;
    padding-top: 8px !important;
  }

  .topbar.app-header,
  .topbar.app-header.join-topbar,
  .topbar.app-header.no-print {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 9px !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 10px 11px !important;
    margin: 0 0 12px !important;
    border-width: 2px !important;
    border-radius: 11px !important;
  }

  .topbar.app-header .brand {
    order: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .topbar.app-header .header-logo,
  .topbar.app-header .brand .header-logo {
    width: 36px !important;
    max-width: 36px !important;
    height: auto !important;
    flex: 0 0 36px !important;
    margin: 0 !important;
  }

  .topbar.app-header .brand-text {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .topbar.app-header h1 {
    margin: 0 !important;
    font-size: 1.12rem !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar.app-header .subtitle {
    display: block !important;
    margin: 2px 0 0 !important;
    font-size: .66rem !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar.app-header .header-actions {
    order: 2 !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
    margin: 0 !important;
    align-items: stretch !important;
  }

  .topbar.app-header .header-link,
  .topbar.app-header button.header-link {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 31px !important;
    padding: 6px 7px !important;
    font-size: .76rem !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
  }

  .panel,
  .card {
    border-width: 3px !important;
  }

  input,
  select,
  textarea {
    font-size: .95rem !important;
    line-height: 1.2 !important;
    padding: 10px 11px !important;
  }
}

@media (max-width: 380px) and (orientation: portrait) {
  .topbar.app-header .subtitle {
    display: none !important;
  }

  .topbar.app-header h1 {
    font-size: 1rem !important;
  }

  .topbar.app-header .header-actions {
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr)) !important;
    gap: 6px !important;
  }

  .topbar.app-header .header-link,
  .topbar.app-header button.header-link {
    font-size: .72rem !important;
    padding-left: 5px !important;
    padding-right: 5px !important;
  }
}

/* Libellés courts du bandeau commun sur mobile */
.label-mobile {
  display: none;
}

.label-desktop {
  display: inline;
}

@media (max-width: 700px) {
  .label-desktop {
    display: none;
  }

  .label-mobile {
    display: inline;
  }
}


/* Défi v1.21.43 — entête harmonisé : état actif visible sur les pages du mode classe */
.topbar.app-header .header-link.is-active,
.topbar.app-header .header-link[aria-current="page"] {
  border-color: rgba(255,255,255,.88) !important;
  background: #2f8736 !important;
  color: #fff8e8 !important;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 0 rgba(62, 34, 15, .28) !important;
}

.topbar.app-header .header-link.is-active:hover,
.topbar.app-header .header-link[aria-current="page"]:hover {
  background: #2f8736 !important;
  transform: none !important;
}

/* ─────────────────────────────────────────────────────────────
   Défi v1.21.57 — navigation mobile commune
   La navigation de bureau reste inchangée au-dessus de 700 px.
   ───────────────────────────────────────────────────────────── */
.site-mobile-header-row,
.site-mobile-menu {
  display: none;
}

@media (max-width: 700px) {
  .topbar.app-header {
    position: relative !important;
    display: block !important;
    min-height: 0 !important;
    margin-bottom: 10px !important;
    padding: 8px 10px !important;
    border: 2px solid #8a4c24 !important;
    border-radius: 14px !important;
    background: linear-gradient(135deg, #d5a24a 0%, #c88c35 100%) !important;
    box-shadow: 0 3px 0 rgba(97, 53, 23, .18) !important;
    overflow: visible !important;
  }

  .topbar.app-header > .brand,
  .topbar.app-header > .header-actions {
    display: none !important;
  }

  .site-mobile-header-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
  }

  .site-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: #3c1d0e;
    text-decoration: none;
    font-weight: 950;
    font-size: clamp(1.12rem, 5.2vw, 1.46rem);
    line-height: 1.05;
    letter-spacing: -.02em;
  }

  .site-mobile-brand:hover,
  .site-mobile-brand:focus-visible {
    color: #2f160a;
    outline: none;
  }

  .site-mobile-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    object-fit: contain;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.28));
  }

  .site-mobile-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-mobile-menu-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    padding: 0;
    border: 2px solid #7b431f;
    border-radius: 12px;
    background: #fff7df;
    color: #3d1e0f;
    box-shadow: 0 2px 0 rgba(88, 45, 20, .2);
    cursor: pointer;
  }

  .site-mobile-menu-button span {
    display: block;
    width: 19px;
    height: 2.5px;
    border-radius: 999px;
    background: currentColor;
    transition: transform .16s ease, opacity .16s ease;
  }

  .site-mobile-menu-button[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .site-mobile-menu-button[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .site-mobile-menu-button[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }

  .site-mobile-menu {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 7px);
    right: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 9px;
    border: 2px solid #8a4c24;
    border-radius: 13px;
    background: #fff8e2;
    box-shadow: 0 13px 30px rgba(59, 29, 12, .28);
  }

  .site-mobile-menu[hidden] {
    display: none !important;
  }

  .site-mobile-menu a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 43px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #3d1e0f;
    background: transparent;
    font-size: .98rem;
    font-weight: 850;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
  }

  .site-mobile-menu a.site-mobile-menu-cta {
    grid-column: 1 / -1;
    margin-top: 3px;
    border-color: #91b879;
    background: #e8f4dc;
    color: #245c2c;
  }

  .site-mobile-menu a.site-mobile-menu-cta:hover,
  .site-mobile-menu a.site-mobile-menu-cta:focus-visible {
    border-color: #4d8c50;
    background: #d9edc7;
  }

  .site-mobile-menu a:hover,
  .site-mobile-menu a:focus-visible {
    border-color: #d9b575;
    background: #f6e8bf;
    outline: none;
  }

  .site-mobile-menu a.is-active {
    border-color: #2d7735;
    background: linear-gradient(180deg, #4ba94f, #35873d);
    color: #fff;
    box-shadow: inset 0 -2px 0 rgba(24, 84, 31, .25);
  }

  /* Le tableau de score éventuel reste disponible sous le bandeau de jeu. */
  .topbar.app-header > .scoreboard {
    margin-top: 8px;
  }
}

@media (max-width: 370px) {
  .site-mobile-logo {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .site-mobile-brand {
    font-size: 1.08rem;
  }
}
