/* ===================================================================
   MILA — thème "Magique / Féerie" ✨🦊
   Conçu pour tablette, enfant 8 ans. Couleurs vives, boutons brillants,
   animations douces, étoiles scintillantes.
   =================================================================== */

:root {
  --violet: #7b2ff7;
  --violet-d: #5b16c9;
  --rose: #ff5db1;
  --rose-d: #e23b95;
  --bleu: #38bdf8;
  --or: #ffd23f;
  --or-d: #f7a500;
  --menthe: #34e0a1;

  --maths: #ff5db1;     /* rose */
  --francais: #38bdf8;  /* bleu ciel */
  --monde: #34e0a1;     /* menthe */

  --ok: #34e0a1;
  --mid: #ffd23f;
  --low: #ff6b8a;
  --new: #b9a7e8;

  --text: #2a1a52;
  --text-soft: #7a6aa6;
  --card: rgba(255, 255, 255, 0.92);
  --glass: rgba(255, 255, 255, 0.14);

  --shadow: 0 10px 30px rgba(60, 20, 120, 0.22);
  --shadow-sm: 0 6px 16px rgba(60, 20, 120, 0.18);
  --radius: 26px;
  --font: 'Baloo 2', 'Fredoka', 'Segoe UI', system-ui, sans-serif;
  --font-title: 'Fredoka', 'Baloo 2', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
  background: linear-gradient(160deg, #2b1466 0%, #6a1fb0 38%, #b62a98 72%, #ff7eb3 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- Ciel magique ---------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.moon {
  position: absolute; top: 6%; right: 8%;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7d6, #ffe79a 60%, #ffd23f);
  box-shadow: 0 0 60px 18px rgba(255, 226, 140, 0.45);
  animation: floaty 7s ease-in-out infinite;
}
.stars { position: absolute; inset: 0; }
.star {
  position: absolute; border-radius: 50%;
  background: #fff;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  opacity: .8;
}
@keyframes twinkle {
  0%, 100% { opacity: .15; transform: scale(.6); }
  50% { opacity: 1; transform: scale(1.1); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.wrap {
  position: relative; z-index: 1;
  max-width: 1000px; margin: 0 auto;
  padding: 14px clamp(12px, 4vw, 28px) 60px;
}

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0 18px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-title);
  font-size: 1.7rem; font-weight: 700; text-decoration: none; color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.brand .logo { font-size: 2rem; filter: drop-shadow(0 3px 6px rgba(0,0,0,.3)); animation: floaty 5s ease-in-out infinite; }
.brand-name { background: linear-gradient(90deg, #ffe79a, #ff9ed6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.topbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  background: var(--glass); color: #fff; backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 7px 16px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
}
.sound-toggle {
  width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.35);
  background: var(--glass); backdrop-filter: blur(6px); color: #fff; font-size: 1.3rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.sound-toggle:active { transform: scale(.88); }
.sound-toggle.muted { opacity: .55; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 18px; padding: 16px 28px;
  font-family: var(--font); font-size: 1.2rem; font-weight: 800; cursor: pointer;
  color: #fff; text-decoration: none; min-height: 58px;
  background: linear-gradient(180deg, #ff8ec7, var(--rose));
  box-shadow: 0 6px 0 var(--rose-d), 0 10px 22px rgba(226,59,149,.4);
  transition: transform .09s, box-shadow .09s, filter .12s;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-20deg); animation: shine 4s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 80%, 100% { left: 130%; } }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--rose-d), 0 4px 12px rgba(226,59,149,.4); }
.btn.secondary { background: linear-gradient(180deg, #fff, #f0e9ff); color: var(--violet-d); box-shadow: 0 6px 0 #cdbcf0, 0 10px 22px rgba(91,22,201,.25); }
.btn.secondary:active { box-shadow: 0 2px 0 #cdbcf0; }
.btn.ghost { background: var(--glass); backdrop-filter: blur(6px); box-shadow: none; color: #fff; border: 1.5px solid rgba(255,255,255,.35); padding: 12px 18px; min-height: 46px; }
.btn.ghost::after { display: none; }
.btn.big { font-size: 1.45rem; padding: 22px 44px; min-height: 74px; }
.btn:disabled { opacity: .45; cursor: default; filter: grayscale(.3); }
.btn:disabled::after { display: none; }

/* ---------- Accueil ---------- */
.hero { text-align: center; padding: 14px 0 24px; }
.hero h1 {
  font-family: var(--font-title); font-size: 2.4rem; margin: 4px 0 6px; color: #fff;
  text-shadow: 0 3px 14px rgba(0,0,0,.3);
}
.hero p { color: #ffe2f3; margin: 0 0 10px; font-weight: 600; }
.mascot { font-size: 4rem; filter: drop-shadow(0 6px 12px rgba(0,0,0,.35)); animation: floaty 4s ease-in-out infinite; }

.subjects {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-top: 8px;
}
.subject-card {
  background: var(--card); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 3px solid rgba(255,255,255,.6);
  position: relative;
}
.subject-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 10px;
  background: var(--francais);
}
.subject-card.maths::before { background: linear-gradient(90deg, #ff8ec7, var(--maths)); }
.subject-card.francais::before { background: linear-gradient(90deg, #7ad4ff, var(--francais)); }
.subject-card.monde::before { background: linear-gradient(90deg, #6ff0c2, var(--monde)); }
.subject-card .head {
  padding: 20px 20px 8px; display: flex; align-items: center; gap: 12px;
  font-family: var(--font-title); font-size: 1.5rem; font-weight: 700; color: var(--text);
}
.subject-card .head span:first-child { font-size: 1.8rem; }
.skill-list { padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 10px; }

.skill-item {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fbf6ff, #f1e9ff);
  border-radius: 18px; padding: 14px 16px; text-decoration: none; color: var(--text);
  font-weight: 700; min-height: 60px; border: 2.5px solid transparent;
  box-shadow: 0 3px 0 rgba(123,47,247,.12);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.skill-item:active { transform: scale(.97); }
.skill-item:hover { border-color: var(--violet); }
.skill-item .ic {
  font-size: 1.7rem; width: 48px; height: 48px; flex: 0 0 48px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 14px; box-shadow: 0 2px 8px rgba(123,47,247,.18);
}
.skill-item .meta { flex: 1; line-height: 1.15; }
.skill-item .meta .sub { font-size: .78rem; color: var(--text-soft); font-weight: 600; margin-top: 2px; }
.skill-item .status-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.7); }
.status-dot.new { background: var(--new); }
.status-dot.low { background: var(--low); }
.status-dot.mid { background: var(--mid); }
.status-dot.ok  { background: var(--ok); box-shadow: 0 0 0 3px rgba(255,255,255,.7), 0 0 10px var(--ok); }
.skill-item .stars { color: var(--or-d); font-size: 1rem; white-space: nowrap; letter-spacing: 1px; text-shadow: 0 1px 2px rgba(247,165,0,.3); }

/* ---------- Jeu ---------- */
.game-card {
  background: var(--card); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px; margin-top: 8px; border: 3px solid rgba(255,255,255,.6);
  animation: cardIn .4s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.game-meta {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-soft); font-weight: 700; margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.game-meta > span:first-child { color: var(--violet-d); }
.game-meta .tag { background: linear-gradient(180deg, #fff, #f1e9ff); color: var(--violet-d); padding: 7px 16px; border-radius: 999px; box-shadow: 0 2px 8px rgba(123,47,247,.15); }
.live-stars { font-size: 1.5rem; color: var(--or); letter-spacing: 2px; }
.live-stars .pop { display: inline-block; animation: starPop .5s cubic-bezier(.2,.9,.3,1.6); }
@keyframes starPop { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.5) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }

.question {
  font-family: var(--font-title); font-size: 1.7rem; font-weight: 700;
  margin: 6px 0 24px; line-height: 1.3; white-space: pre-line; color: var(--text);
}

.choices { display: grid; gap: 14px; }
.choice {
  background: linear-gradient(135deg, #fbf6ff, #efe7ff);
  border: 3px solid transparent; border-radius: 18px; padding: 18px 22px;
  font-size: 1.35rem; font-family: var(--font); font-weight: 700; cursor: pointer;
  text-align: left; color: var(--text); min-height: 60px;
  box-shadow: 0 4px 0 rgba(123,47,247,.14);
  transition: transform .1s, box-shadow .12s, border-color .12s, background .2s;
}
.choice:hover { border-color: var(--violet); }
.choice:active { transform: translateY(2px); }
.choice.selected { border-color: var(--violet); background: linear-gradient(135deg, #efe3ff, #e3d4ff); box-shadow: 0 4px 0 var(--violet-d); }
.choice.correct { border-color: var(--ok); background: linear-gradient(135deg, #d6fff0, #b8ffe4); box-shadow: 0 4px 0 #16a877; animation: goodPulse .5s; }
.choice.wrong   { border-color: var(--low); background: linear-gradient(135deg, #ffe0e8, #ffd0dc); box-shadow: 0 4px 0 #d34d6c; animation: shake .4s; }
.choice.disabled { pointer-events: none; }
@keyframes goodPulse { 0% { transform: scale(1); } 40% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

.answer-input {
  width: 100%; font-size: 1.6rem; font-family: var(--font); font-weight: 800;
  padding: 18px; border: 3px solid #d9c9ff; border-radius: 18px; text-align: center;
  color: var(--violet-d); background: #fbf6ff;
}
.answer-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(123,47,247,.18); }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-item {
  padding: 16px; border-radius: 16px; background: linear-gradient(135deg, #fbf6ff, #efe7ff);
  border: 3px solid transparent; font-weight: 700; cursor: pointer; min-height: 58px;
  text-align: center; box-shadow: 0 4px 0 rgba(123,47,247,.14); transition: transform .1s;
}
.match-item:active { transform: scale(.96); }
.match-item.selected { border-color: var(--violet); background: #e3d4ff; }
.match-item.matched { background: linear-gradient(135deg, #d6fff0, #b8ffe4); border-color: var(--ok); box-shadow: 0 4px 0 #16a877; animation: goodPulse .5s; }
.match-item.wrong { border-color: var(--low); animation: shake .4s; }

/* --- Mini-jeu Memory (cartes à retourner) --- */
.mem-hint { font-weight: 700; color: var(--text-soft); margin: -8px 0 16px; }
.mem-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.mem-card {
  position: relative; aspect-ratio: 1 / 1; border: none; background: transparent;
  cursor: pointer; perspective: 600px; padding: 0; font-family: var(--font);
}
.mem-inner {
  position: absolute; inset: 0; transition: transform .4s cubic-bezier(.2,.8,.3,1.2);
  transform-style: preserve-3d;
}
.mem-card.flipped .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 800; padding: 8px; box-shadow: 0 5px 14px rgba(60,20,120,.25);
}
.mem-back {
  background: radial-gradient(circle at 35% 30%, #b388ff, var(--violet)); color: #fff; font-size: 2rem;
  border: 4px solid #fff;
}
.mem-front {
  background: linear-gradient(135deg, #fff, #f1e9ff); color: var(--violet-d); font-size: 1.1rem;
  transform: rotateY(180deg); border: 4px solid #e3d4ff; line-height: 1.15;
}
.mem-card.matched .mem-front { border-color: var(--ok); background: linear-gradient(135deg, #d6fff0, #b8ffe4); color: #0f7a54; animation: goodPulse .5s; }
.mem-card.matched { cursor: default; }

.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-item {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fbf6ff, #efe7ff); border-radius: 16px; padding: 16px;
  font-weight: 700; box-shadow: 0 4px 0 rgba(123,47,247,.14); cursor: grab;
}
.order-item .grab { font-size: 1.5rem; color: var(--violet); cursor: grab; }

.feedback {
  margin-top: 20px; padding: 16px 20px; border-radius: 16px; font-weight: 700;
  display: none; font-size: 1.1rem;
}
.feedback.show { display: block; animation: cardIn .3s; }
.feedback.good { background: linear-gradient(135deg, #d6fff0, #b8ffe4); color: #0f7a54; }
.feedback.bad  { background: linear-gradient(135deg, #ffe6ec, #ffd6e0); color: #b3322f; }

.game-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Résultat ---------- */
.result-card {
  text-align: center; background: var(--card); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 38px 26px; margin-top: 8px;
  border: 3px solid rgba(255,255,255,.6); animation: cardIn .5s cubic-bezier(.2,.9,.3,1.3);
}
.result-card .mascot { font-size: 5rem; }
.result-stars { font-size: 4.4rem; margin: 10px 0; letter-spacing: 6px; }
.result-stars .lit { color: var(--or); text-shadow: 0 3px 10px rgba(247,165,0,.6); display: inline-block; animation: starDrop .6s cubic-bezier(.2,.9,.3,1.5) backwards; }
.result-stars .lit:nth-child(1) { animation-delay: .15s; }
.result-stars .lit:nth-child(2) { animation-delay: .35s; }
.result-stars .lit:nth-child(3) { animation-delay: .55s; }
.result-stars .dim { color: #e0d2ff; }
@keyframes starDrop { 0% { transform: translateY(-40px) scale(0) rotate(-30deg); opacity: 0; } 70% { transform: translateY(6px) scale(1.4); opacity: 1; } 100% { transform: none; } }
.result-msg { font-family: var(--font-title); font-size: 1.7rem; font-weight: 700; margin: 12px 0; color: var(--violet-d); }
.result-sub { color: var(--text-soft); margin-bottom: 8px; font-weight: 600; }

/* ---------- Badges ---------- */
.badges-row { display: flex; flex-wrap: wrap; gap: 12px; }
.badge {
  background: linear-gradient(135deg, #fff, #fff2c9); border-radius: 18px; padding: 12px 16px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 8px; font-weight: 700;
  border: 2px solid var(--or);
}
.badge .ic { font-size: 1.7rem; }
.badge.locked { opacity: .35; filter: grayscale(1); border-color: #ccc; }

/* ---------- Panel / Espace parent ---------- */
.panel { background: var(--card); backdrop-filter: blur(8px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; border: 3px solid rgba(255,255,255,.6); }
.panel h3 { margin: 0 0 12px; font-family: var(--font-title); color: var(--violet-d); }
.parent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; margin: 14px 0; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: center; border: 3px solid rgba(255,255,255,.6); }
.stat-card .num { font-family: var(--font-title); font-size: 2.4rem; font-weight: 700; color: var(--rose); }
.stat-card .lbl { color: var(--text-soft); font-weight: 700; }
.mastery-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid #f0e8ff; }
.mastery-row:last-child { border-bottom: none; }
.mastery-row .lbl { flex: 1; font-weight: 700; }
.mastery-row .pct { font-weight: 800; min-width: 48px; text-align: right; }
.bar { flex: 0 0 120px; height: 14px; background: #ece0ff; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.progress-bar { height: 10px; background: #ece0ff; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--rose), var(--violet)); border-radius: 999px; transition: width .5s; }
table.recent { width: 100%; border-collapse: collapse; }
table.recent th, table.recent td { text-align: left; padding: 9px 6px; border-bottom: 1px solid #f0e8ff; font-size: .95rem; }
table.recent th { color: var(--text-soft); font-size: .8rem; text-transform: uppercase; }

/* ---------- Formulaires ---------- */
.form-card { max-width: 440px; margin: 30px auto; background: var(--card); backdrop-filter: blur(8px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px; border: 3px solid rgba(255,255,255,.6); }
.form-card h1 { margin-top: 0; font-family: var(--font-title); color: var(--violet-d); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 800; margin-bottom: 6px; color: var(--violet-d); }
.field input { width: 100%; padding: 15px; border-radius: 16px; border: 3px solid #d9c9ff; font-family: var(--font); font-size: 1.05rem; background: #fbf6ff; }
.field input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(123,47,247,.15); }
.avatar-picker { display: flex; gap: 12px; flex-wrap: wrap; }
.avatar-opt {
  width: 70px; height: 70px; border-radius: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; cursor: pointer; border: 3px solid transparent;
  background: linear-gradient(135deg, #fbf6ff, #efe7ff); box-shadow: 0 4px 0 rgba(123,47,247,.14);
  transition: transform .1s;
}
.avatar-opt:active { transform: scale(.92); }
.avatar-opt.sel { border-color: var(--violet); background: #e3d4ff; box-shadow: 0 4px 0 var(--violet-d); }
.error-msg { background: #ffe6ec; color: #b33222; padding: 12px 16px; border-radius: 14px; margin-bottom: 14px; font-weight: 700; }

/* ---------- Choix profil ---------- */
.profiles { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin: 24px 0; }
.profile-card {
  background: var(--card); backdrop-filter: blur(8px); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; text-align: center; min-width: 150px; cursor: pointer; border: 3px solid rgba(255,255,255,.6);
  transition: transform .12s, border-color .12s; color: var(--text); font-family: var(--font);
}
.profile-card:hover { border-color: var(--rose); transform: translateY(-4px); }
.profile-card:active { transform: scale(.96); }
.profile-card .av { font-size: 3.4rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }

/* ---------- Erreur ---------- */
.error-page { text-align: center; padding: 60px 20px; color: #fff; }
.error-page .code { font-family: var(--font-title); font-size: 5rem; font-weight: 700; color: var(--or); }

.link-back {
  display: inline-block; color: var(--violet); font-weight: 800; text-decoration: none;
  padding: 10px 18px; border-radius: 14px; background: #f1e9ff; border: 2px solid transparent;
}
.link-back:hover { border-color: var(--violet); }

.footer-fox { text-align: center; color: rgba(255,255,255,.6); font-size: .85rem; font-weight: 600; margin-top: 36px; }

/* --- Bandeau mode test --- */
.test-banner {
  position: relative; z-index: 2; text-align: center; font-weight: 800; color: #5b3b00;
  background: repeating-linear-gradient(45deg, #ffe79a, #ffe79a 14px, #ffd23f 14px, #ffd23f 28px);
  padding: 8px 14px; font-size: .92rem; box-shadow: 0 3px 10px rgba(0,0,0,.2);
}
.test-banner a { color: #7b2ff7; margin-left: 10px; font-weight: 800; }

/* ---------- Confettis ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.confetti-piece { position: absolute; will-change: transform; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .hero h1 { font-size: 1.9rem; }
  .question { font-size: 1.4rem; }
  .btn { font-size: 1.1rem; padding: 14px 20px; }
  .moon { width: 64px; height: 64px; }
  .match-item { padding: 13px; font-size: .95rem; }
}

/* ===================================================================
   CARTE D'AVENTURE — la quête de Filou 🦊
   =================================================================== */

/* --- Bannière histoire --- */
.story-banner {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,237,250,.92));
  backdrop-filter: blur(8px); border: 3px solid rgba(255,255,255,.6);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 14px;
}
.story-fox { font-size: 3.4rem; flex: 0 0 auto; animation: floaty 4s ease-in-out infinite; filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)); }
.story-text { flex: 1; }
.chapter-tag {
  display: inline-block; font-family: var(--font-title); font-weight: 700; color: #fff;
  background: linear-gradient(90deg, var(--violet), var(--rose)); padding: 4px 14px; border-radius: 999px;
  font-size: .9rem; margin-bottom: 6px; box-shadow: 0 3px 10px rgba(123,47,247,.35);
}
.story-text p { margin: 0; font-weight: 700; color: var(--text); line-height: 1.35; }

/* --- Barre de quête (étoiles) --- */
.quest-bar {
  background: var(--card); backdrop-filter: blur(8px); border: 3px solid rgba(255,255,255,.6);
  border-radius: 20px; box-shadow: var(--shadow-sm); padding: 14px 18px; margin-bottom: 22px;
}
.quest-label { font-weight: 800; color: var(--violet-d); margin-bottom: 8px; }
.quest-track { height: 16px; background: #ece0ff; border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(123,47,247,.15); }
.quest-track > span {
  display: block; height: 100%; border-radius: 999px; min-width: 16px;
  background: linear-gradient(90deg, var(--or), var(--rose), var(--violet));
  background-size: 200% 100%; animation: questFlow 3s linear infinite; transition: width .6s;
}
@keyframes questFlow { to { background-position: 200% 0; } }

/* --- Les mondes --- */
.map { display: flex; flex-direction: column; gap: 22px; }
.world {
  background: var(--card); backdrop-filter: blur(8px); border: 3px solid rgba(255,255,255,.6);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 10px 24px; overflow: hidden;
  position: relative;
}
.world::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 10px; }
.world.maths::before    { background: linear-gradient(90deg, #ff8ec7, var(--maths)); }
.world.francais::before { background: linear-gradient(90deg, #7ad4ff, var(--francais)); }
.world.monde::before    { background: linear-gradient(90deg, #6ff0c2, var(--monde)); }
.world-head {
  display: flex; align-items: center; gap: 12px; padding: 22px 14px 8px;
  font-family: var(--font-title); font-weight: 700; color: var(--text);
}
.world-guardian { font-size: 2.4rem; filter: drop-shadow(0 3px 6px rgba(0,0,0,.2)); animation: floaty 5s ease-in-out infinite; }
.world-name { font-size: 1.45rem; }
.world-emoji { font-size: 1.5rem; }

/* --- Le chemin sinueux --- */
.trail { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 0 4px; }
.trail::before {
  content: ""; position: absolute; left: 50%; top: 24px; bottom: 24px; width: 0;
  border-left: 5px dashed rgba(123,47,247,.25); transform: translateX(-50%);
}
.node {
  position: relative; width: 50%; display: flex; flex-direction: column; align-items: center;
  text-decoration: none; color: var(--text); padding: 10px 6px; box-sizing: border-box;
}
.node.left  { align-self: flex-start; }
.node.right { align-self: flex-end; }

.medallion {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; border: 5px solid #fff;
  box-shadow: 0 6px 16px rgba(60,20,120,.3), inset 0 -4px 8px rgba(0,0,0,.12);
  transition: transform .12s;
}
.node:active .medallion { transform: scale(.92); }
.world.maths    .node:not(.locked) .medallion { background: radial-gradient(circle at 35% 30%, #ffb3da, var(--maths)); }
.world.francais .node:not(.locked) .medallion { background: radial-gradient(circle at 35% 30%, #9bdcff, var(--francais)); }
.world.monde    .node:not(.locked) .medallion { background: radial-gradient(circle at 35% 30%, #8af2cd, var(--monde)); }
.node-icon { filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }

.node-label {
  margin-top: 8px; font-weight: 800; font-size: .92rem; text-align: center;
  max-width: 130px; line-height: 1.15; color: var(--text);
}
.node-stars { display: flex; gap: 2px; margin-bottom: 6px; font-size: 1rem; }
.node-stars span { color: #d9c9ff; }
.node-stars span.on { color: var(--or); text-shadow: 0 1px 3px rgba(247,165,0,.5); }

/* niveau terminé (maîtrisé) */
.node.done .medallion { border-color: var(--or); box-shadow: 0 0 0 3px var(--or), 0 6px 16px rgba(247,165,0,.4); }

/* niveau verrouillé */
.node.locked { pointer-events: none; }
.node.locked .medallion { background: #ece4f7; border-color: #f3eeff; box-shadow: inset 0 -4px 8px rgba(0,0,0,.08); }
.node.locked .node-lock { font-size: 2rem; opacity: .5; }
.node.locked .node-label { color: var(--text-soft); opacity: .7; }

/* niveau courant : Filou est ici */
.node.current .medallion {
  border-color: #fff; animation: bob 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 6px rgba(255,210,63,.55), 0 0 26px rgba(255,210,63,.7), 0 6px 16px rgba(60,20,120,.3);
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.here {
  position: absolute; top: -14px; z-index: 2;
  background: linear-gradient(90deg, var(--violet), var(--rose)); color: #fff;
  font-weight: 800; font-size: .8rem; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(123,47,247,.45); animation: bob 1.4s ease-in-out infinite;
}

/* --- Coffre aux badges --- */
.badges-panel { margin-top: 22px; }
.badges-empty { color: var(--text-soft); font-weight: 600; margin: 0; }

@media (max-width: 560px) {
  .story-fox { font-size: 2.6rem; }
  .medallion { width: 72px; height: 72px; font-size: 2rem; }
  .node-label { font-size: .82rem; max-width: 110px; }
  .world-name { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
