:root {
  /* Quest 2.0 — habillage clair chaud aux couleurs iMédias (repris de SASIQuest 2.0) */
  --safety-yellow: #d42a1c;   /* accent principal (nom conservé pour compatibilité) */
  --accent-dark: #a81e12;
  --on-accent: #ffffff;
  --gold: #bf831a;
  --teal: #3f7a8a;
  --dark: #faf7f6;            /* fond */
  --dark-2: #f1ebe8;          /* champs, pistes, onglets inactifs */
  --card: #ffffff;
  --text: #1b1614;
  --muted: #6b625c;
  --line: #e4d9d4;
  --line-2: #cbbdb6;
  --success: #2e8b57;
  --ok-soft: #e4f3ea;
  --danger: #c62828;
  --ko: #c62828;
  --ko-soft: #fbe5e2;
  --flag: #e07b00;
  --accent-soft: #fbe9e6;
  --info: #2f6676;
  --info-soft: #e3eff2;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--dark);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--dark);
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ---------- Onboarding ---------- */
.onboarding {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.lang-toggle-top { text-align: right; }
.lang-toggle-top button {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 13px;
}
.onboarding h1 { font-size: 28px; margin: 8px 0 0; }
.tagline { color: var(--safety-yellow); font-weight: 600; margin: 0; }
.program-title { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.field-label { text-align: left; font-size: 13px; color: var(--muted); margin-top: 12px; }
#nameInput, #classCodeInput {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--dark-2);
  color: var(--text);
  font-size: 16px;
}
.totem-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--safety-yellow);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.totem-emoji { font-size: 42px; line-height: 1; }
.totem-name { font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 600; color: var(--text); margin-top: 8px; }
.totem-name b { color: var(--safety-yellow); font-weight: 600; }
.totem-hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.totem-reroll {
  margin-top: 12px;
  width: 100%;
  background: var(--dark-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
}
.share-toggle {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}
.share-toggle .tog {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--line); flex-shrink: 0; position: relative; transition: background .18s;
}
.share-toggle .tog::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .18s;
}
.share-toggle.on .tog { background: var(--safety-yellow); }
.share-toggle.on .tog::after { left: 21px; }
.share-lbl b { font-size: 14px; color: var(--text); }
.share-lbl small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.35; }
.share-status { font-size: 12.5px; color: var(--muted); margin-top: 12px; text-align: center; }
.share-status.on { color: var(--safety-yellow); }
.access-gate { justify-content: center; }
#accessCodeInput {
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line-2);
  background: var(--dark-2);
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
}
#accessCodeInput:focus {
  outline: none;
  border-color: var(--safety-yellow);
}
.access-error {
  color: var(--ko);
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
}
.welcome-screen { text-align: left; }
.welcome-screen .lang-toggle-top,
.welcome-screen h1,
.welcome-screen .tagline { text-align: center; }
.welcome-intro {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin: 0 0 6px;
}
.welcome-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.welcome-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.welcome-icon { font-size: 24px; line-height: 1; }
.welcome-item-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.welcome-item-desc { font-size: 13px; color: var(--muted); line-height: 1.35; }
.avatar-char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.avatar-char-btn {
  background: var(--dark-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.avatar-char-btn svg { border-radius: 50%; }
.avatar-char-btn span { font-size: 10px; color: var(--muted); line-height: 1.2; text-align: center; }
.avatar-char-btn.selected { border-color: var(--safety-yellow); }
.avatar-char-btn.selected span { color: var(--text); font-weight: 600; }

.color-picker { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.color-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
}
.color-swatch.selected { border-color: white; }

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.vehicle-btn {
  background: var(--dark-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.vehicle-btn.selected { border-color: var(--safety-yellow); }
.vehicle-btn span { font-size: 11px; color: var(--muted); }
.vehicle-btn.selected span { color: var(--text); font-weight: 600; }

.vehicle-showcase {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.vehicle-frame {
  height: 190px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: visible;
}
.vehicle-caption { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.cta {
  margin-top: 20px;
  background: var(--safety-yellow);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 16px;
  padding: 16px;
  border-radius: var(--radius);
}
.secondary {
  margin-top: 10px;
  background: var(--card);
  color: var(--text);
  padding: 14px;
  border-radius: var(--radius);
}
.secondary.danger { color: var(--danger); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.avatar-chip {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-chip svg { display: block; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-level { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-btn {
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}
.reset-btn {
  background: var(--card);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
}
.tabs button {
  flex: 1;
  background: var(--dark-2);
  color: var(--muted);
  padding: 9px 3px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}
.tabs button.active {
  background: var(--safety-yellow);
  color: var(--on-accent);
  font-weight: 700;
}

.content { padding: 8px 16px 24px; }

/* ---------- Progress / Map ---------- */
.progress-banner { margin-bottom: 16px; }
.progress-bar {
  height: 10px;
  background: var(--dark-2);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--safety-yellow), var(--success));
}
.progress-label { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; }

.quest-path { display: flex; flex-direction: column; gap: 10px; }
.quest-node {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
}
.quest-node.done { border: 1px solid var(--success); }
.quest-node.locked { opacity: 0.45; }
.quest-node.premium-locked { opacity: 1; border: 1px dashed var(--muted); }
.quest-node.premium-locked .quest-node-main { cursor: pointer; }
.quest-premium-note { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.premium-overlay { position: fixed; inset: 0; background: rgba(27,22,20,0.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; }
.premium-dialog { background: var(--card); border-radius: var(--radius); padding: 22px; max-width: 340px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.premium-dialog h2 { font-size: 17px; margin: 8px 0; }
.premium-dialog p { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.premium-badge { font-size: 12px; font-weight: 700; color: var(--muted); }
.premium-dialog .cta { display: block; text-decoration: none; margin-bottom: 10px; }
.quest-node-main { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.quest-icon { font-size: 26px; width: 36px; text-align: center; }
.quest-body { flex: 1; }
.quest-num { font-size: 11px; color: var(--muted); }
.quest-title { font-size: 14px; font-weight: 600; }
.quest-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quest-status { font-size: 18px; }

/* ---------- Paliers de difficulté (Débutant / Intermédiaire / Avancé) ---------- */
.tier-row { display: flex; gap: 8px; }
.tier-pill {
  flex: 1;
  background: var(--dark-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  border: 2px solid transparent;
}
.tier-pill:disabled { opacity: 0.4; }
.tier-pill.done { border-color: var(--success); background: var(--ok-soft); }
.tier-pill.locked { opacity: 0.5; }
.tier-pill-icon { font-size: 15px; }
.tier-pill-name { font-weight: 600; }
.tier-pill-score { color: var(--safety-yellow); font-weight: 700; }
.quest-intro-tier {
  display: inline-block;
  background: var(--card);
  color: var(--safety-yellow);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  margin: 8px 0;
}

/* ---------- Quest intro / quiz ---------- */
.quest-intro { text-align: center; }
.quest-intro-icon { font-size: 48px; }
.quest-code { color: var(--muted); font-size: 13px; }
.best-score { color: var(--safety-yellow); font-weight: 700; }

.quiz-progress { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.quiz-question { font-size: 18px; line-height: 1.4; }
.scenario-badge {
  display: inline-block;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

/* ---------- Questions d'association de termes ("match") ---------- */
.match-prompt { color: var(--muted); font-size: 13px; margin: 12px 0 8px; }
.match-columns { display: flex; gap: 10px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.match-btn {
  background: var(--card);
  color: var(--text);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.3;
  border: 2px solid transparent;
  text-align: left;
  min-height: 44px;
}
.match-term.selected { border-color: var(--safety-yellow); background: var(--accent-soft); }
.match-btn.matched { border-color: var(--success); background: var(--ok-soft); opacity: 0.75; }
.match-btn.wrong { border-color: var(--danger); background: var(--ko-soft); animation: match-shake 0.35s; }
@keyframes match-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- Questions avec image de cabine ---------- */
.cabin-wrap {
  position: relative;
  margin: 12px 0 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #cfd6db;
  line-height: 0;
}
.cabin-svg { display: block; width: 100%; height: auto; }
.cabin-hotspots { position: absolute; inset: 0; }
.hotspot-dot {
  position: absolute;
  width: 15%;
  padding-top: 15%;
  height: 0;
  margin-left: -7.5%;
  margin-top: -7.5%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.001);
  border: 2px dashed rgba(27,22,20,0.35);
}
.hotspot-dot.selected {
  border: 3px solid var(--safety-yellow);
  background: rgba(212,42,28,0.18);
}
.hotspot-legend { margin-top: 4px; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice-btn {
  text-align: left;
  background: var(--card);
  color: var(--text);
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
  border: 2px solid transparent;
}
.choice-btn.selected {
  border-color: var(--safety-yellow);
  background: var(--accent-soft);
}

.tf-choices {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.tf-btn {
  flex: 1;
  background: var(--card);
  color: var(--text);
  padding: 22px 8px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  border: 2px solid transparent;
  text-align: center;
}
.tf-btn.selected {
  border-color: var(--safety-yellow);
  background: var(--accent-soft);
}
.quiz-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
.quiz-nav .cta:disabled { opacity: 0.4; }

.quest-result { text-align: center; position: relative; }
.result-icon { font-size: 52px; }
.result-icon.celebrate { animation: result-pop 0.6s ease; }
@keyframes result-pop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.result-score { font-size: 18px; font-weight: 700; }
.result-xp { color: var(--safety-yellow); font-weight: 700; }
.result-pass { color: var(--success); font-weight: 600; }
.result-fail { color: var(--danger); font-weight: 600; }
.result-mastery {
  color: var(--safety-yellow);
  font-weight: 800;
  font-size: 15px;
  animation: mastery-glow 1.2s ease-in-out infinite alternate;
}
@keyframes mastery-glow {
  from { text-shadow: 0 0 4px rgba(212,42,28,0.2); }
  to { text-shadow: 0 0 14px rgba(212,42,28,0.55); }
}

/* ---------- Confettis de célébration (paliers réussis) ---------- */
.confetti-burst {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.35, 0.55, 0.65, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(620px) rotate(560deg); opacity: 0; }
}

/* ---------- Badges / Trophies ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.badge-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.badge-card.locked { opacity: 0.4; }
.badge-icon { font-size: 30px; }
.badge-title { font-size: 12px; font-weight: 600; margin-top: 6px; }
.badge-desc { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ---------- Leaderboard ---------- */
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 8px 12px;
}
.leaderboard-row.you {
  border: 2px solid var(--safety-yellow);
  background: var(--accent-soft);
}
.lb-rank { width: 26px; text-align: center; font-weight: 700; font-size: 14px; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.lb-avatar svg { display: block; }
.lb-name { flex: 1; font-size: 13px; font-weight: 600; }
.lb-you-tag { color: var(--safety-yellow); font-weight: 700; font-size: 11px; }
.lb-xp { font-size: 12px; color: var(--muted); font-weight: 700; }
.leaderboard-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--safety-yellow);
  color: var(--on-accent);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ---------- Revue des erreurs ---------- */
.review {
  text-align: left;
  margin: 22px 0 8px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.review-title {
  font-size: 15px;
  color: var(--safety-yellow);
  margin: 0 0 14px;
}
.review-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.review-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  white-space: pre-line;
  line-height: 1.4;
}
.review-line {
  font-size: 13.5px;
  padding: 4px 0;
  line-height: 1.4;
}
.review-line.yours { color: var(--ko); }
.review-line.good { color: var(--success); font-weight: 600; }
.review-expl {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  line-height: 1.5;
}

/* ---------- Bandeau CFP (nom du centre rattaché au code de classe) ---------- */
.cfp-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-left: 3px solid var(--safety-yellow);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0 4px;
  text-align: left;
}
.cfp-banner .cfp-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
  background: #fff;
}
.cfp-banner .cfp-name {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}
.cfp-banner .cfp-prog {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.join-error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: center;
}

/* Loi 25 : pied de page discret vers la politique de confidentialité */
.privacy-footer{text-align:center;padding:14px 0 22px;}
.privacy-footer a{font-size:12px;color:var(--muted);text-decoration:none;opacity:.75;letter-spacing:.02em;}
.privacy-footer a:hover{opacity:1;text-decoration:underline;}
.privacy-footer a:hover{opacity:1;text-decoration:underline;}

/* ---------- Nom de l'application (en haut de chaque écran) ---------- */
.app-title {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--text);
  padding: 14px 16px 0;
}
.app-subtitle {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 16px 0;
  line-height: 1.3;
}
.app-title + .topbar, .app-subtitle + .topbar { padding-top: 8px; }

/* ---------- Messagerie enseignant → élève (messagerie.js) ----------
   Reprend les jetons de l'app (carte sombre, accent jaune). Aucun nouvel
   onglet : un bandeau sur la carte quand il y a du non lu, une pastille sur
   le bouton 👥, et l'historique depuis « Ma classe ». */
.reset-btn { position: relative; }
.msg-point {
  position: absolute; top: -7px; right: -8px;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); border: 2px solid var(--dark);
  color: #fff; font-size: 11px; font-weight: 800; line-height: 15px;
  text-align: center; box-sizing: border-box; pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.msg-banniere {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--safety-yellow); color: var(--on-accent);
  border-radius: var(--radius); padding: 13px 14px; margin: 0 0 14px;
  text-align: left; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.msg-banniere-ic { font-size: 24px; flex-shrink: 0; }
.msg-banniere-tx { flex: 1; min-width: 0; }
.msg-banniere-tx b { display: block; font-size: 15px; }
.msg-banniere-tx small { display: block; font-size: 12.5px; opacity: .8; margin-top: 1px; }
.msg-banniere-fl { font-size: 24px; font-weight: 700; flex-shrink: 0; }
.msg-ouvrir { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 14px; }
.msg-compte { background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 2px 8px; }
.msg-info { font-size: 13px; color: var(--muted); background: var(--dark-2); border-radius: var(--radius); padding: 11px 13px; margin: 10px 0 0; text-align: left; line-height: 1.45; }
.msg-ecran { text-align: left; }
.msg-ecran h1 { text-align: center; }
.msg-ecran .welcome-intro { text-align: center; }
.msg-liste { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.msg-vide { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }
.msg-carte { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px; min-width: 0; }
.msg-carte.nouveau { border-color: var(--safety-yellow); box-shadow: 0 0 0 1px var(--safety-yellow); }
.msg-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg-tete b { font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.msg-portee { font-size: 11px; color: var(--muted); background: var(--dark-2); border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.msg-date { font-size: 12px; color: var(--muted); margin-top: 3px; }
.msg-neuf { color: var(--safety-yellow); font-weight: 700; }
.msg-texte { margin: 10px 0 0; font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.msg-accuses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.msg-acc { min-width: 0; background: var(--dark-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 6px; font-size: 13px; font-weight: 600; line-height: 1.25; }
.msg-acc.on { background: var(--safety-yellow); color: var(--on-accent); border-color: var(--safety-yellow); font-weight: 700; }
.msg-etat { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 340px) { .msg-accuses { grid-template-columns: 1fr; } }

/* ============================================================
   SASIQuest 2.0 — nouveau look (fond clair chaud, rouge iMédias, or)
   ============================================================ */
.topbar {
  background: linear-gradient(135deg, var(--safety-yellow), var(--accent-dark));
  color: #fff; padding: 14px 16px 12px; margin: 0 0 12px;
  border-radius: 0 0 20px 20px; box-shadow: 0 6px 18px rgba(168,30,18,.25);
}
.topbar .brand-name { color: #fff; }
.topbar .brand-level { color: rgba(255,255,255,.85); }
.topbar .lang-btn, .topbar .reset-btn { background: rgba(255,255,255,.18); color: #fff; }
.topbar .avatar-chip { background: #fff; box-shadow: 0 0 0 3px var(--gold); }
.tabs button { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.tabs button.active { background: var(--text); border-color: var(--text); color: #fff; }
.quest-node, .rev-carte, .welcome-item, .totem-card, .msg-carte, .premium-dialog {
  box-shadow: 0 2px 10px rgba(27,22,20,.07);
}
.quest-node, .welcome-item { border: 1px solid var(--line); }
.quest-node.done { border-color: var(--success); }
.progress-fill { background: linear-gradient(90deg, var(--gold), var(--safety-yellow)); }
.tier-pill-score, .best-score { color: var(--gold); }
.cta { box-shadow: 0 4px 12px rgba(212,42,28,.28); }
.cta:active { background: var(--accent-dark); }
.secondary { border: 1px solid var(--line); }
.choice-btn:not(.selected), .tf-btn:not(.selected) { border-color: var(--line); }
.choice-btn, .tf-btn { box-shadow: 0 1px 4px rgba(27,22,20,.06); }
.tagline { color: var(--safety-yellow); }
.totem-name b { color: var(--gold); }
.color-swatch.selected { border-color: var(--text); }
/* Le nom de l'app fait partie de la bande rouge sur les écrans principaux */
.app-title:has(+ .app-subtitle + .topbar), .app-subtitle:has(+ .topbar) {
  background: var(--safety-yellow); color: #fff;
}
.app-title:has(+ .app-subtitle + .topbar) { padding-top: calc(14px + env(safe-area-inset-top)); margin-top: calc(-1 * env(safe-area-inset-top)); }
.app-title:has(+ .app-subtitle + .topbar)::after {
  content: "2.0"; margin-left: 8px; vertical-align: 3px;
  font-size: 11px; font-weight: 800; color: var(--text); background: var(--gold);
  border-radius: 8px; padding: 2px 7px;
}
.app-subtitle:has(+ .topbar) { color: rgba(255,255,255,.88); padding-bottom: 2px; }
.app-subtitle + .topbar { background: linear-gradient(180deg, var(--safety-yellow), var(--accent-dark)); }

/* ============================================================
   SASIQuest 2.0 — nouvelles formes
   Police arrondie, boutons en pilule, barre d'onglets en bas,
   parcours en ligne du temps, réponses avec pastille.
   ============================================================ */
:root { --radius: 20px; }
html, body, button, input, select, textarea {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- Boutons en pilule --- */
.cta {
  border-radius: 999px; padding: 17px 22px; letter-spacing: .2px;
  background: linear-gradient(180deg, #e0412f 0%, var(--safety-yellow) 55%, var(--accent-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 16px rgba(212,42,28,.30);
}
.cta:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 8px rgba(212,42,28,.25); }
.secondary {
  border-radius: 999px; background: transparent;
  border: 2px solid var(--text); color: var(--text); font-weight: 700;
}
.secondary.danger { border-color: var(--danger); }
.topbar .lang-btn, .topbar .reset-btn { border-radius: 999px; }

/* --- Réponses : pastille ronde à gauche --- */
.choice-btn, .tf-btn { border-radius: 18px; }
.choice-btn { position: relative; padding: 15px 16px 15px 50px; }
.choice-btn::before {
  content: ""; position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-2); background: #fff; box-sizing: border-box;
}
.choice-btn.selected::before {
  border-color: var(--safety-yellow); background: var(--safety-yellow);
  box-shadow: inset 0 0 0 4px #fff;
}
.choice-btn.selected, .tf-btn.selected { border-width: 2px; }

/* --- Onglets : barre fixe en bas, icône au-dessus du libellé --- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 50;
  width: 100%; max-width: 480px; margin: 0; gap: 0;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(27,22,20,.06);
}
.tabs button, .tabs button.active {
  background: transparent; border: none; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 4px; font-size: 10.5px; color: var(--muted); font-weight: 600;
  position: relative;
}
.tabs .tab-ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .6; transition: transform .15s; }
.tabs button.active { color: var(--safety-yellow); font-weight: 800; }
.tabs button.active .tab-ic { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }
.tabs button.active::before {
  content: ""; position: absolute; top: -6px; left: 28%; right: 28%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--safety-yellow);
}
#app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* --- Parcours en ligne du temps --- */
.quest-path { position: relative; gap: 14px; padding-left: 4px; }
.quest-path::before {
  content: ""; position: absolute; left: 38.5px; top: 20px; bottom: 20px; width: 3px;
  border-radius: 3px; background: repeating-linear-gradient(180deg, var(--line-2) 0 8px, transparent 8px 14px);
}
.quest-node { position: relative; border-radius: 20px; }
.quest-icon {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: var(--accent-soft); box-shadow: 0 0 0 4px #fff, 0 0 0 5px var(--line);
}
.quest-node.done .quest-icon { background: var(--ok-soft); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--success); }
.quest-node.locked .quest-icon, .quest-node.premium-locked .quest-icon { background: var(--dark-2); }
.quest-title { font-size: 15.5px; font-weight: 800; }

/* --- Paliers en pilules segmentées --- */
.tier-row { background: var(--dark-2); border-radius: 999px; padding: 4px; gap: 4px; }
.tier-pill { border-radius: 999px; background: transparent; padding: 7px 4px; }
.tier-pill:not(:disabled):not(.locked) { background: #fff; box-shadow: 0 1px 4px rgba(27,22,20,.10); }
.tier-pill.done { background: var(--ok-soft); border-color: transparent; }


/* --- Médaillon de l'avatar : fond chaud dégradé or --- */
.vehicle-showcase {
  background: radial-gradient(120% 90% at 50% 0%, #fff6e3 0%, #fbe9e6 60%, #fff 100%);
  border: 1px solid var(--line); border-radius: 24px;
}
.vehicle-caption { font-weight: 700; color: var(--text); }
.progress-bar { height: 12px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }

/* --- Bouton « Ma classe » explicite dans l'en-tête --- */
.classe-btn {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  background: #fff; color: var(--safety-yellow); font-weight: 800; font-size: 12.5px;
  padding: 7px 11px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.15); white-space: nowrap;
}
.classe-btn .classe-ic { font-size: 14px; line-height: 1; }
.classe-btn.on { background: var(--success); color: #fff; }
.classe-btn.on .classe-ic { font-weight: 900; }
.classe-btn .msg-point { position: absolute; top: -5px; right: -5px; }
.topbar-actions { gap: 6px; }
.topbar .brand-name { font-size: 14px; }

/* --- Interrupteur de partage : état écrit en toutes lettres, vert quand c'est oui --- */
.share-toggle { border: 2px solid var(--line-2); border-radius: 20px; padding: 16px; }
.share-toggle .tog { width: 54px; height: 32px; border-radius: 999px; background: var(--line-2); }
.share-toggle .tog::after { width: 26px; height: 26px; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.share-toggle.on .tog { background: var(--success); }
.share-toggle.on .tog::after { left: 25px; }
.share-toggle.on { border-color: var(--success); background: var(--ok-soft); }
.share-etat {
  display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 999px; margin-bottom: 4px;
  background: var(--dark-2); color: var(--muted);
}
.share-toggle.on .share-etat { background: var(--success); color: #fff; }
.share-status.on { color: var(--success); font-weight: 700; }
.share-lbl b { display: block; font-size: 15px; }
/* Bouton de partage sur sa propre ligne, pleine largeur, dans la bande rouge */
.topbar { flex-wrap: wrap; row-gap: 12px; }
.topbar .classe-btn {
  flex: 1 0 100%; justify-content: center; padding: 11px 14px; font-size: 14.5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
.topbar .classe-btn .classe-ic { font-size: 17px; }
.avatar-chip { overflow: visible; }

/* --- 2.0 : fenêtre « Licence requise » — tout empilé, pleine largeur --- */
.premium-dialog { border-radius: 26px; padding: 26px 22px 18px; max-width: 360px; display: flex; flex-direction: column; align-items: stretch; }
.premium-medaillon {
  width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  background: var(--accent-soft); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--gold);
}
.premium-badge { text-transform: uppercase; letter-spacing: .8px; font-size: 11px; font-weight: 800; color: var(--safety-yellow); }
.premium-dialog h2 { font-size: 20px; line-height: 1.25; margin: 6px 0 8px; }
.premium-dialog p { margin: 0 0 18px; line-height: 1.45; }
.premium-label { text-align: left; margin: 0 0 6px 4px; font-weight: 700; color: var(--text); }
.premium-code {
  width: 100%; box-sizing: border-box; padding: 15px 16px; border-radius: 16px;
  border: 2px solid var(--line-2); background: #fff; color: var(--text);
  font-size: 18px; font-weight: 800; letter-spacing: 2px; text-align: center; text-transform: uppercase;
}
.premium-code:focus { outline: none; border-color: var(--safety-yellow); box-shadow: 0 0 0 4px var(--accent-soft); }
.premium-code::placeholder { color: var(--line-2); letter-spacing: 1px; font-weight: 700; }
.premium-dialog .cta { display: block; width: 100%; margin: 12px 0 0; }
.premium-dialog .access-error { margin: 10px 0 0; }
.premium-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px !important; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.premium-or::before, .premium-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.premium-dialog .premium-ecrire {
  display: block; width: 100%; box-sizing: border-box; margin: 0; text-align: center;
  text-decoration: none; font-weight: 800; padding: 13px 16px;
}
.premium-fermer {
  background: none; color: var(--muted); font-weight: 700; font-size: 14px;
  padding: 12px; margin-top: 6px; text-decoration: underline; text-underline-offset: 3px;
}


/* ---------- Nouveaux Quest iMédias en 2.0 — éléments du moteur MusculoQuest absents du style SASI 2.0 ---------- */
.avatar-triumph-wrap { position: relative; display: inline-flex; }
.avatar-triumph-wrap--maxed > span { animation: triumphPose 3.2s ease-in-out infinite; transform-origin: center bottom; }
@keyframes triumphPose {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.06) rotate(-2deg); }
}
.triumph-crown {
  position: absolute; top: -16px; right: -8px;
  font-size: 34px; transform: rotate(18deg);
  animation: triumphCrownBounce 2.2s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.45));
}
@keyframes triumphCrownBounce {
  0%, 100% { transform: rotate(18deg) translateY(0); }
  50%      { transform: rotate(18deg) translateY(-4px); }
}
.triumph-sparkle { position: absolute; font-size: 18px; opacity: .9; animation: triumphSparkle 1.8s ease-in-out infinite; }
.triumph-sparkle-1 { top: 6px; left: -16px; animation-delay: .3s; }
.triumph-sparkle-2 { bottom: 14px; right: -14px; animation-delay: .9s; }
@keyframes triumphSparkle {
  0%, 100% { opacity: .35; transform: scale(.75); }
  50%      { opacity: 1; transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar-triumph-wrap--maxed > span, .triumph-crown, .triumph-sparkle { animation: none; }
/* La couronne de l'étape légendaire est déjà sur l'avatar 3D : pas de 2e couronne. */
.triumph-crown { display: none; }
.tier-pill-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 142px;
  white-space: nowrap;
  font-size: 12px;
}
.tier-pill-icon { font-size: 16px; }
.tier-pill-name { font-weight: 700; }
.tier-pill-score { color: var(--safety-yellow); font-weight: 700; }
.tier-pill-count { color: var(--muted); font-size: 10px; font-weight: 600; }
/* Thème du palier : donne de la substance à une carte qui ne compte
   qu'un seul nœud de quête (app à une seule compétence). */
.tier-pill-theme {
  flex: 1;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}
.quest-intro-theme { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.tier-row .tier-pill { flex: 1; width: auto; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 8px 4px; }
.tier-row .tier-pill-head { flex: none; flex-direction: column; gap: 2px; white-space: normal; font-size: 11px; }
.tier-row .tier-pill-theme { display: none; }

