/* ============================================================
   FAST XR Pause — thème « braise nocturne »
   Mobile-first, tactile, zéro dépendance externe
   ============================================================ */

:root {
  --fire:        #FF5722;
  --fire-light:  #FF8A50;
  --ember:       #D32F2F;
  --gold:        #FFC107;
  --ok:          #4CAF50;
  --ok-soft:     rgba(76, 175, 80, .18);
  --ko:          #EF5350;
  --ko-soft:     rgba(239, 83, 80, .16);
  --bg:          #141417;
  --bg-raise:    #1E1E24;
  --bg-card:     #232329;
  --line:        rgba(255, 255, 255, .09);
  --text:        #F5F2EE;
  --text-dim:    rgba(245, 242, 238, .62);
  --radius:      18px;
  --shadow:      0 10px 30px rgba(0, 0, 0, .45);
  --font: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Halo de braises en fond */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 38% at 50% 112%, rgba(255, 87, 34, .22), transparent 70%),
    radial-gradient(45% 30% at 88% -8%, rgba(211, 47, 47, .14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative; z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: 0 18px;
}

/* ---------- Header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
  min-height: 58px;
}
header img.logo { height: 26px; display: block; }
.header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform .12s ease, color .15s, border-color .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.active { color: var(--fire-light); border-color: var(--fire); }
.score-chip {
  display: none;
  align-items: center; gap: 6px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700; font-size: 15px;
  letter-spacing: .02em;
}
.score-chip.visible { display: inline-flex; }
.score-chip .pts { color: var(--gold); font-variant-numeric: tabular-nums; }
.score-chip.bump { animation: bump .45s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); box-shadow: 0 0 18px rgba(255, 193, 7, .35); }
  100% { transform: scale(1); }
}

/* ---------- Écrans ---------- */
.screen { display: none; flex: 1; flex-direction: column; padding-bottom: 30px; animation: rise .35s ease both; }
.screen.active { display: flex; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.015em;
}
h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.muted { color: var(--text-dim); }
.small { font-size: 14px; }

/* ---------- Boutons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 56px;
  border: none; border-radius: 999px;
  font-family: inherit; font-size: 17px; font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, filter .15s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--fire) 10%, var(--ember) 95%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 87, 34, .32);
}
.btn-ghost {
  background: var(--bg-raise);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-link {
  background: none; border: none;
  color: var(--text-dim);
  font-family: inherit; font-size: 15px;
  text-decoration: underline;
  min-height: 44px;
  cursor: pointer;
}

/* ---------- Accueil ---------- */
#screen-welcome { justify-content: center; gap: 22px; text-align: center; padding-top: 4vh; }
.flame-hero { font-size: 64px; line-height: 1; animation: flicker 2.6s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); filter: brightness(1); }
  40%      { transform: scale(1.07) rotate(2deg); filter: brightness(1.18); }
  70%      { transform: scale(.98) rotate(-1deg); }
}
.title-gradient {
  background: linear-gradient(110deg, #fff 30%, var(--fire-light) 60%, var(--fire) 85%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.field {
  width: 100%;
  min-height: 56px;
  background: var(--bg-raise);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  font-family: inherit; font-size: 17px;
  padding: 0 18px;
  text-align: center;
  outline: none;
  transition: border-color .2s;
}
.field:focus { border-color: var(--fire); }
.field::placeholder { color: var(--text-dim); }
#screen-welcome form { display: flex; flex-direction: column; gap: 14px; }
.duration-pill {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 auto;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px; color: var(--text-dim);
}

/* ---------- Parcours (carte) ---------- */
#screen-map h2 { margin-bottom: 4px; }
.map-track { position: relative; margin: 26px 0 10px; padding-left: 34px; }
.map-track::before {
  content: "";
  position: absolute; left: 13px; top: 28px; bottom: 28px;
  width: 3px; border-radius: 3px;
  background: linear-gradient(var(--fire) var(--map-progress, 0%), rgba(255,255,255,.12) var(--map-progress, 0%));
}
.map-node {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-family: inherit; color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, border-color .2s;
}
.map-node:active { transform: scale(.98); }
.map-node::before {
  content: "";
  position: absolute; left: -27px; top: 50%;
  width: 13px; height: 13px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid rgba(255,255,255,.2);
}
.map-node.done::before  { background: var(--fire); border-color: var(--fire); }
.map-node.next::before  { border-color: var(--fire); animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 87, 34, .5); }
  60%      { box-shadow: 0 0 0 9px rgba(255, 87, 34, 0); }
}
.map-node.locked { opacity: .45; pointer-events: none; }
.map-node.next   { border-color: var(--fire); box-shadow: 0 6px 22px rgba(255, 87, 34, .18); }
.map-node .node-emoji {
  flex: none;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  font-size: 26px;
  background: var(--bg-raise);
  border-radius: 14px;
}
.map-node .node-body { flex: 1; min-width: 0; }
.map-node .node-title { font-weight: 800; font-size: 16px; }
.map-node .node-sub { font-size: 13px; color: var(--text-dim); }
.map-node .node-state { flex: none; font-size: 14px; letter-spacing: 1px; }
.map-node .stars { color: var(--gold); }
.badge-shelf {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px;
  padding: 12px 14px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text-dim);
}
.badge-shelf .b { font-size: 22px; }

/* ---------- Cartes théorie ---------- */
.lesson-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; }
.lesson-head .mod-emoji { font-size: 28px; }
.lesson-head .mod-name { font-weight: 800; font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.card {
  background: linear-gradient(165deg, var(--bg-card), var(--bg-raise));
  border: 1.5px solid var(--line);
  border-radius: 24px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  flex: 1;
  display: flex; flex-direction: column; gap: 14px;
  max-height: 62vh;
  overflow-y: auto;
}
.card .card-emoji { font-size: 44px; line-height: 1; }
.card h3 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.card .card-text { color: var(--text); font-size: 16.5px; }
.card .card-text b { color: var(--fire-light); }
.step-dots { display: flex; justify-content: center; gap: 8px; margin: 18px 0 14px; }
.step-dots .dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: rgba(255,255,255,.18);
  transition: all .25s ease;
}
.step-dots .dot.on { width: 24px; background: var(--fire); }

/* ---------- Activités (cadre commun) ---------- */
.activity-zone { flex: 1; display: flex; flex-direction: column; }
.activity-intro { text-align: center; padding: 8px 4px 18px; color: var(--text-dim); }
.game-status {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700; color: var(--text-dim);
  padding: 4px 2px 12px;
  min-height: 34px;
}
.game-status .timer { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 16px; }
.feedback-line {
  min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 14.5px;
  padding: 6px 10px;
  color: var(--text-dim);
}
.feedback-line.good { color: var(--ok); }
.feedback-line.bad  { color: var(--ko); }

/* ---------- Quiz ---------- */
.quiz-q {
  font-size: 19px; font-weight: 800;
  text-align: center;
  padding: 6px 4px 20px;
  min-height: 86px;
}
.quiz-answers { display: flex; flex-direction: column; gap: 12px; }
.quiz-answers .ans {
  min-height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  font-family: inherit; font-size: 16px; font-weight: 600; color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  text-align: center;
  transition: transform .1s ease, border-color .15s, background .15s;
}
.quiz-answers .ans:active { transform: scale(.97); }
.quiz-answers .ans.good { background: var(--ok-soft); border-color: var(--ok); }
.quiz-answers .ans.bad  { background: var(--ko-soft); border-color: var(--ko); animation: shake .4s ease; }
.quiz-answers .ans.off  { opacity: .4; pointer-events: none; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  55% { transform: translateX(6px); }
  80% { transform: translateX(-3px); }
}

/* ---------- Jeu A : triangle ---------- */
.triangle-stage { position: relative; margin: 4px auto 6px; width: min(82vw, 330px); }
.triangle-stage svg { display: block; width: 100%; height: auto; }
.tri-side { stroke: rgba(255,255,255,.16); stroke-width: 10; stroke-linecap: round; fill: none; transition: stroke .3s; cursor: pointer; }
.tri-side.filled { stroke: var(--fire); filter: drop-shadow(0 0 6px rgba(255,87,34,.6)); }
.tri-side.target { stroke-dasharray: 4 10; animation: dashmove 1.2s linear infinite; stroke: rgba(255,138,80,.6); }
@keyframes dashmove { to { stroke-dashoffset: -14; } }
.tri-label {
  font-size: 13px; font-weight: 800; fill: var(--text-dim);
  text-anchor: middle;
}
.tri-label.set { fill: var(--fire-light); }
.tri-flame { font-size: 44px; text-anchor: middle; opacity: 0; transition: opacity .5s; }
.tri-flame.on { opacity: 1; }
.token-tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 12px 0; }
.token {
  min-height: 48px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--text);
  cursor: pointer;
  transition: transform .12s, border-color .15s, opacity .2s;
}
.token.selected { border-color: var(--fire); background: rgba(255,87,34,.14); transform: scale(1.05); }
.token.used { opacity: 0; pointer-events: none; transform: scale(.6); }
.token.wrong { animation: shake .4s ease; border-color: var(--ko); }

/* ---------- Jeu B : extincteur ---------- */
.fire-card {
  background: linear-gradient(165deg, var(--bg-card), var(--bg-raise));
  border: 1.5px solid var(--line);
  border-radius: 24px;
  min-height: 190px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center;
  padding: 18px;
  box-shadow: var(--shadow);
}
.fire-card .fire-emoji { font-size: 56px; line-height: 1; animation: flicker 1.8s ease-in-out infinite; }
.fire-card .fire-label { font-size: 18px; font-weight: 800; }
.fire-card .fire-hint { font-size: 13px; color: var(--text-dim); }
.fire-card.slide-in { animation: slidein .3s ease both; }
@keyframes slidein {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.ext-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 16px; }
.ext-btn {
  min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  font-family: inherit; color: var(--text);
  font-size: 12.5px; font-weight: 700;
  cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s;
}
.ext-btn:active { transform: scale(.95); }
.ext-btn .e { font-size: 30px; }
.ext-btn.good { border-color: var(--ok); background: var(--ok-soft); }
.ext-btn.bad  { border-color: var(--ko); background: var(--ko-soft); animation: shake .4s; }
.ext-btn.off  { pointer-events: none; opacity: .55; }

/* ---------- Jeu C : séquence ---------- */
.seq-list { display: flex; flex-direction: column; gap: 10px; }
.seq-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  transition: border-color .2s, background .2s, transform .25s ease;
}
.seq-item .seq-num {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--bg-raise);
  border-radius: 99px;
  font-size: 14px; font-weight: 800; color: var(--text-dim);
}
.seq-item .seq-text { flex: 1; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.seq-item .seq-arrows { display: flex; flex-direction: column; gap: 6px; }
.seq-item .seq-arrows button {
  width: 44px; height: 34px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.seq-item .seq-arrows button:active { background: rgba(255,87,34,.2); }
.seq-item .seq-arrows button:disabled { opacity: .25; pointer-events: none; }
.seq-item.locked { border-color: var(--ok); background: var(--ok-soft); }
.seq-item.locked .seq-num { background: var(--ok); color: #fff; }
.seq-item.locked .seq-arrows { display: none; }

/* ---------- Jeu D : chasse aux dangers ---------- */
.danger-scene {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.danger-scene svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.danger-scene .hot { cursor: pointer; }
.danger-scene .hot.found { pointer-events: none; }
.found-ring {
  fill: none; stroke: var(--ko); stroke-width: 3;
  transform-box: fill-box; transform-origin: center;
  animation: ringpulse 1s ease-out infinite;
}
@keyframes ringpulse {
  0%   { stroke-opacity: 1; transform: scale(1); }
  100% { stroke-opacity: .35; transform: scale(1.12); }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 140%);
  z-index: 60;
  width: min(88vw, 460px);
  background: #2A2A31;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  font-size: 14.5px;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), visibility 0s .35s;
  pointer-events: none;
  visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .35s cubic-bezier(.2, .9, .3, 1.2); }
#toast .t-emoji { font-size: 26px; flex: none; }
#toast.badge-toast { border-color: var(--gold); box-shadow: 0 10px 34px rgba(255, 193, 7, .25); }
#toast .t-body b { display: block; }

/* ---------- Récap module ---------- */
#screen-recap { text-align: center; justify-content: center; gap: 16px; }
.recap-stars { font-size: 44px; letter-spacing: 6px; }
.recap-stars .dim { opacity: .22; }
.recap-points { font-size: 20px; font-weight: 800; color: var(--gold); }
.recap-key {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 15px;
  color: var(--text-dim);
  text-align: left;
}
.recap-key b { color: var(--fire-light); }

/* ---------- Écran final ---------- */
#screen-final { text-align: center; gap: 14px; padding-top: 8px; }
.final-grade-emoji { font-size: 70px; line-height: 1.1; }
.final-score { font-size: 42px; font-weight: 800; color: var(--gold); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.final-grade-name { font-size: 24px; font-weight: 800; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0; }
.badge-cell {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.badge-cell .be { font-size: 26px; }
.badge-cell .bn { font-size: 9.5px; font-weight: 700; color: var(--text-dim); line-height: 1.15; }
.badge-cell.off { opacity: .3; filter: grayscale(1); }
.badge-cell.earned { border-color: rgba(255,193,7,.5); animation: badgein .5s ease both; }
@keyframes badgein {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Envoi résultats ---------- */
.send-block {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 12px;
  text-align: left;
}
.send-block h3 { font-size: 17px; }
.send-block .field { text-align: left; }
.send-status { font-size: 14.5px; min-height: 22px; text-align: center; }
.send-status.good { color: var(--ok); }
.send-status.bad  { color: var(--ko); }
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Écran QR code ---------- */
#screen-qr { text-align: center; gap: 16px; padding-top: 8px; }
.qr-hero h2 { margin-bottom: 8px; }
.qr-card {
  width: min(78vw, 320px);
  margin: 6px auto 0;
  background: #fff;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 14px 40px rgba(255, 87, 34, .22), var(--shadow);
  animation: qrpop .45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.qr-card img { display: block; width: 100%; height: auto; }
@keyframes qrpop {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.qr-url {
  font-weight: 800; font-size: 18px;
  color: var(--fire-light);
  letter-spacing: .02em;
}

/* ---------- Confetti ---------- */
#confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 10px 0 22px;
  font-size: 12px;
  color: rgba(245, 242, 238, .4);
}
footer a { color: rgba(245, 242, 238, .55); }

/* ---------- Écran Confidentialité ---------- */
#screen-privacy h2 { margin: 4px 0 6px; }
.privacy-blocks { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.privacy-blocks .recap-key b { color: var(--fire-light); }

/* ---------- Bas d'écran sticky ---------- */
.bottom-cta { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 521px) {
  body { font-size: 18px; }
}
