/* 
 * 合群之落 - 样式表
 * 极简主义设计，复用原插件配色
 */

/* ============ CSS 变量定义 ============ */
:root {
    /* 主题色 */
    --bg-warm: #f5f0e8;           /* 暖黄色背景 */
    --border-color: #8b7355;      /* 边框颜色 */
    --text-dark: #3e2723;         /* 深色文字 */
    --text-light: #6d4c41;        /* 浅色文字 */
    
    /* 玩家颜色 */
    --player1-color: #2c3e50;     /* 黑棋（深蓝灰） */
    --player2-color: #ecf0f1;     /* 白棋（浅灰白） */
    --player1-area: rgb(255, 182, 193);   /* 黑方领地（浅红色） */
    --player2-area: rgb(173, 216, 230);  /* 白方领地（浅蓝色） */
    
    /* 交互色 */
    --hover-color: rgba(139, 115, 85, 0.1);
    --active-color: #5d4037;
    --button-bg: #8b7355;
    --button-hover: #6d4c41;
}

/* ============ 全局样式 ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-warm);
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* ============ 容器布局 ============ */
#app {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

/* 标题 */
h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-dark);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 30px;
}
/* ============ 昵称输入区（常驻） ============ */
.nickname-section {
    margin: 20px 0 30px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nickname-input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.nickname-input-group input {
    flex: 1;
    max-width: 300px;
}

.login-status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.login-status.logged-in {
    color: #27ae60;
    font-weight: bold;
}

.login-status.not-logged-in {
    color: #e74c3c;
}

/* ============ 按钮样式 ============ */
button {
    background: var(--button-bg);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
}

button:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ============ 输入框样式 ============ */
input[type="text"] {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-dark);
    margin: 5px;
    min-width: 200px;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--active-color);
}

/* ============ 模态框/弹窗 ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

.modal-content p {
    margin: 15px 0;
    color: var(--text-light);
}

/* ============ 页面切换 ============ */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============ 大厅页面 ============ */
#lobby-page .actions {
    margin-top: 20px;
}

#room-id-display {
    font-size: 2rem;
    font-weight: bold;
    color: var(--active-color);
    margin: 20px 0;
    letter-spacing: 4px;
}

.waiting-text {
    color: var(--text-light);
    font-style: italic;
}

/* ============ 游戏页面 ============ */
#game-page {
    margin-top: 20px;
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.player-info {
    flex: 1;
    text-align: center;
}

.player-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.player-score {
    font-size: 1.5rem;
    font-weight: bold;
}

.player-info.player1 .player-name {
    color: var(--player1-color);
}

.player-info.player2 .player-name {
    color: #34495e;
}

.turn-indicator {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 10px;
    text-align: center;
}

/* 旁观者提示 */
.spectator-mode {
    background: #e8f4f8;
    border: 2px solid #3498db;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    text-align: center;
    color: #2980b9;
    font-weight: bold;
}

.current-turn {
    font-weight: bold;
    color: var(--active-color);
}

/* ============ 棋盘样式 ============ */
.board-container {
    display: inline-block;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

#board {
    display: grid;
    grid-template-columns: repeat(10, 40px);
    grid-template-rows: repeat(10, 40px);
    gap: 2px;
    background: var(--border-color);
    border: 3px solid var(--border-color);
    border-radius: 4px;
}

/* 棋盘格子 */
.cell {
    width: 40px;
    height: 40px;
    background: var(--bg-warm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell:hover {
    background: var(--hover-color);
}

/* 已占据的格子 */
.cell.occupied {
    cursor: not-allowed;
}

.cell.occupied::before {
    content: '';
    width: 30px;
    height: 30px;
    border-radius: 50%;
    position: absolute;
}

/* ============ 棋子显示（::before 伪元素）============ */
/* 黑棋 */
.cell.occupied.piece-p1::before {
    background: var(--player1-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* 白棋 */
.cell.occupied.piece-p2::before {
    background: var(--player2-color);
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}


/* ============ 棋子序号显示（::after 伪元素）============ */
/* 
 * 使用 ::after 伪元素在棋子上显示落子序号
 * ::before 用于显示棋子本身
 * ::after 用于显示数字
 */
.cell.occupied::after {
    content: attr(data-move-number);
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 1;
}

/* 黑棋上的数字为白色 */
.cell.occupied.piece-p1::after {
    color: white;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

/* 白棋上的数字为黑色 */
.cell.occupied.piece-p2::after {
    color: black;
    text-shadow: 0 0 2px rgba(255,255,255,0.8);
}

/* ============ 染色区域（背景色）============ */
/* 黑方染色 */
.cell.colored-p1 {
    background: var(--player1-area);
}

/* 白方染色 */
.cell.colored-p2 {
    background: var(--player2-area);
}

/* 
 * 关键说明：
 * 1. 染色状态只改变 background（背景色）
 * 2. 棋子状态通过 ::before 伪元素显示（在背景之上）
 * 3. 两者互不干扰：
 *    - .colored-p1 控制背景为淡红色
 *    - .piece-p2::before 控制显示白色棋子
 *    - 最终效果：白色棋子显示在淡红色背景上（黑方染色区域内的白棋）
 */
/* ============ 游戏控制按钮 ============ */
.game-controls {
    margin-top: 20px;
}

.resign-btn {
    background: #e74c3c;
}

.resign-btn:hover {
    background: #c0392b;
}

/* ============ 结算界面 ============ */
.result-modal .modal-content {
    text-align: center;
}

.winner-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--active-color);
    margin: 20px 0;
}

.final-scores {
    margin: 20px 0;
    font-size: 1.1rem;
}

.final-scores div {
    margin: 10px 0;
}

/* ============ 响应式设计 ============ */
@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }
    
    #board {
        grid-template-columns: repeat(10, 30px);
        grid-template-rows: repeat(10, 30px);
    }
    
    .cell {
        width: 30px;
        height: 30px;
    }
    
    .cell.occupied::before {
        width: 22px;
        height: 22px;
    }
    
    /* 移动端调整数字大小 */
    .cell.occupied::after {
        font-size: 10px;
    }
    
    .game-info {
        flex-direction: column;
    }
    
    .player-info {
        margin: 10px 0;
    }
}

/* ============ 加载动画 ============ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ 消息提示 ============ */
.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 2000;
    display: none;
}

.message.show {
    display: block;
    animation: slideDown 0.3s;
}

.message.error {
    background: #e74c3c;
    color: white;
}

.message.success {
    background: #27ae60;
    color: white;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}