/* ==========================================================================
   中国象棋 · 音游霓虹风格 (节奏打击统一 UI)
   --------------------------------------------------------------------------
   设计规范:
   - 背景: linear-gradient(180deg,#1a0a3a 0%,#0a0a1a 60%,#001a2a 100%) 固定
   - 主色: 霓虹青 #7ef2ff / 金 #ffd700 / 粉 #ff9ad5 / 蓝 #2196f3
   - 玻璃卡片: rgba(255,255,255,.07) + 白边 + 圆角12-16px + blur(8px)
   - 按钮: 玻璃底 + 白边 + 圆角12px, hover 发光; 主按钮霓虹渐变
   - 标题: 渐变文字 (青→金)
   - 说明: 所有 id / 类名 / JS 绑定保持不变, 仅视觉与文字调整
   ========================================================================== */

:root {
    --neon-cyan: #7ef2ff;
    --neon-gold: #ffd700;
    --neon-pink: #ff9ad5;
    --neon-blue: #2196f3;
    --neon-orange: #ffb300;
    --glass-bg: rgba(255, 255, 255, .07);
    --glass-border: rgba(255, 255, 255, .13);
    --text-main: #eef2ff;
    --text-dim: rgba(238, 242, 255, .62);
    --text-faint: rgba(238, 242, 255, .38);
    --red-neon: #ff9ad5;          /* 红方 → 霓虹粉 */
    --black-neon: #7ef2ff;        /* 黑方 → 霓虹青 */
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-card: 0 12px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}

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

html {
    min-height: 100%;
    background: linear-gradient(180deg, #1a0a3a 0%, #0a0a1a 60%, #001a2a 100%) fixed;
}

body {
    min-height: 100vh;
    font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: transparent;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 16px;
    position: relative;
}

/* ---------- 背景氛围: 霓虹光斑 + 顶部扫描光束 (音游感) ---------- */
body::before {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    width: 62vmax;
    height: 62vmax;
    top: -24vmax;
    left: -18vmax;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(33, 150, 243, .4), rgba(126, 242, 255, .12) 45%, transparent 65%);
    filter: blur(70px);
    opacity: .5;
}

body::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(126, 242, 255, 0) 28%,
        rgba(126, 242, 255, .75) 47%,
        rgba(255, 215, 0, .75) 57%,
        rgba(255, 154, 213, 0) 75%,
        transparent 100%);
    background-size: 220% 100%;
    opacity: .5;
    animation: beam-sweep 9s linear infinite;
}

@keyframes beam-sweep {
    0% { background-position: 220% 0; }
    100% { background-position: -220% 0; }
}

/* ---------- 顶部导航栏 (玻璃胶囊) ---------- */
.top-nav {
    width: 100%;
    max-width: 700px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.nav-brand {
    font-size: clamp(15px, 3vw, 18px);
    font-weight: 800;
    letter-spacing: 2px;
    white-space: nowrap;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: clamp(13px, 2.5vw, 14px);
    padding: 7px 12px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    letter-spacing: .5px;
    transition: color .15s, background .15s, border-color .15s, box-shadow .2s;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
    box-shadow: 0 0 14px rgba(33, 150, 243, .25);
}

.nav-link.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(33, 150, 243, .8), rgba(255, 179, 0, .7)) !important;
    border-color: rgba(255, 255, 255, .25) !important;
    box-shadow: 0 2px 16px rgba(33, 150, 243, .45) !important;
}

/* 已登录用户信息 */
.nav-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, .14);
}

.nav-username {
    font-size: clamp(12px, 2.5vw, 13px);
    color: var(--neon-gold);
    white-space: nowrap;
}

.nav-logout-btn {
    font-family: inherit;
    font-size: clamp(11px, 2.2vw, 12px);
    padding: 6px 10px;
    min-height: 30px;
    background: rgba(255, 255, 255, .06);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s ease;
}

.nav-logout-btn:hover {
    color: #fff;
    border-color: rgba(255, 82, 82, .6);
    background: rgba(255, 82, 82, .18);
    box-shadow: 0 0 12px rgba(255, 82, 82, .3);
}

/* ---------- 容器与标题 ---------- */
.container {
    text-align: center;
    max-width: 700px;
    width: 100%;
}

h1 {
    font-size: clamp(22px, 5vw, 30px);
    font-weight: 800;
    margin-bottom: clamp(12px, 2vw, 18px);
    letter-spacing: clamp(3px, .6vw, 6px);
    background: linear-gradient(90deg, #7ef2ff, #ffd700);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 14px rgba(126, 242, 255, .35));
}

/* ---------- 状态栏 (回合指示 / 游戏信息) ---------- */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: clamp(8px, 1.5vw, 12px) clamp(12px, 2.5vw, 16px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.turn-indicator {
    color: var(--text-dim);
    font-size: clamp(14px, 3vw, 16px);
    letter-spacing: 1px;
}

.turn-red {
    color: var(--red-neon);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 154, 213, .45);
}

.turn-black {
    color: var(--black-neon);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(126, 242, 255, .45);
}

/* ---------- 求和横幅 ---------- */
.draw-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: clamp(7px, 1.5vw, 9px) clamp(12px, 2.5vw, 16px);
    background: rgba(255, 215, 0, .1);
    border: 1px solid rgba(255, 215, 0, .35);
    border-radius: var(--radius-md);
    font-size: clamp(13px, 2.5vw, 15px);
    color: var(--neon-gold);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 0 20px rgba(255, 215, 0, .15);
    letter-spacing: .5px;
}

/* ---------- 按钮 ---------- */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(7px, 1.4vw, 9px) clamp(14px, 2.6vw, 18px);
    min-height: 40px;
    font-size: clamp(13px, 2.5vw, 14px);
    font-family: inherit;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius-md);
    cursor: pointer;
    letter-spacing: 1px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .4);
    transition: transform .15s, box-shadow .25s, background .2s, filter .2s, border-color .2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, .14);
    box-shadow: 0 0 18px rgba(33, 150, 243, .35), inset 0 0 12px rgba(255, 255, 255, .05);
}

.action-btn:active {
    transform: scale(.96);
}

.action-btn.active {
    background: linear-gradient(90deg, rgba(33, 150, 243, .75), rgba(255, 179, 0, .65)) !important;
    border-color: rgba(126, 242, 255, .5) !important;
    box-shadow: 0 0 14px rgba(33, 150, 243, .4) !important;
    color: #fff !important;
}

.action-btn.danger {
    background: rgba(255, 82, 82, .2);
    border-color: rgba(255, 82, 82, .45);
    color: #ffc9d4;
}

.action-btn.danger:hover {
    background: rgba(255, 82, 82, .32);
    border-color: rgba(255, 82, 82, .65);
    box-shadow: 0 0 18px rgba(255, 82, 82, .35);
}

.action-btn.success {
    background: linear-gradient(90deg, rgba(0, 200, 160, .55), rgba(126, 242, 255, .4)) !important;
    border-color: rgba(126, 242, 255, .4) !important;
    color: #fff !important;
}

.action-btn.success:hover {
    box-shadow: 0 0 18px rgba(126, 242, 255, .4);
    filter: brightness(1.08);
}

.action-btn.small {
    padding: 5px 12px;
    min-height: 34px;
    font-size: 12px;
}

/* 主按钮: 霓虹渐变 (同时被 game-ui.css 的 [class*="primary"] 规则命中) */
.btn-primary {
    background: linear-gradient(90deg, #2196f3, #ffb300) !important;
    border-color: rgba(255, 255, 255, .28) !important;
    box-shadow: 0 4px 18px rgba(33, 150, 243, .4) !important;
    font-weight: 700;
}

.btn-primary:hover {
    filter: brightness(1.12);
    box-shadow: 0 0 24px rgba(33, 150, 243, .55), inset 0 0 12px rgba(255, 255, 255, .08) !important;
}

/* ---------- 棋盘 ---------- */
.board-wrapper {
    display: flex;
    justify-content: center;
}

.board-container {
    position: relative;
    width: 630px;
    max-width: 95vw;
    aspect-ratio: 630 / 700;
    border-radius: 14px;
    overflow: hidden;
    background: #0e1024;
    border: 1px solid rgba(255, 255, 255, .14);
    box-shadow:
        0 0 0 1px rgba(126, 242, 255, .12),
        0 0 34px rgba(33, 150, 243, .22),
        0 18px 50px rgba(0, 0, 0, .5);
}

/* 棋盘内侧轻微暗角, 让木纹棋盘融入深色背景 */
.board-container::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 14px;
    box-shadow: inset 0 0 46px rgba(0, 0, 0, .32);
}

.board-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: saturate(1.12) contrast(1.03);
}

.pieces-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.piece {
    position: absolute;
    width: 8.8%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    pointer-events: auto;
    cursor: pointer;
    transition: transform .15s ease, filter .2s ease;
    transform: translate(-50%, -50%);
}

.piece:hover {
    transform: translate(-50%, -50%) scale(1.08);
    filter: drop-shadow(0 0 8px rgba(126, 242, 255, .5));
}

.piece.selected {
    outline: clamp(2px, .5vw, 3px) solid var(--neon-cyan);
    outline-offset: 2px;
    filter: drop-shadow(0 0 10px rgba(126, 242, 255, .8));
}

.piece.capture-highlight {
    filter: brightness(1.15) drop-shadow(0 0 8px rgba(255, 154, 213, .8));
}

.piece.move-to {
    animation: moveToPulse .5s ease-out;
    filter: drop-shadow(0 0 8px rgba(126, 242, 255, .9));
}

@keyframes moveToPulse {
    0% { filter: drop-shadow(0 0 14px rgba(126, 242, 255, 1)); }
    100% { filter: drop-shadow(0 0 8px rgba(126, 242, 255, .9)); }
}

.move-from-marker {
    position: absolute;
    width: 50px;
    height: 50px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-color: rgba(255, 215, 0, .25);
    border: 2px dashed rgba(255, 215, 0, .7);
    box-shadow: 0 0 12px rgba(255, 215, 0, .3);
    pointer-events: none;
    animation: fadeIn .3s ease-out;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.click-areas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.click-area {
    position: absolute;
    width: 10.3%;
    height: auto;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    background: transparent;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    transition: background .15s, box-shadow .15s;
}

.click-area:hover {
    background: rgba(255, 255, 255, .1);
}

.click-area.valid-move {
    background: radial-gradient(circle, rgba(126, 242, 255, .3), rgba(126, 242, 255, .08) 70%);
    box-shadow: inset 0 0 12px rgba(126, 242, 255, .3);
}

.click-area.valid-move:hover {
    background: radial-gradient(circle, rgba(126, 242, 255, .42), rgba(126, 242, 255, .12) 70%);
}

.click-area.valid-capture {
    background: radial-gradient(circle, rgba(255, 154, 213, .32), rgba(255, 154, 213, .08) 70%);
    box-shadow: inset 0 0 12px rgba(255, 154, 213, .3);
}

.click-area.valid-capture:hover {
    background: radial-gradient(circle, rgba(255, 154, 213, .45), rgba(255, 154, 213, .12) 70%);
}

/* 上一步棋高亮 */
.click-area.last-move-from {
    background: rgba(255, 215, 0, .22);
    border: 2px dashed rgba(255, 215, 0, .55);
}

.click-area.last-move-to {
    background: rgba(126, 242, 255, .2);
    border: 2px solid rgba(126, 242, 255, .55);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

/* 复盘回顾中的棋盘光晕 */
.board-container.reviewing {
    box-shadow:
        0 0 0 2px rgba(126, 242, 255, .55),
        0 0 26px rgba(126, 242, 255, .35),
        0 18px 50px rgba(0, 0, 0, .5);
}

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(6px, 1.2vw, 10px);
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, .15);
    margin: 0 6px;
    align-self: center;
}

/* ---------- 调整棋子面板 ---------- */
.adjust-panel {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .07) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-lg) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-card) !important;
}

.adjust-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: clamp(13px, 2.5vw, 15px);
    font-weight: 600;
}

.adjust-hint {
    font-size: clamp(11px, 2vw, 13px);
    color: var(--text-faint);
}

.adjust-pieces {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adjust-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.adjust-group-label {
    font-size: clamp(12px, 2vw, 14px);
    color: var(--text-dim);
    font-weight: 600;
    min-width: 34px;
}

.adjust-pieces-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.adjust-piece {
    width: clamp(30px, 6vw, 40px);
    height: clamp(30px, 6vw, 40px);
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    padding: 2px;
    transition: border-color .15s, background .15s, box-shadow .2s, transform .15s;
}

.adjust-piece:hover {
    border-color: rgba(126, 242, 255, .5);
    background: rgba(126, 242, 255, .08);
    transform: scale(1.06);
}

.adjust-piece.selected {
    border-color: var(--neon-cyan) !important;
    background: rgba(126, 242, 255, .12) !important;
    box-shadow: 0 0 12px rgba(126, 242, 255, .35) !important;
}

/* ---------- 走棋记录 ---------- */
.history-section {
    margin-top: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: clamp(13px, 2.5vw, 15px);
    color: var(--text-dim);
    user-select: none;
    background: rgba(255, 255, 255, .04);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    transition: background .15s, color .15s;
}

.history-header:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.history-section .history-title {
    flex-shrink: 0;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
}

/* 历史记录翻页按钮 */
.history-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hist-nav-btn {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .14);
    color: #fff;
    padding: 5px 10px;
    min-height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: clamp(12px, 2.2vw, 14px);
    line-height: 1.4;
    transition: background .15s, border-color .15s, box-shadow .2s;
}

.hist-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(126, 242, 255, .4);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

.hist-nav-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.hist-position {
    font-size: clamp(11px, 2vw, 13px);
    color: var(--text-faint);
    min-width: 48px;
    text-align: center;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 6px 0;
}

.history-list .history-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1px 6px !important;
    padding: 5px 10px !important;
    border: none !important;
    border-radius: 8px !important;
    background: transparent !important;
    font-size: clamp(12px, 2.5vw, 14px);
    transition: background .15s;
}

.history-list .history-row:nth-child(odd) {
    background: rgba(255, 255, 255, .03) !important;
}

.history-list .history-row:hover {
    background: rgba(255, 255, 255, .07) !important;
}

.history-num {
    color: var(--text-faint);
    min-width: 28px;
    font-variant-numeric: tabular-nums;
}

.history-red {
    color: var(--red-neon);
    min-width: 80px;
}

.history-black {
    color: rgba(238, 242, 255, .75);
}

.history-move {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 8px;
    transition: background .15s, box-shadow .2s;
    flex: 1;
}

.history-move:hover {
    background: rgba(126, 242, 255, .12);
}

/* 当前查看的着法高亮 */
.history-move.history-current {
    background: linear-gradient(90deg, rgba(33, 150, 243, .4), rgba(126, 242, 255, .18)) !important;
    border-color: rgba(126, 242, 255, .5) !important;
    box-shadow: 0 0 10px rgba(126, 242, 255, .25) !important;
    color: #fff;
}

.history-empty {
    padding: 12px;
    color: var(--text-faint);
    font-size: 13px;
    text-align: center;
}

/* ---------- 消息 ---------- */
.message {
    margin-top: 10px;
    padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2.5vw, 14px);
    font-size: clamp(13px, 2.5vw, 15px);
    color: var(--text-dim);
    min-height: clamp(28px, 7vw, 36px);
    letter-spacing: .5px;
    transition: color .2s;
}

.message.error {
    color: #ff8fa3;
    text-shadow: 0 0 12px rgba(255, 82, 82, .35);
}

.message.success {
    color: #6ff7c4;
    text-shadow: 0 0 12px rgba(0, 220, 160, .35);
}

.message.warning {
    color: var(--neon-gold);
    text-shadow: 0 0 12px rgba(255, 215, 0, .35);
}

/* ---------- 通用面板 (分析 / 复盘 / 导入导出 / 聊天) ---------- */
.analyze-panel, .review-panel, .io-panel, .chat-panel {
    margin-top: 12px;
    background: rgba(255, 255, 255, .07) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-lg) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    overflow: hidden;
    text-align: left;
    box-shadow: var(--shadow-card) !important;
}

.analyze-header, .review-header, .io-header, .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-size: clamp(13px, 2.5vw, 15px);
    font-weight: 700;
    background: linear-gradient(90deg, rgba(33, 150, 243, .18), rgba(255, 179, 0, .1));
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.close-btn {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--text-dim);
    font-size: 18px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s, box-shadow .2s;
}

.close-btn:hover {
    color: #fff;
    background: rgba(255, 82, 82, .25);
    box-shadow: 0 0 12px rgba(255, 82, 82, .3);
}

.analyze-content, .review-content, .io-content, .chat-content {
    padding: 12px 14px;
}

.analyze-loading, .review-loading {
    text-align: center;
    color: var(--text-faint);
    padding: 18px;
    letter-spacing: 2px;
    animation: loading-blink 1.2s ease-in-out infinite;
}

@keyframes loading-blink {
    0%, 100% { opacity: .45; }
    50% { opacity: 1; }
}

.analyze-recommendation, .analyze-evaluation {
    margin-bottom: 8px;
    font-size: clamp(12px, 2.2vw, 14px);
}

.analyze-label {
    color: var(--text-faint);
    margin-right: 4px;
}

.analyze-desc {
    color: var(--neon-gold);
    font-weight: 600;
}

.analyze-score {
    color: var(--neon-cyan);
    font-weight: 600;
}

/* ---------- 复盘面板 ---------- */
.review-list {
    max-height: 300px;
    overflow-y: auto;
}

.review-list .review-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 !important;
    padding: 7px 4px !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
    border-radius: 10px !important;
    background: transparent !important;
    font-size: clamp(12px, 2.2vw, 14px);
}

.review-num {
    color: var(--text-faint);
    min-width: 32px;
}

.review-color {
    color: var(--neon-gold);
    min-width: 24px;
}

.review-desc {
    flex: 1;
    color: #dfe6ff;
}

.review-quality {
    min-width: 48px;
    text-align: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: clamp(11px, 2vw, 12px);
    font-weight: 600;
    letter-spacing: 1px;
}

.review-excellent {
    background: rgba(0, 220, 160, .18);
    color: #6ff7c4;
    box-shadow: 0 0 10px rgba(0, 220, 160, .2);
}

.review-good {
    background: rgba(33, 150, 243, .2);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(33, 150, 243, .2);
}

.review-miss {
    background: rgba(255, 165, 0, .18);
    color: #ffc46b;
}

.review-bad {
    background: rgba(255, 82, 82, .2);
    color: #ff8fa3;
}

.review-comment {
    color: var(--text-faint);
    font-size: clamp(11px, 2vw, 12px);
}

.review-empty {
    text-align: center;
    color: var(--text-faint);
    padding: 16px;
}

/* ---------- 导入 / 导出面板 ---------- */
.io-mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.io-tab {
    flex: 1;
    padding: 9px 12px;
    min-height: 40px;
    background: rgba(255, 255, 255, .06);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: clamp(12px, 2.2vw, 14px);
    letter-spacing: 1px;
    transition: all .15s ease;
}

.io-tab:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.io-tab.active {
    background: linear-gradient(90deg, rgba(33, 150, 243, .75), rgba(255, 179, 0, .65)) !important;
    color: #fff !important;
    border-color: rgba(126, 242, 255, .45) !important;
    box-shadow: 0 0 12px rgba(33, 150, 243, .35) !important;
}

.io-format-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.io-format-label {
    color: var(--text-faint);
    font-size: clamp(12px, 2.2vw, 13px);
    flex-shrink: 0;
}

.io-format-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.io-chip {
    padding: 6px 14px;
    background: rgba(255, 255, 255, .06);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-size: clamp(11px, 2vw, 12px);
    letter-spacing: 1px;
    transition: all .15s ease;
    user-select: none;
}

.io-chip:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-color: rgba(126, 242, 255, .4);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

.io-chip.active {
    background: linear-gradient(90deg, rgba(33, 150, 243, .75), rgba(255, 179, 0, .65)) !important;
    color: #fff !important;
    border-color: rgba(126, 242, 255, .5) !important;
    box-shadow: 0 0 12px rgba(33, 150, 243, .35) !important;
    font-weight: 700;
}

.io-textarea {
    width: 100%;
    min-height: 110px;
    max-height: 240px;
    padding: 10px 12px;
    background: rgba(10, 12, 32, .6);
    color: #dfe6ff;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--radius-md);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: clamp(11px, 2vw, 13px);
    line-height: 1.5;
    resize: vertical;
    word-break: break-all;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.io-textarea:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 14px rgba(126, 242, 255, .25);
}

.io-textarea[readonly] {
    background: rgba(10, 12, 32, .35);
    color: var(--text-dim);
    cursor: default;
}

.io-hint {
    margin-top: 6px;
    color: var(--text-faint);
    font-size: clamp(11px, 2vw, 12px);
    min-height: 1em;
    line-height: 1.4;
}

.io-hint.io-error {
    color: #ff8fa3 !important;
}

.io-hint.io-success {
    color: #6ff7c4 !important;
}

.io-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ---------- 聊天面板 ---------- */
.chat-messages {
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    display: flex;
    gap: 6px;
    padding: 2px 0;
    font-size: clamp(12px, 2.2vw, 14px);
    align-items: flex-start;
}

.chat-me {
    justify-content: flex-end;
}

.chat-me .chat-name {
    color: var(--neon-cyan);
}

.chat-me .chat-text {
    background: linear-gradient(90deg, rgba(33, 150, 243, .45), rgba(33, 150, 243, .22));
    color: #fff;
    border: 1px solid rgba(126, 242, 255, .3);
}

.chat-other {
    justify-content: flex-start;
}

.chat-other .chat-name {
    color: var(--neon-gold);
}

.chat-other .chat-text {
    background: rgba(255, 255, 255, .09);
    color: #e6ebff;
    border: 1px solid rgba(255, 255, 255, .1);
}

.chat-name {
    min-width: 60px;
    font-weight: 600;
}

.chat-text {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    max-width: 72%;
    word-break: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}

.chat-input-area {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .16);
    color: #fff;
    padding: 10px 12px;
    min-height: 42px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: clamp(12px, 2.2vw, 14px);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.chat-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.chat-send-btn {
    background: linear-gradient(90deg, #2196f3, #ffb300);
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    padding: 8px 20px;
    min-height: 42px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: clamp(12px, 2.2vw, 14px);
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: 0 4px 18px rgba(33, 150, 243, .4);
    transition: filter .2s, box-shadow .2s, transform .15s;
}

.chat-send-btn:hover {
    filter: brightness(1.12);
    box-shadow: 0 0 22px rgba(33, 150, 243, .55);
}

.chat-send-btn:active {
    transform: scale(.96);
}

/* ---------- 推演面板 (浮动窗口) ---------- */
.deduce-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: min(720px, 95vw);
    max-height: 90vh;
    background: rgba(15, 17, 48, .88) !important;
    border: 1px solid rgba(126, 242, 255, .28) !important;
    border-radius: 18px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 40px rgba(33, 150, 243, .22) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    overflow: hidden;
    flex-direction: column;
}

.deduce-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(33, 150, 243, .22), rgba(255, 179, 0, .12));
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.deduce-header .deduce-title {
    font-size: clamp(14px, 2.6vw, 16px);
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
}

.deduce-hint {
    flex: 1;
    font-size: clamp(11px, 2vw, 12px);
    color: var(--text-dim);
}

.deduce-body {
    display: flex;
    gap: 14px;
    padding: 14px;
    overflow: auto;
}

.deduce-board-wrapper {
    flex-shrink: 0;
}

.deduce-board-container {
    position: relative;
    width: clamp(280px, 42vw, 390px);
    aspect-ratio: 9 / 10;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 0 20px rgba(33, 150, 243, .15);
}

.deduce-board-container .board-image {
    width: 100%;
    height: 100%;
    display: block;
    filter: saturate(1.12) contrast(1.03);
}

.deduce-board-container .pieces-layer,
.deduce-board-container .click-areas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.deduce-board-container .move-from-marker {
    width: 28px;
    height: 28px;
}

.deduce-sidebar {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deduce-turn {
    font-size: clamp(13px, 2.4vw, 15px);
    color: #dfe6ff;
    padding: 10px 12px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--radius-md);
}

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

.deduce-history-header {
    font-size: clamp(12px, 2.2vw, 14px);
    color: var(--text-dim);
    font-weight: 600;
    letter-spacing: 1px;
    padding: 4px 2px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.deduce-history-list {
    flex: 1;
    max-height: 260px;
    overflow-y: auto;
    font-size: clamp(12px, 2.2vw, 14px);
}

/* ---------- 联机大厅 ---------- */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: clamp(13px, 2.5vw, 15px);
    color: #dfe6ff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.lobby-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 14px;
    text-align: left;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-card);
}

.lobby-section h2 {
    font-size: clamp(15px, 3vw, 17px);
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
}

.lobby-hint {
    font-size: clamp(12px, 2vw, 13px);
    color: var(--text-faint);
    margin-bottom: 12px;
}

.join-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.join-row .auth-input {
    flex: 1;
    min-width: 140px;
}

.lobby-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.room-info {
    padding: 10px 14px;
    margin-bottom: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: clamp(12px, 2.5vw, 14px);
    color: #dfe6ff;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
    word-break: break-all;
}

/* 同步中指示器 */
.pending-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--neon-gold);
    background: rgba(255, 215, 0, .1);
    border: 1px solid rgba(255, 215, 0, .4);
    border-radius: 999px;
    animation: pending-pulse 1.2s ease-in-out infinite;
}

.pending-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-gold);
    box-shadow: 0 0 8px var(--neon-gold);
    animation: pending-blink 1s ease-in-out infinite;
}

@keyframes pending-pulse {
    0%, 100% { opacity: .85; }
    50% { opacity: 1; }
}

@keyframes pending-blink {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* ---------- 登录 / 注册 ---------- */
.auth-container {
    max-width: 400px;
    margin-top: 20px;
    width: 100%;
}

.auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    padding: 5px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    min-height: 42px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: clamp(13px, 2.5vw, 15px);
    border-radius: 10px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all .15s ease;
}

.auth-tab:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.auth-tab.active {
    background: linear-gradient(90deg, rgba(33, 150, 243, .75), rgba(255, 179, 0, .65)) !important;
    color: #fff !important;
    border-color: rgba(126, 242, 255, .45) !important;
    box-shadow: 0 0 14px rgba(33, 150, 243, .35) !important;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-card);
}

.auth-input {
    width: 100%;
    padding: 11px 14px;
    min-height: 44px;
    font-family: inherit;
    font-size: clamp(13px, 2.5vw, 15px);
    background: rgba(255, 255, 255, .07);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.auth-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 14px rgba(126, 242, 255, .25);
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.auth-submit {
    margin-top: 6px;
    padding: 11px;
    min-height: 44px;
    font-size: clamp(13px, 2.5vw, 15px);
    font-weight: 700;
    letter-spacing: 3px;
}

.auth-footer {
    margin-top: 14px;
    font-size: 13px;
}

.auth-subtitle {
    color: var(--text-dim);
    font-size: clamp(13px, 2.5vw, 15px);
    margin-bottom: 16px;
    margin-top: -6px;
    letter-spacing: 1px;
}

/* ---------- 人机对战 ---------- */
.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.difficulty-label {
    font-size: clamp(12px, 2.5vw, 14px);
    color: var(--text-dim);
    white-space: nowrap;
    letter-spacing: 1px;
}

.difficulty-select {
    padding: 8px 12px;
    min-height: 40px;
    font-size: clamp(12px, 2.5vw, 14px);
    font-family: inherit;
    background: rgba(255, 255, 255, .07);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius-md);
    outline: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}

.difficulty-select:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

.difficulty-select option {
    background: #14163c;
    color: #fff;
}

.ai-thinking {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 9px 14px;
    background: rgba(33, 150, 243, .14);
    border: 1px solid rgba(126, 242, 255, .35);
    border-radius: var(--radius-md);
    font-size: clamp(13px, 2.5vw, 15px);
    color: var(--neon-cyan);
    letter-spacing: 1px;
    box-shadow: 0 0 18px rgba(33, 150, 243, .2);
}

.thinking-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-cyan);
    box-shadow: 0 0 12px var(--neon-cyan);
    animation: thinking-pulse 1.2s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: .5;
    }
    50% {
        transform: scale(1.4);
        opacity: 1;
    }
}

.last-move-info {
    display: flex;
    justify-content: center;
    gap: clamp(16px, 4vw, 26px);
    margin-bottom: 10px;
    padding: clamp(5px, 1vw, 8px) clamp(12px, 2.5vw, 16px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: clamp(12px, 2.5vw, 14px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.last-move-player {
    color: var(--red-neon);
}

.last-move-ai {
    color: var(--neon-cyan);
}

.last-move-player span,
.last-move-ai span {
    font-weight: 600;
}

/* ---------- 棋盘防抖 (渲染时禁用动画) ---------- */
.pieces-layer.no-anim .piece {
    transition: none !important;
}

.pieces-layer.no-anim .move-from-marker {
    animation: none !important;
}

/* ---------- 复盘回放 (保留兼容, 当前页面未用) ---------- */
.replay-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.replay-btn {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .14);
    color: #fff;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all .15s ease;
}

.replay-btn:hover {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(126, 242, 255, .4);
    box-shadow: 0 0 12px rgba(126, 242, 255, .25);
}

.replay-position {
    font-size: clamp(13px, 2.5vw, 15px);
    color: var(--text-faint);
    min-width: 60px;
    text-align: center;
}

.replay-list {
    max-height: 250px;
    overflow-y: auto;
}

.replay-list .replay-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 !important;
    padding: 7px 8px !important;
    border: none !important;
    border-radius: 10px !important;
    background: transparent !important;
    cursor: pointer;
    transition: background .15s;
    font-size: clamp(12px, 2.2vw, 14px);
}

.replay-list .replay-row:hover {
    background: rgba(255, 255, 255, .08) !important;
}

.replay-list .replay-row.replay-current {
    background: linear-gradient(90deg, rgba(33, 150, 243, .4), rgba(126, 242, 255, .18)) !important;
    border-color: rgba(126, 242, 255, .5) !important;
    box-shadow: 0 0 10px rgba(126, 242, 255, .25) !important;
}

.replay-num {
    color: var(--text-faint);
    min-width: 32px;
}

.replay-color {
    color: var(--neon-gold);
    min-width: 24px;
}

.replay-desc {
    color: #dfe6ff;
}

.replay-empty {
    text-align: center;
    color: var(--text-faint);
    padding: 16px;
}

/* ---------- 滚动条 ---------- */
.history-list::-webkit-scrollbar,
.review-list::-webkit-scrollbar,
.replay-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.deduce-history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track,
.review-list::-webkit-scrollbar-track,
.replay-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.deduce-history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, .04);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb,
.review-list::-webkit-scrollbar-thumb,
.replay-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.deduce-history-list::-webkit-scrollbar-thumb {
    background: rgba(126, 242, 255, .4);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover,
.review-list::-webkit-scrollbar-thumb:hover,
.replay-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.deduce-history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(126, 242, 255, .6);
}

/* ---------- 禁用状态 ---------- */
.action-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- 无障碍焦点 ---------- */
.action-btn:focus-visible,
.auth-input:focus-visible,
.difficulty-select:focus-visible,
.nav-link:focus-visible,
.io-chip:focus-visible,
.io-tab:focus-visible,
.hist-nav-btn:focus-visible,
.chat-input:focus-visible,
.chat-send-btn:focus-visible,
.close-btn:focus-visible,
.io-textarea:focus-visible {
    outline: 2px solid var(--neon-cyan);
    outline-offset: 2px;
}

/* ---------- 响应式 ---------- */

/* --- 平板 / 小桌面 (≤ 768px) --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .top-nav {
        padding: 8px 10px;
    }

    .nav-links {
        gap: 6px;
    }

    .nav-user-info {
        gap: 6px;
        padding-left: 6px;
    }

    .game-info {
        padding: 8px 10px;
    }

    .action-btn {
        padding: 7px 12px;
        font-size: 13px;
    }

    .toolbar {
        gap: 6px;
    }

    .toolbar-divider {
        height: 18px;
        margin: 0 2px;
    }

    .history-section,
    .analyze-panel,
    .review-panel,
    .replay-panel,
    .chat-panel,
    .adjust-panel,
    .io-panel {
        margin-top: 10px;
    }

    .review-list,
    .replay-list,
    .chat-messages {
        max-height: 220px;
    }
}

/* --- 手机 (≤ 480px): 紧凑 + 触控目标 ≥ 44px --- */
@media (max-width: 480px) {
    body {
        padding: 8px;
        padding-top: env(safe-area-inset-top, 8px);
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    .top-nav {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 6px;
    }

    .nav-link {
        padding: 9px 12px;
        min-height: 44px;
        font-size: 13px;
    }

    .nav-user-info {
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, .12);
        width: 100%;
        justify-content: center;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 10px;
        letter-spacing: 2px;
    }

    .game-info {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 8px 10px;
    }

    .turn-indicator {
        width: 100%;
        font-size: 15px;
    }

    .board-container {
        max-width: 98vw;
        border-radius: 10px;
    }

    .toolbar {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
    }

    .action-btn {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 12px;
        min-height: 44px;
        min-width: 44px;
    }

    .action-btn.small {
        padding: 6px 10px;
        min-height: 38px;
    }

    .last-move-info {
        flex-direction: column;
        gap: 4px;
        text-align: center;
        padding: 6px 10px;
    }

    .difficulty-selector {
        flex-wrap: wrap;
        justify-content: center;
    }

    .difficulty-select {
        padding: 8px 10px;
        min-height: 44px;
    }

    .draw-banner {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 8px 10px;
    }

    .history-header {
        padding: 8px 10px;
        flex-wrap: wrap;
    }

    .history-list {
        max-height: 150px;
    }

    .history-list .history-row {
        padding: 5px 8px !important;
        gap: 8px;
    }

    .history-red {
        min-width: 60px;
    }

    .hist-nav-btn {
        padding: 6px 12px;
        min-height: 40px;
        min-width: 40px;
    }

    .message {
        padding: 6px 10px;
        min-height: 32px;
        font-size: 13px;
    }

    /* 调整棋子面板 */
    .adjust-panel {
        padding: 10px;
    }

    .adjust-hint {
        font-size: 12px;
    }

    .adjust-piece {
        width: 40px;
        height: 40px;
    }

    /* 面板移动端 */
    .analyze-header,
    .review-header,
    .replay-header,
    .chat-header,
    .io-header {
        padding: 8px 10px;
        font-size: 14px;
    }

    .analyze-content,
    .review-content,
    .replay-content,
    .chat-content,
    .io-content {
        padding: 10px;
    }

    .review-list {
        max-height: 200px;
    }

    .review-row {
        flex-wrap: wrap;
        gap: 4px 8px;
        padding: 6px 0;
    }

    .review-comment {
        width: 100%;
        margin-left: 32px;
    }

    .replay-controls {
        gap: 6px;
        margin-bottom: 10px;
    }

    .replay-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 44px;
        min-width: 44px;
    }

    .replay-list {
        max-height: 180px;
    }

    .chat-messages {
        max-height: 180px;
        margin-bottom: 10px;
    }

    .chat-text {
        max-width: 82%;
    }

    .chat-input-area {
        gap: 6px;
    }

    .chat-input {
        padding: 10px 12px;
        min-height: 44px;
    }

    .chat-send-btn {
        padding: 8px 16px;
        min-height: 44px;
    }

    /* 登录页 */
    .auth-container {
        margin-top: 16px;
        max-width: 100%;
    }

    .auth-form {
        padding: 14px;
    }

    .auth-input {
        padding: 10px 12px;
        min-height: 44px;
    }

    .auth-submit {
        padding: 10px;
        min-height: 44px;
    }

    /* 大厅 */
    .user-bar {
        flex-wrap: wrap;
        padding: 8px 10px;
        font-size: 13px;
    }

    .lobby-section {
        padding: 12px;
    }

    .lobby-section h2 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .join-row {
        flex-direction: column;
    }

    .join-row .auth-input {
        min-width: 100%;
    }

    .lobby-actions {
        flex-direction: column;
    }

    .lobby-actions .action-btn {
        width: 100%;
        min-height: 44px;
    }

    .room-info {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* 棋盘点击区域加大 */
    .click-area {
        width: 11%;
    }

    .piece {
        width: 9.2%;
    }

    /* 推演面板全屏 */
    .deduce-panel {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
    }

    .deduce-header {
        padding: 10px 12px;
    }

    .deduce-title {
        font-size: 15px;
    }

    .close-btn {
        font-size: 22px;
        padding: 4px 8px;
        min-height: 44px;
        min-width: 44px;
    }

    .deduce-body {
        flex-direction: column;
        padding: 8px;
        gap: 8px;
    }

    .deduce-board-container {
        max-width: 100%;
    }

    .deduce-turn {
        font-size: 13px;
        padding: 8px 10px;
    }

    .deduce-controls {
        gap: 6px;
    }

    .deduce-controls .action-btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 44px;
    }

    .deduce-history-list {
        max-height: 120px;
    }

    /* IO 面板 */
    .io-tab {
        min-height: 44px;
    }

    .io-chip {
        padding: 8px 14px;
        min-height: 40px;
    }

    .io-actions .action-btn {
        min-height: 44px;
    }
}

/* --- 超小屏 (≤ 360px) --- */
@media (max-width: 360px) {
    body {
        padding: 6px;
    }

    .top-nav {
        padding: 8px;
        gap: 6px;
    }

    .nav-link {
        padding: 8px 8px;
        font-size: 12px;
    }

    .nav-brand {
        font-size: 14px;
        letter-spacing: 1px;
    }

    .action-btn {
        padding: 7px 8px;
        font-size: 11px;
        min-height: 44px;
    }

    h1 {
        font-size: 18px;
    }

    .turn-indicator {
        font-size: 14px;
    }

    .review-quality {
        font-size: 11px;
        padding: 2px 5px;
    }
}

/* --- 手机横屏 --- */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 8px;
    }

    .top-nav {
        padding: 6px 10px;
        margin-bottom: 6px;
    }

    .nav-brand {
        font-size: 14px;
    }

    .nav-link {
        font-size: 12px;
        padding: 4px 8px;
        min-height: 32px;
    }

    h1 {
        display: none;
    }

    .game-info {
        padding: 4px 8px;
        margin-bottom: 4px;
    }

    .turn-indicator {
        font-size: 13px;
    }

    .toolbar {
        margin-top: 6px;
    }

    .action-btn {
        padding: 5px 8px;
        font-size: 11px;
        min-height: 34px;
    }

    .board-container {
        max-height: calc(100vh - 120px);
        max-width: calc((100vh - 120px) * 0.9);
    }

    .message {
        margin-top: 4px;
        padding: 4px 8px;
        min-height: 24px;
        font-size: 12px;
    }

    .history-section,
    .analyze-panel,
    .review-panel,
    .replay-panel,
    .chat-panel,
    .adjust-panel,
    .io-panel {
        margin-top: 6px;
    }

    .history-list,
    .review-list,
    .replay-list,
    .chat-messages {
        max-height: 100px;
    }

    .deduce-panel {
        width: 95vw;
        max-height: 95vh;
    }

    .deduce-body {
        flex-direction: row;
        padding: 8px;
        gap: 8px;
    }

    .deduce-board-container {
        width: 50vw;
        max-width: 300px;
    }

    .deduce-sidebar {
        min-width: 160px;
    }

    .deduce-history-list {
        max-height: 120px;
    }
}

/* --- 触屏优化 (去除 hover 带来的误触) --- */
@media (hover: none) and (pointer: coarse) {
    .piece:hover {
        transform: translate(-50%, -50%);
    }

    .action-btn:hover {
        background: rgba(255, 255, 255, .08);
        box-shadow: none;
    }

    .action-btn:active {
        background: rgba(255, 255, 255, .14);
        box-shadow: 0 0 18px rgba(33, 150, 243, .35);
    }

    .nav-link:hover {
        color: var(--text-dim);
        background: transparent;
        box-shadow: none;
    }

    .nav-link:active {
        color: #fff;
        background: rgba(255, 255, 255, .08);
    }

    .close-btn:hover {
        color: var(--text-dim);
        background: rgba(255, 255, 255, .06);
        box-shadow: none;
    }

    .close-btn:active {
        color: #fff;
        background: rgba(255, 82, 82, .25);
    }

    .adjust-piece:hover {
        border-color: transparent;
        transform: none;
    }

    .adjust-piece:active {
        border-color: var(--neon-cyan);
    }

    .replay-row:hover {
        background: transparent;
    }

    .replay-row:active {
        background: rgba(255, 255, 255, .08);
    }

    .click-area:hover {
        background: transparent;
        box-shadow: none;
    }

    .click-area.valid-move:hover {
        background: radial-gradient(circle, rgba(126, 242, 255, .3), rgba(126, 242, 255, .08) 70%);
    }

    .click-area.valid-capture:hover {
        background: radial-gradient(circle, rgba(255, 154, 213, .32), rgba(255, 154, 213, .08) 70%);
    }

    .history-header:hover {
        color: var(--text-dim);
        background: rgba(255, 255, 255, .04);
    }

    .history-header:active {
        color: #fff;
        background: rgba(255, 255, 255, .08);
    }

    .chat-send-btn:hover {
        filter: none;
        box-shadow: 0 4px 18px rgba(33, 150, 243, .4);
    }

    .chat-send-btn:active {
        filter: brightness(1.12);
    }

    .auth-tab:hover {
        background: transparent;
        color: var(--text-dim);
    }

    .auth-tab:active {
        background: rgba(255, 255, 255, .08);
        color: #fff;
    }

    .nav-logout-btn:hover {
        color: var(--text-dim);
        border-color: rgba(255, 255, 255, .14);
        background: rgba(255, 255, 255, .06);
        box-shadow: none;
    }

    .nav-logout-btn:active {
        color: #fff;
        border-color: rgba(255, 82, 82, .6);
        background: rgba(255, 82, 82, .18);
    }

    .replay-btn:hover {
        background: rgba(255, 255, 255, .07);
        border-color: rgba(255, 255, 255, .14);
        box-shadow: none;
    }

    .replay-btn:active {
        background: rgba(255, 255, 255, .14);
        border-color: rgba(126, 242, 255, .4);
    }

    .hist-nav-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, .07);
        border-color: rgba(255, 255, 255, .14);
        box-shadow: none;
    }

    .hist-nav-btn:active:not(:disabled) {
        background: rgba(255, 255, 255, .14);
        border-color: rgba(126, 242, 255, .4);
    }
}

/* ==========================================================================
   推演面板 (deduce.js 动态生成, 仅视觉样式; 结构与 JS 绑定保持不变)
   ========================================================================== */
#deducePanel {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 6, 18, .72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
#deducePanel.deduce-panel {
    flex-direction: column;
    gap: 0;
}
.deduce-panel {
    max-width: 860px;
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    background: rgba(12, 14, 36, .92);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
    animation: modal-in .25s ease-out both;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.deduce-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .04);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.deduce-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.deduce-hint {
    flex: 1;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-dim);
}
.deduce-body {
    display: flex;
    gap: 16px;
    padding: 16px;
    flex-wrap: wrap;
}
.deduce-board-wrapper {
    flex: 1 1 360px;
    min-width: 280px;
}
.deduce-board-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(0, 0, 0, .35);
}
.deduce-board-container .board-image {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}
.deduce-board-container .pieces-layer,
.deduce-board-container .click-areas {
    position: absolute;
    inset: 0;
}
.deduce-sidebar {
    flex: 1 1 220px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.deduce-turn {
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 10px 12px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-md);
}
.deduce-controls {
    display: flex;
    gap: 10px;
}
.deduce-history-header {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(126, 242, 255, .3);
    margin-top: 4px;
}
.deduce-history-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px;
}
.deduce-history-list::-webkit-scrollbar { width: 4px; }
.deduce-history-list::-webkit-scrollbar-thumb { background: rgba(126, 242, 255, .3); border-radius: 2px; }
.deduce-history-list .history-row {
    display: flex;
    gap: 8px;
    font-size: 13px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 8px;
}
.deduce-history-list .history-num {
    color: var(--text-faint);
    min-width: 24px;
}
.deduce-history-list .history-red {
    color: var(--red-neon);
    flex: 1;
}
.deduce-history-list .history-black {
    color: var(--black-neon);
    flex: 1;
}
.deduce-history-list .history-empty {
    color: var(--text-faint);
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

/* --- 减弱动效偏好 --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
