/* ==========================================================================
   OsmoTools : jeux de mots ([osmova_pendu], [osmova_mots_meles])
   Pendu dessiné en SVG, mots mêlés en grille CSS avec traits SVG, aucune image externe.
   Même langage visuel que les jeux d'arcade (arcade.css).
   ========================================================================== */

.omt {
    --omt-noir: #0A0A0A;
    --omt-gris: #6B6B6B;
    --omt-gris-bg: #F6F7F9;
    --omt-border: #E5E7EB;
    --omt-blue: #0064FF;
    --omt-vert: #1D8A4E;
    --omt-rouge: #C8102E;
    --omt-tapis: #EEF1F6;
    --omt-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    position: relative;
    margin: 0 0 40px;
    padding: 24px 28px 28px;
    border: 1px solid var(--omt-border);
    border-radius: 16px;
    background: #fff;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--omt-noir);
}

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

.omt [hidden] {
    display: none !important;
}

.omt .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.omt :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--omt-blue) 55%, white);
    outline-offset: 2px;
}

/* ---------- En-tête ---------- */

.omt__tete {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    justify-content: space-between;
    align-items: flex-end;
    margin: 0 0 16px;
}

.omt__badge {
    display: inline-block;
    margin: 0 0 8px;
    padding: 4px 10px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--omt-blue) 9%, white);
    color: var(--omt-blue);
    font: 700 11px/1.4 var(--omt-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.omt .omt__titre {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.25;
}

.omt__compteurs {
    display: flex;
    gap: 6px;
    margin: 0;
}

.omt__compteurs > div {
    min-width: 84px;
    padding: 6px 12px;
    border: 1px solid var(--omt-border);
    border-radius: 10px;
    background: var(--omt-gris-bg);
}

.omt__compteurs dt {
    color: var(--omt-gris);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.omt__compteurs dd {
    margin: 0;
    font: 700 16px/1.3 var(--omt-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Boutons ---------- */

.omt__barre {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.omt__btn {
    display: inline-flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid var(--omt-border);
    border-radius: 10px;
    background: #fff;
    color: var(--omt-noir);
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
}

.omt__btn:hover {
    border-color: var(--omt-noir);
    background: var(--omt-gris-bg);
}

.omt__btn--main {
    border-color: var(--omt-blue);
    background: var(--omt-blue);
    color: #fff;
}

.omt__btn--main:hover {
    border-color: color-mix(in srgb, var(--omt-blue) 80%, black);
    background: color-mix(in srgb, var(--omt-blue) 80%, black);
    color: #fff;
}

.omt__btn[aria-pressed="true"],
.omt__btn[aria-expanded="true"] {
    border-color: var(--omt-blue);
    background: color-mix(in srgb, var(--omt-blue) 9%, white);
    color: var(--omt-blue);
}

.omt__ico {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.omt__lien {
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--omt-gris);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ---------- Réglages ---------- */

.omt__reglage {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}

.omt__reglage legend,
.omt__champ label {
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    color: var(--omt-gris);
    font-weight: 600;
    font-size: 13px;
}

.omt__reglage label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid var(--omt-border);
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.omt__reglage label:has(input:checked) {
    border-color: var(--omt-blue);
    background: color-mix(in srgb, var(--omt-blue) 7%, white);
}

.omt__reglage input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--omt-blue);
}

.omt__reglages {
    display: flex;
    flex-wrap: wrap;
    gap: 0 24px;
    align-items: flex-start;
}

.omt__champ {
    display: flex;
    flex-direction: column;
    margin: 0 0 16px;
}

.omt__champ select {
    min-width: 200px;
    min-height: 40px;
    padding: 6px 36px 6px 14px;
    border: 1px solid var(--omt-border);
    border-radius: 999px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A0A0A' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 14px center / 14px no-repeat;
    color: var(--omt-noir);
    font: 600 14px inherit;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.omt__hint {
    margin: 0 0 12px;
    color: var(--omt-gris);
    font-size: 13px;
    line-height: 1.5;
}

/* ---------- Zone de jeu ---------- */

.omt__zone {
    position: relative;
    padding: 22px;
    border-radius: 14px;
    background: var(--omt-tapis);
}

.omt__bandeau {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: center;
    align-items: center;
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    animation: omt-fondu .25s ease-out;
}

.omt.is-gagne .omt__bandeau {
    box-shadow: inset 0 0 0 2px #2F9E5B;
}

.omt.is-perdu .omt__bandeau {
    box-shadow: inset 0 0 0 2px var(--omt-rouge);
}

/* ---------- Pendu ---------- */

.omt__duo {
    margin: 0 0 16px;
    padding: 16px;
    border: 1px solid var(--omt-border);
    border-radius: 12px;
    animation: omt-fondu .2s ease-out;
}

.omt__d-lib {
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
    font-size: 14px;
}

.omt__d-ligne {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}

.omt__d-mot {
    flex: 1 1 220px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--omt-border);
    border-radius: 10px;
    color: var(--omt-noir);
    font: 600 16px var(--omt-mono);
    letter-spacing: .08em;
}

.omt__d-voir-l {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.omt__d-voir {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--omt-blue);
}

.omt .omt__d-err {
    margin: 0;
    color: var(--omt-rouge);
    font-weight: 600;
    font-size: 14px;
}

.omt__d-err:empty {
    display: none;
}

.omt__jeu {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    gap: 28px;
    align-items: center;
}

.omt__dessin {
    display: block;
    width: 100%;
    height: auto;
    padding: 10px;
    border-radius: 12px;
    background: #fff;
}

/* Les éléments à venir sont tracés en gris très clair : la forme du dessin se devine dès le départ. */
.omt__p {
    fill: none;
    stroke: #E3E7EE;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke .3s ease;
}

.omt__p.is-on {
    stroke: var(--omt-noir);
}

/* Seule la potence se devine en gris ; le personnage n'apparaît qu'avec les erreurs. */
.omt__p:not(.omt__p--bois):not(.is-on) {
    stroke: transparent;
}

.omt__p--bois.is-on {
    stroke: #8A6A4A;
}

.omt.is-tendu .omt__p.is-on:not(.omt__p--bois) {
    stroke: #B7791F;
}

.omt__droite {
    min-width: 0;
}

.omt .omt__etat {
    margin: 0 0 14px;
    color: var(--omt-gris);
    font-weight: 600;
    font-size: 13px;
}

.omt__mot {
    --nb: 6;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 16px;
}

.omt__l {
    display: flex;
    justify-content: center;
    align-items: center;
    width: clamp(26px, calc((100% - (var(--nb) - 1) * 6px) / var(--nb)), 46px);
    aspect-ratio: .82;
    border-radius: 8px;
    background: #fff;
    box-shadow: inset 0 -3px 0 var(--omt-noir);
    font: 800 clamp(16px, 2.6vw, 26px) / 1 var(--omt-mono);
    text-transform: uppercase;
}

.omt__l.is-vu {
    animation: omt-pop .25s ease-out;
}

.omt__l.is-manque {
    color: var(--omt-rouge);
    box-shadow: inset 0 -3px 0 var(--omt-rouge);
}

.omt.is-gagne .omt__l {
    box-shadow: inset 0 -3px 0 #2F9E5B;
}

.omt .omt__infos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 0 0 16px;
    color: var(--omt-gris);
    font-size: 14px;
}

.omt__infos strong {
    color: var(--omt-noir);
    font-family: var(--omt-mono);
    letter-spacing: .06em;
}

.omt__clavier {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 520px;
}

.omt__rangee {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 5px;
}

.omt__rangee:last-child {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    padding: 0;
}

.omt__rangee:last-child .omt__touche:first-child {
    grid-column-start: 3;
}

.omt__touche {
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid #D9DEE6;
    border-radius: 8px;
    background: linear-gradient(#fff, #F6F7F9);
    box-shadow: 0 1px 0 #CDD3DD;
    color: var(--omt-noir);
    font: 700 16px var(--omt-mono);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.omt__touche:hover:not(:disabled) {
    border-color: var(--omt-blue);
}

.omt__touche:disabled {
    cursor: default;
    box-shadow: none;
}

.omt__touche.is-bon {
    border-color: color-mix(in srgb, var(--omt-vert) 40%, white);
    background: color-mix(in srgb, var(--omt-vert) 12%, white);
    color: var(--omt-vert);
}

.omt__touche.is-faux {
    border-color: transparent;
    background: #E3E7EE;
    color: #A3A9B3;
    text-decoration: line-through;
}

.omt__touche:disabled:not(.is-bon):not(.is-faux) {
    opacity: .5;
}

/* ---------- Mots mêlés ---------- */

.omt--meles .omt__zone {
    padding: 18px;
}

.omt__plateau-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 24px;
    align-items: start;
}

.omt__plateau {
    position: relative;
    width: min(100%, calc(var(--n, 8) * 46px));
    margin: 0 auto;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(13, 13, 13, .06);
}

.omt__traits {
    position: absolute;
    inset: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    overflow: visible;
    pointer-events: none;
}

.omt__t,
.omt__t-sel,
.omt__t-sol {
    fill: none;
    stroke-width: .74;
    stroke-linecap: round;
}

.omt__t {
    stroke-opacity: .3;
    animation: omt-fondu .2s ease-out;
}

.omt__t-sel {
    stroke: var(--omt-blue);
    stroke-opacity: .16;
}

.omt__t-sol {
    stroke: var(--omt-rouge);
    stroke-opacity: .22;
}

.omt__grille {
    position: relative;
    container-type: inline-size;
    display: grid;
    grid-template-rows: repeat(var(--n, 8), 1fr);
    aspect-ratio: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.omt__rang {
    display: grid;
    grid-template-columns: repeat(var(--n, 8), 1fr);
}

.omt__c {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font: 700 calc(100cqi / var(--n, 8) * .6) / 1 var(--omt-mono);
    text-transform: uppercase;
}

.omt__c:focus-visible {
    outline-offset: -2px;
}

.omt__c.is-sel {
    color: var(--omt-blue);
}

.omt.is-rate .omt__grille {
    animation: omt-non .3s ease-in-out;
}

.omt__cote {
    min-width: 0;
}

.omt .omt__liste-t {
    margin: 0 0 10px;
    font-weight: 800;
    font-size: 15px;
    line-height: 1.3;
}

.omt .omt__vide {
    margin: 0;
    color: var(--omt-gris);
    font-size: 14px;
}

.omt .omt__liste {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.omt .omt__mot-l {
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fff;
    font: 700 13px/1.5 var(--omt-mono);
    letter-spacing: .04em;
}

.omt .omt__mot-l.is-trouve {
    background: color-mix(in srgb, var(--c, var(--omt-blue)) 14%, white);
    color: color-mix(in srgb, var(--c, var(--omt-blue)) 70%, black);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.omt__imp-t,
.omt__imp-pied {
    display: none;
}

/* ---------- Statistiques, aide, source ---------- */

.omt__options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 24px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--omt-border);
}

.omt__details {
    margin: 0 0 8px;
    padding: 10px 0;
}

.omt__details summary {
    width: fit-content;
    padding: 4px 0;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.omt__details[open] summary {
    margin-bottom: 10px;
}

.omt__table-wrap {
    overflow-x: auto;
}

.omt__stats {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 14px;
}

.omt__stats th,
.omt__stats td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--omt-border);
    text-align: left;
}

.omt__stats th {
    font-weight: 600;
}

.omt__stats td {
    font: 600 14px var(--omt-mono);
    text-align: right;
}

.omt__aide {
    margin: 0;
    padding-left: 18px;
    color: var(--omt-gris);
    font-size: 14px;
    line-height: 1.55;
}

.omt__aide li {
    margin: 0 0 6px;
}

.omt .omt__source {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    color: var(--omt-gris);
    font-size: 13px;
    line-height: 1.5;
}

.omt__source a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@keyframes omt-fondu {
    from {
        opacity: 0;
    }
}

@keyframes omt-pop {
    from {
        transform: translateY(4px);
        opacity: 0;
    }
}

@keyframes omt-non {
    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* ---------- Tablette et mobile ---------- */

@media (max-width: 860px) {
    .omt__plateau-wrap {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .omt {
        padding: 16px 10px 18px;
    }

    .omt__tete {
        padding: 0 4px;
    }

    .omt .omt__titre {
        font-size: 1.25rem;
    }

    .omt__compteurs {
        width: 100%;
    }

    .omt__compteurs > div {
        flex: 1 1 0;
        min-width: 0;
        padding: 5px 10px;
    }

    .omt__barre .omt__btn {
        flex: 1 1 0;
        flex-direction: column;
        gap: 3px;
        min-height: 52px;
        padding: 6px 2px;
        font-size: 12px;
        text-align: center;
    }

    .omt__reglage,
    .omt__reglages,
    .omt__duo {
        margin-left: 4px;
        margin-right: 4px;
    }

    .omt__reglage label {
        padding: 6px 12px;
        font-size: 13px;
    }

    .omt__champ select {
        width: 100%;
    }

    .omt__zone,
    .omt--meles .omt__zone {
        padding: 12px 8px;
        border-radius: 10px;
    }

    .omt__jeu {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .omt__dessin {
        width: 150px;
        margin: 0 auto;
        padding: 6px;
    }

    .omt__mot {
        justify-content: center;
    }

    .omt .omt__etat,
    .omt .omt__infos {
        justify-content: center;
        text-align: center;
    }

    .omt__clavier {
        gap: 5px;
        margin: 0 -2px;
    }

    .omt__rangee {
        gap: 4px;
    }

    .omt__touche {
        height: 46px;
        border-radius: 6px;
        font-size: 15px;
    }

    .omt__plateau {
        padding: 3px;
    }

    .omt__traits {
        inset: 3px;
        width: calc(100% - 6px);
        height: calc(100% - 6px);
    }

    .omt__options {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px 4px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .omt__bandeau,
    .omt__duo,
    .omt__l.is-vu,
    .omt__t,
    .omt.is-rate .omt__grille {
        animation: none;
    }

    .omt__p {
        transition: none;
    }
}

/* ---------- Impression (mots mêlés à imprimer) ---------- */

@media print {
    body * {
        visibility: hidden;
    }

    .omt--meles,
    .omt--meles * {
        visibility: visible;
    }

    .omt--meles {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .omt--meles .omt__tete,
    .omt--meles .omt__barre,
    .omt--meles .omt__reglages,
    .omt--meles .omt__bandeau,
    .omt--meles .omt__options,
    .omt--meles .omt__annonce,
    .omt--meles .omt__t-sel {
        display: none !important;
    }

    .omt--meles .omt__zone {
        padding: 0;
        background: none;
    }

    .omt--meles .omt__imp-t {
        display: block;
        margin: 0 0 6mm;
        font-weight: 800;
        font-size: 16pt;
    }

    .omt--meles .omt__imp-pied {
        display: block;
        margin: 6mm 0 0;
        color: #555;
        font-size: 9pt;
    }

    .omt--meles .omt__plateau-wrap {
        display: block;
    }

    .omt--meles .omt__plateau {
        width: 165mm;
        margin: 0 auto;
        padding: 0;
        box-shadow: none;
        outline: 1px solid #999;
    }

    .omt--meles .omt__traits {
        inset: 0;
        width: 100%;
        height: 100%;
    }

    .omt--meles .omt__c {
        color: #000;
    }

    .omt--meles .omt__cote {
        margin-top: 8mm;
        break-inside: avoid;
    }

    .omt--meles .omt__liste {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2mm 6mm;
    }

    .omt--meles .omt__mot-l {
        padding: 0;
        background: none;
        font-size: 11pt;
    }

    .omt--meles .omt__mot-l::before {
        content: '\25A1\00A0';
    }

    .omt--meles,
    .omt--meles * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
