/* ─── Reset & base ─────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px 16px 0px 24px;
    font-family: "Inter", "Roboto", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 400;
    background: rgba(255, 255, 255, 0.1);
    color: #2C2C2A;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
}

/* ─── Header ───────────────────────────────────────────────────────── */

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.header h1 {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.3px;
    margin: 0;
    color: #2C2C2A;
}

.header p {
    font-size: 13px;
    color: #888780;
    margin: 0;
}

/* ─── Footer ────────────────────────────────────────────── */

#metriques {
    display: flex;
    flex-direction: row;
    gap: 50px;
    font-size: 13px;
    color: #888780;
    align-items: center;
    margin-bottom: 10px;
}

#score, #erreurs {
    display: flex;
    align-items: center;
    gap: 8px;
}

#abandon:hover, #info:hover, #partage:hover {
    cursor: pointer;
}


/* ─── Grille principale ─────────────────────────────────────────────── */

.main {
    display: grid;
    grid-template-columns: clamp(60px, 18vw, 90px) repeat(3, minmax(0, 1fr));
    grid-template-rows: auto repeat(3, 1fr);
    gap: clamp(5px, 1.5vw, 10px);
    width: 100%;
    max-width: 600px;
}

/* ─── Cellule générique ─────────────────────────────────────────────── */

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 10px;
    line-height: 1.4;
    font-size: clamp(10px, 1.8vw, 14px);
}

/* Coin haut-gauche vide */
.cell.corner {
    background: transparent;
}

/* Critères horizontaux (ligne du haut) */
.cell.crit-h {
    font-weight: 500;
    padding: 8px;
    align-items: center;
    justify-content: end;
    flex-direction: column;
    aspect-ratio: unset;
}

/* Critères verticaux (colonne de gauche) */
.cell.crit-v {
    font-weight: 500;
    padding: 8px;
    aspect-ratio: unset;
    flex-direction: column;
}

.cat {
    display: flex;
    gap: 4px;
}

.cat img {
    display: inline-block;
    height: 1em;
    margin-bottom: 0.2em;
}

.cat div {
    display: flex;
    flex-direction: row;
    gap: 4px;
}

/* ─── Cellule réponse ───────────────────────────────────────────────── */

.cell.ans {
    aspect-ratio: 1;
    background: #ffffff;
    border: 0.5px solid #D3D1C7;
    flex-direction: column;
    cursor: text;
    overflow: hidden;
    transition: border-color 0.15s;
}

.cell.ans:focus-within {
    border-color: #888780;
    box-shadow: 0 0 0 3px rgba(136, 135, 128, 0.12);
}

.cell.ans textarea {
    flex: 1;
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: inherit;
    font-family: inherit;
    color: #2C2C2A;
    outline: none;
    resize: none;
    overflow: hidden;
    padding: 8px 6px 0;
    display: grid;
    place-content: center;
    line-height: 1.4;
}

.cell.ans textarea::placeholder {
    color: #B4B2A9;
}

.cell.ans textarea:disabled {
    color: #B4B2A9;
    cursor: not-allowed;
}

.cell.ans button {
    width: 100%;
    padding: 5px 0;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-top: 0.5px solid #D3D1C7;
    background: transparent;
    color: #888780;
    transition: background 0.1s, color 0.1s;
    border-radius: 0 0 10px 10px;
}

.cell.ans button:hover {
    background: #ebebeb;
    color: #2C2C2A;
}

.cell.ans button:disabled {
    cursor: not-allowed;
    color: #ffb2b2;
}

.rarete {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: clamp(10px, 1.6vw, 14px);
    margin-top: 2px;
    font-weight: 500;
}

.rarete-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}



/* ─── Réponse non acceptée ───────────────────────────────────────────────── */

@keyframes secousse {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-6px); }
    40%  { transform: translateX(6px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

.input-invalide {
    animation: secousse 0.4s ease;
    color: #E24B4A;
}

/* ─── Cellule validée ───────────────────────────────────────────────── */

.cell.ans .station {
    font-size: clamp(10px, 1.6vw, 14px);
    font-weight: 500;
    color: #2C2C2A;
    padding: 4px 4px 0 4px;
    line-height: 1.3;
}

.cell.ans .connexions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.connexions img {
    width: clamp(16px, 4vw, 30px);
    height: clamp(16px, 4vw, 30px);
}

.cell.ans .score {
    font-size: clamp(10px, 1.6vw, 14px);
    font-weight: 500;
}

@keyframes flash-valide {
    0%   { background: transparent; }
    40%  { background: #E1F5EE; }
    100% { background: transparent; }
}

.cell.ans textarea.reponse-valide {
    animation: flash-valide 0.6s ease forwards;
}

/* ─── Cellule refusée ──────────────────────────────────────────── */

@keyframes flash-invalide {
    0%   { background: transparent; }
    40%  { background: #FCEBEB; }
    100% { background: transparent; }
}

.cell.ans textarea.reponse-invalide {
    animation: flash-invalide 0.6s ease forwards;
}

/* ─── Liste de suggestions ──────────────────────────────────────────── */

#suggestions {
    position: fixed;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: #ffffff;
    border: 0.5px solid #D3D1C7;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    z-index: 200;
    display: none;
    min-width: 180px;
    overflow: hidden;
}

#suggestions li {
    padding: 4px 12px;
    cursor: pointer;
    font-size: 11px;
    color: #2C2C2A;
    transition: background 0.1s;
}

#suggestions li:hover,
#suggestions li.active {
    background: #e8e8e8;
}

/* ─── Modaux ───────────────────────────────────────── */

.modal-fin {
    background: #ffffff;
    border: 0.5px solid #D3D1C7;
    border-radius: 14px;
    padding: 2rem 2.5rem;
    text-align: center;
    max-width: 340px;
    width: 100%;
}

.modal-fin-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.modal-fin-erreurs {
    font-size: 1.4rem;
    color: #E24B4A;
    letter-spacing: 8px;
    margin-bottom: 1rem;
}

.modal-fin-title {
    font-size: 1.3rem;
    font-weight: 500;
    color: #2C2C2A;
    margin: 0 0 1rem;
}

.modal-fin-sub {
    font-size: 0.85rem;
    color: #888780;
    margin: 0 0 1.5rem;
    line-height: 1.6;
}

.modal-fin-btn {
    padding: 8px 24px;
    border: 0.5px solid #D3D1C7;
    border-radius: 8px;
    background: transparent;
    color: #2C2C2A;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
}

.modal-fin-btn:hover {
    background: rgb(212, 212, 212);
}

.modal-fin a {
    text-decoration: underline;
    color: #2C2C2A;
}

.modal-fin a:hover {
    cursor: pointer;
    color: #3d3d3a;
}

/* ─── Cases non résolues après défaite/abandon ──────────────────────── */

.cell.ans.non-resolue {
    background: #ededed;
    border-color: #D3D1C7;
    cursor: pointer !important;
    transition: background 0.15s;
}

.cell.ans.non-resolue:hover {
    background: rgb(223, 223, 223);
}

.case-non-resolue {
    font-size: 20px;
    font-weight: 500;
    color: #B4B2A9;
}

/* ─── Liste de solutions dans le modal ──────────────────────────────── */

.btn-autres-reponses {
    width: 70% !important;
    border: none;
    border-top: 0.5px solid #D3D1C7;
    background: transparent;
    color: #888780;
    font-family: inherit;
    font-size: 10px;
    margin-top: 20px !important;
    cursor: pointer;
    border-radius: 0 0 10px 10px;
    transition: background 0.1s, color 0.1s;
}

.btn-autres-reponses:hover {
    background: #F1EFE8;
    color: #2C2C2A;
}

.solutions-liste {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.solutions-liste li {
    font-size: 0.8rem;
    color: #2C2C2A;
    padding: 6px 12px;
    background: #f1f1f1;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.solution-score {
    font-size: 0.7rem;
    color: #888780;
    white-space: nowrap;
    margin-left: 8px;
}

/* ─── Tooltips aide ─────────────────────────────────────────────── */

.crit-avec-aide {
    text-decoration: underline dotted currentColor;
    text-underline-offset: 3px;
    cursor: help;
    position: relative;
}

.crit-avec-aide .tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #2C2C2A;
    color: #f8f7f4;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 220px;
    white-space: normal;
    z-index: 50;
    pointer-events: none;
}

/* Petite flèche pointant vers le critère */
.crit-avec-aide .tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2C2C2A;
}

.crit-avec-aide:hover .tooltip {
    display: block;
}

/* ─── Responsive mobile ─────────────────────────────────────────────── */

@media (max-width: 480px) {
    body {
        padding: 16px 10px;
        gap: 14px;
    }

    .main {
        gap: 5px;
    }

    .cell {
        border-radius: 7px;
    }

    .cell.ans button {
        border-radius: 0 0 7px 7px;
    }

    .modal-fin {
        padding: 1.5rem 1.5rem;
    }

    #metriques {
        gap: 25px;
    }

    .btn-autres-reponses {  
        margin-top: 10px !important;
        font-size: 8px !important;
        width: 80% !important;
    }

    #suggestions {
        min-width: 100px;
    }
}