/* ===== 评分卡片 ===== */
.online-battle-module .ob-rating-card {
    display: flex;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin: 20px;
    border-radius: 12px;
}
.ob-rating-info { flex: 1; }
.ob-rating-main { margin-bottom: 12px; }
.ob-rating-label { font-size: 14px; opacity: 0.8; }
.ob-rating-value { font-size: 36px; font-weight: bold; }
.ob-rating-stats { font-size: 14px; }
.ob-rating-stats .ob-stat { margin-right: 12px; }
.ob-stat-win { color: #90ee90; }
.ob-stat-draw { color: #ffd700; }
.ob-stat-loss { color: #ff9999; }
.ob-rating-rank { text-align: center; padding: 20px; border-left: 1px solid rgba(255,255,255,0.3); }
.ob-rank-label { font-size: 14px; opacity: 0.8; }
.ob-rank-value { font-size: 24px; font-weight: bold; }

/* ===== 对战选项 ===== */
.ob-battle-options {
    display: flex;
    gap: 20px;
    padding: 20px;
}
.ob-option-card {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid #eee;
}
.ob-option-icon { font-size: 48px; margin-bottom: 12px; }
.ob-option-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.ob-option-desc { font-size: 14px; color: #666; margin-bottom: 16px; }

/* 时间控制按钮 */
.ob-time-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}
.ob-time-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.ob-time-btn.active { background: #667eea; color: white; border-color: #667eea; }

/* 颜色选择 */
.ob-color-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}
.ob-color-label { font-size: 13px; color: #666; }
.ob-color-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.ob-color-btn.active { background: #667eea; color: white; border-color: #667eea; }

/* 机器人难度 */
.ob-robot-difficulty {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}
.ob-diff-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.ob-diff-btn.active { background: #667eea; color: white; border-color: #667eea; }

/* 通用按钮 */
.ob-battle-btn {
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: all 0.2s;
}
.ob-battle-primary { background: #667eea; color: white; }
.ob-battle-primary:hover { background: #5a6fd6; }

/* 好友对战区域 */
.ob-friend-section { margin-bottom: 8px; }
.ob-friend-divider { color: #999; font-size: 13px; margin: 8px 0; }
.ob-friend-input {
    display: flex;
    gap: 8px;
}
.ob-friend-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

/* ===== 弹窗 ===== */
.ob-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ob-modal-mask {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
}
.ob-modal-content {
    position: relative;
    background: white;
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    z-index: 1;
    max-width: 400px;
    width: 90%;
}
.ob-modal-sm { max-width: 360px; }
.ob-modal-icon { font-size: 56px; margin-bottom: 12px; }
.ob-modal-title { font-size: 20px; font-weight: bold; margin-bottom: 8px; }
.ob-modal-desc { font-size: 14px; color: #666; margin-bottom: 16px; }
.ob-modal-btn {
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    margin: 4px;
}
.ob-modal-btn-primary { background: #667eea; color: white; }
.ob-modal-btn-cancel { background: #f0f0f0; color: #333; }
.ob-modal-btns { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* 匹配动画 */
.ob-spinner {
    width: 40px; height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: obSpin 1s linear infinite;
    margin: 16px auto;
}
@keyframes obSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 房间码 */
.ob-room-code-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 12px;
}
.ob-room-code-label { font-size: 14px; color: #666; }
.ob-room-code-value { font-size: 22px; font-weight: bold; color: #667eea; flex: 1; }
.ob-copy-btn { padding: 6px 12px; background: #667eea; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; }
.ob-room-status { font-size: 14px; color: #666; margin-bottom: 12px; }
.ob-room-share { margin-bottom: 16px; }
.ob-room-share-label { font-size: 13px; color: #666; display: block; margin-bottom: 4px; }
.ob-room-share input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; }

/* 升变选择 */
.ob-modal-promotion { max-width: 280px; }
.ob-promotion-choices {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}
.ob-promotion-piece {
    width: 56px; height: 56px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ob-promotion-piece:hover { border-color: #667eea; background: #f0f4ff; }
.ob-promotion-piece img { width: 44px; height: 44px; }

/* 结果弹窗 */
.ob-result-rating-change {
    font-size: 18px;
    font-weight: bold;
    margin: 8px 0;
}
.ob-result-rating-change.positive { color: #28a745; }
.ob-result-rating-change.negative { color: #dc3545; }

/* ===== 对弈视图 ===== */
#ob-game {
    max-width: 600px;
    margin: 0 auto;
    padding: 8px;
}
.ob-game-header, .ob-game-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    margin: 4px 0;
}
.ob-opponent-bar, .ob-my-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ob-opponent-avatar, .ob-my-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    overflow: hidden;
}
.ob-opponent-avatar img, .ob-my-avatar img {
    width: 100%; height: 100%; object-fit: cover;
}
.ob-opponent-name, .ob-my-name { font-weight: 600; font-size: 14px; }
.ob-opponent-rating, .ob-my-rating-display { font-size: 12px; color: #667eea; }

/* 计时器 */
.ob-timer {
    font-size: 22px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    padding: 4px 12px;
    border-radius: 6px;
    min-width: 80px;
    text-align: center;
}
.ob-timer-opponent { background: #f8f9fa; color: #333; }
.ob-timer-me { background: #667eea; color: white; }
.ob-timer.ob-timer-active { background: #28a745; color: white; }
.ob-timer.ob-timer-low { background: #dc3545; color: white; animation: obBlink 1s infinite; }
@keyframes obBlink { 50% { opacity: 0.6; } }

/* 棋盘容器 */
.ob-board-container {
    display: flex;
    justify-content: center;
    margin: 4px 0;
}
#ob-canvas {
    cursor: pointer;
    touch-action: none;
}

/* 对弈控制按钮 */
.ob-game-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px 0;
}
.ob-ctrl-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.ob-ctrl-btn:hover { background: #f0f0f0; }
.ob-ctrl-btn.ob-flip{background:linear-gradient(135deg,#ff9800,#f57c00);color:#fff;border-color:#f57c00;box-shadow:0 2px 8px rgba(255,152,0,0.4)}
.ob-ctrl-btn.ob-flip:hover{background:linear-gradient(135deg,#f57c00,#e65100);color:#fff}
.ob-ctrl-danger { border-color: #dc3545; color: #dc3545; }
.ob-ctrl-danger:hover { background: #fff5f5; }

/* 走子记录 */
.ob-moves-list {
    max-height: 120px;
    overflow-y: auto;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.8;
    margin-top: 4px;
}

/* 断线提示 */
.ob-disconnect-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    z-index: 10001;
}

/* ===== 排行榜 ===== */
.ob-leaderboard-section, .ob-recent-section { padding: 20px; }
.ob-leaderboard-section h3, .ob-recent-section h3 { font-size: 18px; margin-bottom: 16px; }
.ob-leaderboard-table, .ob-recent-table { width: 100%; border-collapse: collapse; }
.ob-leaderboard-table th, .ob-recent-table th {
    background: #f8f9fa; padding: 10px; font-weight: 600; color: #666; text-align: left; border-bottom: 2px solid #eee;
}
.ob-leaderboard-table td, .ob-recent-table td { padding: 10px; border-bottom: 1px solid #eee; }
.ob-leaderboard-table tr.ob-current-user { background: #f0f4ff; }
.ob-leaderboard-table tr:hover { background: #f8f9fa; }
.ob-th-rank { width: 60px; }
.ob-th-rating { width: 80px; }
.ob-rank-cell { font-weight: bold; text-align: center; }
.ob-rank-cell.ob-top-1 { color: #ffd700; }
.ob-rank-cell.ob-top-2 { color: #c0c0c0; }
.ob-rank-cell.ob-top-3 { color: #cd7f32; }
.ob-player-cell { font-weight: 500; }
.ob-me-badge { display: inline-block; padding: 2px 6px; background: #667eea; color: white; border-radius: 4px; font-size: 12px; margin-left: 6px; }
.ob-rating-cell { font-weight: 600; color: #667eea; }
.ob-stats-cell { font-size: 13px; color: #666; }
.ob-player-avatar { width: 24px; height: 24px; border-radius: 50%; margin-right: 8px; vertical-align: middle; object-fit: cover; }
.ob-result-cell { font-weight: bold; padding: 4px 8px; border-radius: 4px; }
.ob-result-cell.ob-white-win { background: #d4edda; color: #155724; }
.ob-result-cell.ob-black-win { background: #f8d7da; color: #721c24; }
.ob-result-cell.ob-draw { background: #fff3cd; color: #856404; }

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .online-battle-module { padding: 0 4px; }
    .ob-rating-card { flex-direction: column; margin: 8px; padding: 16px; text-align: center; }
    .ob-rating-rank { border-left: none; border-top: 1px solid rgba(255,255,255,0.2); padding-top: 12px; margin-top: 12px; width: 100%; }
    .ob-battle-options { flex-direction: column; padding: 8px; gap: 12px; }
    .ob-option-card { padding: 16px; }
    .ob-option-icon { font-size: 32px; }
    .ob-leaderboard-section, .ob-recent-section { margin: 8px; padding: 12px; overflow-x: auto; }
    .ob-leaderboard-table, .ob-recent-table { min-width: 500px; font-size: 12px; }
    #ob-game { padding: 4px; }
    .ob-game-header, .ob-game-footer { padding: 6px 8px; }
    .ob-timer { font-size: 18px; min-width: 64px; }
    .ob-game-controls { gap: 4px; }
    .ob-ctrl-btn { padding: 6px 10px; font-size: 12px; }
}
@media (max-width: 480px) {
    .ob-rating-value { font-size: 28px; }
    .ob-option-card { padding: 12px; }
    .ob-option-icon { font-size: 28px; }
    .ob-time-btn { padding: 5px 8px; font-size: 11px; }
    .ob-battle-btn { padding: 10px 16px; font-size: 13px; }
    .ob-leaderboard-table, .ob-recent-table { font-size: 11px; }
}
@media (hover: none) and (pointer: coarse) {
    .ob-time-btn, .ob-color-btn, .ob-diff-btn, .ob-battle-btn, .ob-ctrl-btn, .ob-modal-btn, .ob-copy-btn {
        min-height: 44px;
    }
}
