/* css/style.css */

/* ==================== 全局样式 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Segoe UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto; /* 允许滚动 */
    color: #333;
}

.screen { display: none; width: 100%; min-height: 100vh; }
.screen.active { display: block; }

/* ==================== 启动屏幕 (首页) ==================== */
.start-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    width: 100%;
}

.game-title {
    font-size: 4.5rem;
    color: #fff;
    text-shadow: 0 10px 20px rgba(0,0,0,0.2), 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 50px;
    font-weight: 800;
    letter-spacing: 12px;
}

.setup-options {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 50px 60px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.2);
    margin-bottom: 40px;
    width: 100%;
    max-width: 480px;
    transition: transform 0.3s ease;
}

.option-group { margin-bottom: 25px; }
.option-group.hidden { display: none; }

.option-group label {
    display: block; font-size: 1.1rem; color: #555; margin-bottom: 12px; font-weight: 600; margin-left: 4px;
}

.difficulty-selector, .color-selector, .mode-selector { display: flex; gap: 12px; }

.difficulty-btn, .color-btn, .mode-btn {
    flex: 1; padding: 12px 0; font-size: 1rem; border: 2px solid #eef2f7; border-radius: 12px;
    background: #f8f9fa; color: #666; cursor: pointer; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); font-weight: 500;
}

.difficulty-btn:hover, .color-btn:hover, .mode-btn:hover {
    border-color: #dce4ec; background: #fff; transform: translateY(-2px);
}

.difficulty-btn.active, .color-btn.active, .mode-btn.active {
    background: #4834d4; color: white; border-color: #4834d4; box-shadow: 0 4px 12px rgba(72, 52, 212, 0.3);
}

.primary-btn {
    width: 100%; padding: 18px 0; margin-top: 30px; font-size: 1.4rem; font-weight: 700; letter-spacing: 2px;
    color: white; background: linear-gradient(135deg, #4834d4 0%, #686de0 100%); border: none; border-radius: 16px;
    cursor: pointer; box-shadow: 0 10px 25px rgba(72, 52, 212, 0.4); transition: all 0.3s ease; position: relative; overflow: hidden;
}
.primary-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 35px rgba(72, 52, 212, 0.5); filter: brightness(1.1); }
.primary-btn:active { transform: translateY(1px); box-shadow: 0 5px 15px rgba(72, 52, 212, 0.3); }

/* 在线模式面板 */
#online-setup {
    background: #f9fafc; padding: 35px 30px; border-radius: 16px; border: 2px dashed #dce4ec; margin-top: 20px;
}
.online-actions { display: flex; flex-direction: column; gap: 35px; }
.create-section, .join-section { display: flex; flex-direction: column; gap: 20px; }
.color-selector.small { gap: 15px; }
.color-selector.small .color-btn { padding: 10px 0; }

#room-code-input {
    width: 100%; padding: 16px; font-size: 1.2rem; border: 2px solid #e0e0e0; border-radius: 12px;
    text-align: center; letter-spacing: 4px; font-family: monospace; transition: border-color 0.3s; background: white;
}
#room-code-input:focus { border-color: #4834d4; outline: none; box-shadow: 0 0 0 4px rgba(72, 52, 212, 0.1); }

.secondary-btn {
    width: 100%; padding: 16px 0; background: #6c5ce7; color: white; border: none; border-radius: 12px;
    cursor: pointer; font-size: 1.1rem; font-weight: bold; transition: all 0.2s; box-shadow: 0 4px 10px rgba(108, 92, 231, 0.3);
}
.secondary-btn:hover { background: #5f4dd0; transform: translateY(-2px); }

.divider { text-align: center; color: #adb5bd; font-size: 0.9rem; position: relative; margin: 10px 0; font-weight: 500; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: #e0e0e0; }
.divider::before { left: 0; }
.divider::after { right: 0; }

.code-display {
    font-size: 3.5rem; font-weight: 800; color: #4834d4; letter-spacing: 8px; margin: 30px 0;
    background: #fff; padding: 20px; border-radius: 16px; box-shadow: inset 0 2px 10px rgba(0,0,0,0.05); border: 1px solid #eee;
}

/* ==================== 游戏界面 (核心修复) ==================== */
.game-container {
    display: flex;
    flex-direction: row;
    justify-content: center;

    /* 1. 关键修改：align-items 改为 stretch，让左右面板高度自动撑满，与棋盘等高 */
    align-items: stretch;

    /* 2. 移除固定高度，改为让内容决定高度，body 会负责垂直居中整个区域 */
    /* height: 100vh;  <-- 删除这行 */

    padding: 20px;
    gap: 20px;

    /* 最小宽度，防止面板被挤压 */
    min-width: 1350px;
    margin: 0 auto;
}

.left-panel, .right-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;

    display: flex;
    flex-direction: column;
    gap: 15px;

    width: 260px;
    min-width: 260px;
    flex-shrink: 0;

    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.5);

    /* 确保内容多了可以滚动 */
    overflow-y: auto;
}

/* 面板内部样式 */
.panel-section {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border-left: 5px solid #4834d4;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.panel-section h3 {
    font-size: 1.1rem; color: #333; margin-bottom: 12px; font-weight: 700;
}

/* 棋盘容器 */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;

    background: rgba(255,255,255,0.05);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);

    /* 确保容器尺寸包得住 750px 的棋盘 */
    min-width: 760px;
    min-height: 760px;
}

.board {
    position: relative;
    border-radius: 6px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
    line-height: 0;
}

#board-canvas {
    background-color: #e6b47c;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZGNhOTcyIi8+CjxwYXRoIGQ9Ik0wIDBMNCA0Wk00IDBMMCA0WiIHN0cm9rZT0iI2QyYTA2YyIgb3BhY2l0eT0iMC4yIi8+Cjwvc3ZnPg==');
    border-radius: 4px;
}

/* 状态指示 */
.turn-indicator { padding: 12px; border-radius: 10px; text-align: center; font-weight: bold; color: white; transition: all 0.3s; font-size: 1.1rem; }
.turn-indicator.black { background: #2d3436; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.turn-indicator.white { background: #fff; color: #2d3436; border: 2px solid #dfe6e9; box-shadow: 0 4px 15px rgba(255,255,255,0.5); }

/* 控制按钮 */
.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #eef2f7;
    font-weight: 600;
    color: #444;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.control-btn:hover {
    background: #dfe6e9;
    transform: translateY(-2px);
    color: #3f2b96;
}

#pass-btn { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); color: #d63031; }
#pass-btn:hover { filter: brightness(0.95); }

#surrender-btn { background: #ff7675; color: white; }
#surrender-btn:hover { background: #d63031; }

/* 棋谱记录 */
.move-history {
    height: 250px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    font-family: Consolas, monospace;
    font-size: 0.9rem;
    border: 1px solid #eee;
}

.move-item {
    padding: 5px 8px;
    border-bottom: 1px dashed #e0e0e0;
    display: flex;
    justify-content: space-between;
    color: #666;
}

.move-item:last-child {
    border-bottom: none;
    font-weight: bold;
    color: #3f2b96;
    background: rgba(63, 43, 150, 0.05);
    border-radius: 4px;
}

/* 倒计时圆圈 */
.timer-container { margin: 20px 0; display: flex; flex-direction: column; align-items: center; gap: 15px; }
.countdown-circle {
    width: 80px; height: 80px; border-radius: 50%; border: 6px solid #4834d4;
    display: flex; justify-content: center; align-items: center;
    font-size: 2rem; font-weight: 800; color: #4834d4; background: #f0f0ff;
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(72, 52, 212, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(72, 52, 212, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(72, 52, 212, 0); }
}

/* 模态框 */
.modal-content {
    background: white; padding: 50px; border-radius: 24px; text-align: center; max-width: 450px; width: 90%;
    box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}
.modal h2 { font-size: 2rem; color: #333; margin-bottom: 15px; }
.modal p { font-size: 1.2rem; color: #666; line-height: 1.6; }
.modal-buttons { margin-top: 30px; display: flex; gap: 15px; justify-content: center; }

.hidden { display: none !important; }