* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100vh;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f7fb;
  background-image: url("img/chameleon_fond.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #172033;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 1000;
  transform: translateY(-140%);
  background: #0f172a;
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

header,
.app {
  max-width: 1150px;
  margin: 0 auto;
  padding: 20px;
}

.app {
  display: grid;
  gap: 18px;
  width: 100%;
}

main.home {
  flex: 1;
}

.panel,
.card,
.question-card {
  background: white;
  border-radius: 22px;
  box-shadow: 0 10px 30px #10204018;
  padding: 22px;
}
.panel,
.card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.hero {
  text-align: center;
}

.compact {
  padding: 18px;
}

.hidden,
.modal.hidden {
  display: none !important;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
  gap: 18px;
}

h1,
h2,
h3 {
  margin-top: 0;
}

.small,
.note {
  color: #475569;
}

.center {
  text-align: center;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0;
}

.actions.left {
  justify-content: flex-start;
}

.btn,
button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: #e8eef8;
  color: #172033;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.primary {
  background: #1e40af;
  color: white;
}

.danger {
  background: #fee2e2;
  color: #991b1b;
}

.big {
  font-size: 1.1rem;
  padding: 16px 22px;
}

.small-btn {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: .85rem;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d7dfec;
  border-radius: 14px;
  padding: 12px;
  margin: 6px 0 12px;
  background: #fbfdff;
  font: inherit;
}

label {
  font-weight: 800;
}

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

.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;
}

.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;
}

.question-editor {
  display: grid;
  gap: 14px;
}

.question-card {
  box-shadow: none;
  border: 1px solid #e2e8f0;
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: #eef3ff;
  font-weight: 800;
}

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

.studentWrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
}

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

.answerBtn {
  width: 100%;
  background: #047857;
  color: white;
  font-size: 1.15rem;
  padding: 18px;
}

.feedback {
  font-size: 1.2rem;
  font-weight: 900;
}

.feedback.good {
  color: #15803d;
}

.feedback.bad {
  color: #b91c1c;
}

.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-screen {
  max-width: 1200px;
  margin: auto;
  width: 100%;
}

.score-panel-full {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scoreboard {
  display: grid;
  gap: 20px;
}

.score-row {
  background: #f8fafc;
  border-radius: 22px;
  padding: 18px;
  border: 1px solid #e2e8f0;
}

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

.score-track {
  height: 34px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.score-bar {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 999px;
  transition: width .45s ease;
}

.score-row.up .score-bar {
  animation: pulseUp .6s;
}

.score-row.down .score-bar {
  animation: pulseDown .6s;
}

@keyframes pulseUp {
  50% {
    filter: brightness(1.25);
  }
}

@keyframes pulseDown {
  50% {
    filter: grayscale(.6);
  }
}

#scoreOnlyTitle {
  text-align: center;
  font-size: 2.4rem;
  margin-top: 0;
}

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

/* ===== Banque compacte ===== */
.bank-panel {
  padding: 16px;
}

.bank-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.bank-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bank-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

.bank-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #1e40af;
  color: white;
  font-weight: 900;
  box-shadow: 0 8px 18px #1e40af35;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  margin-left: 4px;
  border-radius: 999px;
  background: #2563eb;
  color: white;
  font-size: .85rem;
}

.bank-actions {
  margin-left: auto;
}

.bank-panel .actions {
  margin-bottom: 0;
}

.bank-panel #bankHint {
  margin: 6px 0 4px;
}

.question-table-wrap {
  overflow: auto;
  border: 1px solid #dbe5f4;
  border-radius: 14px;
  margin-top: 12px;
}

.question-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  font-size: .88rem;
}

.question-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8fc;
  color: #475569;
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .03em;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #dbe5f4;
}

.question-table td {
  padding: 7px 6px;
  border-bottom: 1px solid #e8eef8;
  vertical-align: middle;
}

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

.col-num {
  width: 42px;
  text-align: center;
  color: #475569;
  font-weight: 900;
}

.col-actions {
  width: 88px;
  text-align: center;
  white-space: nowrap;
}

.compact-input {
  width: 100%;
  min-width: 130px;
  margin: 0 !important;
  padding: 8px 10px !important;
  border-radius: 8px !important;
  font-size: .88rem !important;
  background: #f7f9fd !important;
}

.question-input {
  min-width: 260px;
  resize: vertical;
  line-height: 1.25;
  min-height: 38px;
  max-height: 80px;
}

.good-input {
  border-color: #047857 !important;
  background: #ecfdf5 !important;
}

.wrong-input {
  border-color: #ff6b6b !important;
  background: #fff7f7 !important;
}

.icon-btn {
  border: 0;
  background: transparent;
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  background: #eef3ff;
}

.danger-icon:hover {
  background: #fee2e2;
}

/* ===== Bandeau accueil ===== */
.home-banner {
  background: #1e3a8a;
  color: white;
  border-radius: 18px;
  padding: 16px 24px;
  box-shadow: 0 8px 24px rgba(30, 58, 138, .25);
}

.home-banner-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.home-banner h1 {
  margin: 0;
  font-size: 1.6rem;
  color: white;
}

.home-banner p {
  margin: 4px 0 0;
  color: white;
}

.home-banner-actions {
  display: flex;
  gap: 10px;
}

.home-banner .btn {
  background: white;
  color: #2563eb;
}

/* ===== Modales ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .58);
  backdrop-filter: blur(4px);
}

.modal-content {
  width: min(800px, 90%);
  max-height: 80vh;
  overflow-y: auto;
  background: white;
  border-radius: 24px;
  padding: 26px;
  text-align: left;
  box-shadow: 0 28px 70px rgba(15, 23, 42, .35);
}

.warning-modal {
  width: min(460px, 100%);
  text-align: center;
}

.modal-content h2 {
  margin-top: 0;
}

.modal-content h3 {
  margin-top: 20px;
  margin-bottom: 8px;
  color: #2563eb;
}

.modal-content ul,
.modal-content ol {
  padding-left: 20px;
}

.modal-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fef3c7;
  font-size: 2rem;
}

.warning-modal h2 {
  margin: 0 0 8px;
}

.warning-modal p {
  margin: 0;
  color: #475569;
  line-height: 1.45;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.strong-danger {
  background: #dc2626 !important;
  color: white !important;
}

.help-tip {
  margin-top: 16px;
  padding: 12px;
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
}

/* ===== Aperçu élève dans la modale prof ===== */
.preview-modal-content {
  max-width: 720px;
  width: min(94vw, 720px);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.student-preview-card {
  background: var(--card-bg, #ffffff);
  border-radius: 24px;
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.student-preview-card .answers {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.student-preview-card .answerBtn {
  width: 100%;
  text-align: center;
}

.correct-preview {
  background: #d1fae5 !important;
  border: 2px solid #047857 !important;
  color: #065f46 !important;
  font-weight: 700;
}

/* ===== 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;
}

/* ===== Élève ===== */
.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: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.3rem;
  gap: 10px;
}

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

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

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

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

/* ===== Pied de page ===== */
.site-footer {
  margin-top: auto;
  padding: 18px;
  text-align: center;
  font-size: .9rem;
  color: #475569;
  border-top: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(8px);
}

.site-footer p {
  margin: 0 0 6px;
}

.site-footer small {
  display: block;
  color: #475569;
}

.site-footer a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 700;
  transition: color .2s ease;
}

.site-footer a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
  transition: transform .2s ease;
}

.footer-avatar:hover {
  transform: scale(1.08);
}

.footer-links p {
  margin: 0;
}

@media(max-width:760px) {
  .bank-toolbar {
    align-items: flex-start;
  }

  .bank-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .question-table {
    font-size: .82rem;
  }

  .compact-input {
    font-size: .82rem !important;
  }

  .question-input {
    min-width: 210px;
  }
}

@media(max-width:700px) {
  .home-banner-content {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media(max-width:640px) {

  header,
  .app {
    padding: 12px;
  }

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

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

  .modal-content {
    padding: 22px 18px;
  }

  .modal-buttons .btn {
    width: 100%;
  }
}

.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;
  margin-bottom: 1rem;
}

.waiting-room-layout .hero {
  flex: 0 0 380px;
}

.students-panel {
  flex: 1;
}

.students-panel .cards {
  max-height: 350px;
  overflow-y: auto;
}
/* ===== Génération IA CollabQuiz ===== */
.ai-preview-modal-content {
  max-width: 900px;
  width: min(94vw, 900px);
}

.ai-preview-list {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.ai-question-preview {
  border: 1px solid #dbe5f4;
  border-radius: 18px;
  padding: 16px;
  background: #f8fafc;
}

.ai-question-preview h3 {
  margin-top: 0;
  color: #2563eb;
}

.ai-question-text {
  font-weight: 800;
  margin: 8px 0 12px;
}

.ai-answer-list {
  display: grid;
  gap: 8px;
}

.ai-answer-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbe5f4;
  border-radius: 12px;
  background: white;
  font-weight: 700;
  cursor: pointer;
}

.ai-answer-choice input {
  width: auto;
  margin: 0;
}

.ai-answer-good {
  border-color: #047857;
  background: #ecfdf5;
  color: #065f46;
}

.ai-insert-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 18px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
}

.ai-insert-box h3 {
  margin-top: 0;
}

/* ===== Modale IA éditable ===== */
.ai-question-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ai-edit-question {
  min-height: 64px;
  resize: vertical;
  font-weight: 700;
  background: white;
}

.ai-answer-choice .ai-edit-answer {
  flex: 1;
  margin: 0;
  border: 0;
  background: transparent;
  font-weight: 700;
  padding: 6px 4px;
}

.ai-answer-choice .ai-edit-answer:focus {
  outline: 2px solid #2563eb;
  border-radius: 8px;
  background: white;
}

.ai-answer-good .ai-edit-answer {
  color: #065f46;
}

/* ===== IA / import : disposition formulaire ===== */
.import-grid,
.ai-generation-grid {
  align-items: end;
}

.ai-generation-grid {
  margin-top: 4px;
}

/* ===== Surbrillance question ajoutée ===== */
.question-table tr.question-row-highlight td {
  animation: questionRowFlash 1.8s ease;
}

@keyframes questionRowFlash {
  0%, 70% {
    background: #fef3c7;
  }
  100% {
    background: transparent;
  }
}


/* ===== Statut génération IA ===== */
.ai-status {
  margin: 6px 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 700;
  text-align: left;
}
