/* =========================================================================
   GARDE DU CORPS — Feuille de style
   Direction artistique : planche de sciences naturelles, papier clair,
   couleurs de la coloration MGG (violets, roses, bleus). Lisible au
   vidéoprojecteur, sans dépendance externe hormis les polices (facultatives).
   ========================================================================= */
[hidden] { display: none !important; } /* l'attribut hidden l'emporte toujours (ex. bouton plein écran sans support) */

:root {
  --paper: #FBF7F1;
  --paper-2: #F4EDE3;
  --paper-3: #EAE0D2;
  --white: #FFFFFF;
  --ink: #271F33;
  --ink-2: #4B4258;
  --ink-3: #7A7186;
  --line: #E6DCCF;
  --line-2: #D6C9B8;

  --rose: #D9546F;   --rose-soft: #F8DEE4;
  --violet: #6B4FB8; --violet-soft: #E9E2F7;
  --bleu: #2F6FCF;   --bleu-soft: #DDE8F8;
  --teal: #18907F;   --teal-soft: #D6EFEA;
  --or: #C98A12;     --or-soft: #F8EBCB;
  --vert: #3E8E3A;   --vert-soft: #DFF0D9;
  --danger: #C8423B;

  --accent: var(--violet);
  --accent-soft: var(--violet-soft);

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --shadow-1: 0 1px 2px rgba(39, 31, 51, .06), 0 4px 14px rgba(39, 31, 51, .06);
  --shadow-2: 0 2px 6px rgba(39, 31, 51, .07), 0 14px 34px rgba(39, 31, 51, .12);
  --shadow-3: 0 6px 16px rgba(39, 31, 51, .12), 0 30px 70px rgba(39, 31, 51, .22);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --hud-top: 68px;
  --hud-bottom: 92px;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .3 0 0 0 .055 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font-family: inherit; color: inherit; }
a { color: var(--violet); }
h1, h2, h3, h4 { margin: 0; }
.ic { flex: none; display: block; }
kbd {
  font: 600 .7rem/1 var(--font-body); color: var(--ink-3);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  padding: .25em .45em; background: var(--paper);
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  font: 600 1rem/1 var(--font-body);
  padding: .82em 1.25em; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .18), 0 8px 20px rgba(39, 31, 51, .2); }
.btn-primary:hover:not(:disabled) { background: #3A2E4D; transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-accent:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-soft { background: var(--white); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow-1); }
.btn-soft:hover:not(:disabled) { border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(39, 31, 51, .06); }
.btn-big { font-size: 1.12rem; padding: 1em 1.6em; }
.btn-small { font-size: .88rem; padding: .6em 1em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1.5px solid var(--line-2);
  background: var(--white); display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: border-color .2s, background .2s, color .2s;
}
.icon-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.icon-btn.off { color: var(--ink-3); background: var(--paper-2); }

/* ---------- Écrans ---------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
#screen-game.active { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px) 14px 74px; /* à gauche : place du logo */
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar h1, .topbar h2 { font: 600 1.45rem/1.1 var(--font-display); flex: 1; }
.topbar .sub { color: var(--ink-3); font-size: .9rem; }
.star-count { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--or); background: var(--or-soft); padding: .45em .9em; border-radius: 999px; }

/* ---------- Accueil ---------- */
#screen-title { position: relative; overflow: hidden; }
#screen-title::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(40% 40% at 12% 18%, rgba(217, 84, 111, .12), transparent 70%),
    radial-gradient(45% 45% at 88% 82%, rgba(107, 79, 184, .13), transparent 70%),
    radial-gradient(30% 30% at 80% 10%, rgba(201, 138, 18, .08), transparent 70%);
  pointer-events: none;
}
.title-wrap {
  position: relative; min-height: 100vh; max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(20px, 4vw, 64px);
  padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 56px);
}
.brand-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--violet);
  background: var(--violet-soft); padding: .45em .9em; border-radius: 999px;
}
.title-main {
  font: 600 clamp(3rem, 7.4vw, 6.4rem)/0.95 var(--font-display);
  letter-spacing: -.02em; margin: .3em 0 .25em;
}
.title-main em { font-style: italic; font-weight: 500; color: var(--rose); }
.tagline { font-size: clamp(1.02rem, 1.5vw, 1.2rem); color: var(--ink-2); max-width: 34em; margin: 0 0 1.6em; line-height: 1.6; }
.title-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.title-foot { display: flex; align-items: center; gap: 8px; margin-top: 28px; flex-wrap: wrap; color: var(--ink-3); font-size: .88rem; }
.title-foot .btn-ghost { padding: .7em .9em; }
.title-foot .sep { flex: 1; }
.continue-hint { margin-top: 14px; font-size: .92rem; color: var(--ink-3); }
.title-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 22px; }
.title-about { color: var(--ink-3); font-size: .88rem; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.title-about:hover { color: var(--violet); text-decoration-color: currentColor; }
.title-credit {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 4px;
  padding: 5px 16px 5px 5px; border-radius: 999px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--white) 70%, transparent);
  color: var(--ink-2); font: inherit; font-size: .88rem; cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.title-credit img { width: 46px; height: 46px; display: block; }
.title-credit b { color: var(--ink); font-weight: 600; }
.title-credit .more { color: var(--ink-3); padding-left: 10px; border-left: 1px solid var(--line); }
.title-credit:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.title-credit:hover .more { color: var(--violet); }
.title-credit:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

/* Logo de l'auteur, fixé en haut à gauche sur tous les écrans sauf l'accueil */
.brand-logo {
  position: fixed; top: 12px; left: 14px; z-index: 20; width: 44px; height: 44px; padding: 0;
  border: 0; background: none; cursor: pointer; border-radius: 12px;
  filter: drop-shadow(0 2px 6px rgba(39, 31, 51, .18)); transition: transform .2s;
}
.brand-logo img { width: 44px; height: 44px; display: block; }
.brand-logo:hover { transform: scale(1.06); }
.brand-logo:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
body[data-screen="title"] .brand-logo { display: none; }
@media print { .brand-logo { display: none; } }

/* Choix de la langue (accueil) */
.lang-switch { position: absolute; top: 16px; right: clamp(16px, 4vw, 56px); z-index: 3; display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: color-mix(in srgb, var(--white) 80%, transparent); border: 1px solid var(--line); }
.lang-switch button { display: grid; place-items: center; padding: 5px; border: 2px solid transparent; border-radius: 9px; background: none; cursor: pointer; opacity: .55; filter: saturate(.6); transition: opacity .15s, filter .15s, transform .15s; }
.lang-switch button svg { display: block; width: 30px; height: 20px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .14); }
.lang-switch button:hover { opacity: 1; filter: none; transform: translateY(-1px); }
.lang-switch button.on { opacity: 1; filter: none; border-color: var(--ink); background: var(--white); }
.lang-switch button:focus-visible { outline: 3px solid var(--violet); outline-offset: 1px; }

.scope-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.scope {
  position: relative; width: min(42vw, 64vh, 560px); aspect-ratio: 1; border-radius: 50%;
  background: #FCEFF0;
  box-shadow:
    0 0 0 10px #2C2436, 0 0 0 13px #4A3F58, 0 0 0 22px #E9E1D6, 0 0 0 23px var(--line-2),
    var(--shadow-3);
}
.scope canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; }
.scope::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, transparent 58%, rgba(40, 20, 40, .22) 88%, rgba(40, 20, 40, .45) 100%);
}
.scope-caption { font-size: .85rem; color: var(--ink-3); text-align: center; max-width: 30em; margin-top: 18px; }
.scope-caption b { color: var(--ink-2); font-weight: 600; }

/* ---------- Carte des missions ---------- */
.map-layout {
  max-width: 1280px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 36px) 40px;
  display: grid; grid-template-columns: minmax(250px, 380px) minmax(0, 1fr); gap: clamp(18px, 3vw, 40px); align-items: start;
}
.body-card {
  position: sticky; top: 90px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 16px 16px 12px;
}
.body-card h3 { font: 600 1.15rem var(--font-display); margin: 2px 4px 2px; }
.body-card p { font-size: .85rem; color: var(--ink-3); margin: 0 4px 6px; }
.body-svg { width: 100%; height: auto; display: block; max-height: calc(100vh - 250px); }
.body-svg .pin { cursor: pointer; }
.body-svg .pin circle.halo { transform-origin: center; transform-box: fill-box; animation: pinPulse 2.2s ease-out infinite; }
.body-svg .pin.locked { opacity: .45; cursor: default; }
.body-svg .pin.locked circle.halo { animation: none; }
.body-svg .pin.hl circle.core { stroke-width: 4; }
@keyframes pinPulse { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.8); opacity: 0; } }
.body-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-3); margin: 6px 4px 0; }
.body-legend span { display: inline-flex; align-items: center; gap: 6px; }
.body-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.missions { display: flex; flex-direction: column; gap: 14px; }
.mcard {
  --mc: var(--violet);
  display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 18px; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-1);
  transition: transform .18s ease, box-shadow .2s, border-color .2s;
}
.mcard:hover:not(.locked) { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--mc) 40%, var(--line)); }
.mcard .mnum {
  width: 74px; height: 74px; border-radius: 20px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--mc) 12%, white); color: var(--mc);
  font: 600 2rem var(--font-display); position: relative; overflow: hidden;
}
.mcard .mnum canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; }
.mcard .mnum span { position: relative; z-index: 1; text-shadow: 0 0 8px #fff, 0 0 2px #fff; }
.mcard h3 { font: 600 1.3rem/1.2 var(--font-display); }
.mcard .msub { font-size: .9rem; color: var(--mc); font-weight: 600; margin: 2px 0 6px; }
.mcard .mpitch { font-size: .92rem; color: var(--ink-2); margin: 0 0 8px; }
.mcard .mmeta { display: flex; flex-wrap: wrap; gap: 6px; }
.mcard .mmeta span { font-size: .75rem; background: var(--paper-2); color: var(--ink-2); padding: .3em .65em; border-radius: 999px; }
.mcard .mside { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.mstars { display: flex; gap: 2px; color: var(--line-2); }
.mstars .on { color: var(--or); }
.mstars .on svg { fill: currentColor; }
.mcard.locked { opacity: .62; }
.mcard.locked .btn { pointer-events: none; }
.mcard.done .mnum::after {
  content: ""; position: absolute; right: 6px; bottom: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--vert) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7.5'/></svg>") center/12px no-repeat;
  z-index: 2;
}

/* ---------- Atlas ---------- */
.atlas-wrap { max-width: 1280px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 36px) 40px; }
.tabs { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: .55em 1.1em; border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.tabs button.on { background: var(--white); color: var(--ink); box-shadow: var(--shadow-1); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.filters button {
  border: 1.5px solid var(--line-2); background: var(--white); padding: .45em .95em; border-radius: 999px;
  font-weight: 500; font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.filters button i { width: 10px; height: 10px; border-radius: 50%; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.acard {
  --fc: var(--violet);
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  transition: transform .15s, box-shadow .2s; box-shadow: var(--shadow-1);
}
.acard:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.acard .athumb { aspect-ratio: 1.15; position: relative; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fc) 10%, white), var(--paper)); }
.acard .athumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.acard .ainfo { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.acard .aname { font-weight: 600; font-size: .98rem; line-height: 1.2; }
.acard .afam { font-size: .75rem; color: var(--fc); font-weight: 600; margin-top: 4px; }
.acard.locked { cursor: default; }
.acard.locked .athumb { filter: grayscale(1) brightness(1.15) contrast(.5); opacity: .7; }
.acard.locked .aname { color: var(--ink-3); }

.adetail { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; }
.adetail .aportrait {
  border-radius: var(--r-md); background: radial-gradient(circle at 50% 42%, #fff, var(--paper-2));
  border: 1px solid var(--line); aspect-ratio: 1; position: relative; overflow: hidden;
}
.adetail .aportrait canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.adetail .fam-pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .3em .7em; border-radius: 999px; }
.adetail h2 { font: 600 1.8rem/1.1 var(--font-display); margin: 8px 0 2px; }
.adetail .alt { color: var(--ink-3); font-size: .95rem; }
.adetail .sci { font-style: italic; color: var(--ink-3); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.fact { background: var(--paper-2); border-radius: 12px; padding: 8px 12px; }
.fact small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.fact span { font-size: .92rem; }
.adetail .role { color: var(--ink-2); line-height: 1.6; }
.asection { margin-top: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--white); }
.asection h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.asection p { margin: 0; font-size: .94rem; color: var(--ink-2); }
.asection.savais { background: var(--or-soft); border-color: #EED9A5; }
.asection.jeu { background: var(--violet-soft); border-color: #D8CCF2; }

.scale-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 16px; margin-top: 16px; }
.scale-panel canvas { width: 100%; height: 440px; display: block; border-radius: 14px; background: #FCF6F0; }
.scale-controls { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.scale-controls input[type=range] { flex: 1; min-width: 200px; accent-color: var(--violet); }
.scale-controls .ruler { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 9em; }
.scale-note { font-size: .88rem; color: var(--ink-3); margin-top: 6px; }

/* ---------- Espace enseignant ---------- */
.teacher { max-width: 940px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 36px) 60px; }
.teacher section { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 24px; margin-bottom: 16px; box-shadow: var(--shadow-1); }
.teacher h2 { font: 600 1.35rem var(--font-display); margin-bottom: 8px; }
.teacher .teacher-credits { display: flex; gap: 18px; align-items: center; }
.teacher .teacher-credits img { flex: none; width: 64px; height: 64px; }
.teacher .teacher-credits p { margin: 0; }
.teacher h3 { font-size: 1rem; margin: 14px 0 4px; }
.teacher p, .teacher li { color: var(--ink-2); line-height: 1.6; }
.teacher ul { padding-left: 1.2em; margin: 6px 0; }
.teacher table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.teacher th, .teacher td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.teacher th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { width: 44px; height: 26px; appearance: none; background: var(--line-2); border-radius: 13px; position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(18px); }
.settings-list { display: flex; flex-direction: column; gap: 14px; }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: .45em .9em; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-3); font-size: .9rem; }
.seg button.on { background: var(--white); color: var(--ink); box-shadow: var(--shadow-1); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-row small { display: block; color: var(--ink-3); font-size: .82rem; }

/* ---------- Écran de jeu ---------- */
#screen-game { position: fixed; inset: 0; overflow: hidden; background: #F3E3DA; user-select: none; -webkit-user-select: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; height: var(--hud-top); z-index: 10;
  display: flex; align-items: center; gap: 14px; padding: 0 14px 0 70px; /* à gauche : place du logo */
  background: linear-gradient(to bottom, rgba(251, 247, 241, .97), rgba(251, 247, 241, .9));
  border-bottom: 1px solid rgba(214, 201, 184, .8);
  box-shadow: 0 4px 18px rgba(39, 31, 51, .06);
}
.hud-titles { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
#hud-kicker { font-size: .7rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
#hud-title { font: 600 1.12rem var(--font-display); white-space: nowrap; }
#hud-step { font-size: .8rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
#hud-step.flash { animation: stepFlash 1s ease; }
@keyframes stepFlash { 0% { color: var(--accent); } 100% { color: var(--ink-3); } }
.hud-obj {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; height: 48px;
}
.hud-obj .ic { color: var(--accent); }
#hud-objective { font-size: .95rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#hud-objective b { color: var(--accent); }
#hud-meters { display: flex; gap: 8px; }
.meter { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 5px 11px; min-width: 112px; height: 48px; display: flex; flex-direction: column; justify-content: center; }
.meter-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.meter-label .ic { color: var(--mc); }
.meter-bar { height: 7px; background: var(--paper-3); border-radius: 4px; overflow: hidden; margin: 4px 0 1px; }
.meter-fill { height: 100%; width: 0; background: var(--mc); border-radius: 4px; transition: width .25s ease; }
.meter-bar + .meter-value { font-size: .72rem; color: var(--ink-3); line-height: 1; }
.meter-value { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 1.02rem; line-height: 1.1; white-space: nowrap; }
.meter-row { display: flex; align-items: center; gap: 8px; }
.meter.k-spark { min-width: 150px; }
.meter.k-spark .spark { width: 84px; height: 26px; }
.meter.danger { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(200, 66, 59, .15); }
.meter.danger .meter-value { color: var(--danger); }

.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hud-bottom); z-index: 10;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: linear-gradient(to top, rgba(251, 247, 241, .97), rgba(251, 247, 241, .9));
  border-top: 1px solid rgba(214, 201, 184, .8);
  box-shadow: 0 -4px 18px rgba(39, 31, 51, .05);
}
#hud-actions { display: flex; gap: 10px; flex: 1 1 auto; min-width: max-content; padding: 4px 0; }
#hud-actions::-webkit-scrollbar { display: none; }
.act {
  position: relative; overflow: hidden; flex: none;
  display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 16px 0 9px;
  background: var(--white); border: 1.5px solid var(--line-2); border-radius: 16px; cursor: pointer;
  text-align: left; transition: border-color .2s, background .2s, transform .12s, box-shadow .2s;
  box-shadow: 0 2px 0 rgba(39, 31, 51, .06);
}
.act:hover:not(:disabled) { border-color: var(--accent); }
.act:active:not(:disabled) { transform: translateY(1px); }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.act-txt { display: flex; flex-direction: column; line-height: 1.15; }
.act-txt b { font-weight: 600; font-size: .95rem; white-space: nowrap; }
.act-txt small { color: var(--ink-3); font-size: .74rem; white-space: nowrap; }
.act kbd { margin-left: 4px; }
.act.on { border-color: var(--accent); background: var(--accent-soft); }
.act.on .act-ic { background: var(--accent); color: #fff; }
.act-cd { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); opacity: .75; }
.act-badge { position: absolute; top: 5px; right: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 600; display: none; place-items: center; line-height: 22px; text-align: center; }
.act.has-badge { padding-right: 36px; }
.hud-top.obj-row { flex-wrap: wrap; height: auto; min-height: var(--hud-top); row-gap: 6px; padding-top: 8px; padding-bottom: 8px; }
.hud-top.obj-row .hud-obj { order: 10; flex: 1 1 100%; height: auto; min-height: 40px; }
.hud-top.obj-row #hud-meters { margin-left: auto; } /* place réservée à la pastille du compteur */
.act.pulse { animation: actPulse 1.3s ease-in-out infinite; }
@keyframes actPulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); } }
#hud-widgets { display: flex; gap: 10px; align-items: center; flex: none; margin-left: auto; }
/* si boutons + widgets ne tiennent pas sur une ligne (petit écran, langue aux mots longs),
   les widgets passent à la ligne ; la scène s'adapte à la hauteur réelle du bandeau */
.hud-bottom { flex-wrap: wrap; row-gap: 8px; height: auto; min-height: var(--hud-bottom); padding-top: 6px; padding-bottom: 6px; }
.hud-btn { width: 46px; height: 46px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--white); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.hud-btn:hover { border-color: var(--ink-3); color: var(--ink); }

/* Widgets propres aux missions */
.signs { display: flex; gap: 6px; }
.sign {
  min-width: 82px; padding: 0 6px; box-sizing: border-box; height: 64px; border-radius: 14px; border: 1.5px dashed var(--line-2); background: rgba(255, 255, 255, .6); /* largeur minimale : s'élargit pour les mots longs (ex. « Enrojecimiento ») */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-3);
  font-size: .74rem; font-weight: 600; text-align: center; line-height: 1.1; transition: all .35s ease;
}
.sign .ic { opacity: .5; }
.sign.on { border-style: solid; border-color: var(--rose); background: var(--rose-soft); color: #8E2440; transform: scale(1.04); }
.sign.on .ic { opacity: 1; color: var(--rose); }
.finger { width: 92px; height: 64px; border-radius: 14px; background: var(--white); border: 1.5px solid var(--line-2); position: relative; overflow: hidden; flex: none; }
.finger svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.finger small { position: absolute; left: 6px; top: 3px; font-size: .6rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.journal { background: var(--white); border: 1.5px solid var(--line-2); border-radius: 14px; padding: 6px 12px; min-width: 210px; max-width: 280px; height: 64px; display: flex; flex-direction: column; justify-content: center; }
.journal .jday { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; color: var(--accent); }
.journal .jtxt { font-size: .84rem; line-height: 1.25; color: var(--ink-2); }

#layer-coach { position: absolute; left: 14px; bottom: calc(var(--hud-bottom-h, var(--hud-bottom)) + 12px); z-index: 12; pointer-events: none; }
/* la bulle laisse passer les clics vers le jeu ; seuls ses boutons restent cliquables */
#layer-coach .coach { pointer-events: none; }
#layer-coach .coach .btn, #layer-coach .coach button, #layer-coach .coach a { pointer-events: auto; }
.coach {
  display: flex; align-items: center; gap: 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 11px 14px 11px 11px;
  box-shadow: var(--shadow-2); max-width: min(480px, calc(100vw - 28px));
  animation: slideUp .32s cubic-bezier(.2, .9, .3, 1.15);
}
.coach.leaving { animation: fadeOut .2s forwards; }
.coach-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.coach-text { font-size: .96rem; line-height: 1.42; color: var(--ink-2); }
.coach-text b { color: var(--ink); }
.coach .btn { flex: none; }

/* ---------- Fenêtres ---------- */
#layer-cards { position: relative; z-index: 60; }
.modal-wrap {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(39, 31, 51, .36); animation: fadeIn .2s ease;
}
.modal-wrap.leaving { animation: fadeOut .18s ease forwards; }
.modal {
  position: relative; width: 100%; max-width: 580px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--paper); background-image: var(--grain);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3); border: 1px solid rgba(255, 255, 255, .8);
  animation: popIn .3s cubic-bezier(.2, .9, .3, 1.12);
}
.modal.wide { max-width: 860px; }
.modal-figure { position: relative; border-bottom: 1px solid var(--line); background: radial-gradient(circle at 50% 40%, #FFFFFF, #F3EADF); overflow: hidden; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.modal-figure canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fig-caption { position: absolute; left: 12px; bottom: 10px; font-size: .75rem; color: var(--ink-3); background: rgba(255, 255, 255, .85); padding: .25em .6em; border-radius: 8px; }
.modal-body { padding: 22px 26px 22px; }
.kicker { font-size: .74rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.modal-title { font: 600 1.65rem/1.18 var(--font-display); margin: 6px 0 10px; }
.rich { color: var(--ink-2); line-height: 1.58; }
.rich p { margin: .55em 0; }
.rich b { color: var(--ink); font-weight: 600; }
.rich ul, .rich ol { margin: .4em 0; padding-left: 1.25em; }
.rich li { margin: .25em 0; }
.rich .credits-id { display: flex; align-items: center; gap: 18px; margin: 4px 0 16px; }
.rich .credits-id img { flex: none; width: 84px; height: 84px; }
.rich .credits-id small { display: block; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.rich .credits-id b { display: block; font: 600 1.6rem/1.15 var(--font-display); }
.rich .credits-id .role { display: block; margin-top: 2px; color: var(--ink-2); }
.rich .credits-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 14px 0 2px; border-top: 1px solid var(--line); font-size: .92rem; }
.rich .credits-list dt { color: var(--ink-3); font-weight: 600; }
.rich .credits-list dd { margin: 0; }
@media (max-width: 520px) { .rich .credits-list { grid-template-columns: 1fr; gap: 2px; } .rich .credits-list dd { margin-bottom: 8px; } }
.rich .note { font-size: .88rem; color: var(--ink-3); background: var(--paper-2); border-radius: 10px; padding: 8px 12px; margin-top: 10px; }
.rich .steps { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rich .step { display: flex; gap: 12px; align-items: flex-start; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.rich .step .n { flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 600; display: grid; place-items: center; font-size: .9rem; }
.rich .controls { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 10px 0; font-size: .92rem; }
.rich .controls kbd { justify-self: start; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .9); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); z-index: 2; }
.modal-x:hover { background: var(--white); color: var(--ink); }
.modal:focus { outline: none; }
.chip:focus-visible, .drop-zone:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tone-good .kicker { color: var(--vert); }
.tone-bad .kicker { color: var(--danger); }

/* Prédiction / QCM dans une carte */
.predict { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* ---------- Activités de bilan ---------- */
.bilan { max-width: 880px; }
.bilan-head { padding: 22px 26px 0; }
.bilan-dots { display: flex; gap: 6px; margin-top: 4px; }
.bilan-dots span { width: 28px; height: 5px; border-radius: 3px; background: var(--line); }
.bilan-dots span.done { background: var(--accent); }
.bilan-dots span.cur { background: color-mix(in srgb, var(--accent) 50%, white); }
.bilan-body { padding: 8px 26px 24px; }
.consigne { color: var(--ink-2); margin: 12px 0 14px; }
.consigne.q { font-size: 1.12rem; color: var(--ink); font-weight: 500; }
.chip-bank { display: flex; flex-wrap: wrap; gap: 8px; min-height: 58px; padding: 10px; border: 1.5px dashed var(--line-2); border-radius: 14px; background: rgba(255, 255, 255, .5); }
.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  background: var(--white); border: 1.5px solid var(--line-2); border-radius: 12px; padding: 8px 12px;
  font-weight: 500; font-size: .94rem; cursor: grab; touch-action: none; box-shadow: 0 2px 0 rgba(39, 31, 51, .06);
  transition: transform .12s, border-color .2s, background .2s;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.chip.dragging { opacity: .35; }
.chip.good { border-color: var(--vert); background: var(--vert-soft); }
.chip.bad { border-color: var(--danger); background: #FBE3E1; }
.chip.locked { cursor: default; }
.chip .fix { font-size: .76rem; color: var(--danger); font-weight: 600; margin-top: 2px; }
.drag-ghost { position: fixed; z-index: 200; pointer-events: none; transform: rotate(-2deg) scale(1.03); box-shadow: var(--shadow-2); }
.match-targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.match-targets.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.match-target { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.mt-label { font-weight: 600; font-size: .92rem; margin-bottom: 8px; color: var(--ink); }
.mt-label small { display: block; font-weight: 400; color: var(--ink-3); font-size: .8rem; }
.mt-zone { min-height: 54px; border-radius: 10px; background: var(--paper-2); border: 1.5px dashed var(--line-2); padding: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; transition: background .15s, border-color .15s; }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
.act-footer { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.feedback { flex: 1; min-width: 240px; padding: 10px 14px; border-radius: 12px; font-size: .94rem; line-height: 1.45; }
.feedback.good { background: var(--vert-soft); color: #23561F; }
.feedback.mid { background: var(--or-soft); color: #6B4A06; }
.feedback.bad { background: #FBE3E1; color: #7E201B; }
.order-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.order-item {
  display: flex; align-items: center; gap: 10px; background: var(--white); border: 1.5px solid var(--line-2); border-radius: 12px;
  padding: 9px 10px; cursor: grab; touch-action: none; transition: box-shadow .15s, border-color .2s;
}
.order-item.dragging { box-shadow: var(--shadow-2); border-color: var(--accent); cursor: grabbing; z-index: 2; position: relative; }
.order-item.good { border-color: var(--vert); background: var(--vert-soft); }
.order-item.bad { border-color: var(--danger); background: #FBE3E1; }
.oi-num { width: 28px; height: 28px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 600; display: grid; place-items: center; flex: none; font-size: .9rem; }
.oi-grip { color: var(--line-2); letter-spacing: -2px; font-weight: 700; }
.oi-txt { flex: 1; font-size: .95rem; }
.oi-txt .fix { color: var(--danger); font-weight: 600; }
.oi-btns { display: flex; gap: 4px; }
.oi-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--white); border: 1.5px solid var(--line-2); border-radius: 14px; padding: 12px 14px; font-size: .98rem; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--accent); }
.choice .ch-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; }
.choice.good { border-color: var(--vert); background: var(--vert-soft); }
.choice.good .ch-dot { border-color: var(--vert); background: var(--vert); box-shadow: inset 0 0 0 3px #fff; }
.choice.bad { border-color: var(--danger); background: #FBE3E1; }
.choice.bad .ch-dot { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px #fff; }
.choice.dim { opacity: .55; }

/* ---------- Résultats ---------- */
.results-card .modal-title { text-align: center; }
.results-card .kicker { text-align: center; }
.res-stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0 6px; }
.res-star { color: var(--line-2); transition: transform .35s cubic-bezier(.2, .9, .3, 1.6), color .3s; }
.res-star svg { fill: var(--paper-3); }
.res-star.on { color: #B97D0C; transform: scale(1.12) rotate(-6deg); }
.res-star.on svg { fill: #F2BD3A; }
.star-hints { list-style: none; padding: 0; margin: 0 auto 10px; display: flex; flex-direction: column; gap: 2px; align-items: center; font-size: .86rem; color: var(--ink-3); }
.star-hints li { display: flex; gap: 6px; align-items: center; }
.star-hints li.ok { color: var(--vert); }
.res-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.res-stats div { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 8px 16px; text-align: center; min-width: 110px; }
.res-stats b { display: block; font: 600 1.4rem var(--font-display); }
.res-stats span { font-size: .78rem; color: var(--ink-3); }
.retenir { background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 12px 16px; }
.retenir h3 { font-size: 1rem; display: flex; align-items: center; gap: 8px; color: var(--accent); margin-bottom: 4px; }
.retenir ul { margin: 0; padding-left: 1.2em; color: var(--ink-2); }
.retenir li { margin: 4px 0; line-height: 1.45; }
.res-unlocked { margin-top: 12px; }
.res-unlocked h4 { font-size: .85rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.unl-row { display: flex; gap: 8px; flex-wrap: wrap; }
.unl { display: flex; align-items: center; gap: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px 4px 4px; font-size: .85rem; }
.unl canvas { width: 40px; height: 40px; }

/* ---------- Notifications ---------- */
#layer-toasts { position: fixed; top: calc(var(--hud-top-h, var(--hud-top)) + 12px); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: .92rem; font-weight: 500; box-shadow: var(--shadow-2);
  animation: toastIn .3s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.good { background: #2F6E2B; }
.toast.bad { background: #A8352F; }
.toast.leaving { animation: fadeOut .3s forwards; }

/* ---------- Divers ---------- */
#rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 720px) {
  body.in-game #rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 300; background: var(--paper); flex-direction: column;
    align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 30px; font-size: 1.05rem;
  }
}
.noscript { padding: 40px; text-align: center; max-width: 40em; margin: 0 auto; }
.noscript a { color: var(--violet); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.95); } to { opacity: 1; transform: none; } }

/* ---------- Adaptation aux écrans ---------- */
@media (max-width: 1100px) {
  #hud-step { max-width: 170px; }
  .meter { min-width: 96px; }
  .meter.k-spark { min-width: 132px; }
  .meter.k-spark .spark { width: 64px; }
  .act-txt small { display: none; }
  .act kbd { display: none; }
  .act { height: 58px; }
  .hud-obj { padding: 4px 12px; }
  #hud-objective { font-size: .82rem; line-height: 1.18; -webkit-line-clamp: 3; }
  .sign { min-width: 70px; font-size: .7rem; }
}
@media (max-width: 900px) {
  .title-wrap { grid-template-columns: 1fr; text-align: left; }
  .scope-col { order: -1; }
  .scope { width: min(70vw, 340px); }
  .map-layout { grid-template-columns: 1fr; }
  .body-card { position: static; max-width: 420px; }
  .adetail { grid-template-columns: 1fr; }
  .adetail .aportrait { max-width: 260px; }
  .act kbd { display: none; }
  .mcard { grid-template-columns: 56px minmax(0, 1fr); }
  .mcard .mnum { width: 56px; height: 56px; font-size: 1.5rem; }
  .mcard .mside { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}
/* Tablette en portrait et écrans étroits : les bandeaux passent sur deux lignes
   (l'objectif reste toujours visible ; la scène s'adapte à leur hauteur réelle) */
@media (max-width: 900px), (orientation: portrait) and (max-width: 1100px) {
  .hud-top { height: auto; min-height: var(--hud-top); flex-wrap: wrap; row-gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .hud-obj { order: 10; flex: 1 1 100%; max-width: none; height: auto; min-height: 42px; }
  #hud-meters { margin-left: auto; }
  .hud-bottom { height: auto; min-height: var(--hud-bottom); flex-wrap: wrap; row-gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  #hud-actions { flex: 1 1 100%; }
  #hud-widgets { flex: 1 1 100%; justify-content: flex-end; }
  .journal { max-width: none; flex: 1; }
}
@media (max-height: 640px) {
  :root { --hud-top: 58px; --hud-bottom: 78px; }
  .act { height: 54px; }
  .act-ic { width: 38px; height: 38px; }
  .meter, .hud-obj { height: 42px; }
  .sign, .finger, .journal { height: 56px; }
  .modal-body { padding: 16px 20px; }
  .modal-title { font-size: 1.4rem; }
}
@media (max-width: 640px) {
  .facts { grid-template-columns: 1fr; }
  .modal-body { padding: 18px; }
  .bilan-head, .bilan-body { padding-left: 18px; padding-right: 18px; }
}
/* Grands écrans (≥ 1800 px) : textes et colonnes un peu plus grands, pour ne pas laisser
   le contenu tout petit au milieu de l'écran (le jeu, lui, s'adapte déjà à toute taille) */
@media (min-width: 1800px) and (min-height: 950px) {
  html { font-size: 18px; }
  body { font-size: 19px; }
  .title-wrap { max-width: 1560px; }
  .scope { width: min(42vw, 64vh, 700px); }
  .map-layout, .atlas-wrap { max-width: 1560px; }
  .teacher { max-width: 1120px; }
  .modal { max-width: 720px; }
  .modal.wide { max-width: 1000px; }
  .bilan { max-width: 1020px; }
}
@media (min-width: 2400px) and (min-height: 1300px) {
  html { font-size: 21px; }
  body { font-size: 22px; }
  .title-wrap { max-width: 1900px; }
  .scope { width: min(42vw, 64vh, 860px); }
  .map-layout, .atlas-wrap { max-width: 1900px; }
  .teacher { max-width: 1320px; }
  .modal { max-width: 840px; }
  .modal.wide { max-width: 1180px; }
  .bilan { max-width: 1200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
body.reduced *, body.reduced *::before, body.reduced *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

@media print {
  body { background: #fff; }
}

/* Menu du clic droit (menu.js) */
.ctx-menu {
  position: fixed; z-index: 1000; min-width: 220px; padding: 6px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-3);
  font: 500 .92rem/1.2 var(--font-body); color: var(--ink);
  animation: cm-in .12s ease-out;
}
@keyframes cm-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.cm-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 9px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.cm-item:hover, .cm-item:focus-visible { background: var(--violet-soft); outline: none; }
.cm-ico { display: grid; place-items: center; color: var(--ink-2); }
.cm-label { flex: 1; white-space: nowrap; }
.cm-check { display: grid; place-items: center; color: var(--violet); visibility: hidden; }
.cm-item[aria-checked="true"] .cm-check { visibility: visible; }
.cm-item[aria-checked="false"] .cm-label { color: var(--ink-3); }
.cm-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.cm-flags { display: flex; justify-content: space-between; gap: 2px; padding: 2px 4px; }
.cm-flag { display: grid; place-items: center; padding: 4px; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; opacity: .55; filter: saturate(.6); }
.cm-flag svg { display: block; width: 27px; height: 18px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .14); }
.cm-flag:hover, .cm-flag:focus-visible { opacity: 1; filter: none; background: var(--violet-soft); outline: none; }
.cm-flag.on { opacity: 1; filter: none; border-color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .ctx-menu { animation: none; } }
