:root {
  --night: #14102a;
  --night2: #241a45;
  --gold: #d9a74a;
  --gold-hi: #f4d58d;
  --parch: #f3e6c8;
  --parch2: #e7d3a6;
  --ink: #3a2a17;
  --ink-soft: #6b5434;
  --red: #9c2f2f;
  --green: #3f7d4e;
  --leather: #5a3220;
  --g: #ae0001; --s: #2a623d; --p: #ecb939; --r: #222f5b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at top, var(--night2), var(--night) 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 20px;
  line-height: 1.5;
}
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; animation: twinkle 3s infinite ease-in-out; }
@keyframes twinkle { 50% { opacity: .15; } }
#preview-banner { position: sticky; top: 0; z-index: 50; background: #c0392b; color: #fff; text-align: center; font: 600 14px system-ui; padding: 6px; }
main { position: relative; z-index: 1; max-width: 920px; margin: 0 auto; padding: 24px 16px 80px; }
.loading { color: var(--gold-hi); text-align: center; font-family: Cinzel; margin-top: 30vh; }
h1, h2, h3 { font-family: Cinzel, serif; margin: 0 0 .4em; line-height: 1.2; }
button { font: inherit; cursor: pointer; }

/* ─── Couverture ─── */
.cover { text-align: center; color: var(--gold-hi); margin: 10px 0 26px; }
.cover h1 { font-size: clamp(28px, 6vw, 52px); font-weight: 900; letter-spacing: .04em; text-shadow: 0 0 24px rgba(244,213,141,.35); }
.cover .sub { font-style: italic; color: #cbb98f; }
.countdown { display: inline-flex; gap: 10px; margin-top: 14px; }
.countdown div { background: rgba(255,255,255,.06); border: 1px solid rgba(217,167,74,.4); border-radius: 10px; padding: 8px 12px; min-width: 70px; }
.countdown b { display: block; font: 700 28px Cinzel; color: var(--gold-hi); }
.countdown small { font-size: 13px; color: #cbb98f; text-transform: uppercase; letter-spacing: .1em; }
.next-label { margin-top: 18px; font-size: 16px; color: #cbb98f; }

/* ─── Page parchemin ─── */
.page {
  background: linear-gradient(135deg, var(--parch), var(--parch2));
  border-radius: 6px 14px 14px 6px;
  box-shadow: 0 0 0 6px var(--leather), 0 0 0 8px var(--gold), 0 20px 60px rgba(0,0,0,.6), inset 0 0 80px rgba(120,80,30,.25);
  padding: 28px clamp(18px, 4vw, 44px);
  margin: 0 0 30px;
  position: relative;
}
.page::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(107,84,52,.07) 31px 32px); }

/* ─── Révélations ─── */
.reveals h2 { color: var(--leather); font-size: 22px; text-align: center; }
.reveal-row { display: flex; gap: 14px; align-items: baseline; padding: 10px 0; border-bottom: 1px dashed rgba(107,84,52,.35); }
.reveal-row:last-child { border: 0; }
.reveal-row .q { font-family: Cinzel; font-weight: 700; min-width: 190px; color: var(--ink-soft); font-size: 17px; }
.reveal-row .a { flex: 1; }
.reveal-row .a.unknown { color: rgba(58,42,23,.35); letter-spacing: .3em; }
@media (max-width: 600px) { .reveal-row { flex-direction: column; gap: 2px; } }

/* ─── Chapitres et jours ─── */
.chapter { margin-bottom: 26px; }
.chapter h3 { color: var(--gold-hi); font-size: 18px; margin-bottom: 10px; text-shadow: 0 1px 3px #000; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.day {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid rgba(217,167,74,.35);
  background: rgba(255,255,255,.04); color: #cbb98f; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-decoration: none; text-align: center; padding: 6px; position: relative;
  transition: transform .15s;
}
.day small { font-size: 13px; line-height: 1.1; }
.day .num { font: 700 26px Cinzel; }
.day.locked { opacity: .45; }
.day.locked .num::before { content: '🔒'; font-size: 20px; display: block; }
.day.open, .day.started { background: linear-gradient(135deg, var(--parch), var(--parch2)); color: var(--ink); border-color: var(--gold); box-shadow: 0 0 18px rgba(244,213,141,.55); animation: glow 2s infinite; }
.day.solved { background: linear-gradient(135deg, #3b2a5c, #261a40); border-color: var(--gold); color: var(--gold-hi); }
.day.solved .rune { font: 900 28px Cinzel; text-shadow: 0 0 12px var(--gold); }
.day.meta { border-style: double; border-width: 4px; }
.day:active { transform: scale(.95); }
@keyframes glow { 50% { box-shadow: 0 0 4px rgba(244,213,141,.3); } }

/* ─── Vue d’une épreuve ─── */
.back { display: inline-block; color: var(--gold-hi); text-decoration: none; font-family: Cinzel; margin-bottom: 14px; }
.ch-title { font-family: Cinzel; color: var(--ink-soft); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.page h2 { font-size: clamp(24px, 4vw, 34px); color: var(--leather); }
.dateline { color: var(--ink-soft); font-style: italic; font-size: 16px; margin-bottom: 14px; }
.story { font-style: italic; border-left: 3px solid var(--gold); padding-left: 14px; margin-bottom: 18px; }
.sig { text-align: right; font-style: italic; }
.sig.big { font-size: 26px; text-align: center; margin-top: 30px; }
.cipher { font-family: 'Courier New', monospace; font-size: 21px; letter-spacing: .08em; background: rgba(90,50,32,.08); border: 1px solid rgba(90,50,32,.25); border-radius: 8px; padding: 14px; word-break: break-word; }
.cipher.big { font-size: 28px; text-align: center; letter-spacing: .15em; }
.riddle { font-style: italic; text-align: center; font-size: 22px; }
.question { font-weight: 600; color: var(--leather); }
.clues li { margin-bottom: 6px; }
.poem { font-style: italic; font-size: 21px; padding-left: 10px; }
.mirror { transform: scaleX(-1); font-family: 'Courier New', monospace; font-weight: 700; font-size: 20px; text-align: center; letter-spacing: .05em; }
table.codes { border-collapse: collapse; margin: 0 auto; }
table.codes td { padding: 8px 14px; border-bottom: 1px solid rgba(90,50,32,.2); }
table.codes td:first-child { font: 700 26px 'Courier New', monospace; letter-spacing: .2em; white-space: nowrap; }
.tile { display: inline-block; width: 26px; height: 26px; line-height: 26px; text-align: center; font: 700 15px system-ui; border-radius: 4px; color: #fff; }
.tile.g { background: var(--green); } .tile.y { background: #c99a1f; } .tile.x { background: #7a6c5a; }

.answer-form { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.answer-form input { flex: 1; min-width: 200px; font: 600 22px Cinzel; padding: 12px 16px; border: 2px solid var(--ink-soft); border-radius: 10px; background: #fffaf0; color: var(--ink); text-transform: uppercase; }
.btn { background: linear-gradient(180deg, #e7b95b, #b9852f); color: #2a1a07; border: 0; border-radius: 10px; padding: 12px 22px; font-family: Cinzel; font-weight: 700; box-shadow: 0 3px 0 #7a5418; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a5418; }
.btn.ghost { background: transparent; border: 2px solid var(--ink-soft); color: var(--ink); box-shadow: none; }
.btn[disabled] { opacity: .5; }
.feedback { min-height: 28px; margin-top: 10px; font-weight: 600; }
.feedback.bad { color: var(--red); animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.hints { margin-top: 26px; border-top: 1px dashed rgba(107,84,52,.4); padding-top: 14px; }
.hints h4 { font-family: Cinzel; margin: 0 0 8px; color: var(--ink-soft); }
.hint { background: rgba(255,255,255,.45); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.hint b { font-family: Cinzel; color: var(--leather); }
.hint-wait { font-size: 16px; color: var(--ink-soft); font-style: italic; }

.solved-box { text-align: center; margin-top: 22px; padding: 18px; background: rgba(63,125,78,.12); border: 2px solid var(--green); border-radius: 12px; }
.solved-box .rune-big { font: 900 54px Cinzel; color: var(--leather); text-shadow: 0 0 20px var(--gold); }
.fragment { font-size: 24px; text-align: center; padding: 18px; border: 3px double var(--gold); border-radius: 12px; background: rgba(255,255,255,.4); margin-top: 16px; }
.runes-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.runes-row span { min-width: 54px; height: 64px; padding: 0 8px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #2c2047; color: var(--gold-hi); font: 900 28px Cinzel; box-shadow: 0 0 10px rgba(217,167,74,.5); }
.runes-row span.missing { background: rgba(0,0,0,.1); color: rgba(0,0,0,.3); box-shadow: none; }

/* ─── Modale ─── */
#modal { position: fixed; inset: 0; z-index: 100; background: rgba(10,6,25,.85); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden] { display: none; }
.modal-card { background: linear-gradient(135deg, var(--parch), var(--parch2)); border-radius: 16px; padding: 30px; max-width: 560px; width: 100%; text-align: center; box-shadow: 0 0 0 4px var(--gold), 0 0 60px rgba(244,213,141,.5); animation: pop .5s cubic-bezier(.2,1.6,.4,1); max-height: 90vh; overflow: auto; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ─── Mini-jeux ─── */
.game { margin-top: 18px; text-align: center; user-select: none; -webkit-user-select: none; }
.game .status { font-family: Cinzel; font-weight: 700; margin: 10px 0; min-height: 30px; }
.simon { display: grid; grid-template-columns: repeat(2, 130px); gap: 14px; justify-content: center; }
.simon button { height: 130px; border-radius: 18px; border: 4px solid rgba(0,0,0,.25); opacity: .55; font-size: 44px; transition: opacity .1s, transform .1s; }
.simon button.lit { opacity: 1; transform: scale(1.06); box-shadow: 0 0 30px currentColor; }
.memory { display: grid; gap: 8px; justify-content: center; }
.memory .card { width: 76px; height: 92px; border-radius: 10px; border: 0; background: linear-gradient(135deg, #3b2a5c, #1d1433); color: transparent; font-size: 34px; box-shadow: inset 0 0 0 2px var(--gold); position: relative; }
.memory .card::after { content: '✦'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--gold); font-size: 26px; }
.memory .card.up, .memory .card.done { background: #fffaf0; color: var(--ink); }
.memory .card.up::after, .memory .card.done::after { content: none; }
.memory .card.done { opacity: .55; }
.memory .card.word { font: 600 16px 'Crimson Pro'; }
.sudoku { display: inline-grid; grid-template-columns: repeat(6, 54px); border: 3px solid var(--ink); }
.sudoku input { width: 54px; height: 54px; text-align: center; font: 700 26px Cinzel; border: 1px solid rgba(58,42,23,.3); background: #fffaf0; color: #2a4c8c; border-radius: 0; padding: 0; }
.sudoku input.given { color: var(--ink); background: var(--parch2); }
.sudoku input.c2 { border-right: 3px solid var(--ink); }
.sudoku input.r1 { border-bottom: 3px solid var(--ink); }
.taquin { display: inline-grid; gap: 6px; background: var(--leather); padding: 6px; border-radius: 10px; }
.taquin button { border: 0; border-radius: 8px; background: linear-gradient(135deg, var(--parch), var(--parch2)); font: 700 28px Cinzel; color: var(--ink); }
.taquin button.empty { visibility: hidden; }
.mm-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; }
.peg { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(0,0,0,.3); display: inline-block; }
.peg.empty { background: rgba(0,0,0,.08); }
.mm-score { display: grid; grid-template-columns: repeat(3, 12px); gap: 3px; width: 46px; }
.mm-score i { width: 12px; height: 12px; border-radius: 50%; background: rgba(0,0,0,.1); }
.mm-score i.b { background: var(--gold); box-shadow: 0 0 4px var(--gold); }
.mm-score i.w { background: #fff; border: 1px solid #999; }
.mm-palette { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.mm-palette button { width: 48px; height: 48px; border-radius: 50%; border: 3px solid rgba(0,0,0,.25); }
.lights { display: inline-grid; gap: 6px; }
.lights button { width: 58px; height: 58px; border-radius: 10px; border: 2px solid var(--ink-soft); background: #2c2047; font-size: 28px; }
.lights button.on { background: #fff3c4; box-shadow: 0 0 16px var(--gold-hi); }
.wordle { display: inline-grid; gap: 5px; }
.wordle .row { display: flex; gap: 5px; }
.wordle .row span { width: 44px; height: 50px; border: 2px solid var(--ink-soft); border-radius: 6px; display: flex; align-items: center; justify-content: center; font: 700 24px Cinzel; background: #fffaf0; }
.wordle .row span.m2 { background: var(--green); color: #fff; border-color: var(--green); }
.wordle .row span.m1 { background: #c99a1f; color: #fff; border-color: #c99a1f; }
.wordle .row span.m0 { background: #7a6c5a; color: #fff; border-color: #7a6c5a; }
.swim-pool { position: relative; height: 110px; border-radius: 10px; background: repeating-linear-gradient(90deg, #4fa3d1 0 40px, #4799c6 40px 80px); border: 4px solid #2c6b8f; overflow: hidden; margin-bottom: 10px; }
.swim-pool .lane { position: absolute; left: 0; right: 0; height: 50%; border-bottom: 2px dashed rgba(255,255,255,.6); }
.swim-pool .swimmer { position: absolute; font-size: 38px; transition: left .1s linear; transform: scaleX(-1); }
.swim-pool .wall { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; background: #fff; }
.swim-btns { display: flex; gap: 16px; justify-content: center; }
.swim-btns button { width: 140px; height: 120px; font-size: 44px; border-radius: 20px; border: 3px solid var(--ink-soft); background: #fffaf0; touch-action: manipulation; }
.swim-btns button.next { box-shadow: 0 0 18px var(--gold); border-color: var(--gold); }
.snitch-field { position: relative; height: 380px; border-radius: 12px; background: radial-gradient(ellipse at bottom, #5b8f3a, #2f5d22); overflow: hidden; touch-action: manipulation; }
.snitch { position: absolute; font-size: 36px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; transition: left .9s ease-in-out, top .9s ease-in-out; filter: drop-shadow(0 0 8px gold); }
.nono { display: inline-grid; gap: 0; }
.nono .clue { font: 600 14px system-ui; color: var(--ink-soft); display: flex; align-items: flex-end; justify-content: flex-end; padding: 2px 4px; gap: 4px; }
.nono .clue.col { flex-direction: column; align-items: center; justify-content: flex-end; line-height: 1.1; }
.nono .cell { width: 34px; height: 34px; border: 1px solid rgba(58,42,23,.3); background: #fffaf0; font: 700 18px system-ui; color: #a33; padding: 0; border-radius: 0; }
.nono .cell.on { background: var(--ink); }
.nono .cell.b5 { border-right: 2px solid var(--ink); }
.nono .cell.r5 { border-bottom: 2px solid var(--ink); }
.morse-light { width: 120px; height: 120px; margin: 20px auto; border-radius: 50%; background: #2c2047; border: 4px solid var(--leather); transition: background .05s, box-shadow .05s; }
.morse-light.on { background: #fff7d1; box-shadow: 0 0 60px 20px rgba(255,240,180,.9); }
.morse-audio { text-align: center; margin: 20px 0; }
.pigpen-key { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pigpen-key span { display: flex; flex-direction: column; align-items: center; font-size: 14px; }
@media (max-width: 520px) {
  .memory .card { width: 58px; height: 72px; font-size: 26px; }
  .sudoku { grid-template-columns: repeat(6, 46px); } .sudoku input { width: 46px; height: 46px; }
  .nono .cell { width: 26px; height: 26px; }
  .lights button { width: 48px; height: 48px; }
  .wordle .row span { width: 34px; height: 42px; font-size: 19px; }
}

/* ─── Révélation finale ─── */
.boarding { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.4); margin: 10px 0 24px; font-family: system-ui, sans-serif; color: #1b1b2f; animation: pop .8s cubic-bezier(.2,1.4,.4,1); }
.bp-head { display: flex; justify-content: space-between; background: #1d2b64; color: #fff; padding: 12px 18px; font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.bp-route { display: flex; justify-content: space-around; align-items: center; padding: 18px; }
.bp-route div { text-align: center; } .bp-route b { display: block; font-size: 48px; letter-spacing: .05em; }
.bp-route small, .bp-grid small, .bp-mission small { display: block; font-size: 11px; color: #777; letter-spacing: .1em; }
.bp-plane { font-size: 40px; color: #1d2b64; }
.bp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 18px 18px; font-weight: 700; font-size: 18px; }
.bp-mission { background: repeating-linear-gradient(45deg, #ffe9a8, #ffe9a8 10px, #ffdf80 10px, #ffdf80 20px); text-align: center; padding: 16px; border-top: 2px dashed #999; }
.bp-mission b { font-size: 34px; letter-spacing: .1em; color: #b0002a; }
.reveal-big { text-align: center; } .reveal-big h2 { font-size: clamp(26px, 5vw, 40px); color: var(--red); }
.program ul { padding-left: 20px; }
.media-zone img { width: 100%; border-radius: 10px; margin: 8px 0; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.media-zone video { width: 100%; border-radius: 10px; margin: 8px 0; }
.confetti { position: fixed; top: -20px; z-index: 200; font-size: 26px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.morse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 4px; background: rgba(90,50,32,.06); border-radius: 8px; padding: 10px; }
.morse-grid span { font: 700 18px 'Courier New', monospace; letter-spacing: 2px; }
.morse-grid b { display: inline-block; width: 22px; color: var(--leather); }
table.codes.polybe td { font: 700 20px 'Courier New', monospace; text-align: center; padding: 4px 10px; letter-spacing: 0; }
.final-letter { font-style: italic; font-size: 21px; background: rgba(255,255,255,.45); border-left: 4px solid var(--gold); border-radius: 8px; padding: 16px 20px; margin: 20px 0; }
.hint-photo { display: block; max-width: 280px; width: 100%; border-radius: 10px; margin: 10px auto 0; box-shadow: 0 4px 14px rgba(0,0,0,.3); }

/* ─── Introduction ─── */
#intro { position: fixed; inset: 0; z-index: 150; background: radial-gradient(ellipse at center, #241a45, #07050f 75%); display: flex; align-items: center; justify-content: center; padding: 16px; transition: opacity .8s; overflow: auto; }
#intro.closing { opacity: 0; }
.intro-scene { text-align: center; width: 100%; max-width: 620px; }
.intro-scene[hidden] { display: none; }
.intro-tap { color: #cbb98f; font-style: italic; font-size: 20px; margin-top: 24px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.owl { font-size: 90px; position: relative; display: inline-block; animation: fly 3s ease-out forwards; }
.owl .env { position: absolute; font-size: 40px; left: 50%; bottom: -24px; transform: translateX(-50%); }
@keyframes fly { from { transform: translate(-60vw, -30vh) rotate(-15deg); } 70% { transform: translate(0, 10px) rotate(5deg); } to { transform: none; } }
.envelope { width: 260px; height: 170px; border: 0; border-radius: 8px; background: linear-gradient(160deg, var(--parch), var(--parch2)); position: relative; box-shadow: 0 10px 40px rgba(0,0,0,.6); animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
.envelope::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 0; border-left: 130px solid transparent; border-right: 130px solid transparent; border-top: 95px solid #e2cc9b; }
.wax { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #c0392b, #7b1d1d); color: #f4d58d; font: 900 30px Cinzel; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 8px rgba(0,0,0,.5); animation: glowseal 1.6s infinite; }
@keyframes glowseal { 50% { box-shadow: 0 0 24px 6px rgba(244,213,141,.7); } }
.envelope.open { animation: openenv .7s forwards; }
@keyframes openenv { to { transform: scale(1.4) rotate(4deg); opacity: 0; } }
.letter { background: linear-gradient(135deg, var(--parch), var(--parch2)); border-radius: 10px; padding: 28px clamp(18px, 4vw, 40px); text-align: left; box-shadow: 0 0 0 4px var(--gold), 0 0 60px rgba(244,213,141,.4); font-size: 21px; animation: pop .6s; }
.fade-line { animation: fadein 1.2s both; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }
.letter .btn { display: block; margin: 20px auto 0; font-size: 20px; }
.replay { color: #cbb98f; font-size: 15px; }
