* {
            box-sizing: border-box;
        }

        :root {
            --bg: #0d0d0f;
            --surface: #17171a;
            --surface-2: #202024;
            --surface-3: #29292e;
            --text: #ffffff;
            --muted: #929299;
            --accent: #7657ff;
            --accent-hover: #866cff;
            --danger: #d94b4b;
            --border: rgba(255,255,255,0.07);
        }

        html {
            background: var(--bg);
        }

        body {
            margin: 0;
            min-height: 100vh;
            font-family:
                Inter,
                system-ui,
                -apple-system,
                BlinkMacSystemFont,
                "Segoe UI",
                sans-serif;
            background:
                radial-gradient(
                    circle at top,
                    rgba(118,87,255,0.10),
                    transparent 500px
                ),
                var(--bg);
            color: var(--text);
        }

        button,
        input,
        select {
            font: inherit;
        }

        button {
            border: 0;
        }

        main {
            width: min(1100px, calc(100% - 32px));
            margin: 0 auto;
            padding: 42px 0 70px;
        }

        /* ---------------------------------------------------------
           HEADER
        --------------------------------------------------------- */

        .header {
            margin-bottom: 32px;
        }

        .title {
            margin: 0;
            font-size: clamp(2rem, 5vw, 3rem);
            letter-spacing: -0.04em;
        }

        .subtitle {
            margin: 8px 0 0;
            color: var(--muted);
            font-size: 1rem;
        }

        /* ---------------------------------------------------------
           LIVE CAMERA
        --------------------------------------------------------- */

        .live-section {
            margin-bottom: 42px;
        }

        .live-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 16px;
        }

        .section-title {
            margin: 0;
            font-size: 1.15rem;
        }

        .live-status {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.08em;
            color: #ff4d4d;
        }

        .live-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #ff4d4d;
            box-shadow: 0 0 10px rgba(255,77,77,.65);
            animation: live-pulse 1.5s ease-in-out infinite;
        }

        @keyframes live-pulse {
            0%, 100% {
                opacity: 1;
            }

            50% {
                opacity: .35;
            }
        }

        .live-player {
            position: relative;
            width: 100%;
            aspect-ratio: 16 / 9;
            overflow: hidden;
            border-radius: 16px;
            background: #090909;
            box-shadow: 0 12px 35px rgba(0,0,0,.25);
        }

        .live-player img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: contain;
            background: #090909;
        }

        .live-loading {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(255,255,255,.65);
            font-size: 14px;
            pointer-events: none;
        }

        .live-player.live-connected .live-loading {
            display: none;
        }

        /* ---------------------------------------------------------
           GAME
        --------------------------------------------------------- */

        .game-section {
            margin-bottom: 22px;
            padding: 22px;
            border: 1px solid var(--border);
            border-radius: 22px;
            background: rgba(23,23,26,.88);
            backdrop-filter: blur(10px);
        }

        .game-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
        }

        .game-status {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #55d88a;
            font-size: .8rem;
            font-weight: 800;
            letter-spacing: .07em;
            text-transform: uppercase;
        }

        .game-status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #55d88a;
            box-shadow: 0 0 10px rgba(85,216,138,.55);
        }

        .game-empty {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 18px;
        }

        .game-empty-text {
            color: var(--muted);
            font-size: .92rem;
        }

        .game-active {
            margin-top: 16px;
            padding: 18px;
            border-radius: 16px;
            background: var(--surface-2);
            border: 1px solid var(--border);
        }

        .game-matchup {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            gap: 18px;
            text-align: center;
        }

        .game-team {
            font-size: 1.15rem;
            font-weight: 750;
        }

        .game-vs {
            color: var(--muted);
            font-size: .8rem;
            font-weight: 800;
            letter-spacing: .08em;
        }

        .game-type {
            margin-top: 8px;
            color: var(--muted);
            font-size: .8rem;
        }

        .game-score-status {
            margin-top: 14px;
            text-align: center;
            color: var(--muted);
            font-size: .84rem;
            font-weight: 700;
        }

        .game-score {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: stretch;
            gap: 12px;
            margin-top: 12px;
        }

        .game-score-button {
            min-height: 100px;
            padding: 14px;
            border: 1px solid var(--border);
            border-radius: 16px;
            background: var(--surface-2);
            color: var(--text);
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition:
                transform .15s ease,
                background .15s ease,
                border-color .15s ease;
        }

        .game-score-button:hover {
            background: var(--surface-3);
            border-color: var(--accent);
            transform: translateY(-2px);
        }

        .game-score-button:active {
            transform: scale(.97);
        }

        .game-score-player {
            font-size: .9rem;
            font-weight: 700;
            text-align: center;
            word-break: break-word;
        }

        .game-score-number {
            font-size: 2.1rem;
            font-weight: 850;
            line-height: 1;
        }

        .game-score-divider {
            align-self: center;
            color: var(--muted);
            font-size: 1.8rem;
            font-weight: 700;
        }

        .game-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 16px;
        }

        .game-button {
            min-height: 44px;
            padding: 0 16px;
            border-radius: 12px;
            background: var(--accent);
            color: white;
            font-weight: 700;
            cursor: pointer;
        }

        .game-button:hover {
            background: var(--accent-hover);
        }

        .game-button.secondary {
            background: var(--surface-3);
        }

        .game-button.danger {
            background: var(--danger);
        }

        .game-form {
            margin-top: 18px;
        }

        .game-type-buttons {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-bottom: 18px;
        }

        .game-type-button {
            min-height: 48px;
            border-radius: 12px;
            background: var(--surface-2);
            color: var(--muted);
            border: 1px solid var(--border);
            font-weight: 750;
            cursor: pointer;
        }

        .game-type-button.active {
            background: var(--accent);
            color: white;
            border-color: transparent;
        }

        .game-teams {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 14px;
        }

        .game-team-form {
            padding: 16px;
            border-radius: 14px;
            background: var(--surface-2);
            border: 1px solid var(--border);
        }

        .game-team-label {
            margin-bottom: 10px;
            font-size: .8rem;
            font-weight: 800;
            color: var(--muted);
            text-transform: uppercase;
            letter-spacing: .07em;
        }

        .game-player-input-wrap {
            position: relative;
        }

        .game-player-input {
            width: 100%;
            height: 44px;
            margin-bottom: 8px;
            padding: 0 12px;
            border: 1px solid var(--border);
            border-radius: 10px;
            outline: none;
            background: var(--surface);
            color: white;
        }

        .game-player-input:focus {
            border-color: var(--accent);
        }

        .game-player-suggestions {
            position: absolute;
            top: 44px;
            left: 0;
            right: 0;
            z-index: 100;
            max-height: 180px;
            overflow-y: auto;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 0 0 10px 10px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
        }

        .game-player-suggestions.open-up {
            top: auto;
            bottom: calc(100% + 3px);
            border-radius: 10px;
        }

        .game-player-suggestion {
            padding: 10px 12px;
            cursor: pointer;
            color: white;
        }

        .game-player-suggestion:hover,
        .game-player-suggestion.active {
            background: var(--border);
        }

        .game-form-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 14px;
        }

        .game-error {
            margin-top: 12px;
            color: #ff7777;
            font-size: .9rem;
        }

        .hidden {
            display: none !important;
        }

        @media (max-width: 650px) {

            .game-empty {
                align-items: stretch;
                flex-direction: column;
            }

            .game-empty .game-button {
                width: 100%;
            }

            .game-matchup {
                grid-template-columns: 1fr;
                gap: 8px;
            }

            .game-vs {
                order: 2;
            }

            .game-teams {
                grid-template-columns: 1fr;
            }

            .game-actions,
            .game-form-actions {
                flex-direction: column;
            }

            .game-button {
                width: 100%;
            }
        }

        /* ---------------------------------------------------------
           GAME
        --------------------------------------------------------- */

        .game-section {
            margin-bottom: 24px;
            padding: 22px;
            border: 1px solid var(--border);
            border-radius: 22px;
            background: rgba(23,23,26,.88);
            backdrop-filter: blur(10px);
        }

        .game-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 20px;
        }

        .game-subtitle {
            margin: 7px 0 0;
            color: var(--muted);
            font-size: .9rem;
        }

        .active-game-badge {
            flex-shrink: 0;
            padding: 8px 11px;
            border-radius: 999px;
            background: rgba(70,190,110,.12);
            color: #62d889;
            font-size: 11px;
            font-weight: 800;
            letter-spacing: .06em;
        }

        .active-game-badge::first-letter {
            color: #62d889;
        }

        .game-type-buttons {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-bottom: 20px;
        }

        .game-type-button {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 4px;
            padding: 16px;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: var(--surface-2);
            color: var(--text);
            cursor: pointer;
            text-align: left;
            transition:
                border-color .15s ease,
                background .15s ease,
                transform .15s ease;
        }

        .game-type-button:hover {
            transform: translateY(-1px);
        }

        .game-type-button.active {
            border-color: var(--accent);
            background: rgba(118,87,255,.14);
        }

        .game-type-button strong {
            font-size: 1.1rem;
        }

        .game-type-button span {
            color: var(--muted);
            font-size: .8rem;
        }

        .teams {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            gap: 16px;
        }

        .team {
            min-width: 0;
        }

        .team-title {
            margin-bottom: 9px;
            color: var(--muted);
            font-size: .8rem;
            font-weight: 750;
            text-transform: uppercase;
            letter-spacing: .08em;
        }

        .player-input {
            width: 100%;
            height: 48px;
            margin-bottom: 9px;
            padding: 0 14px;
            border: 1px solid var(--border);
            border-radius: 12px;
            outline: none;
            background: var(--surface);
            color: white;
        }

        .player-input:focus {
            border-color: var(--accent);
        }

        .vs,
        .active-vs {
            color: var(--muted);
            font-size: .8rem;
            font-weight: 850;
            letter-spacing: .08em;
        }

        .start-game-button {
            width: 100%;
            min-height: 52px;
            margin-top: 8px;
            border-radius: 14px;
            background: var(--accent);
            color: white;
            font-weight: 800;
            cursor: pointer;
            transition:
                background .15s ease,
                transform .15s ease,
                opacity .15s ease;
        }

        .start-game-button:hover:not(:disabled) {
            background: var(--accent-hover);
            transform: translateY(-1px);
        }

        .start-game-button:disabled {
            opacity: .45;
            cursor: not-allowed;
        }

        .game-error {
            margin-top: 12px;
            padding: 12px 14px;
            border-radius: 12px;
            background: rgba(217,75,75,.12);
            color: #ff7777;
            font-size: .9rem;
        }

        .active-game-panel {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            padding: 18px;
            border-radius: 16px;
            background: var(--surface-2);
            border: 1px solid var(--border);
        }

        .active-game-type {
            margin-bottom: 9px;
            color: var(--muted);
            font-size: .75rem;
            font-weight: 800;
            letter-spacing: .08em;
            text-transform: uppercase;
        }

        .active-teams {
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .active-team {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
        }

        .player-tag {
            display: inline-flex;
            align-items: center;
            min-height: 30px;
            padding: 5px 10px;
            border-radius: 999px;
            background: rgba(118,87,255,.16);
            color: #ddd6ff;
            font-size: .85rem;
            font-weight: 700;
        }

        .active-game-started {
            margin-top: 8px;
            color: var(--muted);
            font-size: .78rem;
        }

        .end-game-button {
            flex-shrink: 0;
            min-height: 44px;
            padding: 0 18px;
            border-radius: 12px;
            background: rgba(217,75,75,.14);
            color: #ff7777;
            font-weight: 750;
            cursor: pointer;
        }

        .end-game-button:hover {
            background: rgba(217,75,75,.22);
        }

        .hidden {
            display: none !important;
        }


        /* ---------------------------------------------------------
           RECORD
        --------------------------------------------------------- */

        .record-section {
            padding: 22px;
            border: 1px solid var(--border);
            border-radius: 22px;
            background: rgba(23,23,26,.88);
            backdrop-filter: blur(10px);
        }

        .record-buttons {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 12px;
            margin-top: 16px;
        }

        .record-button {
            min-height: 74px;
            padding: 18px 12px;
            border-radius: 16px;
            background: var(--accent);
            color: white;
            font-size: 1.25rem;
            font-weight: 750;
            cursor: pointer;
            transition:
                transform .15s ease,
                background .15s ease,
                opacity .15s ease,
                box-shadow .15s ease;
        }

        .record-button:hover:not(:disabled) {
            background: var(--accent-hover);
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(118,87,255,.22);
        }

        .record-button:active:not(:disabled) {
            transform: scale(.98);
        }

        .record-button:disabled {
            opacity: .35;
            cursor: not-allowed;
        }

        /* ---------------------------------------------------------
           PROCESSING
        --------------------------------------------------------- */

        .processing {
            margin-top: 18px;
            padding: 18px;
            border-radius: 16px;
            background: var(--surface-2);
            border: 1px solid var(--border);
        }

        .processing.hidden {
            display: none;
        }

        .processing-header {
            display: flex;
            justify-content: space-between;
            gap: 16px;
            align-items: center;
            margin-bottom: 12px;
        }

        .processing-title {
            font-weight: 700;
        }

        .processing-percent {
            color: var(--muted);
            font-variant-numeric: tabular-nums;
        }

        .progress-track {
            height: 12px;
            overflow: hidden;
            border-radius: 999px;
            background: #303035;
        }

        .progress-fill {
            height: 100%;
            width: 0%;
            border-radius: inherit;
            background: var(--accent);
            transition: width .25s ease;
        }

        .processing-stage {
            margin-top: 9px;
            color: var(--muted);
            font-size: .9rem;
        }

        /* ---------------------------------------------------------
           LIBRARY
        --------------------------------------------------------- */

        .library {
            margin-top: 42px;
        }

        .library-header {
            display: flex;
            justify-content: space-between;
            align-items: end;
            gap: 20px;
            margin-bottom: 18px;
        }

        .library-header h2 {
            margin: 0;
            font-size: 1.5rem;
        }

        .library-count {
            color: var(--muted);
            font-size: .9rem;
        }

        .tools {
            display: grid;
            grid-template-columns: 1fr auto auto auto;
            gap: 10px;
            margin-bottom: 18px;
        }

        .search {
            min-width: 0;
            height: 46px;
            padding: 0 14px;
            border: 1px solid var(--border);
            border-radius: 12px;
            outline: none;
            background: var(--surface);
            color: white;
        }

        .search:focus {
            border-color: var(--accent);
        }

        .filter {
            height: 46px;
            padding: 0 12px;
            border: 1px solid var(--border);
            border-radius: 12px;
            outline: none;
            background: var(--surface);
            color: white;
        }

        .filter:focus {
            border-color: var(--accent);
        }

        .favorites-toggle {
            min-height: 44px;
            padding: 10px 16px;
            border-radius: 10px;
            background: var(--surface-3);
            color: var(--text);
            cursor: pointer;
            font-weight: 650;
            white-space: nowrap;
            transition: .15s ease;
        }

        .favorites-toggle:hover {
            filter: brightness(1.12);
        }

        .favorites-toggle.active {
            background: var(--accent);
            color: white;
        }

        /* ---------------------------------------------------------
           REPLAY GRID
        --------------------------------------------------------- */

        .replay-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 18px;
        }

        .replay-card {
            overflow: hidden;
            border: 1px solid var(--border);
            border-radius: 18px;
            background: var(--surface);
            transition:
                transform .18s ease,
                border-color .18s ease,
                box-shadow .18s ease;
        }

        .replay-card:hover {
            transform: translateY(-2px);
            border-color: rgba(255,255,255,.12);
            box-shadow: 0 14px 35px rgba(0,0,0,.22);
        }

        .thumbnail-wrap {
            position: relative;
            cursor: pointer;
            background: #090909;
            overflow: hidden;
        }

        .thumbnail-wrap::after {
            content: "▶";
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            width: 54px;
            height: 54px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: rgba(0,0,0,.72);
            color: white;
            font-size: 22px;
            padding-left: 3px;
            opacity: .9;
            pointer-events: none;
            transition:
                transform .15s ease,
                opacity .15s ease;
        }

        .thumbnail-wrap:hover::after {
            transform: translate(-50%,-50%) scale(1.08);
            opacity: 1;
        }

        .thumbnail {
            display: block;
            width: 100%;
            aspect-ratio: 16 / 9;
            object-fit: cover;
        }

        .duration {
            position: absolute;
            right: 10px;
            bottom: 10px;
            padding: 4px 7px;
            border-radius: 7px;
            background: rgba(0,0,0,.75);
            font-size: .8rem;
            font-weight: 700;
        }

        .thumbnail-favorite {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 42px;
            height: 42px;
            min-height: 42px;
            padding: 0;
            border-radius: 50%;
            background: rgba(0,0,0,.65);
            color: white;
            font-size: 1.5rem;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(5px);
            transition:
                transform .15s ease,
                background .15s ease;
        }

        .thumbnail-favorite:hover {
            transform: scale(1.08);
            background: rgba(0,0,0,.8);
        }

        .thumbnail-favorite.is-favorite {
            color: #ffd84d;
        }

        /* ---------------------------------------------------------
           REPLAY BODY
        --------------------------------------------------------- */

        .replay-body {
            padding: 15px;
        }

        .replay-title-row {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 10px;
        }

        .replay-title-info {
            min-width: 0;
        }

        .replay-name {
            margin: 0;
            font-size: 1.08rem;
            font-weight: 750;
            word-break: break-word;
        }

        .replay-date {
            margin-top: 5px;
            color: var(--muted);
            font-size: .84rem;
        }

        .replay-game-info {
            margin-top: 8px;
            color: var(--text);
            font-size: .88rem;
            font-weight: 650;
            opacity: .9;
            word-break: break-word;
        }

        .action-delete-small {
            flex: 0 0 auto;
            width: 36px;
            height: 36px;
            min-height: 36px;
            padding: 0;
            border-radius: 9px;
            background: rgba(217,75,75,.14);
            color: #ff7777;
            cursor: pointer;
            font-size: 1.05rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition:
                background .15s ease,
                transform .15s ease;
        }

        .action-delete-small:hover {
            background: rgba(217,75,75,.28);
            transform: scale(1.05);
        }

        .action-delete-small:active {
            transform: scale(.95);
        }

        .replay-actions {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 8px;
            margin-top: 14px;
        }

        .action {
            min-height: 42px;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 650;
            transition:
                transform .15s ease,
                filter .15s ease;
        }

        .action:hover {
            filter: brightness(1.12);
            transform: translateY(-1px);
        }

        .action:active {
            transform: scale(.98);
        }

        .action-play {
            background: var(--accent);
            color: white;
        }

        .action-secondary,
        .action-share {
            background: var(--surface-3);
            color: white;
        }

        .empty {
            grid-column: 1 / -1;
            padding: 45px 20px;
            text-align: center;
            border-radius: 18px;
            border: 1px dashed var(--border);
            color: var(--muted);
        }

        /* ---------------------------------------------------------
           MODALS
        --------------------------------------------------------- */

        .modal-overlay {
            position: fixed;
            inset: 0;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background: rgba(0,0,0,.78);
            backdrop-filter: blur(8px);
        }

        .modal {
            width: min(100%, 460px);
            padding: 24px;
            border-radius: 20px;
            background: var(--surface-2);
            border: 1px solid var(--border);
            box-shadow: 0 25px 80px rgba(0,0,0,.55);
        }

        .modal h3 {
            margin: 0 0 8px;
            font-size: 1.35rem;
        }

        .modal-text {
            margin: 0 0 18px;
            color: var(--muted);
            line-height: 1.5;
        }

        .modal-input {
            width: 100%;
            height: 52px;
            padding: 0 14px;
            border: 1px solid #3b3b42;
            border-radius: 12px;
            outline: none;
            background: var(--bg);
            color: white;
        }

        .modal-input:focus {
            border-color: var(--accent);
        }

        .modal-buttons {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 18px;
        }

        .modal-button {
            min-height: 48px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
        }

        .modal-cancel {
            background: var(--surface-3);
            color: white;
        }

        .modal-confirm {
            background: var(--accent);
            color: white;
        }

        .modal-danger {
            background: var(--danger);
            color: white;
        }

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

        .player-profile-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 20px;
        }

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

        .player-profile-close {
            width: 40px;
            height: 40px;
            min-height: 40px;
            padding: 0;
            border-radius: 50%;
            background: var(--surface-3);
            color: white;
            cursor: pointer;
            font-size: 20px;
        }

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

        .player-profile-stat {
            padding: 14px;
            border-radius: 12px;
            background: var(--surface-3);
        }

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

        .player-profile-stat-value {
            font-size: 1.25rem;
            font-weight: 750;
        }

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

        .player-profile-section h4 {
            margin: 0 0 10px;
            font-size: 14px;
        }

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

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

        .player-profile-types th {
            font-size: 12px;
            opacity: .55;
        }

        .player-profile-player {
            cursor: pointer;
        }

        .player-profile-player:hover {
            text-decoration: underline;
        }

        @media (max-width: 600px) {
            .player-profile-modal {
                width: 100%;
                max-height: calc(100vh - 24px);
            }

            .player-profile-record {
                grid-template-columns: 1fr 1fr;
            }
        }

        .share-url {
            display: flex;
            gap: 8px;
        }

        .share-url .modal-input {
            flex: 1;
            min-width: 0;
        }

        .share-copy {
            flex: 0 0 auto;
            width: 100px;
            min-height: 52px;
            border-radius: 12px;
            background: var(--accent);
            color: white;
            font-weight: 700;
            cursor: pointer;
        }

        .share-copy:hover {
            background: var(--accent-hover);
        }

        /* ---------------------------------------------------------
           VIDEO VIEWER
        --------------------------------------------------------- */

        .viewer {
            width: min(1100px,100%);
            max-height: calc(100vh - 40px);
            display: flex;
            flex-direction: column;
            gap: 14px;
        }

        .viewer-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
        }

        .viewer-title {
            margin: 0;
            font-size: 1.35rem;
            font-weight: 750;
            word-break: break-word;
        }

        .viewer-close {
            flex: 0 0 auto;
            width: 44px;
            height: 44px;
            min-height: 44px;
            padding: 0;
            border-radius: 50%;
            background: var(--surface-3);
            color: white;
            font-size: 1.4rem;
            cursor: pointer;
        }

        .viewer video {
            display: block;
            width: 100%;
            max-height: 68vh;
            border-radius: 14px;
            background: black;
            object-fit: contain;
        }

        .viewer-info {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            color: var(--muted);
            font-size: .9rem;
        }

        .viewer-controls {
            display: grid;
            grid-template-columns: 1fr 1fr auto auto auto;
            gap: 10px;
        }

        .viewer-control {
            min-height: 46px;
            padding: 10px 14px;
            border-radius: 11px;
            background: var(--surface-3);
            color: white;
            font-size: .95rem;
            font-weight: 650;
            cursor: pointer;
        }

        .viewer-control:hover {
            filter: brightness(1.15);
        }

        .viewer-download {
            display: flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
        }

        .viewer-speed {
            min-height: 46px;
            padding: 0 12px;
            border-radius: 11px;
            background: var(--surface-3);
            color: white;
            font-size: .95rem;
        }

        /* ---------------------------------------------------------
           LOGIN
        --------------------------------------------------------- */

        .login-screen {
            position: fixed;
            inset: 0;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 24px;
            background: #0b0d12;
        }

        .login-card {
            width: min(420px,100%);
            padding: 32px;
            border-radius: 20px;
            background: #151922;
            border: 1px solid rgba(255,255,255,.08);
            box-shadow: 0 24px 80px rgba(0,0,0,.45);
        }

        .login-icon {
            font-size: 3rem;
            text-align: center;
            margin-bottom: 8px;
        }

        .login-card h1 {
            margin: 0;
            text-align: center;
        }

        .login-subtitle {
            text-align: center;
            opacity: .65;
            margin: 8px 0 28px;
        }

        .login-card label {
            display: block;
            margin: 14px 0 6px;
            font-size: .9rem;
            opacity: .8;
        }

        .login-card input {
            width: 100%;
            padding: 13px 14px;
            border-radius: 10px;
            border: 1px solid rgba(255,255,255,.12);
            background: #0d1016;
            color: inherit;
            outline: none;
        }

        .login-card input:focus {
            border-color: rgba(255,255,255,.35);
        }

        .login-card button {
            width: 100%;
            margin-top: 22px;
            padding: 13px;
            border-radius: 10px;
            background: white;
            color: #111;
            font-weight: 700;
            cursor: pointer;
        }

        .login-card button:disabled {
            opacity: .6;
            cursor: wait;
        }

        .login-error {
            min-height: 20px;
            margin-top: 12px;
            text-align: center;
            color: #ff7777;
            font-size: .9rem;
        }

        .app-hidden {
            visibility: hidden;
        }

        .app-visible {
            visibility: visible;
        }

        /* ---------------------------------------------------------
           MOBILE
        --------------------------------------------------------- */

        @media (max-width: 700px) {
            main {
                width: min(calc(100% - 20px),520px);
                padding-top: 24px;
            }

            .live-section {
                margin-bottom: 32px;
            }

            .live-header {
                margin-bottom: 12px;
            }

            .live-player {
                border-radius: 12px;
            }

            .record-section {
                padding: 16px;
                border-radius: 18px;
            }

            .record-buttons {
                grid-template-columns: 1fr;
                gap: 10px;
            }

            .record-button {
                min-height: 84px;
                font-size: 1.4rem;
            }

            .replay-grid {
                grid-template-columns: 1fr;
            }

            .library-header {
                align-items: start;
                flex-direction: column;
                gap: 5px;
            }

            .tools {
                grid-template-columns: 1fr 1fr;
                gap: 10px;
            }

            .tools .search {
                grid-column: 1 / -1;
                width: 100%;
            }

            .tools .filter,
            .tools .favorites-toggle {
                width: 100%;
            }

            .viewer {
                width: 100%;
                max-height: calc(100vh - 24px);
                gap: 10px;
            }

            .viewer video {
                max-height: 55vh;
                border-radius: 10px;
            }

            .viewer-title {
                font-size: 1.15rem;
            }

            .viewer-info {
                font-size: .82rem;
            }

            .viewer-controls {
                grid-template-columns: 1fr 1fr;
            }

            .viewer-control,
            .viewer-speed {
                min-height: 48px;
            }

            .share-url {
                flex-direction: column;
            }

            .share-copy {
                width: 100%;
            }
        }
    
        .overall-leaderboard {
            margin-top: 24px;
            padding: 20px;
            border-radius: 16px;
            background: rgba(255, 255, 255, 0.04);
        }

        .overall-leaderboard-title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 14px;
        }

        .overall-leaderboard-title h3 {
            margin: 0;
        }

        .overall-leaderboard-table {
            width: 100%;
            border-collapse: collapse;
        }

        .overall-leaderboard-table th,
        .overall-leaderboard-table td {
            padding: 10px 8px;
            text-align: left;
        }

        .overall-leaderboard-table th {
            font-size: 12px;
            opacity: 0.55;
            font-weight: 600;
        }

        .overall-leaderboard-table td {
            border-top: 1px solid rgba(255, 255, 255, 0.07);
        }

        .overall-leaderboard-rank {
            width: 36px;
            opacity: 0.55;
        }

        .overall-leaderboard-player {
            font-weight: 600;
        }

        .overall-leaderboard-record {
            white-space: nowrap;
        }

        .overall-leaderboard-winrate {
            text-align: right !important;
            white-space: nowrap;
        }

        .overall-leaderboard-empty {
            opacity: 0.55;
            padding: 8px 0;
        }

        @media (max-width: 600px) {
            .overall-leaderboard {
                padding: 16px;
            }

            .overall-leaderboard-table th,
            .overall-leaderboard-table td {
                padding: 8px 5px;
            }

            .overall-leaderboard-table th:nth-child(4),
            .overall-leaderboard-table td:nth-child(4) {
                display: none;
            }
        }

        .session-leaderboard {
            margin-top: 24px;
            padding: 20px;
            border-radius: 16px;
            background: rgba(255, 255, 255, 0.04);
        }

        .session-leaderboard-title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 14px;
        }

        .session-leaderboard-title h3 {
            margin: 0;
        }

        .session-leaderboard-actions {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .session-leaderboard-session {
            font-size: 12px;
            opacity: 0.55;
        }

        .session-end-button {
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.06);
            color: inherit;
            border-radius: 8px;
            padding: 7px 11px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
        }

        .session-end-button:hover {
            background: rgba(255, 255, 255, 0.10);
        }

        .session-end-button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .session-leaderboard-table {
            width: 100%;
            border-collapse: collapse;
        }

        .session-leaderboard-table th,
        .session-leaderboard-table td {
            padding: 10px 8px;
            text-align: left;
        }

        .session-leaderboard-table th {
            font-size: 12px;
            opacity: 0.55;
            font-weight: 600;
        }

        .session-leaderboard-table td {
            border-top: 1px solid rgba(255, 255, 255, 0.07);
        }

        .session-leaderboard-rank {
            width: 36px;
            opacity: 0.55;
        }

        .session-leaderboard-player {
            font-weight: 600;
        }

        .session-leaderboard-record {
            white-space: nowrap;
        }

        .session-leaderboard-winrate {
            text-align: right !important;
            white-space: nowrap;
        }

        .session-leaderboard-empty {
            opacity: 0.55;
            padding: 8px 0;
        }

        @media (max-width: 600px) {
            .session-leaderboard {
                padding: 16px;
            }

            .session-leaderboard-table th,
            .session-leaderboard-table td {
                padding: 8px 5px;
            }

            .session-leaderboard-table th:nth-child(3),
            .session-leaderboard-table td:nth-child(3) {
                display: none;
            }
        }


        /* =====================================================
           DASHBOARD LAYOUT
           Mobile-first leaderboard / capture layout
        ===================================================== */

        .dashboard-grid {
            display: grid;
            grid-template-columns:
                minmax(0, 1.65fr)
                minmax(330px, .75fr);
            gap: 20px;
            align-items: start;
            margin-bottom: 22px;
        }

        .dashboard-main {
            min-width: 0;
        }

        .dashboard-main .live-section {
            margin-bottom: 20px;
        }

        .dashboard-main .game-section {
            margin-bottom: 0;
        }

        .dashboard-leaderboards {
            display: grid;
            gap: 16px;
            min-width: 0;
        }

        .dashboard-leaderboards
        .session-leaderboard,
        .dashboard-leaderboards
        .overall-leaderboard {
            margin: 0;
            border: 1px solid var(--border);
            background: rgba(23,23,26,.88);
            backdrop-filter: blur(10px);
        }

        .dashboard-leaderboards
        .session-leaderboard-title,
        .dashboard-leaderboards
        .overall-leaderboard-title {
            margin-bottom: 14px;
        }

        .record-section {
            margin-top: 0;
        }


        /*
         * At narrower desktop/tablet widths, stop forcing the
         * sidebar. The order remains:
         *
         * Live
         * Game
         * Session leaderboard
         * Overall leaderboard
         * Replay capture
         */
        @media (max-width: 900px) {

            .dashboard-grid {
                grid-template-columns: 1fr;
                gap: 14px;
            }

            .dashboard-leaderboards {
                gap: 10px;
            }
        }


        /* =====================================================
           MOBILE
        ===================================================== */

        @media (max-width: 700px) {

            main {
                width: calc(100% - 16px);
                max-width: 520px;
                padding: 14px 0 44px;
            }

            .header {
                margin-bottom: 18px;
                padding: 0 4px;
            }

            .title {
                font-size: 1.75rem;
            }

            .subtitle {
                margin-top: 5px;
                font-size: .88rem;
                line-height: 1.4;
            }


            /* ---------------- LIVE ---------------- */

            .dashboard-grid {
                gap: 10px;
                margin-bottom: 12px;
            }

            .dashboard-main .live-section {
                margin-bottom: 10px;
            }

            .live-header {
                margin-bottom: 9px;
                padding: 0 3px;
            }

            .section-title {
                font-size: 1.05rem;
            }

            .live-status {
                font-size: 10px;
            }

            .live-player {
                border-radius: 14px;
                box-shadow:
                    0 8px 28px rgba(0,0,0,.32);
            }


            /* ---------------- GAME ---------------- */

            .game-section {
                margin-bottom: 0;
                padding: 14px;
                border-radius: 16px;
                background:
                    rgba(23,23,26,.94);
            }

            .game-header {
                gap: 10px;
                margin-bottom: 14px;
            }

            .game-empty {
                gap: 12px;
            }

            .game-button {
                min-height: 46px;
                border-radius: 11px;
            }

            .game-type-buttons {
                gap: 8px;
                margin-bottom: 14px;
            }

            .game-round-buttons {
                gap: 7px;
            }

            .game-player-input {
                height: 46px;
            }

            .game-score-button {
                border-radius: 14px;
            }

            .game-score-number {
                font-size: clamp(
                    2rem,
                    12vw,
                    3rem
                );
            }


            /* ---------------- LEADERBOARD CARDS ---------------- */

            .dashboard-leaderboards {
                gap: 8px;
            }

            .dashboard-leaderboards
            .session-leaderboard,
            .dashboard-leaderboards
            .overall-leaderboard {
                padding: 0;
                border-radius: 15px;
                overflow: hidden;
                background:
                    rgba(26,26,30,.96);
                box-shadow:
                    0 5px 20px rgba(0,0,0,.16);
            }

            .session-leaderboard-title,
            .overall-leaderboard-title {
                min-height: 52px;
                margin: 0 !important;
                padding: 12px 14px;
                cursor: pointer;
                user-select: none;
                -webkit-tap-highlight-color:
                    transparent;
            }

            .session-leaderboard-title:active,
            .overall-leaderboard-title:active {
                background:
                    rgba(255,255,255,.04);
            }

            .session-leaderboard-title h3,
            .overall-leaderboard-title h3 {
                display: flex;
                align-items: center;
                gap: 7px;
                font-size: .96rem;
            }

            .session-leaderboard-title h3::after,
            .overall-leaderboard-title h3::after {
                content: "⌄";
                display: inline-block;
                color: var(--muted);
                font-size: 1rem;
                transition:
                    transform .18s ease;
            }

            .session-leaderboard:not(.mobile-collapsed)
            .session-leaderboard-title h3::after,

            .overall-leaderboard:not(.mobile-collapsed)
            .overall-leaderboard-title h3::after {
                transform: rotate(180deg);
            }

            .session-leaderboard-session {
                font-size: 10px;
            }

            .session-end-button {
                min-height: 32px;
                padding: 5px 9px;
                border-radius: 8px;
                font-size: 10px;
            }


            /*
             * This is the important space saver:
             * collapsed leaderboard = basically one compact bar.
             */
            .session-leaderboard.mobile-collapsed
            #session-leaderboard-content,

            .overall-leaderboard.mobile-collapsed
            #overall-leaderboard-content {
                display: none;
            }


            #session-leaderboard-content,
            #overall-leaderboard-content {
                overflow-x: auto;
                padding: 0 10px 11px;
                -webkit-overflow-scrolling: touch;
            }

            .session-leaderboard-table,
            .overall-leaderboard-table {
                min-width: 600px;
                font-size: 12px;
            }

            .session-leaderboard-table th,
            .session-leaderboard-table td,
            .overall-leaderboard-table th,
            .overall-leaderboard-table td {
                padding: 8px 6px;
            }


            /*
             * Old mobile CSS hid leaderboard columns.
             * When expanded, we want the full information
             * available by horizontal scrolling.
             */
            .overall-leaderboard-table
            th:nth-child(4),
            .overall-leaderboard-table
            td:nth-child(4),

            .session-leaderboard-table
            th:nth-child(3),
            .session-leaderboard-table
            td:nth-child(3) {
                display: table-cell;
            }

            .overall-leaderboard-empty,
            .session-leaderboard-empty {
                padding: 8px 3px;
                font-size: .84rem;
            }


            /* ---------------- REPLAY CAPTURE ---------------- */

            .record-section {
                margin-top: 0;
                padding: 14px;
                border-radius: 16px;
            }

            .record-section .section-title {
                margin-bottom: 11px;
            }

            .record-buttons {
                grid-template-columns:
                    repeat(2, minmax(0, 1fr));
                gap: 8px;
                margin-top: 12px;
            }

            .record-button {
                min-height: 60px;
                padding: 10px 8px;
                border-radius: 12px;
                font-size: 1rem;
                font-weight: 750;
            }

            .record-button:last-child {
                grid-column: 1 / -1;
            }


            /* ---------------- LIBRARY ---------------- */

            .library {
                margin-top: 18px;
            }

            .library-header {
                gap: 3px;
            }

            .tools {
                gap: 8px;
            }

            .replay-grid {
                gap: 12px;
            }

            .replay-card {
                border-radius: 15px;
            }
        }


        /* =====================================================
           LEADERBOARD CLEANUP
        ===================================================== */

        .overall-leaderboard-title h3,
        .session-leaderboard-title h3 {
            text-align: center;
        }

        .overall-leaderboard-table th,
        .overall-leaderboard-table td,
        .session-leaderboard-table th,
        .session-leaderboard-table td {
            text-align: center !important;
        }

        .overall-leaderboard-rank,
        .session-leaderboard-rank {
            text-align: center !important;
        }

        .overall-leaderboard-player,
        .session-leaderboard-player {
            text-align: center !important;
        }

        .overall-leaderboard-record,
        .session-leaderboard-record,
        .overall-leaderboard-winrate,
        .session-leaderboard-winrate,
        .overall-leaderboard-streak,
        .session-leaderboard-streak {
            text-align: center !important;
        }


        /* =====================================================
           MOBILE LEADERBOARD BUTTON
        ===================================================== */

        .mobile-leaderboard-open {
            display: none;
        }

        .mobile-leaderboard-overlay {
            display: none;
        }


        @media (max-width: 700px) {

            /*
             * Header button sits level with "Pool Replay".
             */
            .header {
                position: relative;
                padding-right: 54px;
            }

            .mobile-leaderboard-open {
                position: absolute;
                top: -2px;
                right: 2px;

                display: flex;
                align-items: center;
                justify-content: center;

                width: 44px;
                height: 44px;
                padding: 0;

                border: 1px solid
                    rgba(255,255,255,.09);

                border-radius: 13px;

                background:
                    rgba(255,255,255,.055);

                color: white;
                cursor: pointer;

                -webkit-tap-highlight-color:
                    transparent;
            }

            .mobile-leaderboard-open:active {
                transform: scale(.96);
                background:
                    rgba(255,255,255,.10);
            }

            .mobile-leaderboard-open svg {
                width: 23px;
                height: 23px;
                fill: currentColor;
            }


            /*
             * The original leaderboard sidebar is unnecessary
             * on mobile now. This means Capture Replay follows
             * directly after Game.
             */
            .dashboard-leaderboards {
                display: none !important;
            }


            /* ---------------- OVERLAY ---------------- */

            .mobile-leaderboard-overlay {
                position: fixed;
                inset: 0;
                z-index: 12000;

                display: block;
                overflow-y: auto;

                background:
                    radial-gradient(
                        circle at top,
                        rgba(118,87,255,.14),
                        transparent 360px
                    ),
                    #0d0d0f;

                color: var(--text);

                overscroll-behavior:
                    contain;

                -webkit-overflow-scrolling:
                    touch;
            }

            .mobile-leaderboard-overlay.hidden {
                display: none;
            }


            /*
             * Sticky means the Session/Overall selector and
             * close button remain on screen while leaderboard
             * results scroll underneath them.
             */
            .mobile-leaderboard-toolbar {
                position: sticky;
                top: 0;
                z-index: 5;

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

                min-height: 68px;
                padding:
                    calc(10px + env(safe-area-inset-top))
                    14px
                    10px;

                border-bottom:
                    1px solid rgba(255,255,255,.07);

                background:
                    rgba(13,13,15,.88);

                backdrop-filter:
                    blur(18px);

                -webkit-backdrop-filter:
                    blur(18px);
            }


            /* ---------------- TABS ---------------- */

            .mobile-leaderboard-tabs {
                display: flex;
                align-items: center;
                gap: 4px;

                padding: 4px;

                border-radius: 12px;

                background:
                    rgba(255,255,255,.06);
            }

            .mobile-leaderboard-tab {
                min-height: 36px;
                padding: 0 13px;

                border-radius: 9px;

                background: transparent;
                color: var(--muted);

                font-size: 13px;
                font-weight: 750;

                cursor: pointer;

                transition:
                    background .15s ease,
                    color .15s ease;
            }

            .mobile-leaderboard-tab.active {
                background:
                    var(--surface-3);

                color: white;

                box-shadow:
                    0 2px 8px rgba(0,0,0,.22);
            }


            /* ---------------- CLOSE ---------------- */

            .mobile-leaderboard-close {
                flex: 0 0 auto;

                display: flex;
                align-items: center;
                justify-content: center;

                width: 40px;
                height: 40px;
                min-height: 40px;
                padding: 0;

                border-radius: 12px;

                background:
                    rgba(255,255,255,.07);

                color: white;

                font-size: 27px;
                font-weight: 300;
                line-height: 1;

                cursor: pointer;
            }

            .mobile-leaderboard-close:active {
                transform: scale(.95);
            }


            /* ---------------- BODY ---------------- */

            .mobile-leaderboard-body {
                width: 100%;
                max-width: 560px;

                margin: 0 auto;

                padding:
                    24px
                    12px
                    calc(
                        36px +
                        env(safe-area-inset-bottom)
                    );
            }

            .mobile-leaderboard-heading {
                padding: 4px 5px 20px;
                text-align: center;
            }

            .mobile-leaderboard-kicker {
                margin-bottom: 6px;

                color: var(--accent-hover);

                font-size: 11px;
                font-weight: 800;

                text-transform: uppercase;
                letter-spacing: .09em;
            }

            .mobile-leaderboard-heading h2 {
                margin: 0;

                font-size: 1.6rem;
                letter-spacing: -.025em;
            }

            .mobile-leaderboard-subtitle {
                min-height: 19px;

                margin-top: 7px;

                color: var(--muted);
                font-size: 12px;
            }


            /* ---------------- TABLE CARD ---------------- */

            .mobile-leaderboard-content {
                overflow: hidden;

                border:
                    1px solid rgba(255,255,255,.07);

                border-radius: 17px;

                background:
                    rgba(23,23,26,.92);

                box-shadow:
                    0 14px 40px rgba(0,0,0,.22);
            }

            .mobile-leaderboard-content
            .session-leaderboard-empty,

            .mobile-leaderboard-content
            .overall-leaderboard-empty {
                padding: 28px 16px;
                text-align: center;
            }

            /*
             * Let the table scroll sideways only if it truly
             * needs to, while keeping the overlay itself
             * vertically scrollable.
             */
            .mobile-leaderboard-content {
                overflow-x: auto;

                -webkit-overflow-scrolling:
                    touch;
            }

            .mobile-leaderboard-content
            .session-leaderboard-table,

            .mobile-leaderboard-content
            .overall-leaderboard-table {
                width: 100%;
                min-width: 560px;

                border-collapse: collapse;

                font-size: 12px;
            }

            .mobile-leaderboard-content
            th {
                padding: 12px 8px;

                color: var(--muted);

                font-size: 10px;
                font-weight: 750;

                text-transform: uppercase;
                letter-spacing: .04em;

                white-space: nowrap;
            }

            .mobile-leaderboard-content
            td {
                padding: 13px 8px;

                border-top:
                    1px solid rgba(255,255,255,.06);

                white-space: nowrap;
            }

            .mobile-leaderboard-content
            th,

            .mobile-leaderboard-content
            td {
                text-align:
                    center !important;
            }

            .mobile-leaderboard-content
            .player-profile-player {
                color: #fff;
                font-weight: 750;
            }

            .mobile-leaderboard-content
            .player-profile-player:active {
                opacity: .65;
            }


            /*
             * Undo the old column-hiding mobile rules.
             * In the overlay we want every leaderboard stat.
             */
            .mobile-leaderboard-content
            .overall-leaderboard-table
            th:nth-child(4),

            .mobile-leaderboard-content
            .overall-leaderboard-table
            td:nth-child(4),

            .mobile-leaderboard-content
            .session-leaderboard-table
            th:nth-child(3),

            .mobile-leaderboard-content
            .session-leaderboard-table
            td:nth-child(3) {
                display: table-cell !important;
            }
        }


        @media (max-width: 700px) {

            .mobile-leaderboard-content {
                overflow: hidden;
            }

            .mobile-summary-table {
                width: 100%;
                min-width: 0;
                table-layout: fixed;
                border-collapse: collapse;
                font-size: 12px;
            }

            .mobile-summary-table th,
            .mobile-summary-table td {
                padding: 12px 4px;
                text-align: center;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .mobile-summary-table th {
                color: var(--muted);
                font-size: 9px;
                font-weight: 800;
                text-transform: uppercase;
                letter-spacing: .035em;
            }

            .mobile-summary-table td {
                border-top:
                    1px solid rgba(255,255,255,.06);
            }

            .mobile-summary-table th:nth-child(1),
            .mobile-summary-table td:nth-child(1) {
                width: 9%;
            }

            .mobile-summary-table th:nth-child(2),
            .mobile-summary-table td:nth-child(2) {
                width: 31%;
            }

            .mobile-summary-table th:nth-child(3),
            .mobile-summary-table td:nth-child(3) {
                width: 20%;
            }

            .mobile-summary-table th:nth-child(4),
            .mobile-summary-table td:nth-child(4) {
                width: 19%;
            }

            .mobile-summary-table th:nth-child(5),
            .mobile-summary-table td:nth-child(5) {
                width: 21%;
            }

            .mobile-leaderboard-player {
                max-width: 100%;
                padding: 0;
                background: none;
                color: white;
                font-weight: 800;
                cursor: pointer;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .mobile-leaderboard-player:active {
                opacity: .6;
            }

            .mobile-leaderboard-rank {
                color: var(--muted);
                font-weight: 700;
            }

            .mobile-leaderboard-empty {
                padding: 30px 16px;
                text-align: center;
                color: var(--muted);
                font-size: .9rem;
            }
        }



        /* =========================================================
           FINAL GAME UI
           Authoritative styling for current game interface.
        ========================================================= */

        .game-section {
            margin-bottom: 24px;
            padding: 22px;
            border: 1px solid var(--border);
            border-radius: 20px;
            background: rgba(23,23,26,.92);
            backdrop-filter: blur(10px);
        }

        .game-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 18px;
        }

        .game-header .section-title {
            margin: 0;
        }

        .game-status {
            flex: 0 0 auto;
        }


        /* ---------------- EMPTY GAME ---------------- */

        .game-empty {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
        }

        .game-empty-text {
            color: var(--muted);
            font-size: .92rem;
        }


        /* ---------------- COMMON BUTTONS ---------------- */

        .game-button {
            min-height: 46px;
            padding: 0 18px;
            border-radius: 12px;
            background: var(--accent);
            color: #fff;
            font-weight: 750;
            cursor: pointer;
        }

        .game-button.secondary {
            background: var(--surface-3);
            color: var(--text);
        }


        /* ---------------- GAME TYPE ---------------- */

        .game-type-buttons {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 10px;
            width: 100%;
            margin-bottom: 20px;
        }

        .game-type-button {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 52px;
            padding: 0 16px;
            border: 1px solid var(--border);
            border-radius: 13px;
            background: var(--surface-2);
            color: var(--muted);
            font-size: 1rem;
            font-weight: 800;
            text-align: center;
            cursor: pointer;
        }

        .game-type-button.active {
            border-color: var(--accent);
            background: rgba(118,87,255,.16);
            color: #fff;
        }


        /* ---------------- ROUND SELECTOR ---------------- */

        .game-round-options {
            margin-bottom: 20px;
        }

        .game-round-options > .game-team-label {
            margin-bottom: 10px;
            text-align: center;
        }

        .game-round-buttons {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 8px;
        }

        .game-round-button {
            min-height: 40px;
            padding: 0 14px;
            border: 1px solid var(--border);
            border-radius: 10px;
            background: var(--surface-2);
            color: var(--muted);
            font-weight: 700;
            cursor: pointer;
        }

        .game-round-button.active {
            border-color: var(--accent);
            background: rgba(118,87,255,.16);
            color: #fff;
        }

        #selected-rounds-status {
            margin-top: 10px;
            text-align: center;
        }


        /* ---------------- TEAM ENTRY ---------------- */

        .game-teams {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 12px;
        }

        .game-team-form {
            min-width: 0;
            padding: 15px;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: var(--surface-2);
        }

        .game-team-form > .game-team-label {
            margin-bottom: 10px;
            text-align: center;
        }

        .game-player-input {
            display: block;
            width: 100%;
            height: 46px;
            margin-bottom: 8px;
            padding: 0 13px;
            border: 1px solid var(--border);
            border-radius: 11px;
            background: var(--surface);
            color: #fff;
            text-align: center;
        }

        .game-player-input:focus {
            border-color: var(--accent);
        }

        .game-form-actions {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 16px;
        }

        .game-form-actions .game-button {
            width: 100%;
        }


        /* ---------------- ACTIVE MATCH ---------------- */

        .game-active {
            margin-top: 0;
            padding: 18px;
            border: 1px solid var(--border);
            border-radius: 16px;
            background: var(--surface-2);
        }

        .game-matchup {
            display: grid;
            grid-template-columns:
                minmax(0, 1fr) auto minmax(0, 1fr);
            align-items: center;
            gap: 14px;
            text-align: center;
        }

        .game-matchup > div {
            min-width: 0;
        }

        .game-team {
            color: var(--text);
            font-size: 1.08rem;
            font-weight: 800;
            line-height: 1.35;
            overflow-wrap: anywhere;
        }

        .game-vs {
            color: var(--muted);
            font-size: .72rem;
            font-weight: 850;
            letter-spacing: .12em;
        }

        .game-type {
            margin-top: 10px;
            text-align: center;
            color: var(--muted);
            font-size: .78rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .06em;
        }

        .game-score-status {
            margin-top: 8px;
            text-align: center;
            color: var(--muted);
            font-size: .82rem;
            font-weight: 650;
        }


        /* ---------------- SCORE ---------------- */

        .game-score {
            display: grid;
            grid-template-columns:
                minmax(0, 1fr) auto minmax(0, 1fr);
            align-items: stretch;
            gap: 10px;
            margin-top: 14px;
        }

        .game-score-button {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            min-width: 0;
            min-height: 108px;
            padding: 14px 10px;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: var(--surface);
            color: var(--text);
            cursor: pointer;
        }

        .game-score-player {
            width: 100%;
            color: var(--muted);
            font-size: .82rem;
            font-weight: 700;
            line-height: 1.25;
            text-align: center;
            overflow-wrap: anywhere;
        }

        .game-score-number {
            font-size: 2.5rem;
            font-weight: 850;
            line-height: 1;
        }

        .game-score-divider {
            align-self: center;
            color: var(--muted);
            font-size: 1.4rem;
            font-weight: 700;
        }

        .game-actions {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 14px;
        }

        .game-actions .game-button {
            width: 100%;
        }



        /* =========================================================
           FINAL GAME UI — MOBILE
        ========================================================= */

        @media (max-width: 700px) {

            .game-section {
                padding: 14px;
                border-radius: 16px;
            }

            .game-header {
                align-items: center;
                margin-bottom: 14px;
            }


            /* Empty state */

            .game-empty {
                display: grid;
                grid-template-columns: 1fr;
                gap: 10px;
                text-align: center;
            }

            .game-empty-text {
                padding: 2px 0;
            }

            .game-empty .game-button {
                width: 100%;
            }


            /* 1v1 / 2v2 */

            .game-type-buttons {
                gap: 8px;
                margin-bottom: 16px;
            }

            .game-type-button {
                min-height: 48px;
                padding: 0 10px;
                border-radius: 11px;
                font-size: .95rem;
                text-align: center;
                justify-content: center;
                align-items: center;
            }


            /* Rounds */

            .game-round-options {
                margin-bottom: 16px;
            }

            .game-round-buttons {
                display: grid;
                grid-template-columns:
                    repeat(3, minmax(0, 1fr));
                gap: 7px;
            }

            .game-round-button {
                width: 100%;
                min-height: 42px;
                padding: 0 6px;
                font-size: .82rem;
            }


            /* Player entry */

            .game-teams {
                grid-template-columns: 1fr;
                gap: 10px;
            }

            .game-team-form {
                padding: 13px;
            }

            .game-player-input {
                height: 46px;
                text-align: left;
            }


            /* Active matchup
               Team 1
                 VS
               Team 2
            */

            .game-active {
                padding: 14px;
            }

            .game-matchup {
                display: flex;
                flex-direction: column;
                align-items: stretch;
                gap: 5px;
                width: 100%;
            }

            .game-matchup > div:first-child {
                order: 1;
            }

            .game-matchup > .game-vs {
                order: 2;
            }

            .game-matchup > div:last-child {
                order: 3;
            }

            .game-team {
                width: 100%;
                padding: 7px 8px;
                font-size: 1.05rem;
                line-height: 1.3;
                text-align: center;
            }

            .game-vs {
                width: 100%;
                padding: 1px 0;
                text-align: center;
                font-size: .68rem;
            }

            .game-type {
                margin-top: 10px;
                text-align: center;
            }

            .game-score-status {
                margin-top: 5px;
            }


            /* Score remains side-by-side */

            .game-score {
                grid-template-columns:
                    minmax(0, 1fr)
                    18px
                    minmax(0, 1fr);
                gap: 6px;
                margin-top: 12px;
            }

            .game-score-button {
                min-height: 104px;
                padding: 11px 6px;
                border-radius: 12px;
            }

            .game-score-player {
                font-size: .76rem;
            }

            .game-score-number {
                font-size: 2.55rem;
            }

            .game-score-divider {
                font-size: 1rem;
                text-align: center;
            }


            /* Actions */

            .game-actions,
            .game-form-actions {
                display: grid;
                grid-template-columns:
                    repeat(2, minmax(0, 1fr));
                gap: 8px;
            }

            .game-actions .game-button,
            .game-form-actions .game-button {
                width: 100%;
                min-width: 0;
                padding: 0 8px;
                font-size: .86rem;
            }

        }


        @media (max-width: 380px) {

            .game-round-buttons {
                grid-template-columns:
                    repeat(2, minmax(0, 1fr));
            }

            .game-actions,
            .game-form-actions {
                grid-template-columns: 1fr;
            }
        }



        /* =========================================================
           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);
            }
        }



        /* =========================================================
           TOURNAMENT UI — FINAL
        ========================================================= */

        #game-empty {
            flex-wrap: wrap;
        }

        #game-empty #start-game-button,
        #game-empty #tournament-button {
            min-width: 145px;
        }


        .tournament-panel {
            margin-top: 20px;
            padding: 18px;
            border: 1px solid var(--border);
            border-radius: 16px;
            background: var(--surface-2);
        }

        .tournament-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            margin-bottom: 16px;
        }

        .tournament-eyebrow {
            margin-bottom: 3px;
            color: var(--muted);
            font-size: .68rem;
            font-weight: 850;
            letter-spacing: .1em;
            text-transform: uppercase;
        }

        .tournament-title {
            margin: 0;
            font-size: 1.2rem;
        }

        .tournament-meta {
            color: var(--muted);
            font-size: .76rem;
            text-align: right;
        }


        /* -----------------------------------------
           CHAMPION
        ----------------------------------------- */

        .tournament-champion {
            margin-bottom: 16px;
            padding: 18px;
            border: 1px solid rgba(118,87,255,.35);
            border-radius: 14px;
            background:
                linear-gradient(
                    135deg,
                    rgba(118,87,255,.18),
                    rgba(118,87,255,.05)
                );
            text-align: center;
        }

        .tournament-champion-icon {
            margin-bottom: 5px;
            font-size: 1.8rem;
        }

        .tournament-champion-label {
            margin-bottom: 5px;
            color: var(--muted);
            font-size: .68rem;
            font-weight: 850;
            letter-spacing: .1em;
            text-transform: uppercase;
        }

        .tournament-champion-name {
            font-size: 1.35rem;
            font-weight: 850;
        }


        /* -----------------------------------------
           BRACKET
        ----------------------------------------- */

        .tournament-bracket {
            display: grid;
            grid-auto-flow: column;
            grid-auto-columns: minmax(210px, 1fr);
            gap: 14px;

            width: 100%;
            overflow-x: auto;
            padding-bottom: 6px;
        }

        .tournament-round {
            display: flex;
            flex-direction: column;
            min-width: 0;
            gap: 10px;
        }

        .tournament-round-title {
            min-height: 25px;
            color: var(--muted);
            font-size: .72rem;
            font-weight: 850;
            letter-spacing: .08em;
            text-align: center;
            text-transform: uppercase;
        }

        .tournament-round-matches {
            display: flex;
            flex: 1;
            flex-direction: column;
            justify-content: space-around;
            gap: 12px;
        }


        .tournament-match {
            padding: 10px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--surface);
        }

        .tournament-match.ready {
            border-color: rgba(118,87,255,.45);
        }

        .tournament-match.active {
            border-color: rgba(255,190,70,.4);
        }

        .tournament-match.completed {
            opacity: .88;
        }


        .tournament-match-row {
            display: grid;
            grid-template-columns:
                minmax(0, 1fr) auto;
            align-items: center;
            gap: 8px;

            min-height: 34px;
            padding: 6px 8px;
            border-radius: 8px;
        }

        .tournament-match-row + .tournament-match-row {
            margin-top: 4px;
        }

        .tournament-match-row.winner {
            background: rgba(85,216,138,.10);
        }

        .tournament-match-entry {
            min-width: 0;
            overflow: hidden;
            font-size: .8rem;
            font-weight: 750;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .tournament-match-row.winner
        .tournament-match-entry {
            color: #72df99;
        }

        .tournament-match-score {
            min-width: 20px;
            font-size: .9rem;
            font-weight: 850;
            text-align: right;
        }

        .tournament-match-empty {
            color: var(--muted);
            font-weight: 500;
        }


        .tournament-match-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--border);
        }

        .tournament-match-status {
            color: var(--muted);
            font-size: .68rem;
            font-weight: 700;
        }

        .tournament-play-button {
            min-height: 34px;
            padding: 0 12px;
            border-radius: 8px;
            background: var(--accent);
            color: #fff;
            font-size: .75rem;
            font-weight: 800;
            cursor: pointer;
        }


        /* -----------------------------------------
           SETUP MODAL
        ----------------------------------------- */

        .tournament-setup-modal {
            width: min(100%, 580px);
            max-height: calc(100vh - 30px);
            overflow-y: auto;
        }

        .tournament-setup-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 18px;
        }

        .tournament-setup-header h3 {
            margin: 0;
        }

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


        .tournament-setting {
            margin-top: 18px;
        }

        .tournament-setting-label {
            margin-bottom: 8px;
            color: var(--muted);
            font-size: .7rem;
            font-weight: 850;
            letter-spacing: .08em;
            text-transform: uppercase;
        }


        .tournament-type-buttons {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 8px;
        }

        .tournament-type-button {
            min-height: 46px;
            border: 1px solid var(--border);
            border-radius: 11px;
            background: var(--surface-3);
            color: var(--muted);
            font-weight: 800;
            cursor: pointer;
        }

        .tournament-type-button.active {
            border-color: var(--accent);
            background: rgba(118,87,255,.16);
            color: #fff;
        }


        .tournament-round-select {
            width: 100%;
            height: 46px;
            padding: 0 12px;
            border: 1px solid var(--border);
            border-radius: 11px;
            background: var(--surface-3);
            color: #fff;
        }


        .tournament-entries {
            display: flex;
            flex-direction: column;
            gap: 9px;
        }

        .tournament-entry {
            position: relative;
            padding: 12px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--surface-3);
        }

        .tournament-entry-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 8px;
        }

        .tournament-entry-number {
            color: var(--muted);
            font-size: .7rem;
            font-weight: 850;
            text-transform: uppercase;
        }

        .tournament-entry-remove {
            padding: 4px 7px;
            border-radius: 7px;
            background: transparent;
            color: #ff7777;
            font-size: .72rem;
            font-weight: 750;
            cursor: pointer;
        }


        .tournament-entry-inputs {
            display: grid;
            grid-template-columns:
                repeat(2, minmax(0, 1fr));
            gap: 8px;
        }

        .tournament-entry-inputs.single {
            grid-template-columns: 1fr;
        }

        .tournament-player-input-wrap {
            position: relative;
            min-width: 0;
        }

        .tournament-player-input {
            width: 100%;
            height: 44px;
            padding: 0 12px;
            border: 1px solid var(--border);
            border-radius: 10px;
            outline: none;
            background: var(--surface);
            color: #fff;
        }

        .tournament-player-input:focus {
            border-color: var(--accent);
        }


        .tournament-player-suggestions {
            position: absolute;
            top: calc(100% + 3px);
            left: 0;
            right: 0;
            z-index: 100;

            max-height: 180px;
            overflow-y: auto;

            border: 1px solid var(--border);
            border-radius: 10px;
            background: #17171a;

            box-shadow:
                0 12px 30px rgba(0,0,0,.4);
        }

        .tournament-player-suggestions.open-up {
            top: auto;
            bottom: calc(100% + 3px);
        }

        .tournament-player-suggestion {
            padding: 10px 12px;
            font-size: .85rem;
            cursor: pointer;
        }

        .tournament-player-suggestion:hover {
            background: var(--surface-3);
        }


        .tournament-setup-actions {
            display: grid;
            grid-template-columns:
                1fr 1fr;
            gap: 9px;
            margin-top: 18px;
        }

        .tournament-setup-action {
            min-height: 46px;
            border-radius: 11px;
            font-weight: 800;
            cursor: pointer;
        }

        .tournament-add-entry {
            background: var(--surface-3);
            color: #fff;
        }

        .tournament-create {
            background: var(--accent);
            color: #fff;
        }

        .tournament-setup-error {
            margin-top: 10px;
            color: #ff7777;
            font-size: .82rem;
        }


        /* =========================================================
           TOURNAMENT MOBILE
        ========================================================= */

        @media (max-width: 700px) {

            #game-empty {
                display: grid;
                grid-template-columns:
                    repeat(2, minmax(0, 1fr));
                gap: 8px;
            }

            #game-empty .game-empty-text {
                grid-column: 1 / -1;
            }

            #game-empty #start-game-button,
            #game-empty #tournament-button {
                min-width: 0;
                width: 100%;
                padding: 0 8px;
            }


            .tournament-panel {
                margin-top: 16px;
                padding: 14px;
                border-radius: 14px;
            }

            .tournament-panel-header {
                align-items: flex-start;
                margin-bottom: 14px;
            }


            /*
             * Mobile brackets are stacked vertically.
             * No sideways scrolling needed.
             */
            .tournament-bracket {
                display: block;
                overflow-x: visible;
                padding: 0;
            }

            .tournament-round + .tournament-round {
                margin-top: 18px;
                padding-top: 16px;
                border-top: 1px solid var(--border);
            }

            .tournament-round-title {
                margin-bottom: 8px;
            }

            .tournament-round-matches {
                gap: 8px;
            }

            .tournament-match {
                padding: 9px;
            }

            .tournament-match-entry {
                font-size: .79rem;
            }

            .tournament-play-button {
                min-height: 36px;
            }


            .tournament-setup-modal {
                width: 100%;
                max-height: calc(100dvh - 20px);
                padding: 16px;
                border-radius: 18px;
            }

            .tournament-entry {
                padding: 10px;
            }

            .tournament-entry-inputs {
                grid-template-columns: 1fr;
            }

            .tournament-setup-actions {
                grid-template-columns: 1fr;
            }

            .tournament-setup-action {
                min-height: 48px;
            }
        }



        /* =========================================================
           TOURNAMENT CANCEL
        ========================================================= */

        .tournament-panel-actions {
            display: flex;
            align-items: flex-end;
            flex-direction: column;
            gap: 8px;
        }

        .tournament-cancel-button {
            min-height: 36px;
            padding: 0 12px;

            border: 1px solid rgba(255,95,95,.20);
            border-radius: 9px;

            background: rgba(182,61,61,.16);
            color: #ff8585;

            font-size: .72rem;
            font-weight: 800;

            cursor: pointer;
            touch-action: manipulation;
        }

        .tournament-cancel-button:hover {
            background: rgba(182,61,61,.25);
        }


        @media (max-width: 700px) {

            .tournament-panel-header {
                align-items: flex-start;
            }

            .tournament-panel-actions {
                align-items: flex-end;
                flex: 0 0 auto;
            }

            .tournament-cancel-button {
                min-height: 38px;
                padding: 0 10px;
                font-size: .68rem;
            }
        }




        /* =========================================================
           END SESSION BUTTON — AUTHORITATIVE
        ========================================================= */

        #end-session-button {
            display: block;
            width: 100%;
            min-height: 50px;
            margin: 14px 0 22px;
            padding: 12px 16px;

            border: 1px solid rgba(255,95,95,.24);
            border-radius: 12px;

            background: #b63d3d;
            color: #fff;

            font: inherit;
            font-size: .95rem;
            font-weight: 800;

            cursor: pointer;
            pointer-events: auto;
            touch-action: manipulation;

            visibility: visible;
            opacity: 1;

            position: relative;
            z-index: 20;
        }

        #end-session-button.hidden {
            display: none !important;
        }

        #end-session-button:hover:not(:disabled) {
            background: #c44747;
        }

        #end-session-button:active:not(:disabled) {
            transform: scale(.985);
        }

        #end-session-button:disabled {
            opacity: .5;
            cursor: wait;
        }

        @media (max-width: 700px) {

            #end-session-button {
                min-height: 48px;
                margin: 12px 0 20px;
                border-radius: 11px;
            }

            #end-session-button.hidden {
                display: none !important;
            }
        }

/* =========================================================
   REFACTOR — CONSOLIDATED PLAY STATE / SESSION HISTORY
========================================================= */

.play-state-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: -6px 0 14px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.play-state-banner-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #6f6f78;
}

.play-state-banner.active .play-state-banner-dot { background: #62d889; }
.play-state-banner.tournament .play-state-banner-dot { background: var(--accent); }

.session-history-button {
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.session-history-button:hover { background: rgba(255,255,255,.10); }

.session-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.session-history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: #fff;
    text-align: left;
    cursor: pointer;
}

.session-history-item span { color: var(--muted); font-size: .75rem; }
.session-history-item strong { font-size: .9rem; }

.session-history-table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
    font-size: .82rem;
}

.session-history-table th,
.session-history-table td {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
    text-align: left;
}

.undo-round-context {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 650;
}

@media (max-width: 700px) {
    .play-state-banner { margin-top: -2px; font-size: .72rem; }
    .session-history-button { min-height: 32px; }
}
