:root {
  --navy: #14213d; --navy-2: #1f3260; --yellow: #f2c500; --orange: #ff7a1a;
  --bg: #eef1f5; --card: #ffffff; --text: #1f2937; --muted: #6b7280; --line: #dde2e8;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 33, 61, 0.10);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select { font: inherit; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
.hidden, [hidden] { display: none !important; }

/* En-tête */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 14px; padding: 10px 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand-mark { min-width: 44px; height: 34px; padding: 0 6px; border-radius: 9px; background: var(--yellow); color: var(--navy); display: grid; place-items: center; font-weight: 900; font-size: 14px; letter-spacing: .5px; }
.brand small { display: block; font-weight: 400; opacity: .75; font-size: 12px; }
.topbar .spacer { flex: 1; }

/* Mise en page */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.center-page { min-height: calc(100% - 56px); display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card.narrow { width: min(460px, 100%); }
.card.medium { width: min(760px, 100%); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* Formulaires */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(31, 50, 96, .15); }
input.code { text-transform: uppercase; letter-spacing: 6px; font-size: 26px; text-align: center; font-weight: 700; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--navy); color: #fff; transition: transform .05s, filter .15s; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.yellow { background: var(--yellow); color: var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.big { padding: 14px 22px; font-size: 17px; width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.choice { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.choice button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px; cursor: pointer; font-weight: 700; font-size: 18px; color: var(--navy); }
.choice button small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.choice button.on { border-color: var(--navy); background: #e8edf7; box-shadow: inset 0 0 0 1px var(--navy); }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.notice { background: #fff8db; border: 1px solid #f3dc7a; border-radius: 10px; padding: 10px 14px; }
.notice.info { background: #e8f1fb; border-color: #b9d3f0; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e5e7eb; color: #374151; }
.badge.afp { background: #dbeafe; color: #1e40af; }
.badge.cfc { background: #fde68a; color: #78350f; }
.badge.warn { background: #fee2e2; color: #991b1b; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.status { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.status.inscription { background: #e0e7ff; color: #3730a3; }
.status.groupes { background: #fef3c7; color: #92400e; }
.status.en_cours { background: #dcfce7; color: #166534; }
.status.pause { background: #ffedd5; color: #9a3412; }
.status.terminee { background: #e5e7eb; color: #374151; }

/* Avatar */
.avatar-layout { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
@media (max-width: 760px) { .avatar-layout { grid-template-columns: 1fr; } }
@media (min-width: 761px) { .avatar-layout > div:first-child { align-self: start; position: sticky; top: 12px; } }
.avatar-preview { background: linear-gradient(180deg, #dbe7f3, #f4f7fb); border-radius: 14px; height: 340px; position: relative; overflow: hidden; }
.avatar-preview canvas { width: 100% !important; height: 100% !important; display: block; }
.persos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.persos button { border: 2px solid var(--line); border-radius: 12px; background: #f8fafc; padding: 4px; cursor: pointer; }
.persos button.on { border-color: var(--navy); background: #e8edf7; }
.persos img { width: 100%; display: block; aspect-ratio: 1; }
.persos span { font-size: 12px; font-weight: 600; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.swatches button.on { box-shadow: 0 0 0 3px var(--navy); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy); }
.pills button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.epi { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.epi span { background: #ecfdf5; color: #065f46; border-radius: 8px; padding: 4px 9px; font-weight: 600; }

/* Jeu */
#game { position: fixed; inset: 0; background: #0b1220; }
#viewport { position: absolute; inset: 0; touch-action: none; }
.hud { position: absolute; pointer-events: none; color: #fff; font-size: 14px; }
.hud .panel { background: rgba(15, 23, 42, .78); border-radius: 12px; padding: 10px 14px; pointer-events: auto; backdrop-filter: blur(4px); }
.hud-top-left { top: 12px; left: 12px; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.hud-top-right { top: 12px; right: 12px; }
.hud-btns { justify-content: flex-end; margin-top: 8px; gap: 6px; }
#btn-team, .fold { display: none; }
.hud-bottom { left: 50%; transform: translateX(-50%); bottom: 16px; text-align: center; }
.hud .zone { font-weight: 700; font-size: 17px; }
.hud .zone small { display: block; font-weight: 400; opacity: .7; font-size: 12px; }
.hud .team li { list-style: none; display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.hud .team ul { margin: 6px 0 0; padding: 0; }
.hud .keys { font-size: 12px; opacity: .85; }
.hud kbd { background: rgba(255, 255, 255, .15); border-radius: 5px; padding: 1px 6px; font-family: inherit; font-weight: 700; }
.hud .interact { background: var(--yellow); color: var(--navy); font-weight: 700; border-radius: 10px; padding: 8px 14px; border: 0; pointer-events: auto; cursor: pointer; font-size: 15px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.hud-btn { pointer-events: auto; background: rgba(15, 23, 42, .78); color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11, 18, 32, .62); backdrop-filter: blur(3px); z-index: 5; padding: 16px; }
.overlay .card { text-align: center; max-width: 480px; }
.toast { position: absolute; top: 14px; max-width: min(520px, calc(100% - 760px)); min-width: 260px; text-align: center; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, .9); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 6; transition: opacity .4s; }
.joystick { position: fixed; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .15); border: 2px solid rgba(255, 255, 255, .35); z-index: 4; pointer-events: none; }
.joystick-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .65); }
.disclaimer { font-size: 11px; opacity: .7; }
.disclaimer .short { display: none; }

/* Tableau de bord enseignant */
.tabs { display: flex; gap: 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f8fafc; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 26px; color: var(--navy); }
.kpi span { font-size: 13px; color: var(--muted); }
.codebox { background: var(--navy); color: #fff; border-radius: 14px; padding: 14px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.codebox .code { font-size: 38px; font-weight: 800; letter-spacing: 8px; color: var(--yellow); }
.codebox .link { font-size: 14px; opacity: .9; word-break: break-all; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.group { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.group header { color: #fff; padding: 8px 12px; font-weight: 700; display: flex; justify-content: space-between; }
.group ul { list-style: none; margin: 0; padding: 6px 10px; }
.group li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.group li:last-child { border-bottom: 0; }
.group li .meta { font-size: 12px; color: var(--muted); }
.group li select { padding: 2px 4px; font-size: 12px; width: auto; border-radius: 6px; }
.tree details { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.tree summary { padding: 10px 12px; cursor: pointer; font-weight: 700; }
.tree .theme { padding: 4px 12px 10px 24px; }
.tree .theme h4 { margin: 8px 0 4px; font-size: 14px; }
.tree .mission { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tree .mission:hover { background: #f1f5f9; }
.tree .mission.on { background: #e8edf7; outline: 2px solid var(--navy); }
.tree .mission.off { opacity: .5; cursor: not-allowed; }
.map-wrap { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 12px; }
#minimap { width: 100%; height: auto; display: block; }
.sizes { display: flex; gap: 8px; }
.sizes button { width: 52px; height: 48px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 18px; cursor: pointer; color: var(--navy); }
.sizes button.on { border-color: var(--navy); background: #e8edf7; }
input[type=range] { width: 100%; accent-color: var(--navy); }
@media (max-width: 900px) { #g-cols { grid-template-columns: 1fr !important; } }

/* ---------- Missions ---------- */
.mpanel-wrap { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(11,18,32,.45); padding: 12px; }
.mpanel { background: #fff; color: var(--text); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.mpanel.wide { width: min(900px, 100%); }
.mpanel header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.mpanel header h2 { font-size: 20px; margin: 0; }
.mpanel header .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.mclose { border: 0; background: #f1f5f9; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 16px; flex: none; }
.mbody { padding: 16px 20px 20px; overflow: auto; min-height: 0; }
.mbody p { margin: 0 0 10px; }
.mchoices { display: grid; gap: 8px; margin-top: 10px; }
.mchoice { text-align: left; border: 2px solid var(--line); background: #f8fafc; border-radius: 12px; padding: 12px 14px; cursor: pointer; font-weight: 600; color: var(--navy); font-size: 15px; }
.mchoice:hover { border-color: var(--navy-2); background: #eef2ff; }
.mchoice:disabled { opacity: .5; cursor: default; }
.mchoice.done { border-color: var(--ok); background: #ecfdf5; color: #065f46; }
.quote { background: #f1f5f9; border-left: 4px solid var(--navy-2); padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.quote b { color: var(--navy); }
.mfeedback { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); z-index: 9; width: min(560px, calc(100% - 24px)); display: grid; grid-template-columns: 40px 1fr; gap: 10px; background: #fff; color: var(--text); border-radius: 14px; padding: 12px 16px; box-shadow: 0 14px 40px rgba(0,0,0,.3); border-left: 8px solid #64748b; cursor: pointer; }
.mfeedback .ic { font-size: 26px; line-height: 1; padding-top: 2px; }
.mfeedback .expl { margin-top: 6px; font-size: 13px; color: #334155; background: #f8fafc; border-radius: 8px; padding: 6px 8px; }
.mfeedback.v-bon, .mfeedback.v-procedure, .mfeedback.v-ok { border-left-color: var(--ok); }
.mfeedback.v-detecte { border-left-color: #7c3aed; }
.mfeedback.v-erreur, .mfeedback.v-mauvaise { border-left-color: var(--warn); }
.mfeedback.v-danger { border-left-color: var(--bad); }
.doc { background: #fffdf5; border: 1px solid #e5dcc0; border-radius: 6px; padding: 14px 16px; font-family: "Courier New", ui-monospace, monospace; font-size: 13px; color: #111; margin-bottom: 12px; }
.doc h3 { font-family: "Segoe UI", system-ui, sans-serif; font-size: 15px; letter-spacing: .5px; text-transform: uppercase; border-bottom: 2px solid #111; padding-bottom: 4px; }
.doc .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.doc .grid div small { display: block; font-family: "Segoe UI", sans-serif; color: #6b7280; font-size: 11px; text-transform: uppercase; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc th, .doc td { border: 1px solid #d6cfb6; padding: 4px 6px; text-align: left; }
.doc th { background: #f4efdc; font-family: "Segoe UI", sans-serif; font-size: 11px; text-transform: uppercase; }
.doc .stamp { display: inline-block; border: 2px solid #b91c1c; color: #b91c1c; padding: 2px 8px; transform: rotate(-4deg); font-weight: 700; margin-top: 6px; }
.form-table { width: 100%; border-collapse: collapse; }
.form-table th, .form-table td { border-bottom: 1px solid var(--line); padding: 7px 6px; text-align: left; font-size: 14px; }
.form-table input[type=number], .form-table input[type=text], .form-table select { padding: 6px 8px; border-radius: 8px; width: 100%; }
.hint { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.checkrow { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 6px; cursor: pointer; font-weight: 600; }
.checkrow input { width: 18px; height: 18px; }
.hud .mission-steps { list-style: none; margin: 6px 0 0; padding: 0; }
.hud .mission-steps li { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; opacity: .75; }
.hud .mission-steps li.cur { opacity: 1; font-weight: 700; color: #fde68a; }
.hud .mission-steps li.ok { opacity: .6; text-decoration: line-through; }
.hud .feed { font-size: 12px; margin: 6px 0 0; padding: 0; list-style: none; }
.hud .feed li { padding: 1px 0; }
.hud .feed .v-bon, .hud .feed .v-procedure { color: #86efac; }
.hud .feed .v-detecte { color: #d8b4fe; }
.hud .feed .v-erreur, .hud .feed .v-mauvaise { color: #fcd34d; }
.hud .feed .v-danger { color: #fca5a5; }
.mbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.mbar .hud-btn { font-size: 14px; }
.hud .roles { font-size: 12px; margin-top: 4px; opacity: .9; }
.drive-pad { position: absolute; right: 16px; bottom: 120px; display: grid; gap: 8px; z-index: 4; }
.drive-pad { grid-template-columns: 64px 64px; }
.drive-pad button { width: 64px; height: 58px; border-radius: 14px; border: 0; background: rgba(15,23,42,.82); color: #fff; font-weight: 800; font-size: 20px; line-height: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.drive-pad button small { display: block; font-size: 10px; font-weight: 600; opacity: .8; margin-top: 3px; }
.drive-pad button.on, .drive-pad button:active { background: #f2c500; color: var(--navy); }
.drive-pad .brake { background: rgba(185, 28, 28, .85); }
.drive-pad .exit { grid-column: 1 / -1; width: auto; height: 44px; font-size: 14px; }
.gauge { font-variant-numeric: tabular-nums; }
.interrupt .card { border-top: 8px solid var(--bad); text-align: left; }
.bilan-table td, .bilan-table th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: top; }
.lvl { font-weight: 700; border-radius: 999px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }
.lvl.maitrisee { background: #dcfce7; color: #166534; }
.lvl.partielle { background: #fef3c7; color: #92400e; }
.lvl.a_ameliorer { background: #fee2e2; color: #991b1b; }
.st { font-weight: 700; white-space: nowrap; }
.st.bonne { color: var(--ok); } .st.mauvaise { color: var(--warn); } .st.non_detecte { color: var(--bad); } .st.en_attente { color: var(--muted); }
.roles-chips { display: flex; gap: 3px; margin-top: 4px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 1px 5px; font-size: 14px; cursor: pointer; opacity: .35; }
.chip.on { opacity: 1; border-color: var(--navy); background: #e8edf7; }
.chip:disabled { cursor: default; }
.gsum { padding: 8px 12px; border-bottom: 1px solid #eef2f6; background: #f8fafc; }
.bar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-bottom: 5px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e); }
@media print { .topbar, #btn-bilan-back, #btn-export, #btn-print { display: none !important; } body { background: #fff; } .card { box-shadow: none; border: 1px solid #ddd; } }
.fork-gauge { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 92px; background: rgba(15,23,42,.82); color: #fff; border-radius: 12px; padding: 10px; z-index: 4; display: grid; grid-template-columns: 26px 1fr; gap: 6px; }
.fork-gauge .fg-label { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-align: center; }
.fg-track { position: relative; height: 170px; background: #334155; border-radius: 6px; }
.fg-entry { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: #22c55e; border-radius: 0 0 6px 6px; opacity: .8; }
.fg-level { position: absolute; left: -6px; right: -6px; height: 5px; background: #ff3b30; border-radius: 3px; transform: translateY(50%); box-shadow: 0 0 6px rgba(255,59,48,.8); }
.fork-gauge.low .fg-level { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.9); }
.fg-scale { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; opacity: .8; height: 170px; }
.drive-status { position: absolute; right: 18px; top: calc(50% - 150px); transform: translateY(-100%); max-width: 260px; z-index: 4; padding: 9px 16px; border-radius: 12px; font-weight: 700; background: rgba(15,23,42,.85); color: #fff; border-left: 6px solid #94a3b8; }
.drive-status.ok { border-left-color: #22c55e; }
.drive-status.warn { border-left-color: #f59e0b; }
.hud .guide { margin-bottom: 8px; max-width: min(640px, 92vw); text-align: left; border-left: 6px solid #64748b; }
.hud .guide.mine { border-left-color: #facc15; background: rgba(30, 41, 59, .92); }
.hud .mission-steps.sub { margin-left: 14px; font-size: 12px; }
.hud-btn.pulse { animation: pulse 1.2s infinite; background: #b45309; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, .7); } 50% { box-shadow: 0 0 0 8px rgba(250, 204, 21, 0); } }
.teacher-msg { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 20; background: #fff7d6; color: #422006; border: 3px solid #f2c500; border-radius: 16px; padding: 16px 22px; max-width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); font-size: 17px; cursor: pointer; }
.teacher-msg b { display: block; margin-bottom: 6px; color: #92400e; }

/* ---------- Téléphones et tablettes ---------- */
.touch-only { display: none; }
html.touch .touch-only { display: block; }
html.touch .keyboard-only { display: none !important; }
#game, #game * { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game button { touch-action: manipulation; }
#game .mpanel, #game .mpanel * { -webkit-user-select: text; user-select: text; }
.rotate-hint { display: none; z-index: 30; }
@media (orientation: portrait) and (max-width: 700px) { html.touch #game:not(.rotate-ok) .rotate-hint { display: grid; } }
.hud-top-left { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
.hud-top-right { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.hud-bottom { bottom: max(16px, env(safe-area-inset-bottom)); }
.mpanel { max-height: calc(100dvh - 24px); }
.mbody { overflow-x: auto; }
.zone-panel { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.fold { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; width: 30px; height: 30px; font-size: 15px; cursor: pointer; flex: none; transition: transform .2s; }
.hud-top-left.folded .fold { transform: rotate(-90deg); }
.hud-top-left.folded #hud-mission { display: none; }

/* Tablettes (et grands téléphones) : interface tactile plus généreuse */
html.touch .hud-btn { padding: 10px 13px; font-size: 15px; }
html.touch .hud .interact { padding: 13px 22px; font-size: 17px; }
html.touch .interact::before { content: "👆 "; }
html.touch .mchoice { padding: 14px 16px; }

/* Petits écrans (téléphones, à l'horizontale ou à la verticale) */
@media (max-width: 900px), (max-height: 560px) {
  .topbar { padding: 6px 12px; }
  .brand small { display: none; }
  .center-page { padding: 12px 8px; min-height: calc(100% - 46px); }
  .card { padding: 16px; }
  .avatar-preview { height: 220px; }
  h1 { font-size: 22px; }
  .hud { font-size: 13px; }
  .hud .panel { padding: 7px 10px; border-radius: 10px; }
  .hud-top-left { max-width: min(300px, 42vw); gap: 6px; }
  .hud .zone { font-size: 14px; }
  .hud .zone small { display: none; }
  #hud-mission { max-height: calc(100dvh - 170px); overflow-y: auto; }
  .hud .feed li:nth-last-child(n+3) { display: none; }
  .fold { display: block; }
  #btn-team { display: inline-block; }
  .hud-btns .lbl { display: none; }
  .hud-btn { padding: 8px 10px; }
  #hud-teampanel { display: none; }
  #hud-teampanel.open { display: block; position: absolute; right: 0; top: 46px; min-width: 180px; }
  .hud-top-right { display: flex; flex-direction: column-reverse; align-items: flex-end; }
  .hud-btns { margin-top: 0; }
  .hud-bottom { width: min(560px, 54vw); }
  .hud .guide { font-size: 12.5px; padding: 6px 10px; margin-bottom: 6px; }
  .mbar { margin-top: 6px; gap: 5px; }
  .mbar .hud-btn { font-size: 13px; padding: 8px 10px; }
  .toast { max-width: min(70vw, 520px); min-width: 0; font-size: 13px; top: 58px; }
  .disclaimer .long, #drive-hud .lbl-long { display: none; }
  .disclaimer .short { display: inline; }
  #drive-hud { padding: 5px 10px; margin-top: 4px !important; }
  .mfeedback { top: 58px; font-size: 13px; padding: 9px 12px; grid-template-columns: 30px 1fr; }
  .mfeedback .ic { font-size: 22px; }
  .mpanel-wrap { padding: 0; }
  .mpanel { width: 100% !important; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .mpanel header { padding: max(10px, env(safe-area-inset-top)) 14px 8px; }
  .mpanel header h2 { font-size: 17px; }
  .mclose { width: 42px; height: 42px; font-size: 18px; }
  .mbody { padding: 12px 14px max(16px, env(safe-area-inset-bottom)); }
  .overlay .card { max-height: calc(100dvh - 24px); overflow: auto; }
  #drive-hud { font-size: 12px; }
  .fork-gauge { right: max(10px, env(safe-area-inset-right)); top: 64px; transform: none; width: 74px; padding: 6px; grid-template-columns: 22px 1fr; }
  .fg-track, .fg-scale { height: 90px; }
  .fg-scale { font-size: 9.5px; }
  .drive-status { top: 64px; right: calc(max(10px, env(safe-area-inset-right)) + 82px); transform: none; max-width: 220px; font-size: 12.5px; padding: 6px 10px; }
  .drive-pad { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); gap: 6px; grid-template-columns: 56px 56px; }
  .drive-pad button { width: 56px; height: 50px; font-size: 18px; }
  .drive-pad .exit { width: auto; height: 38px; font-size: 13px; }
  .teacher-msg { font-size: 15px; padding: 12px 16px; }
  .joystick { width: 104px; height: 104px; }
  .joystick-knob { left: 29px; top: 29px; width: 46px; height: 46px; }
}
/* Téléphone à la verticale */
@media (max-width: 560px) {
  .hud-top-left { max-width: 62vw; }
  .hud-bottom { width: calc(100vw - 20px); }
  #hud-mission { max-height: 34dvh; }
}

/* Guide : cadre qui clignote à chaque nouvelle action, flèche au bord de l'écran vers la balise */
.hud .guide.flash { animation: guideFlash .55s ease-in-out 6; }
@keyframes guideFlash { 0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); background: rgba(30, 41, 59, .92); } 50% { box-shadow: 0 0 0 6px rgba(250, 204, 21, .75); background: rgba(161, 98, 7, .95); } }
.guide-arrow { position: absolute; z-index: 7; transform: translate(-50%, -50%); pointer-events: none; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: rgba(250, 204, 21, .95); color: #14213d; box-shadow: 0 4px 16px rgba(0,0,0,.35); transition: opacity .15s; }
.guide-arrow.dim { opacity: .45; }
.guide-arrow .ga-ic { display: block; }
.guide-arrow .ga-d { font-size: 11px; font-weight: 800; margin-top: -6px; }

/* Création de partie : contenu (module / révision / mission) */
.choice.three button { font-size: 15px; padding: 10px; }
.modlist { display: grid; gap: 8px; }
.modbtn { text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--navy); font-size: 14px; }
.modbtn.on { border-color: var(--navy); background: #e8edf7; }

/* Compte apprenti */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #eef2f7; padding: 4px; border-radius: 12px; }
.tabs button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--navy); cursor: pointer; }
.tabs button.on { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.classeur { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.classeur li { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.classeur li .grow { min-width: 0; }
.hud-timer { background: rgba(15,23,42,.85); color: #fff; font-weight: 800; border-radius: 10px; padding: 7px 11px; font-variant-numeric: tabular-nums; pointer-events: none; }
.hud-timer.warn { background: #b91c1c; animation: pulse 1s infinite; }
/* Parcours par module */
.pstep h3 { margin: 4px 0 8px; }
.pdialog { background: #f1f5f9; border-left: 4px solid var(--navy); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.pdialog b { color: var(--navy); }
.pdoc { background: #fffbea; border: 1px solid #f2c500; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.pq { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.pq.ok { border-color: #16a34a; background: #f0fdf4; }
.pq .mchoice.sel-ko { border-color: #dc2626; background: #fef2f2; }
.pq .mchoice.sel-ok { border-color: #16a34a; background: #dcfce7; }
.pexpl { font-size: 13px; color: #334155; background: #eef6ff; border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.pmatch { display: grid; gap: 10px; }
.pmitem { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.pmsit { margin-bottom: 6px; }
.pmrow { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; margin: 4px 0; font-size: 13px; font-weight: 600; color: #475569; }
.pmrow select { width: 100%; font-size: 14px; }
@media (max-width: 600px) { .pmrow { grid-template-columns: 1fr; gap: 2px; } }
.porder li { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; background: #fff; }
.porder li .grow { flex: 1; }
.porder button { min-width: 36px; }
.pchecks label { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; font-weight: 500; }
.pchecks input { width: auto; margin-top: 3px; }
.ponenote { border: 2px dashed #7c3aed; background: #faf5ff; border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.ponenote .path { font-weight: 700; color: #6d28d9; }
.ponenote.done { border-style: solid; border-color: #16a34a; background: #f0fdf4; }
.perp { width: 100%; font-size: 13px; border-collapse: collapse; margin-bottom: 10px; }
.perp td { border: 1px solid var(--line); padding: 4px 8px; }
.corrige-view { user-select: none; -webkit-user-select: none; }
.corrige-view h4 { margin: 14px 0 6px; color: var(--navy); }
.corrige-view dt { font-weight: 700; margin-top: 6px; }
.corrige-view dd { margin: 2px 0 6px 0; }
@media print { .corrige-view, .mpanel-wrap { display: none !important; } }
