:root {
  --accent: #f2b84b;
  --ink: #edeae0;
  --muted: #aab0cc;
  --panel: rgba(17, 21, 42, .94);
  --panel-2: #1b2142;
  --line: rgba(255, 255, 255, .13);
  --ok: #59c98a;
  --ko: #ef6b72;
  --serif: "Constantia", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0e1c; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
#app { min-height: 100%; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; }
h4 { margin: 1em 0 .4em; color: var(--accent); }
p { margin: .5em 0; }
.hidden { display: none !important; }
.small { font-size: .85rem; color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.scroll-x { overflow-x: auto; max-width: 100%; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem 1rem; transition: transform .12s, background .2s, border-color .2s; }
.btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #14162a; border-color: transparent; font-weight: 700; }
.btn.big { font-size: 1.15rem; padding: .75rem 2.2rem; }
.btn.danger { border-color: rgba(239, 107, 114, .5); color: #ffb4b8; }
.mini { background: rgba(10, 13, 28, .75); border: 1px solid var(--line); border-radius: 8px; padding: .25rem .65rem; font-size: .82rem; }
.mini.on { border-color: var(--accent); color: var(--accent); }
.x { background: none; border: 0; font-size: 1.2rem; padding: .2rem .5rem; border-radius: 6px; }
.x:hover { background: rgba(255, 255, 255, .1); }
.link { color: var(--muted); font-size: .9rem; }

input, select { font: inherit; color: var(--ink); background: #0e1227; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; }
input:focus, select:focus { border-color: var(--accent); outline: none; }
input.num { width: 8.5rem; font-variant-numeric: tabular-nums; text-align: right; }
input.bad, select.bad { border-color: var(--ko); background: #2a1222; }
.field { display: flex; align-items: center; gap: .6rem; margin: .45rem 0; flex-wrap: wrap; }
.field.center { justify-content: center; }
.flabel { min-width: 9rem; }
.unit { color: var(--muted); }

.audio-toggles { position: fixed; right: .7rem; bottom: .6rem; display: flex; gap: .4rem; z-index: 5; }

/* ---------- Écrans ---------- */
.screen { min-height: 100vh; min-height: 100dvh; position: relative; }
.screen.title, .screen.hub, .screen.story, .screen.end {
  background: linear-gradient(180deg, rgba(9, 11, 24, .35), rgba(9, 11, 24, .88)), var(--bg) center / cover fixed;
}
.screen.title { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.title-card { width: min(34rem, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 2rem 2.4rem; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); animation: rise .6s ease both; }
.title-card h1 { font-size: clamp(2.6rem, 7vw, 4rem); color: var(--accent); text-shadow: 0 4px 30px rgba(242, 184, 75, .35); }
.kicker { text-transform: uppercase; letter-spacing: .22em; font-size: .75rem; color: var(--accent); margin: 0 0 .4rem; }
.lead { color: var(--muted); }
.title-form { text-align: left; margin: 1.2rem 0; }
.title-form .field input { flex: 1; min-width: 10rem; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; }
.title-card .row { justify-content: center; margin-bottom: .8rem; }

.screen.hub { padding: 1.2rem clamp(1rem, 3vw, 2.5rem) 3.5rem; }
.hub-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.hub-head h2 { font-size: 2rem; margin: 0; }
.hub-team { text-align: right; font-weight: 700; }
.hub-team span { font-weight: 400; color: var(--muted); font-size: .85rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; margin: 1.4rem auto; max-width: 1500px; }
@media (min-width: 1250px) { .cards { grid-template-columns: repeat(5, 1fr); } }
.card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; transition: transform .18s, border-color .2s, box-shadow .2s; }
.card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.card-img { display: block; aspect-ratio: 16 / 10; background-size: cover; background-position: center; position: relative; }
.card-num { position: absolute; left: .6rem; top: .6rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #12142a; font: 700 1.1rem var(--serif); }
.card-body { display: flex; flex-direction: column; gap: .2rem; padding: .8rem .9rem 1rem; flex: 1; }
.card-chapter { color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.card-title { font: 600 1.15rem var(--serif); }
.card-status { color: var(--muted); font-size: .85rem; margin-top: auto; }
.card.done { border-color: rgba(89, 201, 138, .6); }
.hub-foot { display: flex; gap: 1rem; justify-content: center; align-items: center; }
.stars { color: #ffd25e; letter-spacing: .1em; }
.stars i { color: #4a5078; font-style: normal; }

.screen.story, .screen.end { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.story-card { width: min(46rem, 100%); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 18px; padding: 1.8rem 2.2rem; animation: rise .6s ease both; }
.story-card.wide { width: min(68rem, 100%); }
.story-card h2 { font-size: 2.1rem; }
.story-card .row { margin-top: 1.2rem; justify-content: space-between; }
.transition .story-card, .diploma { text-align: center; }
.diploma h3 { font-size: 2.4rem; color: var(--accent); }
.seals { color: #ffd25e; font-size: 1.6rem; }
.story-meta { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.story-meta span { background: var(--panel-2); border-radius: 99px; padding: .25rem .8rem; font-size: .85rem; }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 1.2rem 0; text-align: center; }
.end-stats div { background: var(--panel-2); border-radius: 12px; padding: .8rem; display: flex; flex-direction: column; font-size: 1.3rem; }
.end-stats span:last-child { font-size: .8rem; color: var(--muted); }
.lvl { white-space: nowrap; font-weight: 700; }
.lvl.a { color: var(--ok); } .lvl.b { color: #f2b84b; } .lvl.c { color: var(--ko); }

/* ---------- Salle ---------- */
.screen.room { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.screen.room::before { content: ""; position: absolute; inset: 0; background: var(--bg) center / cover; filter: blur(28px) brightness(.35); transform: scale(1.1); z-index: -1; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 1rem; background: rgba(10, 13, 28, .85); border-bottom: 1px solid var(--line); }
.hud-left, .hud-right { display: flex; align-items: center; gap: .8rem; }
.hud-title { display: flex; flex-direction: column; line-height: 1.25; }
.hud-title b { font: 600 1.2rem var(--serif); color: var(--accent); }
.hud-title span { font-size: .78rem; color: var(--muted); }
.hud-chip { background: var(--panel-2); border-radius: 8px; padding: .3rem .7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-progress { width: 12rem; height: 8px; background: var(--panel-2); border-radius: 9px; overflow: hidden; }
.hud-progress i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.stage-wrap { min-height: 0; display: flex; align-items: center; justify-content: center; padding: .6rem; container-type: size; }
.stage { position: relative; width: min(100cqw, 175cqh); aspect-ratio: 1344 / 768; background-size: cover; border-radius: 14px; box-shadow: 0 20px 70px rgba(0, 0, 0, .65); animation: fade .7s both; }
.spot { position: absolute; transform: translate(-50%, -50%); background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: 0; }
.spot .ring { width: 2.9rem; height: 2.9rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem; background: rgba(13, 16, 34, .82); border: 2px solid var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s infinite; transition: transform .15s; }
.spot.doc .ring { width: 2.4rem; height: 2.4rem; font-size: 1.1rem; border-color: #cfe8ff; color: #cfe8ff; }
.spot.doc.seen .ring { animation: none; opacity: .75; }
.spot.solved .ring { border-color: var(--ok); color: var(--ok); animation: none; }
.spot.locked .ring { border-color: #777da0; animation: none; filter: grayscale(.6); }
.spot.exit .ring { width: 3.4rem; height: 3.4rem; font-size: 1.7rem; }
.spot.exit.ready .ring { background: var(--accent); color: #12142a; animation: pulse 1.1s infinite; }
.spot .tag { background: rgba(10, 13, 28, .88); border: 1px solid var(--line); border-radius: 7px; padding: .1rem .55rem; font-size: .8rem; white-space: nowrap; }
.spot:hover .ring { transform: scale(1.18); }
.spot:hover { z-index: 3; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .5rem 11rem .5rem 1rem; background: rgba(10, 13, 28, .85); border-top: 1px solid var(--line); }
.frags { margin-left: auto; display: flex; gap: .4rem; }
.frag { display: inline-block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .2rem .6rem; color: var(--muted); }
.frag.on { border-color: var(--accent); color: var(--accent); }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 18, .66); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 20; animation: fade .25s both; }
.modal { width: min(46rem, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 16px; box-shadow: 0 30px 90px rgba(0, 0, 0, .7); animation: rise .3s ease both; }
.modal.wide { width: min(80rem, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.35rem; }
.modal-content { overflow: auto; padding: 1rem 1.2rem 1.3rem; }
.modal.shake { animation: shake .4s; }
.story-text p { font: 1.15rem/1.65 var(--serif); }
.paper { background: #f3ecd9; color: #23233a; border-radius: 10px; padding: 1rem 1.3rem; }
.paper h4 { color: #7a4a12; margin-top: .4em; }
.paper .small { color: #5d5a50; }
.paper .btn { background: #e4dabd; border-color: #b7a77a; }
.puzzle { display: flex; gap: 1.2rem; align-items: flex-start; }
.puzzle-main { flex: 1; min-width: 0; }
.puzzle-side { width: 46%; max-height: calc(100vh - 9rem); overflow: auto; position: sticky; top: 0; }
.puzzle-side h4 { margin-top: 0; }
.puzzle-intro { color: var(--muted); font-style: italic; }
.doc-chips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: .25rem .8rem; font-size: .88rem; }
.chip:hover { border-color: var(--accent); }
.chip.on { border-color: var(--accent); }
.step-dots { display: flex; gap: .35rem; margin: .7rem 0; }
.step-dots i { height: 5px; flex: 1; border-radius: 5px; background: var(--panel-2); }
.step-dots i.done { background: var(--ok); }
.step-dots i.now { background: var(--accent); }
.question { font-size: 1.07rem; margin-bottom: .8rem; }
.qnum { font-size: .75rem; text-transform: uppercase; letter-spacing: .15em; color: var(--accent); }
.answer-area.frozen { pointer-events: none; opacity: .8; }
.actions { margin-top: 1rem; }
.feedback { margin-top: .8rem; border-radius: 10px; }
.feedback.ok, .feedback.ko, .feedback.info { padding: .7rem 1rem; border: 1px solid; }
.feedback.ok { border-color: var(--ok); background: rgba(89, 201, 138, .13); }
.feedback.ko { border-color: var(--ko); background: rgba(239, 107, 114, .13); }
.feedback.info { border-color: var(--accent); background: rgba(242, 184, 75, .1); }
.feedback .btn { margin-top: .6rem; }
.hint { margin-top: .6rem; padding: .6rem .9rem; border-left: 4px solid var(--accent); background: var(--panel-2); border-radius: 0 8px 8px 0; }
.hint.solution { border-color: var(--ko); }
.success-panel { text-align: center; padding: 1.5rem 0; }
.success-panel h4 { color: var(--ok); font: 600 1.7rem var(--serif); margin: 0; }
.bigfrag { display: inline-block; font: 700 2rem var(--serif); color: var(--accent); border: 2px solid var(--accent); border-radius: 12px; padding: 0 1rem; margin-left: .5rem; animation: pop .6s both; }
.puzzle-main > .btn { display: block; margin: 0 auto; }

/* ---------- Composants ---------- */
table.data { border-collapse: collapse; margin: .7rem 0; font-variant-numeric: tabular-nums; }
table.data th, table.data td { border: 1px solid rgba(140, 145, 180, .5); padding: .3rem .7rem; text-align: center; }
table.data th { background: rgba(120, 130, 180, .2); font-weight: 600; }
table.data th.rowh { text-align: left; }
table.data td.cell { padding: .2rem .35rem; white-space: nowrap; }
table.data td.cell input { width: 6rem; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 .15em; }
.frac span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .25em; }
.formula { font-family: var(--serif); font-size: 1.12rem; background: rgba(120, 130, 180, .16); border-radius: 8px; padding: .45rem .8rem; display: inline-block; margin: .3rem 0; }
pre.code { background: #10142b; color: #d8e6ff; border-radius: 10px; padding: .8rem 1rem; font: .95rem/1.6 "Cascadia Code", Consolas, monospace; overflow-x: auto; }
.choices { display: grid; gap: .5rem; }
.choices.short { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.choice { background: var(--panel-2); border: 2px solid var(--line); border-radius: 10px; padding: .6rem .9rem; text-align: left; }
.choices.short .choice { text-align: center; }
.choice:hover { border-color: var(--muted); }
.choice.on { border-color: var(--accent); background: rgba(242, 184, 75, .16); }
.order-pool { display: flex; gap: .45rem; flex-wrap: wrap; min-height: 2.4rem; }
.order-line { display: flex; flex-direction: column; gap: .3rem; padding-left: 1.6rem; }
.slot { color: #626890; }
.match-row { display: grid; grid-template-columns: 1fr minmax(9rem, 16rem); gap: .8rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.interactive { max-width: 100%; overflow-x: auto; text-align: center; }
.chart { max-width: 100%; height: auto; background: #11152e; border-radius: 10px; user-select: none; }
.interactive .chart { touch-action: none; }
.doc-body { overflow-x: auto; }
.chart .gl { stroke: rgba(255, 255, 255, .11); stroke-width: 1; }
.chart .axis { stroke: #dfe3f5; stroke-width: 1.8; }
.chart .ax { fill: #c3c9e4; font-size: 12px; }
.chart .axt { fill: #f2b84b; font-size: 12px; font-weight: 700; }
.chart .pl { fill: #0d1020; font-size: 13px; font-weight: 700; }
.chart .pl.dark { fill: #fff; }
.chart .lg { fill: #e8e4d8; font-size: 13px; }
.chart .fl { fill: #fff; font-size: 15px; font-weight: 600; }
.bar-adjust { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-top: .5rem; }
.bar-cell { display: flex; flex-direction: column; align-items: center; font-size: .8rem; color: var(--muted); }
.bar-cell input.num { width: 6rem; text-align: center; }
.pie-build { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: center; }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .4rem; }
.angle-bar { display: flex; justify-content: center; gap: 1rem; align-items: center; margin-top: .4rem; }
.codelock { display: flex; justify-content: center; gap: .8rem; margin: 1rem 0; }
.wheel { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.wsym { font-size: 1.4rem; color: var(--accent); }
.wval { width: 3.6rem; height: 4.4rem; display: grid; place-items: center; font: 700 2.4rem var(--serif); background: linear-gradient(#05070f, #222a52 50%, #05070f); border: 2px solid var(--line); border-radius: 10px; }
.warrow { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; width: 3.6rem; padding: .15rem; }
.rush { text-align: center; background: var(--panel-2); border-radius: 12px; padding: 1rem; }
.rush-top { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; }
.rush-bar { height: 7px; background: #0d1020; border-radius: 6px; margin: .5rem 0; overflow: hidden; }
.rush-bar i { display: block; height: 100%; width: 100%; background: var(--accent); }
.rush-q { font: 600 1.7rem var(--serif); margin: .9rem 0; }
.rush-win { color: var(--ok); font-size: 1.2rem; font-weight: 700; }
.sim .data { margin-top: .4rem; }

.robot { display: flex; gap: 1rem; flex-wrap: wrap; }
.robot-left { flex: 0 1 auto; text-align: center; }
.robot-controls { display: flex; gap: .5rem; justify-content: center; margin-top: .5rem; }
.robot-prog { flex: 1; min-width: 16rem; }
.robot-msg.ok { color: var(--ok); font-weight: 700; } .robot-msg.ko { color: var(--ko); font-weight: 700; }
.palette { display: flex; gap: .35rem; flex-wrap: wrap; }
.pblock, .bhead { border: 0; border-radius: 8px; padding: .3rem .65rem; font-size: .86rem; color: #0d1020; font-weight: 600; }
.pblock.leaf, .block.leaf > .bhead { background: #6fd0e4; }
.pblock.container, .block.container > .bhead { background: #f2b84b; }
.blocks { max-height: 20rem; overflow: auto; background: #0e1227; border-radius: 10px; padding: .5rem; }
.block { margin: .25rem 0; }
.bhead { display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.bhead select { padding: 0 .3rem; font-size: .82rem; }
.bdel { background: none; border: 0; color: #0d1020; font-weight: 700; }
.bzone { margin-left: 1rem; border-left: 4px solid #f2b84b; padding: .15rem .4rem; cursor: pointer; min-height: 1.8rem; }
.bzone.active { background: rgba(242, 184, 75, .15); outline: 1px dashed var(--accent); }
.belse { margin-left: 1rem; color: var(--accent); font-size: .85rem; font-weight: 700; }
.bempty { color: #6d739a; font-size: .8rem; }
.bmain { width: 100%; background: none; border: 1px dashed var(--line); border-radius: 8px; font-size: .8rem; color: var(--muted); padding: .25rem; }
.bmain.active { border-color: var(--accent); color: var(--accent); }

.tool { position: fixed; right: 1rem; top: 4.5rem; z-index: 40; background: #151a36; border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .7); }
.tool-head { display: flex; gap: .5rem; align-items: center; padding: .35rem .7rem; cursor: move; touch-action: none; }
.tool-head span { margin-right: auto; font-weight: 700; color: var(--accent); }
.calc { width: 17rem; padding-bottom: .6rem; }
.calc-screen { width: calc(100% - 1.2rem); margin: 0 .6rem; text-align: right; font-size: 1.1rem; }
.calc-out { text-align: right; padding: .2rem .8rem; font-size: 1.25rem; min-height: 2rem; overflow-wrap: anywhere; }
.calc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; padding: 0 .6rem; }
.calc-keys button { border: 1px solid var(--line); border-radius: 7px; padding: .35rem 0; background: var(--panel-2); }
.calc-keys .op { color: var(--accent); }
.calc-keys .eq { background: var(--accent); color: #14162a; font-weight: 700; }
.pad { width: min(40rem, 92vw); }
.pad canvas { display: block; width: 100%; background: #f6f1e2; border-radius: 0 0 12px 12px; cursor: crosshair; touch-action: none; }

/* ---------- Note, examen, historique ---------- */
.grade { display: flex; gap: 1.5rem; align-items: center; justify-content: center; flex-wrap: wrap; margin: 1.2rem 0; }
.grade-note { font: 700 4.2rem/1 var(--serif); color: var(--accent); border: 3px solid var(--accent); border-radius: 18px; padding: .8rem 1.4rem; animation: pop .7s both; }
.grade-note small { font-size: 1.4rem; margin-left: .4rem; }
.grade-detail p { margin: .15rem 0; }
.story-card .end-stats { grid-template-columns: repeat(4, 1fr); }
.hud-chip.urgent { background: var(--ko); color: #14162a; font-weight: 700; }
.card.exam { grid-column: 1 / -1; flex-direction: row; border-width: 2px; border-color: var(--accent); }
.card.exam .card-img { width: 18rem; flex: none; aspect-ratio: 16 / 9; }
.card.exam .card-body { justify-content: center; }
.card.exam .card-status { margin-top: .4rem; }
.keybar { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.keybar .mini { min-width: 3rem; min-height: 2.4rem; font-size: 1.2rem; }

/* ---------- Téléphones et petits écrans ---------- */
@media (max-width: 800px), (max-height: 560px) {
  body { font-size: 15px; }
  .screen.title, .screen.hub, .screen.story, .screen.end { background-attachment: scroll; }
  .screen.title { padding: .8rem .8rem 3.5rem; }
  .title-card { padding: 1.3rem 1.1rem; }
  .flabel { min-width: 0; width: 100%; }
  .screen.hub { padding: .8rem .8rem 4rem; }
  .hub-head h2 { font-size: 1.4rem; }
  .hub-foot { flex-wrap: wrap; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
  .card-body { padding: .55rem .6rem .7rem; }
  .card-title { font-size: 1rem; }
  .card-chapter { font-size: .66rem; overflow-wrap: anywhere; }
  .card.exam .card-img { width: 38%; aspect-ratio: auto; }
  .screen.story, .screen.end { padding: .6rem .6rem 4rem; align-items: flex-start; }
  .story-card { padding: 1.1rem 1rem; min-width: 0; }
  .story-card h2 { font-size: 1.5rem; }
  .story-card .row { gap: .4rem; flex-wrap: wrap; }
  .story-card .end-stats { grid-template-columns: repeat(2, 1fr); }
  .grade-note { font-size: 3rem; }
  table.data th, table.data td { padding: .25rem .4rem; }
  table.data td.cell input { width: 4.6rem; padding: .4rem; }
  input, select { font-size: 16px; }

  /* La salle devient un décor surmontant une liste d'objets faciles à toucher. */
  .hud { padding: .3rem .5rem; gap: .4rem; }
  .hud-left, .hud-right { gap: .4rem; min-width: 0; }
  .hud-left .btn { padding: .4rem .55rem; font-size: 0; }
  .hud-left .btn::before { content: "←"; font-size: 1.1rem; }
  .hud-title b { font-size: .95rem; }
  .hud-title span, .hud-progress { display: none; }
  .hud-chip { padding: .2rem .45rem; font-size: .85rem; }
  .stage-wrap { display: block; overflow-y: auto; padding: .5rem; container-type: normal; }
  .stage { width: 100%; max-width: 40rem; margin: 0 auto; aspect-ratio: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .45rem; align-content: start;
    background-size: 100% auto; background-repeat: no-repeat; box-shadow: none; padding-top: min(57.14%, 22.9rem); border-radius: 12px; }
  .spot { position: static; transform: none; flex-direction: row; gap: .55rem; background: rgba(20, 25, 52, .95); border: 1px solid var(--line); border-radius: 12px; padding: .4rem .5rem; min-height: 3.2rem; text-align: left; }
  .spot .ring, .spot.doc .ring, .spot.exit .ring { width: 2.1rem; height: 2.1rem; flex: none; font-size: 1rem; animation: none; }
  .spot .tag { white-space: normal; background: none; border: 0; padding: 0; font-size: .85rem; line-height: 1.25; }
  .spot:hover .ring { transform: none; }
  .spot.exit { grid-column: 1 / -1; border-color: var(--accent); }

  .toolbar { padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom)); gap: .3rem; justify-content: space-between; }
  .toolbar .btn { padding: .4rem .6rem; font-size: 1.1rem; }
  .toolbar .btn span { display: none; }
  .frags { margin: 0; width: 100%; justify-content: center; }
  .screen.room .audio-toggles { display: none; }
  .audio-toggles { right: .4rem; bottom: .4rem; }

  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-height: 100dvh; height: 100%; border-radius: 0; }
  .modal.doc { height: auto; max-height: 100dvh; align-self: center; }
  .modal-head { padding: .5rem .8rem; }
  .modal-head h3 { font-size: 1.1rem; }
  .x { min-width: 2.6rem; min-height: 2.6rem; }
  .modal-content { padding: .7rem .7rem 1.5rem; }
  .paper { padding: .8rem; }
  .puzzle { flex-direction: column; align-items: stretch; }
  .puzzle-side { width: 100%; max-height: none; position: static; order: -1; border-bottom: 2px solid var(--accent); padding-bottom: .6rem; }
  .match-row { grid-template-columns: 1fr; gap: .25rem; }
  .match-row select { max-width: 100%; }
  .robot-left { flex: 1 1 100%; }
  .robot-prog { min-width: 0; flex-basis: 100%; }
  .pblock { padding: .55rem .7rem; }
  .blocks { max-height: none; }
  .codelock { gap: .45rem; }
  .tool { top: auto !important; bottom: .4rem; right: .4rem; max-width: calc(100vw - .8rem); max-height: calc(100dvh - .8rem); overflow: auto; }
  .calc-keys button { min-height: 2.5rem; }
}

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 14px transparent; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media print {
  body, .screen.end { background: #fff !important; color: #000; }
  .noprint, .audio-toggles, .tool { display: none !important; }
  .grade-note { color: #000; border-color: #000; }
  .story-card { background: #fff; color: #000; border: 1px solid #999; }
  .story-card h2, .story-card h3, .story-card h4, .kicker { color: #000; }
  .end-stats div { background: #eee; }
  .lvl.a, .lvl.b, .lvl.c, .stars { color: #000; }
}
