/* Ladder Isolation. Deux couleurs, celles des pions : le rouge sert aussi d'action principale,
   l'encre est le noir. Le plateau est le seul élément expressif ; les cases détruites sont percées. */

:root {
    --paper: #eceff3;
    --surface: #f9fafb;
    --ink: #12161d;
    --muted: #5b6470;
    --line: #d3d9e0;
    --red: #c32f3c;
    --red-ink: #ffffff;
    --pawn-black: #1b1f27;
    --pawn-rim: #1b1f27;
    --black-mark: #7b8594;
    --tile: #dce2e9;
    --hole: #171b22;
    --hover: #e3e8ee;
    --ok: #1f7a4d;
    /* Équipes du graphe, dans cet ordre : voisines distinctes aussi pour les daltoniens. */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --series-7: #6250d6;
    --series-8: #e34948;
    --series-9: #0f95b0;
    --series-10: #a86a00;

    --radius: 10px;
    --gap: clamp(10px, 1.2vw, 16px);
    --font: 'Archivo', system-ui, sans-serif;

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #121419;
        --surface: #1a1e25;
        --ink: #e7eaee;
        --muted: #959da9;
        --line: #2a303a;
        --red: #e5484d;
        --pawn-black: #0d0f13;
        --pawn-rim: #aab2bd;
        --black-mark: #aab2bd;
        --tile: #313843;
        --hole: #07080a;
        --hover: #222730;
        --ok: #4cc38a;
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --series-5: #d55181;
        --series-6: #008300;
        --series-7: #9085e9;
        --series-8: #e66767;
        --series-9: #1fa3bf;
        --series-10: #b8790a;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 400 15px/1.45 var(--font);
    font-variant-numeric: tabular-nums;
}

h1,
h2,
p {
    margin: 0;
}

h2 {
    font-size: 1rem;
    font-weight: 700;
    font-stretch: 112%;
    letter-spacing: -0.01em;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

abbr[title] {
    text-decoration: none;
}

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

.masthead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    padding: 12px max(var(--gap), env(safe-area-inset-right)) 12px max(var(--gap), env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
}

.title {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem);
    font-weight: 850;
    font-stretch: 118%;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.title-course {
    font-weight: 500;
    font-stretch: 100%;
    letter-spacing: 0;
    color: var(--muted);
}

.pages {
    display: flex;
    gap: 4px;
    margin-right: auto;
}

.pages a {
    padding: 4px 12px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
}

.pages a:hover {
    background: var(--hover);
    color: var(--ink);
}

.pages a[aria-current='page'] {
    background: color-mix(in srgb, var(--red) 14%, transparent);
    color: var(--ink);
    font-weight: 600;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
}

.session {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.verified {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    cursor: pointer;
}

.verified input {
    margin: 0;
    accent-color: var(--red);
}

select {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.875rem;
}

.live {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    flex: none;
}

.live.on {
    background: var(--ok);
}

.live.error {
    background: var(--red);
}

/* Le seul mouvement non sollicité : de nouvelles parties viennent d'arriver. */
.live.pulse {
    animation: pulse 1.2s ease-out;
}

@keyframes pulse {
    from {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 70%, transparent);
    }

    to {
        box-shadow: 0 0 0 10px transparent;
    }
}

/* --- Gabarit ------------------------------------------------------------------------------- */

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gap);
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: var(--gap) max(var(--gap), env(safe-area-inset-right)) max(var(--gap), env(safe-area-inset-bottom)) max(var(--gap), env(safe-area-inset-left));
}

.panel {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.panel>h2 {
    margin-bottom: 10px;
}

/* Repères et légendes : rien à copier, et un double-clic ne doit pas les surligner. */
.board,
th,
.rank,
.badge,
.duel-badge,
.band,
.round-title,
.match-id,
.match-state,
.slot .seed,
.elo-caption,
.elo-window label,
h2,
.live,
.title-course,
.pages a,
.icon,
.picker-icon,
.chip-remove,
.bump-grid text {
    -webkit-user-select: none;
    user-select: none;
}

.scroll {
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
    display: none;
}

/* Sans barre, une ligne coupée sous un dégradé gris dit qu'il y en a d'autres. */
.scroll::after {
    content: '';
    display: block;
    position: sticky;
    bottom: 0;
    height: 2.5rem;
    margin-top: -2.5rem;
    background: linear-gradient(transparent, color-mix(in srgb, var(--line) 70%, var(--surface)));
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.scroll.more::after {
    opacity: 1;
}

/* Tout l'essentiel sur un écran : seuls le classement au-delà du 10e et les parties défilent. */
@media (min-width: 960px) and (min-height: 600px) {
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .layout {
        min-height: 0;
        grid-template-columns: minmax(420px, 6fr) minmax(0, 7fr);
        grid-template-rows: auto auto minmax(9.5rem, 1fr);
        grid-template-areas:
            'ranking submit'
            'ranking replay'
            'games replay';
    }

    .ranking {
        grid-area: ranking;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .submit {
        grid-area: submit;
    }

    .replay {
        grid-area: replay;
        min-height: 0;
    }

    .games {
        grid-area: games;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .games-list {
        flex: 1;
        min-height: 0;
    }

    /* Même hauteur quelle que soit la sélection : le sélecteur d'équipes en dessous ne bouge pas.
       Sept lignes et la moitié de la huitième, qui annonce la suite. */
    .ranking-scroll {
        max-height: min(calc(2rem + 7.5 * 2.25rem), calc(100dvh - 20rem));
    }
}

@media (min-width: 1400px) and (min-height: 600px) {
    .layout {
        grid-template-columns: minmax(620px, 5fr) minmax(0, 7fr);
    }
}

/* --- Classement ----------------------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0 8px;
    height: 2.25rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 2rem;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.num {
    text-align: right;
}

.rank {
    width: 2.5em;
    color: var(--muted);
}

.team {
    font-weight: 600;
    width: 100%;
    max-width: 0;
    overflow: hidden;
}

.team-line {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* Le nom cède d'abord la place, puis l'adversaire ; les autres badges restent entiers. */
.team-name {
    flex: 0 100 auto;
    min-width: 6ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-line .badge {
    flex: none;
}

tbody tr {
    scroll-margin-block: 2rem 2.5rem;
}

tbody td {
    transition: background-color 0.6s ease-out;
}

tr.opponent td {
    background: color-mix(in srgb, var(--red) 10%, transparent);
}

tr.ping td {
    background: color-mix(in srgb, var(--red) 22%, transparent);
}

.elo {
    font-size: 1.25rem;
    font-weight: 800;
    font-stretch: 75%;
    letter-spacing: 0.01em;
}

tr.bot td {
    color: var(--muted);
}

tr.bot .team {
    font-weight: 500;
}

tbody tr:first-child .rank,
tbody tr:first-child .elo {
    color: var(--red);
}

.record,
.last-col,
.pct,
.pace {
    color: var(--muted);
}

.th-toggle {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.pace.warn {
    color: var(--red);
    font-weight: 700;
}

.ranking {
    container: ranking / inline-size;
}

/* Selon la largeur du panneau, pas de la fenêtre : Dernière, V–D, moy., % V puis Elo s'effacent. */
@container ranking (max-width: 560px) {
    .last-col {
        display: none;
    }
}

@container ranking (max-width: 500px) {
    .record {
        display: none;
    }
}

@container ranking (max-width: 440px) {
    .pace {
        display: none;
    }
}

@container ranking (max-width: 390px) {
    .pct {
        display: none;
    }
}

@container ranking (max-width: 330px) {
    .elo,
    th:nth-child(3) {
        display: none;
    }
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--muted);
    vertical-align: 1px;
}

.badge.anchor {
    border-color: var(--ink);
    color: var(--ink);
}

/* Pointillé : résultat non vérifié par le serveur. */
.badge.remote {
    border-style: dashed;
    border-color: var(--muted);
    color: var(--ink);
}

.side .badge {
    flex: none;
    margin-left: 0;
}

.duel-icon {
    flex: none;
    width: 1em;
    height: 1em;
    overflow: visible;
}

.duel-sword {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.duel-sword.red {
    stroke: var(--red);
}

.duel-sword.black {
    stroke: var(--pawn-rim);
}

.duel-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
    margin-left: 6px;
    padding: 1px 5px;
    border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--red) 8%, transparent);
    color: var(--ink);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
}

.team-line .duel-badge {
    flex: 0 1 auto;
    min-width: 0;
}

.duel-name {
    min-width: 2ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.duel-prob {
    flex: none;
    color: var(--muted);
}

button.duel-badge {
    cursor: pointer;
}

button.duel-badge:hover {
    background: color-mix(in srgb, var(--red) 16%, transparent);
}

button.duel-badge:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 1px;
}

.duel-badge.black {
    border-color: color-mix(in srgb, var(--pawn-rim) 55%, var(--line));
}

.empty {
    padding: 16px 8px;
    color: var(--muted);
}

.how {
    margin-top: 10px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.how summary {
    cursor: pointer;
    width: fit-content;
}

.how p {
    margin-top: 6px;
}

/* --- Soumission ------------------------------------------------------------------------------ */

.submit-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    font-size: 0.8125rem;
    color: var(--muted);
}

.field input[type='password'],
.file-button,
.primary {
    height: 2.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
}

.field input[type='password'] {
    width: 100%;
    padding: 0 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink);
}

/* Le vrai champ reste dans le DOM (clavier, lecteurs d'écran) mais invisible. */
.file {
    position: relative;
}

.file input {
    position: absolute;
    inset: auto 0 0;
    height: 2.5rem;
    opacity: 0;
    cursor: pointer;
}

.file-button {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px dashed var(--muted);
    color: var(--ink);
    pointer-events: none;
}

.file-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file input:focus-visible+.file-button {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

.file input:hover+.file-button {
    border-color: var(--ink);
}

.primary {
    padding: 0 18px;
    border: 0;
    background: var(--red);
    color: var(--red-ink);
    font-weight: 700;
    cursor: pointer;
}

.primary:hover {
    background: color-mix(in srgb, var(--red) 88%, var(--ink));
}

.primary:disabled {
    cursor: progress;
    opacity: 0.6;
}

.submit-status {
    margin-top: 10px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.submit-status[data-state] {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.submit-status[data-state='ok'] {
    color: var(--ok);
    font-weight: 600;
}

.submit-status[data-state='error'] {
    color: var(--red);
    font-weight: 600;
}

.submit-status[data-state='pending'] {
    color: var(--ink);
}

/* --- Replay ---------------------------------------------------------------------------------- */

.replay {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.replay-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
}

.replay-info {
    color: var(--muted);
    min-width: 0;
}

.share {
    margin-left: auto;
    padding: 2px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.share:hover {
    border-color: var(--ink);
}

.replay-info strong {
    color: var(--ink);
    font-weight: 700;
}

.board-wrap {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
}

.board {
    --mover: var(--red);
    display: grid;
    grid-template-columns: 1.5em repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(12, minmax(0, 1fr)) 1.5em;
    gap: clamp(2px, 0.35vmin, 4px);
    width: min(100%, 560px);
    aspect-ratio: 1;
    font-size: clamp(0.625rem, 0.5rem + 0.4vw, 0.8125rem);
}

.board[data-mover='black'] {
    --mover: var(--black-mark);
}

.board .label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.cell {
    position: relative;
    display: grid;
    place-items: center;
    background: var(--tile);
    border-radius: 3px;
}

/* Une case détruite est un trou dans le plateau, plus profond que le fond de la page. */
.cell.hole {
    background: var(--hole);
    box-shadow:
        inset 0 3px 6px rgb(0 0 0 / 0.65),
        inset 0 -1px 0 rgb(255 255 255 / 0.08);
}

.cell.from {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--mover) 55%, transparent);
}

.cell.to {
    box-shadow: inset 0 0 0 2px var(--mover);
}

.cell.destroyed-now {
    box-shadow:
        inset 0 0 0 2px var(--mover),
        inset 0 3px 6px rgb(0 0 0 / 0.65);
}

.pawn {
    width: 72%;
    aspect-ratio: 1;
    border-radius: 50%;
}

.pawn.red {
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--red) 70%, #fff), var(--red) 60%);
}

.pawn.black {
    background: radial-gradient(circle at 35% 30%, #3a4150, var(--pawn-black) 60%);
    box-shadow: 0 0 0 2px var(--pawn-rim);
}

.replay-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
}

.move {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.move-count {
    color: var(--muted);
    font-size: 0.875rem;
}

.move-text {
    font-size: 1.375rem;
    font-weight: 800;
    font-stretch: 75%;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.move-text .destroyed {
    color: var(--muted);
    font-weight: 600;
}

.replay-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 320px;
    max-width: 520px;
}

.icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.icon:hover {
    border-color: var(--ink);
}

.icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
}

.icon.play {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.icon.play .i-pause,
.icon.play.playing .i-play {
    display: none;
}

.icon.play.playing .i-pause {
    display: block;
}

input[type='range'] {
    flex: 1;
    min-width: 80px;
    accent-color: var(--red);
    cursor: pointer;
}

/* --- Parties récentes ------------------------------------------------------------------------ */

.games-list {
    list-style: none;
    margin: 0 -8px;
    padding: 0;
}

.game {
    display: grid;
    grid-template-columns: 4.25em minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    text-align: left;
    cursor: pointer;
}

.game:hover {
    background: var(--hover);
}

.game[aria-current='true'] {
    background: var(--hover);
    box-shadow: inset 3px 0 0 var(--red);
}

.game time,
.game .meta {
    color: var(--muted);
    font-size: 0.8125rem;
}

.game .meta {
    text-align: right;
    white-space: nowrap;
}

.side {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.side span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side::before {
    content: '';
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.side.red::before {
    background: var(--red);
}

.side.black::before {
    background: var(--pawn-black);
    box-shadow: 0 0 0 1.5px var(--pawn-rim);
}

.side .delta {
    flex: none;
    overflow: visible;
    font-size: 0.8125rem;
    font-weight: 400;
}

.delta.up {
    color: var(--ok);
}

.delta.down {
    color: var(--red);
}

.games-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    min-height: 1.5rem;
    margin-bottom: 10px;
}

.elo-chart {
    margin: 0 0 10px;
}

.games-head .match {
    margin-top: 0;
}

/* Leur display l'emporterait sur l'attribut hidden. */
.match[hidden],
.graph-link[hidden],
.verified[hidden] {
    display: none;
}

/* Paragraphe, pas lien : pas de survol. */
p.graph-link:hover {
    color: var(--muted);
}

.picker.games-picker {
    flex: none;
    margin-bottom: 10px;
}

.graph-link {
    display: block;
    margin: -2px 0 10px;
    color: var(--muted);
    font-size: 0.8125rem;
}

.graph-link:hover {
    color: var(--ink);
}

.elo-caption {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.elo-caption strong {
    color: var(--ink);
    font-size: 0.9375rem;
}

/* Le SVG s'étire ; curseur et point sont en HTML pour garder leur forme. */
.elo-plot {
    position: relative;
    height: 72px;
    cursor: crosshair;
    touch-action: pan-y;
}

.elo-plot svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.elo-plot polygon {
    fill: color-mix(in srgb, var(--red) 14%, transparent);
}

.elo-plot polyline {
    fill: none;
    stroke: var(--red);
    stroke-width: 2;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.elo-cursor {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--muted);
    pointer-events: none;
}

.elo-version {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px dashed var(--muted);
    pointer-events: none;
}

.elo-version::after {
    content: attr(data-label);
    position: absolute;
    top: -2px;
    left: 3px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.6875rem;
    line-height: 1.3;
}

.elo-version.end::after {
    left: auto;
    right: 3px;
}

.elo-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 2px var(--surface);
    pointer-events: none;
}

.elo-window {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.elo-window label {
    position: relative;
    padding: 2px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.elo-window input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.elo-window label:has(:checked) {
    background: color-mix(in srgb, var(--red) 14%, transparent);
    color: var(--ink);
    font-weight: 600;
}

.elo-window label:has(:focus-visible) {
    outline: 2px solid var(--red);
    outline-offset: 1px;
}

.side.winner {
    font-weight: 700;
}

.side:not(.winner) {
    color: var(--muted);
}

/* --- Graphe des rangs ------------------------------------------------------------------------- */

/* Plus précis que les grilles de .layout des media queries. */
.layout.graph-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: none;
}

.bump {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.bump-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
}

.bump-head .elo-window {
    margin-top: 0;
}

.bump-pick {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.picker {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 2.25rem;
    padding: 3px 64px 3px 4px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: text;
}

.picker:focus-within {
    border-color: var(--muted);
}

.chips {
    display: contents;
    list-style: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 1.75rem;
    padding: 0 2px 0 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.8125rem;
    cursor: default;
}

.chip.idle {
    color: var(--muted);
}

.chip.idle .chip-dot {
    opacity: 0.4;
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

.chip-remove {
    width: 1.375rem;
    height: 1.375rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 3px;
    color: var(--muted);
    line-height: 1;
    cursor: pointer;
}

.chip-remove:hover {
    background: var(--hover);
    color: var(--ink);
}

.picker-input {
    flex: 1 0 9rem;
    min-width: 0;
    height: 1.75rem;
    padding: 0 6px;
    background: none;
    border: 0;
}

.picker-input:focus-visible {
    outline: none;
}

.picker-icon {
    position: absolute;
    top: 50%;
    width: 1.75rem;
    height: 1.75rem;
    margin-top: -0.875rem;
    padding: 5px;
    background: none;
    border: 0;
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
}

.picker-icon:hover {
    background: var(--hover);
    color: var(--ink);
}

#picker-clear {
    right: 32px;
}

#picker-toggle {
    right: 4px;
}

.picker-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.picker-list {
    position: absolute;
    top: calc(100% + 4px);
    left: -1px;
    right: -1px;
    z-index: 10;
    max-height: 18rem;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
}

.picker-option {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) auto;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.picker-option:hover,
.picker-option[aria-selected='true'] {
    background: var(--hover);
}

.option-rank,
.option-elo {
    color: var(--muted);
}

.option-rank {
    text-align: right;
}

.picker-empty {
    padding: 6px 8px;
    color: var(--muted);
}

.picker-top {
    flex: none;
    height: 2.25rem;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}

.picker-top:hover {
    background: var(--hover);
}

.bump-figure {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.bump-plot {
    position: relative;
    flex: 1;
    min-height: 320px;
    cursor: crosshair;
    touch-action: pan-y;
}

.bump-plot svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    font-size: 0.75rem;
}

.bump-grid line {
    stroke: var(--line);
    stroke-width: 1;
}

.bump-grid text {
    fill: var(--muted);
}

.bump-grid .rank {
    text-anchor: end;
    dominant-baseline: middle;
}

.bump-lines path {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
}

.bump-lines path.bot {
    stroke-dasharray: 4 3;
}

/* Anneau de la couleur du fond : un nœud se détache des lignes qu'il recouvre. */
.bump-nodes circle {
    stroke: var(--surface);
    stroke-width: 2;
}

.bump-nodes .version-label {
    fill: var(--muted);
    font-size: 0.6875rem;
    text-anchor: middle;
    paint-order: stroke;
    stroke: var(--surface);
    stroke-width: 3px;
}

.bump-labels text {
    fill: var(--ink);
    dominant-baseline: middle;
}

.bump-plot:focus-visible {
    outline-offset: 4px;
}

#bump-svg [data-team] {
    transition: opacity 0.15s;
}

#bump-svg.focusing [data-team]:not(.on) {
    opacity: 0.2;
}

#bump-svg.focusing path.on {
    stroke-width: 3;
}

.bump-cursor {
    position: absolute;
    width: 1px;
    background: var(--muted);
    pointer-events: none;
}

.bump-tip {
    position: absolute;
    top: 0;
    z-index: 5;
    width: max-content;
    max-width: min(20rem, 100%);
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
    font-size: 0.8125rem;
    pointer-events: none;
}

.tip-when,
.tip-hint {
    color: var(--muted);
    font-size: 0.75rem;
}

.tip-game {
    margin: 2px 0 6px;
}

.tip-rows {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 2px 8px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
}

.tip-rows li {
    display: contents;
    color: var(--muted);
}

.tip-rows li.on {
    color: var(--ink);
    font-weight: 700;
}

.tip-rows li.played .tip-team::after {
    content: ' ●';
    font-size: 0.625rem;
    vertical-align: middle;
}

.tip-rows .chip-dot {
    align-self: center;
}

.tip-rank,
.tip-elo {
    text-align: right;
}

.bump-summary {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.8125rem;
}

/* --- Petits écrans ---------------------------------------------------------------------------- */

/* --- Tournoi --------------------------------------------------------------------------------- */

.layout.tournament-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: none;
}

.tournament {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.tournament-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px 24px;
}

.tournament-meta,
.next {
    color: var(--muted);
    font-size: 0.875rem;
}

.tournament-meta {
    margin-top: 2px;
}

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

.places li {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.875rem;
}

.places .place {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.places .first {
    border-color: var(--red);
    background: color-mix(in srgb, var(--red) 10%, transparent);
    font-weight: 700;
}

.bracket {
    flex: 1;
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 20px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.band {
    margin: 0 0 10px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--tile);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rounds {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 196px;
    column-gap: 40px;
    width: max-content;
}

.links {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.links path {
    fill: none;
    stroke: var(--black-mark);
    stroke-width: 1.5;
}

.round {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.round-title {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.round-matches {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 14px;
}

.match-wrap {
    display: grid;
    gap: 3px;
}

/* Deux exemptions : rien à montrer, mais la place garde l'alignement de l'arbre. */
.match-wrap:empty {
    min-height: 76px;
}

.match-id {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.match-state {
    padding: 0 6px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0;
}

.match-state.running {
    background: color-mix(in srgb, var(--ok) 18%, transparent);
    color: var(--ok);
}

.match-state.suspended {
    background: color-mix(in srgb, var(--red) 14%, transparent);
    color: var(--red);
}

.match-note {
    font-weight: 500;
    letter-spacing: 0;
}

.match {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.match.running {
    border-color: var(--ok);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 25%, transparent);
}

.match.suspended {
    border-color: var(--red);
    border-style: dashed;
}

.match.bye {
    opacity: 0.55;
}

.slot {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 28px;
    align-items: center;
    height: 28px;
    font-size: 0.875rem;
}

.slot+.slot {
    border-top: 1px solid var(--line);
}

.slot .seed {
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

.slot .name {
    overflow: hidden;
    padding-right: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot .score {
    align-self: stretch;
    display: grid;
    place-items: center;
    background: var(--tile);
    font-weight: 700;
}

.slot .score.prob {
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.slot.win .name {
    font-weight: 700;
}

.slot.win .score {
    background: var(--red);
    color: var(--red-ink);
}

.slot.lose .name,
.slot.tbd .name {
    color: var(--muted);
}

.slot.tbd .name {
    font-size: 0.8125rem;
    font-style: italic;
}

.match-games {
    display: flex;
    gap: 6px;
    color: var(--muted);
    font-size: 0.75rem;
}

.match-games a {
    color: var(--ink);
}

@media (max-width: 959px),
(max-height: 599px) {
    .ranking-scroll {
        max-height: calc(2rem + 7.5 * 2.25rem);
    }

    .games-list {
        max-height: 60vh;
    }

    .scroll {
        overscroll-behavior: auto;
    }

    .replay {
        padding: 4px 0;
    }
}

@media (max-width: 640px) {
    .masthead {
        align-items: flex-start;
        gap: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .title {
        font-size: 1.25rem;
    }

    .pages {
        order: 3;
        width: 100%;
        margin-right: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .pages a {
        flex: none;
        padding-inline: 10px;
    }

    .controls {
        margin-left: auto;
        justify-content: flex-end;
        gap: 4px 12px;
    }

    .session>span,
    .status {
        font-size: 0.75rem;
    }

    .layout {
        gap: 10px;
        padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    }

    .panel {
        padding: 12px;
        border-radius: 8px;
    }

    .duel-badge {
        margin-left: 4px;
        padding-inline: 4px;
    }

    .submit-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .game {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        row-gap: 2px;
    }

    .game time {
        grid-column: 1;
        grid-row: 2;
    }

    .game .meta {
        grid-column: 2;
        grid-row: 2;
    }

    .move-text {
        font-size: 1.125rem;
    }

    .replay-controls {
        max-width: none;
    }
}

/* Plein écran : le plateau prend toute la place libre de sa colonne. En fin de fichier pour
   l'emporter sur la taille par défaut de .board. */
@media (min-width: 960px) and (min-height: 600px) {
    .board-wrap {
        container-type: size;
    }

    .board {
        width: min(100cqw, 100cqh);
    }
}

@media (prefers-reduced-motion: reduce) {
    .live.pulse {
        animation: none;
    }

    .scroll::after,
    tbody td {
        transition: none;
    }
}
