/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a6da7;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --black-color: #212529;
    --white-color: #f8f9fa;
    --board-color: #e6bc7c;
    --grid-color: #8b4513;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Roboto', 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--dark-color);
    line-height: 1.6;
}

/* 容器布局 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.title {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.game-mode, .difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-label, .difficulty-label {
    font-weight: 500;
}

select {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: white;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

select:hover {
    border-color: var(--primary-color);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border-radius: 20px;
    transition: var(--transition);
}

.player.active {
    background-color: rgba(74, 109, 167, 0.1);
    transform: scale(1.05);
}

.player-piece {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #333;
}

.player.black .player-piece {
    background-color: var(--black-color);
}

.player.white .player-piece {
    background-color: var(--white-color);
}

.turn-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.turn-text {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.turn-arrow {
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* 主要内容 */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.game-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 棋盘样式 */
.board {
    background-color: var(--board-color);
    border: 3px solid var(--grid-color);
    border-radius: 5px;
    box-shadow: var(--shadow);
    position: relative;
    margin: 0 auto;
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(15, 30px);
    grid-template-rows: repeat(15, 30px);
    gap: 0;
    position: relative;
}

.grid-cell {
    width: 30px;
    height: 30px;
    position: relative;
    border: 1px solid var(--grid-color);
    cursor: pointer;
    transition: var(--transition);
}

.grid-cell:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.grid-cell.disabled {
    cursor: not-allowed;
}

/* 棋子样式 */
.piece {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: placeStone 0.3s ease-out;
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #555, #000);
    border: 1px solid #000;
}

.piece.white {
    background: radial-gradient(circle at 30% 30%, #fff, #e0e0e0);
    border: 1px solid #ccc;
}

.piece.winning {
    animation: pulse 1s infinite;
}

.piece.last-move {
    box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.8);
}

@keyframes placeStone {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 10px 3px rgba(255, 0, 0, 0.7);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 15px 5px rgba(255, 0, 0, 0.8);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 10px 3px rgba(255, 0, 0, 0.7);
    }
}

/* 游戏状态 */
.game-status {
    margin-top: 15px;
    text-align: center;
    padding: 10px 20px;
    border-radius: 20px;
    background-color: white;
    box-shadow: var(--shadow);
    font-weight: 500;
}

.status-text {
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* 控制面板 */
.controls {
    background-color: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: var(--shadow);
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 按钮样式 */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #3a5a8e;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

.btn-secondary.active {
    background-color: var(--success-color);
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* 统计和历史 */
.game-stats, .game-history {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-stats h3, .game-history h3 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background-color: rgba(74, 109, 167, 0.05);
    border-radius: 5px;
}

.stat-label {
    font-weight: 500;
}

.stat-value {
    font-weight: 700;
    color: var(--primary-color);
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 5px;
    padding: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.history-item:last-child {
    border-bottom: none;
}

.history-result {
    font-weight: 500;
}

.win {
    color: var(--success-color);
}

.lose {
    color: var(--danger-color);
}

.draw {
    color: var(--warning-color);
}

.no-history {
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
}

/* 对话框样式 */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: var(--transition);
}

.dialog.show {
    visibility: visible;
    opacity: 1;
}

.dialog-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    transform: scale(0.8);
    transition: var(--transition);
    text-align: center;
}

.dialog.show .dialog-content {
    transform: scale(1);
}

.dialog-content h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* 页脚样式 */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 992px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .controls {
        width: 100%;
        max-width: 500px;
    }
    
    .game-info {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .board-grid {
        grid-template-columns: repeat(15, 20px);
        grid-template-rows: repeat(15, 20px);
    }
    
    .grid-cell {
        width: 20px;
        height: 20px;
    }
    
    .piece {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .player-info {
        order: 1;
    }
    
    .game-mode, .difficulty-selector {
        width: 100%;
        justify-content: space-between;
    }
}