/* ——— Spectate / games list page ——— */
.game-spectate-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.game-catalog-hero--spectate {
    background: linear-gradient(
        135deg,
        color-mix(in srgb, #8b5cf6 14%, var(--surface)) 0%,
        var(--surface) 50%,
        color-mix(in srgb, var(--accent) 10%, var(--surface)) 100%
    );
}

.game-catalog-hero--spectate .game-catalog-hero__icon {
    background: color-mix(in srgb, #8b5cf6 20%, var(--surface-soft));
    color: #7c3aed;
}

html.dark .game-catalog-hero--spectate {
    background: linear-gradient(135deg, #141414 0%, var(--surface) 52%, #101010 100%);
}

html.dark .game-catalog-hero--spectate .game-catalog-hero__icon {
    background: #242424;
    color: #c4b5fd;
}

.game-spectate-stats {
    margin-bottom: 0;
}

.game-spectate-page .game-card {
    margin-bottom: 0;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.game-spectate-section-head {
    margin-bottom: 16px;
}

.game-spectate-section-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 6px;
}

.game-spectate-section .game-card-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.02rem;
}

.game-spectate-section .game-card-title i {
    color: var(--muted);
    font-size: 0.92rem;
}

.game-spectate-section-hint {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    max-width: 62ch;
}

.game-spectate-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, #22c55e 14%, var(--surface));
    border: 1px solid color-mix(in srgb, #22c55e 35%, var(--border));
    color: #15803d;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

html.dark .game-spectate-live-badge {
    color: #86efac;
}

.game-spectate-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    animation: spectate-live-pulse 1.4s ease-in-out infinite;
}

@keyframes spectate-live-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.45;
        transform: scale(0.85);
    }
}

.spectate-match-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.spectate-match-list--history {
    gap: 16px;
}

.game-spectate-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 16px;
    text-align: center;
    border-radius: 12px;
    border: 1px dashed color-mix(in srgb, var(--border) 90%, var(--muted));
    background: var(--surface-soft);
}

.game-spectate-empty--compact {
    padding: 22px 14px;
}

.game-spectate-empty i {
    font-size: 1.75rem;
    color: var(--muted);
    opacity: 0.75;
}

.game-spectate-empty p {
    margin: 0;
    max-width: 36ch;
    font-size: 0.9rem;
    line-height: 1.45;
}

/* ——— Match cards ——— */
.spectate-match-card,
.history-match-card {
    padding: 16px 18px 18px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.spectate-match-card:hover {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.spectate-match-card__head,
.history-match-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px 16px;
    margin-bottom: 16px;
}

.spectate-match-card__actions {
    display: flex;
    flex-shrink: 0;
    align-items: flex-start;
}

.spectate-match-watch-form {
    margin: 0;
}

.spectate-match-action {
    gap: 8px;
    min-height: 38px;
    padding: 8px 14px;
    font-size: 0.88rem;
    white-space: nowrap;
}

.spectate-match-action.is-disabled {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.history-match-card__mode {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.history-match-card__mode-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    color: #fff;
}

.history-match-card__mode-icon--classic {
    background: linear-gradient(145deg, #64748b, #475569);
}

.history-match-card__mode-icon--competitive {
    background: linear-gradient(145deg, #f59e0b, #d97706);
}

.history-match-card__title {
    margin: 0 0 4px;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.25;
}

.history-match-card__meta {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.4;
}

.history-match-card__players {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px 16px;
}

.history-match-card__side {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.history-match-card__side:first-child {
    justify-content: flex-end;
}

.history-match-card__side:last-child {
    justify-content: flex-start;
}

.history-match-card__vs {
    font-size: 1.1rem;
    line-height: 1;
    color: var(--accent);
    text-align: center;
    user-select: none;
    opacity: 0.85;
}

.history-match-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    max-width: 120px;
    text-align: center;
}

.history-match-player__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface) center/cover no-repeat;
    border: 2px solid color-mix(in srgb, var(--border) 80%, transparent);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.history-match-player__avatar--ph {
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--muted);
}

.history-match-player__name {
    max-width: 100%;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-match-player__name:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.history-match-player__name--plain {
    text-decoration: none;
}

.history-match-player__name--plain:hover {
    color: var(--text);
    text-decoration: none;
}

.history-match-player__stats {
    margin: 0;
    font-size: 0.74rem;
    line-height: 1.3;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .spectate-match-card__head,
    .history-match-card__head {
        flex-direction: column;
        align-items: stretch;
    }

    .spectate-match-card__actions {
        width: 100%;
    }

    .spectate-match-action {
        width: 100%;
    }

    .history-match-card__players {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .history-match-card__vs {
        order: -1;
    }

    .history-match-card__side,
    .history-match-card__side:first-child,
    .history-match-card__side:last-child {
        justify-content: center;
    }
}

/* ——— Replay page (unchanged scope, token cleanup) ——— */
.replay-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 8px 0 40px;
}

.replay-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 20px 24px;
    align-items: start;
}

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

.replay-board-wrap {
    width: 100%;
    max-width: min(100%, 720px);
    margin: 0 auto;
}

.board-center-frame--replay {
    display: grid;
    place-items: center;
    min-height: 100%;
    padding: 12px;
}

.replay-center-hint {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.replay-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.92rem;
}

.replay-status-bar__turn {
    font-weight: 700;
}

.replay-status-bar__action {
    flex: 1 1 100%;
    font-size: 0.88rem;
    color: var(--text);
}

.replay-players {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.replay-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.replay-player--active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.replay-player--out {
    opacity: 0.45;
}

.replay-player__token {
    position: static !important;
    transform: none !important;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 50%;
}

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

.replay-player__info strong {
    font-size: 0.9rem;
}

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

.replay-back {
    margin: 0 0 16px;
}

.replay-head h2 {
    margin: 0 0 6px;
}

.replay-controls {
    margin: 0;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.replay-controls__transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.replay-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.replay-speed select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
}

.replay-time {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-size: 0.88rem;
    color: var(--muted);
}

.replay-scrubber {
    width: 100%;
    height: 8px;
    accent-color: var(--accent);
    cursor: pointer;
}

.replay-feed {
    max-height: min(72vh, 640px);
    overflow: auto;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.replay-entry {
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.35;
    transition: opacity 0.15s;
}

.replay-entry--visible {
    opacity: 1;
}

.replay-entry--highlight {
    opacity: 1;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    margin: 0 -8px;
    padding: 8px;
    border-radius: 8px;
}

.replay-entry time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    margin-right: 8px;
    font-size: 0.8rem;
}

.replay-entry-kind {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-right: 6px;
}

.replay-entry-actor {
    font-weight: 600;
    margin-right: 4px;
}

.replay-entry--system {
    color: var(--muted);
}

.replay-entry--move .replay-entry-kind {
    color: #34d399;
}

.replay-entry--move {
    font-weight: 500;
}

.replay-error {
    margin-top: 12px;
    color: var(--danger);
}

@media (max-width: 960px) {
    .replay-layout {
        grid-template-columns: 1fr;
    }

    .replay-side {
        order: 2;
    }

    .replay-board-wrap {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .replay-time {
        margin-left: 0;
        width: 100%;
    }
}
