.game-scoreboard-side.red {
    --score-panel-highlight: rgba(255, 242, 238, 0.28);
    --score-panel-highlight-stop: 40%;
    --score-panel-top: #d35a4d;
    --score-panel-mid: #b3372a;
    --score-panel-bottom: #84261f;
    --score-panel-text: #fff3ed;
    --score-panel-border: rgba(179, 55, 42, 0.2);
    --score-panel-shadow: rgba(138, 45, 37, 0.22);
    --score-panel-inner-top: rgba(255, 255, 255, 0.16);
    --score-panel-inner-bottom: rgba(106, 24, 18, 0.2);
}

.game-scoreboard-side.black {
    --score-panel-highlight: rgba(255, 255, 255, 0.16);
    --score-panel-highlight-stop: 38%;
    --score-panel-top: #536779;
    --score-panel-mid: #34495e;
    --score-panel-bottom: #1f2d3a;
    --score-panel-text: #eef4f8;
    --score-panel-border: rgba(52, 73, 94, 0.2);
    --score-panel-shadow: rgba(34, 48, 62, 0.2);
    --score-panel-inner-top: rgba(255, 255, 255, 0.12);
    --score-panel-inner-bottom: rgba(19, 28, 36, 0.2);
}

.chessboard {
    padding: 1.495cqi 1.6cqi 1.585cqi 1.5cqi;
    width: 100%;
    max-width: 700px;
    aspect-ratio: 7 / 8;
    margin: 0 auto;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(9, minmax(0, 1fr));
    border: 2px solid #8b4513;
    background-image: url('table.png');
    background-size: 100% 100%;
    background-position: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    container-type: inline-size;
}

.cell {
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    min-width: 0;
    transition: background-color 0.2s ease;
    width: 100%;
}

.cell:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.cell.selected {
    background-color: rgba(100, 200, 100, 0.5);
}

.cell.valid-move {
    background-color: rgba(100, 200, 100, 0.5) !important;
    z-index: 2;
}

.cell.last-move {
    background-color: rgba(100, 149, 237, 0.5) !important;
    z-index: 1;
}

/* 水域格子样式 */
.cell.water {
    background-color: rgba(64, 164, 223, 0.25);
}

/* 陷阱格子样式 */
.cell.trap {
    background-color: rgba(200, 160, 60, 0.2);
}

/* 兽穴格子样式 */
.cell.den {
    background-color: rgba(200, 60, 60, 0.15);
}

.piece {
    width: 105%;
    height: 105%;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.7rem, 4.5cqi, 2rem);
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(135, 102, 58, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 251, 240, 0.62), inset 0 0 0 2px rgba(248, 235, 198, 0.18), inset 0 -1px 0 rgba(166, 131, 83, 0.2), 0 2px 4px rgba(0, 0, 0, 0.18);
}

.piece:hover {
    transform: scale(1.1);
}

.piece.moving {
    transition: transform 0.3s ease-in-out;
}

.piece.captured {
    animation: capture 0.5s ease-in-out forwards;
}

@keyframes capture {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* 红方棋子：暖色底 + 红色文字 + 红框 */
.piece.red {
    background: #f2d4b0;
    color: #a02020;
    text-shadow: 0 1px 0 rgba(255, 249, 240, 0.35);
    border: 5px solid #b3372a;
}

/* 黑方棋子：冷色底 + 深色文字 + 黑框 */
.piece.black {
    background: #c8c0b4;
    color: #1a1a2e;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    border: 5px solid #2c3e50;
}

/* 动物图标样式 */
.piece .animal-icon {
    font-size: 1.2em;
    line-height: 1;
}

/* 动物文字样式 */
.piece .animal-text {
    font-size: 1em;
    line-height: 1;
    margin-top: 1px;
}

#game-over-modal .modal-content {
    min-width: 300px;
}

#game-over-message {
    font-size: 1.2rem;
    margin: 1rem 0;
    color: #e74c3c;
    font-weight: bold;
}

#rematch-waiting-modal .modal-content,
#opponent-left-modal .modal-content,
#player-left-modal .modal-content {
    min-width: 280px;
}

#opponent-left-modal p,
#player-left-modal p,
#all-players-left-modal p {
    color: #e74c3c;
}

#all-players-left-modal .modal-content {
    min-width: 320px;
}

@media (min-width: 1179px) {
    .game-layout {
        container-type: size;
    }

    .chessboard {
        width: min(100%, 700px, 90cqh);
        max-width: 700px;
        max-height: 100cqh;
    }
}

@media (min-width: 1179px) and (max-height: 850px) {
    .game-layout {
        align-items: flex-start;
    }
}

@media (max-width: 1178px) {
    .spectator-controls {
        gap: 0.5rem;
        justify-content: center;
    }

    .left-sidebar {
        flex: 1;
        align-items: center;
    }

    .right-sidebar {
        flex: 1;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .game-room-info,
    .turn-indicator {
        margin-bottom: 0;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 111px;
    }

    .game-room-info {
        min-height: 2.5rem;
        max-height: 49px;
        white-space: nowrap;
    }

    .turn-indicator {
        min-height: 4.2rem;
        max-height: none;
        line-height: 1.4;
        white-space: pre-line;
    }

    .turn-indicator.spectator {
        flex: 2;
        white-space: pre-line;
    }

    .game-buttons {
        gap: 0.5rem;
        flex: 1;
        justify-content: center;
    }

    .right-sidebar:has(.turn-indicator.spectator) .game-buttons {
        display: none;
    }

    .right-sidebar:has(.turn-indicator.spectator) {
        justify-content: space-between;
    }

    .right-sidebar:has(.turn-indicator.spectator) .game-room-info,
    .right-sidebar:has(.turn-indicator.spectator) .turn-indicator {
        flex: 1;
        min-width: 159px;
    }

    .game-btn {
        padding: 0.5rem 1rem;
        font-size: 1rem;
        min-width: 64px;
    }
}

@media (max-width: 1024px) {
    .chessboard {
        height: auto;
        max-width: 700px;
    }
}
