/* ==========================================================================
   MelodySuite · Jeux
   Styles communs aux jeux : mise en page plein écran, cartes retournables,
   échelle des notes, bandeau des joueurs, effets, fenêtres.
   ========================================================================== */

:root {
  /* Palette accordée au fond illustré : eau turquoise, feuilles de lotus. */
  --bg-1: #dff6f2;
  --bg-2: #bfe9ef;
  --ink: #15384a;
  --muted: #5b7a86;
  --panel: #ffffff;
  --glass: rgba(246, 255, 253, .82);
  --line: #cfe6e6;
  --accent: #1b8fa8;
  --accent-ink: #ffffff;
  --good: #1a9c4a;
  --bad: #d62d20;
  --radius: 16px;
  --shadow: 0 6px 18px rgba(8, 72, 92, .2);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.game {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  /* Fond illustré ; taille et position sont recalculées par ui/backdrop.js pour
     amener le bateau dans le coin bas droit (valeurs CSS = repli). */
  background: url("../img/fond-memory.webp") 72% 88% / cover no-repeat, linear-gradient(160deg, var(--bg-1), var(--bg-2));
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ───────────── En-tête ───────────── */
.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(240, 253, 250, .72);
  border-bottom: 1px solid rgba(255, 255, 255, .6);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}
.game-header h1 { font-size: 1.15rem; margin: 0; }
/* Icônes dessinées (ui/icons.js) : alignées sur le texte qui les entoure. */
.ico { display: inline-block; vertical-align: -.25em; flex: none; overflow: visible; }
.hd-back { display: inline-flex; text-decoration: none; font-size: 1.4rem; opacity: .8; }
.hd-back:hover { opacity: 1; }
.hd-spacer { flex: 1; }
.hd-level { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; }
.hd-level .ico { width: 1.6em; height: 1.6em; }
.hd-info { color: var(--muted); font-size: .9rem; }
.hd-info .pen { color: var(--bad); letter-spacing: 2px; }
.hd-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.3rem; padding: 2px 10px; border-radius: 999px; background: var(--glass); box-shadow: var(--shadow); }
.hd-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.hd-btn:hover { background: #f4f4ff; }
.hd-action { border: 0; background: var(--bad); color: #fff; font-weight: 800; padding: 6px 16px; border-radius: 999px; cursor: pointer; box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 65%, #000); }
.hd-action:active { transform: translateY(2px); box-shadow: none; }

/* ───────────── Zone de jeu ───────────── */
.game-main {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  grid-template-areas: "board players" "scale players";
  min-height: 0;
  gap: 16px;
  padding: 16px;
}
.board { grid-area: board; position: relative; min-width: 0; min-height: 0; }
.players-host { grid-area: players; }
.scale-host { grid-area: scale; min-width: 0; }
.scale-host:empty { display: none; }

/* ───────────── Grille de cartes ───────────── */
.card-grid {
  display: grid;
  gap: var(--gap, 12px);
  justify-content: center;
  align-content: center;
  height: 100%;
}
.fc {
  width: var(--card-w);
  height: var(--card-h);
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fc.is-locked, .card-grid.is-locked .fc { cursor: default; }
.fc.is-gone { visibility: hidden; pointer-events: none; }
.fc.is-new { animation: card-in .45s cubic-bezier(.3, .7, .3, 1.4); }
@keyframes card-in { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }
.fc-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform .45s cubic-bezier(.3, .7, .3, 1.2);
  transform-style: preserve-3d;
}
.fc.is-up .fc-inner { transform: rotateY(180deg); }
.fc:not(.is-up):not(.is-locked):hover .fc-inner { transform: translateY(-4px) rotate(-1deg); }
.fc:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }
.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* Dos : la couleur de l'étoile du niveau, en aquarelle comme le décor —
   nervures rayonnantes de feuille de lotus, lumière venue d'en haut, bord
   assombri vers le turquoise de l'eau. */
.fc-back {
  /* Teinte de l'étoile adoucie vers le turquoise de l'eau, légèrement translucide. */
  --soft: color-mix(in oklab, var(--back) 80%, #8fded5);
  --tint: color-mix(in oklab, var(--soft) 70%, #ffffff);
  --deep: color-mix(in oklab, var(--back) 62%, #0b5d6e);
  background:
    radial-gradient(ellipse 70% 55% at 30% 18%, rgba(255, 255, 255, .5), transparent 70%),
    repeating-conic-gradient(from 8deg at 50% 50%, rgba(255, 255, 255, .22) 0deg 1.4deg, transparent 1.4deg 24deg),
    radial-gradient(circle at 50% 50%, color-mix(in oklab, var(--tint) 92%, transparent) 0%, color-mix(in oklab, var(--soft) 90%, transparent) 55%, color-mix(in oklab, var(--deep) 92%, transparent) 100%);
  border: 2px solid rgba(255, 255, 255, .7);
}
/* Teinte pure : pas de mélange avec le turquoise, qui ternirait la couleur. */
.card-grid.is-vivid .fc-back {
  --soft: var(--back);
  --tint: color-mix(in oklab, var(--back) 82%, #ffffff);
  --deep: color-mix(in oklab, var(--back) 78%, #5c0010);
}
.card-grid.is-metal .fc-back {
  background:
    radial-gradient(ellipse 70% 55% at 30% 18%, rgba(255, 255, 255, .55), transparent 70%),
    repeating-conic-gradient(from 8deg at 50% 50%, rgba(255, 255, 255, .28) 0deg 1.4deg, transparent 1.4deg 24deg),
    linear-gradient(135deg, var(--back) 0%, var(--back-shine) 30%, var(--back) 50%, var(--back-shine) 72%, var(--back) 100%);
}
.fc-star { display: block; width: 44%; height: 44%; filter: drop-shadow(0 2px 3px rgba(8, 72, 92, .35)); }
/* Face : papier clair légèrement teinté d'eau. */
.fc-front { transform: rotateY(180deg); background: linear-gradient(170deg, #ffffff, #effaf8); padding: 5%; border: 2px solid rgba(255, 255, 255, .9); }
.fc-front svg { display: block; }
.fc.is-glow .fc-front { border-color: #ffc83d; box-shadow: 0 0 0 4px rgba(255, 200, 61, .45), var(--shadow); animation: glow 1s ease-in-out infinite alternate; }
.fc.is-wrong .fc-front { border-color: var(--bad); }
@keyframes glow { to { box-shadow: 0 0 0 9px rgba(255, 200, 61, .2), var(--shadow); } }

/* Carte « nom de note » */
.name-card {
  font-size: calc(var(--card-h) * .3);
  font-weight: 900;
  color: var(--nc);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .08);
  letter-spacing: .02em;
}

/* ───────────── Échelle des notes (bas de l'écran, do à gauche → si à droite) ───────────── */
.note-scale { display: flex; flex-direction: column; gap: 6px; width: min(980px, 100%); margin: 0 auto; }
.ns-prompt { align-self: center; margin: 0; min-height: 1.4em; padding: 2px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(6px); font-weight: 700; text-align: center; font-size: 1rem; }
.ns-prompt:empty { visibility: hidden; }
.ns-rungs { display: flex; flex-direction: row-reverse; gap: 8px; }
.ns-btn {
  position: relative;
  flex: 1;
  min-width: 0;
  height: clamp(54px, 9vh, 76px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  border: 0;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  border-bottom: 9px solid var(--nc);
  box-shadow: var(--shadow);
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, background .2s, opacity .2s;
}
.ns-btn:hover:not(:disabled) { transform: translateY(-4px); background: color-mix(in srgb, var(--nc) 12%, #fff); }
.ns-btn:active:not(:disabled) { transform: scale(.97); }
.ns-key { font-size: .7rem; color: var(--muted); font-weight: 600; line-height: 1; }
/* Désactivée : grisée mais opaque, pour rester lisible sur le fond illustré. */
.note-scale.is-disabled .ns-btn { color: #8fa9b1; border-bottom-color: color-mix(in srgb, var(--nc) 35%, #fff); cursor: default; }
.ns-btn.is-right { animation: right .7s ease-out; }
.ns-btn.is-wrong { animation: wrong .5s ease-in-out; }
@keyframes right { 30% { background: #c9f2d6; transform: scale(1.06); } }
@keyframes wrong { 20% { transform: translateX(-8px); background: #ffd5d1; } 50% { transform: translateX(8px); } 80% { transform: translateX(-4px); } }

/* ───────────── Joueurs (colonne de droite) ───────────── */
/* La colonne défile (7 joueurs) : la marge intérieure laisse la place au décalage
   du joueur actif, à son badge « À toi ! » et aux ombres, sinon rognés. */
.players-host { width: 216px; min-height: 0; overflow-y: auto; padding: 16px 14px 16px 16px; margin: -16px -14px 0 0; }
.player-bar { display: flex; flex-direction: column; gap: 12px; }
.pb-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  border: 3px solid color-mix(in srgb, var(--pc) 35%, #fff);
  box-shadow: var(--shadow);
  transition: transform .25s, border-color .25s, background .25s;
}
.pb-chip.is-active { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, #fff); transform: translateX(-6px) scale(1.04); }
.pb-basket { width: 2.4rem; height: 2.4rem; padding: 3px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--pc) 18%, #fff); }
.pb-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
/* Noms de binômes : deux lignes au plus. */
.pb-name { font-weight: 800; color: var(--pc); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.1; }
.pb-stat { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pb-turn { display: none; position: absolute; top: -12px; right: -6px; background: var(--pc); color: #fff; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.pb-chip.is-active .pb-turn { display: block; animation: bob 1s ease-in-out infinite alternate; }
.pb-chip.is-bump { animation: bump .5s ease-out; }
@keyframes bob { to { transform: translateY(-3px); } }
@keyframes bump { 40% { transform: translateY(-8px) scale(1.15); } }

/* ───────────── Effets ───────────── */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1000; overflow: hidden; }
.fx-particle { position: absolute; line-height: 0; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .18)); }
.fx-shard { position: absolute; border-radius: 2px; }
.fx-float { position: absolute; font-weight: 900; font-size: 2rem; text-shadow: 0 2px 0 #fff, 0 3px 8px rgba(0, 0, 0, .2); white-space: nowrap; }
.fx-flying { pointer-events: none; z-index: 1; }
.fx-flying .fc-inner { transition: none; }

/* ───────────── Fenêtres ───────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 60, 75, .3);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}
.panel { background: var(--panel); border-radius: 20px; box-shadow: 0 20px 60px rgba(30, 30, 80, .3); padding: 22px 26px; width: min(760px, 100%); }
.panel h2 { margin: 0 0 12px; }
.announce { text-align: center; width: min(460px, 100%); animation: pop-in .35s cubic-bezier(.3, .7, .3, 1.3); }
.announce h2 { font-size: 1.6rem; }
.announce-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
@keyframes pop-in { from { transform: scale(.8); opacity: 0; } }

.btn { border: 0; border-radius: 999px; padding: 10px 22px; font-weight: 800; cursor: pointer; background: #eef0fb; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.btn:active { transform: translateY(2px); }

/* Réglages */
.setup fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.setup legend { font-weight: 800; margin-bottom: 8px; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tiles { display: grid; gap: 8px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tiles.stars { grid-template-columns: repeat(6, 1fr); margin-top: 10px; }
.tile { position: relative; cursor: pointer; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile > span { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fafaff; transition: border-color .15s, background .15s; }
.tile small { color: var(--muted); font-size: .8rem; }
.tile input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, #fff); }
.tile input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.star-tile > span { align-items: center; text-align: center; padding: 8px 4px; }
.star-tile .star .ico { width: 2.2rem; height: 2.2rem; }
.star-tile b { font-size: .8rem; }
.star-tile small { white-space: pre-line; } /* Sol + Fa : une étendue par ligne */
.star-tile input:checked + span { border-color: var(--lc); background: color-mix(in srgb, var(--lc) 12%, #fff); }

.seg { display: flex; flex-wrap: wrap; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg label { flex: 1; cursor: pointer; text-align: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 10px; font-weight: 700; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }
.seg.count label { flex: 0 0 auto; min-width: 44px; }

.sub { margin-top: 10px; display: grid; gap: 10px; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.row label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.row input[type="number"] { width: 64px; }
.setup input[type="number"], .setup input[type="text"], .setup select { padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.hint.warn { color: var(--bad); }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.names label { display: flex; align-items: center; gap: 6px; }
.names .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--pc); flex: 0 0 auto; }
.names input { width: 100%; }
.records { font-size: .85rem; color: var(--muted); min-height: 1em; margin-bottom: 12px; }
.records ol { margin: 4px 0 0; padding-left: 1.4em; }
.play { width: 100%; font-size: 1.3rem; padding: 14px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 900; cursor: pointer; box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.play:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 70%, #000); }

body:not(.v-flash) .setup .flash-only, body.v-flash .setup .pairs-only, body:not(.flash-timed) .setup .timed-only { display: none; }

.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.setup-head h2 { margin: 0; }
.setup-head small { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* ───────────── Mode élève (assistant) ───────────── */
.wizard { width: min(680px, 100%); text-align: center; position: relative; }
.wz-top { display: flex; align-items: center; justify-content: center; position: relative; min-height: 36px; margin-bottom: 4px; }
.wz-back { position: absolute; left: 0; top: 0; border: 0; background: #eef0fb; border-radius: 50%; width: 40px; height: 40px; font-size: 1.3rem; cursor: pointer; }
.wz-dots { display: flex; gap: 8px; }
.wz-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.wz-dots span.on { background: var(--accent); transform: scale(1.25); }
.wz-step { display: none; animation: pop-in .3s ease-out; }
.wz-step.is-active { display: block; }
.wizard h2 { font-size: 1.7rem; margin: 4px 0 14px; }
.wz-say { font-size: 1.25rem; font-weight: 800; margin: 16px 0 8px; color: var(--ink); }
.wz-say.small { font-size: 1rem; margin: 12px 0 6px; color: var(--muted); }
.wz-ut { animation: pop-in .25s ease-out; }
.wz-choices { display: grid; gap: 12px; }
.wz-choices.two { grid-template-columns: 1fr 1fr; }
.wz-choices.three { grid-template-columns: repeat(3, 1fr); }
.wz-choices.four { grid-template-columns: repeat(4, 1fr); }
.wz-big { position: relative; display: block; cursor: pointer; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: center; }
.wz-big input { position: absolute; opacity: 0; pointer-events: none; }
.wz-big > span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 92px; padding: 12px; border: 3px solid var(--line); border-radius: 18px; background: #fafaff; transition: transform .12s, border-color .15s, background .15s; }
.wz-big:hover > span { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.wz-big input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 35%, #fff); }
.wz-big input:focus-visible + span, .wz-btn:focus-visible > span { outline: 3px solid var(--accent); outline-offset: 2px; }
.wz-big b { font-size: 1.25rem; }
.wz-big small { color: var(--muted); font-size: .9rem; }
.wz-emoji { font-size: 2.4rem; line-height: 1.1; }
.wz-btn > span { flex-direction: row; justify-content: flex-start; gap: 16px; text-align: left; min-height: 84px; }
.wz-text { display: flex; flex-direction: column; gap: 2px; }
.wz-btn .wz-emoji { font-size: 2.8rem; }
.wz-btn:active > span { transform: scale(.98); }
.wz-choices.small .wz-big > span { min-height: 70px; }
.wz-choices.small .wz-emoji { font-size: 2rem; }
.wz-emoji .ico { width: 54px; height: 54px; }
.wz-btn .wz-emoji .ico { width: 64px; height: 64px; }
.wz-choices.small .wz-emoji .ico { width: 44px; height: 44px; }
.wz-acorns { display: inline-flex; }
.wz-acorns .ico { width: 42px; height: 42px; margin: 0 -3px; }
.tile b .ico { width: 1.6em; height: 1.6em; vertical-align: -.5em; }
.wz-stars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.wz-star { cursor: pointer; }
.wz-star input { position: absolute; opacity: 0; pointer-events: none; }
.wz-star > span { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; border: 3px solid var(--line); border-radius: 16px; background: #fafaff; transition: transform .12s; }
.wz-star .star { display: block; line-height: 0; transition: transform .2s; }
.wz-star .star .ico { width: 2.8rem; height: 2.8rem; }
.wz-star b { font-size: .85rem; }
.wz-star input:checked + span { border-color: var(--lc); background: color-mix(in srgb, var(--lc) 14%, #fff); }
.wz-star input:checked + span .star { transform: scale(1.2) rotate(-8deg); }
.wz-star input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.wz-sentence { margin: 18px 0 14px; font-size: 1rem; color: var(--muted); }
.wz-names { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.wz-names label { display: flex; align-items: center; gap: 6px; }
.wz-names .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--pc); }
.wz-names input { width: 150px; font-size: 1.05rem; padding: 8px 10px; border: 3px solid color-mix(in srgb, var(--pc) 40%, #fff); border-radius: 12px; }
.wz-summary { margin: 18px 0 4px; color: var(--muted); font-weight: 600; }
.wz-record { margin: 0 0 12px; font-weight: 800; color: #b7791f; min-height: 1.2em; }
.wz-teacher { margin-top: 16px; border: 0; background: none; color: var(--muted); font-size: .85rem; cursor: pointer; text-decoration: underline; }
.wz-teacher .ico { width: 1.8em; height: 1.8em; vertical-align: -.6em; }
.wz-back .ico { vertical-align: middle; }
.wz-record .ico, .record-msg .ico, .records .ico { width: 1.5em; height: 1.5em; vertical-align: -.4em; }
.announce-art { line-height: 0; margin: -4px 0 6px; }
.verdict .ico { vertical-align: -.45em; }
.hd-icon { padding: 2px 10px; line-height: 0; }
.setup-head h2 .ico { width: 1.3em; height: 1.3em; }
.verdict { font-weight: 800; font-size: 1.1rem; }
.verdict.ok { color: var(--good); font-size: 1.3rem; }

/* Histogramme des résultats (ui/speedBars.js) */
.speed-bars { --animal: 46px; display: grid; gap: 12px; margin-top: 10px; text-align: left; }
.sb-row { display: grid; grid-template-columns: 5.2em 1fr; align-items: center; gap: 8px; }
.sb-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.sb-who b { color: var(--pc); overflow-wrap: anywhere; line-height: 1.1; }
.sb-who small { color: var(--muted); font-size: .72rem; white-space: nowrap; }
/* La barre s'arrête avant le bord pour laisser la place à l'animal, posé à son bout. */
.sb-track { position: relative; height: var(--animal); }
.sb-bar { position: absolute; left: 0; top: 7px; bottom: 7px; width: calc((100% - var(--animal)) * var(--ratio, 0)); min-width: 8px; border-radius: 10px; background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 70%, #fff), var(--pc) 70%, color-mix(in srgb, var(--pc) 80%, #000)); box-shadow: var(--shadow); transition: width .9s cubic-bezier(.2, .8, .3, 1); }
.sb-animal { position: absolute; top: 0; left: calc((100% - var(--animal)) * var(--ratio, 0)); width: var(--animal); height: var(--animal); display: grid; place-items: center; opacity: 0; transition: left .9s cubic-bezier(.2, .8, .3, 1), opacity .3s; }
.sb-row.is-grown .sb-animal { opacity: 1; }
.sb-debug { grid-column: 2; margin-top: -6px; font-size: .72rem; color: var(--muted); }
.result-art { line-height: 0; margin: 2px 0 8px; }

/* Module Classe (js/classroom/) : gestion, sélecteur, rapport */
.setup-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.setup-tools .btn { padding: 7px 12px; font-size: .85rem; }
body.class-play #playerCount, body.class-play #playerNames { display: none; }
.classroom { width: min(860px, 100%); }
.classroom select, .classroom input[type="text"], .classroom textarea, .class-picker select { padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.classroom .row { margin: 8px 0; }
.classroom .row label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.cr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cr-head h2 { margin: 0; }
.cr-add { display: flex; gap: 8px; margin: 10px 0; align-items: stretch; }
.cr-add input, .cr-add textarea { flex: 1; min-width: 0; font: inherit; }
.cr-class { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 8px; background: #fafffe; }
.cr-class summary { cursor: pointer; }
.cr-class summary small { color: var(--muted); }
.cr-students { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cr-chip { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.cr-chip button { border: 0; background: none; padding: 3px 10px; cursor: pointer; }
.cr-chip button + button { padding: 3px 9px 3px 2px; color: var(--muted); }
.cr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cr-backup { margin-top: 16px; }
label.btn { display: inline-block; }

.class-picker .row { margin-bottom: 8px; }
.cp-present { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.cp-student { cursor: pointer; }
.cp-student input { position: absolute; opacity: 0; pointer-events: none; }
.cp-student span { display: block; padding: 4px 12px; border: 2px solid var(--line); border-radius: 999px; color: var(--muted); text-decoration: line-through; }
.cp-student input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--ink); text-decoration: none; }
.cp-student input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.cp-mode { margin-bottom: 8px; }
.cp-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; margin-bottom: 8px; }
.cp-team { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 5px 8px; border: 2px solid var(--line); border-radius: 12px; }
.cp-team > b { color: var(--muted); margin-right: 2px; }
.cp-member { border: 0; border-radius: 999px; padding: 3px 9px; background: #eef7f6; cursor: pointer; }
.cp-member.is-selected { background: var(--accent); color: var(--accent-ink); }

.ev-title { margin: 12px 0 6px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ev-students { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-student { border: 2px solid var(--line); border-radius: 999px; background: #fff; padding: 6px 14px; font-weight: 700; cursor: pointer; }
.ev-student.is-selected { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.classroom .play { margin-top: 12px; }
.play:disabled { opacity: .5; cursor: default; box-shadow: none; }

.rt-wrap { overflow-x: auto; margin-top: 10px; }
.rt { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rt th, .rt td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.rt tbody th { text-align: left; }
.rt-head { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .75rem; }
.rt-name { border: 0; background: none; padding: 0; font-weight: 800; color: var(--accent); cursor: pointer; text-decoration: underline; }
.rt tr.is-open th { background: color-mix(in srgb, var(--accent) 8%, #fff); }
.rt-empty { color: var(--muted); }
.rt-valid { background: color-mix(in srgb, var(--good) 16%, #fff); }
.rt small { color: var(--muted); }
.rt-faults { color: var(--bad); font-weight: 700; font-size: .8rem; }
.rt-title { margin: 16px 0 0; }
.rt-del { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }

/* ───────────── Du rythme à la mélodie ───────────── */
body.rm { grid-template-rows: auto 1fr auto auto; background-image: var(--rm-backdrop, none), linear-gradient(160deg, var(--bg-1), var(--bg-2)); }
body.rm[data-year="C1N1"] { --rm-backdrop: url("../img/fond-c1n1.webp"); }
body.rm[data-year="C1N2"] { --rm-backdrop: url("../img/fond-c1n2.webp"); }
body.rm[data-year="C1N3"] { --rm-backdrop: url("../img/fond-c1n3.webp"); }
body.rm[data-year="C1N4"] { --rm-backdrop: url("../img/fond-c1n4.webp"); }
body.rm[data-year="C2N1"] { --rm-backdrop: url("../img/fond-c2n1.webp"); }
/* Le flou des cadres crée des plans d'empilement : l'en-tête et son menu doivent rester au-dessus. */
.rm .game-header { position: relative; z-index: 60; }
.rm-menu-host { position: relative; }
.rm-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(340px, 92vw); padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.rm-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.rm-field select { width: 100%; padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-weight: 600; font-size: .95rem; }
.rm-field .seg { color: var(--ink); }
.rm-field .seg span { padding: 6px 4px; font-size: .9rem; }
.rm-tempo { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.rm-tempo output { flex: 1; text-align: center; font-variant-numeric: tabular-nums; }
.rm-menu .hint { margin: 0; font-size: .72rem; }
.rm-no-subdivisions .mn-subdivision { visibility: hidden; }
.rm-link { text-align: center; font-size: .85rem; font-weight: 700; color: var(--accent); }
.rm .hd-level { min-width: 0; max-width: 46vw; }
.rm .hd-level span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Récapitulatif des niveaux (niveaux-rythmes.html) */
body.rl { height: auto; padding: 20px clamp(16px, 4vw, 48px) 48px; background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); }
.rl-head h1 { margin: 10px 0 6px; }
.rl-head p { max-width: 72ch; margin: 0 0 12px; }
.rl-head a { color: var(--accent); font-weight: 700; }
.rl-checks, .rl-year { margin-top: 20px; padding: 14px 18px; border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow-x: auto; }
.rl-checks h2, .rl-year h2 { margin: 0 0 10px; font-size: 1.15rem; }
.rl-checks ul { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 4px; }
.rl-checks p { margin: 0; }
.rl-year h2 small { color: var(--muted); font-weight: 600; font-size: .85rem; }
.rl-table { width: 100%; border-collapse: collapse; }
.rl-table th { text-align: left; font-size: .8rem; color: var(--muted); padding: 4px 8px; border-bottom: 2px solid var(--line); }
.rl-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rl-table td small { display: block; color: var(--muted); font-size: .78rem; }
.rl-table td em { display: block; margin-top: 4px; font-size: .8rem; font-style: normal; color: #9a5b00; }
.rl-table tr.has-note { background: #fff8e8; }
.rl-num { font-weight: 800; text-align: center; }
.rl-figures { min-width: 180px; }
.rl-figures figure { display: inline-block; margin: 0 12px 4px 0; text-align: center; vertical-align: top; }
.rl-figures figcaption { font-size: .72rem; color: var(--muted); }
.rl-example { min-width: 340px; }

.rm-stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr); align-items: center; gap: 14px; padding: 16px 24px; min-height: 0; }
.rm-panel { height: min(100%, 460px); min-height: 0; padding: 14px; border-radius: 22px; background: var(--glass); backdrop-filter: blur(6px); border: 4px solid rgba(255, 255, 255, .85); box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.rm-panel.is-active { border-color: #f2b84b; box-shadow: 0 0 0 5px rgba(242, 184, 75, .35), var(--shadow); }
.rm-score { width: 100%; height: 100%; }
.rm-score svg { display: block; }
.rm-panel .mn-score .mn-note.is-active * { fill: #d9542c; stroke: #d9542c; }
.rm-panel .mn-score .mn-beat.is-active * { stroke: #d9542c; }
.rm-count { position: absolute; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%); display: flex; gap: 4px; padding: 8px; border-radius: 22px; background: var(--glass); backdrop-filter: blur(6px); box-shadow: var(--shadow); font-weight: 800; font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: 1.2; font-variant-numeric: tabular-nums; }
.rm-count[hidden] { display: none; }
.rm-count span { min-width: 1.1em; border-radius: 14px; text-align: center; visibility: hidden; }
.rm-count span.is-shown { visibility: visible; }
.rm-count span.is-active { background: rgba(0, 0, 0, .16); }
.rm-arrow { display: block; width: 48px; height: 48px; transform: scaleX(-1); filter: drop-shadow(0 1px 3px rgba(255, 255, 255, .9)); }

.rm-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 24px 16px; }
.rm-transport { display: flex; gap: 12px; justify-content: flex-end; }
.rm-round { display: grid; place-items: center; width: 62px; height: 62px; padding: 0; border: 3px solid rgba(255, 255, 255, .85); border-radius: 50%; background: var(--glass); backdrop-filter: blur(6px); box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, opacity .2s; }
.rm-round:hover:not(:disabled) { transform: translateY(-2px); }
.rm-round:active:not(:disabled) { transform: scale(.95); }
.rm-round:disabled { opacity: .45; cursor: default; }
.rm-round.big { width: 78px; height: 78px; }
.rm-round.small { width: 34px; height: 34px; border: 2px solid var(--line); box-shadow: none; font-size: 1.2rem; font-weight: 800; color: var(--ink); }
.rm-round.is-on { border-color: #8cbf5f; }
.rm-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; justify-self: center; }
.rm-steps li { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(6px); color: var(--muted); font-weight: 700; font-size: .95rem; transition: background .2s, color .2s, transform .2s; }
.rm-steps li.is-active { background: #fff; color: var(--ink); box-shadow: 0 0 0 3px #f2b84b, var(--shadow); transform: translateY(-2px); }
.rm-status { margin: 0; padding: 0 24px; min-height: 0; text-align: center; font-weight: 700; color: var(--ink); }
.rm-status:not(:empty) { padding-bottom: 10px; }

/* Classement de fin */
.ranking { list-style: none; padding: 0; margin: 12px 0 0; text-align: left; display: grid; gap: 6px; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--pc) 10%, #fff); border-left: 6px solid var(--pc); }
.ranking .medal { width: 34px; text-align: center; line-height: 0; font-weight: 800; }
.ranking .who { font-weight: 800; flex: 1; }
.ranking .val { font-variant-numeric: tabular-nums; font-weight: 800; }
.ranking small { display: block; color: var(--muted); font-weight: 500; }
.big-time { font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums; margin: 4px 0; }
.record-msg { font-weight: 800; color: #b7791f; }

/* L'en-tête tient sur une ligne : le titre cède sa place en premier. */
@media (max-width: 1180px) {
  .game-header h1 { display: none; }
}

/* ───────────── Petits écrans ───────────── */
@media (max-width: 760px) {
  /* Du rythme à la mélodie : partitions l'une sous l'autre, commandes en bas. */
  .rm-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 30px minmax(0, 1fr); gap: 6px; padding: 8px 10px; }
  .rm-panel { height: 100%; padding: 8px; }
  .rm-arrow { width: 30px; height: 30px; justify-self: center; transform: rotate(-90deg); }
  .rm-controls { grid-template-columns: auto 1fr; padding: 0 10px 10px; }
  .rm-steps { grid-column: 1 / -1; grid-row: 1; flex-wrap: wrap; justify-content: center; }
  .rm-steps li { padding: 4px 9px; font-size: .78rem; }
  .rm-round.big { width: 62px; height: 62px; }
  /* Joueurs en bande horizontale sous les cartes, échelle tout en bas. */
  .game-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; grid-template-areas: "board" "players" "scale"; padding: 10px; gap: 10px; }
  .players-host { width: auto; padding: 8px 0 0; margin: 0; overflow: visible; }
  .player-bar { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .pb-chip.is-active { transform: translateY(-3px) scale(1.04); }
  .ns-btn { height: 56px; }
  .tiles.three { grid-template-columns: 1fr; }
  .tiles.stars { grid-template-columns: repeat(3, 1fr); }
  .wz-stars { grid-template-columns: repeat(3, 1fr); }
  .wz-choices.three { grid-template-columns: 1fr; }
  [data-step="goal"] .wz-choices.three { grid-template-columns: repeat(3, 1fr); }
  .wz-choices.four { grid-template-columns: repeat(2, 1fr); }
  .wizard h2 { font-size: 1.35rem; }
  .game-header { padding: 6px 10px; gap: 8px; }
  /* Portées aussi grandes que possible sur les petites cartes. */
  .fc-front { padding: 1%; border-width: 1px; }
  .fc-face { border-radius: 10px; }
}
