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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: linear-gradient(135deg, #FFF8E7 0%, #FFF0D4 50%, #FFE4B5 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.game-container {
    width: 100%;
    max-width: 900px;
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    overflow: hidden;
}

/* 标题区域 */
.game-header {
    position: relative;
    text-align: center;
    padding: 0;
}

.title-image {
    width: 100%;
    height: auto;
    display: block;
}

.game-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: #FF6B35;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: bold;
    letter-spacing: 5px;
}

/* 模式选择 */
.mode-selection {
    padding: 30px;
    text-align: center;
}

.mode-selection h2 {
    font-size: 1.8rem;
    color: #5D4E37;
    margin-bottom: 25px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border: 3px solid #FFD700;
    border-radius: 15px;
    background: linear-gradient(145deg, #FFF9E6, #FFF0B3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.4);
    background: linear-gradient(145deg, #FFF0B3, #FFE680);
}

.mode-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.mode-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #5D4E37;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 0.9rem;
    color: #8B7355;
}

/* 游戏区域 */
.game-area {
    padding: 15px;
}

/* 信息栏 */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(90deg, #FFE4E1, #FFF0E0, #E0F0FF);
    border-radius: 10px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
}

.red-player {
    color: #DC143C;
}

.black-player {
    color: #2F4F4F;
}

.turn-indicator {
    font-size: 1.5rem;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.turn-indicator.active {
    opacity: 1;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.game-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #FFF;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 棋盘容器 */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* 象棋棋盘 - SVG线条 + 绝对定位棋子 */
.xiangqi-board {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1.1;
    background: linear-gradient(145deg, #F5DEB3, #DEB887, #D2A679);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2), inset 0 0 30px rgba(139, 90, 43, 0.1);
    border: 4px solid #8B5A2B;
    overflow: hidden;
}

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

/* 棋盘格子 - 隐形的点击区域，定位在交叉点上 */
.board-cell {
    position: absolute;
    width: 11%;
    height: 9%;
    cursor: pointer;
    transition: background-color 0.2s;
    z-index: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.board-cell:hover {
    background-color: rgba(255, 215, 0, 0.25);
}

.board-cell.selected {
    background-color: rgba(255, 215, 0, 0.4);
}

.board-cell.valid-move {
    background-color: rgba(144, 238, 144, 0.35);
}

.board-cell.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: #32CD32;
    border-radius: 50%;
    opacity: 0.7;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.board-cell.last-move {
    background-color: rgba(255, 165, 0, 0.25);
}

/* 棋子样式 - 纯CSS绘制 */
.piece {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(14px, 3.5vw, 28px);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.3);
    border: 3px solid;
    user-select: none;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'KaiTi', 'STKaiti', serif;
    position: relative;
}

.piece:hover {
    transform: scale(1.1);
}

.piece.selected-piece {
    animation: bounce 0.5s infinite alternate;
}

/* 红方棋子 */
.piece.red-piece {
    background: radial-gradient(circle at 35% 35%, #FFE0B2, #FF8A65, #E53935);
    border-color: #B71C1C;
    color: #B71C1C;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* 黑方棋子 */
.piece.black-piece {
    background: radial-gradient(circle at 35% 35%, #E0E0E0, #9E9E9E, #424242);
    border-color: #212121;
    color: #212121;
    text-shadow: 0 1px 2px rgba(255,255,255,0.15);
}

/* 棋子内部装饰圈 */
.piece::before {
    content: '';
    position: absolute;
    width: 75%;
    height: 75%;
    border-radius: 50%;
    border: 2px solid;
    opacity: 0.4;
}

.piece.red-piece::before {
    border-color: #B71C1C;
}

.piece.black-piece::before {
    border-color: #616161;
}

/* 学习模式大棋子展示 */
.learn-piece-display .piece {
    width: 120px;
    height: 120px;
    font-size: 48px;
    margin: 15px auto;
}

.learn-piece-display .piece::before {
    width: 80%;
    height: 80%;
}

@keyframes bounce {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

/* 吃掉的棋子 */
.captured-pieces {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 10px;
    background: #F5F5DC;
    border-radius: 10px;
    min-height: 60px;
}

.captured-red, .captured-black {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
}

.captured-red {
    justify-content: flex-start;
}

.captured-black {
    justify-content: flex-end;
}

.captured-piece {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-family: 'Microsoft YaHei', 'PingFang SC', 'KaiTi', 'STKaiti', serif;
}

.captured-piece.red-piece {
    background: radial-gradient(circle at 35% 35%, #FFE0B2, #FF8A65, #E53935);
    border-color: #B71C1C;
    color: #B71C1C;
}

.captured-piece.black-piece {
    background: radial-gradient(circle at 35% 35%, #E0E0E0, #9E9E9E, #424242);
    border-color: #212121;
    color: #212121;
}

/* 消息区域 */
.message-area {
    margin-top: 15px;
    text-align: center;
}

.game-message {
    font-size: 1.1rem;
    color: #5D4E37;
    padding: 10px;
    background: #FFF8DC;
    border-radius: 10px;
    margin-bottom: 10px;
    font-weight: bold;
}

.piece-info {
    font-size: 0.9rem;
    color: #8B7355;
    padding: 8px;
    background: #F0F8FF;
    border-radius: 8px;
    min-height: 40px;
}

/* 弹窗样式 */
.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: 1000;
}

.modal-content {
    background: #FFF;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

/* 学习模式弹窗 */
.learn-content h2 {
    color: #FF6B35;
    margin-bottom: 20px;
}

.learn-piece-display {
    margin: 20px 0;
}

.learn-piece-display img {
    width: 150px;
    height: 150px;
    object-fit: contain;
}

.learn-info {
    background: #FFF8DC;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    text-align: left;
}

.learn-info h3 {
    color: #DC143C;
    margin-bottom: 10px;
}

.learn-info p {
    color: #5D4E37;
    line-height: 1.6;
}

.learn-navigation {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.learn-navigation button {
    padding: 10px 25px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(145deg, #FFD700, #FFA500);
    color: #FFF;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.learn-navigation button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.learn-navigation .speak-btn {
    background: linear-gradient(145deg, #32CD32, #228B22);
    font-size: 1.1rem;
}

.learn-navigation .speak-btn:hover {
    box-shadow: 0 4px 12px rgba(50, 205, 50, 0.4);
}

.learn-navigation .speak-btn.speaking {
    animation: pulse 0.5s infinite;
    background: linear-gradient(145deg, #FF6B35, #FF4500);
}

/* 提示弹窗 */
.hint-content h2 {
    color: #32CD32;
    margin-bottom: 15px;
}

.hint-content p {
    color: #5D4E37;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* 胜利弹窗 */
.win-content h2 {
    color: #FF6B35;
    font-size: 2rem;
    margin-bottom: 15px;
}

.win-content p {
    color: #5D4E37;
    font-size: 1.2rem;
    margin-bottom: 25px;
}

.win-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.win-buttons button {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.win-buttons button:first-child {
    background: linear-gradient(145deg, #32CD32, #228B22);
    color: #FFF;
}

.win-buttons button:last-child {
    background: linear-gradient(145deg, #87CEEB, #4682B4);
    color: #FFF;
}

.win-buttons button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 响应式设计 */
@media (max-width: 600px) {
    .game-title {
        font-size: 1.8rem;
    }
    
    .mode-selection {
        padding: 20px;
    }
    
    .mode-btn {
        padding: 15px;
    }
    
    .info-bar {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .game-controls {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .captured-piece {
        width: 25px;
        height: 25px;
    }
}

/* 动画效果 */
.piece-move {
    animation: movePiece 0.3s ease;
}

@keyframes movePiece {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.capture-effect {
    animation: captureAnim 0.5s ease;
}

@keyframes captureAnim {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.3) rotate(180deg); opacity: 0.5; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}
