:root {
  --fond: #14121c;
  --carte: #1f1c2b;
  --carte2: #2a2639;
  --texte: #f3eee6;
  --doux: #b9b2c7;
  --ath: #5fa8d3;
  --rom: #e5484d;
  --or: #e9c46a;
  --ok: #52b788;
  --ko: #ef6351;
  --rayon: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 17px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { max-width: 820px; margin: 0 auto; min-height: 100vh; }
.ecran { display: none; padding: 16px; padding-bottom: 40px; }
.ecran.actif { display: block; }

/* ---------- Accueil ---------- */
.titre-app { text-align: center; padding: 18px 0 8px; }
.surtitre { color: var(--doux); letter-spacing: .08em; text-transform: uppercase; font-size: 13px; margin: 0; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(36px, 9vw, 58px); margin: 6px 0; line-height: 1.1; }
h1 em { font-style: normal; color: var(--or); font-size: .6em; vertical-align: middle; }
.ath { color: var(--ath); } .rom { color: var(--rom); }
.sous { color: var(--doux); margin: 0; }
.liste-episodes { display: grid; gap: 12px; margin: 20px 0; }
.ep-carte { display: flex; gap: 14px; align-items: center; text-align: left; background: var(--carte); border: 1px solid #ffffff14; border-radius: var(--rayon); padding: 14px; width: 100%; transition: transform .15s, border-color .15s; }
.ep-carte:hover { transform: translateY(-2px); border-color: #ffffff30; }
.ep-pastille { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-family: Georgia, serif; font-size: 26px; font-weight: 700; }
.ep-pastille.athenes { background: #1b4965; color: #cae9ff; }
.ep-pastille.rome { background: #6a040f; color: #ffccd5; }
.ep-pastille.duel { background: linear-gradient(135deg, #1b4965 50%, #6a040f 50%); color: #fff; }
.ep-info { flex: 1; min-width: 0; }
.ep-info strong { display: block; font-size: 18px; }
.ep-info span { color: var(--doux); font-size: 14px; }
.ep-fait { color: var(--ok); font-size: 22px; }
.modes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.btn-mode { text-align: left; background: var(--carte2); border: 1px solid #ffffff14; border-radius: var(--rayon); padding: 14px; }
.btn-mode strong { display: block; font-size: 17px; }
.btn-mode span { color: var(--doux); font-size: 14px; }
.reglages { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; margin: 22px 0 10px; color: var(--doux); font-size: 15px; }
.reglages select { background: var(--carte2); color: var(--texte); border: 1px solid #ffffff22; border-radius: 8px; padding: 4px 6px; }
.lien { background: none; border: 0; text-decoration: underline; color: var(--doux); font-size: 14px; }
.mention { color: #8d86a0; font-size: 13px; text-align: center; max-width: 560px; margin: 8px auto 0; }

/* ---------- Barre haut ---------- */
.barre-haut { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.icone { background: var(--carte2); border: 1px solid #ffffff1a; border-radius: 12px; min-width: 44px; height: 44px; font-size: 18px; }
.progression { flex: 1; height: 8px; background: #ffffff14; border-radius: 99px; overflow: hidden; }
.progression > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ath), var(--rom)); transition: width .4s; }
.prog-texte { color: var(--doux); font-size: 14px; white-space: nowrap; }
.titre-ecran { margin: 0; font-size: 20px; }

/* ---------- Scène ---------- */
.scene { position: relative; border-radius: var(--rayon); overflow: hidden; aspect-ratio: 16 / 10; background: #000; min-height: 300px; }
.scene.reduite { aspect-ratio: 16 / 5; min-height: 110px; }
.scene { transition: aspect-ratio .4s; }

.decor { position: absolute; inset: 0; }
.decor svg { width: 100%; height: 100%; display: block; animation: kenburns 24s ease-in-out infinite alternate; transform-origin: 50% 60%; }
@keyframes kenburns { from { transform: scale(1.02) translateX(0); } to { transform: scale(1.12) translateX(-2%); } }
.decor.fondu svg { animation: fondu .9s ease, kenburns 24s ease-in-out infinite alternate; }
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
.carton { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: #000a; font-family: Georgia, serif; font-size: clamp(24px, 6vw, 40px); padding: 20px; opacity: 0; pointer-events: none; transition: opacity .5s; }
.carton.visible { opacity: 1; }
.carton small { display: block; font-family: "Segoe UI", system-ui, sans-serif; font-size: 15px; color: var(--or); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.sous-titres { position: absolute; left: 0; right: 0; bottom: 64px; padding: 0 14px; display: flex; flex-direction: column; align-items: flex-start; }
.locuteur { font-weight: 700; font-size: 14px; padding: 3px 10px; border-radius: 99px; background: #000b; margin-bottom: 6px; display: none; }
.locuteur.visible { display: inline-block; }
.replique { margin: 0; background: #000c; padding: 10px 14px; border-radius: 12px; font-size: clamp(16px, 3.6vw, 20px); line-height: 1.4; max-width: 100%; display: none; }
.replique.visible { display: block; animation: monte .3s ease; }
@keyframes monte { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.commandes { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.commandes .icone { background: #000a; }
.petit { background: #000a; border: 1px solid #ffffff33; border-radius: 12px; height: 44px; padding: 0 14px; font-size: 15px; }
.demarrer { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle, #000a, #000e); padding: 20px; }
.demarrer.cache { display: none; }
.demarrer-boite { text-align: center; max-width: 520px; }
.ep-num { color: var(--or); text-transform: uppercase; letter-spacing: .12em; font-size: 14px; margin: 0; }
.demarrer h2 { font-family: Georgia, serif; font-size: clamp(26px, 6vw, 40px); margin: 6px 0; }
.lieu { color: var(--doux); margin: 0 0 12px; }
.accroche { font-style: italic; font-size: 18px; margin: 0 0 20px; }
.btn-principal { background: var(--or); color: #1d1a12; border: 0; border-radius: 99px; padding: 14px 30px; font-size: 19px; font-weight: 700; box-shadow: 0 6px 24px #e9c46a55; }
.btn-principal:disabled { opacity: .4; box-shadow: none; }
.btn-second { background: var(--carte2); color: var(--texte); border: 1px solid #ffffff2a; border-radius: 99px; padding: 12px 22px; font-size: 16px; }

/* ---------- Panneau défi ---------- */
.panneau { margin-top: 14px; }
.defi { background: var(--carte); border: 1px solid #ffffff17; border-radius: var(--rayon); padding: 18px; animation: monte .3s ease; }
.defi-type { color: var(--or); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 6px; }
.defi h3 { margin: 0 0 14px; font-size: 19px; line-height: 1.35; }
.options { display: grid; gap: 10px; }
.opt { text-align: left; background: var(--carte2); border: 2px solid transparent; border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.opt.choisi { border-color: var(--or); }
.opt.bon { border-color: var(--ok); background: #1f3d2f; }
.opt.faux { border-color: var(--ko); background: #4a1f1c; }
.opt:disabled { cursor: default; }
.ligne-assoc { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; align-items: center; background: var(--carte2); border-radius: 12px; padding: 10px 12px; border: 2px solid transparent; }
.ligne-assoc.bon { border-color: var(--ok); } .ligne-assoc.faux { border-color: var(--ko); }
.ligne-assoc select { width: 100%; background: var(--fond); color: var(--texte); border: 1px solid #ffffff33; border-radius: 8px; padding: 9px 8px; font-size: 15px; }
.corrige { grid-column: 1 / -1; color: var(--ok); font-size: 14px; }
@media (max-width: 560px) { .ligne-assoc { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.retour { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 16px; animation: monte .3s ease; }
.retour.bon { background: #1f3d2f; border-left: 4px solid var(--ok); }
.retour.faux { background: #3d2220; border-left: 4px solid var(--ko); }
.retour strong { display: block; margin-bottom: 4px; }

/* tri */
.tri-carte { text-align: center; background: var(--carte2); border-radius: 14px; padding: 26px 16px; font-size: 21px; font-weight: 600; margin-bottom: 14px; min-height: 96px; display: grid; place-items: center; }
.tri-carte.bon { background: #1f3d2f; } .tri-carte.faux { background: #4a1f1c; }
.tri-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tri-boutons button { border: 0; border-radius: 14px; padding: 16px 8px; font-size: 18px; font-weight: 700; }
.tri-boutons .c0 { background: #1b4965; color: #cae9ff; }
.tri-boutons .c1 { background: #6a040f; color: #ffccd5; }
.tri-etat { display: flex; justify-content: space-between; color: var(--doux); font-size: 15px; margin-bottom: 10px; }
.chrono { font-weight: 700; color: var(--or); }
.chrono.urgent { color: var(--ko); }
.liste-ratee { margin: 8px 0 0; padding-left: 18px; color: var(--doux); font-size: 15px; }

/* fin d'épisode */
.fin h3 { font-family: Georgia, serif; font-size: 26px; margin: 0 0 6px; }
.score { font-size: 18px; color: var(--or); margin: 0 0 14px; }
.retenir { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.retenir li { background: var(--carte2); border-radius: 10px; padding: 10px 12px; border-left: 4px solid var(--or); }

/* ---------- Révision ---------- */
.rev-onglets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: thin; }
.rev-onglets button { flex: none; background: var(--carte2); border: 1px solid #ffffff1a; border-radius: 99px; padding: 8px 14px; font-size: 15px; }
.rev-onglets button.actif { background: var(--or); color: #1d1a12; border-color: var(--or); font-weight: 700; }
.flash { perspective: 1000px; margin: 8px 0 14px; }
.flash-inner { position: relative; min-height: 220px; transition: transform .45s; transform-style: preserve-3d; cursor: pointer; }
.flash.retourne .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; display: grid; place-items: center; text-align: center; padding: 22px; }
.flash-recto { background: var(--carte); border: 1px solid #ffffff22; font-family: Georgia, serif; font-size: clamp(28px, 7vw, 42px); }
.flash-recto small { display: block; font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; color: var(--doux); margin-top: 10px; }
.flash-verso { background: #2a2440; border: 1px solid var(--or); transform: rotateY(180deg); font-size: 19px; }
.rev-etat { color: var(--doux); text-align: center; font-size: 15px; }
.rev-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rev-boutons button { border: 0; border-radius: 14px; padding: 14px; font-size: 17px; font-weight: 700; }
.b-revoir { background: #4a1f1c; color: #ffd6d1; }
.b-sais { background: #1f3d2f; color: #d8f3dc; }
.rev-liste { margin-top: 18px; }
.rev-liste summary { cursor: pointer; color: var(--doux); }
.rev-liste table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.rev-liste td { padding: 7px 6px; border-bottom: 1px solid #ffffff12; vertical-align: top; }
.rev-liste td:first-child { font-weight: 700; color: var(--or); white-space: nowrap; }

/* ---------- Téléphone : décor en haut, texte dessous, boutons au pouce ---------- */
@media (max-width: 560px) {
  .ecran { padding: 12px; }
  .scene { aspect-ratio: auto; min-height: 0; overflow: visible; background: transparent; border-radius: 0; display: flex; flex-direction: column; }
  .decor { position: relative; inset: auto; aspect-ratio: 4 / 3; border-radius: var(--rayon); overflow: hidden; box-shadow: 0 10px 30px #0008; }
  .carton { bottom: auto; aspect-ratio: 4 / 3; border-radius: var(--rayon); }
  .sous-titres { position: static; padding: 16px 2px 8px; min-height: 190px; justify-content: flex-start; }
  .locuteur { font-size: 15px; padding: 5px 12px; background: var(--carte2); margin-bottom: 10px; }
  .replique { background: transparent; padding: 0 2px; font-size: 20px; line-height: 1.5; }
  .commandes { position: static; padding: 8px 0 4px; gap: 10px; }
  .commandes .icone { background: var(--carte2); min-width: 54px; height: 54px; font-size: 20px; border-radius: 16px; }
  .commandes .petit { background: var(--carte2); height: 54px; border-radius: 16px; flex: 1; max-width: 190px; }
  .demarrer { border-radius: var(--rayon); }
  .scene.reduite { aspect-ratio: auto; }
  .scene.reduite .decor { aspect-ratio: 16 / 6; }
  .scene.reduite .sous-titres { display: none; }
}
