:root {
  --bg: #08090c;
  --panel: #10131a;
  --panel-2: #161a23;
  --line: #232936;
  --line-soft: #1a1f2a;
  --text: #e9edf5;
  --muted: #8b94a7;
  --lime: #b8ff3c;
  --lime-dim: #7fae2a;
  --violet: #8b6cff;
  --red: #ff5c7a;
  --amber: #ffc247;
  --radius: 18px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}
.glow-a {
  top: -25vmax;
  right: -20vmax;
  background: var(--violet);
}
.glow-b {
  bottom: -30vmax;
  left: -25vmax;
  background: var(--lime);
}

a {
  color: var(--lime);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(8, 9, 12, 0.78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  padding-left: max(clamp(16px, 4vw, 40px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 4vw, 40px), env(safe-area-inset-right));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand:hover {
  text-decoration: none;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 18px var(--lime);
}

.topbar nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
}
.topbar nav a {
  color: var(--muted);
}
.topbar nav a:hover {
  color: var(--text);
  text-decoration: none;
}

#app {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
}

.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fade 0.32s ease;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  max-width: 680px;
  margin: 3vh auto 0;
  text-align: center;
}

.kicker {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 18px 0 10px;
  /* padding-bottom : avec background-clip: text et ce line-height serré,
     le dégradé s'arrête avant la descente du « g » et du « Q » ; on étend
     la zone peinte vers le bas pour que la boucle du « g » reste visible. */
  padding-bottom: 0.14em;
  font-size: clamp(22px, 9vw, 70px);
  line-height: 1.02;
  white-space: nowrap;
  letter-spacing: -0.045em;
  font-weight: 900;
  background: linear-gradient(100deg, #fff 20%, var(--lime) 60%, var(--violet) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  margin: 0 auto 26px;
  max-width: 54ch;
  color: var(--muted);
  font-size: clamp(15px, 2.4vw, 18px);
}

h2 {
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
h3 {
  margin: 0 0 14px;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.card {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 26px);
  margin-bottom: 18px;
  box-shadow: 0 22px 50px -30px rgba(0, 0, 0, 0.9);
}
.card.narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* Login admin : la ligne input/bouton reste centrée dans l'encadré
   (on ne réserve la place du message d'erreur que s'il existe) */
#admin-error:empty {
  display: none;
}

/* Écran de connexion admin : centré verticalement tant qu'on n'est pas connecté */
#screen-admin.active.login-mode {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#screen-admin.active.login-mode .page-head {
  text-align: center;
  margin-bottom: 26px;
}
#screen-admin.active.login-mode #admin-error {
  text-align: center;
}

.start-card {
  text-align: left;
}

.instructions {
  text-align: left;
  margin-top: 36px;
}
.instructions h2 {
  font-size: 18px;
  margin-bottom: 10px;
}
.instruction-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.instruction-list strong {
  color: var(--text);
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.row {
  display: flex;
  gap: 10px;
}
.row input {
  flex: 1;
}

input,
textarea {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: #0b0e14;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder,
textarea::placeholder {
  color: #5d667a;
}
input:focus,
textarea:focus {
  border-color: var(--lime-dim);
  box-shadow: 0 0 0 3px rgba(184, 255, 60, 0.1);
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s, opacity 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--lime);
  color: #0a0d06;
  box-shadow: 0 10px 30px -14px var(--lime);
}
.btn.primary:hover {
  background: #c8ff69;
}
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn.ghost:hover {
  border-color: var(--muted);
}
.btn.small {
  padding: 8px 12px;
  font-size: 13px;
}
.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--red) 45%, transparent);
  color: var(--red);
}
.btn.danger:hover {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 10%, transparent);
}
.admin-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.note {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.note strong {
  color: var(--text);
}

.meta {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #6f788c;
  font-family: var(--mono);
}

.links {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 22px;
  font-size: 14px;
}

.error {
  color: var(--red);
  font-size: 13.5px;
  min-height: 20px;
  margin: 10px 0 0;
}

.muted {
  color: var(--muted);
}

.page-head {
  margin-bottom: 20px;
}

.quiz-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.counter {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.sub {
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.q-timer {
  text-align: right;
}
.q-timer span {
  display: block;
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--lime);
  line-height: 1;
  letter-spacing: -0.03em;
}
.q-timer small {
  font-size: 11px;
  color: var(--muted);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #141821;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.progress > div {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--lime));
  transition: width 0.35s ease;
}

.question-card {
  margin-top: 18px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.pill {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(184, 255, 60, 0.1);
  color: var(--lime);
  border: 1px solid rgba(184, 255, 60, 0.25);
}
.pill.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.prompt {
  font-size: clamp(18px, 2.6vw, 22px);
  line-height: 1.45;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
  white-space: pre-wrap;
}

.hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.center-actions {
  justify-content: center;
  margin-top: 24px;
}

.quiz-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--muted);
}
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover {
  color: var(--text);
}

.center {
  text-align: center;
  padding-top: 36px;
  padding-bottom: 36px;
}

.spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--lime);
  border-right-color: var(--violet);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#grading-text {
  font-family: var(--mono);
  font-size: 14px;
}
#screen-grading .progress {
  margin-top: 18px;
}

.result-hero {
  text-align: center;
  padding-top: 32px;
  padding-bottom: 28px;
}
.iq {
  font-family: var(--mono);
  font-size: clamp(72px, 18vw, 132px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: var(--lime);
  text-shadow: 0 0 60px rgba(184, 255, 60, 0.35);
  margin: 8px 0 4px;
}
.iq-label {
  font-size: clamp(16px, 2.5vw, 20px);
  font-weight: 600;
  color: var(--text);
}
.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 26px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.stat {
  text-align: center;
}
.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 20px;
  color: var(--text);
}
.stat span {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.disclaimer {
  margin: 18px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.grid-2 .card {
  margin-bottom: 18px;
}

.bars {
  display: grid;
  gap: 14px;
}
.bar-row .bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.bar-row .bar-top span:last-child {
  font-family: var(--mono);
  color: var(--muted);
}
.bar {
  height: 7px;
  border-radius: 999px;
  background: #0b0e14;
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--lime));
}

.summary {
  display: grid;
  gap: 12px;
  font-size: 14px;
}
.summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line-soft);
}
.summary div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.summary span:first-child {
  color: var(--muted);
}
.summary span:last-child {
  font-family: var(--mono);
  text-align: right;
}

.qa-list {
  display: grid;
  gap: 10px;
}
details.qa {
  background: #0c0f15;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
}
details.qa[open] {
  border-color: var(--line);
}
details.qa > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
}
details.qa > summary::-webkit-details-marker {
  display: none;
}
details.qa > summary:hover {
  background: rgba(255, 255, 255, 0.02);
}
.qa-score {
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(184, 255, 60, 0.12);
  color: var(--lime);
  border: 1px solid rgba(184, 255, 60, 0.25);
  white-space: nowrap;
}
.qa-score.low {
  background: rgba(255, 92, 122, 0.1);
  color: var(--red);
  border-color: rgba(255, 92, 122, 0.3);
}
.qa-score.mid {
  background: rgba(255, 194, 71, 0.1);
  color: var(--amber);
  border-color: rgba(255, 194, 71, 0.3);
}
.qa-title {
  font-size: 14px;
  line-height: 1.45;
}
.qa-title small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 3px;
  letter-spacing: 0.02em;
}
.qa-body {
  padding: 0 15px 16px;
  font-size: 14px;
  display: grid;
  gap: 12px;
}
.qa-block {
  background: #080b10;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 11px 13px;
  white-space: pre-wrap;
}
.qa-block .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 5px;
}
.qa-block.answer {
  color: #cfd6e4;
}
.qa-feedback {
  color: var(--text);
}
.qa-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.qa-sub .good {
  color: var(--lime);
}
.qa-sub .bad {
  color: var(--red);
}
.rubric {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}

.table-card {
  padding: 0;
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
}
table.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.board th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.board td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}
table.board tr:last-child td {
  border-bottom: none;
}
table.board tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
table.board .rank {
  font-family: var(--mono);
  color: var(--muted);
  width: 44px;
}
table.board .pseudo-cell {
  font-weight: 700;
}
.lb-toggle {
  display: block;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--lime);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.lb-toggle:hover {
  color: var(--text);
}
table.board tbody tr.lb-appr-row:hover {
  background: transparent;
}
.lb-appr-row td {
  padding-top: 0;
  background: rgba(255, 255, 255, 0.015);
}
.lb-appr {
  display: grid;
  gap: 8px;
  max-width: 900px;
  padding: 2px 0 8px;
  font-size: 13px;
}
.lb-appr-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lb-appr p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.lb-appr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.lb-appr-grid div {
  display: grid;
  gap: 2px;
}
.lb-appr-grid span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.lb-appr-grid strong {
  font-weight: 500;
}
table.board .num {
  font-family: var(--mono);
}
table.board .qi-cell {
  color: var(--lime);
  font-weight: 700;
  font-family: var(--mono);
}
table.board tr.top1 .rank {
  color: var(--amber);
}
.rank-1 {
  color: var(--amber) !important;
  font-weight: 700;
}
.rank-2 {
  color: #cfd8e8 !important;
  font-weight: 700;
}
.rank-3 {
  color: #d59b6a !important;
  font-weight: 700;
}

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px max(clamp(16px, 4vw, 32px), env(safe-area-inset-left)) max(34px, env(safe-area-inset-bottom)) max(clamp(16px, 4vw, 32px), env(safe-area-inset-right));
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.toolbar h3 {
  margin: 0;
}
.search-input {
  width: 100%;
  max-width: 260px;
  padding: 9px 12px;
  font-size: 13px;
}

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

@media (max-width: 560px) {
  .topbar {
    padding: 12px 16px;
  }
  .start-card .row,
  .row {
    flex-direction: column;
  }
  .row .btn {
    width: 100%;
  }
  .quiz-head {
    align-items: center;
  }
  .q-timer span {
    font-size: 22px;
  }
  /* Classement (mobile) : 4 colonnes lisibles (#, joueur, score, QI),
     temps et date masqués — infos secondaires. */
  #screen-leaderboard table.board {
    font-size: 13px;
  }
  #screen-leaderboard table.board th,
  #screen-leaderboard table.board td {
    padding: 11px 8px;
  }
  #screen-leaderboard table.board th:nth-child(5),
  #screen-leaderboard table.board td:nth-child(5),
  #screen-leaderboard table.board th:nth-child(6),
  #screen-leaderboard table.board td:nth-child(6) {
    display: none;
  }
  #screen-leaderboard table.board .rank {
    width: 26px;
  }
  #screen-leaderboard table.board .num,
  #screen-leaderboard table.board .qi-cell {
    white-space: nowrap;
  }
  #screen-leaderboard .lb-appr-grid {
    grid-template-columns: 1fr;
  }
  /* Admin (mobile) : colonne Temps masquée, tableau scrollable. */
  #screen-admin table.board th:nth-child(6),
  #screen-admin table.board td:nth-child(6) {
    display: none;
  }
  .actions .btn {
    flex: 1;
  }
  .quiz-foot {
    flex-direction: column;
    align-items: center;
  }
}
