/* ==================== Page spectateur ==================== */
/* Même fenêtre que la partie (classes sandbox__*), en lecture seule */

.watch__layout[hidden],
.watch--message .watch__layout { display: none !important; }

.watch .sandbox__moves-panel[hidden] { display: none; }
.watch .sandbox__moves-panel.is-empty .moves-panel__content { visibility: hidden; }

/* En-tête de la colonne de gauche : retour, mode, spectateur en direct, état, équipes ou score */
.watch-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-lg, 3px);
    border: 1px solid rgba(242, 112, 15, 0.3);
    background: linear-gradient(135deg, rgba(242, 112, 15, 0.10), rgba(255, 138, 61, 0.08));
}

.watch-head__row { display: flex; align-items: center; gap: 8px; min-width: 0; }

.watch-bar__back { flex-shrink: 0; }

.watch-bar__live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 2px;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: help;
}

.watch-bar__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    animation: multi-pulse 2s infinite;
}

.watch-bar__mode {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
}

.watch-bar__mode .game-card__private { font-size: 0.7rem; }

.watch-bar__teams,
.watch-bar__rush {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
    font-weight: 700;
}

.watch-bar__teams[hidden],
.watch-bar__rush[hidden] { display: none; }

.watch-bar__team {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.watch-bar__team--white { color: #f9fafb; }
.watch-bar__team--black { color: #9ca3af; }
.watch-bar__vs { color: #ff8a3d; }

.watch-bar__team.is-turn {
    text-decoration: underline;
    text-decoration-color: #ff8a3d;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
}

.watch-bar__chip {
    padding: 2px 8px;
    border-radius: 2px;
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    font-size: 0.8rem;
}

.watch-bar__stat { white-space: nowrap; font-size: 0.9rem; }
.watch-bar__stat b { font-family: 'JetBrains Mono', monospace; color: var(--text-primary); }
.watch-bar__label { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; }
.watch-bar__hearts { white-space: nowrap; font-size: 0.85rem; }

@media (max-width: 480px) {
    .watch-bar__live-text { display: none; }
    .watch-bar__mode { font-size: 0.95rem; }
}

/* Votes : la liste garde une hauteur minimale, l'historique en dessous bouge moins */
:is(#watch-votes, #h24-votes) { min-height: 96px; }

/* Coups disponibles : visibles mais pas cliquables, colorés comme les votes */
#watch-moves .moves-group button {
    cursor: default;
    opacity: 1;
    pointer-events: none;
}

.watch__board { width: 100%; }

.watch__board .watch-last {
    box-shadow: inset 0 0 0 100px rgba(245, 200, 66, 0.42);
}

.watch .board-container { position: relative; }

/* Minuteur du tour : à côté de l'échiquier, jamais par-dessus */
.watch__timer {
    position: absolute;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.watch__timer[hidden] { display: none; }

.watch__timer-ring { width: 72px; height: 72px; }
.watch__timer-ring svg { width: 100%; height: 100%; }

.watch__timer-ring circle:first-child {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 4;
}

.watch__timer-ring circle:last-child {
    fill: none;
    stroke: #8a9b0f;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 283 283;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dasharray 0.25s linear;
}

.watch__timer.is-critical .watch__timer-ring circle:last-child { stroke: #e0245e; }
.watch__timer.is-paused .watch__timer-ring circle:last-child { stroke: #ff9800; }

.watch__timer-value {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    min-width: 56px;
    text-align: center;
}

.watch__timer.is-paused .watch__timer-value { color: #ff9800; }

.watch__player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    margin: 6px 0;
    font-weight: 600;
}

.watch__player[hidden] { display: none; }

.watch__dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
}

.watch__dot--white { background: #f4eee8; }
.watch__dot--black { background: #111; }

.watch__name { color: var(--text-primary); text-decoration: none; }
.watch__name:hover { text-decoration: underline; }
.watch__twitch { color: var(--twitch-purple); font-size: 0.85rem; }
.watch__muted { color: var(--text-muted); font-style: italic; }

.watch__status {
    min-height: 1.4em;
    line-height: 1.4;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.watch__status.is-over { color: var(--accent-orange); }

.watch__message { margin-top: 40px; }
.watch__message[hidden] { display: none; }

/* ==================== Spectateurs (joueurs et spectateurs) ==================== */

.spectators-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 2px;
    border: 1px solid rgba(242, 112, 15, 0.4);
    background: rgba(242, 112, 15, 0.12);
    color: var(--accent-cyan, #f2700f);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.spectators-badge[hidden],
.spectators-panel[hidden] { display: none !important; }

.spectators-panel__count {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-cyan, #f2700f);
}

.spectators {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.spectators__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 2px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8rem;
    text-decoration: none;
}

a.spectators__chip:hover { border-color: rgba(242, 112, 15, 0.6); }
.spectators__chip i { color: var(--text-muted); font-size: 0.7rem; }

.spectators__chip.is-me {
    border-color: rgba(242, 112, 15, 0.7);
    background: rgba(242, 112, 15, 0.15);
}

.spectators__me {
    font-size: 0.7rem;
    color: var(--accent-cyan, #f2700f);
}

.spectators__chip--anon { color: var(--text-secondary); font-style: italic; }

.spectators__empty,
.spectators__login {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.spectators__login { margin-top: 8px; }
.spectators__login[hidden] { display: none; }

.game-card__spectators {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-cyan, #f2700f);
}


/* Minuteur : à droite de l'échiquier quand la colonne a la place (comme chez les joueurs) */
:is(#page-watch, #page-h24) .board-wrapper { container-type: inline-size; position: relative; }

:is(#page-watch, #page-h24) .watch__player { max-width: 560px; margin-left: auto; margin-right: auto; }

@container (min-width: 640px) {
    :is(#page-watch, #page-h24) .board-container { max-width: min(560px, calc(100cqi - 220px)); margin-left: auto; margin-right: auto; }
    :is(#page-watch, #page-h24) .watch__timer { left: calc(50% + min(280px, 50cqi - 110px) + 16px); }
}

/* ==================== Roue / bande de tirage (spectateur) ==================== */
:is(#watch-wheel-area, #h24-wheel-area) { display: none; margin-top: 12px; }
:is(#watch-wheel-area, #h24-wheel-area).is-visible { display: block; }
/* Bande : place gardée entre deux tours (pas de saut de page) */
:is(#watch-wheel-area, #h24-wheel-area).is-reserved { display: block; visibility: hidden; min-height: 64px; }
:is(#watch-wheel-area, #h24-wheel-area).is-reserved.is-visible { visibility: visible; }

:is(#watch-wheel-area, #h24-wheel-area).wheel-area--band { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
:is(#watch-wheel-area, #h24-wheel-area).is-spinning .wheel-band {
    outline: 2px solid var(--accent-purple);
    box-shadow: 0 0 24px rgba(255, 138, 61, 0.4);
}

:is(#watch-wheel-area, #h24-wheel-area) .wheel-container {
    width: var(--wheel-size);
    height: var(--wheel-size);
    background: rgba(16, 13, 11, 0.95);
    border-radius: 50%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 3px var(--accent-purple, #ff8a3d), 0 0 60px rgba(255, 138, 61, 0.3);
}

:is(#watch-wheel-area, #h24-wheel-area) .wheel-canvas {
    width: var(--wheel-size) !important;
    height: var(--wheel-size) !important;
}

:is(#watch-wheel-area, #h24-wheel-area) .wheel-center {
    width: var(--wheel-center-size);
    height: var(--wheel-center-size);
    font-size: calc(var(--wheel-center-size) * 0.35);
}

/* Roue classique : cachée pendant le remplissage, visible dans la dernière seconde puis pendant le tirage */
:is(#watch-wheel-area, #h24-wheel-area) { transition: opacity 0.9s ease, transform 0.9s ease; }
:is(#watch-wheel-area, #h24-wheel-area).wheel-area--band:not(.is-spinning):not(.is-soon) {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
    pointer-events: none;
    animation: none;
}

/* ================================================ Mise en page de la partie (comme chez les joueurs) */
:is(#page-watch, #page-h24) { --sidebar-width: clamp(380px, 30vw, 470px); }

@media (max-width: 1100px) {
    :is(#page-watch, #page-h24) { --sidebar-width: clamp(280px, 30vw, 330px); }
}

@media (max-width: 900px) {
    :is(#page-watch, #page-h24) { --sidebar-width: clamp(300px, 36vw, 360px); }
}

@media (max-width: 760px) {
    :is(#page-watch, #page-h24) { --sidebar-width: calc(100vw - 24px); }
    /* Mobile : la partie regardée d'abord, puis 👁 / retourner juste au-dessus de l'échiquier */
    :is(#page-watch, #page-h24) .sandbox__left { order: -2; }
    :is(#page-watch, #page-h24) .sandbox__sidebar > .sandbox__actions { order: 0; }
}

/* Roue classique posée à la place du podium : l'encart gère son apparition */
:is(#watch-wheel-area, #h24-wheel-area).wheel-area--docked { margin: 0; }
:is(#watch-wheel-area, #h24-wheel-area).wheel-area--docked .wheel-container { background: rgba(16, 13, 11, 0.95); }

/* Chrono : jamais par-dessus l'échiquier
   560–639 px de colonne : côte à côte, l'échiquier cède la place
   < 560 : chrono compact au-dessus de l'échiquier */
:is(#page-watch, #page-h24) .sandbox__main { container: watch-col / inline-size; }

@container watch-col (max-width: 639.98px) {
    :is(#page-watch, #page-h24) .board-wrapper:has(> .watch__timer:not([hidden])) {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
    }

    :is(#page-watch, #page-h24) .board-wrapper:has(> .watch__timer:not([hidden])) > .board-container {
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
    }

    :is(#page-watch, #page-h24) .watch__timer { position: static; flex: none; padding: 8px; }
    :is(#page-watch, #page-h24) .watch__timer-ring { width: 64px; height: 64px; }
}

@container watch-col (max-width: 559.98px) {
    :is(#page-watch, #page-h24) .board-wrapper:has(> .watch__timer:not([hidden])) {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    :is(#page-watch, #page-h24) .watch__timer {
        order: -1;
        flex-direction: row;
        justify-content: center;
        align-self: center;
        padding: 4px 10px;
    }

    :is(#page-watch, #page-h24) .watch__timer-ring { width: 50px; height: 50px; }
    :is(#page-watch, #page-h24) .watch__timer .countdown__label { display: none; }
}
