@font-face { font-family: 'Lilita One'; src: url('fonts/lilita-one.woff2') format('woff2'); font-display: swap; }

:root {
  --nuit: #2a1f3d; --parchemin: #f3e3c3; --parchemin2: #e8d2a6; --encre: #4a2a1a; --terre: #c9673a;
  --or: #e8b93a; --vert: #5f9b45; --rouge: #e0465e;
  --haut: env(safe-area-inset-top); --bas: env(safe-area-inset-bottom);
}
*, *::before, *::after { box-sizing: border-box; touch-action: manipulation; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--nuit); color: var(--encre);
  font: 600 15px/1.3 system-ui, -apple-system, sans-serif; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100dvh; display: block; touch-action: none; }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(10, 5, 25, .55)); }

/* ---------- Bandeau du haut : page + titre à réaliser ---------- */
#haut { position: fixed; z-index: 3; top: calc(10px + var(--haut)); left: 12px; right: 12px; display: grid; gap: 10px; }
.ligne { display: flex; align-items: center; gap: 12px; }
.rond { flex: none; height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 22px; background: rgba(243, 227, 195, .95);
  box-shadow: 0 3px 0 #a07c4e; font-size: 20px; color: var(--encre); }
.rond:active { transform: translateY(2px); box-shadow: 0 1px 0 #a07c4e; }
.rond.secrets { font-size: 15px; display: flex; align-items: center; gap: 4px; }
.rond.secrets span { color: #b08a1e; font-size: 18px; }
.page { flex: 1; min-width: 0; color: var(--parchemin); text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.page small { display: block; font-size: 12px; opacity: .75; letter-spacing: .04em; }
.page span { font: 22px/1.1 'Lilita One', system-ui; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.but { display: flex; align-items: center; gap: 12px; background: var(--parchemin); border-radius: 14px; padding: 10px 14px;
  box-shadow: 0 4px 0 #a07c4e, inset 0 0 0 2px #d7bb8a; font: 19px/1.15 'Lilita One', system-ui; }
.case-a-cocher { flex: none; width: 28px; height: 28px; border: 3px solid var(--encre); border-radius: 6px; position: relative; background: #fff8e6; }
.but.fait .case-a-cocher { background: var(--vert); border-color: #3d6e2b; animation: coche .5s cubic-bezier(.3, 1.8, .5, 1); }
.but.fait .case-a-cocher::after { content: '✓'; position: absolute; inset: -6px 0 0 1px; color: #fff; font-size: 26px; }
.but.fait { box-shadow: 0 4px 0 #3d6e2b, inset 0 0 0 3px var(--vert); }
@keyframes coche { from { transform: scale(.3) rotate(-30deg); } to { transform: none; } }

/* ---------- Bas : légende de la case + plateau des pièces ---------- */
#bas { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; padding: 0 12px calc(12px + var(--bas)); display: grid; gap: 12px; }
.legende { display: flex; align-items: stretch; gap: 10px; }
.fleche { flex: none; width: 44px; border: 0; border-radius: 14px; background: rgba(243, 227, 195, .95); box-shadow: 0 3px 0 #a07c4e; font-size: 30px; line-height: 1; }
.fleche:active { transform: translateY(2px); box-shadow: 0 1px 0 #a07c4e; }
.milieu { flex: 1; min-width: 0; background: rgba(243, 227, 195, .95); border-radius: 14px; padding: 8px 12px 10px; box-shadow: 0 3px 0 #a07c4e; display: grid; gap: 6px; }
.points { display: flex; justify-content: center; gap: 8px; }
.points button { width: 30px; height: 22px; border: 2px solid var(--encre); border-radius: 6px; background: #fff8e6; font: 13px/1 Georgia, serif; font-weight: 900; padding: 0; }
.points button.vide { opacity: .45; }
.points button.ici { background: var(--terre); color: #fff; border-color: #7a3a1e; }
#texte { margin: 0; min-height: 2.6em; text-align: center; font-size: 15px; line-height: 1.3; }
.pieces { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 0; }
.pieces:empty { display: none; }
.puce { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 12px; padding: 3px 4px 3px 10px; background: var(--parchemin2); font-size: 13px; }
.puce b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 10px; background: var(--encre); color: var(--parchemin); font-size: 12px; }

.plateau { background: linear-gradient(#5a3a28, #46291b); border-radius: 18px; padding: 10px; display: grid; gap: 10px;
  box-shadow: 0 4px 0 #2a160c, inset 0 2px 0 rgba(255, 255, 255, .12); }
.rang { display: flex; justify-content: center; gap: 10px; }
.jeton { flex: 0 1 76px; min-width: 0; border: 0; padding: 0 0 4px; border-radius: 12px; background: var(--parchemin); box-shadow: 0 3px 0 #a07c4e;
  display: grid; justify-items: center; gap: 2px; touch-action: none; transition: transform .15s; }
.jeton img { width: 100%; aspect-ratio: 1.25; object-fit: cover; border-radius: 12px 12px 4px 4px; pointer-events: none; display: block; }
.jeton.perso img { aspect-ratio: 1.25; object-fit: contain; background: radial-gradient(circle at 50% 40%, #fff8e6, #e8d2a6); }
.jeton span { font: 13px/1 'Lilita One', system-ui; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.jeton.choisi { transform: translateY(-6px); box-shadow: 0 3px 0 #a07c4e, 0 0 0 3px var(--or), 0 0 16px rgba(232, 185, 58, .8); }
.jeton:active { transform: translateY(2px); }
.glisse { position: fixed; z-index: 20; width: 76px; pointer-events: none; translate: -50% -60%; transform: rotate(-6deg) scale(1.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45), 0 0 0 3px var(--or); }

/* ---------- Écran titre ---------- */
.ecran { position: fixed; inset: 0; z-index: 5; display: grid; align-content: center; justify-items: center; gap: 22px; padding: calc(20px + var(--haut)) 20px calc(16px + var(--bas));
  background: radial-gradient(ellipse at 50% 40%, rgba(42, 31, 61, .35), rgba(20, 12, 34, .88)); overflow-y: auto; }
.titre-gauche { text-align: center; }
.logo { font: 64px/1 'Lilita One', system-ui; color: var(--parchemin); text-shadow: 0 5px 0 var(--terre), 0 9px 18px rgba(0, 0, 0, .5); letter-spacing: .02em; }
.accroche { margin: 12px 0 0; color: var(--parchemin); opacity: .9; font-size: 16px; }
.menu { display: grid; gap: 12px; width: min(320px, 100%); }
.btn { border: 0; border-radius: 16px; padding: 14px 18px; background: var(--parchemin); box-shadow: 0 4px 0 #a07c4e; font: 19px/1.1 'Lilita One', system-ui; text-align: center; text-decoration: none; color: var(--encre); display: block; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a07c4e; }
.btn.grand { font-size: 26px; padding: 18px; background: var(--or); box-shadow: 0 5px 0 #a8701a; }
.btn.discret { background: rgba(243, 227, 195, .18); color: var(--parchemin); box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.pied { color: var(--parchemin); opacity: .7; font-size: 12px; text-align: center; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.pied a { color: inherit; }

/* ---------- Fenêtres ---------- */
.voile { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(15, 8, 28, .6); }
.carte { width: min(400px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--parchemin); border-radius: 20px; padding: 22px 18px 18px;
  box-shadow: 0 6px 0 #a07c4e, 0 20px 50px rgba(0, 0, 0, .5); display: grid; gap: 14px; animation: arrive .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes arrive { from { transform: translateY(40px) scale(.9); opacity: 0; } }
.carte h2 { margin: 0; text-align: center; font: 28px/1.1 'Lilita One', system-ui; }
.carte p { margin: 0; text-align: center; font-size: 16px; }
.carte .actions { display: grid; gap: 12px; margin-top: 4px; }
.liste { display: grid; gap: 10px; }
.ligne-page { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 14px; padding: 12px 14px; background: var(--parchemin2); box-shadow: 0 3px 0 #a07c4e; text-align: left; }
.ligne-page:disabled { opacity: .45; }
.ligne-page .n { font: 24px/1 Georgia, serif; font-weight: 900; width: 34px; text-align: center; }
.ligne-page .t { flex: 1; display: grid; gap: 2px; }
.ligne-page .t b { font: 18px/1.1 'Lilita One', system-ui; font-weight: 400; }
.ligne-page .t small { font-size: 13px; opacity: .8; }
.secret { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--parchemin2); font-size: 16px; }
.secret i { font-style: normal; color: #b08a1e; font-size: 20px; }
.secret.cache { opacity: .55; }
.diapo { display: grid; gap: 14px; justify-items: center; text-align: center; }
.diapo .ill { font-size: 56px; line-height: 1; }
.pastilles { display: flex; justify-content: center; gap: 8px; }
.pastilles i { width: 10px; height: 10px; border-radius: 5px; background: #cdb184; }
.pastilles i.ici { background: var(--terre); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt { display: flex; gap: 12px; }
.opt .btn { flex: 1; }
.opt .btn.actif { background: var(--terre); color: #fff; box-shadow: 0 4px 0 #7a3a1e; }

.toast { position: fixed; z-index: 12; left: 50%; top: calc(140px + var(--haut)); translate: -50% 0; max-width: calc(100% - 40px); background: var(--encre); color: var(--parchemin);
  padding: 10px 16px; border-radius: 14px; font-size: 15px; text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); animation: arrive .35s cubic-bezier(.3, 1.6, .5, 1); }
.toast.secret-trouve { background: linear-gradient(#f6d77a, #e8b93a); color: var(--encre); font: 18px/1.2 'Lilita One', system-ui; }
.update { position: fixed; z-index: 30; left: 12px; right: 12px; top: calc(10px + var(--haut)); display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--encre); color: var(--parchemin); padding: 10px 12px 10px 16px; border-radius: 14px; }
.update button { border: 0; border-radius: 10px; padding: 8px 12px; background: var(--or); color: var(--encre); font-weight: 800; }

/* lecture de l'histoire : le plateau s'efface */
body.lecture #plateau { opacity: .35; pointer-events: none; }
.confetti { position: fixed; z-index: 11; width: 9px; height: 14px; border-radius: 2px; pointer-events: none; }

/* petits écrans (iPhone SE…) : pièces plus compactes */
@media (max-height: 700px) {
  .jeton img { aspect-ratio: 1.6; }
  .but { font-size: 17px; padding: 8px 12px; }
  #texte { font-size: 14px; }
}

/* ---------- Ordinateur ---------- */
@media (min-width: 960px) and (min-height: 600px) {
  #haut { left: 50%; right: auto; width: min(560px, 46vw); translate: -50% 0; top: 18px; }
  .page span { font-size: 26px; }
  .but { font-size: 22px; padding: 12px 16px; }
  #bas { left: 50%; right: auto; width: min(980px, 76vw); translate: -50% 0; padding-bottom: 20px; grid-template-columns: 1fr; }
  .rang { gap: 14px; }
  .plateau { grid-template-columns: auto auto; justify-content: center; column-gap: 36px; padding: 14px 20px; }
  .jeton { flex-basis: clamp(80px, 7.5vw, 104px); }
  .jeton:hover { transform: translateY(-4px); }
  .rond:hover, .fleche:hover, .btn:hover { filter: brightness(1.06); }
  #texte { font-size: 17px; }
  .ecran { grid-template-columns: 1.2fr 1fr; align-items: center; justify-items: stretch; padding: 40px 6vw; column-gap: 6vw; }
  .titre-gauche { text-align: left; }
  .logo { font-size: clamp(72px, 7vw, 120px); }
  .accroche { font-size: 20px; }
  .menu { width: min(380px, 100%); justify-self: end; }
  .btn.grand { font-size: 30px; padding: 22px; }
  .pied { grid-column: 1 / -1; align-self: end; }
}
