/* Le Ciel Chantant — style « carnet de voyage » : parchemin, encre bleue, laiton et pierre volante. */
:root {
  --ink: #2c3650;
  --ink-soft: #5d6780;
  --parch: #f8f2e2;
  --parch-2: #efe4c8;
  --paper: #fffaf0;
  --line: #d6c49b;
  --line-soft: #e6dabd;
  --sky: #3d84ab;
  --sky-deep: #2a6283;
  --sky-pale: #e5f1f8;
  --gold: #e3a43c;
  --gold-deep: #c6782a;
  --green: #5b8d3c;
  --green-pale: #e7f1dc;
  --amber: #c98a1c;
  --red: #c4513d;
  --red-pale: #f8e3dc;
  --shadow: 0 18px 48px rgba(28, 44, 80, 0.28), 0 2px 6px rgba(28, 44, 80, 0.12);
  --radius: 22px;
  --font-title: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Nunito', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: #86bde6;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, textarea { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.muted { color: var(--ink-soft); }
sub { font-size: 0.62em; vertical-align: -0.15em; margin-left: 1px; opacity: 0.75; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- écrans ---------- */
main { position: fixed; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
  pointer-events: auto;
}
.screen.active { display: flex; animation: fade-in 0.35s ease both; }
#screen-none { display: none !important; }
.screen-dim { background: rgba(28, 40, 72, 0.32); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background:
    radial-gradient(120% 80% at 10% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, var(--parch), #f3ead3);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(255, 255, 255, 0.35);
}

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(120, 95, 50, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s;
}
.btn:hover { transform: translateY(-1px); border-color: #c4ac78; box-shadow: 0 4px 0 rgba(120, 95, 50, 0.22); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(120, 95, 50, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #4b95bd, var(--sky-deep));
  border-color: #23597a;
  color: #fffaf0;
  box-shadow: 0 3px 0 #1d4b67, inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover { border-color: #1d4b67; box-shadow: 0 5px 0 #1d4b67, inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.5); box-shadow: none; }
.btn-xl { min-height: 60px; font-size: 22px; }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.danger { color: var(--red); }
.link { background: none; border: 0; padding: 0; color: var(--sky-deep); font-weight: 800; text-decoration: underline; cursor: pointer; }
.btn-back {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-size: 20px; font-weight: 900;
  cursor: pointer;
}
.btn-back:hover { border-color: #c4ac78; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.row-actions.center { justify-content: center; }
.stack { display: grid; gap: 10px; margin-top: 18px; }

/* ---------- accueil ---------- */
.home {
  width: min(1180px, 100%);
  height: 100%;
  display: flex; flex-direction: column; justify-content: center; gap: 26px;
  padding: 0 clamp(8px, 4vw, 48px);
}
.home-title .kicker {
  margin: 0;
  font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px;
  color: #fffaf0; text-shadow: 0 1px 2px rgba(30, 50, 90, 0.4);
}
.home-title h1 {
  margin: 4px 0 6px;
  font-family: var(--font-title);
  font-style: italic; font-weight: 700;
  font-size: clamp(52px, 8.5vw, 104px);
  line-height: 0.95;
  color: #fffaf0;
  text-shadow: 0 2px 0 rgba(40, 70, 120, 0.35), 0 10px 34px rgba(30, 50, 90, 0.35);
}
.home-title .tagline {
  margin: 0; max-width: 32ch;
  font-size: clamp(17px, 2vw, 21px); font-weight: 700;
  color: #fffaf0; text-shadow: 0 1px 3px rgba(30, 50, 90, 0.45);
}
.home-menu {
  width: min(360px, 100%);
  padding: 20px;
  display: grid; gap: 10px;
}
.voice-pill { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); text-align: center; }

/* ---------- panneaux ---------- */
.panel {
  width: min(1040px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  padding: 18px 20px 20px;
}
.panel-wide { width: min(1180px, 100%); }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1.5px dashed var(--line); }
.panel-head h2 { margin: 0; flex: 1; font-family: var(--font-title); font-weight: 700; font-size: 32px; line-height: 1.1; }
.panel-scroll { overflow: auto; padding: 14px 4px 4px; margin: 0 -4px; }
.section-title { font-family: var(--font-title); font-size: 24px; margin: 22px 0 10px; }
.voice-chip {
  border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 800; color: var(--sky-deep); cursor: pointer;
}
.empty { color: var(--ink-soft); margin: 0; }

/* ---------- cartes de niveau ---------- */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.level-card {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px;
  padding: 12px 14px;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--line-soft);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s, box-shadow 0.12s;
}
.level-card:hover { transform: translateY(-2px); border-color: var(--sky); box-shadow: 0 8px 20px rgba(42, 98, 131, 0.16); }
.level-tile { background: var(--paper); border: 1.5px solid var(--line-soft); border-radius: 16px; overflow: hidden; }
.level-tile > .level-card { width: 100%; border: 0; border-radius: 0; background: transparent; }
.song-slot { margin: 0 12px 10px; padding-top: 9px; border-top: 1px solid var(--line-soft); }
.song-locked { margin: 0; color: var(--ink-soft); font-size: 13px; font-weight: 800; }
.song-locked small, .song-launch small { display: block; font-weight: 600; font-size: 12px; margin-top: 3px; }
.song-launch { width: 100%; display: flex; align-items: center; gap: 9px; text-align: left; background: #fff3c9; color: #72511b; border: 1px solid #d8b66b; border-radius: 10px; padding: 9px; cursor: pointer; }
.song-launch > span:first-child { font-size: 25px; }
.song-launch > span:nth-child(2) { flex: 1; }
.song-launch:hover { background: #ffe8a1; }
.song-launch .stars { flex: none; }
.res-unlock { padding: 12px; background: #fff0ba; border: 1px solid #d8b66b; border-radius: 12px; color: #72511b; font-weight: 900; }
.medal { --medal-face: #f2cb56; --medal-edge: #936b17; display: inline-flex; flex: none; flex-direction: column; align-items: center; color: var(--medal-edge); width: 42px; vertical-align: middle; }
.medal-silver { --medal-face: #d6e0e8; --medal-edge: #566b80; }
.medal-bronze { --medal-face: #d9a47a; --medal-edge: #80512e; }
.medal svg { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 2px 2px #48351622); }
.medal circle { fill: var(--medal-face); stroke: var(--medal-edge); stroke-width: 1.5; }
.medal .medal-inner { fill: none; stroke: #fff8; stroke-width: 2; }
.medal .medal-ribbon { fill: #477e99; stroke: #315c73; stroke-width: 1; }
.medal .medal-mark { fill: var(--medal-edge); stroke: #fffa; stroke-width: 0.6; }
.medal small { font-size: 11px; font-weight: 900; margin-top: 1px; }
.medal-large { width: 86px; }
.medal-large small { font-size: 18px; }
.medal-empty { font-size: 11px; color: var(--ink-soft); max-width: 70px; font-weight: 700; text-align: center; }
.res-stars .medal-empty { max-width: none; font-size: 16px; }
.lv-num {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 21px;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #bfeeff, #4fb6e6 45%, #23689a);
  box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px var(--line), 0 0 16px rgba(95, 208, 255, 0.45);
  text-shadow: 0 1px 2px rgba(20, 60, 100, 0.5);
}
.lv-num-custom { background: radial-gradient(circle at 35% 30%, #fff1c9, #e3a43c 50%, #a8641d); font-size: 22px; }
.lv-text { display: grid; gap: 2px; min-width: 0; }
.lv-title { font-weight: 900; font-size: 16px; }
.lv-sub { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.lv-notes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.lv-notes i {
  font-style: normal; font-weight: 800; font-size: 12px;
  padding: 1px 8px; border-radius: 999px;
  background: var(--sky-pale); color: var(--sky-deep);
}
.lv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lv-head .stars { flex: none; margin-top: 1px; }
.lv-sub b { color: var(--gold-deep); font-weight: 800; }
.stars { display: inline-flex; gap: 1px; }
.star { width: 18px; height: 18px; fill: #e2d8c0; }
.star.on { fill: var(--gold); filter: drop-shadow(0 1px 0 rgba(150, 90, 20, 0.5)); }

/* ---------- calibration ---------- */
.calib .panel-head { row-gap: 10px; }
.steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--ink-soft); padding: 4px 10px 4px 4px; border-radius: 999px; }
.steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--parch-2); font-size: 12px; }
.steps li.current { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.steps li.current span { background: var(--sky-deep); color: #fff; }
.steps li.done span { background: var(--green); color: #fff; }
.calib-body { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; padding-top: 16px; overflow: auto; }
.calib-step h3 { margin: 0 0 6px; font-family: var(--font-title); font-size: 28px; line-height: 1.15; }
.calib-step p { margin: 0 0 12px; }
.calib-monitor { display: grid; grid-template-rows: 1fr auto; gap: 8px; min-height: 300px; }
#monitor { width: 100%; height: 100%; min-height: 280px; border-radius: 16px; border: 1.5px solid var(--line); background: #cfe3f1; touch-action: none; }
.monitor-read { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--ink-soft); font-weight: 700; padding: 0 4px; }
.monitor-read b { font-size: 22px; color: var(--ink); }
.monitor-read small { font-size: 12px; color: var(--ink-soft); }
.voice-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 4px; }
.voice-card {
  display: grid; gap: 2px; text-align: left;
  padding: 14px; border-radius: 16px;
  border: 1.5px solid var(--line-soft); background: var(--paper);
  cursor: pointer; transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.voice-card:hover { transform: translateY(-2px); border-color: var(--sky); }
.voice-card b { font-size: 17px; }
.voice-card span { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.voice-card em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--sky-deep); margin-top: 6px; }
.voice-card.selected { border-color: var(--sky-deep); background: var(--sky-pale); box-shadow: inset 0 0 0 1.5px var(--sky-deep); }
.meter-big { height: 16px; border-radius: 999px; background: var(--parch-2); overflow: hidden; box-shadow: inset 0 1px 2px rgba(80, 60, 30, 0.2); margin: 14px 0 8px; }
.meter-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #8cc56d, var(--green)); transition: width 0.1s linear; }
.status-line { font-weight: 700; min-height: 1.5em; }
.range-line { font-size: 17px; }
.note-box, .error-box, .ok-box { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 10px 0; }
.note-box { background: #fff4d6; border: 1px solid #ecd28f; }
.error-box { background: var(--red-pale); border: 1px solid #e7b2a4; color: #7a2c1f; }
.ok-box { background: var(--green-pale); border: 1px solid #bcd6a6; }
.note-box ul, .error-box ul, .ok-box ul { margin: 6px 0 0; padding-left: 18px; }
.ok-box li { margin: 4px 0; }
.ok-box .lv-notes { display: inline-flex; margin: 0 0 0 4px; vertical-align: middle; }

/* ---------- champs ---------- */
.field { display: grid; gap: 6px; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-weight: 800; padding: 0; }
.field > span em { font-style: normal; font-weight: 600; color: var(--ink-soft); }
.field small { color: var(--ink-soft); font-size: 13px; }
.field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 14px; }
select, textarea {
  width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--paper);
  padding: 10px 12px;
}
select { min-height: 44px; }
textarea { min-height: 220px; resize: vertical; font-size: 13px; line-height: 1.5; tab-size: 2; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row small { font-weight: 700; }
input[type=range] { flex: 1; accent-color: var(--sky-deep); height: 28px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span {
  display: grid; padding: 8px 16px; border-radius: 14px;
  border: 1.5px solid var(--line-soft); background: var(--paper);
  font-weight: 800; cursor: pointer; line-height: 1.2;
}
.seg span small { font-weight: 600; font-size: 12px; color: var(--ink-soft); }
.seg input:checked + span { border-color: var(--sky-deep); background: var(--sky-pale); box-shadow: inset 0 0 0 1.5px var(--sky-deep); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.toggle { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; cursor: pointer; font-weight: 700; }
.toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 26px; border-radius: 999px; background: #d8ccb0; position: relative; cursor: pointer; transition: background 0.15s; margin: 0; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.toggle input:checked { background: var(--sky-deep); }
.toggle input:checked::after { transform: translateX(20px); }
.toggle small { font-weight: 600; color: var(--ink-soft); }
.settings { max-width: 640px; }
.voice-line { margin: 0; font-weight: 700; color: var(--ink-soft); }

/* ---------- espace professeur ---------- */
.teacher-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.teacher-col h3 { font-family: var(--font-title); font-size: 24px; margin: 4px 0 10px; }
.teacher-col h3 + * { margin-top: 0; }
.teacher-col > h3:not(:first-child) { margin-top: 24px; }
.dropzone {
  border: 2px dashed #c9b27f; border-radius: 16px;
  padding: 16px; text-align: center;
  background: rgba(255, 250, 240, 0.6);
  margin-bottom: 14px;
  transition: background 0.12s, border-color 0.12s;
}
.dropzone p { margin: 0 0 10px; }
.dropzone.over { background: var(--sky-pale); border-color: var(--sky); }
.json-feedback:empty { display: none; }
.custom-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.custom-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--paper); border: 1.5px solid var(--line-soft); }
.ci-text { display: grid; gap: 2px; min-width: 0; }
.ci-text small { color: var(--ink-soft); font-weight: 600; }
.ci-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.doc { font-size: 14px; }
.doc p { margin: 0 0 10px; }
.doc pre { background: #2f3850; color: #f3ead3; border-radius: 12px; padding: 12px 14px; overflow: auto; font-size: 13px; margin: 0 0 12px; }
.doc code { font-size: 0.92em; }
.doc :not(pre) > code { background: rgba(214, 196, 155, 0.35); padding: 1px 5px; border-radius: 5px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.doc-table th, .doc-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.doc-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }

/* ---------- HUD ---------- */
.hud { position: fixed; top: 0; left: 0; right: 0; padding: 10px 12px 0; pointer-events: none; z-index: 5; }
.hud[hidden] { display: none; }
.hud-bar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: 1100px; margin: 0 auto;
  padding: 6px 8px 6px 14px;
  background: rgba(250, 244, 228, 0.93);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(28, 44, 80, 0.2);
}
.hud-score { display: flex; align-items: center; gap: 7px; font-size: 22px; font-weight: 900; min-width: 62px; }
.hud-score.bump b { animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--sky-deep); } }
.hud-score b { display: inline-block; }
.collect-star-ico {
  display: inline-block; width: 24px; height: 24px; flex: none;
  background: linear-gradient(135deg, #fff3a0, #ffd447 48%, #e5a213);
  clip-path: polygon(50% 0, 63% 32%, 98% 35%, 73% 59%, 80% 96%, 50% 77%, 20% 96%, 27% 59%, 2% 35%, 37% 32%);
  filter: drop-shadow(0 0 4px rgba(255, 209, 62, 0.8));
}
.collect-star-ico.big { width: 36px; height: 36px; }
.hud-lives { display: flex; gap: 3px; }
.heart svg { width: 22px; height: 20px; display: block; fill: #df5745; stroke: #8f2e22; stroke-width: 1.2; transition: fill 0.3s; }
.heart.lost svg { fill: #d9cfba; stroke: #b5a888; }
.heart.pop { animation: pop 0.5s ease; }
@keyframes pop { 30% { transform: scale(1.5) rotate(-10deg); } 100% { transform: scale(1); } }
.hud-note {
  display: grid; justify-items: center; line-height: 1;
  min-width: 70px; padding: 4px 10px 6px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.55);
  border: 1.5px solid var(--line-soft);
}
.hud-note small { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 2px; }
.hud-note b { font-size: 21px; font-weight: 900; white-space: nowrap; }
.hud-note.sung b { color: var(--ink-soft); }
.hud-note.sung.on b { color: var(--sky-deep); }
.hud-note.target { background: #fff3cf; border-color: #e6c77e; }
.hud-tuner { flex: 1; display: grid; gap: 4px; min-width: 120px; }
.tuner-track { position: relative; height: 12px; border-radius: 999px; background: linear-gradient(90deg, #efb07a, #f4dfae 30%, #f4dfae 70%, #efb07a); box-shadow: inset 0 1px 2px rgba(80, 60, 30, 0.25); }
.tuner-zone { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); border-radius: 999px; background: rgba(91, 141, 60, 0.75); }
.tuner-mid { position: absolute; top: -3px; bottom: -3px; left: 50%; width: 2px; margin-left: -1px; background: rgba(44, 54, 80, 0.5); }
.tuner-needle { position: absolute; top: -5px; width: 8px; height: 22px; margin-left: -4px; border-radius: 4px; background: var(--ink); box-shadow: 0 0 0 2px #fff; transition: left 0.06s linear, opacity 0.2s; }
.tuner-needle.hidden { opacity: 0.2; }
.tuner-text { text-align: center; font-size: 13px; font-weight: 900; min-height: 1.2em; color: var(--ink-soft); }
.tuner-text.ok { color: var(--green); }
.tuner-text.near { color: var(--amber); }
.tuner-text.far { color: var(--red); }
.hud-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--paper); cursor: pointer; display: grid; place-items: center; }
.hud-btn svg { width: 18px; height: 18px; fill: var(--ink); }
.hud-progress { max-width: 1060px; margin: 6px auto 0; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.45); overflow: hidden; }
.hud-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #bfeeff, #4fb6e6); border-radius: inherit; transition: width 0.4s ease; }

.countdown {
  position: fixed; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title); font-weight: 700; font-style: italic;
  font-size: clamp(64px, 12vw, 140px);
  color: var(--sky-deep);
  -webkit-text-stroke: 8px #fffaf0;
  paint-order: stroke fill;
  text-shadow: 0 6px 24px rgba(30, 50, 90, 0.35);
  pointer-events: none; opacity: 0; z-index: 6; white-space: nowrap;
}
.countdown.show { animation: count 0.95s ease forwards; }
@keyframes count {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
}
.banner {
  position: fixed; left: 50%; top: 104px; transform: translate(-50%, -10px);
  max-width: calc(100% - 32px);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(250, 244, 228, 0.95);
  border: 1.5px solid var(--line);
  box-shadow: 0 8px 22px rgba(28, 44, 80, 0.2);
  font-weight: 900; font-size: 17px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s; z-index: 6;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner[data-kind=win] { color: var(--green); }
.banner[data-kind=lose] { color: var(--red); }
.rotate-hint { display: none; }

/* ---------- pause & résultats ---------- */
.small-card { width: min(360px, 100%); padding: 26px; text-align: center; }
.small-card h2 { margin: 0; font-family: var(--font-title); font-size: 40px; }
.small-card p { margin: 4px 0 0; }
.results-card {
  position: relative;
  width: min(660px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 50px 26px 22px;
  margin-top: 18px;
  text-align: center;
}
.ribbon {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -2px);
  min-width: 300px;
  padding: 10px 46px 12px;
  background: linear-gradient(180deg, #6aa147, #4d7f31);
  color: #fffaf0;
  font-family: var(--font-title); font-weight: 700; font-size: 28px; line-height: 1;
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.results-card.lose .ribbon { background: linear-gradient(180deg, #d98a5a, #b9643a); }
.res-stars { display: flex; justify-content: center; margin: 4px 0 2px; }
.res-stars .stars { gap: 8px; align-items: flex-end; }
.res-stars .star { width: 50px; height: 50px; }
.res-stars .star:nth-child(2) { width: 64px; height: 64px; }
.res-stars .star.on { animation: star-in 0.5s ease both; }
.res-stars .star.on:nth-child(2) { animation-delay: 0.15s; }
.res-stars .star.on:nth-child(3) { animation-delay: 0.3s; }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.2); } to { transform: none; } }
.res-score { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; }
.res-score b { font-size: 48px; color: var(--gold-deep); line-height: 1; }
.res-score span:last-child { font-size: 20px; color: var(--ink-soft); }
.res-record { margin: 6px 0 0; font-weight: 900; color: var(--gold-deep); }
.res-message { margin: 8px auto 4px; font-weight: 700; max-width: 46ch; }
.res-meta { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); }
.res-meta b { color: var(--ink); }
.res-table-wrap { border-radius: 14px; border: 1.5px solid var(--line-soft); overflow: hidden; background: rgba(255, 250, 240, 0.7); }
.res-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.res-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); padding: 8px 6px; background: var(--parch-2); }
.res-table td { padding: 6px; border-top: 1px solid var(--line-soft); font-weight: 700; }
.res-table .good { color: var(--green); }
.res-table .mid { color: var(--amber); }
.res-table .bad { color: var(--red); }

/* ---------- modale & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(28, 40, 72, 0.4); }
.modal[hidden] { display: none; }
.modal-card { width: min(460px, 100%); padding: 22px 24px; }
.modal-card h2 { margin: 0 0 8px; font-family: var(--font-title); font-size: 30px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 30;
  transform: translate(-50%, 20px);
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 20px; border-radius: 16px;
  background: rgba(44, 54, 80, 0.94); color: #fffaf0;
  font-weight: 700; font-size: 15px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- petits écrans ---------- */
@media (max-width: 860px) {
  .calib-body, .teacher-grid { grid-template-columns: 1fr; }
  .calib-monitor { min-height: 240px; }
  #monitor { min-height: 220px; }
  .voice-cards { grid-template-columns: 1fr; }
  .hud-bar { gap: 8px; padding: 5px 6px 5px 10px; }
  .hud-note { min-width: 56px; padding: 3px 6px 5px; }
  .hud-note small { display: none; }
  .hud-note b { font-size: 18px; }
  .heart svg { width: 18px; height: 16px; }
  .hud-score { font-size: 18px; min-width: 48px; }
}
@media (max-width: 560px) {
  .panel { padding: 14px 14px 16px; }
  .panel-head h2 { font-size: 26px; }
  .level-grid { grid-template-columns: 1fr; }
  .hud-lives { display: none; }
  .tuner-text { font-size: 11px; }
  .ribbon { min-width: 240px; font-size: 24px; }
  .res-table th:last-child, .res-table td:last-child { display: none; }
}
@media (max-height: 520px) {
  .home { gap: 10px; }
  .home-title .kicker { display: none; }
  .home-title h1 { font-size: 50px; }
  .home-title .tagline { font-size: 15px; max-width: none; }
  .home-menu { padding: 12px; gap: 8px; width: min(520px, 100%); grid-template-columns: 1fr 1fr; }
  .home-menu .btn-xl, .voice-pill { grid-column: 1 / -1; }
  .hud { padding-top: 6px; }
  .btn-xl { min-height: 48px; font-size: 19px; }
  .btn { min-height: 40px; }
  .banner { top: 80px; }
}
@media (orientation: portrait) and (max-width: 700px) {
  body[data-screen=none] .rotate-hint {
    display: block; position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
    padding: 8px 16px; border-radius: 999px; z-index: 7;
    background: rgba(44, 54, 80, 0.9); color: #fffaf0; font-weight: 700; font-size: 13px; white-space: nowrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  .screen.active, .countdown.show, .res-stars .star.on, .heart.pop { animation-duration: 0.01s; }
}

/* ---------- premier envol ---------- */
.adult-menu summary, .tutorial-help summary { cursor: pointer; font-weight: 800; color: var(--sky-deep); padding: 8px 0; }
.adult-menu .stack { margin: 4px 0 0; }
.home-menu { max-height: 60dvh; overflow: auto; }
.tutorial-panel { width: min(1200px, 100%); }
.tutorial-body { display: grid; grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr); gap: 24px; overflow: auto; padding-top: 18px; }
.tutorial-coach h3 { font-family: var(--font-title); font-size: 32px; line-height: 1.1; margin: 0 0 12px; }
.tutorial-coach p { margin: 0 0 12px; }
.tutorial-playground { min-width: 0; align-self: start; }
#tutorial-canvas { width: 100%; aspect-ratio: 720 / 440; display: block; border: 2px solid var(--line); border-radius: 20px; touch-action: none; }
#tutorial-feedback { font-weight: 900; text-align: center; padding: 12px; margin: 8px 0 0; border-radius: 14px; background: var(--sky-pale); min-height: 3em; }
.tutorial-count { color: var(--green); font-weight: 900; font-size: 20px; }
.tutorial-flight { margin-top: 20px; }
.tutorial-flight .seg span { padding: 12px; }
.tutorial-coach .row-actions { margin-bottom: 16px; }
.difficulty-panel { width: min(940px, 100%); overflow: auto; }
.difficulty-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 12px 0; }
.difficulty-choices .voice-card { min-height: 155px; align-content: start; gap: 10px; padding: 22px; }
@media (max-width: 760px) {
  .tutorial-body { grid-template-columns: 1fr; gap: 14px; }
  .tutorial-playground { grid-row: 1; }
  #tutorial-canvas { max-height: 35dvh; }
  .difficulty-choices { grid-template-columns: 1fr; }
  .difficulty-choices .voice-card { min-height: auto; padding: 16px; }
}
@media (max-height: 520px) and (min-width: 761px) {
  .tutorial-body { gap: 16px; }
  .tutorial-coach h3 { font-size: 26px; }
  .tutorial-coach p { font-size: 14px; margin-bottom: 8px; }
  .tutorial-playground { position: sticky; top: 0; }
  .home-menu { max-height: 48dvh; }
}
@media (max-width: 760px) {
  .tutorial-playground { position: sticky; top: 0; z-index: 1; background: var(--parch); padding-bottom: 4px; }
  #tutorial-feedback { font-size: 14px; padding: 8px; }
}

/* ---------- joueurs ---------- */
.players-panel { width: min(880px, 100%); }
.new-player-panel { width: min(540px, 100%); overflow: auto; }
.players-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.player-card-wrap { position: relative; display: flex; }
.player-card-wrap .player-card { width: 100%; padding-right: 36px; }
.player-card { grid-template-columns: auto 1fr; align-items: center; min-height: 100px; }
.player-card b, .player-card > span:last-child { overflow-wrap: anywhere; }
.player-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s;
  z-index: 2;
}
.player-del:hover, .player-del:focus-visible {
  background: #fde8e8;
  color: #c53030;
  border-color: #f87171;
  transform: scale(1.1);
}
.player-avatar { grid-row: span 2; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--sky-pale); color: var(--sky-deep) !important; font-size: 30px !important; }
.player-greeting { margin: 0; text-align: center; font-weight: 900; overflow-wrap: anywhere; }
#player-name { width: 100%; min-height: 52px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper); font-size: 22px; }
.account-local { font-size: 13px; margin: 18px 0 0; }
#levels-title, #difficulty-title, #tutorial-title { min-width: 0; overflow-wrap: anywhere; }

.hud-piano { width: auto; min-width: 80px; padding: 0 12px; border-radius: 14px; font-size: 13px; font-weight: 900; white-space: nowrap; }
.hud-piano[aria-pressed="false"] { background: var(--parch-2); color: var(--ink-soft); }
.hud-speed {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--line-soft);
  border-radius: 14px;
  padding: 2px 4px;
  flex: none;
}
.hud-speed-btn {
  width: auto;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: var(--paper);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
}
.hud-speed-btn:hover:not(:disabled) {
  background: #ffffff;
  transform: scale(1.05);
}
.hud-speed-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.hud-speed-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.hud-speed-val {
  min-width: 32px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
  user-select: none;
}
.level-mode { padding: 4px 0 12px; }
.level-mode .seg label { flex: 1; min-width: 220px; }
.level-mode .seg span { min-height: 64px; gap: 5px; padding: 12px 16px; }
@media (max-width: 560px) {
  .hud-bar { gap: 5px; }
  .hud-piano { min-width: 62px; padding: 0 7px; font-size: 11px; }
  .hud-tuner { min-width: 65px; }
}
@media (max-width: 560px) {
  .hud-bar { display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 5px; }
  .hud-score { grid-column: 1; grid-row: 1; }
  .hud-note.sung { grid-column: 2; grid-row: 1; }
  .hud-note.target { grid-column: 3; grid-row: 1; }
  .hud-piano { grid-column: 4; grid-row: 1; }
  .hud-speed { grid-column: 1 / 4; grid-row: 3; justify-self: start; padding: 1px 3px; gap: 2px; }
  .hud-speed-btn { min-width: 28px; height: 28px; padding: 0 4px; font-size: 11px; }
  .hud-speed-val { min-width: 26px; font-size: 11px; }
  #btn-music { grid-column: 4 / -1; grid-row: 3; justify-self: end; min-height: 30px; height: auto; padding: 5px 10px; }
  #btn-pause { grid-column: 5; grid-row: 1; }
  .hud-tuner { grid-column: 1 / -1; grid-row: 2; padding: 2px 4px 0; }
}

/* Les étoiles récoltées restent visibles pendant leur envol vers la barre de score. */
#collect-fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 8; }

/* Chantier 2 : Tessiture directe & enregistrement prénom fin de partie */
.level-voice { padding: 4px 0 10px; }
.voice-presets-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.voice-preset-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line-soft);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.voice-preset-btn:hover {
  transform: translateY(-2px);
  border-color: var(--sky);
}
.voice-preset-btn .vp-ico {
  font-size: 24px;
  line-height: 1;
}
.voice-preset-btn .vp-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.voice-preset-btn b {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.voice-preset-btn small {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.voice-preset-btn.selected {
  border-color: var(--sky-deep);
  background: var(--sky-pale);
  box-shadow: inset 0 0 0 1.5px var(--sky-deep);
}

.pitch-toggle-btn {
  font-weight: 700;
  transition: all 0.15s ease;
}
.pitch-toggle-btn.baroque {
  background: var(--gold-pale, #fff6db);
  color: #7c4f00;
  border-color: #c8962e;
  box-shadow: 0 0 0 1px #c8962e;
}

.res-save-player {
  background: var(--paper);
  border: 1.5px solid var(--line-soft);
  border-radius: 18px;
  padding: 16px;
  margin: 14px 0 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.rsp-head b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 2px;
}
.rsp-head p {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.rsp-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.rsp-form input {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  font-size: 14px;
  font-family: inherit;
  width: min(220px, 100%);
  background: var(--paper);
  color: var(--ink);
}
.rsp-form input:focus {
  border-color: var(--sky);
  outline: none;
}
.rsp-existing {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
}
.rsp-or {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 6px;
}
.rsp-badges {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.rsp-badge {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s;
}
.rsp-badge:hover {
  background: var(--sky-pale);
  border-color: var(--sky-deep);
}

@media (max-width: 680px) {
  .voice-presets-row { grid-template-columns: 1fr; }
  .voice-preset-btn { padding: 8px 12px; }
}
