/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "SimHei", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
}

.screen.active {
    display: block;
}

/* ==================== 开始界面 ==================== */
.start-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
}

.game-title {
    font-size: 4rem;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 60px;
    font-weight: bold;
    letter-spacing: 10px;
}

.setup-options {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: 40px;
    width: 100%;
    max-width: 500px;

    /* 修复布局：垂直排列并增加间距 */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-group {
    margin-bottom: 0; /* 由 gap 控制间距 */
}

.option-group label {
    display: block;
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 10px;
    font-weight: bold;
}

.difficulty-selector,
.color-selector {
    display: flex;
    gap: 10px;
}

/* 新增：模式按钮样式 */
.mode-btn,
.difficulty-btn,
.color-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 1rem;
    border: 3px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    white-space: nowrap;
}

.mode-btn:hover,
.difficulty-btn:hover,
.color-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.mode-btn.active,
.difficulty-btn.active,
.color-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.primary-btn {
    padding: 15px 60px;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.primary-btn:active {
    transform: translateY(-1px);
}

/* 在线操作按钮组 */
#online-actions {
    display: flex;
    gap: 10px;
}

#online-actions[style*="display: none"] {
    display: none !important;
}

/* ==================== 游戏主界面 ==================== */
.game-container {
    display: flex;
    height: 100vh;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

.left-panel,
.right-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.left-panel {
    width: 280px;
    min-width: 280px;
}

.right-panel {
    width: 320px;
    min-width: 320px;
}

.panel-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.panel-section h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 15px;
    font-weight: bold;
}

/* ==================== 棋盘区域 ==================== */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.board {
    position: relative;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

#board-canvas {
    display: block;
    background: linear-gradient(135deg,
        #d4a574 0%,
        #c4956a 25%,
        #b8895e 50%,
        #c4956a 75%,
        #d4a574 100%
    );
}

#board-canvas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* ==================== 棋子样式 ==================== */
.piece {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: bold;
    transition: all 0.2s;
    user-select: none;
    z-index: 10;
}

.piece.red {
    background: radial-gradient(circle at 30% 30%, #fff5f5, #ffe0e0, #ffd0d0);
    color: #cc0000;
    border: 4px solid #cc0000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #fff8e0, #ffe8a0, #ffd870);
    color: #000;
    border: 4px solid #8b4513;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.piece:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.piece.selected {
    transform: scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.8), inset 0 2px 4px rgba(255, 255, 255, 0.5);
    z-index: 20;
}

.piece.red.selected { border-color: #ffd700; }
.piece.black.selected { border-color: #ffd700; }

.valid-move {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 255, 0, 0.6);
    border: 3px solid #00ff00;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s;
}

.valid-move:hover {
    background: rgba(0, 255, 0, 0.8);
    transform: scale(1.2);
}

.valid-move.capture {
    background: rgba(255, 0, 0, 0.6);
    border-color: #ff0000;
}

.valid-move.capture:hover {
    background: rgba(255, 0, 0, 0.8);
}

/* ==================== 游戏控制 ==================== */
.turn-indicator {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    margin-top: 10px;
}
.turn-indicator.red { background: #ffe5e5; color: #cc0000; border: 3px solid #cc0000; }
.turn-indicator.black { background: #fff8e0; color: #000; border: 3px solid #8b4513; }

.control-buttons { display: flex; flex-direction: column; gap: 10px; }

.control-btn {
    padding: 12px 20px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.control-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4); }
.control-btn:active { transform: translateY(0); }

#surrender-btn { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
#undo-btn { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

.settings { display: flex; flex-direction: column; gap: 10px; }
.setting-item { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; cursor: pointer; user-select: none; }
.setting-item input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }

/* ==================== 游戏信息与统计 ==================== */
.game-info, .stats { display: flex; flex-direction: column; gap: 12px; }
.info-item, .stat-item {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 1.1rem; padding: 8px; background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.info-item .label, .stat-item .label { font-weight: bold; color: #666; }

.move-history { max-height: 300px; overflow-y: auto; background: white; border-radius: 8px; padding: 10px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); }
.move-item { padding: 8px; border-bottom: 1px solid #eee; font-size: 0.95rem; display: flex; justify-content: space-between; align-items: center; }
.move-item:last-child { border-bottom: none; }
.move-item .move-number { font-weight: bold; color: #667eea; width: 50px; }
.move-item .move-content { flex: 1; }
.move-item.red-move { background: #ffe5e5; }
.move-item.black-move { background: #fff8e0; }

/* ==================== 游戏消息与模态框 ==================== */
.game-message {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9); color: white; padding: 30px 50px;
    border-radius: 15px; font-size: 2rem; font-weight: bold; z-index: 100; animation: fadeIn 0.3s;
}
.game-message.hidden { display: none; }
.game-message.check { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.game-message.win { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center;
    z-index: 1000; animation: fadeIn 0.3s;
}
.modal.hidden { display: none; }
.modal-content {
    background: white; padding: 40px; border-radius: 20px; text-align: center;
    max-width: 500px; width: 90%; box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}
.modal-content h2 { font-size: 2rem; color: #333; margin-bottom: 20px; }
.modal-content p { font-size: 1.3rem; color: #666; margin-bottom: 30px; }
.modal-buttons { display: flex; gap: 15px; justify-content: center; }
.modal-buttons button {
    padding: 12px 30px; font-size: 1.2rem; font-weight: bold;
    border: none; border-radius: 10px; cursor: pointer; transition: all 0.3s;
}
.modal-buttons .primary-btn { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.modal-buttons .secondary-btn { background: #ddd; color: #333; }
.modal-buttons button:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); }

@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* 滚动条与响应式 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

@media (max-width: 1400px) { .left-panel, .right-panel { width: 240px; min-width: 240px; } .panel-section { padding: 12px; } }
@media (max-width: 1200px) { .game-container { flex-direction: column; overflow-y: auto; } .left-panel, .right-panel { width: 100%; min-width: auto; } .board-container { min-height: 500px; } }
@media (max-width: 768px) {
    body { padding: 10px; }
    .game-title { font-size: 2.5rem; }
    .setup-options { padding: 20px 30px; }
    .mode-btn, .difficulty-btn, .color-btn { font-size: 0.9rem; padding: 10px 15px; }
    .piece { width: 60px; height: 60px; font-size: 2rem; }
    .board-container { padding: 10px; }
}
@media (max-width: 480px) {
    .game-title { font-size: 2rem; }
    .primary-btn { padding: 12px 40px; font-size: 1.2rem; }
    .piece { width: 50px; height: 50px; font-size: 1.5rem; }
}