/* ===== Le Grimoire Musical — thème sorcier ===== */
:root {
    --nuit: #14102a;
    --nuit-2: #1e1740;
    --parchemin: #f3e6c8;
    --or: #d9a944;
    --or-clair: #f0cf7e;
    --rouge: #7f1d2c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Cormorant Garamond", Georgia, serif;
    background: radial-gradient(ellipse at top, var(--nuit-2), var(--nuit) 65%);
    color: var(--parchemin);
    min-height: 100vh;
    font-size: 1.1rem;
}

/* Ciel étoilé */
.etoiles {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 12% 20%, #fff8, transparent),
        radial-gradient(1px 1px at 30% 65%, #fff6, transparent),
        radial-gradient(2px 2px at 48% 12%, #ffd97066, transparent),
        radial-gradient(1px 1px at 62% 42%, #fff7, transparent),
        radial-gradient(1.5px 1.5px at 76% 18%, #fff5, transparent),
        radial-gradient(1px 1px at 88% 58%, #ffd97055, transparent),
        radial-gradient(1.5px 1.5px at 20% 85%, #fff5, transparent),
        radial-gradient(1px 1px at 70% 88%, #fff6, transparent);
    animation: scintiller 4s ease-in-out infinite alternate;
}
@keyframes scintiller { from { opacity: .5; } to { opacity: 1; } }

header, main, footer { position: relative; z-index: 1; }

/* ===== En-tête ===== */
.entete { text-align: center; padding: 3rem 1rem 1.5rem; }

.eclair { width: 54px; margin: 0 auto .5rem; color: var(--or); filter: drop-shadow(0 0 10px #d9a94488); }
.eclair svg { width: 100%; }

h1 {
    font-family: "Cinzel", serif;
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 3.4rem);
    letter-spacing: .06em;
    background: linear-gradient(180deg, var(--or-clair), var(--or) 60%, #a67c2e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 30px #d9a94433;
}

.soustitre { font-style: italic; font-size: 1.35rem; margin-top: .4rem; color: #e8d9b8; }

.regle {
    max-width: 620px; margin: 1rem auto 0; color: #cfc0a0;
    border-top: 1px solid #d9a94444; border-bottom: 1px solid #d9a94444;
    padding: .7rem 1rem;
}

.menu { margin-top: 1.4rem; display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.menu a {
    font-family: "Cinzel", serif; font-size: .85rem; letter-spacing: .1em;
    color: var(--or-clair); text-decoration: none;
    border: 1px solid #d9a94466; border-radius: 999px;
    padding: .5rem 1.2rem; transition: all .2s;
}
.menu a:hover, .menu a.actif { background: #d9a94422; border-color: var(--or); }
.menu-haut { margin: 0 0 1.5rem; }

/* ===== Bibliothèque (accueil) ===== */
.biblio {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.6rem;
    padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem;
    max-width: 1200px; margin: 0 auto;
}

.livre {
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
    text-decoration: none; color: var(--parchemin);
    background: linear-gradient(160deg, #241b48, #1a1435);
    border: 1px solid #d9a94433; border-radius: 14px;
    padding: 1.2rem 1rem 1.3rem;
    box-shadow: 0 8px 24px #00000055;
    transition: transform .2s, border-color .2s, box-shadow .2s;
    text-align: center;
}
.livre:hover { transform: translateY(-5px); border-color: #d9a94499; box-shadow: 0 14px 32px #00000077; }

.couverture { width: 130px; margin-bottom: .6rem; }
.couverture img {
    width: 100%; display: block; border-radius: 4px;
    box-shadow: 4px 6px 16px #00000088, 0 0 0 1px #d9a94433;
    transform: rotate(-1.5deg);
    transition: transform .2s;
}
.livre:hover .couverture img { transform: rotate(0deg) scale(1.03); }

.couverture-vide {
    width: 100%; aspect-ratio: 2 / 3; border-radius: 4px;
    background: linear-gradient(160deg, var(--rouge), #4a1019);
    border: 1px solid #d9a94455;
    display: flex; align-items: center; justify-content: center;
    font-family: "Cinzel", serif; color: var(--or-clair); font-size: 1.3rem;
}

.livre-tome { font-family: "Cinzel", serif; font-size: .75rem; letter-spacing: .15em; text-transform: uppercase; color: #b9a67e; }
.livre-titre { font-family: "Cinzel", serif; font-weight: 700; font-size: .95rem; line-height: 1.35; min-height: 2.6em; }
.livre-stats { font-style: italic; font-size: .95rem; color: #cbbb97; }

/* ===== Page d'un livre ===== */
.entete-livre { text-align: left; max-width: 860px; margin: 0 auto; }

.fiche-livre { display: flex; gap: 1.8rem; align-items: center; }
.fiche-couverture {
    width: 150px; border-radius: 4px; flex-shrink: 0;
    box-shadow: 6px 8px 20px #00000088, 0 0 0 1px #d9a94433;
    transform: rotate(-2deg);
}
.titre-livre {
    font-size: clamp(1.5rem, 4vw, 2.3rem);
    text-align: left;
}
.entete-livre .regle { margin-left: 0; text-align: left; }
.entete-livre .livre-tome { display: block; margin-bottom: .2rem; }

@media (max-width: 560px) {
    .fiche-livre { flex-direction: column; text-align: center; }
    .titre-livre, .entete-livre .regle { text-align: center; }
}

/* ===== Pistes (musiques mystères) ===== */
.pistes { max-width: 860px; margin: 1.5rem auto 3rem; padding: 0 1rem; display: flex; flex-direction: column; gap: .9rem; }

.piste {
    display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
    background: linear-gradient(160deg, #241b48, #1a1435);
    border: 1px solid #d9a94433; border-radius: 14px;
    padding: 1rem 1.3rem;
    transition: border-color .2s, box-shadow .2s;
}
.piste:hover { border-color: #d9a94477; }
.piste.votee { border-color: var(--or); box-shadow: 0 0 22px #d9a94433; }

.piste-code { display: flex; align-items: center; gap: .5rem; min-width: 150px; }
.rune { color: var(--or); font-size: 1.1rem; }
.piste-code strong { font-family: "Cinzel", serif; font-weight: 700; font-size: 1rem; letter-spacing: .04em; }

.piste audio { flex: 1; min-width: 220px; height: 38px; }

.piste-vote { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.voix {
    font-family: "Cinzel", serif; font-size: .8rem; color: var(--or-clair);
    background: #d9a9441c; border: 1px solid #d9a94444; border-radius: 999px;
    padding: .15rem .6rem; white-space: nowrap;
}

.bouton-vote {
    cursor: pointer;
    font-family: "Cinzel", serif; font-size: .85rem; letter-spacing: .06em;
    color: var(--nuit);
    background: linear-gradient(180deg, var(--or-clair), var(--or));
    border: none; border-radius: 999px; padding: .55rem 1.2rem;
    transition: filter .15s, transform .1s;
}
.bouton-vote:hover { filter: brightness(1.1); }
.bouton-vote:active { transform: scale(.96); }
.piste.votee .bouton-vote { background: none; color: var(--or-clair); border: 1px solid var(--or); }

/* ===== Devinettes : propositions de titre ===== */
.devinettes {
    width: 100%;
    border-top: 1px dashed #d9a94433;
    margin-top: .4rem;
    padding-top: .6rem;
}
.devinettes summary {
    cursor: pointer;
    font-family: "Cinzel", serif;
    font-size: .82rem;
    letter-spacing: .05em;
    color: #cbbb97;
    list-style-position: inside;
    transition: color .15s;
}
.devinettes summary:hover { color: var(--or-clair); }

.prop-ligne {
    display: flex; align-items: center; gap: .8rem;
    padding: .45rem .2rem;
    border-bottom: 1px solid #ffffff0d;
}
.prop-ligne.mon-choix .prop-nom { color: var(--or-clair); }
.prop-nom { flex: 1; font-size: 1.05rem; font-style: italic; min-width: 0; overflow-wrap: anywhere; }

.bouton-mini {
    cursor: pointer;
    font-family: "Cinzel", serif; font-size: .72rem; letter-spacing: .05em;
    color: var(--or-clair); background: #d9a94415;
    border: 1px solid #d9a94455; border-radius: 999px;
    padding: .35rem .8rem; white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.bouton-mini:hover { background: #d9a94430; border-color: var(--or); }
.mon-choix .bouton-mini { background: linear-gradient(180deg, var(--or-clair), var(--or)); color: var(--nuit); border-color: var(--or); }

.form-prop { display: flex; gap: .6rem; margin-top: .7rem; flex-wrap: wrap; }
.form-prop input[type="text"] {
    flex: 1; min-width: 200px;
    font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.05rem;
    color: var(--parchemin); background: #ffffff0d;
    border: 1px solid #d9a94444; border-radius: 999px;
    padding: .5rem 1.1rem; outline: none;
    transition: border-color .15s;
}
.form-prop input[type="text"]::placeholder { color: #a89877; font-style: italic; }
.form-prop input[type="text"]:focus { border-color: var(--or); }

.badge-ok {
    font-family: "Cinzel", serif; font-style: normal; font-size: .7rem;
    color: #9fdca4; background: #2e5b3355; border: 1px solid #4c8a52;
    border-radius: 999px; padding: .15rem .6rem; margin-left: .4rem;
    white-space: nowrap; vertical-align: middle;
}

/* ===== Admin ===== */
.connexion { max-width: 420px; margin: 2rem auto; padding: 0 1rem; text-align: center; }
.form-connexion { justify-content: center; }
.erreur { color: #e08b8b; font-style: italic; margin-bottom: 1rem; }

.admin { max-width: 860px; margin: 1.5rem auto 3rem; padding: 0 1rem; display: flex; flex-direction: column; gap: .9rem; }
.admin-livre {
    font-family: "Cinzel", serif; font-size: 1.1rem; color: var(--or-clair);
    margin: 1.4rem 0 .2rem; border-bottom: 1px solid #d9a94444; padding-bottom: .4rem;
}
.admin-piste { flex-direction: column; align-items: stretch; gap: .6rem; }
.admin-entete-piste { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.admin-entete-piste strong { font-family: "Cinzel", serif; }
.vrai-nom {
    font-size: .8rem; color: #b9a67e; background: #00000033;
    border-radius: 6px; padding: .15rem .5rem;
    overflow-wrap: anywhere;
}
.admin-vide { font-style: italic; color: #8d7f63; font-size: .95rem; }
.bouton-danger { border-color: #a1454577; color: #e08b8b; background: #7f1d2c22; }
.bouton-danger:hover { background: #7f1d2c55; border-color: #a14545; }

.stats-cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.stat-carte {
    background: linear-gradient(160deg, #241b48, #1a1435);
    border: 1px solid #d9a94433; border-radius: 12px;
    padding: .9rem 1rem; text-align: center;
    font-style: italic; color: #cbbb97; font-size: .95rem;
}
.stat-chiffre {
    display: block; font-family: "Cinzel", serif; font-style: normal;
    font-size: 1.9rem; font-weight: 700; color: var(--or-clair);
}
.stats-table { width: 100%; border-collapse: collapse; margin-top: .9rem; }
.stats-table th, .stats-table td {
    text-align: left; padding: .45rem .8rem;
    border-bottom: 1px solid #ffffff0d;
}
.stats-table th { font-family: "Cinzel", serif; font-size: .8rem; letter-spacing: .08em; color: #b9a67e; }

.vide { text-align: center; font-style: italic; color: #cbbb97; padding: 2rem 0; }
.vide code { color: var(--or-clair); }

/* ===== Classement ===== */
.classement { max-width: 760px; margin: 1rem auto 3rem; padding: 0 1rem; display: flex; flex-direction: column; gap: .7rem; }

.ligne {
    display: flex; align-items: center; gap: 1rem;
    background: linear-gradient(160deg, #241b48, #1a1435);
    border: 1px solid #d9a94433; border-radius: 12px;
    padding: .7rem 1.1rem;
}
.ligne.podium { border-color: #d9a94499; box-shadow: 0 0 18px #d9a94422; }

.rang { font-family: "Cinzel", serif; font-size: 1.3rem; width: 2.2rem; text-align: center; color: var(--or-clair); flex-shrink: 0; }

.ligne-infos { flex: 1; min-width: 0; }
.ligne-infos strong { font-family: "Cinzel", serif; font-weight: 600; font-size: .92rem; display: block; margin-bottom: .35rem; }
.ligne-infos a { color: var(--parchemin); text-decoration: none; }
.ligne-infos a:hover { color: var(--or-clair); }

.jauge { height: 8px; background: #ffffff14; border-radius: 999px; overflow: hidden; }
.jauge-remplie { height: 100%; background: linear-gradient(90deg, var(--rouge), var(--or)); border-radius: 999px; transition: width .4s; }

.score { font-family: "Cinzel", serif; font-size: .85rem; color: var(--or-clair); white-space: nowrap; }

/* ===== Salon commun (chat) ===== */
.salon { max-width: 860px; margin: 2.5rem auto 3rem; padding: 0 1rem; }
.salon-titre {
    font-family: "Cinzel", serif; font-size: 1.4rem; color: var(--or-clair);
    border-bottom: 1px solid #d9a94444; padding-bottom: .4rem;
}
.salon-sous-titre { font-style: italic; color: #cbbb97; margin: .4rem 0 .9rem; }

#chat-messages {
    background: linear-gradient(160deg, #241b48, #1a1435);
    border: 1px solid #d9a94433; border-radius: 14px;
    max-height: 340px; min-height: 120px; overflow-y: auto;
    padding: .9rem 1.1rem;
    display: flex; flex-direction: column; gap: .45rem;
    scroll-behavior: smooth;
}
.chat-ligne { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.chat-heure { font-size: .78rem; color: #8d7f63; font-family: "Cinzel", serif; white-space: nowrap; }
.chat-nom { color: var(--or-clair); font-family: "Cinzel", serif; font-size: .88rem; }
.chat-texte { overflow-wrap: anywhere; }

#chat-form { display: flex; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; }
#chat-form input {
    font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.05rem;
    color: var(--parchemin); background: #ffffff0d;
    border: 1px solid #d9a94444; border-radius: 999px;
    padding: .55rem 1.1rem; outline: none;
    transition: border-color .15s;
}
#chat-form input::placeholder { color: #a89877; font-style: italic; }
#chat-form input:focus { border-color: var(--or); }
#chat-form input[name="nom"] { flex: 0 1 190px; }
#chat-form input[name="message"] { flex: 1 1 260px; }

/* ===== Pied de page ===== */
.pied { text-align: center; padding: 1.5rem 1rem 2.5rem; color: #a89877; font-style: italic; }
.pied .mention { font-size: .85rem; margin-top: .4rem; opacity: .7; }
.retour { color: var(--or-clair); }

@media (max-width: 480px) {
    .ligne, .piste { flex-wrap: wrap; }
    .piste-vote { margin-left: 0; width: 100%; justify-content: space-between; }
}
