/* ---------- Thème « tactique » : bleu nuit, rouge vif, blanc cassé ---------- */

:root {
    --fond: #0f1923;
    --fond-2: #131f2b;
    --carte: #1c2733;
    --carte-survol: #263443;
    --trait: #3a4753;
    --rouge: #ff4655;
    --rouge-clair: #ff6673;
    --clair: #ece8e1;
    --discret: #8b97a3;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    margin: 0;
    padding: 1rem;
    color: var(--clair);
    background-color: var(--fond);
    /* bandes diagonales discrètes en fond */
    background-image: linear-gradient(
        115deg,
        transparent 0 55%,
        var(--fond-2) 55% 63%,
        transparent 63% 100%
    );
    background-attachment: fixed;
}

h2 {
    text-align: center;
    margin: 0 0 1.2rem;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .18em;
}

/* petit filet rouge sous les titres */
h2::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    margin: .5rem auto 0;
    background: var(--rouge);
    clip-path: polygon(0 0, 100% 0, 86% 100%, 0 100%);
}

/* ---------- Mise en page : 3 colonnes ---------- */

.page {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(0, 3fr) minmax(110px, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.colonne-centre {
    max-width: 720px;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
}

/* ---------- Bouton (coins coupés) ---------- */

button {
    display: block;
    margin: 1.6rem auto 0;
    padding: .85rem 2rem;
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--fond);
    background: var(--rouge);
    border: 0;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    transition: background .15s;
}

button:hover {
    background: var(--rouge-clair);
}

/* ---------- Messages d'erreur (masqués quand ils sont vides) ---------- */

.erreur {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    margin-bottom: .8rem;
    padding: .7rem .8rem .7rem 1rem;
    background: #2a1a22;
    color: #ff8a94;
    border-left: 3px solid var(--rouge);
}

/* petite croix pour fermer l'alerte */
.fermer {
    flex: none;
    margin: 0;
    padding: .15rem .45rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    color: var(--clair);
    background: transparent;
    clip-path: none;
}

.fermer:hover {
    background: rgba(255, 255, 255, .12);
    color: var(--rouge-clair);
}

/* ---------- Gauche : mini-grilles des autres participants ---------- */

.joueurs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    color: var(--discret);
    text-align: center;
    font-size: .9rem;
}

.joueur {
    width: 100%;
    max-width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
}

.mini {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    width: 100%;
    padding: 5px;
    background: var(--fond-2);
    border: 2px solid var(--trait);
}

.mini span {
    aspect-ratio: 1;
    background: var(--carte);
    border: 1px solid var(--trait);
}

.mini span.on {
    background: var(--rouge);
    border-color: var(--rouge);
}

.joueur small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--clair);
    font-weight: 600;
    letter-spacing: .04em;
}

/* ---------- Milieu : ma grille (cases aux coins coupés) ---------- */

.grille {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 6px;
    aspect-ratio: 1;
    margin: 0 auto;
    /* largeur = min(place disponible, hauteur de la fenêtre moins titre et bouton) */
    width: min(100%, max(220px, calc(100vh - 11rem)));
    width: min(100%, max(220px, calc(100dvh - 11rem)));
    /* permet aux cases d'adapter texte et coins à la taille de la grille */
    container-type: inline-size;
}

.case {
    --fill: var(--carte);
    --c: clamp(8px, 2.6cqw, 14px);      /* coin coupé */
    --ci: calc(var(--c) * 1.2);         /* coin coupé du fond */
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4cqw;
    text-align: center;
    font-size: clamp(.5rem, 2.8cqw, .95rem);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-weight: 600;
    color: var(--clair);
    background: var(--trait);            /* sert de bordure */
    cursor: default;
    user-select: none;
    clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
}

/* fond de la case, légèrement rentré pour laisser voir la bordure */
.case::before {
    content: "";
    position: absolute;
    inset: 2px;
    z-index: -1;
    background: var(--fill);
    clip-path: polygon(0 0, calc(100% - var(--ci)) 0, 100% var(--ci), 100% 100%, var(--ci) 100%, 0 calc(100% - var(--ci)));
}

.case.cochee {
    --fill: var(--rouge);
    background: var(--rouge);
    color: var(--fond);
}

/* ---------- Droite : toutes les phrases (un clic lance un vote) ---------- */

.phrases {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: calc(100vh - 9rem);
    overflow-y: auto;
    scrollbar-width: none;          /* Firefox */
}

.phrases::-webkit-scrollbar {
    display: none;                  /* Chrome, Edge, Discord */
}

.phrase {
    padding: .55rem .7rem;
    font-size: .85rem;
    line-height: 1.3;
    background: var(--carte);
    border-left: 3px solid var(--trait);
    cursor: pointer;
    user-select: none;
}

.phrase:hover {
    background: var(--carte-survol);
    border-left-color: var(--rouge);
}

.phrase.vote-en-cours {
    background: #2a1a22;
    border-left-color: var(--rouge);
}

/* phrase validée : grisée, plus cliquable */
.phrase.validee {
    opacity: .35;
    text-decoration: line-through;
    cursor: default;
    background: var(--carte);
    border-left-color: var(--trait);
}

/* ---------- Fenêtre de vote et annonces ---------- */

[hidden] {
    display: none !important;
}

.vote,
.annonce {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 520px);
    z-index: 10;
    padding: 1rem 1.2rem;
    text-align: center;
    background: var(--carte);
    border-left: 4px solid var(--rouge);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .55);
}

.vote {
    bottom: 1rem;
}

.annonce {
    top: 1rem;
    font-weight: 700;
}

.annonce.ok {
    border-left-color: #2ecc71;
}

.vote p {
    margin: 0 0 .5rem;
}

.vote-titre {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--discret);
}

.vote-texte {
    font-size: 1.1rem;
    font-weight: 700;
}

.vote-compteur {
    font-size: .85rem;
    color: var(--discret);
}

.vote-boutons {
    display: flex;
    gap: .8rem;
    justify-content: center;
    margin-top: .6rem;
}

.vote-boutons button {
    margin: 0;
}

button.secondaire {
    background: var(--trait);
    color: var(--clair);
}

button.secondaire:hover {
    background: #4b5966;
}

button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

button:disabled:hover {
    background: var(--rouge);
}

/* ---------- Fenêtre de victoire ---------- */

.victoire {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 25, 35, .88);
}

.victoire-carte {
    width: min(92vw, 520px);
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--carte);
    border-top: 4px solid var(--rouge);
    clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
    animation: apparition .35s ease-out;
}

.victoire-carte p {
    margin: 0;
}

.victoire-icone {
    font-size: 3rem;
}

.victoire-titre {
    margin-top: .5rem !important;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
}

.victoire-sous-titre {
    margin-top: .5rem !important;
    color: var(--discret);
}

.victoire-compte {
    margin-top: 1.4rem !important;
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--rouge);
}

@keyframes apparition {
    from {
        opacity: 0;
        transform: scale(.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ---------- Gauche : bouton « Nouvelle partie » tout en bas ---------- */

.colonne-gauche {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    min-height: calc(100vh - 2rem);
}

.colonne-gauche > button {
    align-self: center;
    margin: auto 0 0;
    padding: .7rem 1.2rem;
    font-size: .85rem;
}

/* ---------- Droite : barre de recherche ---------- */

.recherche {
    width: 100%;
    margin-bottom: .6rem;
    padding: .6rem .7rem;
    font: inherit;
    font-size: .85rem;
    color: var(--clair);
    color-scheme: dark;
    background: var(--carte);
    border: 0;
    border-left: 3px solid var(--trait);
    outline: none;
}

.recherche:focus {
    border-left-color: var(--rouge);
}

.recherche::placeholder {
    color: var(--discret);
}

.vide {
    margin: .8rem 0 0;
    font-size: .85rem;
    text-align: center;
    color: var(--discret);
}

/* ---------- Petit écran : les colonnes s'empilent ---------- */

@media (max-width: 800px) {
    .page {
        grid-template-columns: 1fr;
    }

    .colonne-centre {
        order: 1;
    }

    .colonne-droite {
        order: 2;
    }

    .colonne-gauche {
        order: 3;
        min-height: 0;
    }

    .colonne-gauche > button {
        margin-top: 1.2rem;
    }

    .phrases {
        max-height: 40vh;
    }

    .joueurs {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .joueur {
        width: 110px;
    }

    .grille {
        gap: 5px;
    }

}