/* ============================================================
   Encore ! — feuille de style unique
   Mobile-first, max-width 430 px, zéro dépendance.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg: #F7F3FC;
  --card: #FFFFFF;
  --ink: #2A2438;
  --muted: #8B84A0;
  --line: #E9E4F5;

  --green: #3ECF6B;  --green-d: #2AA84F;  --green-l: #E4F9EA;
  --red:   #F45B5B;  --red-d:   #D13D3D;  --red-l:   #FDE8E8;
  --gold:  #FFB020;  --gold-d:  #E08E00;  --gold-l:  #FFF3DC;
  --blue:  #4EA8FF;  --blue-d:  #2F87E0;

  --violet: #7B2CF2; --violet-d: #6222C8; --violet-l: #F0E9FE;
  --pink:   #F04E98; --pink-d:   #CC2F7B; --pink-l:   #FEE7F2;

  --radius: 18px;
  --radius-s: 12px;
  --shadow-soft: 0 6px 24px rgba(75, 44, 130, .10);
}
.app[data-course="music"] { --c: var(--violet); --c-d: var(--violet-d); --c-l: var(--violet-l); }
.app[data-course="ballet"] { --c: var(--pink); --c-d: var(--pink-d); --c-l: var(--pink-l); }

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 8px; }

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.desknote {
  display: none;
  position: fixed;
  top: 18px;
  left: 28px;
  max-width: 230px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.45;
}
@media (min-width: 560px) {
  body { background:
    radial-gradient(900px 500px at 15% 0%, #EFE6FD 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 100%, #FDE7F2 0%, transparent 55%),
    #F3EDFB; }
  .app { box-shadow: 0 30px 80px rgba(60, 30, 120, .25); }
  .desknote { display: block; }
}

/* ---------- écran ---------- */
.screen { display: flex; flex-direction: column; min-height: 100dvh; }
.screen-scroll { flex: 1; padding: 0 18px calc(24px + env(safe-area-inset-bottom)); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 16px;
  padding: 15px 20px;
  letter-spacing: .2px;
  transition: transform .06s ease, box-shadow .06s ease, filter .15s ease;
}
.btn:active { transform: translateY(3px); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d); }
.btn-primary:active { box-shadow: 0 1px 0 var(--green-d); }
.btn-primary:disabled {
  background: #E7E1F2; color: #B9B0CF; box-shadow: 0 4px 0 #D9D1E9;
  transform: none; cursor: default;
}
.btn-ghost { background: transparent; color: var(--muted); font-weight: 800; }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-d); }
.btn-danger:active { box-shadow: 0 1px 0 var(--red-d); }
.btn-big { width: 100%; font-size: 17px; padding: 17px 20px; }

/* ---------- accueil : en-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(247, 243, 252, .92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.brand { font-size: 22px; font-weight: 900; letter-spacing: .3px; }
.stats { display: flex; gap: 8px; }
.stat {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 2px solid var(--line);
  border-radius: 999px; padding: 5px 12px;
  font-size: 14px; font-weight: 900;
}
.stat b { font-weight: 900; }

/* ---------- pilules de cours ---------- */
.pills {
  display: flex; gap: 8px;
  padding: 14px 18px 6px;
}
.pill {
  flex: 1;
  border-radius: 999px;
  padding: 11px 8px;
  font-size: 14.5px; font-weight: 900;
  background: var(--card);
  border: 2.5px solid var(--line);
  color: var(--muted);
  transition: all .15s ease;
}
.pill.on { border-color: var(--c); color: var(--c-d); background: var(--c-l); }

/* ---------- unités + chemin ---------- */
.unit { margin-top: 18px; }
.unit-head {
  display: flex; align-items: center; gap: 12px;
  background: var(--c-l);
  border: 2.5px solid transparent;
  border-radius: var(--radius);
  padding: 13px 15px;
}
.unit-emoji { font-size: 30px; line-height: 1; }
.unit-title { font-size: 16.5px; font-weight: 900; color: var(--c-d); }
.unit-blurb { font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.unit-count {
  margin-left: auto; flex-shrink: 0;
  font-size: 13px; font-weight: 900; color: var(--c-d);
  background: #fff; border-radius: 999px; padding: 5px 11px;
  box-shadow: 0 2px 0 rgba(98, 34, 200, .15);
}
.unit.done .unit-head { background: var(--gold-l); }
.unit.done .unit-title { color: var(--gold-d); }
.unit.done .unit-count { color: var(--gold-d); }

.track {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 58px 0 6px;
}
.track::before {
  content: "";
  position: absolute; top: 6px; bottom: 6px; left: 50%;
  width: 4px; margin-left: -2px;
  border-radius: 4px;
  background: repeating-linear-gradient(180deg, #DCD4F0 0 10px, transparent 10px 22px);
}
.node-row { position: relative; z-index: 1; padding: 11px 0; }
.node-row.off-r1 { transform: translateX(56px); }
.node-row.off-r2 { transform: translateX(84px); }
.node-row.off-l1 { transform: translateX(-56px); }
.node-row.off-l2 { transform: translateX(-84px); }

.node {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 6px 0 var(--c-d), inset 0 -10px 0 rgba(0, 0, 0, .10);
  display: grid; place-items: center;
  font-size: 32px;
  transition: transform .06s ease;
}
.node:active { transform: translateY(4px); }
.node.locked { background: #E3DEEE; box-shadow: 0 6px 0 #CBC3DE; color: #A9A0C2; }
.node.done { background: var(--gold); box-shadow: 0 6px 0 var(--gold-d), inset 0 -10px 0 rgba(0, 0, 0, .10); }
.node.review { font-size: 30px; }
.node .lock { font-size: 26px; }

.node.current::after {
  content: "";
  position: absolute; inset: -9px;
  border-radius: 50%;
  border: 3.5px solid var(--c);
  animation: pulse 1.5s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.86); opacity: .9; }
  70% { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}
.start-bubble {
  position: absolute; top: -42px; left: 50%;
  transform: translateX(-50%);
  background: #fff; color: var(--c-d);
  border: 2.5px solid var(--c);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px; font-weight: 900; letter-spacing: .6px;
  animation: bounce 1.4s ease-in-out infinite;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(60, 30, 120, .18);
}
.start-bubble::after {
  content: ""; position: absolute; bottom: -7px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: #fff;
  border-right: 2.5px solid var(--c); border-bottom: 2.5px solid var(--c);
}
@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-7px); }
}
.node-crown {
  position: absolute; right: -4px; bottom: -2px;
  background: #fff; border-radius: 50%;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 14px;
  box-shadow: 0 2px 0 rgba(60, 30, 120, .15);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.shake { animation: shake .45s ease; }

/* ---------- leçon : barre haute ---------- */
.lesson-top {
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
}
.btn-close {
  font-size: 22px; font-weight: 900; color: var(--muted);
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
}
.btn-close:active { background: var(--line); }
.progressbar {
  flex: 1; height: 14px;
  background: #E7E1F2; border-radius: 999px;
  overflow: hidden;
}
.progressbar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #7BE495, var(--green));
  border-radius: 999px;
  transition: width .35s cubic-bezier(.2, .8, .3, 1.2);
}
.hearts { display: flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 900; }
.hearts span { font-size: 15px; }

/* ---------- leçon : corps ---------- */
.exercise {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 12px 20px 8px;
  overflow-y: auto;
}
.ex-emoji { font-size: 58px; line-height: 1.1; text-align: center; margin: 14px 0 8px; }
.ex-prompt {
  font-size: 21px; font-weight: 900; line-height: 1.32;
  text-align: center;
  margin: 6px 0 20px;
}
.ex-hint {
  text-align: center; font-size: 13.5px; font-weight: 700;
  color: var(--muted); margin: -12px 0 16px;
}

/* options qcm / vrai-faux */
.opts { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  font-size: 16.5px; font-weight: 800;
  text-align: left;
  box-shadow: 0 3px 0 var(--line);
  transition: all .12s ease;
  min-height: 54px;
}
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.opt .dot {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 2.5px solid #D5CDE9; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px; color: transparent; font-weight: 900;
}
.opt.sel { border-color: var(--blue); background: #EFF7FF; box-shadow: 0 3px 0 #CBE3FB; }
.opt.sel .dot { border-color: var(--blue); color: var(--blue); }
.opt.good { border-color: var(--green); background: var(--green-l); box-shadow: 0 3px 0 #C4ECCF; }
.opt.good .dot { border-color: var(--green); color: var(--green); }
.opt.bad { border-color: var(--red); background: var(--red-l); box-shadow: 0 3px 0 #F3C6C6; }
.opt.bad .dot { border-color: var(--red); color: var(--red); }
.opt.tf { justify-content: center; font-size: 18px; padding: 18px; }
.opts-row { display: flex; gap: 11px; }
.opts-row .opt { flex: 1; justify-content: center; }

/* associer : colonnes gauche/droite (4 lignes × 2 colonnes) */
.match-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(4, auto);
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mtile {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: 0 3px 0 var(--line);
  padding: 14px 12px;
  font-size: 15px; font-weight: 800; line-height: 1.25;
  min-height: 62px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transition: all .12s ease;
}
.mtile:active { transform: translateY(2px); }
.mtile.pick { border-color: var(--blue); background: #EFF7FF; box-shadow: 0 3px 0 #CBE3FB; transform: scale(1.03); }
.mtile.ok { border-color: var(--green); background: var(--green-l); opacity: .55; box-shadow: none; pointer-events: none; }
.mtile.no { animation: shake .4s ease; border-color: var(--red); background: var(--red-l); }

/* ordre */
.order-slots {
  display: flex; flex-wrap: wrap; gap: 9px;
  background: #EFEAF8; border: 2.5px dashed #D5CDE9;
  border-radius: var(--radius-s);
  padding: 14px; min-height: 78px;
  margin-bottom: 22px;
}
.order-slots .chip { background: #fff; }
.chip {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--line);
  padding: 10px 16px;
  font-size: 15.5px; font-weight: 800;
  transition: transform .08s ease;
}
.chip:active { transform: translateY(2px); }
.chip.dim { opacity: .25; pointer-events: none; box-shadow: none; }
.order-bank { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }

/* pied de leçon */
.lesson-foot {
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 2px solid var(--line);
}

/* ---------- panneau de correction ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(42, 36, 56, .35);
  animation: fadein .18s ease;
  max-width: 430px; margin: 0 auto;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  width: 100%;
  border-radius: 26px 26px 0 0;
  padding: 22px 22px calc(20px + env(safe-area-inset-bottom));
  animation: slideup .25s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes slideup { from { transform: translateY(60%); } }
.sheet.good { background: var(--green-l); }
.sheet.bad { background: var(--red-l); }
.sheet-ico { font-size: 34px; line-height: 1; }
.sheet-title { font-size: 23px; font-weight: 900; margin: 8px 0 6px; }
.sheet.good .sheet-title { color: var(--green-d); }
.sheet.bad .sheet-title { color: var(--red-d); }
.sheet-explain { font-size: 15.5px; font-weight: 700; line-height: 1.45; color: var(--ink); }
.sheet .btn-big { margin-top: 18px; }
.sheet.good .btn-big { background: var(--green-d); box-shadow: 0 4px 0 #1E8A40; }
.sheet.bad .btn-big { background: var(--red-d); box-shadow: 0 4px 0 #B02E2E; }

/* ---------- écrans de fin ---------- */
.endscreen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 8px;
}
.end-emoji { font-size: 84px; animation: popin .5s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes popin { from { transform: scale(.3); opacity: 0; } }
.end-title { font-size: 27px; font-weight: 900; margin-top: 10px; }
.end-sub { font-size: 15.5px; font-weight: 700; color: var(--muted); line-height: 1.45; max-width: 300px; }
.end-stats { display: flex; gap: 12px; margin: 20px 0 8px; }
.end-stat {
  background: var(--card); border: 2.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 108px;
}
.end-stat .v { font-size: 21px; font-weight: 900; }
.end-stat .k { font-size: 12.5px; font-weight: 800; color: var(--muted); }
.endscreen .btn-big { max-width: 300px; margin-top: 16px; }
.end-title.fail { color: var(--red-d); }

/* ---------- modales ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(42, 36, 56, .45);
  padding: 26px;
  animation: fadein .18s ease;
  max-width: 430px; margin: 0 auto;
}
.modal {
  background: var(--card);
  border-radius: 26px;
  padding: 28px 24px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-soft);
  animation: popin .3s cubic-bezier(.2, .9, .3, 1.3);
}
.modal-emoji { font-size: 64px; line-height: 1; }
.modal-title { font-size: 23px; font-weight: 900; margin: 12px 0 8px; }
.modal-text { font-size: 15.5px; font-weight: 700; color: var(--muted); line-height: 1.5; }
.modal .btn-big { margin-top: 20px; }
.modal .btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: calc(30px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 14.5px; font-weight: 800;
  box-shadow: 0 10px 30px rgba(42, 36, 56, .35);
  animation: slideup .25s ease;
  max-width: 86vw; text-align: center;
  z-index: 90;
}

/* ---------- confettis ---------- */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti-layer i {
  position: absolute; top: -16px;
  width: 10px; height: 15px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(112vh) rotate(740deg); opacity: .8; }
}

/* ---------- état vide / démarrage ---------- */
.boot {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 30px;
}
.boot .spin {
  font-size: 52px;
  animation: bounce 1.2s ease-in-out infinite;
}
.boot p { font-weight: 800; color: var(--muted); }
