/* ------------------------------------------------ */
/* THÈME */
/* ------------------------------------------------ */

:root {
    /* Scrollbars et contrôles natifs sombres */
    color-scheme: dark;

    /* Fond et surfaces */
    --bg: #121418;
    --surface: #1b1e24;
    --surface-raised: #23272f;
    --border: rgba(255, 255, 255, .07);

    /* Texte */
    --text: #eceef2;
    --text-muted: #9aa1ad;

    /* Médias, par propriétaire */
    --media-red: #d15942;
    --media-blue: #2e7bbf;
    --media-purple: #8c459e;
    --media-yellow: #e3b529;
    --media-green: #4a9636;

    /* Médias indépendants, nuance selon leur effet */
    --indep-cross: #4a9636;
    --indep-square: #2f7a45;
    --indep-dismantle: #6b8e23;

    /* Propriétaires */
    --owner-bg: #0c0d10;

    /* Indice de pluralisme */
    --tier-0: #7cc062;
    --tier-1: #b9c062;
    --tier-2: #dc9a52;
    --tier-3: #d4675a;

    --radius: 14px;
    --radius-small: 10px;
    --shadow: 0 24px 48px rgba(0, 0, 0, .45);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Couleur par groupe */
.tile-red    { --tile: var(--media-red); }
.tile-blue   { --tile: var(--media-blue); }
.tile-purple { --tile: var(--media-purple); }
.tile-yellow { --tile: var(--media-yellow); --tile-ink: #2b2212; }
.tile-green  { --tile: var(--media-green); }

.indep-cross     { --tile: var(--indep-cross); }
.indep-square    { --tile: var(--indep-square); }
.indep-dismantle { --tile: var(--indep-dismantle); }

/* ------------------------------------------------ */
/* RESET */
/* ------------------------------------------------ */

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

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
}

/* ------------------------------------------------ */
/* PAGE */
/* ------------------------------------------------ */

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

/* ------------------------------------------------ */
/* EN-TÊTE */
/* ------------------------------------------------ */

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 24px;
    padding: 20px 16px 0;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.scoreboard {
    display: flex;
    gap: 8px;
}

.scoreboard-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 96px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.scoreboard-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.scoreboard-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Pied de page */
.footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 0;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-links {
    display: contents;
}

.footer > p + .footer-links a:first-child::before,
.footer-links a + a::before {
    content: "·";
    display: inline-block;
    padding: 0 10px;
    color: var(--text-muted);
}

/* Mobile : date sur sa propre ligne */
@media (max-width: 599px) {

    .footer > p {
        flex-basis: 100%;
        text-align: center;
    }

    .footer > p + .footer-links a:first-child::before {
        content: none;
    }
}

.footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer a:hover,
.footer a[aria-current="page"] {
    color: var(--text);
}

.footer a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ------------------------------------------------ */
/* CONTENU */
/* ------------------------------------------------ */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

/* ------------------------------------------------ */
/* BLOC DE GAUCHE */
/* ------------------------------------------------ */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.sidebar-section + .sidebar-section {
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.sidebar-section h2 {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-note {
    font-size: 13px;
    color: var(--text-muted);
}

.pluralism {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.pluralism[data-tier="0"] { color: var(--tier-0); }
.pluralism[data-tier="1"] { color: var(--tier-1); }
.pluralism[data-tier="2"] { color: var(--tier-2); }
.pluralism[data-tier="3"] { color: var(--tier-3); }

.series {
    font-size: 13px;
    color: var(--text-muted);
}

.series.is-active {
    color: var(--tier-0);
    font-weight: 600;
}

.independents {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Icône d'effet */
.independents li {
    display: grid;
    grid-template-columns: 24px 1fr;
    column-gap: 10px;
    font-size: 13px;
    line-height: 1.35;
}

.independents .independent-icon {
    grid-row: 1 / span 2;
    margin-top: 1px;
}

.independent-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 5px;
    border-radius: 50%;
    background: var(--tile);
    color: #fff;
}

.independent-icon svg {
    width: 100%;
    height: 100%;
}

.independents strong {
    font-weight: 600;
}

/* Description de l'effet */
.independents strong + span {
    color: var(--text-muted);
}

.rules-button {
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.rules-button:hover {
    background: var(--surface-raised);
    border-color: rgba(255, 255, 255, .14);
}

/* ------------------------------------------------ */
/* ZONE DE JEU */
/* ------------------------------------------------ */

/* Mobile : grille en premier */
.game-area {
    order: -1;
    display: flex;
    justify-content: center;
}

/* ------------------------------------------------ */
/* GRILLE */
/* ------------------------------------------------ */

.board {
    width: 100%;
    aspect-ratio: 1;

    display: grid;

    /* minmax(0) : les noms longs n'élargissent pas les colonnes */
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    gap: 5px;

    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    touch-action: none;
}

.cell {
    /* pour les unités cqi */
    container-type: inline-size;

    display: flex;
    justify-content: center;
    align-items: center;

    position: relative;
    border-radius: 18%;
    color: var(--tile-ink, #fff);

    user-select: none;
    cursor: grab;
}

.cell-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3%;
    padding: 6%;
    border-radius: inherit;
}

/* MÉDIAS DES MILLIARDAIRES */
.cell--media {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 60%),
        var(--tile);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}

/* MÉDIAS INDÉPENDANTS */
.cell--independent .cell-inner {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    padding: 10%;
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 65%),
        var(--tile);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, .22),
        0 3px 8px rgba(0, 0, 0, .35);
}

/* Badge d'effet */
.cell-badge {
    position: absolute;
    top: 0;
    right: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 29cqi;
    height: 29cqi;
    padding: 3.5cqi;

    border-radius: 50%;
    background: #f4f1e8;
    color: var(--tile);
    box-shadow: 0 0 0 2px var(--surface);
    pointer-events: none;
}

.cell-badge svg {
    width: 100%;
    height: 100%;
}

/* PROPRIÉTAIRES */
.cell--owner {
    background: var(--owner-bg);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .06),
        inset 0 -4px 0 var(--tile);
}

/* CASES VIDES */
.empty-cell {
    background: rgba(255, 255, 255, .025);
}

/* LOGO */
.cell-logo {
    width: 58%;
    height: 58%;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}

/* Vrais logos (--logo-size = option size) */
.has-logo .cell-logo {
    width: var(--logo-size, 74%);
    height: var(--logo-size, 74%);
}

/* showName */
.has-logo.logo--named .cell-logo {
    width: var(--logo-size, 58%);
    height: var(--logo-size, 58%);
}

/* wide */
.has-logo.logo--wide .cell-logo {
    width: var(--logo-size, 100%);
    height: 42%;
}

.has-logo.logo--wide.logo--named .cell-logo {
    height: 34%;
}

/* style: plate */
.logo--plate .cell-logo {
    padding: 3cqi 3cqi;
    background-color: #fff;
    background-origin: content-box;
    border-radius: 5cqi;
    filter: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

/* style: white */
.logo--white .cell-logo {
    filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}

/* NOM DU MÉDIA */
.cell-label {
    max-width: 100%;
    font-size: clamp(6px, 12cqi, 11px);
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    /* \n du nom court */
    white-space: pre-line;
    /* lisibilité sur fond coloré */
    text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

/* pas d'ombre sur le jaune */
.tile-yellow .cell-label {
    text-shadow: none;
}

/* Pas de wrap auto : seuls les \n du nom court comptent */
.cell--independent .cell-label {
    display: block;
    font-size: clamp(6px, 11cqi, 10px);
    white-space: pre;
    text-overflow: ellipsis;
}

/* NOM DU PROPRIÉTAIRE */
.cell-owner {
    font-size: clamp(6px, 12cqi, 11px);
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    color: var(--text);
}

/* ------------------------------------------------ */
/* VERSION TÉLÉPHONE */
/* ------------------------------------------------ */

/* Grille bord à bord */
@media (max-width: 599px) {

    .main {
        padding-left: 0;
        padding-right: 0;
    }

    .side-column {
        margin: 0 16px;
    }

    .board {
        gap: 3px;
        padding: 3px;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }
}

/* ------------------------------------------------ */
/* MOBILE ET TABLETTE (en dessous de la version desktop) */
/* ------------------------------------------------ */

/* Résumé des bonus (mobile / tablette) */
.bonus-summary {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 899px) {

    /* Titre pleine largeur, puis score + bonus */
    .header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 14px 16px 0;
    }

    .header-title {
        grid-column: 1 / -1;
        font-size: 18px;
    }

    /* Score + record dans une carte */
    .scoreboard {
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 8px 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-small);
    }

    .scoreboard-item {
        align-items: flex-start;
        min-width: 0;
        padding: 0;
        background: none;
        border: none;
    }

    .scoreboard-item + .scoreboard-item {
        flex-direction: row;
        align-items: baseline;
        gap: 6px;
    }

    .scoreboard-item + .scoreboard-item .scoreboard-label {
        font-size: 10px;
    }

    .scoreboard-item + .scoreboard-item .scoreboard-value {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-muted);
    }

    /* Carte cliquable */
    .bonus-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        min-width: 0;
        padding: 8px 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-small);
        color: var(--text);
        text-align: left;
        cursor: pointer;
    }

    .bonus-summary-values {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .bonus-summary-pluralism {
        font-size: 22px;
    }

    .bonus-summary-series {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .bonus-summary-chevron {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        color: var(--text-muted);
        transition: transform 200ms ease;
    }

    .bonus-summary[aria-expanded="true"] .bonus-summary-chevron {
        transform: rotate(180deg);
    }

    /* Détail des bonus en surimpression */
    .main {
        position: relative;
        padding-top: 10px;
    }

    .sidebar {
        display: none;
    }

    .guide-entry-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .guide-entry-button {
        font-size: 14px;
    }

    .sidebar.is-open {
        display: flex;
        position: absolute;
        top: 6px;
        left: 16px;
        right: 16px;
        z-index: 30;
        margin: 0;
        max-height: calc(100dvh - 150px);
        overflow-y: auto;
        box-shadow: var(--shadow);
    }
}

/* ------------------------------------------------ */
/* VERSION DESKTOP */
/* ------------------------------------------------ */

@media (min-width: 900px) {

    .header {
        padding: 28px 24px 0;
    }

    .header-title {
        font-size: 24px;
    }

    .header-title .logo {
        --brand-size: 26px;
    }

    .main {
        flex-direction: row;
        align-items: flex-start;
        gap: 24px;
        padding: 24px;
    }

    .side-column {
        width: 280px;
        flex-shrink: 0;
    }

    .game-area {
        order: 0;
        flex: 1;
    }

    /* La grille tient dans la hauteur */
    .board {
        width: min(100%, 700px, calc(100vh - 150px));
        gap: 6px;
        padding: 8px;
    }
}

/* ------------------------------------------------ */
/* ANIMATIONS MATCH-3 */
/* ------------------------------------------------ */

.cell {
    transition: transform 200ms ease, opacity 200ms ease;
}

.cell.swap {
    z-index: 10;
    transform: scale(1.1);
}

.cell.pop {
    animation: tile-pop 350ms ease-in forwards;
}

.cell.owner-appear {
    animation: owner-appear 250ms ease-out both;
}

.cell.empty-cell-hidden {
    opacity: 0;
}

@keyframes tile-pop {
    to {
        opacity: 0;
        transform: scale(.2);
    }
}

@keyframes owner-appear {
    from {
        opacity: 0;
        transform: scale(.65);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.cell.fall {
    z-index: 5;
    transition: transform 350ms ease-in;
}

/* ------------------------------------------------ */
/* INDICE */
/* ------------------------------------------------ */

/* Les deux tuiles pulsent l'une vers l'autre (--hint-dx / --hint-dy) */
.cell.hint {
    z-index: 2;
    animation: hint-nudge 1.2s ease-in-out infinite;
}

@keyframes hint-nudge {
    0%, 100% {
        transform: none;
    }

    50% {
        transform:
            translate(calc(var(--hint-dx, 0) * 10%), calc(var(--hint-dy, 0) * 10%))
            scale(1.06);
        filter: brightness(1.25);
    }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {

    .cell.hint {
        animation: none;
        filter: brightness(1.3);
        outline: 2px solid rgba(255, 255, 255, .8);
        outline-offset: -2px;
    }
}

/* ------------------------------------------------ */
/* EFFETS DES MÉDIAS INDÉPENDANTS */
/* ------------------------------------------------ */

.effect-highlight {
    animation: effect-highlight .35s;
}

/* Calque des effets (positionné en JS) */
.effect-layer {
    position: fixed;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
    border-radius: var(--radius);
}

/* Sortie des tuiles touchées */
.cell.effect-vanish {
    z-index: 3;
    animation: effect-vanish 250ms ease-in forwards;
}

@keyframes effect-vanish {
    to {
        opacity: 0;
        transform: scale(.3);
        filter: brightness(2);
    }
}

/* --- Croisement des sources --- */

.effect-beam {
    position: absolute;
    background: linear-gradient(var(--beam-direction), rgba(143, 209, 111, 0), #e6ffd9 50%, rgba(143, 209, 111, 0));
    box-shadow: 0 0 18px 4px rgba(143, 209, 111, .55);
    border-radius: 999px;
    opacity: 0;
    animation: effect-beam 650ms ease-out forwards;
}

.effect-beam--horizontal {
    --beam-direction: 180deg;
    left: 0;
    width: 100%;
    height: 8%;
    max-height: 18px;
    translate: 0 -50%;
}

.effect-beam--vertical {
    --beam-direction: 90deg;
    top: 0;
    height: 100%;
    width: 8%;
    max-width: 18px;
    translate: -50% 0;
}

@keyframes effect-beam {
    0% {
        opacity: 1;
        scale: 0 1;
    }

    45% {
        opacity: 1;
        scale: 1 1;
    }

    100% {
        opacity: 0;
        scale: 1 .2;
    }
}

.effect-beam--vertical {
    animation-name: effect-beam-vertical;
}

@keyframes effect-beam-vertical {
    0% {
        opacity: 1;
        scale: 1 0;
    }

    45% {
        opacity: 1;
        scale: 1 1;
    }

    100% {
        opacity: 0;
        scale: .2 1;
    }
}

/* Onde */
.effect-burst {
    position: absolute;
    border: 3px solid #e6ffd9;
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(143, 209, 111, .8);
    animation: effect-burst 500ms ease-out forwards;
}

@keyframes effect-burst {
    from {
        opacity: 1;
        scale: .3;
    }

    to {
        opacity: 0;
        scale: 2.2;
    }
}

.cell.effect-hit {
    z-index: 3;
    animation: effect-hit 350ms ease-out both;
}

@keyframes effect-hit {
    30% {
        transform: scale(1.15);
        filter: brightness(2.2);
        box-shadow: 0 0 0 3px #e6ffd9, 0 0 18px rgba(143, 209, 111, .9);
    }

    100% {
        transform: scale(1.05);
        filter: brightness(1.6);
    }
}

/* --- Enquête --- */

.effect-zone {
    position: absolute;
    border: 3px dashed rgba(255, 255, 255, .85);
    border-radius: 12px;
    background: rgba(143, 209, 111, .12);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35);
    overflow: hidden;
    animation: effect-zone 850ms ease-out forwards;
}

@keyframes effect-zone {
    0% {
        opacity: 0;
        scale: 1.25;
    }

    20% {
        opacity: 1;
        scale: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.effect-scan {
    position: absolute;
    left: 0;
    right: 0;
    height: 14%;
    background: linear-gradient(180deg, rgba(230, 255, 217, 0), rgba(230, 255, 217, .75));
    border-bottom: 2px solid #e6ffd9;
    animation: effect-scan 600ms ease-in-out 150ms both;
}

@keyframes effect-scan {
    from {
        top: -14%;
    }

    to {
        top: 100%;
    }
}

/* Loupe */
.effect-lens {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42%;
    aspect-ratio: 1;
    color: #fff;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6));
    translate: -50% -50%;
    animation: effect-lens 750ms ease-in-out 100ms both;
}

.effect-lens svg {
    width: 100%;
    height: 100%;
}

@keyframes effect-lens {
    0% {
        opacity: 0;
        transform: translate(-30%, -30%) scale(.6);
    }

    20% {
        opacity: 1;
        transform: translate(-30%, -30%) scale(1);
    }

    45% {
        transform: translate(30%, -20%);
    }

    70% {
        transform: translate(20%, 30%);
    }

    90% {
        opacity: 1;
        transform: translate(-25%, 20%);
    }

    100% {
        opacity: 0;
        transform: translate(0, 0) scale(1.3);
    }
}

.cell.effect-reveal {
    z-index: 3;
    animation: effect-reveal 300ms ease-out both;
}

@keyframes effect-reveal {
    40% {
        filter: grayscale(1) brightness(1.8);
        transform: scale(.88);
    }

    100% {
        filter: grayscale(.6) brightness(1.4);
        transform: scale(.95);
    }
}

/* --- Démantèlement --- */

.effect-network {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Chaque moitié se dessine depuis son propriétaire puis se rétracte */
.effect-link {
    stroke: var(--network);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
    filter: drop-shadow(0 0 4px var(--network));
    animation:
        effect-link-draw 300ms ease-out forwards,
        effect-link-break 350ms ease-in forwards;
}

@keyframes effect-link-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes effect-link-break {
    from {
        stroke-dashoffset: 0;
        stroke-dasharray: 1 1;
    }

    25% {
        stroke: #fff;
        stroke-dasharray: .85 1;
    }

    to {
        stroke-dashoffset: 0;
        stroke-dasharray: 0 1;
        opacity: 0;
    }
}

.effect-node {
    fill: var(--network);
    stroke: #fff;
    stroke-width: 2;
    animation: effect-node 900ms ease-out forwards;
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes effect-node {
    0% {
        scale: 0;
    }

    25% {
        scale: 1.2;
    }

    45% {
        scale: 1;
    }

    60% {
        scale: 1.6;
        fill: #fff;
    }

    100% {
        scale: 0;
        opacity: 0;
    }
}

/* Étincelle */
.effect-spark {
    border-color: #fff;
    box-shadow: 0 0 14px var(--network, #fff);
    animation: effect-spark 400ms ease-out both;
}

@keyframes effect-spark {
    0% {
        opacity: 0;
        scale: .2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        scale: 2;
    }
}

.cell.effect-break {
    z-index: 3;
    animation: effect-break 450ms ease-in-out both;
}

@keyframes effect-break {
    0%,
    100% {
        transform: none;
    }

    15% {
        transform: translateX(-6%) rotate(-5deg);
    }

    35% {
        transform: translateX(6%) rotate(5deg);
    }

    55% {
        transform: translateX(-4%) rotate(-3deg);
        filter: grayscale(1);
    }

    75% {
        transform: translateX(3%) rotate(2deg);
        filter: grayscale(1) brightness(1.6);
    }
}

/* ------------------------------------------------ */
/* ÉCRANS DE DÉBUT ET DE FIN */
/* ------------------------------------------------ */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;

    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;

    background: rgba(10, 11, 14, .6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.hidden {
    display: none;
}

.overlay-box {
    width: min(420px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 32px 28px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);

    text-align: center;
}

.overlay-box h2 {
    margin-bottom: 12px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.overlay-box p {
    margin-bottom: 24px;
    color: var(--text-muted);
}

.overlay-box button {
    margin-top: 8px;
    padding: 12px 28px;
    background: var(--text);
    border: none;
    border-radius: var(--radius-small);
    color: var(--bg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.overlay-box button:hover {
    background: #fff;
}

/* ------------------------------------------------ */
/* SCORE */
/* ------------------------------------------------ */

.score-float {
    position: fixed;
    z-index: 50;
    transform: translate(-50%, -50%);
    pointer-events: none;

    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .6);

    animation: score-float 900ms ease-out forwards;
}

@keyframes score-float {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(.8);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -180%) scale(1.1);
    }
}

.gameover-stats {
    margin-bottom: 16px;
    text-align: left;
    font-size: 14px;
}

.overlay-box .gameover-stats p {
    margin-bottom: 8px;
}

.gameover-stats ul {
    list-style: none;
    margin: 4px 0 14px;
    padding: 10px 14px;
    background: var(--surface-raised);
    border-radius: var(--radius-small);
}

.gameover-stats li + li {
    margin-top: 4px;
}

/* Libérations, en tête du bloc */
.gameover-stats .gameover-freed {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    color: var(--tier-0);
    font-weight: 600;
}

.gameover-stats .gameover-freed + li {
    margin-top: 0;
}

.overlay-box .gameover-score {
    margin-bottom: 4px;
    font-size: 30px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    text-align: center;
}

.overlay-box .gameover-best {
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--tier-0);
    text-align: center;
}

/* Fin de partie */
#gameover-overlay .overlay-box {
    width: min(480px, 100%);
    padding-top: 24px;
    padding-bottom: 24px;
}

/* Espacements réduits pour éviter le scroll */
#gameover-overlay .overlay-box > p {
    margin-bottom: 14px;
}

#gameover-overlay .gameover-stats ul {
    margin-bottom: 10px;
}

#gameover-overlay .guide-entry-button {
    padding-top: 10px;
    padding-bottom: 10px;
}

@media (max-width: 599px) {

    #gameover-overlay .overlay-box {
        padding: 20px 16px;
    }
}

/* Bloc "Et dans la vraie vie ?" */
.gameover-more {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: rgba(74, 150, 54, .1);
    border: 1px solid rgba(143, 209, 111, .35);
    border-radius: var(--radius);
    text-align: left;
}

.gameover-more h3 {
    margin-bottom: 6px;
    font-size: 17px;
    font-weight: 700;
}

.overlay-box .gameover-more p {
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.5;
}

.overlay-box .gameover-more strong {
    color: var(--text);
}

.gameover-more-buttons {
    display: grid;
    gap: 8px;
}

/* Boutons du guide */
.overlay-box .guide-entry-button {
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
}

.overlay-box .guide-entry-button:hover {
    background: #2a2f38;
    border-color: rgba(255, 255, 255, .14);
}

.gameover-elections {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(143, 209, 111, .25);
}

.gameover-elections[hidden] {
    display: none;
}

.overlay-box .gameover-elections p {
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
}

/* ------------------------------------------------ */
/* RÈGLES */
/* ------------------------------------------------ */

.rules-dialog {
    width: min(640px, calc(100% - 32px));
    max-height: 85vh;
    overflow-x: hidden;
    overflow-y: auto;
    margin: auto;
    padding: 0;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    color: var(--text);
}

.rules-dialog::backdrop {
    background: rgba(10, 11, 14, .6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.rules-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.rules-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.rules-close {
    width: 34px;
    height: 34px;
    background: var(--surface-raised);
    border: none;
    border-radius: 50%;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.rules-close:hover {
    background: #2e333d;
}

.rules-content {
    padding: 4px 24px 24px;
    font-size: 15px;
    line-height: 1.55;
}

.rules-content section {
    margin-top: 22px;
}

.rules-content h3 {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
}

.rules-content p {
    margin-bottom: 10px;
    color: var(--text-muted);
}

.rules-content strong {
    color: var(--text);
}

.rules-list {
    margin: 0 0 10px 20px;
    color: var(--text-muted);
}

.rules-list li {
    margin-bottom: 4px;
}

.rules-effects {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.rules-effects li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.rules-effects .independent-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
}

.rules-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 4px;
    border-radius: 3px;
    background: var(--tile);
    vertical-align: -1px;
}

.rules-green {
    color: var(--media-green);
    font-weight: 600;
}

.rules-table {
    width: 100%;
    margin-bottom: 10px;
    border-collapse: collapse;
    font-size: 14px;
}

.rules-table td {
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.rules-table td:last-child {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    white-space: nowrap;
}

/* ------------------------------------------------ */
/* ACCÈS AU GUIDE */
/* ------------------------------------------------ */

.side-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.guide-entry {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.guide-entry h2 {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.guide-entry-buttons {
    display: grid;
    gap: 8px;
}

.guide-entry-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.guide-entry-button:hover {
    background: #2a2f38;
    border-color: rgba(255, 255, 255, .14);
}

/* Icônes */
.guide-entry-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

/* Milliardaires : € */
.guide-entry-icon--owners {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 3px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    border-radius: 5px;
    background: var(--owner-bg);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .1),
        inset 0 -4px 0 var(--tile, var(--media-red));
}

.guide-entry-icon--owners::before {
    content: "€";
}

/* Indépendants : mégaphone */
.guide-entry-icon--independents {
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11l18-5v12L3 14v-3z'/%3E%3Cpath d='M11.6 16.8a3 3 0 1 1-5.8-1.6'/%3E%3C/svg%3E") center / 14px no-repeat,
        var(--media-green);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .22);
}

/* ------------------------------------------------ */
/* LOGO DU SITE */
/* ------------------------------------------------ */

/* --cap-center : milieu des capitales depuis le haut de la ligne
   --disc : juste assez grand pour couvrir le trait */
.logo {
    --brand-size: 22px;
    --cap-center: .52em;
    --line-top: 1.2em;
    --line-height: .14em;
    --disc: calc((var(--line-top) + var(--line-height) - var(--cap-center)) * 2 + .08em);

    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: baseline;
    /* débordement du rond + trait */
    padding: calc(var(--disc) / 2 - var(--cap-center)) 0 calc(var(--line-top) + var(--line-height) - 1em);
    font-size: var(--brand-size);
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1;
    white-space: nowrap;
}

/* Trait, depuis le centre du rond */
.logo::after {
    content: "";
    position: absolute;
    z-index: -2;
    left: calc(var(--disc) / 2);
    right: 0;
    bottom: 0;
    height: var(--line-height);
    background: linear-gradient(90deg,
        var(--media-red) 0 25%,
        var(--media-blue) 25% 50%,
        var(--media-purple) 50% 75%,
        var(--media-yellow) 75% 100%);
}

/* DÉ = largeur du rond */
.logo-de {
    position: relative;
    width: var(--disc);
    margin-right: .12em;
    color: #fff;
    letter-spacing: 0;
    text-align: center;
}

/* Rond centré sur les capitales */
.logo-de::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: 0;
    top: calc(var(--cap-center) - var(--disc) / 2);
    width: var(--disc);
    height: var(--disc);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 65%),
        var(--media-green);
    box-shadow:
        0 0 0 .08em rgb(90, 90, 90),
        0 .1em .25em rgba(0, 0, 0, .35);
}

.logo-word {
    color: var(--text);
}

/* Écran d'accueil : chute du rond */
.logo--large {
    --brand-size: clamp(26px, 8vw, 40px);
}

.logo--large .logo-de {
    animation: logo-drop 700ms cubic-bezier(.3, 1.4, .5, 1) 300ms both;
}

/* Le trait s'allonge vers la gauche */
.logo--large::after {
    animation: logo-line 450ms cubic-bezier(.2, .8, .3, 1) 550ms both;
}

@keyframes logo-line {
    from {
        left: calc(var(--disc) + .12em);
    }

    to {
        left: calc(var(--disc) / 2);
    }
}

@keyframes logo-drop {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }

    50% {
        opacity: 1;
    }

    to {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    .logo--large .logo-de,
    .logo--large::after {
        animation: none;
    }
}

/* ------------------------------------------------ */
/* ÉCRAN D'ACCUEIL */
/* ------------------------------------------------ */

.overlay-box .start-title {
    margin-bottom: 10px;
}

.overlay-box .start-subtitle {
    margin-bottom: 18px;
    font-size: 14px;
    font-style: italic;
    color: var(--text-muted);
}

.overlay-box .start-lead {
    margin-bottom: 10px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.start-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;
    margin-top: 16px;
}

/* Liens secondaires */
.overlay-box .link-button {
    margin: 0;
    padding: 6px 4px;
    background: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.overlay-box .link-button:hover {
    background: none;
    color: var(--text);
}

/* ------------------------------------------------ */
/* GUIDE DES MÉDIAS */
/* ------------------------------------------------ */

.guide-dialog {
    width: min(880px, calc(100% - 32px));
}

/* Header et onglets sticky */
.guide-top {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.guide-top .rules-header {
    position: static;
    border-bottom: none;
    padding-bottom: 12px;
}

.guide-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 24px 16px;
}

.guide-tab {
    padding: 14px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.guide-tab:hover {
    color: var(--text);
}

.guide-tab[aria-selected="true"] {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

.guide-panel {
    padding: 8px 24px 24px;
    font-size: 15px;
    line-height: 1.55;
}

/* Milliardaires */
.guide-owner {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.guide-owner-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

/* Rappel du bloc propriétaire */
.guide-owner-mark {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--owner-bg);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .08),
        inset 0 -5px 0 var(--tile);
}

.guide-owner h3 {
    font-size: 18px;
    font-weight: 700;
}

.guide-owner-group {
    font-size: 13px;
    color: var(--text-muted);
}

.guide-owner > p {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.guide-empire {
    display: grid;
    gap: 8px;
}

.guide-empire > div {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface-raised);
    border-radius: var(--radius-small);
}

.guide-empire dt {
    font-weight: 600;
    /* éclaircie pour le contraste */
    color: color-mix(in srgb, var(--tile) 55%, #fff);
}

.guide-empire dd {
    color: var(--text);
}

/* Autres milliardaires propriétaires de médias */
.guide-others {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.guide-others h3 {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
}

.guide-others ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 8px;
}

.guide-others li {
    padding: 10px 12px;
    background: var(--surface-raised);
    border-radius: var(--radius-small);
}

.guide-others-group {
    margin-left: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.guide-others li p {
    margin-top: 2px;
    font-size: 14px;
    color: var(--text-muted);
}

.guide-note {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Liens vers les cartes (Diplo, LVSL) */
.guide-maps {
    margin: -8px 0 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.guide-map {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 12px 8px 8px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.guide-map + .guide-map {
    border-top: 1px solid var(--border);
}

.guide-map:hover {
    background: #2a2f38;
}

.guide-map:first-child {
    border-radius: var(--radius-small) var(--radius-small) 0 0;
}

.guide-map:last-child {
    border-radius: 0 0 var(--radius-small) var(--radius-small);
}

/* Miniature ou chiffre */
.guide-map-preview {
    flex-shrink: 0;
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    background: #fff;
}

.guide-map-figure {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--owner-bg);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
}

.guide-map-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.guide-map-text strong {
    color: var(--text);
    font-size: 14px;
}

/* Moins d'espace après les cartes */
.guide-maps + .guide-owner {
    padding-top: 4px;
}

/* Mobile : citation sur 3 lignes max */
@media (max-width: 599px) {

    .guide-map-text > span {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Et bien d'autres… */
.guide-more {
    margin-top: 16px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* Médias indépendants */
.guide-intro {
    margin: 12px 0 20px;
    color: var(--text-muted);
}

.guide-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 12px;
}

.guide-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Logo : même rendu que sur la grille */
.guide-logo {
    container-type: inline-size;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 84px;
    margin-bottom: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-small);
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 70%),
        var(--tile);
    color: #fff;
}

.guide-logo .cell-logo {
    max-height: 100%;
}

/* Hauteur max des logos */
.guide-logo.logo--plate .cell-logo {
    padding: 4cqi 5cqi;
    border-radius: 3cqi;
}

.guide-logo-name {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}

.guide-card h4 {
    font-size: 16px;
    font-weight: 700;
}

.guide-card-description {
    font-size: 14px;
    color: var(--text-muted);
}

/* Fait marquant */
.guide-card-highlight {
    padding: 8px 10px;
    border-left: 3px solid var(--media-green);
    border-radius: 0;
    background: rgba(255, 255, 255, .04);
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
}

/* Lien en bas de carte */
.guide-card-link {
    align-self: flex-start;
    margin-top: auto;
    padding-top: 4px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-underline-offset: 3px;
}

/* Mobile */
@media (max-width: 599px) {

    .guide-tabs {
        padding: 0 16px 12px;
    }

    .guide-tab {
        padding: 12px 8px;
        font-size: 14px;
    }

    .guide-panel {
        padding: 4px 16px 20px;
    }

    .guide-empire > div {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

/* ------------------------------------------------ */
/* ÉLECTIONS (bloc temporaire) */
/* ------------------------------------------------ */

.elections-entry h2 {
    font-size: 16px;
    line-height: 1.3;
}

/* Icône urne */
.elections-entry-icon {
    border-radius: 4px;
    background:
        linear-gradient(var(--text) 0 0) center 5px / 10px 2px no-repeat,
        var(--surface);
    box-shadow: inset 0 0 0 2px var(--text-muted);
}

.elections-dialog {
    width: min(880px, calc(100% - 32px));
}

.rules-content .elections-intro {
    margin: 12px 0 20px;
    color: var(--text-muted);
}

.elections-parties {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
    gap: 12px;
}

.elections-party {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.elections-party h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

/* Puce d'orientation + légende */
.elections-party-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.elections-orientation {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .08);
}

.elections-orientations {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: -8px 0 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.elections-orientations li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.elections-proposals {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

.elections-proposals li {
    position: relative;
    padding-left: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.elections-proposals li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .5em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* vert : contre la concentration, blanc : autres, gris : aucune */
.elections-proposal {
    color: var(--text);
}

.elections-proposal--concentration {
    color: var(--tier-0);
}

.rules-content .elections-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -8px 0 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.elections-legend-mark {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tier-0);
}

.elections-none {
    color: var(--text-muted);
    font-style: italic;
}

.rules-content .elections-sources {
    margin: auto 0 0;
    padding-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.elections-sources a {
    color: var(--text-muted);
    text-underline-offset: 2px;
}

.elections-sources a:hover {
    color: var(--text);
}

/* ------------------------------------------------ */
/* PAGES ANNEXES (CONTACT, CRÉDITS, MENTIONS LÉGALES) */
/* ------------------------------------------------ */

.doc-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 24px;
    padding: 20px 16px 0;
}

.doc-header a {
    color: var(--text);
    text-decoration: none;
}

.doc-back {
    color: var(--text-muted);
    font-size: 14px;
}

.doc-header .doc-back {
    color: var(--text-muted);
}

.doc-header .doc-back:hover {
    color: var(--text);
}

.doc {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 16px 0;
    font-size: 15px;
    line-height: 1.6;
}

.doc h1 {
    margin-bottom: 16px;
    font-size: 28px;
    line-height: 1.2;
}

.doc h2 {
    margin: 32px 0 10px;
    font-size: 18px;
}

.doc p,
.doc li {
    color: var(--text-muted);
}

.doc p {
    margin-bottom: 12px;
}

.doc ul {
    margin: 0 0 12px 20px;
}

.doc strong {
    color: var(--text);
}

.doc a {
    color: var(--text);
    text-underline-offset: 3px;
}

/* Scroll horizontal sur mobile */
.doc-table {
    margin-bottom: 12px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.doc-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.doc-table th,
.doc-table td {
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.doc-table th {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
}

.doc-table td {
    color: var(--text-muted);
}

.doc-table tr:last-child td {
    border-bottom: none;
}

/* Formulaire de contact */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.contact-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contact-field label {
    font-size: 14px;
    font-weight: 600;
}

.contact-optional {
    color: var(--text-muted);
    font-weight: 400;
}

.contact-field input,
.contact-field textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--radius-small);
    color: var(--text);
    font: inherit;
}

.contact-field textarea {
    min-height: 160px;
    resize: vertical;
}

.contact-field input:focus-visible,
.contact-field textarea:focus-visible {
    outline: 2px solid var(--media-green);
    outline-offset: 1px;
}

/* Honeypot */
.contact-honeypot {
    display: none;
}

.contact-submit {
    align-self: flex-start;
    padding: 12px 28px;
    background: var(--text);
    border: none;
    border-radius: var(--radius-small);
    color: var(--bg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.contact-submit:hover {
    background: #fff;
}

.contact-submit:disabled {
    opacity: .6;
    cursor: wait;
}

.contact-status {
    min-height: 1.6em;
}

.contact-status[data-state="success"] {
    color: var(--tier-0);
}

.contact-status[data-state="error"] {
    color: var(--tier-3);
}

/* ------------------------------------------------ */
/* ACCESSIBILITÉ */
/* ------------------------------------------------ */

/* Focus clavier */
:focus-visible {
    outline: 3px solid #8fd16f;
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--text);
    border-radius: var(--radius-small);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

.game-area:focus {
    outline: none;
}

/* Lignes ARIA, sans effet sur la grille */
.board-row {
    display: contents;
}

/* Case active (contour intérieur) */
.cell:focus-visible {
    z-index: 5;
    outline: 3px solid #fff;
    outline-offset: -1px;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, .55);
}

/* Case sélectionnée */
.cell[aria-selected="true"] {
    z-index: 4;
    transform: scale(.9);
    outline: 3px dashed #fff;
    outline-offset: 2px;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
}
