/* Solfège — styles. Gros boutons, couleurs vives, coins arrondis : pensé pour des doigts d'enfant. */

@font-face {
  font-family: 'BravuraSolfege';
  src: url('../assets/fonts/Bravura-solfege.woff') format('woff');
  font-display: block;
}

:root {
  --accent: #ff6fa8;
  --accent-2: #ffd1e3;
  --accent-dark: #d94c86;
  --bg: #fff5fa;
  --card: #ffffff;
  --text: #2b2340;
  --muted: #8a819f;
  --line: #ece6f3;
  --good: #2fb35a;
  --good-soft: #d9f7e3;
  --bad: #f0544f;
  --bad-soft: #ffe3e0;
  --gold: #ffc107;
  --world: var(--accent);
  --radius: 22px;
  --font: 'Nunito', 'Segoe UI Rounded', 'Segoe UI', system-ui, -apple-system, 'Roboto', sans-serif;
}

[data-theme='ocean'] { --accent: #1e88e5; --accent-2: #cfe6fb; --accent-dark: #1565c0; --bg: #f2f8ff; }
[data-theme='foret'] { --accent: #2e7d32; --accent-2: #d3ecd4; --accent-dark: #1b5e20; --bg: #f3faf3; }
[data-theme='soleil'] { --accent: #ef6c00; --accent-2: #ffe3c2; --accent-dark: #c25500; --bg: #fff8ef; }
[data-theme='menthe'] { --accent: #00a88f; --accent-2: #c9f2ea; --accent-dark: #007a68; --bg: #f1fbf9; }
[data-theme='lavande'] { --accent: #8e6bd8; --accent-2: #e4dafb; --accent-dark: #6a4bb5; --bg: #f7f4fe; }
[data-theme='cerise'] { --accent: #d81b60; --accent-2: #fbd0df; --accent-dark: #a3104a; --bg: #fff4f7; }
[data-theme='galaxie'] {
  --accent: #9c7bff; --accent-2: #3d2d7a; --accent-dark: #7350f0; --bg: #1b1340; --card: #2a1f5c;
  --text: #f4f0ff; --muted: #b3a8d8; --line: #3f3278; --good-soft: #1f4d36; --bad-soft: #5a2430;
  --mascot-stem: #d9ceff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; user-select: none; -webkit-user-select: none; }
body.loading #app { visibility: hidden; }
input, textarea { user-select: text; -webkit-user-select: text; }

#app { max-width: 780px; margin: 0 auto; min-height: 100dvh; }

h1, h2, h3 { font-weight: 900; margin: 0.6em 0 0.4em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page { padding: 16px 16px 40px; }
.page-title { font-size: 1.7rem; margin: 6px 0 12px; }
.scroll-x { overflow-x: auto; }
.smufl { font-family: 'BravuraSolfege'; }
svg.glyph { height: 1.7em; width: auto; vertical-align: middle; overflow: visible; }

/* ---------- Boutons et cartes ---------- */
button { font-family: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: 0.5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 20px;
  font-weight: 900;
  font-size: 1.05rem;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent-dark); }
.btn.ghost { background: var(--card); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.danger { background: #e0393e; color: #fff; box-shadow: 0 4px 0 #a8282c; }
.btn.big { width: 100%; font-size: 1.2rem; padding: 16px 24px; }
.btn.small { padding: 8px 14px; font-size: 0.95rem; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card);
  font-size: 1.2rem; font-weight: 900; box-shadow: 0 3px 0 var(--line); flex: none;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 3px 0 var(--line), 0 8px 24px rgba(40, 20, 80, 0.06);
}

.input {
  width: 100%;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); }

.star.on { fill: var(--gold); }
.star.off { fill: var(--line); }
.stars { display: inline-flex; gap: 1px; vertical-align: middle; }
.coin { vertical-align: middle; flex: none; }

/* ---------- Cadre : bandeau du haut et onglets ---------- */
.shell { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--card);
  box-shadow: 0 2px 0 var(--line);
}
/* Avatar (emoji) avec son serre-tête dessiné par-dessus */
.avatar-view { position: relative; display: inline-block; line-height: 1; }
.avatar-view .avatar-emoji { display: block; line-height: 1; }
.avatar-view svg.headband { position: absolute; left: -8%; top: -17%; width: 116%; height: 116%; overflow: visible; pointer-events: none; }
.avatar-view svg.hb-licorne { filter: drop-shadow(0 0 3px rgba(255, 213, 74, 0.9)); }
.avatar-view svg.hb-licorne .sparkle { animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.2; } }
.shop-name { font-size: 0.8rem; text-align: center; line-height: 1.15; }
.headband-grid .shop-emoji { padding-top: 8px; }
.avatar-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent-2); font-size: 1.7rem; line-height: 1;
}
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xpbar { display: flex; align-items: center; gap: 6px; }
.xpbar-level { font-size: 0.75rem; font-weight: 900; color: var(--accent); white-space: nowrap; }
.xpbar-track { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 160px; }
.xpbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px;
  border-radius: 99px; background: var(--bg); font-weight: 900; flex: none;
}
.chip.off { filter: grayscale(1); opacity: 0.55; }

.content { flex: 1; padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 780px; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); box-shadow: 0 -2px 0 var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: 0; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-weight: 800; font-size: 0.72rem;
}
.tab-icon { font-size: 1.5rem; transition: transform 0.15s; }
.tab.active { color: var(--accent); }
.tab.active .tab-icon { transform: scale(1.18); }

/* ---------- Joueurs ---------- */
.hero { text-align: center; padding-top: 18px; }
.logo { font-size: 2.8rem; color: var(--accent); margin: 0; letter-spacing: 0.5px; }
.tagline { margin: 4px 0 8px; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border: 0; border-radius: var(--radius); padding: 16px 8px;
  box-shadow: 0 4px 0 var(--line);
}
.profile-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.profile-card.add { border: 3px dashed var(--line); box-shadow: none; background: transparent; }
.profile-avatar { font-size: 3rem; line-height: 1.1; }
.profile-name { font-weight: 900; font-size: 1.1rem; }
.profile-meta { color: var(--muted); font-size: 0.9rem; }
.install { display: block; margin: 20px auto 0; }
.create { display: flex; flex-direction: column; gap: 12px; }
.create h2, .create h3 { margin: 0; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.avatar-choice {
  font-size: clamp(1.5rem, 7vw, 2.1rem); aspect-ratio: 1; min-width: 0; border-radius: 16px; border: 3px solid transparent;
  background: var(--bg); line-height: 1; padding: 0;
}
.avatar-choice.selected { border-color: var(--accent); transform: scale(1.08); background: var(--accent-2); }

/* ---------- Carte du parcours ---------- */
.hero-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-card .mascot { flex: none; }
.hero-text { flex: 1; min-width: 180px; }
.hero-hello { font-weight: 900; font-size: 1.2rem; }
.hero-next { margin: 2px 0 6px; }
.goal { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.goal-ring { width: 34px; height: 34px; flex: none; }
.goal-bg, .goal-fg { fill: none; stroke-width: 6; }
.goal-bg { stroke: var(--line); }
.goal-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray 0.6s; }
.hero-card > .btn { flex: none; }

.world { margin: 18px 0; }
.world-head {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 0; border-radius: var(--radius); padding: 12px 16px; color: #fff;
  background: var(--world);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--world) 70%, #000);
}
.world-icon {
  width: 50px; height: 50px; border-radius: 50%; flex: none; font-size: 1.7rem;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.22);
}
.world-icon svg.glyph { height: 40px; }
.world-titles { flex: 1; display: flex; flex-direction: column; }
.world-title { font-weight: 900; font-size: 1.2rem; }
.world-sub { font-size: 0.85rem; opacity: 0.9; }
.world-stars { font-weight: 900; white-space: nowrap; }
.world.locked .world-head { filter: grayscale(0.85); opacity: 0.6; cursor: default; }
.world-req { margin: 8px 6px 0; color: var(--muted); font-size: 0.92rem; }

.level-path { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 0 6px; }
.level-node {
  --shift: 54px;
  background: none; border: 0; padding: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transform: translateX(calc(var(--dx) * var(--shift)));
}
.node-bubble {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--world); color: #fff; font-size: 1.7rem; font-weight: 900;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--world) 65%, #000);
  transition: transform 0.1s;
}
.level-node:active .node-bubble { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--world) 65%, #000); }
.level-node.done .node-bubble { background: linear-gradient(160deg, var(--world), color-mix(in srgb, var(--world) 60%, #ffd54a)); }
.level-node.locked .node-bubble { background: var(--line); color: var(--muted); box-shadow: 0 6px 0 color-mix(in srgb, var(--line) 75%, #000); font-size: 1.4rem; }
.level-node.locked { cursor: default; }
.level-node.current .node-bubble {
  outline: 5px solid color-mix(in srgb, var(--world) 35%, transparent); outline-offset: 4px;
  animation: pulse 1.6s infinite;
}
.node-title { font-weight: 800; font-size: 0.85rem; max-width: 170px; text-align: center; line-height: 1.2; }
.level-node.boss .node-bubble { width: 86px; height: 86px; font-size: 2.2rem; background: linear-gradient(160deg, #ffd54a, var(--world)); }
.level-node.boss.locked .node-bubble { background: var(--line); font-size: 1.5rem; }
.chapters { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chapter-head {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  border: 0; border-radius: 16px; padding: 11px 14px; font-weight: 900; color: var(--text);
  background: color-mix(in srgb, var(--world) 12%, var(--card)); box-shadow: 0 3px 0 color-mix(in srgb, var(--world) 25%, var(--line));
}
.chapter-name { flex: 1; }
.chapter-meta { font-size: 0.85rem; white-space: nowrap; color: var(--muted); }
.chapter-caret { color: var(--world); font-size: 1.1rem; }
.chapter.locked .chapter-head { opacity: 0.6; }
.chapter-title {
  align-self: stretch; display: flex; align-items: center; gap: 10px; margin: 16px 4px 6px;
  color: var(--world); font-weight: 900; font-size: 0.95rem; text-align: center;
}
.chapter-title::before, .chapter-title::after {
  content: ''; flex: 1; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--world) 30%, transparent);
}

/* ---------- Fenêtres ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 10, 40, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade 0.2s;
}
.backdrop.closing { opacity: 0; transition: opacity 0.2s; }
.modal {
  background: var(--card); border-radius: 26px; padding: 20px; width: 100%; max-width: 560px;
  max-height: 92dvh; overflow: auto; animation: rise 0.25s ease-out;
}
.modal.sheet { max-width: 640px; }
.sheet-world { color: var(--world); font-weight: 900; display: flex; align-items: center; gap: 6px; }
.sheet-world svg.glyph { height: 1.6em; }
.lesson-sheet h2 { font-size: 1.6rem; margin: 2px 0 10px; }
.speech { display: flex; gap: 8px; align-items: flex-start; }
.speech .mascot { flex: none; }
.bubble {
  margin: 0; background: var(--bg); border-radius: 18px; padding: 12px 14px;
  font-size: 1.05rem; line-height: 1.45; position: relative;
}
.illustration { margin: 14px 0 6px; }
.illustration .muted { margin: 4px 0 0; }
.lesson-staff { display: block; width: 100%; max-height: 210px; color: var(--text); }
.playable .note { cursor: pointer; }
.figures { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.figure { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px; }
.figure svg { width: 74px; height: auto; color: var(--text); }
.sheet-meta { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; }
.quit { text-align: center; }
.quit .row { justify-content: center; }

/* ---------- Exercice ---------- */
/* Colonne étroite à gauche (quitter, progression verticale, série) ; en bas, la zone de
   réponse prend toute la largeur de l'écran (le clavier va d'un bord à l'autre). */
.exercise {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'rail prompt' 'rail stage' 'answers answers';
  gap: 6px 10px;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  position: relative; overflow: hidden;
}
.ex-rail {
  grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 0 6px 10px; min-height: 0;
}
.progress {
  position: relative; flex: 1; width: 14px; min-height: 48px; border-radius: 99px;
  background: var(--line); overflow: hidden;
}
.progress-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p, 0) * 100%);
  background: var(--world); border-radius: 99px; transition: height 0.4s ease;
}
.progress.chrono { width: 16px; }
.progress.chrono .progress-fill { transition: height 0.2s linear; background: linear-gradient(0deg, #ff5252, #ff9800 30%, var(--world)); }
.chrono-left { font-size: 0.8rem; font-weight: 900; }
.combo { font-weight: 900; color: #ff7a00; text-align: center; font-size: 0.9rem; min-height: 1.2em; white-space: nowrap; }
.combo.hot { animation: pop 0.3s; }
.chrono-score { font-weight: 900; font-size: 0.95rem; text-align: center; white-space: nowrap; }
.piano-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 14px;
  background: var(--card); font-weight: 900; font-size: 0.75rem; box-shadow: 0 2px 0 var(--line);
}
.piano-chip.off { filter: grayscale(1); opacity: 0.5; }
.meter { display: inline-flex; gap: 2px; align-items: flex-end; height: 16px; }
.meter i { width: 4px; border-radius: 2px; background: var(--good); height: calc(20% + var(--lvl, 0) * 80%); transition: height 0.06s; }
.meter i:nth-child(2) { height: calc(20% + var(--lvl, 0) * 60%); }
.meter i:nth-child(3) { height: calc(20% + var(--lvl, 0) * 40%); }

.ex-prompt { grid-area: prompt; text-align: center; font-size: 1.3rem; font-weight: 900; min-height: 1.5em; padding: 12px 14px 0 0; }
.prompt-note { color: var(--world); }
.ex-stage {
  grid-area: stage; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; overflow: auto; padding-right: 14px;
}
.ex-stage svg.staff { width: min(100%, 440px); height: auto; max-height: 100%; color: var(--text); }
.ex-answers { grid-area: answers; padding: 0 14px 14px; min-width: 0; }
.ex-answers.with-keyboard { padding: 0; }
.ex-answers.with-keyboard .keyboard { border-radius: 0; border-left: 0; border-right: 0; }
.rotate-hint {
  font-size: 0.85rem; font-weight: 800; color: var(--muted); background: var(--card);
  padding: 6px 12px; border-radius: 99px; box-shadow: 0 2px 0 var(--line);
}
@media (orientation: landscape), (min-width: 700px) { .rotate-hint { display: none; } }

.big-name { font-size: clamp(3.4rem, 15vw, 6rem); font-weight: 900; color: var(--c, var(--world)); animation: pop 0.35s; }
.big-figure { width: min(60vw, 260px); height: auto; color: var(--text); }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; }
.choices.n7 { grid-template-columns: repeat(4, 1fr); }
.choices.n4 { grid-template-columns: repeat(2, 1fr); }
.choice {
  position: relative; border: 0; border-radius: 18px; padding: 16px 6px;
  font-size: 1.4rem; font-weight: 900; background: var(--card);
  box-shadow: 0 5px 0 var(--line); border-top: 7px solid var(--c, var(--world));
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform 0.06s;
}
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.choices.colored .choice { background: var(--c); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.choice-icon { font-size: 2rem; line-height: 1.1; }
.choice-icon + .choice-label { font-size: clamp(0.95rem, 4.2vw, 1.2rem); }
.choice-label { line-height: 1.1; }
.choice kbd {
  position: absolute; top: 4px; right: 8px; font-family: inherit; font-size: 0.7rem;
  color: var(--muted); font-weight: 800;
}
@media (hover: none) { .choice kbd { display: none; } }
.choice.good { background: var(--good) !important; color: #fff; animation: bounce 0.4s; }
.choice.bad { background: var(--bad) !important; color: #fff; animation: shake 0.4s; }
.choices.locked .choice { pointer-events: none; }

/* Clavier de piano */
.keyboard {
  position: relative; display: flex; height: clamp(150px, 32vh, 260px);
  border-radius: 12px; background: #2b2340; border: 6px solid #2b2340; border-bottom: 0; overflow: hidden; touch-action: none;
}
.keyboard.small { height: 110px; }
.keyboard.disabled { pointer-events: none; }
.key { border: 0; padding: 0; position: relative; touch-action: none; }
.key.white {
  flex: none; height: 100%; margin: 0 1px; width: auto;
  background: linear-gradient(#fff, #f4f1f8); border-radius: 0 0 10px 10px;
  box-shadow: inset 0 -7px 0 var(--key-tint, #ddd6e8);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 12px;
}
.key.black {
  position: absolute; top: 0; height: 60%; z-index: 2;
  background: linear-gradient(#3c3550, #14101f); border-radius: 0 0 7px 7px;
  box-shadow: inset 0 -5px 0 #000;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px;
}
.key.white.pressed { background: linear-gradient(#ece6ff, #ddd3ff); }
.key.black.pressed { background: linear-gradient(#5a4f78, #2b2340); }
.key.hint.white { background: linear-gradient(color-mix(in srgb, var(--world) 30%, #fff), color-mix(in srgb, var(--world) 50%, #fff)); }
.key.hint.black { background: var(--world); }
.key.good { background: var(--good) !important; }
.key.bad { background: var(--bad) !important; animation: shake 0.4s; }
.key-label { font-size: clamp(0.62rem, 2.4vw, 0.85rem); font-weight: 900; color: #6b6280; }
.key.black .key-label { color: #fff; font-size: clamp(0.5rem, 1.8vw, 0.68rem); }
.key.good .key-label, .key.bad .key-label { color: #fff; }
.middle-c { width: 9px; height: 9px; border-radius: 50%; background: #ff5252; position: absolute; bottom: 34px; }

/* Barre de temps des leçons « vitesse » */
.time-bar { width: min(100%, 440px); height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; flex: none; }
.time-bar i {
  display: block; height: 100%; width: 100%; transform-origin: left;
  background: linear-gradient(90deg, #ff5252, #ffb300, var(--good)); animation: timeShrink linear forwards;
}
.time-bar.stopped i { animation-play-state: paused; }

/* Portées : lecture, séquences, note à placer */
.staff-box { width: min(100%, 440px); display: flex; justify-content: center; }
.ex-stage .seq-staff { width: min(100%, 640px); }
.ex-stage .seq-staff svg.staff { width: 100%; }
.place-box { width: min(100%, 380px); touch-action: none; cursor: pointer; }
.place-box svg { display: block; width: 100%; height: auto; max-height: 52vh; color: var(--text); }
.staff .note.ghost { opacity: 0.8; }

/* Ordre des notes et séquences */
.order-seq { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.bubble-note {
  min-width: 72px; padding: 14px 16px; border-radius: 20px; background: var(--card);
  box-shadow: 0 4px 0 var(--line); font-size: 1.6rem; font-weight: 900; text-align: center;
}
.bubble-note.mystery { background: var(--world); color: #fff; animation: pulse 1.6s infinite; }
.bubble-note.skip { min-width: 0; padding: 0; background: none; box-shadow: none; color: var(--muted); }
.bubble-note.good { background: var(--good); color: #fff; animation: pop 0.3s; }
.bubble-note.bad { background: var(--bad); color: #fff; }
.seq-dots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.seq-dots .dot {
  min-width: 54px; height: 54px; padding: 0 8px; border-radius: 18px; display: grid; place-items: center;
  background: var(--card); box-shadow: 0 3px 0 var(--line); font-weight: 900; color: var(--muted);
}
.seq-dots .dot.current { outline: 3px solid var(--world); }
.seq-dots .dot.done { background: var(--good); color: #fff; }
.seq-status { text-align: center; font-weight: 800; color: var(--muted); min-height: 1.4em; }
.seq-status.warn { color: var(--bad); animation: shake 0.4s; }

/* Rythmes à compter, à compléter, à reconnaître ; symboles */
.big-rhythm { width: min(100%, 420px); height: auto; color: var(--text); }
.big-rhythm-box { width: min(100%, 460px); color: var(--text); }
.big-rhythm-box svg { width: 100%; height: auto; }
.gap-box { fill: color-mix(in srgb, var(--world) 15%, transparent); stroke: var(--world); stroke-width: 2; stroke-dasharray: 5 4; }
.gap-mark { fill: var(--world); font-size: 26px; font-weight: 900; font-family: var(--font); }
.big-symbol { width: min(70vw, 300px); height: auto; color: var(--text); }
.sym-focus { fill: var(--world); color: var(--world); }
.choice svg { color: inherit; height: auto; }
.choices.long { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choices.long .choice { font-size: 1.05rem; padding: 14px 10px; }
.figure-choices .choice svg { width: 60px; }
.choices.pattern-choices { grid-template-columns: 1fr; gap: 8px; }
.pattern-choices .choice { padding: 6px 10px; border-top-width: 5px; }
.pattern-choices .choice svg { width: min(100%, 300px); }

/* Nouveaux jeux de lecture */
.hunt-box svg .note { cursor: pointer; }
.staff.sliding .note { animation: slideToClef var(--slide, 5s) linear forwards; }
@keyframes slideToClef { from { transform: translateX(170px); } to { transform: translateX(0); } }
.memory { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(100%, 520px); }
.memory.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.memory-card {
  position: relative; aspect-ratio: 1 / 1.1; border: 0; border-radius: 14px; padding: 0;
  background: var(--world); box-shadow: 0 4px 0 color-mix(in srgb, var(--world) 65%, #000); color: var(--text);
}
.memory-back { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; color: #fff; }
.memory-face { position: absolute; inset: 0; display: none; place-items: center; background: var(--card); border-radius: 14px; padding: 4px; }
.memory-face svg { width: 100%; height: 100%; color: var(--text); }
.memory-card.open .memory-face { display: grid; animation: pop 0.25s; }
.memory-card.open .memory-back { display: none; }
.memory-card.matched .memory-face { box-shadow: inset 0 0 0 4px var(--good); }
.memory-name { font-size: 1.5rem; color: var(--c, var(--text)); }
.listen-btn.small { width: 84px; height: 84px; }
.listen-btn.small .listen-icon { font-size: 2rem; }
.listen-btn.small span:last-child { display: none; }
.lyric { font-size: 11px; font-weight: 700; fill: currentColor; font-family: var(--font); }
.ex-stage .seq-staff svg.score { width: 100%; max-width: 640px; }
.seq-tools { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
@media (max-height: 540px) and (orientation: landscape) {
  .ex-stage > .staff-box, .ex-stage > .place-box { flex: 1 1 0; min-height: 0; height: auto; }
  .memory { width: auto; height: auto; align-content: center; grid-template-columns: repeat(4, 74px); }
  .memory.n6 { grid-template-columns: repeat(3, 74px); }
  .memory-card { aspect-ratio: 1 / 1; }
}

/* Oreille */
.listen-btn {
  width: 150px; height: 150px; border-radius: 50%; border: 0; color: #fff; font-weight: 900;
  background: var(--world); box-shadow: 0 8px 0 color-mix(in srgb, var(--world) 65%, #000);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.listen-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 color-mix(in srgb, var(--world) 65%, #000); }
.listen-icon { font-size: 3.2rem; line-height: 1; }
.listen-btn.playing { animation: pulse 0.9s 2; }

/* Rythme */
.tap-score { width: min(100%, 540px); color: var(--text); }
.tap-score svg { width: 100%; height: auto; }
.tap-status { text-align: center; font-weight: 800; color: var(--muted); min-height: 1.4em; }
.countin { font-size: 3.4rem; font-weight: 900; color: var(--world); min-height: 1.2em; line-height: 1.2; }
.countin.beat { animation: pop 0.25s; }
.beat-num { font-size: 13px; font-weight: 800; fill: var(--muted); font-family: var(--font); }
.beat-num.active { fill: var(--world); font-size: 18px; }
.tap-mark.perfect { fill: #2e9d4f; }
.tap-mark.good { fill: #f5c518; }
.tap-mark.late { fill: #f29b11; }
.tap-mark.miss { fill: #e0393e; }
.tap-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.tap-pad {
  width: 100%; height: clamp(110px, 22vh, 180px); border: 0; border-radius: 28px; font-size: 4rem;
  background: var(--world); box-shadow: 0 8px 0 color-mix(in srgb, var(--world) 65%, #000);
  touch-action: manipulation;
}
.tap-pad.hit { animation: hit 0.15s; }

.countdown { font-size: 7rem; font-weight: 900; color: var(--world); animation: pop 0.3s; }

/* Retour après une réponse */
.ex-feedback {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0; transform: translateY(110%); transition: transform 0.22s ease-out;
}
.ex-feedback.show { transform: translateY(0); }
.ex-feedback.good { background: var(--good-soft); color: #146c2e; }
.ex-feedback.bad { background: var(--bad-soft); color: #a3221d; }
[data-theme='galaxie'] .ex-feedback.good { color: #b9f5cc; }
[data-theme='galaxie'] .ex-feedback.bad { color: #ffc9c4; }
.fb-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 1.05rem; }
.fb-text b { font-size: 1.3rem; }
.fb-actions { display: flex; gap: 8px; }
.ex-feedback.bad .btn.primary { background: var(--bad); box-shadow: 0 4px 0 #b3302c; }

/* ---------- Résultats ---------- */
.results { text-align: center; }
.results-head h1 { font-size: 2rem; margin: 6px 0; }
.big-stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.big-stars .star:nth-child(2) { transform: translateY(-14px); }
.big-stars .star.pop { animation: starPop 0.5s; }
.big-score { font-size: 5rem; font-weight: 900; color: var(--accent); line-height: 1; }
.gains { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.gain { background: var(--card); border-radius: 18px; padding: 12px 6px; box-shadow: 0 3px 0 var(--line); }
.gain b { display: flex; justify-content: center; align-items: center; gap: 2px; font-size: 1.4rem; }
.gain span { color: var(--muted); font-size: 0.85rem; }
.banner { background: var(--accent-2); border-radius: 16px; padding: 10px 14px; font-weight: 900; margin: 10px 0; animation: pop 0.4s; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.badge-row .badge { width: 160px; }
.results-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* ---------- Trophées, boutique, défis ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 16px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge {
  background: var(--card); border-radius: 18px; padding: 14px 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 3px 0 var(--line);
}
.badge.todo { opacity: 0.6; }
.badge.todo .badge-icon { filter: grayscale(1); color: var(--muted); }
.badge-icon { font-size: 2.4rem; line-height: 1.15; min-height: 1.15em; display: grid; place-items: center; }
.badge-icon svg.glyph { height: 1.1em; }
.badge small { color: var(--muted); font-size: 0.8rem; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.shop-item, .theme-item {
  background: var(--card); border: 3px solid transparent; border-radius: 18px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 3px 0 var(--line);
}
.shop-item.current, .theme-item.current { border-color: var(--accent); }
.shop-emoji { font-size: 2.6rem; line-height: 1.15; }
.shop-item:not(.owned) .shop-emoji { filter: saturate(0.6); }
.price { display: inline-flex; align-items: center; font-weight: 900; }
.price.too-much { color: var(--muted); }
.tag { font-size: 0.8rem; font-weight: 900; color: var(--accent); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.theme-swatch { width: 100%; height: 50px; border-radius: 12px; background: linear-gradient(135deg, var(--a), var(--b)); }

.challenge { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; }
.challenge:active:not(.locked) { transform: translateY(2px); }
.challenge.locked { opacity: 0.6; cursor: default; }
.challenge-icon {
  width: 54px; height: 54px; border-radius: 50%; flex: none; font-size: 1.8rem;
  display: grid; place-items: center; background: var(--accent-2);
}
.challenge-icon svg.glyph { height: 42px; }
.challenge-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.challenge-text b { font-size: 1.1rem; }
.record { font-weight: 900; white-space: nowrap; }

/* ---------- Sauvegarde sur le serveur ---------- */
.restore .row .input { flex: 1; min-width: 160px; }
.restore-list { display: flex; flex-direction: column; gap: 8px; }
.restore-item {
  display: flex; align-items: center; gap: 12px; text-align: left; border: 0; border-radius: 16px;
  padding: 10px 14px; background: var(--bg); box-shadow: 0 3px 0 var(--line);
}
.restore-item .profile-avatar { font-size: 2.2rem; }
.restore-text { display: flex; flex-direction: column; }

/* ---------- Espace parents ---------- */
.gate { max-width: 360px; margin: 30px auto; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.gate p { font-size: 1.2rem; margin: 0; }
.setting {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting > div:first-child { flex: 1; min-width: 200px; }
.setting small { display: block; margin-top: 2px; line-height: 1.35; }
.segmented { display: inline-flex; background: var(--bg); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 8px 12px; border-radius: 10px; font-weight: 800; color: var(--muted); }
.segmented button.on { background: var(--card); color: var(--accent); box-shadow: 0 2px 0 var(--line); }
.switch { position: relative; width: 54px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background 0.15s; cursor: pointer; }
.switch span::before {
  content: ''; position: absolute; width: 24px; height: 24px; left: 4px; top: 4px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.accuracy-staff { height: 150px; width: auto; color: var(--text); display: block; }
.note-label { font-size: 11px; font-weight: 800; fill: currentColor; font-family: var(--font); }
.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.piano-test { text-align: center; }
.test-note { font-size: 4.5rem; font-weight: 900; color: var(--accent); min-height: 1.3em; }
.test-note.pop { animation: pop 0.3s; }
.test-meter { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.test-meter i { display: block; height: 100%; width: calc(var(--lvl, 0) * 100%); background: var(--good); transition: width 0.06s; }

/* ---------- Effets ---------- */
.float-text {
  position: fixed; z-index: 50; transform: translateX(-50%); pointer-events: none;
  font-weight: 900; font-size: 1.4rem; color: var(--accent); animation: floatUp 1s ease-out forwards;
}
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: opacity 0.25s, transform 0.25s;
  background: #2b2340; color: #fff; padding: 10px 16px; border-radius: 14px; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; animation: confettiFall linear forwards; }
.shake { animation: shake 0.4s; }
.pop, .staff .note.pop { animation: pop 0.35s; transform-box: fill-box; transform-origin: center; }
.mascot { overflow: visible; }
.mascot.mood-happy, .mascot.mood-wow { animation: bounce 0.6s; }

@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes starPop { 0% { transform: scale(0.2) rotate(-30deg); } 60% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes hit { 50% { transform: translateY(5px) scale(0.97); box-shadow: 0 3px 0 color-mix(in srgb, var(--world) 65%, #000); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes timeShrink { to { transform: scaleX(0); } }
@keyframes floatUp { to { transform: translate(-50%, -60px); opacity: 0; } }
@keyframes confettiFall { to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Écrans larges et téléphones à l'horizontale ---------- */
@media (min-width: 640px) {
  .choices.n7 { grid-template-columns: repeat(7, 1fr); }
  .choices.n4 { grid-template-columns: repeat(4, 1fr); }
  .choices.pattern-choices { grid-template-columns: 1fr; }
  .ex-prompt { font-size: 1.5rem; }
  .level-node { --shift: 80px; }
}
@media (max-width: 380px) {
  .chip { padding: 5px 7px; }
  .avatar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Téléphone à l'horizontale : peu de hauteur, beaucoup de largeur. La portée se cale sur la
   hauteur disponible, le clavier prend toute la largeur, le message de réponse s'affiche en
   haut à droite pour laisser voir les touches. */
@media (max-height: 540px) and (orientation: landscape) {
  .ex-prompt { font-size: 1.05rem; padding-top: 6px; min-height: 1.2em; }
  .ex-stage { gap: 4px; }
  .ex-stage svg.staff, .ex-stage .staff-box svg, .ex-stage .place-box svg { height: 100%; width: auto; max-width: 100%; max-height: none; }
  .staff-box, .place-box { height: 100%; width: auto; max-width: 100%; justify-content: center; }
  .ex-stage .seq-staff { height: 100%; width: 100%; }
  .ex-stage .seq-staff svg.staff { width: auto; }
  .keyboard { height: 44vh; }
  .ex-answers { padding-bottom: 8px; }
  .choices { gap: 6px; }
  .choices.n7 { grid-template-columns: repeat(7, 1fr); }
  .choices.n4, .choices.long { grid-template-columns: repeat(4, 1fr); }
  .choice { padding: 8px 4px; font-size: 1.15rem; }
  .choice-icon { font-size: 1.4rem; }
  .listen-btn { width: 96px; height: 96px; }
  .listen-icon { font-size: 2.2rem; }
  .big-name { font-size: 3rem; }
  .big-figure, .big-rhythm, .big-symbol { max-height: 100%; width: auto; }
  .tap-pad { height: 26vh; font-size: 2.6rem; }
  .countin { font-size: 2rem; }
  .ex-feedback {
    left: auto; right: calc(10px + env(safe-area-inset-right)); bottom: auto; top: 8px;
    width: min(52%, 460px); border-radius: 20px; padding: 10px 14px; transform: translateY(-160%);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  }
  .ex-feedback.show { transform: translateY(0); }
  .ex-feedback .mascot { display: none; }
}
}
