/* =========================================================
   1. БЛОК "СМОТРЕТЬ" (ТАБЛИЦА — 6 КОЛОНОК)
   ========================================================= */

.watch {
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.watch-table-wrap {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: var(--c-paper, #fff);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(181, 114, 44, 0.1);
    overflow: hidden;
}

.watch-table { width: 100%; }

/* Сетка (Flex) */
.watch-head, .watch-row {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--c-line, #f0ede8);
    width: 100%;
    box-sizing: border-box;
}

.watch-head {
    background: rgba(44, 24, 16, 0.03);
    font-weight: 600;
    color: var(--c-ink-soft, #7a6b63);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.watch-row:hover { background: rgba(181, 114, 44, 0.04); }
.watch-row:last-child { border-bottom: none; }

/* Жесткие ширины колонок */
.col-status  { width: 100px; flex-shrink: 0; }
.col-player  { width: 180px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.col-mode    { width: 90px;  flex-shrink: 0; display: flex; justify-content: center; }
.col-result  { width: 140px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.col-action  { flex: 1; display: flex; justify-content: flex-end; }

/* Выравнивание заголовков */
.watch-head .col-status  { text-align: left; }
.watch-head .col-player  { text-align: left; }
.watch-head .col-mode    { text-align: center; justify-content: center; }
.watch-head .col-result  { text-align: left; }
.watch-head .col-action  { text-align: right; }

/* Элементы таблицы */
.watch-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #7a6b63; }
.watch-status.live { color: #e74c3c; }
.watch-status.live .dot { width: 8px; height: 8px; background: #e74c3c; border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(1.3); } 100% { opacity: 1; transform: scale(1); } }
.watch-status.finished { color: #7a6b63; }

/* Твои аватарки */
.avatar { width: 10px; height: 10px; background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }

.watch-mode { padding: 3px 8px; background: rgba(181, 114, 44, 0.1); color: #b5722c; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: capitalize; }

.result-badge { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.result-badge.win { color: #27ae60; background: rgba(39, 174, 96, 0.1); }
.result-badge.draw { color: #7a6b63; background: rgba(122, 107, 99, 0.1); }
.reason-text { font-size: 10px; color: #9a8a7a; }

.watch-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 12px; background: #b5722c; color: #fff; border-radius: 6px; font-size: 11px; font-weight: 600; text-decoration: none; transition: all 0.2s ease; white-space: nowrap; border: none; cursor: pointer; }
.watch-btn:hover { background: #9a5f24; }
.watch-btn.secondary { background: transparent; color: #2c1810; border: 1px solid #e5e0d8; }
.watch-btn.secondary:hover { background: rgba(44, 24, 16, 0.05); border-color: #b5722c; }

@media (max-width: 900px) {
    .watch-head { display: none; }
    .watch-row { flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; }
    .col-status, .col-player, .col-mode, .col-result, .col-action { width: 100%; justify-content: flex-start; margin-left: 0; }
    .col-action { margin-top: 8px; }
    .watch-btn { width: 100%; justify-content: center; }
}


/* =========================================================
   2. ТВ-МОДАЛКА С ДОСКОЙ И ХОДАМИ
   ========================================================= */

.tv-modal {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.tv-modal[hidden] { display: none; }

.tv-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    cursor: pointer;
}

.tv-container {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    width: 100%; max-width: 860px; 
    background: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    overflow: hidden; z-index: 1;
}

/* --- НОВАЯ ШАПКА С КНОПКАМИ --- */
.tv-header {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; background: #111;
    border-bottom: 1px solid #333; color: #fff;
    box-sizing: border-box;
}

.tv-title { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; color: #b5722c; }

/* Контейнер для кнопок справа */
.tv-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Кнопки-иконки в шапке */
.tv-btn-icon {
    background: transparent;
    border: 1px solid #333;
    color: #9a8a7a;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    padding: 0;
}

.tv-btn-icon:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-color: #555;
}

/* Кнопка тренера (выделяем цветом) */
.tv-btn-coach {
    color: #b5722c;
    border-color: rgba(181, 114, 44, 0.3);
}
.tv-btn-coach:hover {
    background: rgba(181, 114, 44, 0.2);
    color: #e6a34a;
    border-color: #b5722c;
}

/* Кнопка закрытия */
.tv-close {
    background: transparent; border: none; color: #9a8a7a;
    font-size: 20px; cursor: pointer; width: 32px; height: 32px;
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.tv-close:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* Экран */
.tv-screen {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

/* Две колонки */
.tv-content {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
}

/* Левая колонка (доска) */
.tv-board-col {
    flex: 0 0 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#tvBoardWrap {
    width: 100%;
    max-width: 500px;
}

/* Сама доска */
#tvBoard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin: 0 auto;
    position: relative;
}

/* Клетки */
#tvBoard .sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

/* Твои цвета клеток */
#tvBoard .sq.light { background: var(--c-board-light, #f0d9b5); }
#tvBoard .sq.dark  { background: var(--c-board-dark, #b58863); }

#tvBoard .sq .piece {
    font-size: inherit;
    line-height: 1;
    z-index: 2;
}

#tvBoard .sq .piece.white {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
#tvBoard .sq .piece.black {
    color: #000;
    text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}

/* Подсветка "куда" */
#tvBoard .sq.last-move-to {
    background-color: #e6a34a !important; 
}

.tv-players {
    margin-top: 15px; 
    color: #fff; 
    display: flex; 
    justify-content: space-between; 
    width: 100%;
    font-size: 14px;
}

/* Блок ответа тренера (под доской) */
.tv-coach-box {
    margin-top: 15px;
    padding: 12px;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
}
.tv-coach-box strong { color: #b5722c; }

/* Правая колонка (ходы) */
.tv-moves-col {
    flex: 1;
    min-width: 200px;
    max-width: 260px;
    height: 500px;
    background: #111;
    border-radius: 8px;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tv-moves-header {
    padding: 12px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    color: #b5722c;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tv-moves-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: monospace;
    font-size: 14px;
    color: #e2e8f0;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

/* Строка хода */
.tv-move-row {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
}
.tv-move-row:hover { background: rgba(255,255,255,0.05); }
/* .tv-move-row.current { background: rgba(181, 114, 44, 0.2); } */

.tv-move-num {
    width: 30px;
    color: #64748b;
    flex-shrink: 0;
}
.tv-move-white, .tv-move-black {
    flex: 1;
    font-weight: 600;
}
.tv-move-black {
    color: #9a8a7a;
}

/* Адаптивность */
/* Адаптивность */
@media (max-width: 900px) {
    /* Модалка */
    .tv-modal {
        padding: 10px;
    }
    .tv-container {
        max-width: 100%;
        border-radius: 8px;
    }
    .tv-screen {
        padding: 12px;
    }

    /* Колонки друг под другом */
    .tv-content {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    .tv-board-col {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
    }

    /* Доска и фигуры */
    #tvBoard {
        max-width: 100%;
        border-radius: 4px;
    }
    #tvBoard .sq {
        font-size: 28px; /* Уменьшили фигуры для мобилок */
    }

    /* Список ходов */
    .tv-moves-col {
        width: 100%;
        max-width: 100%;
        height: auto;         /* Убираем жесткую высоту */
        max-height: 250px;    /* Ограничиваем, чтобы не улетал вниз */
        flex: 1 1 auto;
    }
    .tv-moves-list {
        max-height: 200px;    /* Скролл внутри списка */
        overflow-y: auto;
        padding: 8px;
    }

    /* Кнопки в шапке */
    .tv-header {
        padding: 10px 12px;
    }
    .tv-title {
        font-size: 12px;
    }
    .tv-btn-icon, .tv-close {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* Игроки под доской */
    .tv-players {
        font-size: 12px;
        margin-top: 10px;
    }

    /* Блок тренера */
    .tv-coach-box {
        font-size: 12px;
        padding: 10px;
    }
}

