:root {
    --board-bg: #e6b87c;
    --board-line: #5c3a19;
    --piece-shadow: rgba(0, 0, 0, 0.3);
    --red-color: #c00;
    --black-color: #111;
    --highlight-color: rgba(255, 255, 0, 0.4);
    --selected-color: rgba(0, 255, 0, 0.4);
    --last-move-color: rgba(0, 0, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: #f0f2f5;
    background-image: url('../../bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: #333;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8); /* 增加半透明背景以突出内容 */
    border-radius: 16px;
    margin: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
}

.back-btn {
    align-self: flex-start;
    text-decoration: none;
    color: #555;
    font-weight: bold;
    margin-bottom: 10px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    transition: all 0.2s;
}

.back-btn:hover {
    background: #e9ecef;
    color: #000;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

.game-info {
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

#turn-indicator {
    color: var(--red-color);
    margin-right: 20px;
}

.game-area {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

/* 棋盘样式 */
.board-container {
    background: #8b5a2b;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.board {
    width: 450px; /* 9 * 50px */
    height: 500px; /* 10 * 50px */
    background-color: var(--board-bg);
    position: relative;
    user-select: none;
}

.grid-lines {
    position: absolute;
    top: 25px;
    left: 25px;
    width: 400px;
    height: 450px;
    border: 2px solid var(--board-line);
    background-image: 
        linear-gradient(var(--board-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--board-line) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: -1px -1px; /* Adjust for border */
}

/* 楚河汉界 */
.river {
    position: absolute;
    top: 225px;
    left: 25px;
    width: 400px;
    height: 50px;
    background-color: var(--board-bg); /* 盖住中间的线 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 60px;
    font-size: 24px;
    color: var(--board-line);
    font-family: "KaiTi", "STKaiti", serif;
    pointer-events: none;
    z-index: 1;
}

/* 斜线 (九宫格) - 使用伪元素简单实现 */
.board::before, .board::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border: 1px solid transparent;
    z-index: 0;
    pointer-events: none;
}

/* 下方红方九宫格斜线 */
.board::after {
    bottom: 25px;
    left: 175px;
    background: 
        linear-gradient(45deg, transparent 49%, var(--board-line) 49%, var(--board-line) 51%, transparent 51%),
        linear-gradient(-45deg, transparent 49%, var(--board-line) 49%, var(--board-line) 51%, transparent 51%);
}

/* 上方黑方九宫格斜线 */
.board::before {
    top: 25px;
    left: 175px;
    background: 
        linear-gradient(45deg, transparent 49%, var(--board-line) 49%, var(--board-line) 51%, transparent 51%),
        linear-gradient(-45deg, transparent 49%, var(--board-line) 49%, var(--board-line) 51%, transparent 51%);
}


.piece {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    font-family: "KaiTi", "STKaiti", serif;
    cursor: pointer;
    box-shadow: 2px 2px 4px var(--piece-shadow);
    z-index: 10;
    transition: transform 0.2s, top 0.3s, left 0.3s;
    background: #fdf5e6;
    border: 2px solid #b8860b;
    /* 3D效果 */
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.2), 2px 2px 5px rgba(0,0,0,0.4);
}

.piece.red {
    color: var(--red-color);
    border-color: #d35400;
}

.piece.black {
    color: var(--black-color);
    border-color: #333;
}

.piece.selected {
    transform: scale(1.15);
    box-shadow: 0 0 10px yellow;
    z-index: 20;
    background-color: #fff;
}

/* 移动指示点 */
.dot {
    width: 14px;
    height: 14px;
    background-color: var(--highlight-color);
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 5;
    pointer-events: none;
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.panel h3 {
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 4px;
    background-color: #4a90e2;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background-color: #357abd;
}

.btn.sm {
    display: inline-block;
    width: auto;
    padding: 5px 10px;
    font-size: 14px;
    margin-right: 5px;
}

.move-list {
    height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 5px;
    font-family: monospace;
    font-size: 14px;
    background: #fafafa;
}

.move-item {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.move-item:hover {
    background-color: #e6f7ff;
}

.move-item.active {
    background-color: #bae7ff;
    font-weight: bold;
}

.move-index {
    display: inline-block;
    width: 30px;
    color: #888;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 500px;
    max-width: 90%;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
}

textarea {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

/* 响应式适配 */
@media (max-width: 800px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }
    
    .sidebar {
        width: 100%;
        max-width: 450px;
    }
    
    .board {
        transform-origin: top center;
    }
}

/* 上一步移动的高亮样式 */
.last-move-source {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(0, 0, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
}

.last-move-target {
    box-shadow: 0 0 0 3px rgba(0, 0, 255, 0.4);
}
