/* Site du jeu — on descend la tour, un décor par étage, d'après les moodboards de la créa.
   Style illustré : aplats, contours sombres épais, matières lisibles (cristal, cuivre, bois, pierre moussue). */
:root {
    --encre: #241a33;           /* contours, comme les décors dessinés */
    /* Étage 4 : palais de cristal */
    --lavande: #c9b8ff; --lavande-fonce: #6b5ca8; --ciel: #e9e3ff; --bleu-cristal: #9fd8ff; --rose: #ffc6ec;
    /* Étage 3 : machinerie */
    --metal: #2f3a36; --metal-fonce: #1a211f; --cuivre: #c9773f; --lueur: #7dffb0;
    /* Étage 2 : terriers en bois */
    --bois: #8a5a2e; --bois-fonce: #4a2c14; --parchemin: #f6e7c4; --lanterne: #ffb347;
    /* Étage 1 : ruines moussues */
    --pierre: #8b8a7c; --pierre-fonce: #4b4a40; --mousse: #6f9a3a; --mousse-fonce: #2b3d18; --luciole: #f6d84a;

    --titre: "Cinzel", "Palatino Linotype", Georgia, serif;
    --titre-deco: "Cinzel Decorative", "Cinzel", Georgia, serif;
    --corps: "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--corps); color: var(--encre); line-height: 1.5; background: var(--metal-fonce); }

.etage { position: relative; overflow: hidden; padding: 4rem 1rem 4.5rem; }
.contenu { position: relative; z-index: 2; max-width: 860px; margin: 0 auto; }
h1, h2 { font-family: var(--titre); margin: 0; }
h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); text-align: center; margin-bottom: 1.5rem; }
.vide { text-align: center; font-style: italic; }

/* Plaque gravée « Étage N », comme un panneau de la tour. */
.plaque-etage {
    width: max-content; margin: 0 auto 1.2rem; padding: .25rem 1.1rem;
    font-family: var(--titre); font-weight: 800; letter-spacing: .2em; text-transform: uppercase; font-size: .8rem;
    border: 3px solid var(--encre); border-radius: 6px; box-shadow: 0 4px 0 var(--encre);
}

/* Transition entre deux étages : un plancher de pierre. */
.etage + .etage::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 22px; z-index: 3;
    background: repeating-linear-gradient(90deg, #6d6a5e 0 88px, #4b4a40 88px 92px), #6d6a5e;
    border-top: 4px solid var(--encre); border-bottom: 4px solid var(--encre);
}

/* ============ ÉTAGE 4 : palais de cristal ============ */
.etage-4 {
    padding-top: 3rem; padding-bottom: 5rem;
    background: linear-gradient(180deg, #b9c8ff 0%, #e4dcff 45%, #f6efff 100%);
}
.arches { position: absolute; inset: auto 0 0 0; width: 100%; height: 100%; z-index: 0; opacity: .85; }
.cristaux { position: absolute; bottom: 0; width: clamp(120px, 18vw, 230px); z-index: 1; }
.cristaux-g { left: 0; }
.cristaux-d { right: 0; }
.etage-4 .plaque-etage { background: #fff; color: var(--lavande-fonce); }

.entete { position: relative; z-index: 2; text-align: center; margin-bottom: 2.5rem; }
.entete h1 {
    font-family: var(--titre-deco); font-size: clamp(2.2rem, 7vw, 4.4rem); line-height: 1.05; color: #fff;
    -webkit-text-stroke: 2px var(--encre); paint-order: stroke fill;
    text-shadow: 0 5px 0 var(--lavande-fonce), 0 10px 24px rgba(107, 92, 168, .45);
}
.sous-titre { margin: .9rem 0 0; font-weight: 700; color: var(--lavande-fonce); }
.titre-cristal { color: var(--lavande-fonce); }
.titre-cristal::before, .titre-cristal::after { content: "✦"; color: var(--bleu-cristal); -webkit-text-stroke: 1px var(--encre); margin: 0 .5em; }

/* Podium : trois gemmes taillées. */
.podium { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1.18fr 1fr; gap: 1.2rem; align-items: end; }
.gemme {
    position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 2.4rem 1rem 2.6rem;
    clip-path: polygon(50% 0, 100% 18%, 100% 82%, 50% 100%, 0 82%, 0 18%);
    filter: drop-shadow(0 6px 0 var(--encre));
}
.gemme::before { /* contour sombre de la gemme */
    content: ""; position: absolute; inset: 0; z-index: -2; background: var(--encre);
    clip-path: polygon(50% 0, 100% 18%, 100% 82%, 50% 100%, 0 82%, 0 18%);
}
.gemme::after { /* facettes */
    content: ""; position: absolute; inset: 4px; z-index: -1;
    clip-path: polygon(50% 0, 100% 18%, 100% 82%, 50% 100%, 0 82%, 0 18%);
    background:
        linear-gradient(115deg, rgba(255, 255, 255, .55) 0 22%, transparent 22% 100%),
        linear-gradient(245deg, rgba(0, 0, 0, .12) 0 30%, transparent 30% 100%),
        var(--g);
}
.gemme-1 { grid-column: 2; grid-row: 1; --g: linear-gradient(180deg, #fff3b8, #f6c85a); padding-top: 3rem; padding-bottom: 3.2rem; }
.gemme-2 { grid-column: 1; grid-row: 1; --g: linear-gradient(180deg, #e6f4ff, var(--bleu-cristal)); }
.gemme-3 { grid-column: 3; grid-row: 1; --g: linear-gradient(180deg, #ffe6f6, var(--rose)); }
.gemme .etoile { font-size: 1.8rem; line-height: 1; color: #fff; -webkit-text-stroke: 2px var(--encre); }
.gemme-1 .etoile { font-size: 2.6rem; color: #ffe27a; }
.gemme .rang { font-family: var(--titre); font-weight: 800; font-size: .95rem; }
.gemme .nom { font-family: var(--titre); font-weight: 800; font-size: 2rem; letter-spacing: .18em; padding-left: .18em; }
.gemme-1 .nom { font-size: 2.4rem; }
.gemme .points { font-weight: 800; font-size: 1.15rem; }
.gemme .details { font-size: .85rem; font-weight: 700; opacity: .8; }

/* ============ ÉTAGE 3 : machinerie ============ */
.etage-3 {
    padding-top: 7.5rem;
    background:
        radial-gradient(ellipse 50% 40% at 80% 60%, rgba(125, 255, 176, .12), transparent 70%),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, .18) 0 2px, transparent 2px 120px),
        linear-gradient(180deg, #34413b, #232c28);
    color: #e7efe9;
}
.tuyaux { position: absolute; top: 22px; left: 0; width: 100%; height: 100px; z-index: 1; }
.voyants circle { animation: voyant 2.4s ease-in-out infinite; }
.voyants circle:nth-child(2) { animation-delay: .8s; }
.voyants circle:nth-child(3) { animation-delay: 1.6s; }
@keyframes voyant { 50% { fill: #2f8a58; } }
.etage-3 .plaque-etage { background: var(--cuivre); color: #2a1208; }

.panneau-metal {
    position: relative; padding: 2rem clamp(1rem, 4vw, 2.2rem) 2.2rem;
    background: linear-gradient(180deg, #46544d, #36423d);
    border: 4px solid var(--encre); border-radius: 10px;
    box-shadow: inset 0 0 0 6px #5b6b63, inset 0 0 0 9px var(--encre), 0 8px 0 var(--encre);
}
.panneau-metal h2 { color: var(--lueur); text-shadow: 0 0 12px rgba(125, 255, 176, .55), 0 3px 0 var(--encre); }
.rivet { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f0a46c, var(--cuivre) 45%, #5a2a14); border: 2px solid var(--encre); }
.r1 { top: 14px; left: 14px; } .r2 { top: 14px; right: 14px; } .r3 { bottom: 14px; left: 14px; } .r4 { bottom: 14px; right: 14px; }

.classement { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.classement th { font-family: var(--titre); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #b8c7bf; padding: .2rem .5rem; }
.classement td { padding: .55rem .5rem; text-align: center; background: var(--metal-fonce); border-top: 2px solid var(--encre); border-bottom: 2px solid var(--encre); }
.classement td:first-child { border-left: 2px solid var(--encre); border-radius: 8px 0 0 8px; }
.classement td:last-child { border-right: 2px solid var(--encre); border-radius: 0 8px 8px 0; }
.classement th { text-align: center; }
.classement .rang { font-family: var(--titre); font-weight: 800; color: var(--cuivre); }
.classement .nom { font-family: var(--titre); font-weight: 800; letter-spacing: .2em; color: #fff; }
.classement .temps { color: #b8c7bf; }
.classement .points { font-weight: 800; color: var(--lueur); text-shadow: 0 0 8px rgba(125, 255, 176, .6); }

/* Pastille de salle : couleur de l'étage atteint. */
.salle { display: inline-block; padding: .05rem .7rem; border-radius: 999px; font-weight: 800; font-size: .85rem; border: 2px solid var(--encre); color: var(--encre); background: var(--c); }
.e1 { --c: #9cc95a; } .e2 { --c: #f0b264; } .e3 { --c: var(--lueur); } .e4 { --c: var(--lavande); }

/* ============ ÉTAGE 2 : terriers en bois ============ */
.etage-2 {
    background:
        radial-gradient(ellipse 30% 45% at 10% 30%, rgba(255, 179, 71, .35), transparent 70%),
        radial-gradient(ellipse 30% 45% at 90% 30%, rgba(255, 179, 71, .35), transparent 70%),
        repeating-linear-gradient(0deg, transparent 0 46px, rgba(42, 22, 10, .55) 46px 49px),
        repeating-linear-gradient(90deg, transparent 0 180px, rgba(42, 22, 10, .35) 180px 182px),
        linear-gradient(180deg, #9a6634, #6e4220);
    color: var(--parchemin);
}
.porte-ronde { position: absolute; right: -40px; bottom: -30px; width: clamp(140px, 20vw, 230px); z-index: 1; opacity: .95; }
.lanterne { position: absolute; top: 22px; width: 48px; z-index: 1; animation: balance 4s ease-in-out infinite; transform-origin: top center; }
.lanterne-g { left: 6%; }
.lanterne-d { right: 6%; animation-delay: -2s; }
@keyframes balance { 50% { transform: rotate(4deg); } }
.etage-2 .plaque-etage { background: var(--parchemin); color: var(--bois-fonce); }
.titre-bois { color: var(--parchemin); text-shadow: 0 3px 0 var(--encre); }

/* Écriteaux de bois accrochés par des cordes. */
.ecriteaux { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }
.ecriteaux li {
    position: relative; margin-top: 1.6rem; padding: 1rem .6rem; text-align: center;
    background: linear-gradient(180deg, #fbf0d4, var(--parchemin)); color: var(--bois-fonce);
    border: 3px solid var(--encre); border-radius: 8px; box-shadow: 0 5px 0 var(--encre);
    font-weight: 700; font-size: .9rem;
}
.ecriteaux li:nth-child(even) { transform: rotate(1.5deg); }
.ecriteaux li:nth-child(odd) { transform: rotate(-1.5deg); }
.ecriteaux li::before, .ecriteaux li::after { content: ""; position: absolute; top: -1.6rem; width: 3px; height: 1.6rem; background: var(--encre); }
.ecriteaux li::before { left: 25%; }
.ecriteaux li::after { right: 25%; }
.ecriteaux strong { display: block; font-family: var(--titre); font-weight: 800; font-size: 1.9rem; color: #7a3d12; line-height: 1.2; }

/* ============ ÉTAGE 1 : ruines moussues ============ */
.etage-1 {
    padding-bottom: 0;
    background:
        radial-gradient(ellipse 60% 35% at 50% 100%, rgba(111, 154, 58, .45), transparent 70%),
        linear-gradient(rgba(29, 42, 16, .35), rgba(29, 42, 16, .6)),
        repeating-linear-gradient(90deg, transparent 0 96px, rgba(0, 0, 0, .35) 96px 99px),
        repeating-linear-gradient(0deg, transparent 0 64px, rgba(0, 0, 0, .35) 64px 67px),
        linear-gradient(180deg, #5e6a4c, #3a4a2c);
    color: #eef3dc;
}
.etage-1 .plaque-etage { background: var(--pierre); color: #1d2a10; }
.titre-pierre { color: #eef3dc; text-shadow: 0 3px 0 var(--encre); }

.pile { max-width: 600px; margin: 0 auto 3rem; display: flex; flex-direction: column; gap: 0; }
.bloc-pierre {
    display: grid; grid-template-columns: 6rem 1fr 6.5rem; gap: .9rem; align-items: center;
    padding: .8rem 1rem; margin-top: -3px;
    background: linear-gradient(180deg, #9a998b, #7a796c); color: var(--encre);
    border: 3px solid var(--encre);
    box-shadow: inset 0 4px 0 rgba(255, 255, 255, .25), inset 0 -10px 0 rgba(79, 122, 44, .55); /* mousse au pied */
}
.bloc-pierre:first-child { border-radius: 10px 10px 0 0; }
.bloc-pierre:last-child { border-radius: 0 0 10px 10px; }
.nom-niveau { font-family: var(--titre); font-weight: 800; }
.jauge { height: 14px; border-radius: 99px; background: var(--pierre-fonce); border: 2px solid var(--encre); overflow: hidden; }
.jauge span { display: block; height: 100%; min-width: 3px; background: var(--c); }
.nombre { text-align: right; font-weight: 700; font-size: .85rem; }

.lucioles i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--luciole); box-shadow: 0 0 10px 3px rgba(246, 216, 74, .7); animation: luciole 7s ease-in-out infinite; z-index: 1; }
.lucioles i:nth-child(1) { left: 8%; top: 30%; }
.lucioles i:nth-child(2) { left: 18%; top: 70%; animation-delay: -2s; }
.lucioles i:nth-child(3) { left: 30%; top: 20%; animation-delay: -4s; }
.lucioles i:nth-child(4) { left: 72%; top: 25%; animation-delay: -1s; }
.lucioles i:nth-child(5) { left: 84%; top: 60%; animation-delay: -3s; }
.lucioles i:nth-child(6) { left: 92%; top: 35%; animation-delay: -5s; }
.lucioles i:nth-child(7) { left: 60%; top: 75%; animation-delay: -6s; }
.lucioles i:nth-child(8) { left: 45%; top: 12%; animation-delay: -2.5s; }
@keyframes luciole { 0%, 100% { transform: translate(0, 0); opacity: .3; } 50% { transform: translate(14px, -18px); opacity: 1; } }

.mousse { display: block; position: relative; z-index: 2; width: calc(100% + 2rem); margin: 0 -1rem; height: 70px; }
.pied { position: relative; z-index: 2; margin: -2px -1rem 0; padding: .6rem 1rem 1.2rem; text-align: center; font-weight: 700; color: #dfe9c4; background: #4f7a2c; }

/* ============ Back-office : la salle des machines (étage 3) ============ */
body:not(.tour) {
    min-height: 100vh; color: #e7efe9;
    background:
        repeating-linear-gradient(90deg, rgba(0, 0, 0, .18) 0 2px, transparent 2px 120px),
        linear-gradient(180deg, #34413b, #1f2723);
}
body:not(.tour) .entete { padding: 3rem 1rem 1rem; margin: 0; }
body:not(.tour) .entete h1 { font-family: var(--titre); font-size: clamp(2rem, 6vw, 3rem); color: var(--lueur); -webkit-text-stroke: 0; text-shadow: 0 0 14px rgba(125, 255, 176, .5), 0 4px 0 var(--encre); }
body:not(.tour) .sous-titre { color: #b8c7bf; }
body:not(.tour) main { max-width: 620px; margin: 0 auto; padding: 1rem; }
.bloc {
    padding: 1.8rem clamp(1rem, 4vw, 2.2rem);
    background: linear-gradient(180deg, #46544d, #36423d);
    border: 4px solid var(--encre); border-radius: 10px;
    box-shadow: inset 0 0 0 6px #5b6b63, inset 0 0 0 9px var(--encre), 0 8px 0 var(--encre);
}
.formulaire label { display: block; margin-top: 1.1rem; font-weight: 800; }
.formulaire input {
    display: block; width: 100%; margin-top: .35rem; padding: .6rem .7rem; font: inherit; font-size: 1.05rem;
    background: var(--metal-fonce); color: var(--lueur); border: 3px solid var(--encre); border-radius: 8px;
}
.formulaire input:focus { outline: 3px solid var(--cuivre); outline-offset: 1px; }
.couleurs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.formulaire input[type="color"] { height: 2.8rem; padding: .25rem; cursor: pointer; }
.aide { color: #b8c7bf; font-size: .88rem; margin: .35rem 0 0; }
button {
    margin-top: 1.3rem; padding: .65rem 1.4rem; font: inherit; font-weight: 800; cursor: pointer;
    background: linear-gradient(180deg, #f0a46c, var(--cuivre)); color: #2a1208;
    border: 3px solid var(--encre); border-radius: 8px; box-shadow: 0 4px 0 var(--encre);
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--encre); }
button.secondaire { background: #5b6b63; color: #e7efe9; }
.centre { text-align: center; }
.message { color: var(--lueur); text-align: center; font-weight: 700; }
.erreur { color: #ff9a8a; text-align: center; font-weight: 700; }
a { color: var(--lueur); font-weight: 700; }
.ciel { display: none; }

/* ============ Petits écrans ============ */
@media (max-width: 640px) {
    .podium { grid-template-columns: 1fr; max-width: 300px; margin: 0 auto; }
    .gemme-1, .gemme-2, .gemme-3 { grid-column: 1; grid-row: auto; }
    .ecriteaux { grid-template-columns: repeat(2, 1fr); }
    .classement th:nth-child(4), .classement td:nth-child(4) { display: none; }
    .bloc-pierre { grid-template-columns: 4.5rem 1fr 4.5rem; }
    .cristaux { opacity: .5; }
    .lanterne, .porte-ronde { display: none; }
}
@media (prefers-reduced-motion: reduce) { .voyants circle, .lanterne, .lucioles i { animation: none; } }
