        /* =========================================================
           APP DIALOGS
        ========================================================= */

        .app-dialog-modal {
            width: min(100%, 430px);
            padding: 22px;
            border: 1px solid var(--border);
            border-radius: 18px;
            background: #1b1b1f;
            box-shadow:
                0 24px 80px rgba(0,0,0,.55);
        }

        .app-dialog-modal h3 {
            margin: 0 0 8px;
            font-size: 1.2rem;
            line-height: 1.25;
        }

        .app-dialog-modal .modal-text {
            margin: 0;
            color: var(--muted);
            font-size: .92rem;
            line-height: 1.5;
        }

        .app-dialog-buttons {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 9px;
            margin-top: 20px;
        }

        .app-dialog-buttons.single {
            grid-template-columns: 1fr;
        }

        .app-dialog-button {
            min-height: 46px;
            padding: 0 14px;
            border: 0;
            border-radius: 11px;
            font: inherit;
            font-weight: 750;
            cursor: pointer;
            touch-action: manipulation;
        }

        .app-dialog-cancel {
            background: var(--surface-3);
            color: var(--text);
        }

        .app-dialog-confirm {
            background: var(--accent);
            color: #fff;
        }

        .app-dialog-danger {
            background: #b63d3d;
            color: #fff;
        }

        .app-dialog-button:active {
            transform: scale(.98);
        }

        @media (max-width: 700px) {

            .modal-overlay {
                padding: 14px;
            }

            .app-dialog-modal {
                width: 100%;
                padding: 20px;
                border-radius: 17px;
            }

            .app-dialog-modal h3 {
                font-size: 1.15rem;
            }

            .app-dialog-button {
                min-height: 48px;
            }
        }



        /* Space above active game card */
        #game-active {
            margin-top: 20px !important;
        }

        @media (max-width: 700px) {
            #game-active {
                margin-top: 16px !important;
            }
        }


        /* =========================================================
           PLAYER PROFILE — FINAL
        ========================================================= */

        .player-profile-modal {
            width: min(100%, 600px);
            max-height: calc(100vh - 32px);
            overflow-y: auto;
            padding: 22px;
        }

        .player-profile-header {
            position: sticky;
            top: -22px;
            z-index: 5;

            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;

            margin: -22px -22px 18px;
            padding: 20px 22px 14px;

            background:
                linear-gradient(
                    to bottom,
                    #202024 80%,
                    rgba(32,32,36,0)
                );
        }

        .player-profile-eyebrow {
            margin-bottom: 3px;
            color: var(--muted);
            font-size: .7rem;
            font-weight: 800;
            letter-spacing: .1em;
            text-transform: uppercase;
        }

        .player-profile-name {
            margin: 0;
            font-size: 1.5rem;
        }

        .player-profile-close {
            flex: 0 0 auto;
            width: 40px;
            height: 40px;
            min-height: 40px;
            padding: 0;
            border-radius: 50%;
            background: var(--surface-3);
            color: #fff;
            font-size: 1.25rem;
            cursor: pointer;
        }


        .player-profile-hero {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;

            margin-bottom: 14px;
            padding: 16px;

            border: 1px solid var(--border);
            border-radius: 14px;
            background: rgba(118,87,255,.09);
        }

        .player-profile-hero-record {
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .player-profile-hero-record strong {
            font-size: 1.65rem;
            line-height: 1;
        }

        .player-profile-hero-record span,
        .player-profile-streak {
            color: var(--muted);
            font-size: .8rem;
        }


        .player-profile-record {
            display: grid;
            grid-template-columns:
                repeat(3, minmax(0, 1fr));
            gap: 9px;
            margin-bottom: 20px;
        }

        .player-profile-stat {
            min-width: 0;
            padding: 13px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--surface-3);
        }

        .player-profile-stat-label {
            display: block;
            margin-bottom: 4px;
            color: var(--muted);
            font-size: .7rem;
        }

        .player-profile-stat-value {
            display: block;
            font-size: 1.12rem;
            font-weight: 800;
        }


        .player-profile-section {
            margin-top: 20px;
        }

        .player-profile-section h4 {
            margin: 0 0 10px;
            color: var(--muted);
            font-size: .76rem;
            font-weight: 800;
            letter-spacing: .08em;
            text-transform: uppercase;
        }


        .player-profile-mode-grid {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 9px;
        }

        .player-profile-mode {
            display: flex;
            flex-direction: column;
            gap: 4px;

            padding: 14px;

            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--surface-3);
        }

        .player-profile-mode-title {
            color: var(--muted);
            font-size: .72rem;
            font-weight: 800;
            text-transform: uppercase;
        }

        .player-profile-mode strong {
            font-size: 1.25rem;
        }

        .player-profile-mode span {
            color: var(--muted);
            font-size: .74rem;
        }


        .player-profile-types {
            width: 100%;
            border-collapse: collapse;
        }

        .player-profile-types th,
        .player-profile-types td {
            padding: 9px 7px;
            border-top:
                1px solid rgba(255,255,255,.07);
            text-align: center;
        }

        .player-profile-types th:first-child,
        .player-profile-types td:first-child {
            text-align: left;
        }

        .player-profile-types th {
            color: var(--muted);
            font-size: .7rem;
            font-weight: 700;
        }


        .player-profile-recent {
            display: flex;
            flex-direction: column;
            gap: 7px;
        }

        .player-profile-recent-game {
            display: grid;
            grid-template-columns:
                34px minmax(0, 1fr) auto;
            align-items: center;
            gap: 10px;

            padding: 10px 11px;

            border: 1px solid var(--border);
            border-radius: 11px;
            background: var(--surface-3);
        }

        .player-profile-result {
            display: flex;
            align-items: center;
            justify-content: center;

            width: 30px;
            height: 30px;

            border-radius: 8px;

            font-size: .76rem;
            font-weight: 900;
        }

        .player-profile-result-win {
            background: rgba(85,216,138,.14);
            color: #62d889;
        }

        .player-profile-result-loss {
            background: rgba(217,75,75,.14);
            color: #ff7777;
        }

        .player-profile-result-draw {
            background: rgba(255,255,255,.08);
            color: var(--muted);
        }

        .player-profile-recent-main {
            display: flex;
            flex-direction: column;
            min-width: 0;
            gap: 2px;
        }

        .player-profile-recent-main strong {
            font-size: .82rem;
        }

        .player-profile-recent-main span {
            color: var(--muted);
            font-size: .7rem;
        }

        .player-profile-recent-score {
            font-size: .95rem;
            font-weight: 850;
            white-space: nowrap;
        }

        .player-profile-empty,
        .player-profile-loading {
            padding: 16px 4px;
            color: var(--muted);
            font-size: .9rem;
        }


        @media (max-width: 700px) {

            .player-profile-modal {
                width: 100%;
                max-height:
                    calc(100vh - 20px);
                padding: 16px;
                border-radius: 18px;
            }

            .player-profile-header {
                top: -16px;
                margin:
                    -16px -16px 14px;
                padding:
                    16px 16px 12px;
            }

            .player-profile-name {
                font-size: 1.35rem;
            }

            .player-profile-hero {
                align-items: flex-start;
                flex-direction: column;
                padding: 14px;
            }

            .player-profile-record {
                grid-template-columns:
                    repeat(
                        2,
                        minmax(0, 1fr)
                    );
                gap: 8px;
            }

            .player-profile-stat {
                padding: 12px;
            }

            .player-profile-mode-grid {
                gap: 8px;
            }

            .player-profile-mode {
                padding: 12px;
            }

            .player-profile-types th,
            .player-profile-types td {
                padding: 8px 5px;
                font-size: .76rem;
            }

            .player-profile-recent-game {
                padding: 9px;
                gap: 8px;
            }
        }



        /* =========================================================
           PLAYER PROFILE OVER LEADERBOARD
        ========================================================= */

        .player-profile-overlay {
            z-index: 20000 !important;
        }

        .player-profile-overlay .player-profile-modal {
            position: relative;
            z-index: 20001;
        }

        @media (max-width: 700px) {

            .player-profile-overlay {
                z-index: 20000 !important;
                padding: 10px;
            }

            .player-profile-overlay .player-profile-modal {
                width: 100%;
                max-height: calc(100dvh - 20px);
            }
        }



