/* ============================================================
 *  三人象棋 — 样式文件 (v1.1 增强版)
 *  主题: 古风中国象棋风格
 *  新增: 按钮增强、状态面板重构、消息分类、动画关键帧
 * ============================================================ */

/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, #1a0f0a 0%, #2C1810 50%, #1a0f0a 100%);
    color: #3C2415;
    min-height: 100vh;
}

/* ===== 应用容器 ===== */
#app {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 头部 ===== */
header {
    text-align: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #3C2415, #5D3A1A);
    border-bottom: 3px solid #8B6914;
}

header h1 {
    font-size: 28px;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 4px;
}

header .subtitle {
    font-size: 14px;
    color: #C4A35A;
    margin-top: 4px;
}

/* ===== 主内容区 ===== */
main {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    align-items: flex-start;
    justify-content: center;
}

/* ===== 游戏画布容器 ===== */
#gameContainer {
    flex: 0 0 auto;
    border: 4px solid #8B6914;
    border-radius: 12px;
    box-shadow:
        0 0 30px rgba(139, 105, 20, 0.3),
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 0 2px rgba(139, 105, 20, 0.1);
    background: #F5E6C8;
}

#gameCanvas {
    display: block;
    cursor: pointer;
}

/* ===== 侧边栏 ===== */
#sidebar {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== 面板通用（增强卡片式） ===== */
.panel {
    background: linear-gradient(180deg, #FAF0D7 0%, #F0E0B8 100%);
    border: 2px solid #C4A35A;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: box-shadow 0.3s ease;
}

.panel:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ===== 状态面板（卡片式重构） ===== */
.player-status {
    padding: 10px 14px;
    margin: 6px 0;
    border-radius: 8px;
    font-size: 15px;
    color: #3C2415;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-status:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateX(2px);
}

/* 当前走棋方高亮 */
.player-status.current-player {
    font-weight: bold;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
    animation: currentPlayerGlow 2s ease-in-out infinite;
}

/* 出局玩家样式 */
.player-status.eliminated {
    opacity: 0.5;
    text-decoration: line-through;
    background: rgba(100, 100, 100, 0.15);
}

/* 胜者高亮 */
.player-status.winner {
    font-weight: bold;
    background: rgba(255, 215, 0, 0.3);
    border: 1px solid #FFC107;
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.4);
    animation: winnerGlow 1.5s ease-in-out infinite;
}

/* 将军警告状态 */
.player-status.in-check {
    animation: checkPulse 1s ease-in-out infinite;
}

.color-dot {
    font-size: 18px;
    margin-right: 4px;
    flex-shrink: 0;
}

.status-text {
    flex: 1;
    font-size: 13px;
    text-align: right;
    opacity: 0.8;
}

.game-info {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(139, 105, 20, 0.1);
    border-radius: 6px;
    font-size: 14px;
    color: #5D3A1A;
    text-align: center;
    display: flex;
    justify-content: space-between;
}

/* ===== 消息区域（分类样式） ===== */
#messageArea {
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    min-height: 40px;
    word-break: break-all;
    transition: all 0.3s ease;
    animation: messageFadeIn 0.3s ease-out;
}

.msg-info {
    background: rgba(255, 215, 0, 0.15);
    border-left: 4px solid #FFD700;
    color: #5D3A1A;
}

.msg-warning {
    background: rgba(255, 152, 0, 0.2);
    border-left: 4px solid #FF9800;
    color: #E65100;
    font-weight: bold;
}

.msg-danger {
    background: rgba(244, 67, 54, 0.15);
    border-left: 4px solid #F44336;
    color: #C62828;
    font-weight: bold;
}

.msg-success {
    background: rgba(76, 175, 80, 0.15);
    border-left: 4px solid #4CAF50;
    color: #2E7D32;
    font-weight: bold;
}

/* ===== 按钮（增强交互） ===== */
#controlPanel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.btn:active {
    transform: translateY(0) scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, #8B6914, #C4A35A);
    color: #2C1810;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #A07818, #D4B36A);
    box-shadow: 0 6px 16px rgba(139, 105, 20, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #5D3A1A, #8B6914);
    color: #F5E6C8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #6D4A2A, #9B7924);
    box-shadow: 0 6px 16px rgba(93, 58, 26, 0.4);
}

/* ===== 规则面板 ===== */
#rulesPanel h3 {
    font-size: 16px;
    color: #5D3A1A;
    margin-bottom: 8px;
    border-bottom: 1px solid #C4A35A;
    padding-bottom: 6px;
}

#rulesPanel ul {
    list-style: none;
    padding: 0;
}

#rulesPanel li {
    font-size: 13px;
    color: #5D3A1A;
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

#rulesPanel li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: #8B6914;
    font-weight: bold;
}

/* ===== 底部 ===== */
footer {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #3C2415, #5D3A1A);
    color: #C4A35A;
    font-size: 12px;
    border-top: 2px solid #8B6914;
}

/* ===== CSS动画关键帧 ===== */

/* 将军警告脉冲 */
@keyframes checkPulse {
    0%, 100% { background-color: rgba(255, 0, 0, 0.1); }
    50% { background-color: rgba(255, 0, 0, 0.25); }
}

/* 当前玩家呼吸光晕 */
@keyframes currentPlayerGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 14px rgba(255, 215, 0, 0.4); }
}

/* 胜者光晕 */
@keyframes winnerGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* 消息淡入 */
@keyframes messageFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
    main {
        flex-direction: column;
        align-items: center;
    }

    #sidebar {
        flex: 0 0 auto;
        width: 100%;
        max-width: 600px;
    }

    #gameContainer {
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    #gameContainer canvas {
        max-width: 100vw;
        height: auto;
    }
    #sidebar {
        font-size: 13px;
    }
    header h1 {
        font-size: 22px;
    }
}

/* ============================================================
 *  走棋历史面板 & 被吃棋子展示 — 新增样式 (v1.2)
 * ============================================================ */

/* ===== 面板标题通用 ===== */
.panel-title {
    font-size: 14px;
    color: #5D3A1A;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #C4A35A;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== 走棋历史面板 ===== */
#moveHistoryPanel {
    max-height: 320px;
    display: flex;
    flex-direction: column;
}

.move-history-list {
    flex: 1;
    overflow-y: auto;
    max-height: 260px;
    padding-right: 4px;
    scroll-behavior: smooth;
}

.move-history-list::-webkit-scrollbar {
    width: 6px;
}
.move-history-list::-webkit-scrollbar-track {
    background: rgba(139, 105, 20, 0.1);
    border-radius: 3px;
}
.move-history-list::-webkit-scrollbar-thumb {
    background: #C4A35A;
    border-radius: 3px;
}

.move-entry {
    padding: 6px 10px;
    margin: 2px 0;
    border-radius: 6px;
    font-size: 13px;
    font-family: "SimSun", "STSong", "Microsoft YaHei", serif;
    color: #3C2415;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    cursor: default;
    line-height: 1.5;
    border-left: 3px solid transparent;
    animation: moveEntryFadeIn 0.3s ease-out;
}

.move-entry:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateX(2px);
}

.move-entry.player-red   { border-left-color: #CC0000; }
.move-entry.player-green { border-left-color: #008800; }
.move-entry.player-blue  { border-left-color: #0044CC; }

.move-entry.move-latest {
    background: rgba(255, 215, 0, 0.25);
    border-left-width: 4px;
    font-weight: bold;
}

.move-entry.move-capture {
    background: rgba(255, 100, 100, 0.08);
}

.move-entry.move-check {
    background: rgba(255, 152, 0, 0.12);
    animation: checkHighlight 2s ease-in-out;
}

.move-entry.move-checkmate {
    background: rgba(244, 67, 54, 0.1);
    border-left-color: #F44336 !important;
    border-left-width: 4px !important;
    font-weight: bold;
}

.move-empty-hint {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 20px 0;
    font-style: italic;
}

/* ===== 被吃棋子面板 ===== */
#capturedPanel {
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

#capturedContent {
    flex: 1;
    overflow-y: auto;
    max-height: 200px;
    padding-right: 4px;
}

#capturedContent::-webkit-scrollbar {
    width: 6px;
}
#capturedContent::-webkit-scrollbar-track {
    background: rgba(139, 105, 20, 0.1);
    border-radius: 3px;
}
#capturedContent::-webkit-scrollbar-thumb {
    background: #C4A35A;
    border-radius: 3px;
}

.captured-group {
    margin: 5px 0;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.35);
    transition: background 0.2s ease;
}

.captured-group:hover {
    background: rgba(255, 255, 255, 0.55);
}

.captured-group-header {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 13px;
    color: #5D3A1A;
}

.captured-pieces-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.captured-piece-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    font-family: "SimSun", "STSong", serif;
    color: #FFF;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.captured-piece-badge:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.captured-piece-badge.red-piece {
    background: linear-gradient(135deg, #D42020, #A01010);
}
.captured-piece-badge.green-piece {
    background: linear-gradient(135deg, #10A030, #086018);
}
.captured-piece-badge.blue-piece {
    background: linear-gradient(135deg, #2058D0, #1038A0);
}

.captured-empty-hint {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 16px 0;
    font-style: italic;
}

/* ===== 动画关键帧 ===== */
@keyframes moveEntryFadeIn {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes checkHighlight {
    0%, 100% { background-color: rgba(255, 152, 0, 0.08); }
    50% { background-color: rgba(255, 152, 0, 0.2); }
}
