/**
 * 阿鹿小站 v2.0 - 單機五子棋專屬樣式表 (game/gomoku/gomoku_local.css)
 * 嚴格對齊 .vscode/PROJECT_GUIDELINES.md 與 GAME_DEVELOPMENT_GUIDE.md
 */

/* 全局背景與滾動優化 (防止 iOS / Safari 下拉露餡，固定漸層底色並適配動態安全區) */
html, body {
    background-color: #f1f5f9 !important;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #f8fafc 100%) !important;
    background-attachment: fixed !important;
    margin: 0 !important;
    padding: 0 !important;
    padding-top: 0px !important;
    margin-top: 0px !important;
    min-height: 100% !important;
    -webkit-overflow-scrolling: touch;
}

/* 徹底抹除 Google AdSense 在頂部與底部預留的隱形佔位容器與錨定廣告 */
.google-auto-placed,
ins.adsbygoogle[data-anchor-status],
ins.adsbygoogle[data-anchor-shown="true"],
#aswift_0_anchor__container,
#aswift_1_anchor__container,
#aswift_2_anchor__container,
#aswift_3_anchor__container,
#aswift_4_anchor__container,
#aswift_5_anchor__container,
div[id^="aswift_"][id$="_anchor__container"],
div[id^="aswift_"][style*="position: fixed; top: 0"],
div[id^="aswift_"][style*="position: fixed; top:0"],
div[id^="google_ads_iframe"][style*="position: fixed; top: 0"],
iframe[id^="google_ads_iframe"][id*="anchor"] {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* 頁面背景與主容器 */
.gomoku-page-container {
    background: transparent;
    color: #1e293b;
    padding: max(12px, env(safe-area-inset-top, 12px)) 12px max(24px, env(safe-area-inset-bottom, 24px)) 12px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    font-family: 'Outfit', 'Inter', 'SF Pro TC', -apple-system, BlinkMacSystemFont, sans-serif;
    box-sizing: border-box;
}

/* 雙欄主外殼：寬度收斂至 920px，確保電腦螢幕兩側有足夠空間留給 Google 側邊滑軌廣告，絕不遮擋 */
.gomoku-layout-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 920px;
    margin: 0 auto !important;
    align-items: flex-start;
    align-self: center;
}

/* 棋盤區域佔比 */
.gomoku-board-section {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* 棋盤精緻卡片 */
.gomoku-board-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 16px 18px 14px 18px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 棋盤頂部狀態列 */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.board-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.board-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-board-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    line-height: 1.2;
    white-space: nowrap;
}

.btn-top-undo {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.btn-top-undo:hover:not(:disabled) {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.btn-top-undo:disabled {
    background: #cbd5e1 !important;
    color: #94a3b8 !important;
    border-color: #cbd5e1 !important;
    cursor: not-allowed !important;
}

.btn-top-resign {
    background: #dc2626;
    color: #ffffff;
    border: none;
}

.btn-top-resign:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-top-resign:disabled {
    background: #cbd5e1 !important;
    color: #94a3b8 !important;
    cursor: not-allowed !important;
}

.status-badge {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: #ffffff;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
    transition: all 0.3s ease;
}

.status-badge.white-turn {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Outfit', monospace;
    white-space: nowrap;
    line-height: 1.2;
}

.timer-badge #game-timer-text {
    color: #0f172a;
    letter-spacing: 0.5px;
}

/* Canvas 棋盤容器與 aspect-ratio 強制方形 */
.canvas-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12), inset 0 0 10px rgba(0, 0, 0, 0.2);
}

#gomoku-canvas {
    width: 100%;
    height: 100%;
    background: #e5c07b;
    display: block;
    cursor: crosshair;
    border-radius: 12px;
    touch-action: none;
}

/* 手機版落子放大鏡/準星 */
.gomoku-magnifier {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid #2563eb;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    background: #e5c07b;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

#magnifier-canvas {
    width: 100%;
    height: 100%;
}

/* 玩家落子確認列 (棋盤正下方操作欄) */
.confirm-move-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-sizing: border-box;
    min-height: 52px;
    gap: 12px;
}

.confirm-hint-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.confirm-hint-text strong {
    color: #0f172a;
}

.confirm-hint-text.selected {
    color: #2563eb;
}

.confirm-hint-text.ai-thinking {
    color: #d97706;
}

.confirm-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-cancel-move {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel-move:hover {
    background: #f8fafc;
    color: #0f172a;
}

.btn-confirm-move {
    background: #2563eb;
    border: none;
    color: #ffffff;
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-confirm-move:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-confirm-move:disabled {
    background: #cbd5e1 !important;
    color: #94a3b8 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* 控制側邊欄 */
.gomoku-control-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.control-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.control-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 14px 0;
    border-left: 4px solid #2563eb;
    padding-left: 10px;
    color: #0f172a;
}

/* 玩家 VS 狀態區 */
.player-vs-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.player-info {
    flex: 1;
    min-width: 0;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    padding: 12px 8px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.player-info.active {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.player-info.black.active {
    background: #f1f5f9;
    border-color: #475569;
    box-shadow: 0 0 12px rgba(71, 85, 105, 0.2);
}

.stone-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0,0,0,0.25);
    display: inline-block;
}

.stone-icon.black {
    background: radial-gradient(circle at 30% 30%, #475569, #0f172a);
    border: 1px solid #0f172a;
}

.stone-icon.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #cbd5e1);
    border: 1px solid #94a3b8;
}

.player-info .name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.player-info .meta-sub {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

.vs-divider {
    font-size: 0.8rem;
    font-weight: 800;
    color: #94a3b8;
}

/* 按鈕群組與下拉選單 */
.btn-group {
    display: flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #e2e8f0;
}

.btn-option {
    flex: 1;
    background: transparent;
    border: none;
    color: #64748b;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-option:hover {
    color: #0f172a;
}

.btn-option.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.select-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 9px 12px;
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 行動按鈕 (遵循三層按鈕規範) */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-action {
    width: 100%;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-sizing: border-box;
}

.btn-action.btn-primary {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-action.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-action.btn-secondary {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.btn-action.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    color: #0f172a;
}

.btn-action.btn-danger {
    background: #dc2626;
    color: #ffffff;
}

.btn-action.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

/* 複盤控制卡片微調 */
.review-card .btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    padding: 10px 0;
}

/* =========================================================
   🎮 五子棋大廳首頁 (Game Lobby Screen) 樣式
   與第二頁棋局主體 (920px) 保持完全一致的寬度佔位，防止 Google 側邊滑軌廣告壓在遊戲上
   ========================================================= */
.gomoku-lobby-screen {
    width: 100%;
    max-width: 920px;
    margin: 8px auto 20px auto;
    padding: 0 16px;
    box-sizing: border-box;
    animation: fadeInLobby 0.35s ease-out;
}

@keyframes fadeInLobby {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gomoku-lobby-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.08), 0 0 0 1px #e2e8f0;
    padding: 32px 28px;
    text-align: center;
    box-sizing: border-box;
    max-width: 580px;
    margin: 0 auto;
}

.lobby-logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
}

.lobby-brand-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: cover;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.14);
    transition: transform 0.3s ease;
}

.lobby-brand-logo:hover {
    transform: scale(1.04);
}

.lobby-title {
    font-size: 2.1rem;
    font-weight: 900;
    color: #0f172a;
    margin: 0 0 12px 0;
    letter-spacing: 0.5px;
}

/* 棋士身分與快速登入膠囊列 */
.lobby-player-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 22px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 30px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.player-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 700;
}

.player-pill.guest {
    color: #64748b;
}

.player-pill.member {
    color: #1e293b;
}

.player-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.player-pill.member .player-dot {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.btn-quick-login {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #ffffff;
    background: #2563eb;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-quick-login:hover {
    background: #1d4ed8;
}

/* 大廳模式切換分頁 */
.lobby-mode-switch {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 18px;
    gap: 4px;
}

.btn-mode-tab {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.btn-mode-tab:hover:not(.active) {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.5);
}

.btn-mode-tab.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* 首頁設定區域 */
.lobby-settings-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 22px;
    text-align: left;
}

.lobby-setting-item {
    margin-bottom: 14px;
}

.lobby-setting-item:last-child {
    margin-bottom: 0;
}

.lobby-setting-item label {
    display: block;
    font-size: 0.86rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
}

/* 真人線上對局面板 */
.online-mode-desc {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.online-desc-content h4 {
    margin: 0 0 4px 0;
    font-size: 0.98rem;
    font-weight: 800;
    color: #1e3a8a;
}

.online-desc-content p {
    margin: 0;
    font-size: 0.84rem;
    color: #3b82f6;
    line-height: 1.45;
}

.online-login-required-card {
    text-align: center;
    padding: 14px 10px;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
}

.login-tip-text {
    margin: 0 0 10px 0;
    font-size: 0.88rem;
    color: #64748b;
    font-weight: 600;
}

.btn-online-login {
    display: inline-block;
    padding: 9px 24px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: 20px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* 首頁廣告版位與彈窗廣告版位 */
.gomoku-lobby-ad-section,
.gomoku-modal-ad-section {
    margin-bottom: 20px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}

.gomoku-lobby-ad-section .ad-label,
.gomoku-modal-ad-section .ad-label {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gomoku-lobby-ad-section .ad-container,
.gomoku-modal-ad-section .ad-container {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

/* 首頁按鈕群 (嚴格遵循三層按鈕規範，純文字無 Emoji) */
.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-lobby-start {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    color: #ffffff;
    font-size: 1.08rem;
    font-weight: 800;
    padding: 14px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-lobby-start:hover {
    background: #1d4ed8;
}

.btn-lobby-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 0.96rem;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-lobby-secondary:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

/* =========================================================
   🏆 結算、匯入、訪客提示、排行榜 彈窗共用樣式
   ========================================================= */
.gomoku-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10001 !important;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
    box-sizing: border-box;
    animation: fadeInModal 0.25s ease-out;
}

.gomoku-modal-overlay.active,
.gomoku-modal-overlay[style*="display: flex"] {
    display: flex !important;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gomoku-modal-box {
    background: #ffffff;
    width: 100%;
    max-width: 480px;
    border-radius: 18px;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.8);
    padding: 24px 22px;
    position: relative;
    margin: auto !important;
    box-sizing: border-box;
    max-height: calc(85dvh - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.gomoku-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.gomoku-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.gomoku-modal-header {
    text-align: center;
    margin-bottom: 16px;
}

.gomoku-modal-badge {
    display: inline-block;
    background: #fef3c7;
    color: #b45309;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
}

.gomoku-modal-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.gomoku-modal-subtitle {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

.gomoku-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    box-sizing: border-box;
}

.modal-btn.btn-primary {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.modal-btn.btn-primary:hover {
    background: #1d4ed8;
}

.modal-btn.btn-secondary {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.modal-btn.btn-secondary:hover {
    background: #f8fafc;
    color: #0f172a;
}

/* 排行榜彈窗專屬樣式 */
.gomoku-leaderboard-box {
    max-width: 620px;
    width: 95%;
    max-height: calc(85dvh - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
}

.leaderboard-filter-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.leaderboard-filter-group .filter-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
    min-width: 60px;
}

.leaderboard-filter-group .btn-group {
    flex: 1;
    display: flex;
    gap: 6px;
}

.leaderboard-filter-group .btn-option {
    flex: 1;
    padding: 7px 6px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
}

.leaderboard-filter-group .btn-option.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.leaderboard-table-wrapper {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    min-height: 220px;
    max-height: 340px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.leaderboard-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid #e2e8f0;
}

.leaderboard-table td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

.leaderboard-table tr:hover {
    background: #f8fafc;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
}

.rank-badge.top-1 { background: #fef3c7; color: #b45309; border: 1.5px solid #f59e0b; }
.rank-badge.top-2 { background: #f1f5f9; color: #475569; border: 1.5px solid #94a3b8; }
.rank-badge.top-3 { background: #ffedd5; color: #9a3412; border: 1.5px solid #ea580c; }
.rank-badge.other { background: transparent; color: #64748b; font-weight: 600; }

.table-loading, .table-empty {
    text-align: center;
    padding: 40px 10px !important;
    color: #64748b;
    font-size: 0.9rem;
}

.leaderboard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.login-tip-link {
    font-size: 0.82rem;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
}

/* 響應式佈局 (RWD)：手機與 iPad 直式全面採用單欄直向排版，棋盤自動放大滿版，側欄順移至下方 */
@media (max-width: 900px), (max-width: 1024px) and (orientation: portrait) {
    .gomoku-layout-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 14px;
        width: 100%;
        max-width: 680px;
    }

    .gomoku-board-section {
        width: 100%;
    }

    .gomoku-board-card {
        max-width: 100%;
    }

    .gomoku-control-sidebar {
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .gomoku-control-sidebar .review-card {
        order: -10;
        margin-top: 0;
        padding: 12px 14px;
        border-radius: 14px;
    }

    .gomoku-page-container {
        padding: max(10px, env(safe-area-inset-top, 10px)) 10px max(24px, env(safe-area-inset-bottom, 24px)) 10px;
    }
}

@media (max-width: 480px) {
    .gomoku-lobby-card {
        padding: 24px 18px;
    }
    .lobby-title {
        font-size: 1.75rem;
    }
    .leaderboard-filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .leaderboard-filter-group .btn-group {
        width: 100%;
    }
}
