/* batisseur/batisseur.css — « Le Bâtisseur de Pierreval » : pierre de taille, cuir, laiton, nuit d'ardoise.
   Garde-fous fond sombre : .wrap ET .fv-header ont une couleur de texte explicite (+ bloc thèmes en fin de fichier). */
:root {
  --nuit: #16121e; --texte: #f6efe2; --doux: #d8cbb6; --or: #f2c66a; --rouge: #ff9a8a; --vert: #9dffc4;
  --pierre: #3a3240; --pierre2: #262030; --parch: #f2e4c4; --encre: #3a2412;
  --titre: Georgia, "Times New Roman", Times, serif;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: radial-gradient(ellipse at top, #4a3a4e 0%, var(--nuit) 70%) fixed; background-color: var(--nuit); color: var(--texte); font-family: var(--police); -webkit-tap-highlight-color: transparent; }
body { overflow-x: hidden; min-height: 100vh; }
.wrap { position: relative; z-index: 1; width: calc(100% - 16px); max-width: 1400px; margin: 0 auto; padding: 6px 0 10px; display: flex; flex-direction: column; gap: 6px; color: var(--texte); }

/* ── Bandeau ── */
.fv-header { display: flex; align-items: center; gap: 7px; padding: 6px 8px; min-height: 56px; background: linear-gradient(#3a3240, #241e2c); border: 1px solid rgba(242, 198, 106, .4); border-radius: 16px; color: var(--texte); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.fv-header .titre { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
.fv-header .nom-jeu { font: 700 1.12rem var(--titre); font-variant: small-caps; letter-spacing: .04em; color: #fff; }
.fv-header .titre small { display: block; font-size: .75rem; color: var(--doux); overflow: hidden; text-overflow: ellipsis; }
.outils-tete { display: flex; align-items: center; gap: 6px; flex: none; }
.pastille { flex: none; border-radius: 99px; padding: 6px 10px; background: rgba(242, 198, 106, .12); border: 1px solid rgba(242, 198, 106, .45); font-weight: 800; font-size: 1rem; white-space: nowrap; color: var(--or); letter-spacing: 1px; }
.pastille i { font-style: normal; opacity: .25; filter: grayscale(1); }
.btn-rond { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(242, 198, 106, .45); background: linear-gradient(#5a4a5e, #2e2636); color: var(--texte); font-size: 1.15rem; display: grid; place-items: center; padding: 0; cursor: pointer; font-family: inherit; text-decoration: none; }
.btn-rond:active { transform: scale(.94); }
@media (max-width: 560px) {
  .fv-header { flex-wrap: wrap; }
  .fv-header .titre { flex-basis: calc(100% - 52px); }
  .outils-tete { width: 100%; justify-content: space-between; }
}

/* ── Grille : scène + console (côte à côte en paysage large, empilées sinon) ── */
.jeu { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .jeu { grid-template-columns: minmax(0, 1.6fr) minmax(330px, 1fr); align-items: start; }
}

/* ── Scène ── */
.scene { position: relative; width: 100%; aspect-ratio: 16 / 8.6; overflow: hidden; border-radius: 18px; border: 2px solid rgba(242, 198, 106, .5); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #2a2230; user-select: none; -webkit-user-select: none; }
@media (max-width: 899px), (max-aspect-ratio: 1/1) { .scene { aspect-ratio: 16 / 9.4; } }
@media (max-width: 600px) { .scene { aspect-ratio: 16 / 10.5; } }
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.etapes { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; pointer-events: none; }
.etapes span { font: 700 .72rem var(--police); padding: 3px 8px; border-radius: 99px; background: rgba(22, 18, 30, .72); color: var(--doux); border: 1px solid rgba(255, 255, 255, .12); }
.etapes span.fait { color: #10251a; background: var(--vert); border-color: transparent; }
.etapes span.actif { color: #2a1a04; background: var(--or); border-color: transparent; box-shadow: 0 0 14px rgba(242, 198, 106, .6); }

/* ── Console ── */
.console { display: flex; flex-direction: column; gap: 8px; background: linear-gradient(#3a3240, #221c2a); border: 1px solid rgba(242, 198, 106, .35); border-radius: 18px; padding: 10px 12px 6px; color: var(--texte); min-width: 0; box-shadow: inset 0 0 30px rgba(0, 0, 0, .3); }
.guide { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.portrait { width: 64px; height: 64px; border-radius: 50%; flex: none; border: 2px solid var(--or); overflow: hidden; background: #2a2230; }
.bulle { position: relative; flex: 1; background: var(--parch); color: #2b2135; border-radius: 14px; padding: 8px 12px; font-size: 1rem; line-height: 1.45; min-width: 0; min-height: 48px; }
.bulle b { color: #7a3d0c; }
.bulle .avertit { color: #9a2a1a; }
.bulle .gonf { color: #6a2a8a; font-style: italic; }
.bulle .solution { display: block; margin-top: 4px; padding: 6px 8px; border-radius: 10px; background: rgba(122, 61, 12, .1); border-left: 4px solid #b4782a; }
.bulle:before { content: ""; position: absolute; left: -8px; top: 22px; border: 8px solid transparent; border-right-color: var(--parch); border-left: 0; }
.poste { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: center; min-width: 0; }
.zone-saisie { flex-basis: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pied { min-height: 26px; display: flex; align-items: center; justify-content: center; }
.pied .msg { text-align: center; font-size: .92rem; color: var(--doux); }
.pied .msg.ok { color: var(--vert); } .pied .msg.ko { color: var(--rouge); }

/* Saisie : cases, puissance, encadrement, pavé */
.saisie { display: flex; align-items: center; gap: 8px; font: 700 1.25rem var(--police); flex-wrap: wrap; justify-content: center; }
.saisie .lib { color: var(--doux); font-weight: 700; white-space: nowrap; }
.saisie.multi { flex-direction: column; gap: 6px; }
.saisie.multi .ligne { display: flex; align-items: center; gap: 8px; }
.saisie.multi .lib { min-width: 64px; text-align: right; }
.case { display: inline-block; min-width: 80px; min-height: 50px; line-height: 46px; text-align: center; font: 800 1.3rem/46px var(--police); border-radius: 10px; border: 2px solid rgba(216, 203, 182, .5); background: #16121e; color: var(--texte); padding: 0 8px; cursor: pointer; font-variant-numeric: tabular-nums; vertical-align: middle; white-space: nowrap; }
.case.petite { min-width: 54px; min-height: 44px; line-height: 40px; font-size: 1.05rem; }
.case.vide { color: rgba(255, 255, 255, .3); }
.case.actif { border-color: var(--or); box-shadow: 0 0 0 3px rgba(242, 198, 106, .3); }
.case.juste { border-color: var(--vert); color: var(--vert); }
.case.faux { border-color: var(--rouge); color: var(--rouge); animation: tremble .4s; }
.puiss { display: inline-flex; align-items: flex-start; gap: 2px; }
.expo { display: inline-block; transform: translateY(-20px); }
.aide-saisie { font-size: .78rem; color: var(--doux); }
@keyframes tremble { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.pave { display: grid; grid-template-columns: repeat(4, 56px); gap: 6px; }
.touche { height: 50px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .18); background: linear-gradient(180deg, #6a5e6e, #3e3446); color: var(--texte); font: 800 1.25rem var(--police); cursor: pointer; padding: 0; box-shadow: 0 3px 0 #1a1420; }
.touche:active { transform: translateY(2px); box-shadow: 0 1px 0 #1a1420; }
.touche.efface { color: var(--rouge); }
.action { font: 800 1.05rem var(--police); color: #2a1a04; background: linear-gradient(#ffe6a0, #f2c66a); border: 0; border-radius: 16px; padding: 12px 18px; min-height: 52px; cursor: pointer; box-shadow: 0 5px 0 #a07a20, 0 10px 24px rgba(242, 198, 106, .3); animation: appel 2.4s ease-in-out infinite; }
.action:active { transform: translateY(3px); box-shadow: 0 2px 0 #a07a20; }
.action:disabled { opacity: .45; animation: none; cursor: default; }
@keyframes appel { 50% { box-shadow: 0 5px 0 #a07a20, 0 10px 34px rgba(242, 198, 106, .7); } }
.choix-liste { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 620px; }
.choix-liste button { text-align: left; font: 700 1rem var(--police); color: var(--texte); background: #4a3e52; border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px; padding: 10px 14px; min-height: 52px; cursor: pointer; line-height: 1.3; }
.choix-liste button.actif { background: linear-gradient(#7a6488, #554464); border-color: var(--or); box-shadow: 0 0 0 3px rgba(242, 198, 106, .25); }
.choix-liste button.faux { border-color: var(--rouge); background: #5a2a36; }
.choix-liste button.juste { border-color: var(--vert); background: linear-gradient(#2a7a5a, #1d4f3e); }

/* ── Fenêtres ── */
.voile-modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 12px; background: rgba(10, 6, 14, .72); backdrop-filter: blur(3px); }
.voile-modal.ouvert { display: flex; }
.dialogue { width: min(640px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; background: linear-gradient(#3a3240, #221c2a); color: var(--texte); border: 2px solid rgba(242, 198, 106, .55); border-radius: 20px; padding: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: entre .35s ease-out; }
@keyframes entre { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.dialogue h2 { margin: 0 0 8px; font: 700 1.3rem var(--titre); color: var(--or); font-variant: small-caps; }
.dialogue h3 { margin: 10px 0 4px; font: 700 1.02rem var(--titre); color: var(--or); }
.dialogue p { line-height: 1.5; margin: 6px 0; }
.dialogue small { color: var(--doux); }
.dialogue b { color: #ffe6a0; }
.dialogue .qui { font: 700 1.05rem var(--titre); font-variant: small-caps; color: var(--or); margin-bottom: 4px; }
.replique { display: flex; gap: 12px; align-items: flex-start; }
.dialogue .boutons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn-sec { font: 700 1rem var(--police); color: var(--texte); background: transparent; border: 1px solid rgba(242, 198, 106, .55); border-radius: 14px; padding: 10px 16px; min-height: 48px; cursor: pointer; }

/* Portraits dessinés (tête de la pose courante) */
.portrait-dessin { display: block; width: 100%; height: 100%; }
.portrait-dessin img { display: block; width: 100%; height: 100%; object-fit: cover; animation: entre-portrait .3s ease-out; }
@keyframes entre-portrait { from { opacity: .3; transform: scale(1.06); } }
.portrait-dessin.parle img { animation: parle-portrait .45s ease-in-out infinite alternate; }
@keyframes parle-portrait { from { transform: translateY(0) scale(1); } to { transform: translateY(-1.5px) scale(1.03); } }
.replique .portrait-dessin { width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--or); overflow: hidden; flex: none; }
@media (prefers-reduced-motion: reduce) { .portrait-dessin img, .action { animation: none !important; } }

/* ── Fin de niveau, carte, grimoire ── */
.etoiles-fin { font-size: 2.8rem; text-align: center; letter-spacing: 10px; margin: 6px 0; color: var(--or); text-shadow: 0 0 18px rgba(242, 198, 106, .7); }
.etoiles-fin i { font-style: normal; display: inline-block; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.etoiles-fin i.vide { opacity: .22; filter: grayscale(1); text-shadow: none; }
@keyframes pop { from { transform: scale(0) translateY(-30px); opacity: 0; } }
.trophee { text-align: center; font-weight: 800; color: var(--or); font-size: 1.1rem; }
.sceau-txt { text-align: center; color: var(--or); }
.carte h2 { margin: 0 0 4px; text-align: center; font: 700 1.6rem var(--titre); font-variant: small-caps; letter-spacing: .04em; color: #fff; text-shadow: 0 0 18px rgba(242, 198, 106, .5); }
.carte .sous { text-align: center; color: var(--doux); margin: 0 0 14px; font-size: .92rem; }
.carte .legende { text-align: center; color: var(--doux); font-size: .82rem; margin: 10px 0 0; }
.chapitres { display: grid; gap: 10px; }
.chap { --c: #ffd27a; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, .18); cursor: pointer; text-align: left; font: inherit; color: var(--texte); background: linear-gradient(90deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02)); min-height: 64px; width: 100%; }
.chap:disabled { opacity: .45; cursor: default; }
.chap .num { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; font-size: 1.4rem; background: radial-gradient(circle at 35% 30%, #fff, var(--c) 60%); box-shadow: 0 0 16px var(--c); }
.chap .t { flex: 1; font-weight: 700; min-width: 0; }
.chap .t small { display: block; font-weight: 400; color: var(--doux); font-size: .8rem; }
.chap .barre { display: block; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .08); margin-top: 6px; overflow: hidden; }
.chap .barre i { display: block; height: 100%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chap .et { font-size: .9rem; white-space: nowrap; color: var(--or); }
.niveaux-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; }
.niveaux-liste button { font: inherit; text-align: left; cursor: pointer; padding: 9px 11px; border-radius: 12px; border: 1px solid rgba(242, 198, 106, .3); background: rgba(255, 255, 255, .05); color: var(--texte); min-height: 56px; }
.niveaux-liste button:disabled { opacity: .4; cursor: default; }
.niveaux-liste .et { display: block; font-size: .9rem; letter-spacing: 2px; margin-top: 2px; color: var(--or); }
.niveaux-liste .et i { font-style: normal; opacity: .22; filter: grayscale(1); }
.niveaux-liste .boss { border-color: rgba(255, 210, 120, .75); background: rgba(242, 198, 106, .08); }
.grimoire .qui { font-size: 1.15rem; }
.grimoire .onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.grimoire .onglets button { font: 700 .85rem var(--police); color: var(--texte); background: #4a3e52; border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; padding: 8px 10px; min-height: 44px; cursor: pointer; }
.grimoire .onglets button.actif { background: var(--or); color: #2a1a04; }
.grimoire .page { background: linear-gradient(180deg, #f1e7cc, #e2d3aa); color: #2a1a04; border-radius: 14px; padding: 14px 16px; box-shadow: inset 0 0 40px rgba(120, 80, 30, .3); }
.grimoire .page h3 { margin: 0 0 8px; font: 700 1.12rem var(--titre); color: #5a3410; }
.grimoire .page p { color: #2a1a04; }
.grimoire .page b { color: #7a4a10; }
.grimoire .page .ex { font-family: var(--titre); color: #1a3a6a; }
.grimoire svg { display: block; margin: 8px auto 0; max-width: 100%; }
.table-carres { border-collapse: collapse; margin: 8px auto; font-variant-numeric: tabular-nums; }
.table-carres th, .table-carres td { border: 1px solid rgba(90, 52, 16, .4); padding: 4px 5px; text-align: center; font-size: .9rem; color: #2a1a04; }
.table-carres th { background: rgba(120, 70, 20, .12); font-weight: 700; }
.table-carres td { font-weight: 800; }
@media (max-width: 640px) { .table-carres { display: block; overflow-x: auto; } }
.seo-about { max-width: 840px; margin: 26px auto 16px; padding: 16px 22px; border-radius: 14px; background: rgba(22, 18, 30, .85); border: 1px solid rgba(242, 198, 106, .3); color: var(--doux); font-size: .92rem; line-height: 1.55; }
.seo-about h2 { color: var(--or); font-size: 1.05rem; margin: 0 0 8px; }
.seo-about a { color: #ffe6a0; }

/* ── Téléphone ── */
/* Boutons flottants du site (🔍 et 🐛 en bas à gauche, ✏️ Ardoise en bas à droite) : le pavé et « Valider » restent
   entre eux (marges latérales, comme permis_rapporteur/) et une bande libre de 64 px ferme la console (comme
   caravane/ et volcan/) : rien n'est caché, même tout en bas de la page. */
@media (max-width: 640px) {
  .poste { padding: 0 52px; }
  .console { padding-bottom: 64px; }
}
@media (max-width: 640px) {
  .wrap { width: 100%; padding: 4px 4px 8px; }
  .pave { grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 330px; }
  .action { width: 100%; }
  .bulle { font-size: .94rem; }
  .portrait { width: 56px; height: 56px; }
  .dialogue { padding: 12px; }
  .replique .portrait-dessin { width: 64px; height: 64px; }
  .etapes span { font-size: .62rem; padding: 2px 6px; }
  .case { min-width: 70px; }
}

/* Garde-fous thèmes du site : le jeu garde son fond sombre → texte clair ; parchemins → encre sombre */
html body[class*="theme-"] .fv-header, html body[class*="theme-"] .fv-header * { color: #fff !important; -webkit-text-fill-color: #fff !important; text-shadow: none !important; }
html body[class*="theme-"] .wrap, html body[class*="theme-"] .wrap * { color: #f6efe2 !important; -webkit-text-fill-color: #f6efe2 !important; text-shadow: none !important; }
html body[class*="theme-"] .wrap .fv-header small { color: #d8cbb6 !important; -webkit-text-fill-color: #d8cbb6 !important; }
html body[class*="theme-"] .wrap .pastille { color: #f2c66a !important; -webkit-text-fill-color: #f2c66a !important; }
html body[class*="theme-"] .wrap .bulle, html body[class*="theme-"] .wrap .bulle * { color: #2b2135 !important; -webkit-text-fill-color: #2b2135 !important; }
html body[class*="theme-"] .wrap .bulle b { color: #7a3d0c !important; -webkit-text-fill-color: #7a3d0c !important; }
html body[class*="theme-"] .wrap .bulle .avertit { color: #9a2a1a !important; -webkit-text-fill-color: #9a2a1a !important; }
html body[class*="theme-"] .wrap .bulle .gonf { color: #6a2a8a !important; -webkit-text-fill-color: #6a2a8a !important; }
html body[class*="theme-"] .wrap .action, html body[class*="theme-"] .wrap .action * { color: #2a1a04 !important; -webkit-text-fill-color: #2a1a04 !important; }
html body[class*="theme-"] .wrap .msg.ok, html body[class*="theme-"] .wrap .case.juste { color: #9dffc4 !important; -webkit-text-fill-color: #9dffc4 !important; }
html body[class*="theme-"] .wrap .msg.ko, html body[class*="theme-"] .wrap .touche.efface, html body[class*="theme-"] .wrap .case.faux { color: #ff9a8a !important; -webkit-text-fill-color: #ff9a8a !important; }
html body[class*="theme-"] .wrap .etapes span.actif, html body[class*="theme-"] .wrap .etapes span.fait { color: #1a1230 !important; -webkit-text-fill-color: #1a1230 !important; }
html body[class*="theme-"] .voile-modal .dialogue, html body[class*="theme-"] .voile-modal .dialogue * { color: #f6efe2 !important; -webkit-text-fill-color: #f6efe2 !important; }
html body[class*="theme-"] .voile-modal .action, html body[class*="theme-"] .voile-modal .action * { color: #2a1a04 !important; -webkit-text-fill-color: #2a1a04 !important; }
html body[class*="theme-"] .voile-modal .grimoire .page, html body[class*="theme-"] .voile-modal .grimoire .page * { color: #2a1a04 !important; -webkit-text-fill-color: #2a1a04 !important; }
html body[class*="theme-"] .voile-modal .dialogue .qui, html body[class*="theme-"] .voile-modal .etoiles-fin, html body[class*="theme-"] .voile-modal .trophee { color: #f2c66a !important; -webkit-text-fill-color: #f2c66a !important; }
