
        /* #########################################################
           STYLES.CSS — BGTime
           #########################################################

           Este archivo contiene TODOS los estilos de la app.
           Esta organizado en 11 secciones. Para ir a una seccion,
           busca el numero con Ctrl+F, por ejemplo: "5. PANTALLA"

           INDICE
           -------------------------------------------------------
            1. VARIABLES & RESET      Colores, fuentes, tema oscuro
            2. LAYOUT GLOBAL          body, .container, .top-bar
            3. COMPONENTES            Botones, inputs, modales
            4. PANTALLA: SETUP        Configurar partida
            5. PANTALLA: SCORING      Introducir puntos
            6. PANTALLA: TIMER        Temporizador fullscreen
            7. PANTALLA: RESULTS      Resultados finales
            8. PANTALLA: HISTORY      Historial de partidas
            9. PANTALLA: STATS        Estadisticas
           10. PANTALLA: SETTINGS     Ajustes (perfil, amigos...)
           11. UTILIDADES & MISC      Footer y selectores especiales
           ------------------------------------------------------- */

        /* =========================================================
           1. VARIABLES & RESET
           ========================================================= */

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            touch-action: manipulation;
        }

        :root {
            --bg-gradient-start: #3a28c8; /* azul brillante (derivado del favicon) */
            --bg-gradient-mid: #3a28c8;   /* rgb(36,12,121) — azul profundo del favicon */
            --bg-gradient-end: #220855;   /* rgb(33,5,87) — azul más oscuro del favicon */
            --container-bg: #ffffff;
            --text-primary: #333333;
            --text-secondary: #666666;
            --primary-color: #3a28c8;
            --secondary-color: #764ba2;
            --border-color: #ddd;
            --input-bg: #ffffff;
            --input-border: #ddd;
            --table-header-bg: #667eea;
            --table-header-text: #ffffff;
            --table-row-bg: #ffffff;
            --table-row-alt: #f8f9fa;
            --table-total-bg: #f0f0f0;
            --button-bg: #667eea;
            --button-hover: #5568d3;
            --button-secondary: #95a5a6;
            --button-secondary-hover: #7f8c8d;
            --shadow-color: rgba(0, 0, 0, 0.2);
            --info-box-bg: #e3f2fd;
            --info-box-border: #2196f3;
            /* Gradientes de botones */
            --btn-primary-gradient: linear-gradient(135deg, #3a28c8 0%, #320e79 100%);
            --btn-primary-gradient-hover: linear-gradient(135deg, #5a6fd6 0%, #6a3d94 100%);
            --btn-green-gradient: linear-gradient(135deg, #2ecc71 0%, #1abc9c 100%);
            --btn-green-gradient-hover: linear-gradient(135deg, #27ae60 0%, #16a085 100%);
            --btn-red-gradient: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
            --btn-secondary-gradient: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
            --logo-cutout: #ffffff;
        }



        /* =========================================================
           2. LAYOUT GLOBAL
           body  .container  h1/h2  .top-bar  .screen  transiciones
           ========================================================= */

        .top-bar {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 40px;
            padding: 12px 0 8px 0;
        }

        .top-bar-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 22px;
            padding: 8px;
            margin: 0;
            min-height: unset;
            color: rgba(255, 255, 255, 0.5);
            transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease;
            border-radius: 12px;
            -webkit-tap-highlight-color: transparent;
            line-height: 1;
        }

        .top-bar-btn:active {
            opacity: 0.6;
            transform: scale(0.92);
        }

        .top-bar-btn.btn-on {
            color: var(--primary-color);
            background: var(--container-bg);
            border-radius: 12px;
            padding: 8px 14px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.15);
            filter: none;
            opacity: 1;
        }

        #activeGameBtn.game-active {
            color: #f97316;
            animation: game-btn-pulse 1.8s ease-in-out infinite;
        }

        #activeGameBtn.btn-on {
            color: #f97316;
            background: var(--container-bg);
            box-shadow: 0 2px 10px rgba(0,0,0,0.15);
            animation: none;
        }

        #appToast {
            position: fixed;
            bottom: 80px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(30,30,30,0.92);
            color: #fff;
            padding: 10px 22px;
            border-radius: 20px;
            font-size: 0.9rem;
            pointer-events: none;
            z-index: 9999;
            opacity: 0;
            transition: opacity 0.25s;
            white-space: nowrap;
        }
        #appToast.toast-show { opacity: 1; }

        @keyframes game-btn-pulse {
            0%, 100% {
                filter: drop-shadow(0 0 6px rgba(249,115,22,0.9));
            }
            50% {
                filter: drop-shadow(0 0 1px rgba(249,115,22,0.2));
            }
        }

        .active-game-banner {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            font-weight: 700;
            color: #f97316;
            text-transform: uppercase;
            letter-spacing: 0.6px;
            text-align: center;
            animation: game-btn-pulse 1.8s ease-in-out infinite;
            margin-top: 20px;
        }
        .abandon-game-btn {
            background: none;
            border: none;
            color: #f97316;
            cursor: pointer;
            padding: 4px;
            min-height: unset;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
            background: linear-gradient(150deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
            min-height: 100vh;
            min-height: 100dvh;
            background-attachment: fixed;
            padding: 4px 10px 10px 10px;
            padding-top: max(4px, env(safe-area-inset-top));
            padding-bottom: max(10px, env(safe-area-inset-bottom));
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
            -webkit-text-size-adjust: 100%;
            transition: background 0.3s ease;
        }

        .container {
            max-width: 100%;
            margin: 0 auto;
            background: var(--container-bg);
            border-radius: 20px;
            padding: 20px 15px;
            box-shadow: 0 8px 32px var(--shadow-color), 0 1px 0 rgba(255,255,255,0.06) inset;
            transition: all 0.3s ease;
        }

        h1 {
            text-align: center;
            color: var(--primary-color);
            margin-bottom: 20px;
            font-size: 24px;
            font-weight: 800;
            letter-spacing: -0.3px;
        }

        h2 {
            color: var(--secondary-color);
            margin-bottom: 15px;
            font-size: 20px;
            font-weight: 700;
        }

        .screen {
            display: none;
            animation-duration: 0.32s;
            animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
            animation-fill-mode: both;
        }

        .screen.active {
            display: block;
        }

        /* Zoom + fade (avanzar) */
        @keyframes slideInRight {
            from { opacity: 0; transform: scale(0.96); }
            to   { opacity: 1; transform: scale(1); }
        }
        /* Zoom + fade inverso (retroceder) */
        @keyframes slideInLeft {
            from { opacity: 0; transform: scale(1.04); }
            to   { opacity: 1; transform: scale(1); }
        }

        .screen.slide-in-right  { animation-name: slideInRight; }
        .screen.slide-in-left   { animation-name: slideInLeft; }


        /* =========================================================
           3. COMPONENTES REUTILIZABLES
           Botones  Formularios  Tablas  Modales genericos
           ========================================================= */


        /* -- 3a. Formularios y campos -- */
        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: var(--text-primary);
        }

        input[type="text"],
        input[type="number"],
        textarea {
            width: 100%;
            padding: 12px;
            border: 1.5px solid var(--input-border);
            border-radius: 10px;
            font-size: 16px;
            transition: border-color 0.2s, box-shadow 0.2s;
            background: var(--input-bg);
            color: var(--text-primary);
            box-shadow: 0 1px 4px rgba(0,0,0,0.05) inset;
        }

        input[type="text"]:focus,
        input[type="number"]:focus,
        textarea:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
        }

        .checkbox-label {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
        }

        input[type="checkbox"] {
            width: 20px;
            height: 20px;
            cursor: pointer;
        }


        /* -- 3b. Botones -- */
        button {
            background: var(--btn-primary-gradient);
            color: white;
            border: none;
            padding: 14px 24px;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
            cursor: pointer;
            transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
            margin-right: 10px;
            margin-bottom: 10px;
            min-height: 48px;
            -webkit-tap-highlight-color: transparent;
            box-shadow: 0 3px 10px rgba(102,126,234,0.35);
        }

        button:active {
            opacity: 0.88;
            transform: scale(0.98);
            box-shadow: 0 1px 4px rgba(102,126,234,0.2);
        }

        button.secondary {
            background: var(--btn-secondary-gradient);
            box-shadow: 0 3px 10px rgba(0,0,0,0.15);
        }

        button.secondary:active {
            background: var(--btn-secondary-gradient);
        }

        .add-player-btn {
            background: var(--btn-green-gradient);
            margin-top: 10px;
            width: 100%;
            box-shadow: 0 3px 10px rgba(46,204,113,0.35);
        }

        .add-player-btn:active {
            background: var(--btn-green-gradient);
            opacity: 0.88;
        }

        .add-player-btn:disabled {
            background: var(--button-secondary);
            cursor: not-allowed;
            opacity: 0.7;
            transform: none;
        }

        .button-group {
            margin-top: 20px;
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .button-group button {
            flex: 1;
            min-width: 150px;
        }


        /* -- 3c. Cabeceras de ronda y contenedores -- */
        .round-header {
            text-align: center;
            margin-bottom: 20px;
            padding: 15px;
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            border-radius: 10px;
        }

        .round-header h2 {
            margin: 0;
            color: white;
        }

        .table-wrapper {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin-top: 20px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
        }

        .error {
            color: #e74c3c;
            font-size: 14px;
            margin-top: 5px;
        }

        .info-box {
            background: var(--info-box-bg);
            border-left: 4px solid var(--info-box-border);
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 12px;
            color: var(--text-primary);
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        }


        /* -- 3d. Order items (reordenar jugadores — usado en varias pantallas) -- */
        .order-container {
            margin: 20px 0;
        }

        .order-item {
            background: var(--container-bg);
            border: 1.5px solid var(--border-color);
            border-radius: 14px;
            padding: 12px 14px;
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.2s;
            box-shadow: 0 2px 8px rgba(0,0,0,0.07);
        }

        .order-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 18px rgba(0,0,0,0.12);
            border-color: var(--primary-color);
        }

        .order-number {
            background: var(--primary-color);
            color: white;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 15px;
            font-weight: bold;
            flex-shrink: 0;
        }

        .order-player-name {
            font-size: 16px;
            font-weight: 600;
            flex-grow: 1;
            color: var(--text-primary);
        }

        .order-controls {
            display: flex;
            flex-direction: row;
            gap: 6px;
        }

        .order-btn {
            background: var(--button-bg);
            color: white;
            border: none;
            width: 36px;
            height: 36px;
            min-height: unset;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            margin: 0;
        }

        .order-btn:active {
            background: var(--button-hover);
        }

        .order-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        .order-up-btn {
            width: 28px;
            height: 28px;
            min-height: unset;
            border-radius: 6px;
            border: 1px solid rgba(255,255,255,0.35);
            background: rgba(255,255,255,0.18);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            padding: 0;
            margin: 0;
            transition: background 0.15s;
        }
        .order-up-btn:active { background: rgba(255,255,255,0.35); }


        /* -- 3e. Modal de confirmacion (reset, etc.) -- */
        /* ── Modal confirmación reset ── */
        .confirm-modal-overlay {
            position: fixed;
            inset: 0;
            z-index: 2000;
            background: rgba(0,0,0,0.55);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        .confirm-modal-box {
            background: var(--container-bg);
            border-radius: 18px;
            padding: 28px 24px 20px;
            text-align: center;
            width: 100%;
            max-width: 320px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.35);
            animation: modalIn 0.18s ease;
        }
        @keyframes modalIn {
            from { transform: scale(0.88); opacity: 0; }
            to   { transform: scale(1);    opacity: 1; }
        }
        .confirm-modal-icon { font-size: 40px; margin-bottom: 10px; display:flex; align-items:center; justify-content:center; color: var(--primary-color); }
        .confirm-modal-title {
            font-size: 19px;
            font-weight: 700;
            color: var(--text-primary);
            margin: 0 0 8px;
        }
        .confirm-modal-desc {
            font-size: 14px;
            color: var(--text-secondary);
            margin: 0 0 22px;
        }
        .confirm-modal-actions {
            display: flex;
            gap: 10px;
        }
        .confirm-modal-cancel,
        .confirm-modal-ok {
            flex: 1;
            margin: 0;
            padding: 13px 0;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            min-height: 48px;
        }
        .confirm-modal-cancel {
            background: var(--btn-secondary-gradient);
            box-shadow: none;
        }
        .confirm-modal-cancel:active { opacity: 0.88; background: var(--btn-secondary-gradient); }
        .confirm-modal-ok {
            background: var(--btn-red-gradient);
            box-shadow: 0 3px 10px rgba(231,76,60,0.35);
        }
        .confirm-modal-ok:active { opacity: 0.88; background: var(--btn-red-gradient); }


        /* =========================================================
           4. PANTALLA: SETUP / BIENVENIDA
           ========================================================= */


        /* -- 4a. Biblioteca de juegos: cabecera -- */
        @keyframes titleEntrance {
            from { opacity: 0; transform: translateY(14px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .library-header {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px 0 12px;
            gap: 8px;
            animation: titleEntrance 0.5s cubic-bezier(0.34,1.2,0.64,1) both;
        }

        .app-logo-small {
            width: 52px;
            height: 52px;
            display: block;
            filter: drop-shadow(0 2px 6px rgba(102,126,234,0.3));
        }

        .library-title {
            font-size: 20px;
            font-weight: 800;
            letter-spacing: -0.3px;
            color: var(--primary-color);
            margin: 0;
        }

        /* -- 4b-bis. Biblioteca: lista de juegos -- */
        .library-game-item {
            background: var(--container-bg);
            border-radius: 18px;
            padding: 14px 16px;
            margin-bottom: 10px;
            border: 1.5px solid var(--border-color);
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s;
            box-shadow: 0 2px 10px rgba(0,0,0,0.06);
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            text-align: left;
            color: var(--text-primary);
            font-family: inherit;
            -webkit-tap-highlight-color: transparent;
        }
        .library-game-item:active {
            transform: scale(0.98);
            box-shadow: none;
        }
        .library-game-item-emoji {
            width: 42px;
            height: 42px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            flex-shrink: 0;
        }
        .library-game-item-name {
            font-weight: 700;
            font-size: 16px;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .library-subtitle {
            text-align: center;
            font-size: 14px;
            color: var(--text-secondary);
            margin: -8px 0 16px;
        }
        .library-game-item-add {
            border-style: dashed;
            border-color: var(--primary-color);
            background: rgba(102,126,234,0.05);
        }
        .library-game-item-add .library-game-item-emoji,
        .library-game-item-add .library-game-item-name {
            color: var(--primary-color);
        }


        /* -- 4b. Campos de nombre de jugadores -- */
        .player-input {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
        }

        .player-input input {
            flex: 1;
        }

        .player-input button {
            padding: 10px 15px;
            background: #ff4757;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 18px;
        }

        .player-input-row {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
            align-items: center;
        }

        .player-input-row .player-name {
            flex: 1;
        }


        /* -- 4c. Colores de jugadores -- */
        .player-color-btn {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            border: 3px solid rgba(255,255,255,0.6);
            cursor: pointer;
            flex-shrink: 0;
            box-shadow: 0 2px 6px rgba(0,0,0,0.25);
            transition: transform 0.15s;
            padding: 0;
            min-height: unset;
        }

        .player-color-btn[data-locked="1"] {
            cursor: default;
            pointer-events: none;
            opacity: 1;
            position: relative;
        }
        .player-color-btn[data-locked="1"]::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: rgba(255,255,255,0.15);
        }
        .player-color-btn:active {
            transform: scale(0.92);
            background: unset;
        }

        .color-palette-overlay {
            position: fixed;
            inset: 0;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(0,0,0,0.4);
        }

        .color-palette-popup {
            background: var(--container-bg);
            border-radius: 16px;
            padding: 16px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.35);
            display: grid;
            grid-template-columns: repeat(3, 64px);
            gap: 10px;
            width: fit-content;
        }

        .color-picker-delete-btn {
            grid-column: 1 / -1;
            background: rgba(255, 71, 87, 0.15);
            color: #ff4757;
            border: 1.5px solid #ff4757;
            border-radius: 10px;
            padding: 12px 16px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: background 0.2s, transform 0.1s;
            min-height: unset;
            margin: 0;
        }

        .color-picker-delete-btn:hover {
            background: rgba(255, 71, 87, 0.25);
            transform: translateY(-1px);
        }

        .color-picker-delete-btn:active {
            transform: scale(0.98);
        }

        .color-picker-separator {
            grid-column: 1 / -1;
            height: 1px;
            background: var(--border);
            margin: 4px 0;
        }

        .color-swatch {
            width: 64px;
            height: 64px;
            border-radius: 10px;
            cursor: pointer;
            border: 3px solid transparent;
            transition: transform 0.15s, border-color 0.15s;
        }

        .color-swatch:hover {
            transform: scale(1.06);
        }

        .color-swatch.selected {
            border-color: var(--text-primary);
        }

        .player-input-row .remove-player-btn {
            padding: 10px 15px;
            background: #ff4757;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 18px;
            min-width: 48px;
            min-height: 48px;
        }



        /* -- 4d. Jugadores seleccionados (pills) -- */
        /* Selected Players Pills Section */
        .selected-players-section {
            margin-bottom: 20px;
        }
        .selected-players-label {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 12px;
            display: block;
        }
        .selected-players-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            padding: 16px;
            background: var(--surface-secondary);
            border-radius: 14px;
            border: 1px solid var(--border-color);
            min-height: 60px;
            align-items: center;
        }
        .selected-players-container.empty {
            justify-content: center;
            color: var(--text-tertiary);
            font-size: 14px;
            font-style: italic;
        }
        .player-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 14px;
            font-weight: 600;
            color: white;
            box-shadow: 0 2px 8px rgba(0,0,0,0.15);
            position: relative;
            overflow: hidden;
            transition: transform 0.2s, box-shadow 0.2s;
            cursor: pointer;
            line-height: 1;
        }
        .player-pill:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        }
        .player-pill.connected {
            background: linear-gradient(135deg, var(--pill-color-1), var(--pill-color-2));
        }
        .player-pill.regular {
            background: var(--pill-color-1);
        }
        .player-pill.add-player {
            background: var(--bg-secondary);
            color: #10b981;
            border: 2px solid #10b981;
            box-shadow: 0 2px 8px rgba(16,185,129,0.2);
            padding: 5px 13px; /* Ajustado por el borde de 2px */
        }
        .player-pill.add-player:hover {
            box-shadow: 0 4px 12px rgba(16,185,129,0.3);
            background: rgba(16,185,129,0.1);
        }
        .player-pill.add-player.disabled {
            opacity: 0.4;
            cursor: not-allowed;
            border-color: var(--text-secondary);
            color: var(--text-secondary);
            box-shadow: none;
        }
        .player-pill.add-player.disabled:hover {
            box-shadow: none;
            background: var(--bg-secondary);
        }
        .player-pill-name {
            flex: 1;
            line-height: 1;
            display: flex;
            align-items: center;
        }
        .player-pill.pick-starter {
            background: var(--primary-color);
            color: #fff;
            box-shadow: 0 2px 8px rgba(102,126,234,0.35);
        }
        .player-pill.pick-starter:hover {
            filter: brightness(1.08);
            box-shadow: 0 4px 14px rgba(102,126,234,0.45);
        }
        .player-pill.pick-starter.animating {
            opacity: 0.5;
            cursor: not-allowed;
            pointer-events: none;
        }
        .player-pill.cycling {
            animation: pillCycle 0.05s ease;
        }
        @keyframes pillCycle {
            from { opacity: 0.3; transform: scale(0.82); }
            to   { opacity: 1;   transform: scale(1); }
        }

        /* Banner de jugador inicial aleatorio */
        #randomPlayerResult {
            margin-top: 12px;
            padding: 14px 16px;
            background: var(--surface-secondary);
            border-radius: 14px;
            border: 1px solid var(--border-color);
            text-align: center;
            animation: fadeInUp 0.25s ease;
        }
        .random-player-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 10px;
        }
        #randomPlayerPill {
            display: flex;
            justify-content: center;
        }
        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(6px); }
            to   { opacity: 1; transform: translateY(0); }
        }


        /* -- 4e. Chips de jugadores habituales -- */
        /* Chips en pantalla de jugadores */
        .frecuent-chips-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 0;
        }
        .frecuent-chip {
            background: var(--table-row-alt);
            border: 1.5px solid var(--primary-color);
            border-radius: 20px;
            padding: 6px 14px;
            font-size: 14px;
            color: var(--primary-color);
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
            -webkit-tap-highlight-color: transparent;
            min-height: unset;
            margin: 0;
        }
        .frecuent-chip:active {
            background: var(--primary-color);
            color: #fff;
            transform: scale(0.97);
        }
        .connected-chip {
            border: none;
            border-radius: 20px;
            padding: 6px 14px;
            font-size: 14px;
            font-weight: 700;
            color: #fff;
            cursor: pointer;
            transition: opacity 0.15s, transform 0.1s;
            -webkit-tap-highlight-color: transparent;
            min-height: unset;
            margin: 0;
            text-shadow: 0 1px 3px rgba(0,0,0,0.25);
            box-shadow: 0 2px 6px rgba(0,0,0,0.18);
        }
        .connected-chip:active {
            opacity: 0.8;
            transform: scale(0.97);
        }
        .frecuent-chips-section-label {
            width: 100%;
            font-size: 11px;
            font-weight: 700;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.6px;
            margin-bottom: 2px;
            margin-top: 4px;
        }


        /* -- 4f. Modales de biblioteca (bottom sheets) -- */
        .fav-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: var(--btn-primary-gradient);
            border: none;
            border-radius: 20px;
            padding: 7px 15px;
            font-size: 13px;
            font-weight: 700;
            color: #fff;
            cursor: pointer;
            transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
            -webkit-tap-highlight-color: transparent;
            min-height: unset;
            margin: 0;
            box-shadow: 0 2px 10px rgba(102,126,234,0.35);
            text-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }
        /* -- 4f2. scoringSetupScreen en modo bottom sheet (editar plantilla) -- */
        #scoringSetupScreen.sheet-mode {
            position: fixed;
            inset: 0;
            z-index: 2000;
            background: rgba(0,0,0,0.55);
            display: flex !important;
            flex-direction: column;
            justify-content: flex-end;
            padding: 0;
            overflow: hidden;
        }
        #scoringSetupScreen.sheet-mode .scoring-sheet-inner {
            background: var(--container-bg);
            border-radius: 20px 20px 0 0;
            padding: 28px 20px 40px;
            max-height: 88vh;
            overflow-y: auto;
            width: 100%;
            animation: sheetUp 0.25s cubic-bezier(0.34,1.2,0.64,1);
        }

        /* -- 4g. Modal biblioteca (bottom sheet) -- */
        #gameLibraryModal, #addGameSheet, #addPlayerModal {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 2000;
            background: rgba(0,0,0,0.55);
            align-items: flex-end;
            justify-content: center;
        }
        .add-player-sheet {
            background: var(--container-bg);
            border-radius: 20px 20px 0 0;
            width: 100%;
            max-width: 560px;
            padding: 28px 24px 44px;
            display: flex;
            flex-direction: column;
            gap: 14px;
            position: relative;
            animation: sheetUp 0.25s cubic-bezier(0.34,1.2,0.64,1);
            max-height: 75vh;
            overflow-y: auto;
        }
        .add-player-sheet-title {
            font-size: 18px;
            font-weight: 800;
            color: var(--text-primary);
            text-align: center;
            margin: 4px 0 0 0;
        }
        .add-player-input-row {
            display: flex;
            gap: 8px;
            width: 100%;
        }
        .add-player-input-row input {
            flex: 1;
            padding: 12px 14px;
            border-radius: 10px;
            border: 2px solid var(--border);
            background: var(--bg-secondary);
            color: var(--text-primary);
            font-size: 16px;
            font-family: 'Plus Jakarta Sans', sans-serif;
            min-width: 0;
        }
        .add-player-input-row button {
            padding: 0 18px;
            border-radius: 10px;
            background: var(--primary-color);
            color: #fff;
            font-weight: 700;
            font-size: 15px;
            border: none;
            cursor: pointer;
            white-space: nowrap;
            min-height: unset;
            height: 48px;
        }
        .add-player-modal-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        .game-library-sheet {
            background: var(--container-bg);
            border-radius: 20px 20px 0 0;
            width: 100%;
            max-width: 560px;
            padding: 32px 24px 44px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            position: relative;
            animation: sheetUp 0.25s cubic-bezier(0.34,1.2,0.64,1);
        }
        .game-library-sheet-close {
            position: absolute;
            top: 14px;
            right: 16px;
            background: var(--table-row-alt);
            border: none;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            min-height: unset;
            padding: 0;
            margin: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            cursor: pointer;
        }
        .game-library-sheet-close:active { opacity: 0.7; }
        .game-library-sheet-emoji {
            font-size: 72px;
            line-height: 1;
            margin-bottom: 4px;
        }
        .game-library-sheet-title {
            font-size: 22px;
            font-weight: 800;
            color: var(--text-primary);
            text-align: center;
            margin-bottom: 8px;
        }
        .game-library-sheet-actions {
            display: flex;
            gap: 10px;
            width: 100%;
            max-width: 320px;
            margin-top: 8px;
        }
        .game-library-sheet-actions button {
            flex: 1;
            margin: 0;
            padding: 14px 0;
            font-size: 16px;
            font-weight: 700;
        }
        .gl-modal-warning-text {
            font-size: 13px;
            color: var(--text-secondary);
            text-align: center;
            margin: 4px 0 0 0;
            max-width: 280px;
        }

        /* -- 4h-bis. Formulario añadir juego -- */
        .add-game-form {
            display: flex;
            gap: 10px;
            width: 100%;
            align-items: stretch;
        }
        .add-game-emoji-input {
            width: 56px;
            min-width: 56px;
            max-width: 56px;
            flex-shrink: 0;
            text-align: center;
            font-size: 24px;
            padding: 10px 4px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            background: var(--table-row-bg);
            color: var(--text-primary);
            box-sizing: border-box;
        }
        .add-game-name-input {
            flex: 1;
            padding: 10px 14px;
            border-radius: 10px;
            font-size: 16px;
            border: 2px solid var(--border-color);
            background: var(--table-row-bg);
            color: var(--text-primary);
        }



        /* -- 4h. Configuracion del modo de puntuacion -- */
        /* ── Scoring Setup rediseño ── */
        .scoring-type-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-bottom: 20px;
        }

        .scoring-type-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 18px 10px;
            border: 2px solid var(--border-color);
            border-radius: 16px;
            background: var(--table-row-bg);
            cursor: pointer;
            transition: all 0.18s ease;
            min-height: unset;
            color: var(--text-primary);
            font-family: inherit;
            -webkit-tap-highlight-color: transparent;
        }

        .scoring-type-card:active {
            transform: scale(0.97);
        }

        .scoring-type-card.active {
            border-color: var(--primary-color);
            background: linear-gradient(135deg, rgba(102,126,234,0.12) 0%, rgba(118,75,162,0.12) 100%);
            box-shadow: 0 0 0 3px rgba(102,126,234,0.18);
        }


        .stc-icon {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }

        .stc-label {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .stc-sub {
            font-size: 11px;
            color: var(--text-secondary);
            font-weight: 400;
            text-align: center;
        }

        .scoring-detail-panel {
            background: var(--table-row-alt);
            border-radius: 14px;
            padding: 16px;
            margin-bottom: 20px;
            animation: slideInRight 0.22s ease both;
        }

        .sdp-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 14px;
        }

        .sdp-row label {
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
            font-size: 15px;
        }

        .sdp-number {
            width: 90px !important;
            text-align: center;
            font-size: 18px !important;
            font-weight: 700;
            padding: 8px 10px !important;
        }

        .sdp-toggle-group {
            display: flex;
            gap: 8px;
        }

        .sdp-toggle {
            flex: 1;
            padding: 10px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            background: var(--table-row-bg);
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s;
            min-height: unset;
            font-family: inherit;
        }

        .sdp-toggle.active {
            border-color: var(--primary-color);
            color: var(--primary-color);
            background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
        }



        /* =========================================================
           5. PANTALLA: SCORING (PUNTUACION)
           ========================================================= */


        /* -- 5a. Widget de temporizador por turno -- */
        .timer-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .player-timer {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            border: 3px solid transparent;
            transition: all 0.3s;
        }

        .player-timer.active {
            border-color: #2ecc71;
            background: #d4edda;
            transform: scale(1.05);
        }

        .player-timer h3 {
            margin-bottom: 10px;
            color: #333;
        }

        .time-display {
            font-size: 36px;
            font-weight: bold;
            color: #667eea;
            margin: 10px 0;
            font-family: 'DM Mono', 'Courier New', monospace;
        }

        .player-timer.active .time-display {
            color: #2ecc71;
        }

        .player-timer button {
            margin: 5px;
            padding: 8px 20px;
            font-size: 14px;
        }


        /* -- 5b. Tabla de puntuacion -- */
        .score-table {
            border-collapse: collapse;
            table-layout: auto;
            width: max-content;
            min-width: 100%;
        }

        .score-table th,
        .score-table td {
            padding: 10px 8px;
            border: 1px solid var(--border-color);
            text-align: center;
            font-size: 14px;
            white-space: nowrap;
            color: var(--text-primary);
        }

        .score-table th {
            background: var(--table-header-bg);
            color: var(--table-header-text);
        }

        /* Columna de ítems: sticky, ancho fijo, texto con salto de línea */
        .score-table td:first-child,
        .score-table th:first-child {
            position: sticky;
            left: 0;
            z-index: 5;
            font-weight: 600;
            min-width: 110px;
            max-width: 140px;
            white-space: normal;
            word-break: break-word;
            text-align: left;
            padding-left: 10px;
            background: var(--table-row-bg);
            box-shadow: 2px 0 5px rgba(0,0,0,0.08);
        }

        /* Filas alternas */
        .score-table tbody tr:nth-child(even) td {
            background: var(--table-row-alt);
        }

        .score-table tbody tr:nth-child(even) td:first-child {
            background: var(--table-row-alt);
        }

        .score-table th:first-child {
            background: var(--table-header-bg);
            color: var(--table-header-text);
            z-index: 15;
        }

        /* Columnas de jugadores: ancho fijo cómodo para el input */
        .score-table th:not(:first-child),
        .score-table td:not(:first-child) {
            min-width: 80px;
            width: 80px;
        }

        .score-table input {
            width: 64px;
            padding: 8px 4px;
            text-align: center;
            font-size: 16px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background: var(--input-bg);
            color: var(--text-primary);
        }

        .score-table .total-row td {
            background: var(--table-total-bg) !important;
            color: var(--text-primary) !important;
            font-weight: bold;
        }

        .score-table .total-row td:first-child {
            background: var(--table-total-bg) !important;
        }


        /* -- 5c. Items y puntuacion por categoria -- */
        .scoring-item {
            background: var(--input-bg);
            padding: 12px 14px;
            border-radius: 14px;
            margin-bottom: 10px;
            border: 1.5px solid var(--border-color);
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .scoring-item input[type="text"] {
            width: 100% !important;
            margin: 0;
        }

        .scoring-item-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .scoring-item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0;
        }

        /* Toggle "Resta" pill */
        .resta-toggle {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            user-select: none;
        }

        .resta-toggle input[type="checkbox"] {
            display: none;
        }

        .resta-toggle-pill {
            width: 38px;
            height: 22px;
            border-radius: 11px;
            background: var(--border-color);
            position: relative;
            transition: background 0.2s;
            flex-shrink: 0;
        }

        .resta-toggle-pill::after {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: white;
            top: 3px;
            left: 3px;
            transition: left 0.2s;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        .resta-toggle input[type="checkbox"]:checked + .resta-toggle-pill {
            background: #e74c3c;
        }

        .resta-toggle input[type="checkbox"]:checked + .fixed-pts-pill {
            background: var(--primary-color);
        }

        .resta-toggle input[type="checkbox"]:checked + .resta-toggle-pill::after {
            left: 19px;
        }

        .resta-toggle-label {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-secondary);
            transition: color 0.2s;
        }

        .resta-toggle:has(input:checked) .resta-toggle-label {
            color: #e74c3c;
        }

        .item-delete-btn {
            width: 34px;
            height: 34px;
            min-height: unset;
            padding: 0;
            margin: 0;
            border-radius: 8px;
            background: rgba(231,76,60,0.1) !important;
            color: #e74c3c;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: none !important;
            border: 1px solid rgba(231,76,60,0.2) !important;
            flex-shrink: 0;
        }

        .item-delete-btn:active {
            background: rgba(231,76,60,0.2) !important;
        }


        /* =========================================================
           6. PANTALLA: TIMER (TEMPORIZADOR FULLSCREEN)
           ========================================================= */

        .timer-fullscreen {
            display: flex;
            flex-direction: column;
            align-items: center;
            border-radius: 20px;
            padding: 32px 24px 28px 24px;
            transition: background-color 0.5s ease;
            box-shadow: 0 8px 32px rgba(0,0,0,0.25);
            position: relative;
            overflow: hidden;
            min-height: calc(100dvh - 90px);
            justify-content: center;
            gap: 0;
        }

        /* Overlay negro que sube desde abajo para el efecto de cuenta atrás */
        #timerBlackOverlay {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: #111111;
            transition: height 0.25s linear;
            pointer-events: none;
            border-radius: 0 0 20px 20px;
            z-index: 0;
        }

        /* El contenido del timer siempre por encima del overlay negro */
        .timer-fullscreen > *:not(#timerBlackOverlay):not(.paused-overlay) {
            position: relative;
            z-index: 1;
        }

        .timer-info {
            text-align: center;
            width: 100%;
            margin-bottom: 18px;
        }

        .game-name-timer {
            font-size: 18px;
            font-weight: 600;
            color: rgba(255,255,255,0.9);
            margin-bottom: 4px;
        }

        .round-info {
            font-size: 15px;
            color: rgba(255,255,255,0.75);
        }

        .player-name-large {
            font-size: clamp(32px, 9vw, 60px);
            font-weight: bold;
            color: white;
            text-shadow: 0 4px 10px rgba(0,0,0,0.3);
            margin-bottom: 10px;
            animation: fadeIn 0.5s ease;
            text-align: center;
            word-wrap: break-word;
            max-width: 100%;
        }

        .time-display-large {
            font-size: clamp(56px, 18vw, 100px);
            font-weight: bold;
            color: white;
            font-family: 'DM Mono', 'Courier New', monospace;
            text-shadow: 0 4px 10px rgba(0,0,0,0.3);
            margin-bottom: 28px;
            letter-spacing: 5px;
        }

        .timer-controls {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
        }

        .timer-btn {
            background: transparent;
            border: none;
            color: white;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.2s;
            pointer-events: auto;
            -webkit-tap-highlight-color: transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            flex-shrink: 0;
        }

        .timer-btn:active {
            background: transparent;
            transform: scale(0.93);
        }

        .timer-btn.next-btn {
            width: 140px;
            height: 140px;
            position: relative;
            background: rgba(255,255,255,0.15);
            border: 2.5px solid rgba(255,255,255,0.35);
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }

        .next-btn-inner {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }

        .next-btn-player-name {
            font-size: 13px;
            font-weight: 600;
            color: rgba(255,255,255,0.75);
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            text-align: center;
        }


        .order-overlay-list {
            width: 100%;
            max-width: 300px;
            max-height: 45vh;
            overflow-y: auto;
            margin: 0;
            padding: 0 20px;
        }

        .order-overlay-list .order-item {
            background: rgba(255,255,255,0.12);
            border-color: rgba(255,255,255,0.3);
            box-shadow: none;
        }

        .order-overlay-list .order-player-name {
            color: white;
        }

        #orderOverlay .order-btn {
            background: rgba(0,0,0,0.25);
            color: white;
            border: 1px solid rgba(255,255,255,0.4);
            min-height: unset;
            padding: 4px 10px;
            font-size: 14px;
            margin: 0;
        }

        #orderOverlay .order-btn:disabled {
            opacity: 0.25;
        }

        .paused-overlay {
            position: absolute;
            inset: 0;
            border-radius: 20px;
            background: rgba(0,0,0,0.75);
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 28px;
            z-index: 20;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
        }

        .paused-overlay.visible {
            display: flex;
        }

        .paused-title {
            font-size: clamp(26px, 7vw, 40px);
            font-weight: bold;
            color: white;
            text-shadow: 0 2px 10px rgba(0,0,0,0.4);
            letter-spacing: 1px;
        }

        .paused-actions {
            display: flex;
            flex-direction: column;
            gap: 14px;
            width: 100%;
            max-width: 280px;
            padding: 0 24px;
        }

        .paused-btn {
            width: 100%;
            padding: 16px 20px;
            border-radius: 14px;
            border: none;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            margin: 0;
            min-height: unset;
            transition: transform 0.15s, opacity 0.15s;
            -webkit-tap-highlight-color: transparent;
        }

        .paused-btn:active {
            transform: scale(0.96);
            opacity: 0.85;
            background: inherit;
        }

        .paused-resume {
            background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
            color: #333;
            box-shadow: 0 4px 14px rgba(0,0,0,0.25);
        }

        .paused-end {
            background: rgba(255,255,255,0.12);
            color: rgba(255,255,255,0.9);
            border: 1.5px solid rgba(255,255,255,0.3);
            box-shadow: none;
        }

        .timer-btn.pause-btn {
            width: 80px;
            height: 80px;
            padding: 0;
            opacity: 0.85;
            background: rgba(255,255,255,0.15);
            border: 2.5px solid rgba(255,255,255,0.35);
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }

        .timer-btn.pause-btn:active {
            background: rgba(255,255,255,0.25);
        }



        /* -- 6b. Estados de overtime y aviso de tiempo -- */
        /* Overtime: fondo rojo parpadeante */
        @keyframes overtimePulse {
            0%, 100% { opacity: 1; }
            50%       { opacity: 0.55; }
        }
        .timer-overtime #timeDisplayLarge {
            color: #ff4444 !important;
            text-shadow: 0 0 20px rgba(255,60,60,0.8), 0 4px 10px rgba(0,0,0,0.3) !important;
            animation: overtimePulse 0.9s ease-in-out infinite;
        }
        .timer-overtime.timer-fullscreen {
            background: linear-gradient(to bottom, #1a0000 0%, #111111 100%) !important;
        }
        /* Últimos 5s: display amarillo */
        .timer-warning #timeDisplayLarge {
            color: #ffdd57 !important;
            text-shadow: 0 0 14px rgba(255,210,50,0.7), 0 4px 10px rgba(0,0,0,0.3) !important;
        }


        /* =========================================================
           7. PANTALLA: RESULTS (RESULTADOS)
           ========================================================= */

        .results {
            margin-top: 30px;
        }

        /* ── Pantalla de resultados ── */
        .results-winner-card {
            position: relative;
            overflow: hidden;
            border-radius: 20px;
            padding: 28px 24px 24px;
            margin-bottom: 16px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            text-align: center;
            animation: winnerEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
        }

        @keyframes winnerEntrance {
            from { opacity: 0; transform: scale(0.85) translateY(20px); }
            to   { opacity: 1; transform: scale(1) translateY(0); }
        }

        .results-winner-card::before {
            content: '';
            position: absolute;
            inset: 0;
            background: inherit;
            filter: brightness(0.7);
            border-radius: 20px;
            z-index: 0;
        }

        .results-winner-card > * { position: relative; z-index: 1; }

        .results-winner-crown {
            line-height: 1;
            filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
            animation: crownBounce 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
            color: white;
        }

        @keyframes crownBounce {
            from { opacity: 0; transform: scale(0.5) rotate(-15deg); }
            to   { opacity: 1; transform: scale(1) rotate(0deg); }
        }

        .results-winner-name {
            font-size: clamp(28px, 8vw, 42px);
            font-weight: 800;
            color: white;
            text-shadow: 0 3px 12px rgba(0,0,0,0.4);
            letter-spacing: -0.5px;
            line-height: 1.1;
        }

        .results-winner-score {
            font-size: 18px;
            font-weight: 600;
            color: rgba(255,255,255,0.85);
            background: rgba(0,0,0,0.2);
            padding: 4px 14px;
            border-radius: 20px;
            margin-top: 2px;
        }

        .results-winner-label {
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 2px;
            text-transform: uppercase;
            color: rgba(255,255,255,0.7);
            margin-top: 4px;
        }

        .results-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 8px;
        }

        .result-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            padding: 13px 16px;
            background: var(--table-row-alt);
            border-radius: 14px;
            font-size: 16px;
            border: 1.5px solid var(--border-color);
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            animation: resultSlideIn 0.4s ease both;
        }

        @keyframes resultSlideIn {
            from { opacity: 0; transform: translateX(-16px); }
            to   { opacity: 1; transform: translateX(0); }
        }

        .result-item.winner { display: none; } /* handled by winner card now */

        .result-position {
            font-size: 13px;
            font-weight: 800;
            line-height: 1;
            flex-shrink: 0;
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: var(--table-total-bg);
            color: var(--text-secondary);
        }

        .result-item-left {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
            flex: 1;
        }

        .result-player-name {
            font-weight: 600;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .result-item-right {
            font-weight: 700;
            color: var(--primary-color);
            flex-shrink: 0;
            font-size: 17px;
        }

        .winner-badge { display: none; } /* replaced by winner card */


        /* =========================================================
           8. PANTALLA: HISTORY (HISTORIAL)
           ========================================================= */

        .history-card {
            background: var(--container-bg);
            border-radius: 18px;
            padding: 0;
            margin-bottom: 10px;
            border: 1.5px solid var(--border-color);
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s;
            box-shadow: 0 2px 10px rgba(0,0,0,0.06);
            overflow: hidden;
        }
        .history-card:active {
            transform: scale(0.98);
        }
        .history-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 22px rgba(0,0,0,0.11);
        }
        .history-card-top {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 16px 10px;
        }
        .history-card-emoji {
            width: 42px;
            height: 42px;
            border-radius: 12px;
            background: var(--table-row-alt);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 22px;
            flex-shrink: 0;
        }
        .history-card-meta {
            flex: 1;
            min-width: 0;
        }
        .history-card-game {
            font-weight: 800;
            font-size: 16px;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.2;
        }
        .history-card-date {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .history-card-divider {
            height: 1px;
            background: var(--border-color);
            margin: 0 16px;
        }
        .history-card-players {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            padding: 10px 16px 14px;
        }
        .history-card-player-pill {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: var(--table-row-alt);
            border-radius: 20px;
            padding: 4px 10px;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
        }
        .history-card-player-pill.winner {
            background: var(--btn-primary-gradient);
            color: #fff;
        }
       
        .shared-by-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: linear-gradient(135deg, #667eea18, #764ba218);
            border: 1.5px solid #667eea44;
            border-radius: 6px;
            padding: 3px 8px;
            font-size: 11px;
            font-weight: 700;
            color: var(--primary-color);
            margin: 0 16px 12px;
        }

        .history-login-hint,
        .stats-login-hint {
            text-align: center;
            font-size: 13px;
            color: var(--text-secondary);
            margin-top: 16px;
            padding: 12px 16px;
            border-radius: 12px;
            background: var(--table-row-alt);
            border: 1px solid var(--border-color);
        }

        /* -- Modal detalle de partida del historial -- */
        .history-modal-game-title {
            font-size: 18px;
            font-weight: 700;
            color: var(--secondary-color);
            margin-bottom: 12px;
        }

        .history-modal-results {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 14px;
        }

        .history-modal-result-row {
            font-size: 15px;
            color: var(--text-primary);
            font-weight: 500;
        }

        .history-modal-toggle-btn {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 0;
            transition: none;
        }

        .history-modal-toggle-btn.open svg {
            transform: rotate(180deg);
        }

        .history-modal-detail-table {
            margin-top: 12px;
        }


        /* =========================================================
           9. PANTALLA: STATS (ESTADISTICAS)
           ========================================================= */


        /* -- 9b. Tabs y listas de juegos / jugadores / tiempos -- */
        /* ── Stats Screen ─────────────────────────────── */
        .stats-tabs {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 4px;
        }

        .stats-tab-item {
            display: flex;
            flex-direction: column;
        }

        .stats-tab-btn {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: flex-start;
            gap: 12px;
            padding: 14px 18px;
            border-radius: 14px;
            font-size: 15px;
            font-weight: 600;
            background: var(--table-row-alt);
            color: var(--text-secondary);
            border: 2px solid transparent;
            box-shadow: none;
            min-height: unset;
            margin: 0;
            width: 100%;
            text-align: left;
            transition: all 0.2s ease;
        }

        .stats-tab-btn svg {
            flex-shrink: 0;
        }

        .stats-tab-btn .stats-tab-arrow {
            margin-left: auto;
            transition: transform 0.25s ease;
            opacity: 0.4;
        }

        .stats-tab-btn.active {
            background: var(--btn-primary-gradient);
            color: #fff;
            border-color: transparent;
            box-shadow: 0 4px 14px rgba(102,126,234,0.35);
            border-radius: 14px 14px 0 0;
        }

        .stats-tab-btn.active .stats-tab-arrow {
            transform: rotate(90deg);
            opacity: 0.8;
        }

        .stats-tab-btn:active {
            transform: scale(0.98);
        }

        .stats-tab-card {
            display: none;
            background: var(--table-row-alt);
            border-radius: 0 0 14px 14px;
            overflow: hidden;
            border-top: 1px solid rgba(102,126,234,0.15);
        }

        .stats-tab-card.open {
            display: block;
            animation: statsCardOpen 0.22s cubic-bezier(0.4,0,0.2,1) both;
        }

        @keyframes statsCardOpen {
            from { opacity: 0; transform: translateY(-6px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .stats-placeholder {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            padding: 30px 20px;
            color: var(--text-secondary);
            text-align: center;
        }

        .stats-placeholder svg {
            opacity: 0.25;
        }

        .stats-placeholder p {
            font-size: 13px;
            opacity: 0.6;
            line-height: 1.5;
        }

        .stats-game-list {
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 8px 12px 12px;
        }

        .stats-game-row {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 4px;
            border-bottom: 1px solid var(--border-color);
            cursor: pointer;
            border-radius: 8px;
            transition: background 0.15s;
            -webkit-tap-highlight-color: transparent;
        }
        .stats-game-row:active {
            background: rgba(102,126,234,0.08);
        }

        .stats-game-row:last-child {
            border-bottom: none;
        }

        .stats-game-row-arrow {
            flex-shrink: 0;
            color: var(--text-secondary);
            opacity: 0.45;
        }

        .stats-game-rank {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-secondary);
            opacity: 0.5;
            min-width: 20px;
            text-align: center;
        }

        .stats-game-emoji {
            font-size: 22px;
            line-height: 1;
            flex-shrink: 0;
        }

        .stats-game-info {
            flex: 1;
            min-width: 0;
        }

        .stats-game-name {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .stats-game-meta {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .stats-game-winner-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: linear-gradient(135deg, #f59e0b22, #f59e0b11);
            color: #b45309;
            border-radius: 6px;
            padding: 2px 7px;
            font-size: 11px;
            font-weight: 600;
        }


        .stats-game-count {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex-shrink: 0;
        }

        .stats-game-count-num {
            font-size: 22px;
            font-weight: 800;
            color: var(--primary-color);
            line-height: 1;
        }

        .stats-game-count-label {
            font-size: 10px;
            color: var(--text-secondary);
            font-weight: 500;
            opacity: 0.7;
        }

        .history-entry-date {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-secondary);
            opacity: 0.8;
            white-space: nowrap;
            text-align: right;
            display: flex;
            align-items: center;
            gap: 3px;
        }


        /* -- 9c. Panel de detalle de juego -- */
        /* ── Game detail bottom sheet ── */
        #gameDetailModal {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 2000;
            background: rgba(0,0,0,0.55);
            align-items: flex-end;
            justify-content: center;
            padding: 0;
        }
        #gameDetailModal.open { display: flex; }
        .game-detail-sheet {
            background: var(--container-bg);
            border-radius: 20px 20px 0 0;
            width: 100%;
            max-width: 560px;
            max-height: 82vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            animation: sheetUp 0.25s cubic-bezier(0.34,1.2,0.64,1);
        }
        @keyframes sheetUp {
            from { transform: translateY(100%); opacity: 0; }
            to   { transform: translateY(0);    opacity: 1; }
        }
        .game-detail-header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 18px 18px 14px;
            border-bottom: 1px solid var(--border-color);
            flex-shrink: 0;
        }
        .game-detail-title {
            flex: 1;
            font-size: 17px;
            font-weight: 700;
            color: var(--text-primary);
        }
        .game-detail-count {
            font-size: 13px;
            color: var(--text-secondary);
            font-weight: 500;
        }
        .game-detail-body {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            padding: 12px 12px 24px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .game-detail-body > .history-card {
            flex-shrink: 0;
        }
        /* Emoji editable */
        .game-detail-emoji-wrap {
            position: relative;
            display: inline-flex;
            cursor: pointer;
            flex-shrink: 0;
        }
        .game-detail-emoji-wrap:active { opacity: 0.75; }
        .game-detail-emoji-edit-badge {
            position: absolute;
            bottom: -3px;
            right: -5px;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--primary-color);
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }
        #emojiPickerPanel {
            display: none;
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            z-index: 100;
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: 14px;
            padding: 10px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.18);
            width: 260px;
        }
        #emojiPickerPanel.open { display: block; }

        .emoji-picker-input-row {
            display: flex;
            gap: 6px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--border-color);
        }
        .emoji-picker-input {
            flex: 1;
            font-size: 18px;
            text-align: center;
            padding: 6px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            background: var(--input-bg);
            color: var(--text-primary);
            min-height: unset;
        }
        .emoji-picker-confirm {
            padding: 6px 14px;
            font-size: 13px;
            font-weight: 600;
            border-radius: 8px;
            background: var(--btn-primary-gradient);
            color: white;
            border: none;
            cursor: pointer;
            min-height: unset;
        }
        /* ── Fin game detail ── */


        /* -- 9d. Filas de jugador y tiempo -- */
        .stats-player-list {
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 8px 12px 12px;
        }

        .stats-player-row {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 4px;
            border-bottom: 1px solid var(--border-color);
        }

        .stats-player-row:last-child {
            border-bottom: none;
        }

        .stats-player-rank {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-secondary);
            opacity: 0.5;
            min-width: 20px;
            text-align: center;
        }

        .stats-player-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--btn-primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 800;
            color: #fff;
            flex-shrink: 0;
            letter-spacing: -0.5px;
        }

        .stats-player-info {
            flex: 1;
            min-width: 0;
        }

        .stats-player-name {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .stats-player-sub {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .stats-player-winrate {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex-shrink: 0;
            min-width: 52px;
        }

        .stats-player-winrate-num {
            font-size: 20px;
            font-weight: 800;
            line-height: 1;
            background: var(--btn-primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .stats-player-winrate-label {
            font-size: 10px;
            color: var(--text-secondary);
            font-weight: 500;
            opacity: 0.7;
        }

        .stats-time-list {
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 8px 12px 12px;
        }

        .stats-time-row {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 4px;
            border-bottom: 1px solid var(--border-color);
        }

        .stats-time-row:last-child {
            border-bottom: none;
        }

        .stats-time-badge {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex-shrink: 0;
            min-width: 58px;
        }

        .stats-time-badge-num {
            font-size: 19px;
            font-weight: 800;
            line-height: 1;
        }

        .stats-time-badge-num.slow { color: #e74c3c; }
        .stats-time-badge-num.fast { color: #2ecc71; }
        .stats-time-badge-num.neutral { color: var(--text-secondary); }

        .stats-time-badge-label {
            font-size: 10px;
            color: var(--text-secondary);
            font-weight: 500;
            opacity: 0.7;
        }


        /* -- 9e. VS Stats (comparativa entre dos jugadores) -- */
        /* ── VS Stats ─────────────────────────────────── */
        .vs-selector {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 14px 12px 10px;
        }

        .vs-select {
            flex: 1;
            padding: 10px 12px;
            border: 1.5px solid var(--input-border);
            border-radius: 10px;
            font-size: 14px;
            font-weight: 600;
            background: var(--input-bg);
            color: var(--text-primary);
            font-family: 'Plus Jakarta Sans', sans-serif;
            -webkit-appearance: none;
            appearance: none;
            cursor: pointer;
        }

        .vs-label {
            font-size: 13px;
            font-weight: 800;
            color: var(--text-secondary);
            flex-shrink: 0;
            opacity: 0.5;
        }

        .vs-result {
            padding: 0 12px 12px;
        }

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

        .vs-player-name {
            font-size: 14px;
            font-weight: 800;
            color: var(--text-primary);
            flex: 1;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .vs-player-name.left { text-align: left; }
        .vs-player-name.right { text-align: right; }

        .vs-header-label {
            font-size: 11px;
            font-weight: 800;
            color: var(--text-secondary);
            opacity: 0.45;
            flex-shrink: 0;
        }

        .vs-global-score {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background: var(--table-row-alt);
            border-radius: 12px;
            padding: 12px 16px;
            margin-bottom: 16px;
        }

        .vs-global-num {
            font-size: 28px;
            font-weight: 800;
            color: var(--primary-color);
            line-height: 1;
        }

        .vs-global-sep {
            font-size: 18px;
            font-weight: 700;
            color: var(--text-secondary);
            opacity: 0.4;
        }

        .vs-global-sub {
            font-size: 11px;
            color: var(--text-secondary);
            text-align: center;
            margin-top: 2px;
            opacity: 0.6;
        }

        .vs-game-row {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 0;
            border-bottom: 1px solid var(--border-color);
        }

        .vs-game-row:last-child { border-bottom: none; }

        .vs-game-title {
            flex: 1;
            min-width: 0;
            text-align: center;
        }

        .vs-game-name {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .vs-game-sub {
            font-size: 11px;
            color: var(--text-secondary);
            opacity: 0.6;
        }

        .vs-score-block {
            display: flex;
            flex-direction: column;
            align-items: center;
            min-width: 42px;
            flex-shrink: 0;
        }

        .vs-score-num {
            font-size: 20px;
            font-weight: 800;
            line-height: 1;
            color: var(--text-secondary);
        }

        .vs-score-num.winner {
            color: var(--primary-color);
        }

        .vs-score-wins {
            font-size: 10px;
            color: var(--text-secondary);
            opacity: 0.55;
        }

        .vs-score-dash {
            font-size: 16px;
            font-weight: 700;
            color: var(--text-secondary);
            opacity: 0.3;
            flex-shrink: 0;
        }

        .vs-no-data {
            text-align: center;
            color: var(--text-secondary);
            font-size: 13px;
            padding: 16px 12px;
            opacity: 0.6;
        }


        /* -- 9f. Modal de desempate (tiebreaker) -- */
        /* ── Tiebreaker Modal ─────────────────────────── */
        .tiebreaker-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.65);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            animation: fadeInOverlay 0.2s ease both;
        }

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

        .tiebreaker-modal {
            background: var(--container-bg);
            border-radius: 20px;
            padding: 24px 20px 20px;
            width: 100%;
            max-width: 420px;
            box-shadow: 0 12px 48px rgba(0,0,0,0.4);
            animation: slideUpModal 0.28s cubic-bezier(0.34,1.2,0.64,1) both;
        }

        @keyframes slideUpModal {
            from { opacity: 0; transform: translateY(30px) scale(0.96); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }

        .tiebreaker-title {
            font-size: 18px;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 4px;
            text-align: center;
        }

        .tiebreaker-subtitle {
            font-size: 13px;
            color: var(--text-secondary);
            text-align: center;
            margin-bottom: 18px;
            line-height: 1.4;
        }

        .tiebreaker-score-badge {
            display: inline-block;
            background: var(--btn-primary-gradient);
            color: #fff;
            border-radius: 8px;
            padding: 2px 9px;
            font-size: 13px;
            font-weight: 700;
            margin-bottom: 14px;
            width: 100%;
            text-align: center;
        }

        .tiebreaker-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 20px;
        }

        /* Reutiliza .order-item / .order-btn pero dentro del modal */
        .tiebreaker-list .order-item {
            box-shadow: 0 2px 10px rgba(0,0,0,0.18);
            border-width: 2px;
            transition: transform 0.15s;
        }

        .tiebreaker-list .order-item:hover {
            transform: translateY(-2px);
        }

        .tiebreaker-list .order-btn {
            background: rgba(0,0,0,0.25);
            color: white;
            border: 1px solid rgba(255,255,255,0.4);
            min-height: unset;
            padding: 0;
            margin: 0;
        }

        .tiebreaker-list .order-btn:disabled {
            opacity: 0.25;
        }

        .tiebreaker-position-hint {
            font-size: 12px;
            color: rgba(255,255,255,0.75);
            font-weight: 600;
            flex-shrink: 0;
            margin-right: 4px;
        }

        .tiebreaker-actions {
            display: flex;
            gap: 10px;
        }

        .tiebreaker-confirm-btn {
            flex: 1;
            padding: 14px;
            border-radius: 12px;
            border: none;
            background: var(--btn-green-gradient);
            color: #fff;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            font-family: 'Plus Jakarta Sans', sans-serif;
            transition: opacity 0.2s;
        }

        .tiebreaker-confirm-btn:active { opacity: 0.8; }

        .tiebreaker-progress {
            font-size: 12px;
            color: var(--text-secondary);
            text-align: center;
            margin-bottom: 12px;
            opacity: 0.7;
        }

        /* ── End Tiebreaker Modal ─────────────────────── */



        /* =========================================================
           10. PANTALLA: SETTINGS (AJUSTES)
           ========================================================= */


        /* -- 10a. Contenedor de seccion generico -- */
        .settings-section {
            background: var(--table-row-alt);
            border-radius: 16px;
            padding: 18px;
            margin-bottom: 16px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            border: 1px solid var(--border-color);
        }
        .settings-section h2 {
            font-size: 16px;
            margin-bottom: 4px;
            color: var(--text-primary);
        }
        .settings-desc {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 12px;
        }


        /* -- 10b. Sesion (login con Google) -- */
        /* ── Auth Section (settings) ──────────────────── */
        .auth-user-row {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 14px 0 6px;
        }
        .auth-avatar {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            background: var(--btn-primary-gradient);
            background-size: cover;
            background-position: center;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 20px;
            font-weight: 700;
        }
        .auth-user-info { flex: 1; min-width: 0; }
        .auth-user-name {
            font-size: 16px;
            font-weight: 700;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .auth-user-email {
            font-size: 12px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-top: 2px;
        }
        .auth-sync-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 11px;
            font-weight: 700;
            color: #2ecc71;
            margin-top: 5px;
        }



        /* -- 10c. Perfil de jugador -- */
        /* ── Player Profile Section ───────────────────── */
        .profile-section {
            background: var(--table-row-alt);
            border-radius: 16px;
            padding: 18px;
            margin-top: 14px;
            border: 1.5px solid var(--border-color);
        }
        .profile-id-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: var(--btn-primary-gradient);
            color: #fff;
            border-radius: 10px;
            padding: 8px 14px;
            font-size: 15px;
            font-weight: 700;
            letter-spacing: 1.5px;
            font-family: 'DM Mono', monospace;
            cursor: pointer;
            user-select: all;
            transition: opacity 0.15s;
        }
        .profile-id-badge:active { opacity: 0.8; }
        .profile-id-label {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 4px;
        }
        .profile-section-toggle {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }
        .profile-section-toggle .toggle-arrow {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            background: var(--table-row-alt);
            border: 1.5px solid var(--border-color);
            transition: transform 0.25s ease;
            flex-shrink: 0;
        }
        .profile-section-toggle.open .toggle-arrow {
            transform: rotate(180deg);
        }
        .profile-section-body {
            overflow: hidden;
            max-height: 0;
            transition: max-height 0.35s ease, opacity 0.25s ease;
            opacity: 0;
        }
        .profile-section-body.open {
            max-height: 600px;
            opacity: 1;
        }
        .profile-color-row {
            display: flex;
            gap: 12px;
            margin-top: 14px;
        }
        .profile-color-block {
            flex: 1;
        }
        .profile-color-block label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            display: block;
            margin-bottom: 6px;
        }
        .profile-color-swatch-btn {
            width: 100%;
            height: 42px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 13px;
            font-weight: 600;
            color: #fff;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
            transition: opacity 0.15s;
            min-height: unset;
            box-shadow: none;
            margin: 0;
            padding: 0 12px;
        }
        .profile-color-swatch-btn:active { opacity: 0.8; transform: scale(0.98); }
        .profile-name-input {
            width: 100%;
            padding: 11px 14px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            background: var(--input-bg);
            color: var(--text-primary);
            font-size: 15px;
            font-weight: 600;
            font-family: inherit;
            margin-top: 12px;
            box-sizing: border-box;
            transition: border-color 0.2s;
        }
        .profile-name-input:focus {
            outline: none;
            border-color: var(--primary-color);
        }
        .profile-preview {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 14px;
            padding: 12px 14px;
            background: var(--container-bg);
            border-radius: 12px;
            border: 1.5px solid var(--border-color);
        }
        .profile-preview-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            font-weight: 800;
            color: #fff;
            flex-shrink: 0;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        .profile-preview-name {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-primary);
        }
        .profile-preview-sub {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 2px;
        }


        /* -- 10d. Amigos -- */
        /* ── Friends Section ───────────────────────────── */
        .friend-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--container-bg);
            border-radius: 12px;
            border: 1.5px solid var(--border-color);
            margin-bottom: 8px;
        }
        .friend-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 800;
            color: #fff;
            flex-shrink: 0;
        }
        .friend-info { flex: 1; min-width: 0; }
        .friend-name {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
        }
        .friend-code {
            font-size: 11px;
            color: var(--text-secondary);
            font-family: 'DM Mono', monospace;
        }
        .friend-del-btn {
            background: none;
            border: none;
            color: #e74c3c;
            cursor: pointer;
            padding: 6px;
            border-radius: 6px;
            min-height: unset;
            display: flex;
            align-items: center;
        }
        .add-friend-row {
            display: flex;
            gap: 8px;
            margin-top: 10px;
        }
        .add-friend-row input {
            flex: 1;
            padding: 11px 14px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            background: var(--input-bg);
            color: var(--text-primary);
            font-size: 14px;
            font-family: 'DM Mono', monospace;
            font-weight: 600;
            letter-spacing: 1px;
            text-transform: uppercase;
        }
        .add-friend-row input:focus {
            outline: none;
            border-color: var(--primary-color);
        }
        .add-friend-row button {
            padding: 11px 16px;
            margin: 0;
            border-radius: 10px;
            font-size: 14px;
        }


        /* -- 10e. Jugadores frecuentes -- */
        .frecuent-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .frecuent-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--container-bg);
            border-radius: 8px;
            padding: 10px 12px;
            font-size: 15px;
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        .frecuent-item-del {
            background: none;
            border: none;
            color: #e74c3c;
            font-size: 18px;
            padding: 0 4px;
            margin: 0;
            min-height: unset;
            cursor: pointer;
            line-height: 1;
        }
        .frecuent-item-del:active { background: none; transform: none; }


        /* -- 10f. Plantillas personalizadas -- */
        /* Template form modal: bottom sheet */
        #templateFormModal {
            align-items: flex-end;
            padding: 0;
        }
        .template-form-box {
            max-height: 92vh;
            overflow-y: auto;
            text-align: left;
            max-width: 560px;
            width: 100%;
            border-radius: 20px 20px 0 0;
            animation: sheetUp 0.25s cubic-bezier(0.34,1.2,0.64,1);
            padding: 28px 24px 44px;
        }
        .tpl-form-group {
            margin-bottom: 12px;
        }
        .tpl-edit-scoring-btn {
            width: 100%;
            background: var(--surface-secondary);
            border: 1.5px solid var(--border-color);
            color: var(--text-primary);
            border-radius: 10px;
            padding: 11px 14px;
            font-size: 14px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s;
            min-height: unset;
            margin: 0;
            box-shadow: none;
        }
        .tpl-edit-scoring-btn:active {
            background: var(--border-color);
        }
        .tpl-delete-btn {
            width: 100%;
            margin-bottom: 10px;
            background: transparent;
            color: #e74c3c;
            border: 1.5px solid rgba(231,76,60,0.35);
            border-radius: 10px;
            min-height: unset;
            padding: 10px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
        }
        .tpl-delete-btn:active { background: rgba(231,76,60,0.08); }
        .tpl-form-group label {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: 4px;
        }
        .tpl-input {
            width: 100%;
            padding: 10px 12px;
            border: 1.5px solid var(--input-border);
            border-radius: 8px;
            font-size: 15px;
            background: var(--input-bg);
            color: var(--text-primary);
        }
        .tpl-input-sm { max-width: 120px; }
        .tpl-item-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 6px;
        }
        .tpl-item-row input[type="text"] {
            flex: 1;
            padding: 8px 10px;
            font-size: 14px;
        }
        .tpl-item-row .checkbox-label { flex-shrink: 0; }
        .tpl-item-del {
            background: #ff4757;
            border: none;
            color: white;
            border-radius: 6px;
            padding: 5px 10px;
            font-size: 14px;
            cursor: pointer;
            min-height: unset;
            margin: 0;
        }
        /* Custom template card */
        .custom-tpl-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--container-bg);
            border-radius: 8px;
            padding: 10px 12px;
            font-size: 15px;
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        .custom-tpl-item-actions {
            display: flex;
            gap: 6px;
        }
        .custom-tpl-btn {
            background: none;
            border: none;
            font-size: 16px;
            padding: 2px 6px;
            margin: 0;
            min-height: unset;
            cursor: pointer;
            line-height: 1;
        }
        .custom-tpl-btn:active { background: none; transform: none; }




        /* -- 10h. Instalacion PWA -- */
        /* ── Install card ── */
        .install-card-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            margin-top: 12px;
            background: var(--btn-primary-gradient);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 14px 18px;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            transition: opacity 0.15s;
        }
        .install-card-btn:active { opacity: 0.8; }

        .install-ios-steps {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-top: 12px;
        }
        .install-ios-step {
            display: flex;
            align-items: center;
            gap: 12px;
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 11px 14px;
        }
        .install-ios-step-num {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background: var(--primary-color);
            color: white;
            font-size: 12px;
            font-weight: 800;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .install-ios-step-text {
            font-size: 13px;
            color: var(--text-primary);
            line-height: 1.4;
        }
        .install-ios-step-text strong {
            font-weight: 700;
        }
        /* ── Fin Install card ── */


        /* =========================================================
           11. UTILIDADES & MISC
           Footer  body:has() selectors  pantallas especiales
           ========================================================= */

        .footer-credit {
            text-align: center;
            padding: 20px 10px 10px 10px;
            margin-top: 30px;
            font-size: 13px;
            color: var(--text-secondary);
            opacity: 0.7;
            border-top: 1px solid var(--border-color);
            display: none;
        }

        .footer-credit.footer-outside {
            display: block;
            color: rgba(255, 255, 255, 0.7);
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            margin-top: 20px;
            padding-bottom: 20px;
        }

        .footer-credit.footer-outside strong {
            color: rgba(255, 255, 255, 0.9);
        }

        body:has(#orderPlayersScreen.active) .footer-credit.footer-outside {
            display: none;
        }

        body:has(#orderPlayersScreen.active) .top-bar {
            display: none;
        }

        #timerScreen.active ~ * {
            display: none;
        }

        body:has(#timerScreen.active) .container {
            background: transparent !important;
            box-shadow: none !important;
            padding: 6px 0 6px !important;
        }

        .footer-credit a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
            transition: opacity 0.3s;
        }

        .footer-credit a:active {
            opacity: 0.7;
            text-align: center;
            color: var(--text-secondary);
            padding: 40px 0;
            font-size: 16px;
        }

/* ── Emoji picker ─────────────────────────────── */
.emoji-input {
    border: none !important;
    background: transparent !important;
    padding: 0 4px !important;
    font-size: 22px !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    cursor: default;
    text-align: center;
}

.emoji-field-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.emoji-picker-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    min-height: unset;
    border-radius: 6px;
}
.emoji-picker-btn:hover {
    color: var(--primary-color);
    background: var(--hover-bg, rgba(102,126,234,0.08));
}

.emoji-picker-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 9999;
}

emoji-picker {
    --background: var(--container-bg, #fff);
    --border-color: var(--input-border, #e0e0e0);
    --border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    border-radius: 12px;
}

