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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', Arial, sans-serif;
    background: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 50%, #CBD5E0 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* 扁平化背景设计 */
}

.game-container {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    max-width: 1000px;
    width: 100%;
    border: 1px solid #E2E8F0;
    /* 扁平化容器设计 */
}

h1 {
    text-align: center;
    color: #1E293B;
    margin-bottom: 24px;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    /* 扁平化标题设计 */
}

.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-card {
    background: #F8FAFC;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #E2E8F0;
    transition: all 0.2s ease;
    /* 扁平化信息卡片 */
}

.info-card:hover {
    background: #F1F5F9;
    border-color: #CBD5E0;
}

.info-label {
    color: #64748B;
    font-size: 0.875rem;
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    color: #1E293B;
    font-size: 1.25rem;
    font-weight: 700;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

button {
    background: #8B4513;
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 120px;
    /* 扁平化按钮设计 - 更大更易点击 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover {
    background: #A0522D;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    /* 扁平化悬停效果 */
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button:disabled {
    background: #CBD5E0;
    color: #A0AEC0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}.game-boar
d {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin: 20px 0;
    min-height: 600px;
}

.chess-board-container {
    background: #F8FAFC;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #E2E8F0;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 扁平化棋盘容器 */
}

.chess-board {
    width: 600px;
    height: 660px;
    background: #D4B08A;
    border: 3px solid #8B4513;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    overflow: visible;
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 确保棋盘内容完美居中 */
    margin: 0 auto;
}

/* 棋盘内容容器 */
.board-content {
    position: relative;
    width: 540px;
    height: 600px;
}

/* SVG棋盘线条容器 */
.board-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 楚河汉界标识 */
.river-text {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #C2410C;
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 5;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

/* 士线样式 - 通过SVG实现，确保精确对称 */
.palace-line {
    stroke: #2563EB;
    stroke-width: 2.5;
    fill: none;
    opacity: 0.9;
    stroke-linecap: round;
}

/* 象线 - 田字格对角线 (隐藏) */
.elephant-line {
    display: none;
}

/* 红方象线 */
.red-elephant-line-1 {
    width: 2px;
    height: 78px; /* 55px * √2 ≈ 78px */
    top: 370px; /* 40 + 6*55 = 370px */
    left: 95px; /* 40 + 1*55 = 95px */
    transform: rotate(45deg);
    transform-origin: top left;
}

.red-elephant-line-2 {
    width: 2px;
    height: 78px;
    top: 370px;
    left: 150px; /* 40 + 2*55 = 150px */
    transform: rotate(-45deg);
    transform-origin: top right;
}

.red-elephant-line-3 {
    width: 2px;
    height: 78px;
    top: 370px;
    left: 315px; /* 40 + 5*55 = 315px */
    transform: rotate(45deg);
    transform-origin: top left;
}

.red-elephant-line-4 {
    width: 2px;
    height: 78px;
    top: 370px;
    left: 370px; /* 40 + 6*55 = 370px */
    transform: rotate(-45deg);
    transform-origin: top right;
}

.red-elephant-line-5 {
    width: 2px;
    height: 78px;
    top: 480px; /* 40 + 8*55 = 480px */
    left: 150px; /* 40 + 2*55 = 150px */
    transform: rotate(45deg);
    transform-origin: top left;
}

.red-elephant-line-6 {
    width: 2px;
    height: 78px;
    top: 480px;
    left: 205px; /* 40 + 3*55 = 205px */
    transform: rotate(-45deg);
    transform-origin: top right;
}

.red-elephant-line-7 {
    width: 2px;
    height: 78px;
    top: 480px;
    left: 315px; /* 40 + 5*55 = 315px */
    transform: rotate(45deg);
    transform-origin: top left;
}

.red-elephant-line-8 {
    width: 2px;
    height: 78px;
    top: 480px;
    left: 370px; /* 40 + 6*55 = 370px */
    transform: rotate(-45deg);
    transform-origin: top right;
}

/* 黑方象线 */
.black-elephant-line-1 {
    width: 2px;
    height: 78px;
    top: 40px;
    left: 95px;
    transform: rotate(-45deg);
    transform-origin: top left;
}

.black-elephant-line-2 {
    width: 2px;
    height: 78px;
    top: 40px;
    left: 150px;
    transform: rotate(45deg);
    transform-origin: top right;
}

.black-elephant-line-3 {
    width: 2px;
    height: 78px;
    top: 40px;
    left: 315px;
    transform: rotate(-45deg);
    transform-origin: top left;
}

.black-elephant-line-4 {
    width: 2px;
    height: 78px;
    top: 40px;
    left: 370px;
    transform: rotate(45deg);
    transform-origin: top right;
}

.black-elephant-line-5 {
    width: 2px;
    height: 78px;
    top: 95px; /* 40 + 1*55 = 95px */
    left: 150px;
    transform: rotate(-45deg);
    transform-origin: top left;
}

.black-elephant-line-6 {
    width: 2px;
    height: 78px;
    top: 95px;
    left: 205px;
    transform: rotate(45deg);
    transform-origin: top right;
}

.black-elephant-line-7 {
    width: 2px;
    height: 78px;
    top: 95px;
    left: 315px;
    transform: rotate(-45deg);
    transform-origin: top left;
}

.black-elephant-line-8 {
    width: 2px;
    height: 78px;
    top: 95px;
    left: 370px;
    transform: rotate(45deg);
    transform-origin: top right;
}

/* 交叉点定位系统 - 替代grid cell */
.board-intersection {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1;
    /* 调试模式下显示交叉点 */
}

.board-intersection.debug-visible {
    background: rgba(255, 0, 0, 0.5);
    border: 2px solid #ff0000;
    z-index: 15;
}

.board-intersection.debug-visible::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    background: #ff0000;
    transform: translate(-50%, -50%);
}

.board-intersection:hover {
    background: rgba(255, 215, 0, 0.4);
    border: 2px solid #FFD700;
}

.board-intersection.selected {
    background: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 0 4px #FFD700;
    border-radius: 8px;
}

.board-intersection.possible-move {
    background: rgba(50, 205, 50, 0.6);
    box-shadow: 0 0 0 3px #32CD32;
    border-radius: 6px;
}

.board-intersection.drag-over {
    background: rgba(255, 165, 0, 0.8);
    box-shadow: 0 0 0 4px #FFA500;
    border-radius: 8px;
    transform: scale(1.3);
}

.chess-piece.dragging {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    transition: none;
}

.chess-piece[draggable="true"]:hover {
    cursor: grab;
    transform: translate(-50%, -50%) scale(1.05);
}

.chess-piece[draggable="true"]:active {
    cursor: grabbing;
}

.chess-piece.selected {
    transform: translate(-50%, -50%) scale(1.2);
    animation: selectedPulse 2s infinite;
    /* 扁平化选择效果 - 现代化脉冲动画 */
}

@keyframes selectedPulse {
    0% {
        box-shadow: 
            0 0 0 3px #3B82F6, 
            0 0 0 6px rgba(59, 130, 246, 0.3),
            0 4px 16px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 
            0 0 0 4px #3B82F6, 
            0 0 0 8px rgba(59, 130, 246, 0.5),
            0 6px 20px rgba(59, 130, 246, 0.6);
    }
    100% {
        box-shadow: 
            0 0 0 3px #3B82F6, 
            0 0 0 6px rgba(59, 130, 246, 0.3),
            0 4px 16px rgba(59, 130, 246, 0.4);
    }
}

.chess-piece {
    position: absolute;
    width: 48px;
    height: 48px;
    /* 精确居中在交叉点上 - 使用transform实现完美对齐 */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 900;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid;
    z-index: 10;
    /* 确保棋子文字完美居中 */
    text-align: center;
    line-height: 1;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'SimHei', 'KaiTi', Arial, sans-serif;
    letter-spacing: 0;
    /* 扁平化现代设计 */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    /* 确保棋子在交叉点上完美居中 - transform居中系统 */
    transform-origin: center center;
}

.chess-piece.red {
    /* 扁平化红色设计 - 极强对比度，确保清晰可辨 */
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: #FFFFFF;
    border-color: #B91C1C;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 1px 2px rgba(0, 0, 0, 0.9),
        0 0 8px rgba(0, 0, 0, 0.4);
    /* 红色棋子强化阴影效果 */
    box-shadow: 
        0 6px 20px rgba(239, 68, 68, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        0 0 0 2px rgba(185, 28, 28, 0.8);
}

.chess-piece.black {
    /* 扁平化黑色设计 - 深邃对比，确保与红色完全区分 */
    background: linear-gradient(135deg, #374151 0%, #1F2937 100%);
    color: #F9FAFB;
    border-color: #111827;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 1),
        0 1px 2px rgba(255, 255, 255, 0.1),
        0 0 8px rgba(255, 255, 255, 0.05);
    /* 黑色棋子强化阴影效果 */
    box-shadow: 
        0 6px 20px rgba(55, 65, 81, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        0 0 0 2px rgba(17, 24, 39, 0.9);
}

.chess-piece:hover {
    transform: translate(-50%, -50%) scale(1.15);
    /* 扁平化悬停效果 - 保持居中的平滑缩放 */
}

.chess-piece.red:hover {
    background: linear-gradient(135deg, #F87171 0%, #EF4444 100%);
    box-shadow: 
        0 8px 24px rgba(239, 68, 68, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        0 0 0 3px rgba(185, 28, 28, 0.9);
    border-color: #DC2626;
}

.chess-piece.black:hover {
    background: linear-gradient(135deg, #4B5563 0%, #374151 100%);
    box-shadow: 
        0 8px 24px rgba(55, 65, 81, 0.7),
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        0 0 0 3px rgba(17, 24, 39, 1);
    border-color: #1F2937;
}

.river {
    border-top: 3px solid #4169E1;
    border-bottom: 3px solid #4169E1;
}

.palace {
    background: rgba(218, 165, 32, 0.2);
}

.control-panel {
    background: #F8FAFC;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #E2E8F0;
    /* 扁平化控制面板 */
}

.section-title {
    text-align: center;
    color: #1E293B;
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 1.25rem;
    /* 扁平化标题 */
}

.puzzle-info {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* 扁平化信息面板 */
}

.puzzle-title {
    font-weight: 600;
    color: #1E293B;
    margin-bottom: 12px;
    font-size: 1.125rem;
    /* 扁平化题目标题 */
}

.puzzle-description {
    color: #64748B;
    line-height: 1.6;
    margin-bottom: 12px;
    font-size: 0.875rem;
    /* 扁平化描述文字 */
}

.puzzle-difficulty {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
}

.difficulty-easy {
    background: #32CD32;
}

.difficulty-medium {
    background: #FFD700;
    color: black;
}

.difficulty-hard {
    background: #FF4500;
}

.move-history {
    background: white;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid #CD853F;
}

.move-entry {
    padding: 5px;
    margin: 2px 0;
    border-radius: 5px;
    font-size: 0.9rem;
}

.move-entry:nth-child(even) {
    background: #F5F5F5;
}

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

.action-btn {
    background: #CD853F;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: #B8860B;
    transform: translateY(-1px);
}

.puzzle-list {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* 扁平化列表容器 */
}

.puzzle-item {
    padding: 16px 20px;
    margin: 6px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    background: #F8FAFC;
    font-size: 0.875rem;
    position: relative;
    overflow: hidden;
    font-weight: 500;
    color: #475569;
    /* 扁平化列表项设计 */
}

.puzzle-item:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: #334155;
    /* 扁平化悬停效果 */
}

.puzzle-item.current {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border-color: #F59E0B;
    color: #92400E;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
    transform: translateX(12px);
    /* 扁平化当前选中效果 - 金黄色主题 */
}

.puzzle-item.current:hover {
    background: linear-gradient(135deg, #FDE68A 0%, #FCD34D 100%);
    border-color: #D97706;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.puzzle-item.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(to bottom, #F59E0B 0%, #D97706 100%);
    /* 扁平化选中指示条 */
    border-radius: 0 4px 4px 0;
}

.puzzle-item.completed {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    border-color: #10B981;
    color: #065F46;
}

.puzzle-item.completed::after {
    content: '✓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #10B981;
    font-weight: bold;
    font-size: 1.2rem;
}

.success-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.success-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    animation: successPop 0.5s ease-out;
    border: 3px solid #8B4513;
}

@keyframes successPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }

    h1 {
        font-size: 2rem;
    }

    .game-board {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .chess-board {
        width: 350px;
        height: 400px;
        border: 2px solid #8B4513;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
        padding: 25px;
    }
    
    .board-content {
        width: 300px !important;
        height: 350px !important;
    }

    .chess-board::before {
        top: 25px;
        left: 25px;
        width: calc(100% - 50px);
        height: calc(100% - 50px);
        background-image: 
            repeating-linear-gradient(
                to right,
                transparent 0,
                transparent calc(35px - 1px),
                #C2410C calc(35px - 1px),
                #C2410C calc(35px + 1px)
            ),
            repeating-linear-gradient(
                to bottom,
                transparent 0,
                transparent calc(35px - 1px),
                #C2410C calc(35px - 1px),
                #C2410C calc(35px + 1px)
            );
    }

    .chess-board::after {
        border: 1px solid #654321;
        border-radius: 8px;
    }

    /* 移动端士线调整 */
    .red-palace-line-1, .red-palace-line-2,
    .black-palace-line-1, .black-palace-line-2 {
        height: 99px; /* 2 * 35px * √2 ≈ 99px */
        width: 2px;
    }

    .red-palace-line-1 {
        top: 270px; /* 25 + 7*35 = 270px */
        left: 130px; /* 25 + 3*35 = 130px */
    }

    .red-palace-line-2 {
        top: 270px;
        left: 200px; /* 25 + 5*35 = 200px */
    }

    .black-palace-line-1 {
        top: 25px;
        left: 130px;
    }

    .black-palace-line-2 {
        top: 25px;
        left: 200px;
    }

    .river-text {
        font-size: 12px;
        letter-spacing: 1px;
    }

    /* 移动端象线调整 */
    .elephant-line {
        height: 49px; /* 35px * √2 ≈ 49px */
    }

    .red-elephant-line-1 {
        top: 235px; /* 25 + 6*35 = 235px */
        left: 60px; /* 25 + 1*35 = 60px */
    }

    .red-elephant-line-2 {
        top: 235px;
        left: 95px; /* 25 + 2*35 = 95px */
    }

    .red-elephant-line-3 {
        top: 235px;
        left: 200px; /* 25 + 5*35 = 200px */
    }

    .red-elephant-line-4 {
        top: 235px;
        left: 235px; /* 25 + 6*35 = 235px */
    }

    .red-elephant-line-5 {
        top: 305px; /* 25 + 8*35 = 305px */
        left: 95px; /* 25 + 2*35 = 95px */
    }

    .red-elephant-line-6 {
        top: 305px;
        left: 130px; /* 25 + 3*35 = 130px */
    }

    .red-elephant-line-7 {
        top: 305px;
        left: 200px;
    }

    .red-elephant-line-8 {
        top: 305px;
        left: 235px;
    }

    .black-elephant-line-1 {
        top: 25px;
        left: 60px;
    }

    .black-elephant-line-2 {
        top: 25px;
        left: 95px;
    }

    .black-elephant-line-3 {
        top: 25px;
        left: 200px;
    }

    .black-elephant-line-4 {
        top: 25px;
        left: 235px;
    }

    .black-elephant-line-5 {
        top: 60px; /* 25 + 1*35 = 60px */
        left: 95px;
    }

    .black-elephant-line-6 {
        top: 60px;
        left: 130px;
    }

    .black-elephant-line-7 {
        top: 60px;
        left: 200px;
    }

    .black-elephant-line-8 {
        top: 60px;
        left: 235px;
    }

    .chess-piece {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-width: 2px;
        /* 移动端也使用transform居中，无需margin调整 */
        transform-origin: center center;
    }

    .board-intersection {
        width: 10px;
        height: 10px;
        margin: -5px 0 0 -5px;
    }

    button {
        padding: 16px 32px;
        font-size: 1.1rem;
        min-height: 48px;
        min-width: 140px;
        /* 移动端按钮更大，更易触摸 */
    }
}