:root {
    --board-columns: 19;
    --board-rows: 19;
    --board-width: min(92vw, 720px);
    --board-bg: #f0d9b5;
    --board-border: #8b4513;
    --cell-border: rgba(107, 62, 20, 0.78);
    --cell-hover-bg: rgba(0, 0, 0, 0.08);
    --cell-selected-bg: rgba(0, 255, 0, 0.2);
    --cell-valid-bg: rgba(0, 255, 0, 0.1);
    --cell-last-move-bg: rgba(255, 215, 0, 0.28);
    --piece-size: 88%;
    --go-black-piece-top: #66605a;
    --go-black-piece-mid: #47423d;
    --go-black-piece-bottom: #2f2b28;
    --go-white-piece-top: #f7f3eb;
    --go-white-piece-mid: #ece5da;
    --go-white-piece-bottom: #d8cfc2;
}

.chessboard-stack {
    display: flex;
    flex-direction: column;
    align-self: center;
    width: var(--board-width);
    max-width: 100%;
}

/* ========== 统计条（三栏布局） ========== */
.go-stats-strip {
    width: 100%;
    height: 44px;
    border: 1px solid rgba(201, 169, 98, 0.18);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 10px 24px rgba(26, 26, 26, 0.05);
    overflow: hidden;
    display: flex;
    flex-shrink: 0;
}

.go-stats-strip-label {
    flex-shrink: 0;
    background: rgba(240, 217, 181, 0.95);
    border-right: 1px solid rgba(102, 90, 76, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.4rem;
    font-weight: 600;
    color: #5a4a3a;
    letter-spacing: 0.04em;
}

.go-stats-strip-track {
    flex: 1;
    display: flex;
}

.go-stats-strip-fill {
    transition: flex-grow 0.28s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0 0.6rem;
    min-width: 80px;
}

.go-stats-strip-fill--black {
    flex-grow: var(--go-stats-black-grow, 1);
    flex-shrink: 1;
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.12), transparent 34%),
        linear-gradient(150deg, #66605a 0%, #47423d 58%, #2f2b28 100%);
    color: #f1ece4;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.go-stats-strip-fill--white {
    flex-grow: var(--go-stats-white-grow, 1);
    flex-shrink: 1;
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.92), transparent 38%),
        linear-gradient(150deg, #f7f3eb 0%, #ece5da 62%, #d8cfc2 100%);
    color: #3d3834;
    border-left: 1px solid rgba(102, 90, 76, 0.12);
}

.go-stats-strip-fill--info {
    flex-shrink: 0;
    width: 160px;
    background: rgba(240, 217, 181, 0.95);
    border-left: 1px solid rgba(102, 90, 76, 0.18);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.9rem;
    line-height: 1.3;
    color: #3d3834;
    text-align: right;
    white-space: nowrap;
}

.go-stats-label {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.go-stats-value {
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.go-stats-unit {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.go-stats-strip-fill--info span {
    font-weight: 500;
    letter-spacing: 0.03em;
}

/* 房间信息框内的手数显示 */
#game-room-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

#game-move-counter {
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a4a3a;
    opacity: 0.85;
}

/* ========== 棋盘 ========== */
.chessboard {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    background:
        radial-gradient(circle at center, rgba(255, 255, 255, 0.12), transparent 70%),
        var(--board-bg);
}

.cell {
    border: none;
    overflow: visible;
    isolation: isolate;
}

.cell::before,
.cell::after {
    content: '';
    position: absolute;
    background-color: var(--cell-border);
    pointer-events: none;
    z-index: 0;
}

.cell::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    transform: translateY(-50%);
}

.cell::after {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
}

.cell[data-col="0"]::before {
    left: 50%;
}

.cell[data-col="18"]::before {
    right: 50%;
}

.cell[data-row="0"]::after {
    top: 50%;
}

.cell[data-row="18"]::after {
    bottom: 50%;
}

/* 星位 */
.cell[data-row="3"][data-col="3"],
.cell[data-row="3"][data-col="9"],
.cell[data-row="3"][data-col="15"],
.cell[data-row="9"][data-col="3"],
.cell[data-row="9"][data-col="9"],
.cell[data-row="9"][data-col="15"],
.cell[data-row="15"][data-col="3"],
.cell[data-row="15"][data-col="9"],
.cell[data-row="15"][data-col="15"] {
    background-image: radial-gradient(circle at center, var(--cell-border) 0 9%, transparent 10%);
    background-repeat: no-repeat;
}

.cell:hover,
.cell.selected,
.cell.valid-move,
.cell.last-move {
    background-color: transparent;
}

.cell:hover {
    background-color: var(--cell-hover-bg);
}

.cell.last-move {
    background-color: var(--cell-last-move-bg);
}

/* ========== 棋子 ========== */
.piece {
    width: var(--piece-size);
    height: var(--piece-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.piece.black {
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.24), transparent 34%),
        linear-gradient(150deg, var(--go-black-piece-top) 0%, var(--go-black-piece-mid) 58%, var(--go-black-piece-bottom) 100%);
    color: #f1ece4;
    box-shadow:
        0 7px 16px rgba(47, 43, 40, 0.28),
        inset 0 1px 1px rgba(255, 255, 255, 0.16),
        inset 0 -5px 8px rgba(22, 20, 18, 0.3);
}

.piece.white {
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.96), transparent 38%),
        linear-gradient(150deg, var(--go-white-piece-top) 0%, var(--go-white-piece-mid) 62%, var(--go-white-piece-bottom) 100%);
    color: #4f4942;
    border: 1px solid rgba(102, 90, 76, 0.18);
    box-shadow:
        0 7px 16px rgba(116, 104, 92, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        inset 0 -4px 7px rgba(170, 160, 148, 0.22);
}

.cell.last-move .piece::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18%;
    height: 18%;
    background-color: rgba(255, 0, 0, 0.7);
    border-radius: 50%;
    z-index: 10;
}

/* ========== 响应式 ========== */
@media (min-width: 1179px) {
    :root {
        --board-width: min(100%, 820px, 100cqh);
    }

    .game-layout {
        container-type: size;
    }

    .chessboard {
        flex: 0 1 auto;
        width: min(100%, 820px, 100cqh);
        max-width: 820px;
        max-height: 100cqh;
        height: auto !important;
        margin: 0 auto;
    }
}

@media (min-width: 1280px) {
    :root {
        --board-width: min(100%, 820px, 100cqh);
    }

    .game-layout {
        gap: clamp(1.6rem, 2vw, 2.4rem);
    }

    .game-sidebar {
        flex: 0 0 220px;
        max-width: 220px;
    }

    .chessboard {
        flex: 0 1 auto;
        width: min(100%, 820px, 100cqh);
        max-width: 820px;
        max-height: 100cqh;
        height: auto !important;
        margin: 0 auto;
    }
}

@media (min-width: 1179px) and (max-height: 850px) {
    .game-layout {
        align-items: flex-start;
    }
}

@media (max-width: 1024px) {
    :root {
        --board-width: min(85vw, 85dvh);
    }
}

@media (max-width: 1178px) {
    .right-sidebar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .right-sidebar > * {
        min-width: 0;
    }

    #game-room-info,
    #game-scoreboard {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .go-stats-strip {
        height: 36px;
    }

    .go-stats-strip-label {
        width: 50px;
        font-size: 0.5rem;
        padding: 0 0.3rem;
    }

    .go-stats-label {
        font-size: 0.54rem;
    }

    .go-stats-value {
        font-size: 0.8rem;
    }

    .go-stats-unit {
        font-size: 0.52rem;
    }

    .go-stats-strip-fill {
        gap: 0.15rem;
        padding: 0 0.35rem;
        min-width: 60px;
    }

    .go-stats-strip-fill--info {
        width: 130px;
        font-size: 0.62rem;
        padding: 0.1rem 0.35rem;
    }
}
