:root {
  --r: #d6283c; --v: #1d9a4a; --b: #2455d6;
  --papier: #f4f1ea; --encre: #1b1a17; --gris: #6b675d; --trait: #cfc9bb;
  --t: var(--encre);
}
@media (prefers-color-scheme: dark) {
  :root { --papier: #16150f; --encre: #eeeae0; --gris: #a09b8d; --trait: #3a382f; --r: #ff5a6e; --v: #3ddc7a; --b: #6f93ff; }
}
[data-tint="r"] { --t: var(--r); }
[data-tint="v"] { --t: var(--v); }
[data-tint="b"] { --t: var(--b); }

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--t) 12%, var(--papier)); color: var(--encre);
  font: 17px/1.55 Georgia, "Times New Roman", serif; transition: background .6s;
}
a { color: inherit; }
.c-r { color: var(--r); font-weight: 600; } .c-v { color: var(--v); font-weight: 600; } .c-b { color: var(--b); font-weight: 600; }
.marque { color: var(--r); }
abbr.glo { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.lexique { margin: 1.4rem 0; border: 1px solid var(--trait); padding: .5rem .9rem; background: color-mix(in srgb, var(--encre) 4%, transparent); }
.lexique summary { cursor: pointer; font: 700 .85rem ui-monospace, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.lexique dl { margin: .8rem 0 .2rem; }
.lexique dt { font-weight: 700; margin-top: .7rem; }
.lexique dd { margin: .1rem 0 0; font-size: .92rem; color: var(--gris); }
nav .langue { font: 700 .8rem ui-monospace, Consolas, monospace; letter-spacing: .08em; text-decoration: none; border: 1px solid var(--trait); padding: 1px 7px; }
nav .langue:hover { background: var(--encre); color: var(--papier); }
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem; padding: 14px 16px; border-bottom: 1px solid var(--trait); }
.marque { font: 700 1.4rem/1 ui-monospace, Consolas, monospace; text-decoration: none; letter-spacing: .05em; }
.sous { color: var(--gris); font-style: italic; }
nav { margin-left: auto; display: flex; gap: 1rem; align-items: baseline; }
nav button { font: inherit; font-size: .9rem; background: none; border: 1px solid var(--trait); color: inherit; padding: 2px 10px; cursor: pointer; }
nav button[aria-pressed="true"] { background: var(--t, var(--encre)); color: var(--papier); border-color: transparent; }
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
footer { padding: 16px; border-top: 1px solid var(--trait); color: var(--gris); font-size: .85rem; text-align: center; }
footer p { margin: .2rem 0; }

h1, h2 { font-weight: 400; line-height: 1.2; }
h1 { font-size: 1.7rem; margin: 0 0 .6rem; }
.etape { font: .8rem/1 ui-monospace, Consolas, monospace; text-transform: uppercase; letter-spacing: .12em; color: var(--t); margin: 0 0 .8rem; }
.citation { border-left: 3px solid var(--t); margin: 1rem 0; padding: .1rem 0 .1rem 1rem; font-style: italic; }
.discret { color: var(--gris); font-size: .9rem; }

button.gros, .btn {
  font: 600 1rem ui-monospace, Consolas, monospace; padding: .8rem 1.4rem; margin: .4rem .4rem .4rem 0;
  background: var(--encre); color: var(--papier); border: 0; cursor: pointer; letter-spacing: .04em; text-decoration: none; display: inline-block;
}
[data-tint] button.gros { background: var(--t); color: #fff; }
button.gros:disabled { opacity: .35; cursor: not-allowed; }
button.gros:focus-visible, input:focus-visible, .bulletin:focus-visible { outline: 3px solid var(--t); outline-offset: 2px; }

.jauge { height: 8px; background: color-mix(in srgb, var(--encre) 12%, transparent); margin: .6rem 0; overflow: hidden; }
.jauge i { display: block; height: 100%; width: 0; background: var(--t); }

/* --- simulateur --- */
.simu svg { width: 100%; height: auto; max-height: 52vh; background: color-mix(in srgb, var(--encre) 6%, var(--papier)); border: 1px solid var(--trait); }
.simu .legende { display: flex; justify-content: space-between; font: 1rem ui-monospace, Consolas, monospace; margin-top: .5rem; }
.simu .code i { font-style: normal; }
#fig { transition: transform .14s linear; }
#sculpt { transition: transform .14s linear; }

/* --- boîte de neutralisation --- */
.bn { width: 220px; height: 160px; margin: 4.5rem auto 1.5rem; position: relative; perspective: 500px; }
.bn .corps { position: absolute; inset: 40px 0 0 0; background: var(--t); box-shadow: inset 0 -14px 0 rgba(0,0,0,.18); }
.bn .couvercle { position: absolute; left: -6px; right: -6px; top: 22px; height: 24px; background: var(--t); filter: brightness(.85); transform-origin: top center; transition: transform .7s cubic-bezier(.2,.8,.2,1); }
.bn.ouverte .couvercle { transform: rotateX(-115deg); }
.bn .contenu { position: absolute; left: 50%; top: 56px; width: 110px; height: 110px; margin-left: -55px; opacity: 0; box-shadow: 0 0 0 3px var(--papier); transition: opacity .5s .3s, transform .6s .3s; }
.bn .contenu img { display: block; width: 100%; height: 100%; object-fit: contain; }
.bn.ouverte .contenu { opacity: 1; transform: translateY(-70px); }

/* --- périmètre d'estimation --- */
.pe { position: relative; height: 320px; overflow: hidden; border: 1px solid var(--trait); background: linear-gradient(#f4f1ea, #e2ddcf 70%); }
@media (prefers-color-scheme: dark) { .pe { background: linear-gradient(#1c1b14, #0f0e09 70%); } }
.pe .sol { position: absolute; left: 0; right: 0; bottom: 0; height: 60px; border-top: 1px solid var(--trait); }
.pe .cercle { position: absolute; left: 50%; bottom: 8px; width: 240px; height: 40px; margin-left: -120px; border: 2px dashed var(--t); border-radius: 50%; opacity: .6; }
.pe .piedestal { position: absolute; left: 50%; bottom: 40px; width: 170px; height: 90px; margin-left: -85px; background: var(--r); }
.pe .piedestal::before { content: ""; position: absolute; left: -10px; right: -10px; top: -8px; height: 10px; background: var(--r); filter: brightness(.85); }
.pe img { position: absolute; left: 50%; bottom: 128px; height: 200px; width: auto; max-width: 340px; object-fit: contain; transform-origin: 50% 100%; transform: translateX(-50%) scale(1); }
.reglage { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; margin: 1rem 0 .2rem; }
.reglage input[type=range] { width: 100%; accent-color: var(--t); }
.reglage output { font: 1.3rem ui-monospace, Consolas, monospace; min-width: 5.5ch; text-align: right; }
.pe-msg { min-height: 3.2em; }
.fiche { border: 1px solid var(--trait); padding: .6rem .9rem; margin: .8rem 0; background: color-mix(in srgb, var(--t) 8%, transparent); }

/* --- isoloir --- */
.isoloir { background: color-mix(in srgb, var(--t) 16%, var(--papier)); border: 2px solid var(--t); padding: 1rem; margin: 1rem 0; }
.bulletins { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.bulletin { border: 3px solid transparent; padding: 1.1rem .4rem; text-align: center; color: #fff; cursor: pointer; font: 700 1rem ui-monospace, Consolas, monospace; background: var(--bc); transition: transform .15s; }
.bulletin b { display: block; font-size: 2rem; }
.bulletin[aria-checked="true"] { border-color: var(--encre); transform: translateY(-6px) rotate(-1.5deg); box-shadow: 0 8px 0 rgba(0,0,0,.2); }
.bulletin.s { --bc: var(--r); } .bulletin.d { --bc: var(--v); } .bulletin.m { --bc: var(--b); }
.de { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin-right: .8rem; background: var(--t); color: #fff; font: 700 1.9rem ui-monospace, Consolas, monospace; vertical-align: middle; }
.de.roule { animation: roule .09s linear infinite; }
@keyframes roule { to { transform: rotate(90deg) scale(.92); } }
.hcase { display: flex; gap: .5rem; align-items: center; margin: .6rem 0; }
.urne { width: 120px; height: 80px; margin: 1rem 0 0 auto; background: var(--t); position: relative; }
.urne::before { content: ""; position: absolute; left: 20px; right: 20px; top: 12px; height: 6px; background: rgba(0,0,0,.55); }
.urne .chute { position: absolute; left: 40px; width: 40px; height: 54px; top: -70px; background: var(--bc); opacity: 0; }
.urne.depose .chute { animation: chute .9s ease-in forwards; }
@keyframes chute { 0% { opacity: 1; transform: translateY(0); } 70% { opacity: 1; transform: translateY(78px); } 100% { opacity: 0; transform: translateY(84px) scaleY(0); } }

table.recap { border-collapse: collapse; width: 100%; margin: 1rem 0; }
table.recap td, table.recap th { border-bottom: 1px solid var(--trait); padding: .5rem .3rem; text-align: left; }
.pastille { display: inline-block; width: .9em; height: .9em; margin-right: .4em; vertical-align: -.05em; }
.pastille.r { background: var(--r); } .pastille.v { background: var(--v); } .pastille.b { background: var(--b); }

/* --- sanctuaire : œuvres sacralisées sur piédestaux rouges --- */
main.large { max-width: 1040px; }
.sanct { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2.4rem 1.6rem; margin: 2rem 0; align-items: end; }
.socle { margin: 0; text-align: center; }
.sur-socle { height: 260px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 0; position: relative; }
.sur-socle img { max-width: 100%; max-height: 250px; object-fit: contain; display: block; filter: drop-shadow(0 10px 14px rgba(0,0,0,.35)); }
.sur-socle::before { content: ""; position: absolute; left: 50%; bottom: 0; width: 70%; height: 92%; transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, color-mix(in srgb, #c9a227 32%, transparent), transparent 70%); pointer-events: none; }
.piedestal-rouge { position: relative; height: 84px; background: var(--r); margin: 0 auto; width: 78%; box-shadow: inset 0 -12px 0 rgba(0,0,0,.18); }
.piedestal-rouge::before { content: ""; position: absolute; left: -8%; right: -8%; top: -10px; height: 12px; background: var(--r); filter: brightness(.85); }
.socle figcaption { margin-top: .9rem; font-size: .92rem; }
.socle.vide .sur-socle { height: 120px; }
.socle.vide .piedestal-rouge { opacity: .55; }

/* --- archives --- */
.scrutin { margin: 0 0 2.4rem; }
.scrutin h2 { font: 700 1rem ui-monospace, Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; border-bottom: 2px solid var(--encre); padding-bottom: .3rem; }
.alien { background: var(--encre); color: var(--papier); padding: .6rem .9rem; margin: .8rem 0; font-style: italic; }
.trio { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.carte { border: 1px solid var(--trait); padding: .8rem; position: relative; overflow: hidden; }
.carte .etat { font: 700 .8rem ui-monospace, Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 .5rem; }
.carte img { width: 100%; height: 180px; object-fit: contain; background: color-mix(in srgb, var(--encre) 6%, transparent); display: block; }
.carte p { margin: .5rem 0 0; font-size: .92rem; }
.carte.sacralisee { border: 2px solid #c9a227; box-shadow: 0 0 0 4px color-mix(in srgb, #c9a227 25%, transparent), 0 0 24px color-mix(in srgb, #c9a227 35%, transparent); }
.carte.sacralisee .etat { color: #a5820a; }
.carte.detruite { background: #111; color: #d9d4c7; border-color: #111; }
.carte.detruite .cendres { height: 180px; display: grid; place-items: center; text-align: center; padding: 1rem; background: repeating-linear-gradient(135deg, #1a1a1a 0 8px, #141414 8px 16px); color: #8a8a80; font: .85rem ui-monospace, Consolas, monospace; }
.carte.mepris { border: 2px solid var(--b); }
.carte.mepris img { filter: grayscale(1) contrast(.8); opacity: .75; }
.carte.mepris .etat { color: var(--b); }
.carte.neutre img { filter: blur(9px) grayscale(.6); }
.coul-r { border-top: 6px solid var(--r); } .coul-v { border-top: 6px solid var(--v); } .coul-b { border-top: 6px solid var(--b); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
