        /* Games section dark mode */
        .dark #section-games .bg-white {
            background-color: var(--card-bg) !important;
            border-color: var(--border) !important;
        }
        .dark #section-games .game-card {
            background-color: var(--card-bg);
            border-color: var(--border);
        }
        .dark #section-games .game-card:hover {
            background-color: color-mix(in srgb, var(--card-bg) 80%, var(--primary)) !important;
            border-color: color-mix(in srgb, var(--border) 60%, var(--primary)) !important;
        }
        .dark #section-games .bg-gradient-to-r {
            background-image: linear-gradient(to right, color-mix(in srgb, var(--card-bg) 90%, var(--primary)), color-mix(in srgb, var(--card-bg) 90%, #818cf8)) !important;
        }
        .dark #section-games .text-slate-500 {
            color: var(--text-secondary);
        }
        .dark #section-games .border-b {
            border-color: var(--border);
        }
        .dark #game-modal .bg-white {
            background-color: var(--card-bg) !important;
            color: var(--text);
        }
        .dark #game-modal .border {
            border-color: var(--border);
        }
        .dark #game-modal .text-slate-500 {
            color: var(--text-secondary);
        }

        /* ==================== CHECKERS GAME ==================== */
        #checkers-overlay {
            animation: modalPop 0.25s ease-out;
        }
        #checkers-board {
            display: grid;
            grid-template-columns: repeat(8, 1fr);
            aspect-ratio: 1;
            max-width: min(90vw, 400px);
            margin: 0 auto;
            border: 2px solid #8b4513;
            border-radius: 6px;
            overflow: hidden;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
        }
        .checkers-cell {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: default;
            position: relative;
            -webkit-tap-highlight-color: transparent;
        }
        .checkers-cell.light { background-color: #f0d9b5; }
        .checkers-cell.dark { background-color: #8b4513; }
        .checkers-cell.valid-move::after {
            content: '';
            position: absolute;
            width: 28%;
            height: 28%;
            background: rgba(34, 197, 94, 0.7);
            border-radius: 50%;
            pointer-events: none;
        }
        .checkers-cell.valid-jump::after {
            content: '';
            position: absolute;
            width: 100%;
            height: 100%;
            border: 3px solid rgba(34, 197, 94, 0.8);
            border-radius: 4px;
            box-sizing: border-box;
            pointer-events: none;
        }
        .checkers-cell.selected {
            box-shadow: inset 0 0 0 3px #facc15;
        }
        .checkers-cell.selected .checkers-piece {
            filter: brightness(1.3);
        }
        .checkers-piece {
            width: 75%;
            height: 75%;
            border-radius: 50%;
            cursor: pointer;
            transition: transform 0.12s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: clamp(14px, 3vw, 22px);
            box-shadow: 0 2px 4px rgba(0,0,0,0.25);
            border: 2px solid rgba(0,0,0,0.15);
        }
        .checkers-piece.player1 {
            background: radial-gradient(circle at 35% 35%, #ef4444, #b91c1c);
            color: #fff;
        }
        .checkers-piece.player2 {
            background: radial-gradient(circle at 35% 35%, #333, #111);
            color: #fff;
        }
        .checkers-piece.king {
            border-color: #facc15;
            box-shadow: 0 0 6px rgba(250,204,21,0.5), 0 2px 4px rgba(0,0,0,0.25);
        }
        .checkers-piece:active {
            transform: scale(0.9);
        }
        .checkers-piece.last-move {
            box-shadow: 0 0 0 3px #22c55e, 0 2px 4px rgba(0,0,0,0.25);
        }
        .checkers-turn-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 16px;
            border-radius: 999px;
            font-weight: 600;
            font-size: 13px;
        }
        .checkers-turn-dot {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            flex-shrink: 0;
            border: 1px solid rgba(0,0,0,0.15);
        }
        .checkers-turn-dot.p1 { background: radial-gradient(circle at 35% 35%, #ef4444, #b91c1c); }
        .checkers-turn-dot.p2 { background: radial-gradient(circle at 35% 35%, #333, #111); }

        /* Dark mode checkers */
        .dark #checkers-overlay .bg-white {
            background-color: #1e293b !important;
            color: #f1f5f9;
        }
        .dark #checkers-overlay .checkers-cell.light {
            background-color: #475569;
        }
        .dark #checkers-overlay .checkers-cell.dark {
            background-color: #1e293b;
        }
        .dark #checkers-overlay #checkers-board {
            border-color: #475569;
        }
        .dark #checkers-overlay .border-slate-200 {
            border-color: #334155 !important;
        }
        .dark #checkers-overlay .text-slate-500 {
            color: #94a3b8;
        }
        .dark #checkers-overlay .bg-slate-50 {
            background-color: #0f172a !important;
        }
        .dark .checkers-turn-indicator.bg-slate-100 {
            background-color: #334155 !important;
            color: #f1f5f9;
        }
        .dark #checkers-overlay input {
            background-color: #0f172a;
            border-color: #334155;
            color: #f1f5f9;
        }
        .dark #checkers-overlay input:focus {
            border-color: #0ea5e9;
        }
        .dark #checkers-overlay .checkers-piece.player2 {
            background: radial-gradient(circle at 35% 35%, #666, #222);
        }
        .dark #checkers-overlay .text-sky-600 {
            color: #38bdf8;
        }

        /* ==================== CHESS GAME ==================== */
        #chess-overlay {
            animation: modalPop 0.25s ease-out;
        }
        #chess-board {
            display: grid;
            grid-template-columns: repeat(8, 1fr);
            aspect-ratio: 1;
            max-width: min(90vw, 420px);
            margin: 0 auto;
            border: 2px solid #b8860b;
            border-radius: 6px;
            overflow: hidden;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
        }
        .chess-cell {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: default;
            position: relative;
            -webkit-tap-highlight-color: transparent;
            font-size: clamp(22px, 7vw, 44px);
            line-height: 1;
        }
        .chess-cell.light { background-color: #f0d9b5; }
        .chess-cell.dark { background-color: #b58863; }
        .chess-cell.valid-move::after {
            content: '';
            position: absolute;
            width: 30%;
            height: 30%;
            background: rgba(34, 197, 94, 0.6);
            border-radius: 50%;
            pointer-events: none;
            z-index: 2;
        }
        .chess-cell.valid-capture {
            box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.7);
        }
        .chess-cell.selected {
            background-color: #fcd34d !important;
        }
        .chess-cell.last-move {
            background-color: #bae6fd !important;
        }
        .dark .chess-cell.last-move {
            background-color: #1e3a5f !important;
        }
        .chess-cell.in-check {
            background: radial-gradient(circle, rgba(239,68,68,0.4), rgba(239,68,68,0.1)) !important;
        }
        .chess-piece {
            cursor: pointer;
            transition: transform 0.1s ease;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
            pointer-events: none;
            z-index: 1;
            position: relative;
        }
        .chess-piece:active {
            transform: scale(0.9);
        }
        .chess-piece.white-piece { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
        .chess-piece.black-piece { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
        .chess-turn-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 14px;
            border-radius: 999px;
            font-weight: 600;
            font-size: 13px;
        }
        .chess-turn-dot {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            flex-shrink: 0;
            border: 1px solid rgba(0,0,0,0.15);
        }
        .chess-turn-dot.white { background: #fff; border-color: #ccc; }
        .chess-turn-dot.black { background: #222; }

        /* Chess captured pieces tray */
        .chess-captured {
            display: flex;
            flex-wrap: wrap;
            gap: 1px;
            font-size: 14px;
            line-height: 1;
            min-height: 20px;
        }
        .chess-captured span { opacity: 0.85; }

        /* Dark mode chess */
        .dark #chess-overlay .bg-white {
            background-color: #1e293b !important;
            color: #f1f5f9;
        }
        .dark #chess-overlay .chess-cell.light {
            background-color: #475569;
        }
        .dark #chess-overlay .chess-cell.dark {
            background-color: #334155;
        }
        .dark #chess-overlay #chess-board {
            border-color: #475569;
        }
        .dark #chess-overlay .border-slate-200 {
            border-color: #334155 !important;
        }
        .dark #chess-overlay .text-slate-500 {
            color: #94a3b8;
        }
        .dark .chess-turn-indicator.bg-slate-100 {
            background-color: #334155 !important;
            color: #f1f5f9;
        }
        .dark #chess-overlay input {
            background-color: #0f172a;
            border-color: #334155;
            color: #f1f5f9;
        }
        .dark #chess-overlay input:focus {
            border-color: #0ea5e9;
        }
        .dark #chess-overlay .text-sky-600 {
            color: #38bdf8;
        }
        .dark #chess-overlay .bg-amber-50 {
            background-color: #422006 !important;
        }
        .dark #chess-overlay .bg-emerald-50 {
            background-color: #064e3b !important;
        }

        /* ==================== TIC TAC TOE ==================== */
        #tictactoe-overlay {
            animation: modalPop 0.25s ease-out;
        }
        #tictactoe-board {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            aspect-ratio: 1;
            max-width: min(80vw, 320px);
            margin: 0 auto;
            border: 2px solid #94a3b8;
            border-radius: 12px;
            overflow: hidden;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
        }
        .ttt-cell {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: clamp(36px, 12vw, 72px);
            font-weight: 700;
            border: 1px solid #cbd5e1;
            transition: background-color 0.15s ease;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            line-height: 1;
        }
        .ttt-cell.light { background-color: #f8fafc; }
        .ttt-cell.dark { background-color: #f1f5f9; }
        .ttt-cell:hover { background-color: #e2e8f0; }
        .ttt-cell:active { transform: scale(0.95); }
        .ttt-cell.x-move { color: #0ea5e9; }
        .ttt-cell.o-move { color: #ef4444; }
        .ttt-cell.win-cell {
            background-color: #bbf7d0 !important;
            animation: tttPulse 0.6s ease-in-out infinite alternate;
        }
        @keyframes tttPulse {
            from { transform: scale(1); }
            to { transform: scale(1.08); }
        }
        .ttt-cell.win-cell.x-move { color: #0284c7; }
        .ttt-cell.win-cell.o-move { color: #dc2626; }

        /* Dark mode TicTacToe */
        .dark #tictactoe-overlay .bg-white {
            background-color: #1e293b !important;
            color: #f1f5f9;
        }
        .dark #tictactoe-overlay #tictactoe-board {
            border-color: #475569;
        }
        .dark .ttt-cell.light { background-color: #334155; }
        .dark .ttt-cell.dark { background-color: #1e293b; }
        .dark .ttt-cell { border-color: #475569; }
        .dark .ttt-cell:hover { background-color: #475569; }
        .dark .ttt-cell.x-move { color: #38bdf8; }
        .dark .ttt-cell.o-move { color: #f87171; }
        .dark .ttt-cell.win-cell {
            background-color: #064e3b !important;
        }
        .dark .ttt-cell.win-cell.x-move { color: #7dd3fc; }
        .dark .ttt-cell.win-cell.o-move { color: #fca5a5; }
        .dark #tictactoe-overlay .border-slate-200 {
            border-color: #334155 !important;
        }
        .dark #tictactoe-overlay .text-slate-500 {
            color: #94a3b8;
        }
        .dark .ttt-turn-indicator.bg-slate-100 {
            background-color: #334155 !important;
            color: #f1f5f9;
        }
        .dark #tictactoe-overlay input {
            background-color: #0f172a;
            border-color: #334155;
            color: #f1f5f9;
        }
        .dark #tictactoe-overlay input:focus {
            border-color: #0ea5e9;
        }
        .dark #tictactoe-overlay .text-sky-600 {
            color: #38bdf8;
        }
        .ttt-turn-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 14px;
            border-radius: 999px;
            font-weight: 600;
            font-size: 13px;
        }
        .ttt-turn-dot {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            flex-shrink: 0;
            border: 1px solid rgba(0,0,0,0.15);
        }
        .ttt-turn-dot.x { background: #0ea5e9; }
        .ttt-turn-dot.o { background: #ef4444; }
        .dark .ttt-turn-dot.x { background: #38bdf8; }
        .dark .ttt-turn-dot.o { background: #f87171; }

        /* Invitation notification animation */
        @keyframes slideDown {
            from { opacity: 0; transform: translate(-50%, -20px); }
            to { opacity: 1; transform: translate(-50%, 0); }
        }

        /* ==================== CHINESE CHESS (Xiangqi) ==================== */
        #xiangqi-overlay { animation: modalPop 0.25s ease-out; }
        #xiangqi-board {
            display: grid;
            grid-template-columns: repeat(9, 1fr);
            grid-template-rows: repeat(10, 1fr);
            aspect-ratio: 9 / 10;
            max-width: min(92vw, 380px);
            margin: 0 auto;
            background: #e8d5a3;
            border: 3px solid #6b3a2a;
            border-radius: 4px;
            position: relative;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
            padding: 0;
            overflow: visible;
        }
        /* Grid lines drawn via pseudo-elements on cells */
        .xiangqi-cell {
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: default;
            position: relative;
            -webkit-tap-highlight-color: transparent;
            font-size: clamp(16px, 4.5vw, 30px);
            font-weight: 700;
            line-height: 1;
            z-index: 2;
        }
        /* Line segments — horizontal and vertical lines from intersection */
        .xiangqi-cell::before {
            content: '';
            position: absolute;
            pointer-events: none;
            z-index: 0;
        }
        /* Right line segment (except last column) */
        .xiangqi-cell:not([data-col="8"])::before {
            top: 50%;
            left: 50%;
            width: 50%;
            height: 1px;
            background: #6b3a2a;
            transform: translate(0, -50%);
        }
        /* Bottom line segment (except last row and river-crossing rows) */
        .xiangqi-cell:not([data-row="9"]):not([data-river="true"])::before {
            top: 50%;
            left: 50%;
            width: 1px;
            height: 50%;
            background: #6b3a2a;
            transform: translate(-50%, 0);
        }
        /* Palace diagonal lines — row 0-2, col 3-5 for black; row 7-9, col 3-5 for red */
        .xiangqi-cell.palace-tl::after {
            content: ''; position: absolute; pointer-events: none; z-index: 0;
            top: 0; left: 0; width: 100%; height: 100%;
            background: linear-gradient(to bottom right, transparent calc(50% - 0.5px), #6b3a2a calc(50% - 0.5px), #6b3a2a calc(50% + 0.5px), transparent calc(50% + 0.5px));
        }
        .xiangqi-cell.palace-tr::after {
            content: ''; position: absolute; pointer-events: none; z-index: 0;
            top: 0; left: 0; width: 100%; height: 100%;
            background: linear-gradient(to bottom left, transparent calc(50% - 0.5px), #6b3a2a calc(50% - 0.5px), #6b3a2a calc(50% + 0.5px), transparent calc(50% + 0.5px));
        }

        /* River gap — the board itself has a visible gap between rows 4-5 */
        #xiangqi-board::before {
            content: '楚 河              漢 界';
            position: absolute;
            top: calc(4 / 10 * 100%);
            left: 0;
            right: 0;
            height: calc(1 / 10 * 100%);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 8%;
            box-sizing: border-box;
            font-size: clamp(10px, 2.5vw, 16px);
            color: #6b3a2a;
            font-weight: 700;
            letter-spacing: 0.3em;
            z-index: 1;
            pointer-events: none;
            opacity: 0.6;
            font-family: 'Noto Serif SC', 'SimSun', serif;
        }
        /* Hide middle section of vertical lines that cross the river */
        #xiangqi-board .xiangqi-cell[data-row="4"]::before,
        #xiangqi-board .xiangqi-cell[data-row="5"]::before {
            height: 0 !important;
        }
        /* River edge cells extend line to board edge */
        #xiangqi-board .xiangqi-cell[data-row="4"]:not([data-col="8"])::before {
            height: 1px !important;
            background: #6b3a2a;
        }
        #xiangqi-board .xiangqi-cell[data-row="5"]:not([data-col="8"])::before {
            height: 1px !important;
            background: #6b3a2a;
        }

        .xiangqi-piece {
            width: 82%;
            height: 82%;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: transform 0.1s ease, box-shadow 0.1s ease;
            font-size: clamp(14px, 3.8vw, 26px);
            font-weight: 700;
            line-height: 1;
            z-index: 3;
            position: relative;
            box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
            border: 2px solid rgba(0,0,0,0.25);
            touch-action: manipulation;
        }
        .xiangqi-piece:active { transform: scale(0.9); }
        .xiangqi-piece.red {
            background: radial-gradient(circle at 35% 30%, #fff5f5, #fecaca 40%, #dc2626);
            color: #fff;
            border-color: #991b1b;
            text-shadow: 0 1px 2px rgba(0,0,0,0.4);
        }
        .xiangqi-piece.black {
            background: radial-gradient(circle at 35% 30%, #f5f5f5, #d4d4d4 40%, #525252);
            color: #fff;
            border-color: #262626;
            text-shadow: 0 1px 2px rgba(0,0,0,0.5);
        }
        .xiangqi-piece.selected {
            box-shadow: 0 0 0 3px #facc15, 0 2px 8px rgba(250,204,21,0.5);
            transform: scale(1.08);
        }
        .xiangqi-cell.valid-move::after {
            content: '';
            position: absolute;
            width: 30%;
            height: 30%;
            background: rgba(34, 197, 94, 0.5);
            border-radius: 50%;
            z-index: 2;
            pointer-events: none;
        }
        .xiangqi-cell.valid-capture::after {
            content: '';
            position: absolute;
            width: 80%;
            height: 80%;
            border: 3px solid rgba(239, 68, 68, 0.6);
            border-radius: 50%;
            z-index: 2;
            pointer-events: none;
            box-sizing: border-box;
        }
        .xiangqi-piece.last-move {
            box-shadow: 0 0 0 3px #22c55e, 0 2px 4px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.3);
        }
        .xiangqi-cell.in-check .xiangqi-piece {
            box-shadow: 0 0 0 3px #ef4444, 0 0 12px rgba(239,68,68,0.5);
            animation: xqCheckPulse 0.8s ease-in-out infinite alternate;
        }
        @keyframes xqCheckPulse {
            from { box-shadow: 0 0 0 3px #ef4444, 0 0 8px rgba(239,68,68,0.3); }
            to { box-shadow: 0 0 0 3px #ef4444, 0 0 16px rgba(239,68,68,0.6); }
        }
        .xq-turn-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 14px;
            border-radius: 999px;
            font-weight: 600;
            font-size: 13px;
        }
        .xq-turn-dot {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            flex-shrink: 0;
            border: 1px solid rgba(0,0,0,0.15);
        }
        .xq-turn-dot.red { background: #dc2626; }
        .xq-turn-dot.black { background: #262626; }

        /* Dark mode Xiangqi */
        .dark #xiangqi-overlay .bg-white {
            background-color: #1e293b !important;
            color: #f1f5f9;
        }
        .dark #xiangqi-overlay #xiangqi-board {
            background: #475569;
            border-color: #334155;
        }
        .dark .xiangqi-cell::before { background: #94a3b8 !important; }
        .dark .xiangqi-cell.palace-tl::after,
        .dark .xiangqi-cell.palace-tr::after { background: #94a3b8 !important; }
        .dark #xiangqi-board::before { color: #94a3b8; }
        .dark #xiangqi-overlay .border-slate-200 { border-color: #334155 !important; }
        .dark #xiangqi-overlay .text-slate-500 { color: #94a3b8; }
        .dark .xq-turn-indicator.bg-slate-100 { background-color: #334155 !important; color: #f1f5f9; }
        .dark #xiangqi-overlay input { background-color: #0f172a; border-color: #334155; color: #f1f5f9; }
        .dark #xiangqi-overlay input:focus { border-color: #0ea5e9; }
        .dark #xiangqi-overlay .text-sky-600 { color: #38bdf8; }
        .dark .xiangqi-piece.red {
            background: radial-gradient(circle at 35% 30%, #450a0a, #7f1d1d 40%, #991b1b);
            color: #fca5a5;
            border-color: #fca5a5;
        }
        .dark .xiangqi-piece.black {
            background: radial-gradient(circle at 35% 30%, #1e293b, #0f172a 40%, #000);
            color: #cbd5e1;
            border-color: #94a3b8;
        }
        .dark #peer-chat-header,
        .dark #peer-messages {
            background-color: var(--card-bg) !important;
            border-color: var(--border) !important;
            color: var(--text);
        }
        .dark #peer-msg-input {
            background-color: var(--card-bg);
            border-color: var(--border);
            color: var(--text);
        }
        .dark #peer-voice-btn {
            background-color: color-mix(in srgb, var(--card-bg) 85%, var(--text-secondary)) !important;
            color: var(--text-secondary);
        }
        .dark #peer-voice-btn:hover {
            background-color: color-mix(in srgb, var(--card-bg) 75%, var(--text-secondary)) !important;
        }
