/* Math Rocket — thème « conquête spatiale » : ciel sombre, couleurs vives, formes rondes. */

:root {
  --sky-1: #0b1033;
  --sky-2: #1b1f5e;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f4f6fb;
  --muted: #b9c1e0;
  --accent: #ffd23f;
  --accent-text: #1b1f3a;
  --ok: #3ddc97;
  --ok-text: #08281b;
  --fix: #ffb347;
  --miss: #ff8a80;
  --dot-a: #4cc9f0;
  --dot-b: #ff9f1c;
  --radius: 22px;
  --tap: 56px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 120%, var(--sky-2), var(--sky-1) 70%) fixed;
  background-color: var(--sky-1);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

/* Étoiles dessinées en CSS (aucune image) */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 28% 72%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 34%, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 63% 12%, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 78% 58%, #cfe8ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 26%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 88%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 54% 90%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 8%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 84%, #fff 50%, transparent 51%);
  opacity: 0.8;
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle { to { opacity: 0.45; } }

.app {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen { display: flex; flex-direction: column; gap: 16px; min-height: calc(100dvh - 40px); }

h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: 0 0 12px; line-height: 1.15; }

.center { text-align: center; }
.lead { font-size: 1.2rem; color: var(--muted); margin: 8px 0; }
.hint { color: var(--muted); font-size: 0.95rem; margin: 6px 0 14px; }
.error { color: var(--miss); min-height: 1.4em; margin: 8px 0; font-weight: 600; }
.error:empty { min-height: 0; margin: 0; }
.noscript { text-align: center; padding: 40px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 18px;
}

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 22px;
  border: 2px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: #ffdd66; }
.btn-big { font-size: 1.4rem; min-height: 68px; padding: 14px 36px; }
.btn-small { min-height: 48px; padding: 8px 16px; font-size: 0.95rem; }
.btn-icon { width: 48px; padding: 0; flex: none; }

.link { color: var(--accent); font-weight: 700; font-size: 1.1rem; display: inline-block; padding: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* --- Logo --- */
.hero { text-align: center; padding-top: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-size: clamp(2rem, 9vw, 2.8rem); font-weight: 800; letter-spacing: -0.5px; }
.logo b { color: var(--accent); }
.logo-rocket { width: 52px; height: 80px; transform: rotate(20deg); }
.tagline { color: var(--muted); margin: 4px 0 0; }

.rocket { display: block; }
.flame { transform-origin: 50% 70%; animation: flicker 0.25s ease-in-out infinite alternate; }
@keyframes flicker { to { transform: scaleY(0.75); opacity: 0.85; } }

/* --- Qui joue ? --- */
.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  min-height: 150px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--panel-border);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.2s;
}
.player:hover, .player:focus-visible { transform: translateY(-3px); border-color: var(--accent); }
.player .rocket { width: 52px; height: 82px; }
.player-name { font-weight: 800; font-size: 1.15rem; text-align: center; overflow-wrap: anywhere; }
.player-new { border-style: dashed; justify-content: center; }
.plus { font-size: 2.6rem; line-height: 1; color: var(--accent); font-weight: 800; }

/* --- Formulaires --- */
.form label, .form .label { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type="text"] {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: 16px;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
}
input[type="text"]:focus { border-color: var(--accent); outline: none; }
#code { text-transform: uppercase; letter-spacing: 2px; text-align: center; }

.preview { display: flex; justify-content: center; margin: 4px 0 8px; }
.preview .rocket { width: 70px; height: 110px; }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 4px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}
.swatch[aria-pressed="true"] { border-color: var(--text); transform: scale(1.1); }
.swatch-rouge { background: #ff5a5f; }
.swatch-orange { background: #ff9f1c; }
.swatch-jaune { background: #ffd23f; }
.swatch-vert { background: #3ddc97; }
.swatch-bleu { background: #4cc9f0; }
.swatch-violet { background: #b388ff; }

/* --- Accueil profil --- */
.topbar { display: flex; align-items: center; gap: 12px; }
.home { padding-top: 28px; }
.home-rocket { display: flex; justify-content: center; }
.home-rocket .rocket { width: 110px; height: 172px; }
.hover { animation: hover 2.4s ease-in-out infinite alternate; }
@keyframes hover { to { transform: translateY(-10px); } }
.player-title { font-size: clamp(2rem, 8vw, 2.6rem); margin: 10px 0 0; overflow-wrap: anywhere; }
.footnote { text-align: center; color: var(--muted); font-size: 0.95rem; margin-top: auto; }
.code { color: var(--text); letter-spacing: 1px; }

/* --- Réglages --- */
.group { border: 0; padding: 0; margin: 0 0 18px; }
.group legend { font-weight: 800; margin-bottom: 8px; font-size: 1.1rem; }
.choices-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 10px;
  border-radius: 18px;
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.choices-grade { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
.grade-report h3 { margin: 16px 0 8px; }
.grade-item { margin: 12px 0; }
.grade-line { margin: 0 0 6px; }
.grade-done { font-weight: 700; color: var(--ok); }
.choice-card[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 210, 63, 0.16); }
.choice-title { font-weight: 800; font-size: 1.1rem; }
.choice-sub { color: var(--muted); font-size: 0.9rem; }

/* --- Séance --- */
.mission { gap: 12px; }
.pips { list-style: none; display: flex; flex: 1; justify-content: center; gap: 6px; margin: 0; padding: 0; }
.pip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid transparent;
  transition: background 0.3s, transform 0.3s;
}
.pip.current { border-color: var(--accent); transform: scale(1.2); }
.pip.ok { background: var(--ok); }
.pip.miss { background: var(--fix); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 210px;
}
.question {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  font-size: clamp(2.8rem, 15vw, 4.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  padding: 0 0.2em;
  border-radius: 18px;
  border: 4px dashed rgba(255, 255, 255, 0.4);
  color: var(--muted);
}
.slot.typed { color: var(--text); border-style: solid; border-color: var(--accent); }
.slot.ok { background: var(--ok); border: 4px solid var(--ok); color: var(--ok-text); animation: pop 0.45s ease-out; }
.slot.fix { background: var(--fix); border: 4px solid var(--fix); color: var(--accent-text); }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) rotate(-4deg); }
  100% { transform: scale(1); }
}

.feedback { min-height: 64px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.cheer { font-size: 1.6rem; font-weight: 800; color: var(--ok); margin: 0; animation: rise 0.5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.correction { font-size: 1.4rem; font-weight: 800; color: var(--fix); margin: 0; }

.aid { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.aid-op { font-size: 1.6rem; font-weight: 800; }
.dots { display: flex; flex-wrap: wrap; gap: 5px; max-width: calc(5 * 18px + 4 * 5px); }
.dot { display: block; width: 18px; height: 18px; border-radius: 50%; }
.dot-a { background: var(--dot-a); }
.dot-b { background: var(--dot-b); }
.aid-col { flex-direction: column; gap: 4px; }
.aid-note { font-size: 0.9rem; color: var(--muted); }
/* Barre de 10 : cases pleines pour le nombre donné, cases vides pour le complément. */
.tenbar { display: grid; grid-template-columns: repeat(10, 22px); gap: 4px; padding: 6px; border: 2px solid var(--panel-border); border-radius: 10px; }
.tenbar .dot { width: 22px; height: 22px; border-radius: 5px; }
.tenbar .dot-b { background: transparent; border: 2px dashed var(--dot-b); }
/* Soustraction : rangées de 10, les points enlevés sont vides et barrés. */
.dots-take { max-width: calc(10 * 18px + 9 * 5px); }
.dot-taken { box-sizing: border-box; border: 2px dashed var(--dot-a); background: linear-gradient(45deg, transparent 38%, var(--fix) 38%, var(--fix) 62%, transparent 62%); }
@media (max-width: 380px) {
  .dots-take { max-width: calc(10 * 14px + 9 * 4px); gap: 4px; }
  .dots-take .dot { width: 14px; height: 14px; }
}
.dot-array { display: flex; flex-direction: column; gap: 3px; }
.dot-row { display: flex; gap: 3px; }
.dot-array .dot { width: 12px; height: 12px; }
@media (max-width: 380px) {
  .tenbar { grid-template-columns: repeat(10, 18px); }
  .tenbar .dot { width: 18px; height: 18px; }
}

.answer-zone { padding-bottom: 8px; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; }
.key, .choice {
  min-height: 64px;
  border-radius: 18px;
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 1.9rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s, background 0.2s;
}
.key:active, .choice:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.2); }
.key-erase { color: var(--miss); }
.key-ok { background: var(--ok); border-color: var(--ok); color: var(--ok-text); }

.choices { display: grid; gap: 12px; max-width: 420px; margin: 0 auto; }
.choices-3 { grid-template-columns: repeat(3, 1fr); }
.choices-5 { grid-template-columns: repeat(6, 1fr); }
.choices-5 .choice { grid-column: span 2; }
.choices-5 .choice:nth-child(4) { grid-column: 2 / span 2; }
.choice { min-height: 80px; font-size: 2.2rem; }
.choice.ok { background: var(--ok); border-color: var(--ok); color: var(--ok-text); }
.choice.miss { background: rgba(255, 179, 71, 0.25); border-color: var(--fix); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.ok):not(.miss) { opacity: 0.45; }

/* --- Fin de séance --- */
.end { padding-top: 10px; }
.launch { height: 180px; display: flex; justify-content: center; align-items: flex-end; overflow: hidden; }
.launch .rocket { width: 90px; height: 140px; }
.takeoff { animation: takeoff 2.2s cubic-bezier(0.5, 0, 0.75, 0) 0.4s both; }
@keyframes takeoff {
  0% { transform: translateY(0); }
  15% { transform: translateY(4px) rotate(1deg); }
  25% { transform: translateY(0) rotate(-1deg); }
  100% { transform: translateY(-260px); }
}
.score { font-size: 1.3rem; margin: 4px 0; }
.score b { font-size: 2.4rem; color: var(--accent); }
.stars { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; padding: 0; margin: 8px 0; }
.star { font-size: 1.8rem; color: rgba(255, 255, 255, 0.2); }
.star.on { color: var(--accent); }

.mastered { margin: 6px 0; }
.mastered p { margin: 0 0 6px; font-weight: 700; color: var(--ok); }
.fact-chips { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0; margin: 0; }
.fact-chips li { background: rgba(61, 220, 151, 0.18); border: 2px solid var(--ok); border-radius: 999px; padding: 4px 14px; font-weight: 800; }

/* --- Accueil : progression et accès parent --- */
.mastered-count { margin: 0; font-weight: 700; color: var(--accent); }
.link-quiet { color: var(--muted); text-decoration: none; display: inline-block; padding: 12px; min-height: 48px; }
.link-quiet:hover { color: var(--text); }

/* --- Espace parent --- */
.parent h1 { margin: 0; }
.parent h2 { font-size: 1.25rem; margin: 0 0 12px; }
.parent h3 { font-size: 1.05rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: 400; }
.gate-question { font-size: 2.6rem; font-weight: 800; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.form.center input { text-align: center; max-width: 200px; }

.stack-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.1); }
.stack-bar span { display: block; height: 100%; }
.counts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 14px; color: var(--muted); }
.counts b { color: var(--text); }

/* Couleurs des états de faits (carte de chaleur, barre, légende) */
.s-new { background: rgba(255, 255, 255, 0.1); }
.s-learning { background: #c2553f; }
.s-learning.s-l1 { background: #f08a3e; }
.s-learning.s-l2 { background: #f5c842; }
.s-mastered { background: var(--ok); }
.stack-bar .s-learning { background: #f08a3e; }

.heatmap-wrap { overflow-x: auto; }
.heatmap { border-collapse: separate; border-spacing: 3px; margin: 0 auto; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.heatmap th { color: var(--muted); font-weight: 700; width: 24px; height: 24px; text-align: center; }
.heatmap td.cell { width: 24px; height: 24px; border-radius: 5px; }
.heatmap td.cell.due { outline: 2px solid var(--accent); outline-offset: -2px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 12px 0 0; font-size: 0.9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .cell { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }

.table-wrap { overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.history th, .history td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
.history th { color: var(--muted); font-weight: 700; }

.choices-slow { grid-template-columns: repeat(4, 1fr); }
.big-code { font-size: 1.8rem; font-weight: 800; letter-spacing: 2px; margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { font-size: 0.95rem; }
.actions-left { justify-content: flex-start; }
.btn-danger { border-color: var(--miss); color: var(--miss); }
.form .label, .parent .label { display: block; font-weight: 700; margin: 12px 0 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Fusée en construction --- */
.spacer { flex: 1; }
.ship { height: clamp(120px, 22vh, 190px); display: flex; justify-content: center; }
.rocket-build { height: 100%; width: auto; overflow: visible; }
.rocket-build .flame { display: none; }
.piece { transform-box: fill-box; transform-origin: center; }
.piece:not(.on) * { fill: rgba(255, 255, 255, 0.05); stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.4; stroke-dasharray: 3 3; }
.piece.new { animation: snap 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes snap {
  0% { transform: scale(0.2) translateY(-30px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

/* --- Décollage --- */
.launch-scene {
  position: relative;
  min-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.countdown { font-size: clamp(4rem, 22vw, 7rem); font-weight: 800; color: var(--accent); margin: 0; min-height: 1.2em; text-align: center; line-height: 1.2; }
.countdown.beat { animation: beat 0.7s ease-out; }
@keyframes beat { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }
.launchpad { display: flex; flex-direction: column; align-items: center; }
.launchpad .rocket-build { height: 220px; }
.ground { display: block; width: 200px; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); margin-top: -46px; }
.launching .piece:not(.on) { display: none; }
.launching.liftoff .flame { display: block; transform-box: fill-box; transform-origin: top; animation: flicker 0.15s ease-in-out infinite alternate; }
.liftoff { animation: liftoff 1.9s cubic-bezier(0.55, 0, 0.8, 0.2) forwards; }
@keyframes liftoff {
  0% { transform: translate(0, 0); }
  8% { transform: translate(-2px, 2px); }
  16% { transform: translate(2px, 0); }
  24% { transform: translate(-1px, 1px); }
  100% { transform: translate(0, -110vh); }
}
.skip { position: absolute; bottom: 16px; right: 0; }

/* --- Arrivée sur un astre --- */
.arrival { margin-bottom: 8px; }
.arrival-planet { width: 140px; height: 140px; animation: arrive 0.9s cubic-bezier(0.3, 1.4, 0.5, 1); filter: drop-shadow(0 0 24px rgba(255, 210, 63, 0.35)); }
@keyframes arrive { from { transform: scale(0.1) rotate(-90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.arrival-title { font-size: 1.6rem; font-weight: 800; color: var(--accent); margin: 6px 0 0; }
.gained { font-weight: 700; color: var(--accent); margin: 14px 0 6px; }

/* --- Carte du voyage --- */
.journey { text-align: center; }
.journey-track { display: flex; align-items: center; gap: 8px; }
.journey-body { margin: 0; width: 72px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.85rem; font-weight: 700; }
.journey-body .planet { width: 56px; height: 56px; }
.journey-body.dim .planet { opacity: 0.45; filter: grayscale(0.6); }
.journey-path { position: relative; flex: 1; height: 10px; border-radius: 999px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0 6px, transparent 6px 12px); }
.journey-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); transition: width 1.6s ease-out; }
.journey-marker { position: absolute; top: 50%; transform: translate(-50%, -50%) rotate(90deg); transition: left 1.6s ease-out; }
.journey-rocket { display: block; width: 30px; height: 46px; }
.journey-next { margin: 10px 0 0; font-weight: 700; }
.collection { margin-top: 14px; }
.collection-title { margin: 0 0 6px; color: var(--muted); font-size: 0.9rem; }
.collection ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 0; margin: 0; }
.collection .planet { width: 34px; height: 34px; }
.end .journey { margin: 8px 0; padding: 14px 10px; border-radius: 18px; background: rgba(0, 0, 0, 0.18); }

/* Mouvements réduits : animations coupées, transitions instantanées */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 700px) {
  .app { padding-top: 32px; }
  .panel { padding: 28px; }
}

/* Lot 4 : mots dans la question (« double de »), choix des exercices et des tables. */
.question.q-long { font-size: clamp(2.2rem, 12vw, 4.6rem); }
/* Le mot passe sur sa propre ligne, au-dessus du calcul. */
.question:has(.q-word) { flex-wrap: wrap; row-gap: 0; }
.q-word { flex-basis: 100%; text-align: center; font-size: 0.45em; font-weight: 700; color: var(--muted); }
.table-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.table-toggle {
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
}
.table-toggle[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 210, 63, 0.22); }
.choice-card:disabled { opacity: 0.55; cursor: not-allowed; }
.module-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin-top: 8px; }
.module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 18px;
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  text-align: center;
}
.module-card .module-icon { font-size: 1.8rem; }
.module-card .module-name { font-weight: 800; }
.module-card .module-sub { font-size: 0.85rem; color: var(--muted); }
.module-card.current { border-color: var(--accent); }
.module-card.locked { opacity: 0.55; }
a.module-card:hover { border-color: var(--accent); }
.fact-cells { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.fact-cells .cell { width: auto; min-width: 34px; height: 26px; padding: 0 5px; font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.fact-level { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.module-progress + .module-progress { margin-top: 22px; }

/* Lot 5 : badges. */
.medal {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c9, var(--accent) 55%, #e0a400);
  box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.25), 0 4px 10px rgba(0, 0, 0, 0.35);
}
.medal-emoji { font-size: 2rem; line-height: 1; }
.medal-planet { width: 48px; height: 48px; }
.medal-locked { background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 2px var(--panel-border); }
.medal-locked > * { filter: grayscale(1); opacity: 0.35; }
.medal-small { width: 36px; height: 36px; box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.25); }
.medal-small .medal-emoji { font-size: 1.1rem; }
.medal-small .medal-planet { width: 28px; height: 28px; }

.badge-group { margin: 22px 0 10px; font-size: 1.15rem; }
.badge-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  text-align: center;
  border-radius: 18px;
  border: 2px solid rgba(255, 210, 63, 0.5);
  background: rgba(255, 210, 63, 0.08);
}
.badge-card.locked { border-color: var(--panel-border); background: rgba(255, 255, 255, 0.03); }
.badge-card.locked .badge-title { color: var(--muted); }
.badge-title { font-weight: 800; margin-top: 4px; }
.badge-desc { font-size: 0.85rem; color: var(--muted); }
.badge-date { font-size: 0.75rem; color: var(--accent); }

.badges-link { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.badges-link:hover { border-color: var(--accent); }
.badges-link-title { font-weight: 800; font-size: 1.15rem; }
.badges-latest { display: flex; gap: 6px; margin-left: auto; }
.badges-link .chevron { font-size: 1.8rem; color: var(--muted); margin-left: auto; }
.badges-latest + .chevron { margin-left: 0; }

.streak { font-weight: 800; color: var(--fix); margin: 0; }
.level-up { margin: 0; padding: 8px 14px; border-radius: 14px; font-weight: 800; color: var(--accent); background: rgba(255, 210, 63, 0.1); border: 2px solid rgba(255, 210, 63, 0.45); }
.placement-icon { font-size: 3rem; margin: 0; }
.new-badges { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; padding: 14px; border-radius: 18px; background: rgba(255, 210, 63, 0.1); border: 2px solid rgba(255, 210, 63, 0.45); }
.new-badges-title { margin: 0; font-size: 1.3rem; font-weight: 800; color: var(--accent); }
.new-badges-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.new-badge { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 150px; text-align: center; animation: medal-in 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes medal-in {
  from { opacity: 0; transform: scale(0.2) rotate(-20deg); }
  to { opacity: 1; transform: none; }
}

.badge-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 18px 10px 10px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--sky-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  animation: toast-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.badge-toast .medal { width: 48px; height: 48px; }
.badge-toast .medal-emoji { font-size: 1.5rem; }
.badge-toast .medal-planet { width: 36px; height: 36px; }
.badge-toast.leaving { opacity: 0; transition: opacity 0.25s; }
.toast-text { display: flex; flex-direction: column; min-width: 0; }
.toast-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-kicker { font-size: 0.8rem; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -30px) scale(0.8); }
  to { opacity: 1; transform: translateX(-50%); }
}

/* Lot 6 : QR code du profil. */
.qr-box { margin: 14px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr { width: min(220px, 70vw); height: auto; border-radius: 12px; }
.qr-box figcaption { text-align: center; max-width: 34ch; margin: 0; }
