/* ============================================================
 * style.css — 中国象棋界面样式（响应式，支持手机端）
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Microsoft YaHei", sans-serif; -webkit-tap-highlight-color: transparent; }

/* 全局响应式：防止横向滚动被撑大 */
html { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
    background: linear-gradient(to bottom, #3b1d0f, #120904);
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

#gameScreen {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow-x: hidden;
}

.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}

/* ---------- 顶部栏 ---------- */
.topbar {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    gap: 10px;
    flex-wrap: wrap;
    overflow: hidden;
}
.topbar > div { min-width: 0; }
.topbar-left, .turn-indicator { flex-shrink: 0; white-space: nowrap; }
.turn-indicator { font-weight: bold; color: #c41e3a; }
#turnText { font-weight: bold; }
.topbar-center {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 3px 10px;
    user-select: none;
}
.eval-label { color: #888; font-size: 12px; }
.eval-score { font-weight: bold; color: #2563eb; }
.eval-best-label { color: #888; font-size: 12px; margin-left: 4px; }
.eval-best { font-weight: bold; color: #16a34a; }

/* ---------- 棋盘容器（绿色外框） ---------- */
.board-wrap {
    position: relative;
    background: #8fbc8f;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* canvas：显示尺寸由 chess.js 的 resizeCanvas() 控制 */
canvas {
    display: block;
    max-width: 100%;
    cursor: pointer;
    border-radius: 14px;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* ---------- 底部按钮 ---------- */
.bottom-bar {
    display: flex;
    gap: 16px;
    margin-top: 18px;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}
.game-btn {
    min-width: 140px;
    height: 46px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    transition: transform .15s, box-shadow .15s, filter .15s;
}
.game-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4); filter: brightness(1.05); }
.game-btn:active { transform: translateY(0) scale(0.97); }
.game-btn-continue {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.game-btn-continue:hover { box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4); }
.game-btn-copy {
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}
.game-btn-copy:hover { box-shadow: 0 6px 16px rgba(22, 163, 74, 0.4); }
.game-btn-settings {
    background: linear-gradient(180deg, #64748b 0%, #475569 100%);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}
.game-btn-settings:hover { box-shadow: 0 6px 16px rgba(100, 116, 139, 0.4); }
.game-btn-settings.active { filter: brightness(1.2); }

/* ---------- 调试日志面板 ---------- */
.debug-log-panel {
    width: 100%;
    max-width: 100%;
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}
.debug-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}
.debug-log-content {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px 14px;
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    line-height: 1.6;
}
.debug-log-content.collapsed { display: none; }
.log-line { margin-bottom: 2px; word-break: break-all; }
.log-info { color: #9ca3af; }
.log-success { color: #10b981; }
.log-error { color: #ef4444; }
.log-warning { color: #f59e0b; }
.log-request { color: #60a5fa; }

/* ---------- 后台设置面板 ---------- */
.settings-panel {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin-top: 4px;
    padding: 14px;
    background: rgba(30, 41, 59, 0.92);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}
.panel-section {
    flex: 1;
    min-width: 0;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    color: #f1f5f9;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.panel-title-btns { display: flex; gap: 6px; }
.mini-btn {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    cursor: pointer;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.2); }

.side-config { display: flex; flex-direction: column; gap: 8px; }
.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.config-label { font-size: 13px; color: #cbd5e1; flex-shrink: 0; }
.config-label.red-label { color: #f87171; font-weight: bold; }
.config-label.black-label { color: #94a3b8; font-weight: bold; }
.config-btns { display: flex; gap: 6px; }
.config-btn {
    padding: 5px 16px;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    cursor: pointer;
    transition: all .15s;
}
.config-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}
.config-btn.full { width: 100%; margin-top: 4px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-btn {
    flex: 1;
    min-width: 70px;
    padding: 7px 0;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    cursor: pointer;
    transition: all .15s;
}
.preset-btn.active {
    background: #f59e0b;
    color: #1e293b;
    border-color: #f59e0b;
    font-weight: bold;
}
.panel-tip { font-size: 11px; color: #64748b; }

.engine-config { display: flex; flex-direction: column; gap: 8px; }
.config-input {
    flex: 1;
    min-width: 0;
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
}
.config-input:focus { outline: none; border-color: #3b82f6; }
.engine-status { font-size: 12px; }
.engine-result {
    font-size: 11px;
    color: #94a3b8;
    white-space: pre-line;
    max-height: 90px;
    overflow-y: auto;
    line-height: 1.5;
}

/* ---------- 棋谱列表 ---------- */
.record-list {
    flex: 1;
    min-height: 120px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.8;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 8px 10px;
}
.record-row { display: flex; gap: 8px; }
.record-round { color: #64748b; width: 28px; flex-shrink: 0; }
.record-move { flex: 1; color: #e2e8f0; }
.record-move.red-move { color: #fca5a5; }
.record-move.black-move { color: #94a3b8; }
.record-move small { color: #64748b; font-size: 10px; }

/* ---------- 历史对局 ---------- */
.history-panel {
    width: 100%;
    max-width: 100%;
    margin-top: 4px;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.history-item {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
}
.history-head { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.history-date { color: #64748b; }
.history-result { font-weight: bold; }
.history-red { color: #f87171; }
.history-black { color: #94a3b8; }
.history-draw { color: #fbbf24; }
.history-count { color: #64748b; margin-left: auto; }
.history-moves { color: #94a3b8; line-height: 1.6; word-break: break-all; }
.history-empty { color: #64748b; text-align: center; padding: 20px 0; font-size: 13px; }

/* ---------- 游戏结束遮罩 ---------- */
.game-over-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.game-over-content { text-align: center; }
.game-over-title {
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 4px;
    margin-bottom: 16px;
}
.game-over-title.red-win { color: #fca5a5; }
.game-over-title.black-win { color: #d1d5db; }
.game-over-title.draw { color: #fcd34d; }
.game-over-subtitle { color: #9ca3af; font-size: 15px; }

/* ---------- 响应式：手机端 ---------- */
@media (max-width: 600px) {
    body {
        align-items: flex-start;
        padding: 10px 0;
        overflow-y: auto;
        min-height: 100vh;
    }
    #gameScreen {
        padding: 10px 8px;
        align-items: flex-start;
        min-height: auto;
    }
    .board-area { width: 100%; gap: 8px; }
    .topbar {
        font-size: 12px;
        padding: 6px 10px;
        gap: 6px;
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
    }
    .topbar > div { min-width: 0; flex-shrink: 1; }
    .topbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
        font-size: 11px;
        flex-shrink: 0;
        padding: 4px 8px;
    }
    .board-wrap { padding: 8px; width: 100%; }
    .game-over-overlay { top: 8px; right: 8px; bottom: 8px; left: 8px; }
    .game-over-title { font-size: 28px; letter-spacing: 2px; }
    .game-over-subtitle { font-size: 13px; }
    .bottom-bar { flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
    .game-btn {
        min-width: auto;
        height: 40px;
        padding: 0 14px;
        font-size: 13px;
        letter-spacing: 0;
    }
    .settings-panel { flex-direction: column; width: 100%; padding: 10px; }
    .settings-col { width: 100%; }
    .record-list { max-height: 160px; }
    .debug-log-content { max-height: 120px; }
}
