/* CollabQuiz - Jeu : organisateur, joueur, salle, bataille, labyrinthe et nuage de mots.
 * Ordre des feuilles : style, creator, content, game, results, autonomous.
 * Conserver les surcharges et les media queries dans leur ordre relatif.
 */


.code-box {
  display: inline-grid;
  gap: 6px;
  background: #eef6ff;
  border: 2px dashed #2563eb;
  border-radius: 20px;
  padding: 18px 28px;
  margin: 12px auto;
}

.code-box span {
  text-transform: uppercase;
  color: #475569;
  font-size: .8rem;
  font-weight: 900;
}

.code-box strong {
  font-size: 3rem;
  letter-spacing: .14em;
}

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

.team-header,
.question-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  background: #e0f2fe;
  color: #075985;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 900;
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-pill {
  background: #f1f5f9;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.team-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0 20px;
}

/* Animations locales du seul avatar de sélection (aucun trafic PeerJS). */
/* L'inclinaison est sur un groupe SVG distinct pour ne pas écraser la respiration. */
#avatarPreview .cq-avatar-tilt {
  transform-origin: 50% 85%;
  animation: cq-avatar-tilt 8s ease-in-out infinite;
}
#avatarPreview .cq-avatar-character {
  transform-origin: 50% 85%;
  animation: cq-avatar-breathe 3.2s ease-in-out infinite;
}
#avatarPreview .cq-avatar-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: cq-avatar-blink 5.3s infinite;
}
#avatarPreview.avatar-change-bounce svg {
  animation: cq-avatar-bounce 480ms ease-out;
}
@keyframes cq-avatar-tilt {
  0%, 15%, 30%, 65%, 80%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-6deg); }
  70% { transform: rotate(6deg); }
}
@keyframes cq-avatar-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018, .985); }
}
@keyframes cq-avatar-blink {
  0%, 91%, 95%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(.08); }
}
@keyframes cq-avatar-bounce {
  0%, 100% { transform: translateY(0); }
  42% { transform: translateY(-12px); }
}
@media (prefers-reduced-motion: reduce) {
  #avatarPreview .cq-avatar-tilt,
  #avatarPreview .cq-avatar-character,
  #avatarPreview .cq-avatar-eyes,
  #avatarPreview.avatar-change-bounce svg { animation: none; }
}

.identity-nickname {
  font-size: 1.35rem;
  color: #1e3a8a;
  text-align: center;
}

.player-identity,
.player-name-with-avatar,
.score-name-with-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.scoreRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
}

.scoreRow:last-child {
  border-bottom: 0;
}

.player-identity {
  margin-bottom: 12px;
}

.avatar-stack {
  display: inline-flex;
  align-items: center;
}

.avatar-stack .avatar + .avatar {
  margin-left: -9px;
}

.avatar-stack .avatar {
  border: 2px solid white;
  border-radius: 50%;
}

.log {
  max-height: 210px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 10px;
}

.log-item {
  padding: 6px 4px;
  border-bottom: 1px solid #334155;
}

#aiPromptBox,
#csvTextInput {
  margin-top: 8px;
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.studentWrap {
  display: flex;
  width: 100%;
  max-width: none;
  min-height: 0;
  flex: 1;
  margin: 0 auto;
  padding: 12px;
}

#joinCard {
  width: min(720px, 100%);
  margin: clamp(18px, 4vh, 44px) auto auto;
  text-align: center;
}

#joinCard h2 {
  margin-bottom: 12px;
}

#joinFormContent {
  display: grid;
  gap: 10px;
  text-align: left;
}

#joinFormContent .primary {
  margin-top: 4px;
}

.student-waiting-content {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 4px 0 8px;
}

.student-waiting-content .note {
  margin: 0;
  font-size: 1.05rem;
  text-align: center;
}

.answers {
  display: grid;
  gap: 12px;
}

#gameCard > .answers[data-answer-count] {
  grid-template-rows: minmax(0, 1fr);
  height: clamp(190px, 30dvh, 320px);
  min-height: 190px;
  padding: clamp(10px, 1.3vw, 16px);
  flex: 0 1 auto;
  align-self: center;
  border: 0;
  background: rgba(255, 255, 255, .34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  box-shadow: none;
}

#gameCard > .answers[data-answer-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#gameCard > .answers[data-answer-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#gameCard > .answers[data-answer-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.answerBtn {
  width: 100%;
  border: 0;
  background: #047857f2;
  color: white;
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  padding: 18px;
  box-shadow: 0 7px 18px rgba(6, 95, 70, .2);
}

#gameCard > .answers[data-answer-count] > .answerBtn {
  height: 100%;
  min-height: 120px;
}

.answerBtn.is-pending {
  opacity: .72;
}

.answerBtn.is-found {
  border-color: #15803d !important;
  background: #dcfce7 !important;
  color: #166534 !important;
  opacity: .82;
}

.answerBtn.is-wrong {
  border-color: #b91c1c !important;
  background: #fee2e2 !important;
  color: #991b1b !important;
  opacity: .9;
}

.feedback {
  display: flex;
  min-height: 68px;
  margin: 0;
  padding: 11px 16px;
  align-items: center;
  align-self: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid #bfdbfe;
  background: rgba(239, 246, 255, .97);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .09);
  white-space: pre-line;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 900;
}

.feedback.good {
  border-color: #86efac;
  background: rgba(240, 253, 244, .98);
  color: #166534;
}

.feedback.bad {
  border-color: #fca5a5;
  background: rgba(254, 242, 242, .98);
  color: #991b1b;
}

.feedback:empty {
  display: none;
  min-height: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.waiting-screen {
  text-align: center;
  padding: 28px;
}

.waiting-icon {
  font-size: 4rem;
}

.game-screen .panel {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
}

.teacher-controls {
  margin-top: 24px;
}

.teacher-paced-panel {
  display: grid;
  gap: 10px;
  margin: 4px 0 12px;
  padding: 12px 14px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: linear-gradient(145deg, #eff6ff, #fff);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .08);
}

.teacher-pilot-bar {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #bfdbfe;
  border-radius: 13px;
  background: rgba(239, 246, 255, .96);
  box-shadow: 0 5px 15px rgba(30, 64, 175, .1);
  backdrop-filter: blur(8px);
}

.teacher-paced-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  flex-wrap: wrap;
}

.teacher-mode-badge {
  background: #1d4ed8;
  color: #fff;
}

#teacherQuestionCounter {
  color: #1e3a8a;
  font-size: 1rem;
}

#teacherQuestionText {
  margin: 2px 0;
  color: #172554;
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  line-height: 1.3;
  text-align: center;
}

.teacher-question-image {
  display: grid;
  place-items: center;
}

.teacher-question-image-zoom {
  display: grid;
  place-items: center;
  max-width: 100%;
  max-height: 200px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  cursor: zoom-in;
}

.teacher-question-image img {
  display: block;
  max-width: min(100%, 620px);
  max-height: 188px;
  object-fit: contain;
  border-radius: 8px;
}

.teacher-question-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.teacher-answer {
  min-width: 0;
  padding: 8px 11px;
  overflow-wrap: anywhere;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}

.teacher-answer.is-correct {
  border-color: #86efac;
  background: #f0fdf4;
  color: #047857;
  font-weight: 800;
}

.teacher-response-status {
  margin: 0;
  color: #334155;
  font-weight: 800;
  text-align: center;
}

.teacher-correction-button {
  justify-self: center;
  padding-block: 8px;
}

.teacher-class-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 4px 7px;
  color: #334155;
}

.teacher-scoreboard {
  gap: 4px;
  max-height: min(48vh, 520px);
  padding: 2px 6px 2px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.teacher-score-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, auto) 54px 72px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 5px 10px;
  border: 1px solid #e2e8f0;
  border-left: 5px solid var(--team-color);
  border-radius: 10px;
  background: #fff;
}

.teacher-score-row:nth-child(even) {
  background: #f8fafc;
}

.teacher-score-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.teacher-score-identity > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-score-state {
  color: #64748b;
  font-weight: 750;
}

.teacher-score-row.answered .teacher-score-state,
.teacher-score-row.correct .teacher-score-state {
  color: #047857;
}

.teacher-score-row.incorrect .teacher-score-state {
  color: #b91c1c;
}

.teacher-score-row.searching .teacher-score-state {
  color: #a16207;
}

.teacher-score-delta {
  color: #475569;
  text-align: right;
}

.teacher-score-total {
  text-align: right;
  white-space: nowrap;
}

.student-question-counter {
  margin: 0;
  padding: 6px 9px;
  border-radius: 10px;
  background: #eef3ff;
  color: #1e3a8a;
  font-weight: 800;
  font-size: .9rem;
  line-height: 1;
  white-space: nowrap;
}

.student-header-timer {
  margin: 0;
  padding: 6px 9px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: .9rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.student-question-short-label {
  display: none;
}

.student-question-separator {
  margin-inline: .28em;
}

.student-game-header {
  position: sticky;
  z-index: 7;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  max-width: none;
  margin: 0;
  padding: 8px clamp(12px, 3vw, 34px);
  border: 0;
  border-bottom: 1px solid rgba(191, 219, 254, .9);
  border-radius: 0;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 5px 16px rgba(30, 64, 175, .12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: visible;
}

.student-game-header.has-player + .studentWrap {
  padding-top: 58px;
}

.student-brand,
.student-player-summary {
  display: flex;
  align-items: center;
  min-width: 0;
}

.student-brand {
  gap: 6px;
  color: #172554;
}

.student-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.student-brand-name {
  font-size: .9rem;
}

.student-player-summary {
  position: absolute;
  z-index: 2;
  top: 6px;
  left: 50%;
  width: min(240px, 36vw);
  flex-direction: column;
  gap: 3px;
  transform: translateX(-50%);
}

.student-header-avatar {
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  border: 3px solid white;
  border-radius: 999px;
  background: white;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .24);
}

.student-player-labels {
  width: 100%;
  min-width: 0;
  line-height: 1.15;
  text-align: center;
}

.student-player-name,
.student-team-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-player-name {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  color: #172033;
  font-size: .95rem;
  box-shadow: 0 3px 9px rgba(15, 23, 42, .12);
}

.student-team-name {
  margin-top: 2px;
  color: #475569;
  font-size: .74rem;
  font-weight: 700;
}

.student-header-actions {
  display: flex;
  grid-column: 3;
  align-items: center;
  justify-self: end;
  gap: 7px;
}

.student-score-anchor {
  position: relative;
  display: inline-flex;
}

.student-team-score {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #fde68a;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  white-space: nowrap;
}

.student-fullscreen-btn {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border-radius: 10px;
  background: #eef3ff;
  color: #172554;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.student-fullscreen-btn:hover {
  background: #dbeafe;
}

.student-reconnect-card {
  width: min(560px, 100%);
  margin: clamp(18px, 5vh, 54px) auto auto;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.student-reconnect-card h2,
.student-reconnect-card p {
  margin: 0;
}

.student-reconnect-card .primary {
  min-width: min(280px, 100%);
}

.student-reconnect-code {
  font-size: 1.05rem;
}

#gameCard {
  --student-game-zone-max: 1320px;
  --student-game-zone-gutter: clamp(16px, 6vw, 72px);
  --student-game-zone-radius: 18px;
  position: relative;
  display: flex;
  width: 100%;
  min-height: calc(100dvh - 76px);
  flex-direction: column;
  gap: clamp(12px, 2vh, 22px);
  overflow: visible;
}

.student-question-zone,
#gameCard > .answers[data-answer-count],
#gameCard > .feedback {
  width: min(var(--student-game-zone-max), calc(100% - var(--student-game-zone-gutter)));
  margin-inline: auto;
  align-self: center;
  border-radius: var(--student-game-zone-radius);
}

.student-question-zone {
  display: grid;
  max-height: 42dvh;
  flex: 0 1 auto;
  align-self: center;
  padding: clamp(14px, 2vw, 24px);
  overflow: auto;
  border: 1px solid #94a3b8;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.student-question-zone #questionText {
  margin: 2px 0 10px;
  text-align: center;
}

#gameCard .question-image-display {
  width: min(720px, 100%);
  aspect-ratio: 16 / 7;
  margin: 4px auto 10px;
  padding: 0;
  background: #e2e8f0;
}

#gameCard .student-question-image-button {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #e2e8f0;
  border: 0;
  border-radius: inherit;
  cursor: zoom-in;
}

#gameCard .student-question-image-button img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.student-image-zoom-hint {
  position: absolute;
  right: 9px;
  bottom: 9px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: white;
  background: rgba(15, 23, 42, .76);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 999px;
  font-size: 1.15rem;
  line-height: 1;
  pointer-events: none;
}

#gameCard .student-question-image-button:hover .student-image-zoom-hint,
#gameCard .student-question-image-button:focus-visible .student-image-zoom-hint {
  background: #1e40af;
}

@media(min-width:641px) and (max-width:900px) {
  #gameCard > .answers[data-answer-count="3"],
  #gameCard > .answers[data-answer-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
  }

  #gameCard > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: 1 / -1;
  }
}

/* Labyrinthe */
.maze-panel {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid #1d4ed8;
  border-radius: 16px;
  background: linear-gradient(145deg, #07132f, #0f2453);
  box-shadow: 0 10px 24px rgb(2 6 23 / 22%);
}

.maze-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.maze-panel-heading h2,
.maze-panel-heading h3,
.maze-panel-heading p {
  margin: 0;
}

.maze-mode-badge {
  border: 1px solid #60a5fa;
  background: #112a62;
  color: #eff6ff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 14%);
}

.maze-panel-heading .small {
  padding: 5px 9px;
  border: 1px solid #274b86;
  border-radius: 999px;
  background: rgb(3 7 18 / 46%);
  color: #dbeafe;
  font-weight: 700;
}

.maze-board-wrap {
  width: min(100%, 980px);
  margin: 0 auto;
}

.maze-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(21, 1fr);
  width: 100%;
  aspect-ratio: 21 / 15;
  overflow: hidden;
  isolation: isolate;
  border: 3px solid #2563eb;
  border-radius: 14px;
  background: #030712;
  box-shadow: 0 6px 16px rgb(2 6 23 / 32%);
}

.maze-cell {
  min-width: 0;
  min-height: 0;
  background: #030712;
}

.maze-cell.is-wall {
  background: #0b1f55;
}

.maze-cell.wall-edge-top { border-top: 2px solid #3b82f6; }
.maze-cell.wall-edge-right { border-right: 2px solid #3b82f6; }
.maze-cell.wall-edge-bottom { border-bottom: 2px solid #3b82f6; }
.maze-cell.wall-edge-left { border-left: 2px solid #3b82f6; }
.maze-cell.wall-edge-top.wall-edge-left { border-top-left-radius: 6px; }
.maze-cell.wall-edge-top.wall-edge-right { border-top-right-radius: 6px; }
.maze-cell.wall-edge-bottom.wall-edge-left { border-bottom-left-radius: 6px; }
.maze-cell.wall-edge-bottom.wall-edge-right { border-bottom-right-radius: 6px; }

.maze-question-marker {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: calc(100% / 21 * .62);
  aspect-ratio: 1;
  border: 2px solid #fff7c2;
  border-radius: 50%;
  background: linear-gradient(145deg, #facc15, #f59e0b);
  color: #422006;
  font-size: clamp(.5rem, 1.25vw, .9rem);
  font-weight: 900;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgb(146 64 14 / 68%);
  animation: maze-marker-arrive .55s ease-out both;
}

.maze-player {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: calc(100% / 21 * .72);
  aspect-ratio: 1;
  border: 2px solid rgb(255 255 255 / 92%);
  border-radius: 50%;
  color: #fff;
  font-size: clamp(.42rem, 1.1vw, .78rem);
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 30%),
    0 2px 4px rgb(2 6 23 / 52%);
  transition: transform 180ms linear, opacity 140ms ease;
  will-change: transform;
}

.maze-player.is-new {
  transition: none;
}

.maze-player::before {
  --maze-facing-angle: 0deg;
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 1;
  opacity: 0;
  border-radius: 50%;
  background: #030712;
  clip-path: polygon(50% 50%, 104% 27%, 104% 73%);
  transform: rotate(var(--maze-facing-angle)) scaleY(1);
  pointer-events: none;
}

.maze-player[data-maze-direction="down"]::before { --maze-facing-angle: 90deg; }
.maze-player[data-maze-direction="left"]::before { --maze-facing-angle: 180deg; }
.maze-player[data-maze-direction="up"]::before { --maze-facing-angle: 270deg; }

.maze-player.is-moving::before {
  opacity: 1;
  animation: maze-player-chomp 300ms steps(2, end) infinite;
}

.maze-player.is-self {
  z-index: 3;
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow:
    0 0 0 5px #facc15,
    0 4px 11px rgb(15 23 42 / 52%);
}

.maze-player.is-disconnected {
  opacity: .45;
}

.maze-player.is-question {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgb(245 158 11 / 22%), 0 2px 7px rgb(15 23 42 / 45%);
}

.maze-player.is-duel {
  z-index: 4;
  outline: 3px solid #c084fc;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgb(126 34 206 / 34%), 0 3px 10px rgb(15 23 42 / 52%);
}

.maze-player.is-duel::after {
  content: "⚡";
  position: absolute;
  top: -78%;
  font-size: clamp(.62rem, 1.3vw, 1rem);
}

.maze-player.is-immune {
  outline: 2px solid #67e8f9;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgb(34 211 238 / 24%), 0 2px 7px rgb(15 23 42 / 45%);
}

@keyframes maze-marker-arrive {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.72); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes maze-player-chomp {
  50% { transform: rotate(var(--maze-facing-angle)) scaleY(.3); }
}

@media (prefers-reduced-motion: reduce) {
  .maze-question-marker {
    animation: none;
  }

  .maze-player {
    transition: none;
  }

  .maze-player.is-moving::before {
    animation: none;
  }
}

.student-game-layout.is-maze-duel .student-question-zone::before {
  content: "⚡ DÉFI !";
  display: block;
  margin-bottom: .35rem;
  color: #7e22ce;
  font-weight: 900;
  letter-spacing: .06em;
}

.maze-touch-controls {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-areas:
    ". up ."
    "left stop right"
    ". down .";
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  touch-action: none;
  user-select: none;
}

.maze-control {
  min-width: 52px;
  min-height: 46px;
  padding: 6px;
  touch-action: none;
  font-size: 1.05rem;
}

.maze-up { grid-area: up; }
.maze-left { grid-area: left; }
.maze-stop { grid-area: stop; }
.maze-right { grid-area: right; }
.maze-down { grid-area: down; }

.student-game-layout.is-maze-mode:not(.is-maze-question) .student-question-zone,
.student-game-layout.is-maze-mode:not(.is-maze-question) > .answers,
.student-game-layout.is-maze-mode:not(.is-maze-question) > .feedback,
.student-game-layout.is-maze-mode.is-maze-question .student-maze-panel {
  display: none;
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  .maze-touch-controls {
    display: grid;
  }
}

@media (max-width: 600px) {
  .maze-panel {
    padding: 8px;
  }

  .maze-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .maze-board {
    border-width: 2px;
    border-radius: 8px;
  }

  .maze-player {
    width: calc(100% / 21 * .82);
    border-width: 1px;
  }
}

.course-brand,
.course-header-actions {
  display: flex;
  align-items: center;
}

.course-brand {
  min-width: 0;
  gap: 8px;
}

.course-brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  object-fit: contain;
}

.course-brand-name {
  overflow: hidden;
  font-size: 1rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.course-header-actions {
  justify-content: flex-end;
  gap: 7px;
}

/* ===== Couleurs automatiques des équipes ===== */
#teamsList>*:nth-child(6n+1),
#scoreboard .score-row:nth-child(6n+1) {
  border-left: 10px solid #2563eb;
  background: #eff6ff;
}

#teamsList>*:nth-child(6n+2),
#scoreboard .score-row:nth-child(6n+2) {
  border-left: 10px solid #16a34a;
  background: #f0fdf4;
}

#teamsList>*:nth-child(6n+3),
#scoreboard .score-row:nth-child(6n+3) {
  border-left: 10px solid #f97316;
  background: #fff7ed;
}

#teamsList>*:nth-child(6n+4),
#scoreboard .score-row:nth-child(6n+4) {
  border-left: 10px solid #9333ea;
  background: #faf5ff;
}

#teamsList>*:nth-child(6n+5),
#scoreboard .score-row:nth-child(6n+5) {
  border-left: 10px solid #e11d48;
  background: #fff1f2;
}

#teamsList>*:nth-child(6n+6),
#scoreboard .score-row:nth-child(6n+6) {
  border-left: 10px solid #0891b2;
  background: #ecfeff;
}

#scoreboard .score-row:nth-child(6n+1) .score-bar {
  background: linear-gradient(90deg, #93c5fd, #2563eb);
}

#scoreboard .score-row:nth-child(6n+2) .score-bar {
  background: linear-gradient(90deg, #86efac, #16a34a);
}

#scoreboard .score-row:nth-child(6n+3) .score-bar {
  background: linear-gradient(90deg, #fdba74, #f97316);
}

#scoreboard .score-row:nth-child(6n+4) .score-bar {
  background: linear-gradient(90deg, #c4b5fd, #9333ea);
}

#scoreboard .score-row:nth-child(6n+5) .score-bar {
  background: linear-gradient(90deg, #fda4af, #e11d48);
}

#scoreboard .score-row:nth-child(6n+6) .score-bar {
  background: linear-gradient(90deg, #67e8f9, #0891b2);
}

#teamsList>* {
  overflow: hidden;
}

#teamsList>* .badge {
  background: white;
}

/* ===== Joueur ===== */
.player-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px 15px;
  border-radius: 12px;
  background: #eef3ff;
  font-weight: 700;
}

#teamNameDisplay {
  color: #2563eb;
}

#playerNameDisplay {
  color: #475569;
}

.student-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  min-width: 0;
  padding: 6px 8px;
  margin: 0;
  gap: 7px;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .07);
}

.lobby-player-row {
  width: 100%;
  background: rgba(255, 255, 255, .94);
}

.student-card .player-name-with-avatar {
  min-width: 0;
  gap: 8px;
}

.student-card .avatar {
  width: 38px;
  height: 38px;
}

.student-player-list-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.student-connection-status {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 900;
  line-height: 1;
}

.student-connection-status.is-connected {
  color: #047857;
  background: #d1fae5;
}

.student-connection-status.is-disconnected {
  color: #64748b;
  background: #e2e8f0;
}

.student-remove-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  color: #b91c1c;
  background: #fff7f7;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
}

#studentsList {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.team-card .players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 6px;
}

/* ===== QR Code ===== */
.qr-box {
  margin-top: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.qr-box p {
  margin: 0;
}

#qrCodeCanvas {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#qrCodeCanvas canvas,
#qrCodeCanvas img {
  display: block;
  margin: 0 auto;
  background: white;
  padding: 9px;
  border-radius: 14px;
  box-shadow: 0 8px 24px #10204022;
}

@media(max-width:700px) {

  .course-header-actions {
    gap: 5px;
  }




  .course-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media(max-width:640px) {

  #joinCard {
    margin-top: 10px;
  }




  .code-box strong {
    font-size: 2.1rem;
  }

  .score-top,
  .question-card-head {
    font-size: 1rem;
    align-items: flex-start;
    flex-direction: column;
  }




  .studentWrap {
    padding: 8px;
  }

  #gameCard {
    --student-game-zone-gutter: 8px;
    min-height: calc(100dvh - 66px);
    padding: 4px 0 16px;
    overflow: visible;
  }

  #studentPageHeader.student-game-header {
    margin: 0;
    padding: 7px 9px;
  }

  #studentPageHeader.student-game-header.has-player {
    min-height: 64px;
  }

  #studentPageHeader.has-player .student-header-actions {
    align-self: start;
    gap: 5px;
  }

  #studentPageHeader.has-player .student-question-counter {
    padding: 4px 7px;
    font-size: .78rem;
  }

  #studentPageHeader.has-player .student-header-timer {
    padding: 4px 7px;
    font-size: .78rem;
  }

  .student-question-long-label {
    display: none;
  }

  .student-question-short-label {
    display: inline;
  }

  .student-question-separator {
    margin-inline: 0;
  }

  #studentPageHeader.has-player + .studentWrap {
    padding-top: 46px;
  }

  .student-header-avatar {
    width: 52px;
    height: 52px;
  }

  .student-player-summary {
    width: min(190px, 38vw);
  }

  .student-brand-name {
    display: none;
  }

  .student-question-zone {
    width: calc(100% - 8px);
    max-height: none;
    overflow: visible;
  }

  #gameCard > .answers[data-answer-count="2"],
  #gameCard > .answers[data-answer-count="3"],
  #gameCard > .answers[data-answer-count="4"] {
    width: calc(100% - 8px);
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: auto;
    min-height: 0;
    flex: 0 0 auto;
  }

  #gameCard > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: auto;
  }

  #gameCard > .answers[data-answer-count] > .answerBtn {
    min-height: 108px;
  }




  .teacher-question-answers {
    grid-template-columns: 1fr;
  }

  .teacher-pilot-bar {
    top: 4px;
    grid-template-columns: 1fr 1fr;
  }

  .teacher-paced-heading {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .teacher-pilot-bar > button {
    width: 100%;
  }

  .teacher-score-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    min-height: 52px;
  }

  .teacher-score-state {
    grid-column: 1;
    padding-left: 43px;
    font-size: .84rem;
  }

  .teacher-score-delta {
    display: none;
  }

  .teacher-score-total {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .scoreRow {
    align-items: flex-start;
    flex-direction: column;
  }

  #studentsList {
    grid-template-columns: 1fr;
  }
}

.code-badge {
  text-align: center;
  font-size: 1.2rem;
  margin: 0.5rem 0 1rem;
}

.code-badge strong {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  letter-spacing: 0.15em;
  font-size: 1.5rem;
  font-weight: 700;
}

.waiting-room-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.waiting-room-layout .hero {
  width: min(360px, 38vw);
  flex: 0 0 min(360px, 38vw);
}

.lobby-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

#returnToCourseBtn {
  padding: 9px 12px;
  border-radius: 11px;
  white-space: nowrap;
}

.students-panel {
  width: min(540px, 100%);
  min-width: 0;
  flex: 0 1 540px;
}

.students-panel .cards {
  max-height: 350px;
  overflow-y: auto;
}

@media(max-width:760px) {
  .waiting-room-layout {
    flex-direction: column;
  }

  .waiting-room-layout .hero,
  .waiting-room-layout .students-panel {
    width: 100%;
    flex-basis: auto;
  }

  .waiting-room-layout .hero {
    order: -1;
  }
}

@media(max-width:390px) {

  .course-brand-name {
    display: none;
  }

  .course-brand-logo {
    width: 30px;
    height: 30px;
  }
}

@media(max-width:520px) {
  #studentPageHeader.has-player .student-header-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 4px;
  }

  #studentPageHeader.student-game-header.has-player {
    min-height: 78px;
  }

  #studentPageHeader.has-player + .studentWrap {
    padding-top: 56px;
  }
}

@media(max-width:390px) {
  .student-game-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    padding-inline: 7px;
  }

  .student-brand-logo {
    width: 30px;
    height: 30px;
  }

  .student-header-avatar {
    width: 48px;
    height: 48px;
  }

  .student-player-summary {
    width: 36vw;
  }

  .student-player-name {
    font-size: .82rem;
  }

  .student-team-name {
    display: none;
  }

  .student-team-score {
    min-height: 28px;
    padding-inline: 8px;
  }

  .student-fullscreen-btn {
    width: 30px;
    height: 30px;
  }

  #studentPageHeader.has-player .student-header-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 4px;
  }

  #studentPageHeader.student-game-header.has-player {
    min-height: 78px;
  }

  #studentPageHeader.has-player + .studentWrap {
    padding-top: 56px;
  }
}
/* Bataille sur grille : thème naval V1, moteur agnostique dans js/engines/battle-engine.js. */
.battle-panel {
  position: relative;
  margin: 1rem 0 1.35rem;
  padding: clamp(.75rem, 2vw, 1.25rem);
  overflow: hidden;
  border: 1px solid #60a5fa;
  border-radius: 1rem;
  background:
    radial-gradient(circle at 15% 0, rgba(56, 189, 248, .2), transparent 34%),
    linear-gradient(155deg, #eff6ff, #dff7ff 58%, #e0f2fe);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 12px 28px rgba(3, 105, 161, .1);
}

.battle-panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
}

.battle-panel-heading h2,
.battle-panel-heading h3 { margin: .35rem 0 0; }
.battle-mode-badge { background: linear-gradient(135deg, #0c4a6e, #0369a1); color: white; }

.battle-fleet-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .5rem;
  margin-bottom: .8rem;
}

.battle-fleet-card {
  padding: .55rem .7rem;
  border-left: .35rem solid var(--team-color, #64748b);
  border-radius: .6rem;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 2px 8px rgba(12, 74, 110, .08);
}
.battle-fleet-card.is-eliminated { opacity: .62; filter: grayscale(.45); }
.battle-unit-list { display: flex; flex-wrap: wrap; align-items: center; gap: .38rem; margin-top: .38rem; }
.battle-mini-ship {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px 3px;
  border: 1px solid color-mix(in srgb, var(--team-color, #64748b) 70%, #0f172a);
  border-radius: 999px 45% 45% 999px;
  background: color-mix(in srgb, var(--team-color, #64748b) 20%, white);
}
.battle-mini-ship i {
  width: 6px;
  height: 5px;
  border-radius: 2px;
  background: var(--team-color, #64748b);
  pointer-events: none;
}
.battle-mini-ship.is-damaged { background: repeating-linear-gradient(135deg, #fff 0 3px, #fed7aa 3px 6px); }
.battle-mini-ship.is-damaged i:nth-child(odd) { background: #7c2d12; }
.battle-mini-ship.is-sunk { opacity: .5; filter: grayscale(.7); transform: rotate(-4deg); }
.battle-mini-ship.is-sunk i { background: #334155; }

.battle-grid-wrap {
  width: min(100%, 780px);
  margin-inline: auto;
  overflow: auto;
  padding: clamp(.35rem, 1.5vw, .75rem);
  border: 1px solid rgba(14, 116, 144, .35);
  border-radius: .9rem;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(255, 255, 255, .16) 0 8%, transparent 9%),
    radial-gradient(ellipse at 75% 70%, rgba(186, 230, 253, .14) 0 10%, transparent 11%),
    linear-gradient(145deg, #075985, #0284c7 48%, #0369a1);
  box-shadow: inset 0 0 28px rgba(8, 47, 73, .32), 0 8px 20px rgba(3, 105, 161, .15);
}

.battle-grid {
  --battle-grid-size: 10;
  display: grid;
  grid-template-columns: 1.35rem repeat(var(--battle-grid-size), minmax(1.65rem, 1fr));
  width: min(100%, calc(2rem + var(--battle-grid-size) * 3rem));
  min-width: calc(1.35rem + var(--battle-grid-size) * 1.65rem);
  aspect-ratio: calc(var(--battle-grid-size) + 1) / var(--battle-grid-size);
  gap: 2px;
  user-select: none;
  isolation: isolate;
  touch-action: pan-x pan-y;
  background-image: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .045) 50%, transparent 65%);
  background-size: 220% 100%;
  animation: battle-ocean-drift 18s ease-in-out infinite alternate;
}

.battle-axis {
  display: grid;
  place-items: center;
  color: #e0f2fe;
  text-shadow: 0 1px 2px rgba(8, 47, 73, .8);
  font-size: clamp(.62rem, 1.5vw, .78rem);
  font-weight: 800;
}

.battle-cell {
  position: relative;
  min-width: 1.65rem;
  min-height: 1.65rem;
  padding: 0;
  border: 1px solid rgba(3, 105, 161, .28);
  border-radius: .22rem;
  background: linear-gradient(145deg, rgba(56, 189, 248, .72), rgba(14, 165, 233, .58));
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
  isolation: isolate;
  touch-action: manipulation;
}
.battle-cell::before,
.battle-cell::after { pointer-events: none; }
.battle-cell:not(:disabled):hover,
.battle-cell:not(:disabled):focus-visible {
  z-index: 3;
  transform: translateY(-1px) scale(1.04);
  border-color: white;
  filter: brightness(1.15);
  box-shadow: 0 0 0 2px #fbbf24, inset 0 0 0 1px rgba(255, 255, 255, .45);
}
.battle-cell:disabled { opacity: 1; cursor: default; }
.battle-cell.is-played { cursor: default; }
.battle-cell.is-miss::before {
  content: "";
  position: absolute;
  inset: 28%;
  border: 2px solid rgba(240, 249, 255, .92);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(186, 230, 253, .25);
}
.battle-cell.is-miss::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: -5px 2px 0 rgba(224, 242, 254, .75), 5px -2px 0 rgba(224, 242, 254, .75);
}
.battle-cell.is-hit:not(.is-ship-segment)::before {
  content: "";
  position: absolute;
  inset: 24% 17%;
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 55% 30% 45% 25%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--ship-color, #64748b) 72%, white), var(--ship-color, #64748b));
  box-shadow: 0 2px 3px rgba(15, 23, 42, .38);
  transform: rotate(-9deg);
}
.battle-cell.is-hit::after {
  content: "×";
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  margin: auto;
  border-radius: 50%;
  background: #111827;
  color: #fde68a;
  font-size: .78rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px #fb923c, 0 0 7px #f97316;
}
.battle-cell.is-own-ship {
  z-index: 1;
  overflow: visible;
  border-color: rgba(255, 255, 255, .42);
}
.battle-cell.is-sunk {
  z-index: 1;
  overflow: visible;
  border-color: rgba(255, 255, 255, .45);
  filter: saturate(.68) brightness(.82);
}
.battle-cell.is-ship-segment::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 16% 10%;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: .3rem;
  background:
    linear-gradient(90deg, transparent 42%, rgba(255, 255, 255, .5) 43% 57%, transparent 58%),
    linear-gradient(145deg, color-mix(in srgb, var(--ship-color, #64748b) 72%, white), var(--ship-color, #64748b));
  box-shadow: 0 2px 4px rgba(15, 23, 42, .42), inset 0 -2px 0 rgba(15, 23, 42, .22);
}
.battle-cell.is-ship-segment.ship-link-left::before { left: -4px; border-radius: 0 .18rem .18rem 0; }
.battle-cell.is-ship-segment.ship-link-right::before { right: -4px; border-radius: .18rem 0 0 .18rem; }
.battle-cell.is-ship-segment.ship-link-up::before { top: -4px; border-radius: 0 0 .18rem .18rem; }
.battle-cell.is-ship-segment.ship-link-down::before { bottom: -4px; border-radius: .18rem .18rem 0 0; }
.battle-cell.is-ship-segment.ship-link-left.ship-link-right::before,
.battle-cell.is-ship-segment.ship-link-up.ship-link-down::before { border-radius: 0; }
.battle-cell.is-ship-segment.ship-horizontal:not(.ship-link-left)::before {
  clip-path: polygon(0 50%, 24% 5%, 100% 5%, 100% 95%, 24% 95%);
}
.battle-cell.is-ship-segment.ship-horizontal:not(.ship-link-right)::before { border-radius: .18rem 65% 65% .18rem; }
.battle-cell.is-ship-segment.ship-vertical:not(.ship-link-up)::before {
  clip-path: polygon(50% 0, 95% 24%, 95% 100%, 5% 100%, 5% 24%);
}
.battle-cell.is-ship-segment.ship-vertical:not(.ship-link-down)::before { border-radius: .18rem .18rem 65% 65%; }
.battle-cell.is-own-ship:not(.is-hit)::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 39%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .5);
}
.battle-cell.is-sunk::after {
  content: "×";
  position: relative;
  z-index: 2;
  color: #fee2e2;
  font-size: 1rem;
  font-weight: 900;
  text-shadow: 0 1px 3px #450a0a;
}
.battle-cell.is-pending { animation: battle-pulse .7s ease-in-out infinite alternate; }

@keyframes battle-ocean-drift { to { background-position: 100% 0; } }
@keyframes battle-splash { 0% { transform: scale(.25); opacity: 0; } 55% { opacity: 1; } 100% { transform: scale(1); } }
@keyframes battle-impact { 0% { transform: scale(1.8) rotate(20deg); filter: brightness(2); } 100% { transform: scale(1) rotate(0); } }
@keyframes battle-sink { 0% { transform: scale(1.16); filter: brightness(1.8); } 45% { transform: rotate(-3deg); } 100% { transform: scale(1); } }
@keyframes battle-pulse { to { filter: brightness(1.3); } }
.battle-cell.is-latest.is-miss::before { animation: battle-splash .5s ease-out; }
.battle-cell.is-latest.is-hit::after { animation: battle-impact .45s ease-out; }
.battle-cell.is-latest.is-sunk::before { animation: battle-sink .75s ease-out; }

.battle-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .35rem .8rem;
  margin: -.15rem 0 .6rem;
  color: #0c4a6e;
  font-size: .78rem;
  font-weight: 700;
}
.battle-legend span { display: inline-flex; align-items: center; gap: .28rem; }
.battle-legend .battle-legend-label { display: inline; }
.battle-legend-icon { position: relative; display: inline-block; width: 14px; height: 14px; }
.battle-legend-icon.is-miss { border: 2px solid #0284c7; border-radius: 50%; box-shadow: 0 0 0 2px #bae6fd; }
.battle-legend-icon.is-hit { border-radius: 50%; background: #111827; box-shadow: 0 0 0 2px #fb923c; }
.battle-legend-icon.is-sunk { border-radius: 70% 35% 35% 70%; background: #475569; transform: rotate(-8deg); }
.battle-legend-icon.is-sunk::after { content: "×"; position: absolute; inset: -2px; color: white; font-size: 12px; text-align: center; }

.battle-toast {
  position: absolute;
  z-index: 8;
  top: .75rem;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  padding: .58rem .85rem;
  border: 1px solid #fdba74;
  border-radius: 999px;
  background: rgba(124, 45, 18, .94);
  color: white;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 24px rgba(124, 45, 18, .3);
  transform: translate(-50%, -12px) scale(.94);
  opacity: 0;
  transition: opacity .18s ease, transform .25s ease;
  pointer-events: none;
}
.battle-toast.is-showing { transform: translate(-50%, 0) scale(1); opacity: 1; }

/* Thème spatial : mêmes composants et états, habillage uniquement. */
.battle-panel.battle-theme-space {
  border-color: #6366f1;
  color: #e0e7ff;
  background:
    radial-gradient(circle at 16% 8%, rgba(34, 211, 238, .16), transparent 28%),
    radial-gradient(circle at 85% 18%, rgba(168, 85, 247, .2), transparent 34%),
    linear-gradient(150deg, #11102c, #111827 52%, #0b1026);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 14px 32px rgba(15, 23, 42, .28);
}
.battle-theme-space .battle-panel-heading .small { color: #c7d2fe; }
.battle-theme-space .battle-mode-badge {
  color: #f8fafc;
  background: linear-gradient(135deg, #4338ca, #7c3aed 55%, #0891b2);
  box-shadow: 0 0 16px rgba(99, 102, 241, .35);
}
.battle-theme-space .battle-fleet-card {
  color: #e2e8f0;
  background: rgba(15, 23, 42, .78);
  box-shadow: inset 0 0 0 1px rgba(165, 180, 252, .12), 0 3px 12px rgba(2, 6, 23, .34);
}
.battle-theme-space .battle-mini-ship {
  min-width: 31px;
  padding: 2px 4px;
  border-color: color-mix(in srgb, var(--team-color, #64748b) 76%, #c4b5fd);
  border-radius: .35rem;
  color: var(--team-color, #64748b);
  background: color-mix(in srgb, var(--team-color, #64748b) 17%, #111827);
  clip-path: polygon(0 50%, 12% 10%, 72% 20%, 100% 50%, 72% 80%, 12% 90%);
}
.battle-theme-space .battle-mini-spacecraft { display: block; width: auto; height: 11px; overflow: visible; }
.battle-theme-space .spacecraft-hull { fill: currentColor; }
.battle-theme-space .spacecraft-cockpit { fill: rgba(224, 242, 254, .85); }
.battle-theme-space .spacecraft-panels { fill: none; stroke: rgba(15, 23, 42, .62); stroke-width: 1; }
.battle-theme-space .spacecraft-engine { fill: #67e8f9; }
.battle-theme-space .spacecraft-nose { fill: color-mix(in srgb, currentColor 72%, white); }
.battle-theme-space .battle-mini-ship.is-damaged {
  color: color-mix(in srgb, var(--team-color, #64748b) 60%, #f97316);
  background: repeating-linear-gradient(135deg, #111827 0 3px, #7c2d12 3px 6px);
}
.battle-theme-space .battle-mini-ship.is-sunk {
  color: var(--team-color, #64748b);
  background: #111827;
  filter: grayscale(.55) brightness(.72);
}
.battle-theme-space .battle-grid-wrap {
  border-color: rgba(129, 140, 248, .55);
  background-color: #070b1f;
  background-image:
    radial-gradient(circle at 8% 13%, rgba(255, 255, 255, .92) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 26%, rgba(165, 243, 252, .8) 0 1px, transparent 1.5px),
    radial-gradient(circle at 34% 81%, rgba(221, 214, 254, .7) 0 1px, transparent 1.5px),
    radial-gradient(circle at 83% 72%, rgba(255, 255, 255, .54) 0 1px, transparent 1.5px),
    radial-gradient(ellipse at 50% 42%, rgba(79, 70, 229, .2), transparent 58%),
    linear-gradient(145deg, #070b1f, #11183a 54%, #090d24);
  background-size: 83px 79px, 127px 113px, 149px 137px, 191px 173px, auto, auto;
  box-shadow: inset 0 0 35px rgba(2, 6, 23, .84), 0 10px 24px rgba(2, 6, 23, .35);
  animation: battle-stars-drift 28s linear infinite alternate;
}
.battle-theme-space .battle-grid {
  background-image:
    linear-gradient(rgba(99, 102, 241, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, .045) 1px, transparent 1px);
  background-size: 18px 18px;
  animation: none;
}
.battle-theme-space .battle-axis { color: #c7d2fe; text-shadow: 0 0 7px #4338ca; }
.battle-theme-space .battle-cell {
  border-color: rgba(129, 140, 248, .38);
  background: linear-gradient(145deg, rgba(30, 41, 79, .84), rgba(49, 46, 129, .48));
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .045);
}
.battle-theme-space .battle-cell:not(:disabled):hover,
.battle-theme-space .battle-cell:not(:disabled):focus-visible {
  border-color: #67e8f9;
  box-shadow: 0 0 0 2px #a78bfa, 0 0 13px rgba(34, 211, 238, .55);
}
.battle-theme-space .battle-cell.is-miss::before {
  inset: 27%;
  border-color: #67e8f9;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, .2), 0 0 8px rgba(103, 232, 249, .72);
}
.battle-theme-space .battle-cell.is-miss::after {
  width: 2px;
  height: 2px;
  background: #e0f2fe;
  box-shadow: -5px 0 0 #818cf8, 5px 0 0 #c4b5fd, 0 -5px 0 #67e8f9;
}
.battle-theme-space .battle-cell.is-hit:not(.is-ship-segment)::before {
  inset: 20% 13%;
  border-radius: 50% 15% 50% 15%;
  clip-path: polygon(0 50%, 18% 8%, 68% 20%, 100% 50%, 68% 80%, 18% 92%);
  background:
    linear-gradient(90deg, transparent 42%, rgba(224, 242, 254, .78) 44% 56%, transparent 58%),
    linear-gradient(145deg, color-mix(in srgb, var(--ship-color, #64748b) 78%, white), var(--ship-color, #64748b));
}
.battle-theme-space .battle-cell.is-hit::after {
  content: "✦";
  color: #fff7ed;
  background: #7c2d12;
  box-shadow: 0 0 0 2px #fb923c, 0 0 10px #f97316;
}
.battle-theme-space .battle-cell.is-ship-segment::before {
  border-color: color-mix(in srgb, var(--ship-color, #64748b) 65%, #e0e7ff);
  border-radius: .18rem;
  background-color: var(--ship-color, #64748b);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 16'%3E%3Cpath d='M2 8h28M16 2v12M7 4l4 4-4 4M25 4l-4 4 4 4' fill='none' stroke='white' stroke-opacity='.38'/%3E%3C/svg%3E"),
    linear-gradient(145deg, color-mix(in srgb, var(--ship-color, #64748b) 66%, white), var(--ship-color, #64748b));
  background-size: 100% 100%, auto;
  box-shadow: 0 0 7px color-mix(in srgb, var(--ship-color, #64748b) 60%, transparent), inset 0 -2px 0 rgba(2, 6, 23, .32);
}
.battle-theme-space .battle-cell.is-ship-segment.ship-horizontal:not(.ship-link-left)::before {
  clip-path: polygon(0 50%, 24% 2%, 100% 18%, 100% 82%, 24% 98%);
}
.battle-theme-space .battle-cell.is-ship-segment.ship-horizontal:not(.ship-link-right)::before {
  clip-path: polygon(0 18%, 76% 2%, 100% 50%, 76% 98%, 0 82%);
  border-radius: .18rem;
}
.battle-theme-space .battle-cell.is-ship-segment.ship-vertical:not(.ship-link-up)::before {
  clip-path: polygon(50% 0, 98% 24%, 82% 100%, 18% 100%, 2% 24%);
}
.battle-theme-space .battle-cell.is-ship-segment.ship-vertical:not(.ship-link-down)::before {
  clip-path: polygon(18% 0, 82% 0, 98% 76%, 50% 100%, 2% 76%);
  border-radius: .18rem;
}
.battle-theme-space .battle-cell.is-own-ship:not(.is-hit)::after {
  inset: 37%;
  background: #cffafe;
  box-shadow: 0 0 5px #22d3ee;
}
.battle-theme-space .battle-cell.is-sunk { filter: saturate(.68) brightness(.66); }
.battle-theme-space .battle-cell.is-sunk::after { content: "✦"; color: #fed7aa; text-shadow: 0 0 6px #f97316; }
.battle-theme-space .battle-legend { color: #c7d2fe; }
.battle-theme-space .battle-legend-icon.is-miss { border-color: #67e8f9; box-shadow: 0 0 0 2px rgba(34, 211, 238, .22); }
.battle-theme-space .battle-legend-icon.is-hit { background: #7c2d12; box-shadow: 0 0 0 2px #fb923c, 0 0 6px #f97316; }
.battle-theme-space .battle-legend-icon.is-sunk {
  border-radius: 15% 50% 15% 50%;
  background: #6366f1;
  transform: rotate(45deg);
}
.battle-theme-space .battle-legend-icon.is-sunk::after { content: "✦"; transform: rotate(-45deg); }
.battle-theme-space .battle-toast {
  border-color: #fb923c;
  background: rgba(67, 20, 7, .96);
  box-shadow: 0 0 20px rgba(249, 115, 22, .42);
}

@keyframes battle-stars-drift { to { background-position: 7px 4px, -6px 3px, 4px -5px, -3px -4px, center, center; } }

.student-battle-panel { width: 100%; }
.student-battle-panel .battle-panel-heading > div {
  display: flex;
  align-items: center;
  gap: .42rem;
  white-space: nowrap;
}
.student-battle-panel .battle-panel-heading h2 { margin: 0; }
.student-battle-board,
.student-battle-sidebar { min-width: 0; }
.student-battle-sidebar .battle-fleet-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .22rem;
  white-space: nowrap;
}
.student-battle-sidebar .battle-fleet-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.student-battle-sidebar .battle-fleet-count,
.student-battle-sidebar .battle-fleet-separator { flex: 0 0 auto; }
.student-battle-sidebar .battle-unit-list {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  margin: 0;
}
.student-battle-sidebar .battle-mini-ship {
  min-width: 0;
  padding: 1px 2px;
}
.student-battle-sidebar .battle-mini-ship i {
  width: 4px;
  height: 4px;
}
.student-battle-sidebar .battle-mini-spacecraft { height: 8px; }
.battle-fleet-toggle {
  width: auto;
  min-height: 40px;
  padding: .45rem .7rem;
  white-space: nowrap;
  font-size: .88rem;
}
.student-game-layout.is-choosing-shot .student-question-zone,
.student-game-layout.is-choosing-shot > .answers { display: none; }

@media (min-width: 761px) {
  #gameCard:has(.student-battle-panel:not(.hidden)) { gap: 8px; }

  .student-battle-panel {
    margin: 0 0 .15rem;
    padding: .38rem .55rem .52rem;
  }

  .student-battle-panel .battle-panel-heading {
    align-items: center;
    margin-bottom: .25rem;
  }

  .student-battle-panel .battle-panel-heading > div {
    display: flex;
    align-items: center;
    gap: .42rem;
  }

  .student-battle-panel .battle-panel-heading h2 {
    margin: 0;
    font-size: clamp(.92rem, 1.5vw, 1.18rem);
  }

  .student-battle-panel .battle-mode-badge { font-size: .72rem; }
  .student-battle-panel .battle-fleet-toggle {
    min-height: 32px;
    padding: .3rem .58rem;
    font-size: .78rem;
  }

  .student-battle-board {
    display: grid;
    grid-template-columns: minmax(230px, 255px) minmax(0, 1fr);
    align-items: start;
    justify-content: center;
    gap: clamp(.4rem, 1vw, .7rem);
  }

  .student-battle-sidebar {
    display: flex;
    flex-direction: column;
    gap: .32rem;
  }

  .student-battle-sidebar .battle-fleet-status {
    display: flex;
    flex-direction: column;
    gap: .22rem;
    margin: 0;
  }

  .student-battle-sidebar .battle-fleet-card {
    min-height: 25px;
    padding: .24rem .36rem;
    font-size: .68rem;
  }

  .student-battle-sidebar .battle-unit-list {
    gap: .12rem;
  }

  .student-battle-sidebar .battle-legend {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: .25rem .42rem;
    margin: 0;
    padding: .28rem .36rem;
    border: 1px solid currentColor;
    border-radius: .45rem;
    background: rgba(255, 255, 255, .48);
    font-size: .66rem;
  }

  .student-battle-sidebar .battle-legend-icon { width: 11px; height: 11px; }

  .battle-theme-space .student-battle-sidebar .battle-legend {
    background: rgba(15, 23, 42, .52);
  }

  .student-battle-panel .battle-grid-wrap {
    width: min(100%, clamp(450px, calc(100dvh - 300px), 620px));
    margin: 0 auto;
    padding: clamp(.3rem, 1vh, .65rem);
  }

  .student-battle-panel .battle-grid { width: 100%; }
}

@media (max-width: 760px) {
  .student-battle-board {
    display: flex;
    flex-direction: column;
  }

  .student-battle-sidebar { display: block; }
  .student-battle-sidebar .battle-fleet-status { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .battle-panel-heading { display: block; }
  .battle-fleet-toggle { margin-top: .3rem; }
  .battle-fleet-status { grid-template-columns: 1fr; }
  .battle-fleet-card { padding: .45rem .5rem; font-size: .78rem; }
  .battle-fleet-card > div:not(.battle-unit-list) { display: none; }
  .battle-mini-ship i { width: 5px; height: 4px; }
  .battle-legend { justify-content: flex-start; gap: .3rem .55rem; font-size: .72rem; }
  .battle-grid { gap: 1px; }
  .battle-cell { min-width: 1.55rem; min-height: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  .battle-cell { transition: none !important; }
  .battle-grid { animation: none; }
  .battle-cell.is-sunk,
  .battle-cell.is-pending,
  .battle-cell.is-latest::before,
  .battle-cell.is-latest::after { animation: none !important; }
  .battle-toast { transition: none; }
  .battle-theme-space .battle-grid-wrap { animation: none; }
}

/* Nuage de mots : affichage après révélation uniquement */
.word-cloud { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:1rem 1.4rem; padding:2rem; min-height:12rem; }
.word-cloud-item { display:inline-block; font-weight:700; line-height:1.2; overflow-wrap:anywhere; color:var(--primary, #2563eb); }
.word-cloud-item:nth-child(3n+2) { color:#8b5cf6; }
.word-cloud-item:nth-child(3n) { color:#0f766e; }
.word-cloud-form { display:grid; gap:0.75rem; width:100%; }
.word-cloud-form textarea { width:100%; box-sizing:border-box; font:inherit; padding:0.75rem; }

/* Nuage de mots : présentation compacte et classement alternatif. */
.word-cloud-toolbar { display:flex; justify-content:center; flex-wrap:wrap; gap:.5rem; margin:1rem 0; }
.word-cloud-toolbar .active { box-shadow:inset 0 0 0 2px currentColor; }
.word-cloud-compact { display:flex; flex-wrap:wrap; align-content:center; align-items:baseline; justify-content:center; gap:.15rem .55rem; min-height:16rem; max-width:900px; margin:auto; padding:1.25rem; line-height:1; }
.word-cloud-compact .word-cloud-item { line-height:1.08; white-space:normal; text-align:center; max-width:100%; overflow-wrap:anywhere; }
.word-cloud-ranked { max-width:650px; margin:1rem auto; padding-left:2.25rem; }
.word-cloud-ranked li { padding:.45rem .6rem; border-bottom:1px solid var(--border-color, #ddd); }
.word-cloud-ranked li strong { float:right; margin-left:1rem; font-variant-numeric:tabular-nums; }
@media (max-width:600px) { .word-cloud-compact { padding:.5rem; gap:.2rem .4rem; } .word-cloud-compact .word-cloud-item { font-size:min(var(--mobile-cloud-size, 2rem), 2rem) !important; } }

/* Nuage V3 : positionnement libre en deux dimensions, sans flex-wrap. */
.word-cloud-compact { position:relative; display:block; box-sizing:border-box; width:100%; max-width:1100px; min-height:210px; padding:0; overflow:hidden; }
.word-cloud-compact .word-cloud-item { position:absolute; display:block; transform:translate(-50%,-50%); white-space:nowrap; max-width:none; line-height:1; overflow-wrap:normal; }
.word-cloud-compact.word-cloud-overflow { display:flex; flex-wrap:wrap; justify-content:center; gap:.5rem; padding:1rem; }
.word-cloud-compact.word-cloud-overflow .word-cloud-item { position:static; transform:none; }
@media (max-width:600px) { .word-cloud-compact .word-cloud-item { max-width:none; } }

/* Salle d’attente : connexion toujours visible, configuration défilante. */
@media (min-width: 761px) {
  body:has(#lobbyScreen.active) { overflow: hidden; }
  body:has(#lobbyScreen.active) > .app {
    height: calc(100dvh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  #lobbyScreen.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    gap: 12px;
  }
  #lobbyScreen .waiting-room-layout {
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 0;
    max-height: none;
  }
  #lobbyScreen .waiting-room-layout .hero {
    overflow: visible;
  }
  #lobbyScreen .students-panel {
    max-height: 370px;
    display: flex;
    flex-direction: column;
  }
  #lobbyScreen .students-panel .cards { min-height: 0; overflow-y: auto; }
  #lobbyScreen .lobby-scroll-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    align-content: start;
    gap: 18px;
    padding-right: 5px;
  }
}
#lobbyScreen .team-empty-warning {
  padding: 16px 18px;
  border: 1px solid #e5b65c;
  border-radius: 12px;
  background: #fff8e8;
  color: #684b16;
}
#lobbyScreen .team-empty-warning p { margin: 7px 0 0; }

/* Salle d'attente : QR code toujours entièrement visible, sans défilement interne. */
#lobbyScreen .waiting-room-layout .hero { overflow: visible; }
#lobbyScreen .lobby-journal { min-width: 0; }
#lobbyScreen .lobby-journal-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
#lobbyScreen .lobby-journal-summary::-webkit-details-marker { display: none; }
#lobbyScreen .lobby-journal-summary h2 { margin: 0; }
#lobbyScreen .lobby-journal-indicator::after { content: "Afficher"; font-size: .85rem; font-weight: 700; color: #2045aa; }
#lobbyScreen .lobby-journal[open] .lobby-journal-indicator::after { content: "Masquer"; }
#lobbyScreen .lobby-journal[open] .log { margin-top: 16px; }
@media (min-width: 761px) and (max-height: 760px) {
  #lobbyScreen .waiting-room-layout .hero { padding: 12px 18px; }
  #lobbyScreen .waiting-room-layout .hero .code-box { padding: 8px 12px; }
  #lobbyScreen .waiting-room-layout .hero .qr-box { margin-top: 6px; }
  #lobbyScreen #qrCodeCanvas canvas,
  #lobbyScreen #qrCodeCanvas img { max-width: min(190px, 23dvh); max-height: min(190px, 23dvh); width: auto; height: auto; }
}
@media (max-width: 600px) {
  .collective-correction-header .course-brand-name,
  .collective-correction-header .course-flag { display: none; }
}
.student-header-icon-link {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: #eef3ff;
  color: #172554;
  text-decoration: none;
}
.student-header-icon-link:hover { background: #dbeafe; }
.student-header-icon-link svg { width: 21px; height: 21px; }
@media (max-width: 390px) {
  .student-header-icon-link { width: 30px; height: 30px; }
  .student-header-icon-link svg { width: 19px; height: 19px; }
}

/* ===== Interface joueur Course : identité graphique 2026 ===== */
body.cq-student-page {
  --cq-primary: #213f91;
  --cq-action: #2864d8;
  --cq-teal: #0d9488;
  --cq-background: #f3f6fb;
  --cq-text: #17243b;
  --cq-shadow: 0 14px 38px rgba(23, 36, 59, .11);
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--cq-background);
  background-image:
    radial-gradient(ellipse at -5% 22%, rgba(93, 213, 191, .2) 0 7vw, transparent 7.1vw),
    radial-gradient(ellipse at 104% 45%, rgba(92, 202, 245, .18) 0 8vw, transparent 8.1vw),
    radial-gradient(circle at 2% 72%, rgba(139, 92, 246, .09) 0 11px, transparent 12px),
    linear-gradient(180deg, #eef6ff 0, #f8fafe 48%, #f3f6fb 100%);
  background-attachment: scroll;
  color: var(--cq-text);
}

body.cq-student-page::before,
body.cq-student-page::after {
  content: "";
  position: fixed;
  z-index: 0;
  bottom: -110px;
  width: 44vw;
  height: 230px;
  pointer-events: none;
  border-radius: 55% 45% 0 0;
  opacity: .5;
}

body.cq-student-page::before {
  left: -10vw;
  background: linear-gradient(145deg, rgba(93, 213, 191, .34), rgba(80, 151, 239, .14));
  transform: rotate(4deg);
}

body.cq-student-page::after {
  right: -10vw;
  background: linear-gradient(145deg, rgba(92, 177, 245, .16), rgba(32, 69, 181, .27));
  transform: rotate(-4deg);
}

.cq-student-page .student-game-header,
.cq-student-page .studentWrap {
  position: relative;
  z-index: 1;
}

.cq-student-page .student-game-header {
  min-height: 62px;
  padding: 8px clamp(12px, 3vw, 34px);
  border-bottom: 0;
  background: linear-gradient(112deg, #174aa8 0%, #0f3485 58%, #12347e 100%);
  box-shadow: 0 8px 24px rgba(20, 55, 134, .22);
  color: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-student-page .student-brand {
  gap: 8px;
  color: #fff;
}

.cq-student-page .student-brand-logo {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  filter: drop-shadow(0 4px 7px rgba(2, 19, 65, .25));
}

.cq-student-page .student-brand-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cq-student-page .student-brand-name {
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -.02em;
}

.cq-student-page .student-brand-name span {
  color: #5ccaf5;
}

.cq-student-page .student-player-summary {
  top: 7px;
  flex-direction: row;
  gap: 9px;
}

.cq-student-page .student-header-avatar {
  width: 48px;
  height: 48px;
  border-width: 2px;
  box-shadow: 0 6px 15px rgba(2, 19, 65, .28);
}

.cq-student-page .student-player-labels {
  text-align: left;
}

.cq-student-page .student-player-name {
  padding: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  font-size: .9rem;
}

.cq-student-page .student-team-name {
  margin-top: 3px;
  color: #dbeafe;
  font-size: .72rem;
}

.cq-student-page .student-question-counter,
.cq-student-page .student-header-timer,
.cq-student-page .student-team-score {
  min-height: 31px;
  border: 1px solid rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .13);
  color: #fff;
  box-shadow: none;
}

.cq-student-page .student-fullscreen-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .13);
  color: #fff;
}

.cq-student-page .student-fullscreen-btn:hover,
.cq-student-page .student-fullscreen-btn:focus-visible {
  background: rgba(255, 255, 255, .24);
}

.cq-student-page .student-fullscreen-btn svg {
  width: 19px;
  height: 19px;
}

.cq-student-page .studentWrap {
  padding: clamp(8px, 2vw, 18px);
}

.cq-student-page .student-game-header.has-player + .studentWrap {
  padding-top: clamp(8px, 2vw, 18px);
}

.cq-student-page #joinCard,
.cq-student-page .student-reconnect-card {
  width: min(570px, 100%);
  margin: clamp(16px, 5vh, 48px) auto auto;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid rgba(190, 209, 237, .82);
  border-radius: 26px;
  background:
    radial-gradient(circle at 98% -12%, rgba(92, 202, 245, .2) 0 90px, transparent 91px),
    radial-gradient(circle at 0 112%, rgba(13, 148, 136, .14) 0 100px, transparent 101px),
    rgba(255, 255, 255, .97);
  box-shadow: var(--cq-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-student-page #joinCard h2,
.cq-student-page .student-reconnect-card h2 {
  margin-bottom: 20px;
  color: #10204e;
  font-size: clamp(1.55rem, 5vw, 2rem);
  letter-spacing: -.025em;
}

.cq-student-page .avatar-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 22px;
  width: min(390px, 100%);
  margin: 4px auto 26px;
  text-align: left;
}

.cq-student-page #avatarPreview {
  grid-row: 1;
  width: 118px;
  height: 118px;
  filter: drop-shadow(0 10px 17px rgba(23, 54, 113, .16));
}

.cq-student-page .student-identity-controls {
  display: grid;
  justify-items: start;
  gap: 11px;
  min-width: 0;
}

.cq-student-page .identity-nickname {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #153e8d;
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  text-align: left;
}

.cq-student-page #changeAvatarBtn {
  display: inline-flex;
  min-height: 40px;
  padding: 9px 13px;
  align-items: center;
  gap: 7px;
  border: 1px solid #cbdcf6;
  border-radius: 12px;
  background: #edf5ff;
  color: #174caa;
  box-shadow: none;
}

.cq-student-page .student-button-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.cq-student-page #joinFormContent {
  gap: 5px;
}

.cq-student-page #joinFormContent label {
  color: #263b5d;
  font-size: .9rem;
}

.cq-student-page #joinFormContent input {
  min-height: 50px;
  margin: 5px 0 13px;
  border-color: #c9d9ef;
  background: #fbfdff;
  box-shadow: inset 0 1px 2px rgba(23, 54, 113, .04);
}

.cq-student-page #teacherCode {
  color: #10204e;
  font-size: 1.18rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
}

.cq-student-page #joinBtn,
.cq-student-page #reconnectNowBtn,
.cq-student-page #replayStudentBtn {
  min-height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2f7bf1, #1763d8);
  box-shadow: 0 10px 22px rgba(22, 65, 154, .2);
}

.cq-student-page .student-waiting-content {
  gap: 16px;
  padding: 8px 0 12px;
}

.cq-student-page .student-waiting-content .badge {
  background: #e8f2ff;
  color: #174caa;
}

.cq-student-page #joinStatus:not(:empty),
.cq-student-page .student-reconnect-card .small:not(:empty) {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 11px;
  background: #fff7ed;
  color: #9a3412;
}

.cq-student-page .student-reconnect-card {
  gap: 14px;
}

/* La densité de jeu ci-dessous est réservée à la Course classique. */
.cq-student-page #gameCard.is-course-mode {
  --student-game-zone-max: 1360px;
  --student-game-zone-gutter: clamp(10px, 3vw, 44px);
  min-height: calc(100dvh - 86px);
  gap: clamp(9px, 1.6vh, 16px);
  padding: 4px 0 14px;
}

.cq-student-page #gameCard.is-course-mode .student-question-zone {
  max-height: none;
  padding: clamp(13px, 1.8vw, 21px);
  overflow: visible;
  border-color: #c4d6ee;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 9px 24px rgba(23, 54, 113, .09);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-student-page #gameCard.is-course-mode #questionText {
  margin: 0;
  color: #10204e;
  font-size: clamp(1.2rem, 2.3vw, 1.75rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.cq-student-page #gameCard.is-course-mode .question-image-display:not(.hidden) {
  margin-top: 12px;
}

.cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] {
  gap: clamp(8px, 1.2vw, 14px);
  height: clamp(188px, 31dvh, 310px);
  min-height: 188px;
  padding: 0;
  background: transparent;
}

.cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] > .answerBtn {
  min-width: 0;
  min-height: 112px;
  padding: clamp(13px, 1.5vw, 20px);
  overflow-wrap: anywhere;
  border: 2px solid #047857;
  border-radius: 17px;
  box-shadow: 0 9px 20px rgba(6, 95, 70, .16);
  font-size: clamp(1rem, 1.7vw, 1.42rem);
  line-height: 1.3;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}

@media (hover: hover) {
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] > .answerBtn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 13px 25px rgba(6, 95, 70, .22);
  }
}

.cq-student-page #gameCard.is-course-mode > .feedback {
  min-height: 54px;
  padding: 9px 14px;
  border-radius: 15px;
  font-size: clamp(1rem, 2vw, 1.16rem);
}

.cq-student-page #gameCard.is-course-mode > .answers:not([data-answer-count]) {
  width: min(780px, calc(100% - var(--student-game-zone-gutter)));
  margin-inline: auto;
}

.cq-student-page #gameCard.is-course-mode .answerBtn:disabled:not(.is-found):not(.is-wrong) {
  opacity: .62;
}

.cq-student-page #gameCard.is-course-mode .answerBtn.is-pending {
  outline: 3px solid rgba(255, 255, 255, .72);
  outline-offset: -6px;
  opacity: .78;
}

.cq-student-page #gameCard.is-course-mode .waiting-screen {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid #c4d6ee;
  border-radius: 19px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 9px 24px rgba(23, 54, 113, .09);
}

.cq-student-page #gameCard.is-course-mode .waiting-screen p {
  color: #334a6b;
  font-size: 1.08rem;
  font-weight: 750;
}

.cq-student-page #gameCard.is-course-mode .waiting-screen,
.cq-student-page #gameCard.is-course-mode .final-ranking {
  width: min(780px, 100%);
  margin-inline: auto;
}

@media (max-width: 640px) {
  body.cq-student-page::before,
  body.cq-student-page::after {
    opacity: .32;
  }

  .cq-student-page .student-game-header {
    min-height: 58px;
    padding: 6px 7px;
    gap: 5px;
  }

  .cq-student-page .student-brand-logo {
    width: 31px;
    height: 31px;
  }

  .cq-student-page .student-player-summary {
    position: static;
    width: auto;
    min-width: 0;
    gap: 6px;
    transform: none;
  }

  .cq-student-page .student-header-avatar {
    width: 44px;
    height: 44px;
  }

  .cq-student-page .student-player-labels {
    min-width: 0;
  }

  .cq-student-page .student-player-name {
    font-size: .78rem;
  }

  .cq-student-page .student-team-name {
    display: block;
    font-size: .64rem;
  }

  .cq-student-page #studentPageHeader.has-player .student-header-actions {
    align-self: center;
  }

  .cq-student-page .student-question-counter,
  .cq-student-page .student-header-timer,
  .cq-student-page .student-team-score {
    min-height: 25px;
    padding: 3px 6px;
    font-size: .7rem;
  }

  .cq-student-page .student-fullscreen-btn {
    width: 29px;
    height: 29px;
  }

  .cq-student-page .student-fullscreen-btn svg {
    width: 16px;
    height: 16px;
  }

  .cq-student-page #studentPageHeader.student-game-header.has-player {
    min-height: 58px;
  }

  .cq-student-page #studentPageHeader.has-player + .studentWrap {
    padding-top: 5px;
  }

  .cq-student-page .studentWrap {
    padding: 6px;
  }

  .cq-student-page #joinCard,
  .cq-student-page .student-reconnect-card {
    margin-top: 9px;
    padding: 20px 17px;
    border-radius: 20px;
  }

  .cq-student-page #joinCard h2,
  .cq-student-page .student-reconnect-card h2 {
    margin-bottom: 15px;
  }

  .cq-student-page .avatar-picker {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 19px;
  }

  .cq-student-page #avatarPreview {
    width: 82px;
    height: 82px;
  }

  .cq-student-page .student-identity-controls {
    gap: 8px;
  }

  .cq-student-page .identity-nickname {
    font-size: 1.08rem;
  }

  .cq-student-page #changeAvatarBtn {
    min-height: 38px;
    padding: 8px 11px;
  }

  .cq-student-page #joinFormContent input {
    min-height: 47px;
    margin-bottom: 10px;
  }

  .cq-student-page #joinBtn,
  .cq-student-page #reconnectNowBtn,
  .cq-student-page #replayStudentBtn {
    min-height: 48px;
  }

  .cq-student-page #gameCard.is-course-mode {
    --student-game-zone-gutter: 0px;
    min-height: calc(100dvh - 69px);
    gap: 7px;
    padding: 3px 0 10px;
  }

  .cq-student-page #gameCard.is-course-mode .student-question-zone,
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count],
  .cq-student-page #gameCard.is-course-mode > .feedback {
    width: 100%;
  }

  .cq-student-page #gameCard.is-course-mode .student-question-zone {
    min-height: 62px;
    padding: 10px 11px;
    border-radius: 15px;
  }

  .cq-student-page #gameCard.is-course-mode #questionText {
    font-size: clamp(.98rem, 4.5vw, 1.16rem);
    line-height: 1.24;
  }

  .cq-student-page #gameCard.is-course-mode .question-image-display:not(.hidden) {
    width: 100%;
    margin: 9px auto 0;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="2"],
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="4"] {
    height: auto;
    min-height: 184px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(82px, 1fr));
    grid-auto-rows: minmax(82px, 1fr);
    gap: 7px;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="2"] {
    min-height: 86px;
    grid-template-rows: minmax(86px, auto);
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: 1 / -1;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] > .answerBtn {
    height: auto;
    min-height: 82px;
    padding: 10px 8px;
    border-radius: 14px;
    font-size: clamp(.9rem, 4vw, 1.05rem);
    line-height: 1.2;
  }

  .cq-student-page #gameCard.is-course-mode > .feedback {
    min-height: 46px;
    padding: 7px 10px;
    border-radius: 13px;
    font-size: .94rem;
  }
}

/* ===== Salle d'attente organisateur : identité graphique 2026 ===== */
body.cq-course-page {
  --cq-primary: #213f91;
  --cq-action: #2864d8;
  --cq-teal: #0d9488;
  --cq-background: #f3f6fb;
  --cq-text: #17243b;
  --course-header-height: 62px;
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--cq-background);
  background-image:
    radial-gradient(ellipse at -4% 23%, rgba(93, 213, 191, .2) 0 7vw, transparent 7.1vw),
    radial-gradient(ellipse at 104% 48%, rgba(92, 202, 245, .18) 0 8vw, transparent 8.1vw),
    radial-gradient(circle at 2% 73%, rgba(139, 92, 246, .09) 0 11px, transparent 12px),
    linear-gradient(180deg, #eef6ff 0, #f8fafe 48%, #f3f6fb 100%);
  background-attachment: scroll;
  color: var(--cq-text);
}

body.cq-course-page::before,
body.cq-course-page::after {
  content: "";
  position: fixed;
  z-index: 0;
  bottom: -120px;
  width: 44vw;
  height: 230px;
  pointer-events: none;
  border-radius: 55% 45% 0 0;
  opacity: .5;
}

body.cq-course-page::before {
  left: -10vw;
  background: linear-gradient(145deg, rgba(93, 213, 191, .34), rgba(80, 151, 239, .14));
  transform: rotate(4deg);
}

body.cq-course-page::after {
  right: -10vw;
  background: linear-gradient(145deg, rgba(92, 177, 245, .16), rgba(32, 69, 181, .27));
  transform: rotate(-4deg);
}

.cq-course-page .course-header,
.cq-course-page > .app {
  position: relative;
  z-index: 1;
}

.cq-course-page .course-header {
  position: sticky;
  min-height: var(--course-header-height);
  padding: 8px clamp(12px, 3vw, 34px);
  color: #fff;
  background: linear-gradient(112deg, #174aa8 0%, #0f3485 58%, #12347e 100%);
  border-bottom: 0;
  box-shadow: 0 8px 24px rgba(20, 55, 134, .22);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-course-page .course-brand-logo {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  filter: drop-shadow(0 4px 7px rgba(2, 19, 65, .25));
}

.cq-course-page .course-brand-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cq-course-page .course-brand-name {
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -.02em;
}

.cq-course-page .course-brand-name span { color: #5ccaf5; }

.cq-course-page .course-view-label { color: #fff; }

.cq-course-page .course-header-button {
  min-height: 38px;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .22);
}

.cq-course-page .course-header-button:hover,
.cq-course-page .course-header-button:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .2);
}

.cq-course-page .course-close-button {
  color: #fff;
  background: rgba(127, 29, 29, .32);
  border-color: rgba(254, 202, 202, .42);
}

.cq-course-page > .app {
  max-width: 1320px;
}

.cq-course-page #lobbyScreen .panel {
  background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(40, 100, 216, .12);
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(23, 36, 59, .09);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-course-page #lobbyScreen .waiting-room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(370px, .85fr);
  align-items: stretch;
  gap: 16px;
}

.cq-course-page #lobbyScreen .waiting-room-layout .students-panel,
.cq-course-page #lobbyScreen .waiting-room-layout .hero {
  width: 100%;
  min-width: 0;
  flex: none;
}

.cq-course-page #lobbyScreen .students-panel {
  max-height: 292px;
  padding: 18px;
}

.cq-course-page #lobbyScreen .lobby-panel-heading,
.cq-course-page #lobbyScreen .lobby-heading-title {
  display: flex;
  align-items: center;
}

.cq-course-page #lobbyScreen .lobby-panel-heading {
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}

.cq-course-page #lobbyScreen .lobby-heading-title { gap: 10px; }
.cq-course-page #lobbyScreen .lobby-heading-title svg {
  width: 24px;
  height: 24px;
  color: var(--cq-action);
}

.cq-course-page #lobbyScreen .lobby-panel-heading h2 {
  margin: 0;
  color: var(--cq-primary);
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
}

.cq-course-page #lobbyScreen .lobby-player-count {
  display: inline-grid;
  min-width: 38px;
  height: 32px;
  padding: 0 10px;
  place-items: center;
  color: #fff;
  background: var(--cq-teal);
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 900;
}

.cq-course-page #studentsList {
  align-content: start;
  padding: 2px 4px 2px 2px;
  scrollbar-color: #a8bce6 transparent;
  scrollbar-width: thin;
}

.cq-course-page #lobbyScreen .lobby-player-row {
  border: 1px solid #e0e8f5;
  box-shadow: 0 4px 12px rgba(23, 36, 59, .06);
}

.cq-course-page #lobbyScreen .lobby-empty-state {
  grid-column: 1 / -1;
  min-height: 128px;
  margin: 0;
  padding: 28px 18px;
  color: #60708a;
  background: #f7f9fd;
  border: 1px dashed #b7c7e4;
  border-radius: 16px;
  text-align: center;
}

.cq-course-page #lobbyScreen .waiting-room-layout .hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  padding: 16px 18px;
}

.cq-course-page #lobbyScreen .lobby-card-actions {
  justify-content: center;
  margin-bottom: 5px;
}

.cq-course-page #lobbyScreen .lobby-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.cq-course-page #lobbyScreen .lobby-card-actions img {
  width: 18px;
  height: 18px;
  filter: invert(38%) sepia(74%) saturate(991%) hue-rotate(185deg);
}

.cq-course-page #lobbyScreen .code-box {
  width: 100%;
  max-width: 330px;
  margin: 5px auto;
  padding: 10px 18px;
  gap: 2px;
  background: #edf5ff;
  border: 2px dashed #75a2eb;
  border-radius: 16px;
}

.cq-course-page #lobbyScreen .code-box strong {
  color: var(--cq-primary);
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  letter-spacing: .12em;
  line-height: 1.05;
}

.cq-course-page #lobbyScreen .qr-box { margin-top: 5px; }
.cq-course-page #lobbyScreen #qrCodeCanvas canvas,
.cq-course-page #lobbyScreen #qrCodeCanvas img {
  width: auto;
  height: auto;
  max-width: min(170px, 21dvh);
  max-height: min(170px, 21dvh);
  padding: 7px;
  border: 1px solid #dce6f5;
  border-radius: 13px;
  box-shadow: 0 6px 18px rgba(23, 36, 59, .1);
}

.cq-course-page #lobbyScreen #connectionStatus {
  margin: 4px 0 0;
  color: #52627a;
  text-align: center;
}

.cq-course-page #lobbyScreen .lobby-scroll-content {
  scrollbar-color: #a8bce6 transparent;
  scrollbar-width: thin;
}

.cq-course-page #lobbyScreen .lobby-scroll-content > .panel {
  padding: 18px 20px;
}

.cq-course-page #lobbyScreen .bank-icon {
  width: 38px;
  height: 38px;
  color: var(--cq-primary);
  background: #eaf1ff;
}

.cq-course-page #lobbyScreen .bank-icon svg { width: 21px; height: 21px; }
.cq-course-page #lobbyScreen .bank-title h2,
.cq-course-page #lobbyScreen .lobby-journal h2 { color: var(--cq-primary); }

.cq-course-page #lobbyScreen .game-options-layout {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start;
}
.cq-course-page #lobbyScreen .game-options-layout > .panel { min-width: 0; padding: 18px 20px; }
.cq-course-page #lobbyScreen #mainGameOptionsGrid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.cq-course-page #lobbyScreen #mainGameOptionsGrid > div { grid-column: span 2; }
.cq-course-page #lobbyScreen #mainGameOptionsGrid > div:first-child,
.cq-course-page #lobbyScreen #mainGameOptionsGrid > .player-organization { grid-column: span 3; }
.cq-course-page #lobbyScreen #mainGameOptionsGrid > #teamSizeOption,
.cq-course-page #lobbyScreen #mainGameOptionsGrid > #battleTeamCountOption,
.cq-course-page #lobbyScreen #mainGameOptionsGrid > #victoryConditionOption { grid-column: 1 / -1; }
.cq-course-page #lobbyScreen #advancedGameOptionsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cq-course-page #lobbyScreen #advancedGameOptionsGrid > .game-option-inline,
.cq-course-page #lobbyScreen #advancedGameOptionsGrid > .checkbox-option { grid-column: 1 / -1; }
.cq-course-page .game-option-inline {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px;
}
.cq-course-page .game-option-inline > label { margin: 0; flex: 1 1 150px; }
.cq-course-page .game-option-inline > select { width: 170px; max-width: 100%; min-width: 0; flex: 0 1 170px; margin: 0; }
.cq-course-page #lobbyScreen .game-options-layout:has(#toggleGameOptionsBtn.hidden) .lobby-advanced-options-panel { display: none; }
@media (max-width: 900px) {
  .cq-course-page #lobbyScreen .game-options-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .cq-course-page #lobbyScreen .game-options-layout > .panel { padding: 16px; }
  .cq-course-page #lobbyScreen #mainGameOptionsGrid,
  .cq-course-page #lobbyScreen #advancedGameOptionsGrid { grid-template-columns: minmax(0, 1fr); }
  .cq-course-page #lobbyScreen .game-options-layout #mainGameOptionsGrid > div,
  .cq-course-page #lobbyScreen .game-options-layout #mainGameOptionsGrid > fieldset { grid-column: 1 / -1; }
}
.cq-course-page #gameOptionsPanel { margin-top: 14px; }
.cq-course-page .game-options-grid > div { min-width: 0; }
.cq-course-page .player-organization { min-width: 0; margin: 0; padding: 0; border: 0; }
.cq-course-page .player-organization legend { padding: 0; margin-bottom: 7px; font-weight: 700; color: #19315d; }
.cq-course-page .player-organization-choices { display: flex; gap: 8px; }
.cq-course-page .player-organization-choices .btn {
  flex: 1; min-width: 0; padding: 10px 8px; border: 1px solid #bacbe1; background: #edf3ff;
  transition: background .15s ease, box-shadow .15s ease;
}
.cq-course-page .player-organization-choices [aria-pressed="true"] { border-color: #5474a3; box-shadow: inset 0 0 0 1px #5474a3; }
.cq-course-page .player-organization-choices [aria-pressed="true"]::after { content: " \2713"; }
.cq-course-page .player-organization-choices button:focus-visible { outline: 3px solid #193f85; outline-offset: 2px; }
.cq-course-page #playerOrganizationHelp { margin: 7px 0 0; line-height: 1.4; }
.cq-course-page #advancedGameOptionsPanel { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) {
  .cq-course-page .player-organization-choices .btn { transition: none; }
}

.cq-course-page #lobbyScreen .lobby-journal-indicator::after { color: var(--cq-action); }
.cq-course-page #lobbyScreen .lobby-journal .log {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-color: #a8bce6 transparent;
  scrollbar-width: thin;
}

@media (min-width: 1100px) {
  .cq-course-page #lobbyScreen .waiting-room-layout .hero {
    grid-template-columns: minmax(155px, 1fr) minmax(150px, 178px);
    grid-template-areas:
      "actions actions"
      "code qr"
      "status status";
    column-gap: 12px;
  }

  .cq-course-page #lobbyScreen .lobby-card-actions { grid-area: actions; }
  .cq-course-page #lobbyScreen #gameCodeBox { grid-area: code; }
  .cq-course-page #lobbyScreen #qrCodeBox { grid-area: qr; }
  .cq-course-page #lobbyScreen #connectionStatus { grid-area: status; }
}

@media (min-width: 761px) {
  body.cq-course-page:has(#lobbyScreen.active) { overflow: hidden; }
  body.cq-course-page:has(#lobbyScreen.active) > .app {
    height: calc(100dvh - var(--course-header-height));
    max-height: calc(100dvh - var(--course-header-height));
    overflow: hidden;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .cq-course-page #lobbyScreen.active {
    min-height: 0;
    height: 100%;
  }

  .cq-course-page #lobbyScreen .waiting-room-layout { flex: 0 0 auto; }
  .cq-course-page #lobbyScreen .students-panel .cards {
    min-height: 0;
    overflow-y: auto;
  }

  .cq-course-page #lobbyScreen .lobby-scroll-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 761px) and (max-width: 1099px) {
  .cq-course-page #lobbyScreen .waiting-room-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr);
  }

  .cq-course-page #lobbyScreen .students-panel { max-height: 318px; }
  .cq-course-page #lobbyScreen #qrCodeCanvas canvas,
  .cq-course-page #lobbyScreen #qrCodeCanvas img {
    max-width: min(126px, 17dvh);
    max-height: min(126px, 17dvh);
  }
}

@media (max-width: 760px) {
  body.cq-course-page { --course-header-height: 56px; }
  .cq-course-page .course-header { min-height: var(--course-header-height); }
  .cq-course-page > .app { padding: 12px; }
  .cq-course-page #lobbyScreen .waiting-room-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .cq-course-page #lobbyScreen .waiting-room-layout .hero { order: -1; }
  .cq-course-page #lobbyScreen .students-panel { max-height: none; }
  .cq-course-page #lobbyScreen .students-panel .cards { max-height: 280px; overflow-y: auto; }
  .cq-course-page #lobbyScreen .lobby-scroll-content { display: grid; gap: 12px; }
  .cq-course-page #lobbyScreen .lobby-scroll-content > .panel { padding: 16px; }
  .cq-course-page #lobbyScreen .actions.left > button { flex: 1 1 170px; }
}

@media (max-width: 480px) {
  .cq-course-page .course-header { gap: 7px; padding-inline: 8px; }
  .cq-course-page .course-header-actions { gap: 4px; }
  .cq-course-page .course-header-button { min-height: 34px; padding: 5px 7px; }
  .cq-course-page .course-icon-button { width: 34px; padding: 0; }
  .cq-course-page .course-action-label { display: none; }
  .cq-course-page .course-view-label { font-size: .74rem; }
  .cq-course-page #lobbyScreen .panel { border-radius: 17px; }
  .cq-course-page #lobbyScreen .waiting-room-layout .hero,
  .cq-course-page #lobbyScreen .students-panel { padding: 15px; }
  .cq-course-page #studentsList { grid-template-columns: 1fr; }
  .cq-course-page #lobbyScreen .lobby-empty-state { min-height: 92px; padding: 22px 14px; }
  .cq-course-page #lobbyScreen .code-box strong { font-size: clamp(1.8rem, 10vw, 2.4rem); }
}

@media (max-width: 360px) {
  .cq-student-page .student-brand-logo {
    width: 28px;
    height: 28px;
  }

  .cq-student-page .student-header-avatar {
    width: 40px;
    height: 40px;
  }

  .cq-student-page .student-player-name {
    max-width: 82px;
  }

  .cq-student-page #studentPageHeader.has-player .student-header-actions {
    gap: 3px;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="4"] {
    min-height: 172px;
    grid-template-rows: repeat(2, minmax(76px, 1fr));
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] > .answerBtn {
    min-height: 76px;
    padding: 8px 6px;
    font-size: .88rem;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (min-width: 520px) {
  .cq-student-page .student-game-header {
    min-height: 48px;
    padding-block: 4px;
  }

  .cq-student-page .student-brand-logo {
    width: 30px;
    height: 30px;
  }

  .cq-student-page .student-header-avatar {
    width: 40px;
    height: 40px;
  }

  .cq-student-page #studentPageHeader.has-player + .studentWrap {
    padding-top: 4px;
  }

  .cq-student-page #gameCard.is-course-mode {
    min-height: calc(100dvh - 56px);
    gap: 5px;
    padding-bottom: 6px;
  }

  .cq-student-page #gameCard.is-course-mode .student-question-zone {
    min-height: 48px;
    padding: 7px 11px;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="2"],
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="4"] {
    min-height: 96px;
    grid-template-rows: minmax(70px, auto);
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: auto;
  }

  .cq-student-page #gameCard.is-course-mode > .answers[data-answer-count] > .answerBtn {
    min-height: 70px;
    padding: 8px;
  }
}

/* ===== Joueur Bataille : plateau consultable sans repousser la question ===== */
.cq-student-page #gameCard.is-battle-mode {
  --student-game-zone-gutter: 0px;
  gap: clamp(8px, 1.3vh, 14px);
  padding: 2px 0 14px;
}

.cq-student-page #gameCard.is-battle-mode .student-battle-panel {
  margin: 0;
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(23, 54, 113, .12);
}

.cq-student-page .student-battle-heading-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.cq-student-page .battle-board-toggle,
.cq-student-page .battle-fleet-toggle {
  width: auto;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.cq-student-page .battle-board-toggle {
  display: none;
}

.cq-student-page .battle-board-toggle svg,
.cq-student-page .battle-fleet-toggle img {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.cq-student-page .battle-board-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.cq-student-page .battle-fleet-toggle img {
  opacity: .82;
}

.cq-student-page #gameCard.is-battle-mode .student-question-zone {
  max-height: none;
  padding: clamp(12px, 1.7vw, 20px);
  overflow: visible;
  border-color: #c4d6ee;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 9px 24px rgba(23, 54, 113, .09);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-student-page #gameCard.is-battle-mode #questionText {
  margin: 0;
  color: #10204e;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] {
  height: auto;
  min-height: 190px;
  padding: 0;
  gap: clamp(7px, 1vw, 12px);
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] > .answerBtn {
  min-width: 0;
  min-height: 86px;
  height: auto;
  padding: clamp(10px, 1.4vw, 17px);
  overflow-wrap: anywhere;
  border: 2px solid #047857;
  border-radius: 16px;
  font-size: clamp(.95rem, 1.55vw, 1.3rem);
  line-height: 1.24;
}

.cq-student-page #gameCard.is-battle-mode > .feedback {
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 1rem;
}

@media (min-width: 1100px) {
  .cq-student-page #gameCard.is-battle-mode {
    display: grid;
    grid-template-columns: minmax(470px, .94fr) minmax(480px, 1.06fr);
    grid-template-rows: auto auto auto 1fr;
    align-content: start;
    align-items: start;
    min-height: calc(100dvh - 86px);
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-panel {
    grid-column: 1;
    grid-row: 1 / span 3;
    align-self: start;
    max-height: calc(100dvh - 94px);
    overflow: auto;
    scrollbar-gutter: stable;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-board {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-sidebar {
    display: block;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-sidebar .battle-fleet-status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 5px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-sidebar .battle-legend {
    justify-content: center;
    padding: 4px 6px;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-grid-wrap {
    width: min(100%, calc(100dvh - 255px));
    min-width: 0;
    max-width: 620px;
    margin-inline: auto;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone,
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count],
  .cq-student-page #gameCard.is-battle-mode > .feedback {
    grid-column: 2;
    width: 100%;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone { grid-row: 1; }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] {
    grid-row: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(110px, 1fr));
    min-height: min(42dvh, 330px);
  }

  .cq-student-page #gameCard.is-battle-mode > .feedback { grid-row: 3; }

  .cq-student-page #gameCard.is-battle-mode > .quiz-recap {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

@media (min-width: 761px) and (max-width: 1099px) {
  .cq-student-page #gameCard.is-battle-mode .student-battle-panel {
    padding: 7px 9px 9px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-panel .battle-grid-wrap {
    width: min(100%, 56dvh);
    max-width: 590px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone,
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count],
  .cq-student-page #gameCard.is-battle-mode > .feedback {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .cq-student-page #gameCard.is-battle-mode {
    min-height: calc(100dvh - 69px);
    gap: 7px;
    padding-bottom: 9px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-panel {
    padding: 8px;
    border-radius: 15px;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-panel-heading {
    display: flex;
    margin: 0;
    align-items: center;
    gap: 8px;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-panel-heading > div:first-child {
    display: grid;
    min-width: 0;
    flex: 1 1 auto;
    gap: 2px;
    white-space: normal;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-mode-badge {
    width: max-content;
    max-width: 100%;
    padding: 3px 7px;
    font-size: .65rem;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-panel-heading h2 {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: clamp(.78rem, 3.5vw, .94rem);
    line-height: 1.15;
  }

  .cq-student-page .student-battle-heading-actions {
    flex: 0 0 auto;
  }

  .cq-student-page .battle-board-toggle {
    display: inline-flex;
    min-height: 44px;
    margin: 0;
    padding: 7px 10px;
    border-color: rgba(23, 74, 168, .24);
    background: rgba(255, 255, 255, .9);
    color: #174aa8;
    font-size: .78rem;
  }

  .cq-student-page .battle-board-toggle[aria-disabled="true"] {
    cursor: default;
    opacity: .82;
  }

  .cq-student-page .battle-fleet-toggle {
    min-height: 40px;
    margin: 6px 0 0;
    padding: 6px 9px;
    font-size: .76rem;
  }

  .cq-student-page .student-battle-panel.is-board-collapsed .student-battle-board,
  .cq-student-page .student-battle-panel.is-board-collapsed .battle-fleet-toggle {
    display: none;
  }

  .cq-student-page .student-battle-panel:not(.is-board-collapsed) .battle-panel-heading {
    margin-bottom: 7px;
  }

  .cq-student-page .student-battle-panel:not(.is-board-collapsed) .student-battle-heading-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .cq-student-page #gameCard.is-battle-mode .student-battle-board {
    max-width: 100%;
  }

  .cq-student-page #gameCard.is-battle-mode .battle-grid-wrap {
    width: 100%;
    max-width: 100%;
    padding: 5px;
    overscroll-behavior-inline: contain;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone,
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count],
  .cq-student-page #gameCard.is-battle-mode > .feedback {
    width: 100%;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone {
    min-height: 58px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .cq-student-page #gameCard.is-battle-mode #questionText {
    font-size: clamp(.96rem, 4.4vw, 1.14rem);
    line-height: 1.22;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="2"],
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(78px, auto));
    grid-auto-rows: minmax(78px, auto);
    min-height: 170px;
    gap: 7px;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="2"] {
    grid-template-rows: minmax(82px, auto);
    min-height: 82px;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: 1 / -1;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] > .answerBtn {
    min-height: 78px;
    padding: 9px 7px;
    border-radius: 13px;
    font-size: clamp(.88rem, 3.9vw, 1.02rem);
  }
}

@media (max-width: 360px) {
  .cq-student-page .battle-board-toggle {
    padding-inline: 7px;
    font-size: .72rem;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="4"] {
    grid-template-rows: repeat(2, minmax(72px, auto));
    min-height: 158px;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] > .answerBtn {
    min-height: 72px;
    padding: 8px 6px;
    font-size: .86rem;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (min-width: 520px) and (max-width: 1099px) {
  .cq-student-page #gameCard.is-battle-mode {
    gap: 5px;
    padding-bottom: 6px;
  }

  .cq-student-page #gameCard.is-battle-mode .student-question-zone {
    min-height: 46px;
    padding: 7px 10px;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="2"],
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"],
  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="4"] {
    grid-template-rows: minmax(68px, auto);
    min-height: 68px;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count="3"] > .answerBtn:nth-child(3) {
    grid-column: auto;
  }

  .cq-student-page #gameCard.is-battle-mode > .answers[data-answer-count] > .answerBtn {
    min-height: 68px;
  }
}

.autonomous-page .autonomous-header .student-header-icon-link,
.autonomous-page .autonomous-header .student-fullscreen-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .13);
  color: #fff;
  box-shadow: none;
}

.autonomous-page .autonomous-header .student-header-icon-link:hover,
.autonomous-page .autonomous-header .student-header-icon-link:focus-visible,
.autonomous-page .autonomous-header .student-fullscreen-btn:hover,
.autonomous-page .autonomous-header .student-fullscreen-btn:focus-visible {
  background: rgba(255, 255, 255, .24);
}

.autonomous-page .autonomous-header .student-fullscreen-btn svg,
.autonomous-page .autonomous-header .student-header-icon-link svg {
  width: 19px;
  height: 19px;
}

@media (max-width: 700px) {

  .autonomous-page .autonomous-header .student-header-icon-link,
  .autonomous-page .autonomous-header .student-fullscreen-btn {
    width: 30px;
    height: 30px;
  }
}
.course-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.course-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.course-brand-image {
  display: block;
  width: 150px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.course-brand-link:hover .course-brand-image {
  opacity: 0.85;
}

@media (max-width: 600px) {
  .course-brand-image {
    width: 130px;
  }
}

/* Shared team help: hover/focus on desktop, native information toggle on touch. */
.cq-course-page .team-organization-choice { display: flex; flex: 1; min-width: 0; align-items: center; gap: 6px; position: relative; }
.cq-course-page .team-organization-info { flex: none; }
.cq-course-page .team-organization-info > summary {
  display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #bacbe1;
  border-radius: 50%; color: #193f85; background: #edf3ff; font-weight: 800; cursor: pointer; list-style: none;
}
.cq-course-page .team-organization-info > summary::-webkit-details-marker { display: none; }
.cq-course-page .team-organization-info > summary:focus-visible { outline: 3px solid #193f85; outline-offset: 2px; }
.cq-course-page .team-organization-tooltip {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 30; width: min(290px, 80vw);
  padding: 8px 10px; border-radius: 8px; background: #1a2944; color: #fff; font-size: .8rem; line-height: 1.4;
  visibility: hidden; opacity: 0;
}
.cq-course-page .team-organization-choice:has(#teamOrganizationBtn:focus-visible) > .team-organization-tooltip,
.cq-course-page .team-organization-choice:has(.team-organization-info > summary:focus-visible) > .team-organization-tooltip,
.cq-course-page .team-organization-choice:has(.team-organization-info[open]) > .team-organization-tooltip { visibility: visible; opacity: 1; }
@media (hover: hover) {
  .cq-course-page .team-organization-choice:hover > .team-organization-tooltip { visibility: visible; opacity: 1; }
}
.cq-course-page #teamsInfoText:empty { display: none; }

.cq-course-page #playerOrganizationHelp:empty { display: none; }
.cq-course-page .team-size-note { font-weight: 400; }

/* Départ local des joueurs en Course ; aucun son ni asset supplémentaire. */
.course-start-countdown{grid-column:1/-1;min-height:260px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:24px;border:2px solid #bfdbfe;border-radius:24px;background:linear-gradient(145deg,#eff6ff,#ecfdf5);color:#172554;text-align:center}
.course-start-countdown.hidden{display:none}.course-start-countdown>span{font-size:2rem}.course-start-countdown p{margin:0;font-size:1.2rem;font-weight:700}.course-start-countdown strong{font-size:clamp(3rem,16vw,7rem);line-height:1.2;overflow-wrap:anywhere;max-width:100%}
.is-course-starting #studentQuestionZone,.is-course-starting #answerButtons,.is-course-starting #feedback{display:none}
.course-start-pop{animation:course-start-pop .3s ease-out}@keyframes course-start-pop{from{transform:scale(.65);opacity:.2}to{transform:scale(1);opacity:1}}
@media(prefers-reduced-motion:reduce){.course-start-pop{animation:none}}
