:root {
            /* Colores del Balón Oficial Trionda */
            --trionda-blue: #00b0ff;    /* Azul Claro / Sky Blue */
            --trionda-red: #ff1744;     /* Rojo Carmesí Vibrante */
            --trionda-green: #00c853;   /* Verde Vibrante */
            --trionda-white: #ffffff;   /* Blanco Puro */
            --trionda-dark: #050508;    /* Fondo de pantalla Negro Puro */
            --trionda-gray: #12121e;    /* Tarjetas secundarias */

            /* Tarjetas de Arbitro Explicitas */
            --card-yellow: #ffe600;
            --card-red: #ff1744;

            /* Re-mapeo para la UI */
            --bg-dark: #000000;
            --bg-card: rgba(8, 10, 18, 0.96); /* MENUS NEGROS DE ALTO CONTRASTE */
            --neon-cyan: #00f3ff;
            --neon-purple: #bd00ff;
            --neon-green: #00ff66;
            --neon-red: #ff1744;
            --neon-yellow: #ffe600;

            /* Compatibilidad FIFA variables (alias) */
            --fifa-cyan: #00f3ff;
            --fifa-magenta: #bd00ff;
            --fifa-blue: #00b0ff;
            --fifa-purple: #9c27b0;
            --fifa-orange: #ff6d00;
            --fifa-red: #ff1744;
            --fifa-yellow: #ffe600;
            --fifa-green: #00ff66;
            --fifa-black: #000000;
            --fifa-white: #ffffff;

            --text-dark: #ffffff;       /* TODO EL TEXTO BLANCO */
            --text-light: #ffffff;      /* TODO EL TEXTO BLANCO */
            --text-muted: #d0d5e0;      /* TEXTO MUTED CLARO EN BLANCO */
            --font-main: 'Outfit', sans-serif;
            --font-sport: 'Rajdhani', sans-serif;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            user-select: none;
        }

        body, html {
            width: 100%;
            height: 100%;
            overflow: hidden;
            background-color: var(--bg-dark);
            font-family: var(--font-main);
            color: var(--text-light);
        }

        /* Canvas container */
        #canvas-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }

        /* Off-screen edge gradients */
        .edge-indicator {
            position: absolute;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.25s ease, background 0.25s ease;
            z-index: 5; /* Above canvas, below HUD */
        }
        #edge-left {
            left: 0; top: 0; bottom: 0; width: 120px;
        }
        #edge-right {
            right: 0; top: 0; bottom: 0; width: 120px;
        }
        #edge-top {
            left: 0; right: 0; top: 0; height: 120px;
        }
        #edge-bottom {
            left: 0; right: 0; bottom: 0; height: 120px;
        }

        /* Replay Screen Overlay */
        #replay-overlay {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            pointer-events: none;
            z-index: 8; /* below HUD but above game canvas */
            opacity: 0;
            transition: opacity 0.3s ease;
            box-shadow: inset 0 0 100px rgba(255, 0, 0, 0.25);
            border: 6px solid var(--neon-red);
        }
        #replay-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }
        .replay-tag {
            position: absolute;
            top: 40px;
            left: 40px;
            font-family: var(--font-sport);
            font-size: 2.5rem;
            font-weight: 800;
            color: var(--neon-red);
            text-shadow: 0 0 10px var(--neon-red);
            animation: replay-blink 1s infinite;
        }
        @keyframes replay-blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.3; }
        }
        .scanlines {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
            background-size: 100% 4px, 6px 100%;
            pointer-events: none;
        }
        .btn-skip-replay {
            position: absolute;
            bottom: 115px;
            right: 35px;
            background: rgba(10, 10, 18, 0.92);
            color: #ffffff;
            border: 2px solid var(--neon-cyan);
            border-radius: 30px;
            padding: 12px 28px;
            font-family: var(--font-sport);
            font-size: 1.1rem;
            font-weight: 700;
            letter-spacing: 2px;
            cursor: pointer;
            z-index: 15;
            pointer-events: auto;
            transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
            box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
        }
        .btn-skip-replay:hover {
            transform: scale(1.06);
            background: rgba(0, 243, 255, 0.25);
            box-shadow: 0 0 25px rgba(0, 243, 255, 0.8);
        }
        .btn-skip-replay span {
            color: #ffe600;
            margin-left: 6px;
            font-weight: 800;
        }

        /* Banners de saques e instrucciones (Ocultos para mantener la cancha limpia y sin solapamientos) */
        #freekick-banner, #setpiece-help {
            display: none !important;
        }

        /* CUENTA ATRÁS DEL SAQUE DEL MEDIO. Va aparte del banner de saques: aquel está
           oculto a propósito para no ensuciar la cancha, y con él se ocultaba también
           esta cuenta, así que los segundos de congelado parecían el juego trabado. */
        #kickoff-countdown {
            position: absolute;
            top: 108px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 2px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
            z-index: 60;
        }

        #kickoff-countdown.active {
            opacity: 1;
        }

        #kickoff-countdown .ko-label {
            font-family: var(--font-sport);
            font-size: 0.85rem;
            letter-spacing: 4px;
            color: var(--fifa-cyan);
            text-transform: uppercase;
            text-shadow: 0 0 12px rgba(0, 243, 255, 0.7);
        }

        #kickoff-countdown .ko-number {
            font-family: var(--font-sport);
            font-size: 4.6rem;
            line-height: 1;
            font-weight: 900;
            color: #fff;
            text-shadow: 0 0 22px rgba(0, 243, 255, 0.9), 0 4px 10px rgba(0, 0, 0, 0.6);
        }

        /* Late al cambiar de segundo: el número se reinyecta y la animación se repite */
        #kickoff-countdown .ko-number.tick {
            animation: koTick 0.5s ease-out;
        }

        @keyframes koTick {
            0%   { transform: scale(1.45); opacity: 0.35; }
            100% { transform: scale(1);    opacity: 1; }
        }
        .setpiece-help-title {
            font-family: var(--font-sport);
            font-size: 1.05rem;
            color: #ffe600;
            letter-spacing: 3px;
            text-transform: uppercase;
            margin-bottom: 6px;
            text-shadow: 0 0 10px rgba(255, 230, 0, 0.5);
        }
        .setpiece-help-steps {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        .setpiece-help-steps li {
            color: #e8f6ff;
            font-size: 0.85rem;
            line-height: 1.5;
            padding-left: 16px;
            position: relative;
        }
        .setpiece-help-steps li::before {
            content: "▸";
            position: absolute;
            left: 0;
            color: var(--neon-cyan);
        }
        .setpiece-help-steps li strong {
            color: var(--neon-cyan);
            font-weight: 600;
        }

        /* UI Overlay Container */
        #ui-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 10;
            pointer-events: none;
            display: flex;
            flex-direction: column;
        }

        /* Keyframes para Colores Solidos que Rotan */
        @keyframes rotate-trionda-color {
            0%, 100% { border-color: var(--trionda-blue); box-shadow: 0 0 25px rgba(26, 59, 176, 0.5); }
            33% { border-color: var(--trionda-red); box-shadow: 0 0 25px rgba(213, 26, 26, 0.5); }
            66% { border-color: var(--trionda-green); box-shadow: 0 0 25px rgba(40, 142, 58, 0.5); }
        }

        @keyframes rotate-trionda-bg {
            0%, 100% { background-color: var(--trionda-blue); }
            33% { background-color: var(--trionda-red); }
            66% { background-color: var(--trionda-green); }
        }

        @keyframes rotate-trionda-text {
            0%, 100% { color: var(--trionda-blue); text-shadow: 0 0 30px var(--trionda-blue); }
            33% { color: var(--trionda-red); text-shadow: 0 0 30px var(--trionda-red); }
            66% { color: var(--trionda-green); text-shadow: 0 0 30px var(--trionda-green); }
        }

        /* ======= WHITE TEXT & PITCH BLACK UI PANELS ======= */
        .selection-box, .bracket-box, .pause-box, .game-over-box, .hud-player-card, .menu-panel {
            background: rgba(5, 5, 10, 0.95) !important;
            color: #ffffff !important;
        }
        .selection-title, .bracket-title,
        .sub-column-title,
        .pause-box h2, .game-over-box h2,
        .pause-box h3, .game-over-box h3,
        .pause-box label, .game-over-box label,
        .pause-box p, .game-over-box p,
        .sub-player-name, .team-name, .team-strength,
        .bracket-team-name, .bracket-score,
        .selection-header span {
            color: #ffffff !important;
        }
        .sub-column-title {
            border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
            color: var(--neon-cyan) !important;
        }
        .sub-player-role {
            color: #00f3ff !important;
        }
        .sub-player-item {
            background: rgba(255, 255, 255, 0.05) !important;
            border: 1px solid rgba(255, 255, 255, 0.15) !important;
            color: #ffffff !important;
        }
        .sub-player-item:hover {
            background: rgba(0, 243, 255, 0.2) !important;
            border-color: var(--neon-cyan) !important;
        }
        .team-card.selected-p1 .team-name,
        .team-card.selected-p2 .team-name { color: #ffffff !important; }
        .bracket-team-row.winner { color: var(--neon-green) !important; }
        .selection-header {
            border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
        }



        .screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1), transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
            transform: scale(0.94) rotate(-2deg) translateX(30px);
            background: var(--trionda-dark);
            padding: 20px;
        }

        .screen.active {
            opacity: 1;
            pointer-events: auto;
            transform: scale(1) rotate(0deg) translateX(0px);
        }

        .menu-panel {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 15px;
            position: relative;
            z-index: 5;
            transition: opacity 0.1s ease, transform 0.1s ease;
        }

        /* Header Style */
        .neon-title {
            font-family: var(--font-sport);
            font-size: 3.6rem;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 4px;
            color: var(--trionda-white);
            text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
            margin-bottom: 5px;
            text-align: center;
            position: relative;
            z-index: 5;
        }

        .neon-subtitle {
            font-family: var(--font-sport);
            font-size: 1.6rem;
            color: var(--trionda-white);
            letter-spacing: 6px;
            text-transform: uppercase;
            margin-bottom: 30px;
            text-align: center;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
            position: relative;
            z-index: 5;
        }

        /* Buttons styling - Trionda Rotating Solid Colors */
        .btn-neon {
            font-family: var(--font-sport);
            font-size: 1.3rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 2px;
            padding: 15px 40px;
            margin: 10px;
            border: 2.5px solid var(--trionda-blue);
            background: var(--trionda-white);
            color: var(--trionda-dark);
            border-radius: 8px;
            cursor: pointer;
            transition: color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, transform 0.3s ease;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
            position: relative;
            overflow: hidden;
            min-width: 280px;
            text-align: center;
            z-index: 1;
            animation: rotate-trionda-color 6s infinite linear;
        }

        .btn-neon::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background-color: var(--trionda-blue);
            animation: rotate-trionda-bg 6s infinite linear;
            transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
            z-index: -1;
        }

        .btn-neon:hover::before {
            transform: translateX(100%);
        }

        .btn-neon:hover {
            color: var(--trionda-white);
            transform: translateY(-3px);
        }

        .btn-neon.secondary {
            border-color: var(--trionda-red);
            background: var(--trionda-white);
            color: var(--trionda-dark);
        }

        /* Elegant Pitch Black Menu Screens */
        #start-screen, #menu-screen, .screen {
            background: #050508 !important; /* Pure elegant black background */
            overflow: hidden;
        }

        .official-wc-logo {
            width: auto;
            max-width: 180px;
            height: auto;
            max-height: 200px;
            object-fit: contain;
            margin-bottom: 15px;
            filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 15px rgba(0, 243, 255, 0.35));
            animation: pulse-glow 3s infinite ease-in-out;
            position: relative;
            z-index: 5;
        }

        .menu-wc-logo {
            max-width: 120px;
            max-height: 140px;
            margin-bottom: 10px;
        }

        @keyframes pulse-glow {
            0% { transform: scale(1); filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 10px rgba(0, 243, 255, 0.3)); }
            50% { transform: scale(1.04); filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 25px rgba(0, 243, 255, 0.65)); }
            100% { transform: scale(1); filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 10px rgba(0, 243, 255, 0.3)); }
        }

        /* Central Golden Radial Gradient Spotlight behind Trophy */
        #trophy-container, .winner-trophy-spin {
            width: 100%;
            max-width: 480px;
            height: 320px;
            margin-bottom: 15px;
            position: relative;
            pointer-events: none; /* Prevent trophy container from blocking button clicks */
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2;
        }

        #trophy-container::before {
            display: none;
        }

        /* Team Selection Grid */
        .selection-box {
            background: var(--bg-card);
            border: 3px solid var(--trionda-blue);
            border-radius: 16px;
            padding: 20px;
            width: 90%;
            max-width: 1100px;
            height: 80vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(12px);
            animation: rotate-trionda-color 6s infinite linear;
            color: var(--text-dark);
        }

        .selection-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            border-bottom: 1px solid rgba(0,0,0,0.15);
            padding-bottom: 10px;
        }

        .selection-title {
            font-family: var(--font-sport);
            font-size: 1.8rem;
            color: var(--text-dark);
        }

        .team-grid-scroll {
            flex-grow: 1;
            overflow-y: auto;
            padding-right: 10px;
        }

        .team-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
            gap: 12px;
        }

        .team-card {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 8px;
            padding: 12px;
            text-align: center;
            cursor: pointer;
            transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100px;
        }

        .team-card:hover {
            transform: translateY(-5px);
            border-color: var(--fifa-cyan);
            box-shadow: 0 5px 20px rgba(99, 255, 216, 0.25);
            background: rgba(99, 255, 216, 0.08);
        }

        .team-card:hover .team-color-badge {
            border-color: var(--fifa-yellow);
            box-shadow: 0 0 10px var(--fifa-yellow);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .team-card.selected-p1 {
            border-color: var(--fifa-cyan);
            background: rgba(99, 255, 216, 0.15) !important;
            box-shadow: 0 0 20px var(--fifa-cyan);
        }

        .team-card.selected-p1::after {
            content: 'P1';
            position: absolute;
            top: 5px;
            right: 5px;
            font-family: var(--font-sport);
            font-size: 0.8rem;
            font-weight: bold;
            color: var(--fifa-black);
            background: var(--fifa-cyan);
            padding: 2px 6px;
            border-radius: 4px;
        }

        .team-card.selected-p2 {
            border-color: var(--fifa-magenta);
            background: rgba(232, 31, 99, 0.15) !important;
            box-shadow: 0 0 20px var(--fifa-magenta);
        }

        .team-card.selected-p2::after {
            content: 'P2';
            position: absolute;
            top: 5px;
            right: 5px;
            font-family: var(--font-sport);
            font-size: 0.8rem;
            font-weight: bold;
            color: var(--fifa-white);
            background: var(--fifa-magenta);
            padding: 2px 6px;
            border-radius: 4px;
        }

        .team-color-badge {
            width: 38px;
            height: 26px;
            border-radius: 4px;
            margin-bottom: 8px;
            border: 1.5px solid rgba(255, 255, 255, 0.6);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
            object-fit: cover;
            background-size: cover;
            background-position: center;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .team-name {
            font-size: 0.9rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 100%;
            color: var(--text-dark);
        }

        .team-strength {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 4px;
        }

        /* Bracket View */
        .bracket-box {
            background: var(--bg-card);
            border: 3px solid var(--trionda-blue);
            border-radius: 16px;
            padding: 20px;
            width: 95%;
            max-width: 1300px;
            height: 85vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(12px);
            animation: rotate-trionda-color 6s infinite linear;
            color: var(--text-dark);
        }

        .bracket-scroll {
            flex-grow: 1;
            overflow-x: auto;
            overflow-y: auto;
            display: flex;
            padding: 20px 10px;
            gap: 40px;
            align-items: flex-start;
            max-height: 72vh;
        }

        .bracket-column {
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            height: 100%;
            min-width: 180px;
            gap: 15px;
        }

        .bracket-match {
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 6px;
            padding: 8px 12px;
            display: flex;
            flex-direction: column;
            gap: 4px;
            position: relative;
        }

        .bracket-match.playable {
            border-color: var(--neon-cyan);
            box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
            background: rgba(0, 243, 255, 0.03);
            animation: pulse-border 1.5s infinite ease-in-out;
        }

        @keyframes pulse-border {
            0% { border-color: rgba(0, 243, 255, 0.4); }
            50% { border-color: rgba(0, 243, 255, 1); }
            100% { border-color: rgba(0, 243, 255, 0.4); }
        }

        .bracket-team-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.8rem;
        }

        .bracket-team-row.winner {
            font-weight: bold;
            color: var(--neon-green);
        }

        .bracket-team-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 120px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .bracket-dot {
            width: 20px;
            height: 14px;
            border-radius: 2px;
            object-fit: cover;
            border: 1px solid rgba(255, 255, 255, 0.4);
        }

        .bracket-score {
            font-family: var(--font-sport);
            font-size: 0.9rem;
        }

        /* Playing HUD */
        #hud-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 20px;
            opacity: 0;
            transition: opacity 0.5s ease;
        }

        #hud-container.active {
            opacity: 1;
        }

        /* Scoreboard */
        .scoreboard {
            align-self: center;
            background: rgba(10, 10, 25, 0.9);
            border: 2px solid var(--neon-cyan);
            border-radius: 12px;
            padding: 10px 30px;
            display: flex;
            align-items: center;
            gap: 30px;
            box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
            pointer-events: auto;
        }

        .sb-team {
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 150px;
        }

        .sb-team.left {
            justify-content: flex-end;
            text-align: right;
        }

        .sb-team.right {
            justify-content: flex-start;
            text-align: left;
        }

        .sb-team-name {
            font-family: var(--font-sport);
            font-size: 1.4rem;
            font-weight: 700;
            letter-spacing: 1px;
            text-transform: uppercase;
        }

        .sb-team-dot {
            width: 24px;
            height: 16px;
            border-radius: 3px;
            border: 1.5px solid #fff;
            box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
            object-fit: cover;
        }

        .sb-team-expelled {
            font-size: 0.75rem;
            background: var(--neon-red);
            color: #fff;
            padding: 1px 5px;
            border-radius: 4px;
            font-weight: bold;
            margin: 0 5px;
            letter-spacing: 0.5px;
        }

        .sb-score-container {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .sb-score {
            font-family: var(--font-sport);
            font-size: 2.5rem;
            font-weight: 800;
            color: #fff;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
        }

        .sb-divider {
            color: var(--neon-cyan);
            font-size: 1.5rem;
            font-weight: bold;
        }

        .sb-time-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            border-left: 1px solid rgba(255, 255, 255, 0.15);
            padding-left: 20px;
        }

        .sb-time {
            font-family: var(--font-sport);
            font-size: 1.8rem;
            font-weight: bold;
            color: var(--neon-yellow);
        }

        .sb-period {
            font-size: 0.7rem;
            text-transform: uppercase;
            color: var(--text-muted);
            letter-spacing: 1px;
        }

        /* Active AI Tactical Play Indicator */
        .hud-active-play {
            position: absolute;
            top: 78px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(20, 22, 30, 0.85);
            border: 1px solid rgba(255, 204, 0, 0.5);
            color: #ffcc00;
            font-size: 12px;
            letter-spacing: 0.5px;
            padding: 4px 12px;
            border-radius: 6px;
            font-family: 'Arial', sans-serif;
            font-weight: 700;
            text-transform: none;
            white-space: nowrap;
            pointer-events: none;
            box-shadow: 0 0 8px rgba(255, 204, 0, 0.18);
            min-height: 22px;
            visibility: hidden;
        }
        .hud-active-play.has-play { visibility: visible; }

        /* Active Player HUD Panels */
        .hud-player-panels {
            display: flex;
            justify-content: space-between;
            width: 100%;
        }

        .hud-player-card {
            background: rgba(10, 10, 18, 0.92);
            border: 2px solid var(--trionda-blue);
            border-radius: 8px;
            padding: 8px 12px;
            width: 170px;
            display: flex;
            flex-direction: column;
            gap: 4px;
            box-shadow: 0 0 15px rgba(0,0,0,0.5);
            backdrop-filter: blur(12px);
            animation: rotate-trionda-color 6s infinite linear;
        }

        .hud-player-card.p1-side {
            border-left: 4px solid var(--fifa-cyan);
        }

        .hud-player-card.p2-side {
            border-left: 4px solid var(--fifa-magenta);
        }

        .hud-pcard-header, .hud-pcard-name {
            display: none !important;
        }

        .hud-pcard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .hud-pcard-num {
            font-family: var(--font-sport);
            font-weight: 700;
            font-size: 1rem;
            color: var(--text-muted);
        }

        .hud-pcard-role {
            font-size: 0.75rem;
            background: rgba(255, 255, 255, 0.1);
            padding: 1px 6px;
            border-radius: 4px;
            text-transform: uppercase;
        }

        .hud-pcard-name {
            font-weight: 600;
            font-size: 1.1rem;
        }

        .stamina-bar-container {
            width: 100%;
            height: 10px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 5px;
            overflow: hidden;
            position: relative;
        }

        .stamina-bar {
            height: 100%;
            width: 100%;
            background: linear-gradient(90deg, var(--trionda-green), #38ef7d);
            border-radius: 5px;
            transition: width 0.1s ease, background 0.3s ease;
        }

        .stamina-bar.low {
            background: linear-gradient(90deg, var(--trionda-red), #ff4d4d);
        }

        /* Confetti / Goal Screen Overlay - Trionda Rotating Solid Colors */
        #announcement-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 100;
            background: rgba(5, 5, 8, 0.94);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
            backdrop-filter: blur(12px);
        }

        #announcement-overlay.active {
            opacity: 1;
        }

        .announcement-text {
            font-family: var(--font-sport);
            font-size: 7.5rem;
            font-weight: 900;
            animation: rotate-trionda-text 3s infinite linear, bounce-text 0.8s infinite alternate cubic-bezier(0.175, 0.885, 0.32, 1.275);
            text-transform: uppercase;
            letter-spacing: 6px;
        }

        @keyframes bounce-text {
            0% { transform: scale(0.85); }
            100% { transform: scale(1.12); }
        }

        .announcement-subtext {
            font-size: 2rem;
            font-weight: 600;
            color: #fff;
            margin-top: 10px;
            text-shadow: 0 0 10px rgba(255,255,255,0.5);
        }

        /* Referee Whistle / Card Popups */
        #referee-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 100;
            background: rgba(5, 5, 10, 0.85);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
            backdrop-filter: blur(5px);
        }

        #referee-overlay.active {
            opacity: 1;
        }

        .referee-title {
            font-family: var(--font-sport);
            font-size: 3rem;
            color: var(--card-yellow);
            text-transform: uppercase;
            letter-spacing: 2px;
            margin-bottom: 20px;
            text-shadow: 0 0 15px rgba(255, 230, 0, 0.6);
        }

        .card-visual {
            width: 130px;
            height: 200px;
            border-radius: 12px;
            box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
            transform: rotate(-10deg) scale(0.5);
            transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        #referee-overlay.active .card-visual {
            transform: rotate(5deg) scale(1.2);
        }

        .card-visual.yellow-card {
            background: var(--card-yellow);
            border: 4px solid #fff;
            box-shadow: 0 0 35px var(--card-yellow);
        }

        .card-visual.red-card {
            background: var(--card-red);
            border: 4px solid #fff;
            box-shadow: 0 0 35px var(--card-red);
        }

        .referee-desc {
            margin-top: 30px;
            font-size: 1.5rem;
            font-weight: 600;
            text-align: center;
        }

        /* Pause Screen & Substitution Menu */
        .pause-box {
            background: rgba(10, 12, 26, 0.95);
            border: 3px solid var(--trionda-blue);
            border-radius: 16px;
            padding: 24px 30px;
            width: 92%;
            max-width: 950px;
            max-height: 85vh;
            box-shadow: 0 0 45px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 243, 255, 0.05);
            backdrop-filter: blur(14px);
            display: flex;
            flex-direction: column;
            gap: 16px;
            box-sizing: border-box;
            animation: rotate-trionda-color 6s infinite linear;
        }
        
        .pause-box h2, .game-over-box h2 {
            color: var(--text-dark);
        }

        .sub-menu-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 25px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding: 14px 0;
            min-height: 0;
            flex: 1;
            overflow: hidden;
        }

        .sub-column {
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-height: 0;
            overflow: hidden;
        }

        .sub-column-title {
            font-family: var(--font-sport);
            font-size: 1.15rem;
            color: var(--fifa-cyan);
            border-bottom: 1px solid rgba(99, 255, 216, 0.25);
            padding-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .sub-roster-scroll {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 48vh;
            overflow-y: auto;
            padding-right: 8px;
        }

        .sub-roster-scroll::-webkit-scrollbar {
            width: 6px;
        }
        .sub-roster-scroll::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.04);
            border-radius: 3px;
        }
        .sub-roster-scroll::-webkit-scrollbar-thumb {
            background: var(--fifa-cyan);
            border-radius: 3px;
            box-shadow: 0 0 6px var(--fifa-cyan);
        }

        .sub-player-item {
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.09);
            border-radius: 8px;
            padding: 8px 12px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: all 0.2s ease;
            user-select: none;
        }

        .sub-player-item:hover {
            border-color: var(--fifa-cyan);
            background: rgba(99, 255, 216, 0.08);
            transform: translateX(2px);
        }

        .sub-player-item.selected {
            border-color: var(--fifa-magenta) !important;
            background: rgba(232, 31, 99, 0.2) !important;
            box-shadow: 0 0 12px var(--fifa-magenta);
        }

        .sub-player-info {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .sub-player-name {
            font-weight: 700;
            font-size: 0.92rem;
            color: #ffffff;
        }

        .sub-player-role {
            font-size: 0.75rem;
            color: var(--fifa-cyan);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .sub-player-stamina-text {
            font-family: var(--font-sport);
            font-size: 0.88rem;
            font-weight: bold;
            padding: 2px 6px;
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        /* Penalty Shootout Kick HUD */
        #penalty-kicker-hud {
            position: absolute;
            bottom: 40px;
            left: 50%;
            transform: translateX(-50%);
            width: 320px;
            background: rgba(10, 10, 25, 0.9);
            border: 2px solid var(--fifa-cyan);
            border-radius: 12px;
            padding: 15px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            box-shadow: 0 0 20px rgba(99, 255, 216, 0.3);
            pointer-events: auto;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
            z-index: 50;
        }

        #penalty-kicker-hud.active {
            opacity: 1;
            pointer-events: auto;
        }

        .penalty-instructions {
            font-size: 0.9rem;
            text-align: center;
            color: var(--text-muted);
        }

        .penalty-instructions span {
            color: var(--fifa-yellow);
            font-weight: bold;
        }

        .power-bar-bg {
            width: 100%;
            height: 25px;
            background: linear-gradient(90deg, var(--fifa-cyan) 0%, var(--fifa-green) 50%, var(--fifa-red) 100%);
            border-radius: 6px;
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        /* Sin transition: el bucle de apuntado ya escribe la posición en CADA
           fotograma, así que una transición sólo añade un retardo que persigue al
           valor real y se ve como si la barra fuera a tirones. */
        .power-bar-slider {
            position: absolute;
            top: 0;
            left: 0;
            width: 6px;
            height: 100%;
            background: #fff;
            box-shadow: 0 0 10px #fff;
            will-change: left;
        }

        /* Panel de mira y fuerza del pateador. Hereda la columna del HUD para que,
           al envolverlo, las barras conserven la misma separación de antes. */
        #penalty-aim-panel {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            width: 100%;
        }

        /* Barra de dirección del penal: los extremos son los palos, el centro el
           medio del arco. Más apagada que la de fuerza para que no compitan. */
        .penalty-aim-bg {
            width: 100%;
            height: 18px;
            background: linear-gradient(90deg,
                rgba(0, 243, 255, 0.35) 0%,
                rgba(255, 255, 255, 0.20) 50%,
                rgba(189, 0, 255, 0.35) 100%);
            border-radius: 6px;
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        /* Tapa la parte NO cargada de la barra de fuerza, desde la derecha: lo que
           queda a la vista del degradado es la carga actual. */
        .power-bar-mask {
            position: absolute;
            top: 0;
            right: 0;
            height: 100%;
            width: 55%;
            background: rgba(6, 8, 20, 0.85);
            will-change: width;
        }

        .penalty-bar-row {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            font-size: 0.7rem;
            letter-spacing: 1px;
            color: var(--text-muted);
        }

        .penalty-bar-name {
            flex: 1;
        }

        .penalty-bar-key {
            color: var(--fifa-yellow);
            font-weight: bold;
        }

        .penalty-bar-val {
            color: #fff;
            font-weight: bold;
        }

        /* Game Over Screen */
        .game-over-box {
            background: var(--bg-card);
            border: 3px solid var(--trionda-blue);
            border-radius: 16px;
            padding: 40px;
            width: 90%;
            max-width: 600px;
            text-align: center;
            box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(12px);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 25px;
            animation: rotate-trionda-color 6s infinite linear;
        }

        .winner-trophy-spin {
            width: 180px;
            height: 180px;
            background: radial-gradient(circle, rgba(255,215,0,0.25) 0%, transparent 70%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
            position: relative;
            overflow: hidden;
        }

        .go-title {
            font-family: var(--font-sport);
            font-size: 3.5rem;
            color: var(--neon-cyan);
            text-transform: uppercase;
        }

        .go-subtitle {
            font-size: 1.4rem;
            color: #fff;
            font-weight: 600;
        }

        .go-stats {
            display: flex;
            flex-direction: column;
            gap: 10px;
            width: 100%;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding: 20px 0;
            margin: 10px 0;
        }

        .go-stat-row {
            display: flex;
            justify-content: space-between;
            font-size: 1.1rem;
            width: 100%;
        }

        .go-stat-label {
            color: var(--text-muted);
        }

        .go-stat-val {
            font-weight: bold;
            font-family: var(--font-sport);
        }

        /* Penalty Rounds Overlay */
        .penalty-rounds-hud {
            display: flex;
            gap: 10px;
            margin-top: 10px;
        }

        .penalty-dot {
            width: 15px;
            height: 15px;
            border-radius: 50%;
            border: 2px solid rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.1);
        }

        .penalty-dot.goal {
            background: var(--neon-green);
            border-color: var(--neon-green);
            box-shadow: 0 0 8px var(--neon-green);
        }

        .penalty-dot.miss {
            background: var(--neon-red);
            border-color: var(--neon-red);
            box-shadow: 0 0 8px var(--neon-red);
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        ::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb {
            background: var(--neon-cyan);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: var(--neon-purple);
        }


        /* Particle canvas for button hover effects */
        #btn-particles-canvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 9999;
            opacity: 0;
            transition: opacity 0.2s;
        }
        #btn-particles-canvas.active {
            opacity: 1;
        }

        #win-fireworks-canvas {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            pointer-events: none;
            z-index: 8500;
            display: none;
        }
        #win-fireworks-canvas.active { display: block; }

        /* Half-Time Overlay */
        #halftime-overlay {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(10, 14, 26, 0.96);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 9000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.5s ease;
        }
        #halftime-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }
        .halftime-title {
            font-family: 'Rajdhani', sans-serif;
            font-size: 3.5rem;
            font-weight: 900;
            color: #ffe600;
            text-transform: uppercase;
            letter-spacing: 6px;
            margin-bottom: 10px;
            text-shadow: 0 0 20px rgba(255,230,0,0.5);
        }
        .halftime-score {
            font-family: 'Rajdhani', sans-serif;
            font-size: 2rem;
            color: #ffffff;
            margin-bottom: 40px;
            letter-spacing: 4px;
        }
        .halftime-buttons {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            justify-content: center;
        }
        /* FIFA Text Transition Overlay */
        #fifa-transition-overlay {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0, 0, 0, 0.92);
            z-index: 10000;
            display: none;
            align-items: center;
            justify-content: center;
        }

        /* ============================================================
           MATCH VS LOADING SCREEN (5s Loading with Team Crests & 3D Trophy)
           ============================================================ */
        #match-loading-screen {
            position: fixed;
            top: 0; left: 0;
            width: 100vw; height: 100vh;
            background: radial-gradient(circle at center, #0c1220 0%, #030508 100%) !important;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: space-between;
            padding: 50px 30px;
            z-index: 12000;
            overflow: hidden;
        }

        #match-loading-screen.active {
            display: flex !important;
        }

        .vs-loading-header {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 10px;
            text-align: center;
        }

        #vs-loading-subtitle {
            font-family: var(--font-sport);
            font-size: 1.2rem;
            color: var(--trionda-blue);
            letter-spacing: 4px;
            text-transform: uppercase;
            margin-bottom: 5px;
            text-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
        }

        #vs-loading-title {
            font-family: var(--font-sport);
            font-size: 2.8rem;
            font-weight: 900;
            color: #ffffff;
            letter-spacing: 6px;
            text-transform: uppercase;
            text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 223, 0, 0.4);
            margin: 0;
        }

        .vs-matchup-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 60px;
            width: 100%;
            max-width: 1000px;
            margin: auto;
        }

        .vs-team-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 280px;
        }

        .vs-crest-wrapper {
            width: 160px;
            height: 160px;
            display: flex;
            align-items: center;
            justify-content: center;
            filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 20px rgba(0, 243, 255, 0.35));
            transition: transform 0.3s ease;
        }

        .vs-crest-wrapper img {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
        }

        .vs-team-name-row {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-top: 18px;
            font-family: var(--font-sport);
            font-size: 1.8rem;
            font-weight: 900;
            color: #ffffff;
            text-transform: uppercase;
            letter-spacing: 2px;
            text-shadow: 0 4px 15px rgba(0, 0, 0, 0.9);
        }

        .vs-team-badge {
            margin-top: 10px;
            font-size: 0.85rem;
            padding: 5px 18px;
            border-radius: 12px;
            font-weight: 800;
            background: rgba(0, 243, 255, 0.15);
            border: 1.5px solid var(--trionda-blue);
            color: var(--neon-cyan);
            letter-spacing: 2px;
            text-transform: uppercase;
        }

        .vs-center-badge {
            width: 95px;
            height: 95px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: radial-gradient(circle, #e6005c 0%, #7a0026 100%);
            border-radius: 50%;
            border: 3px solid #ff0055;
            box-shadow: 0 0 35px rgba(255, 0, 85, 0.7);
            flex-shrink: 0;
            animation: pulse-vs-glow 2s infinite ease-in-out;
        }

        @keyframes pulse-vs-glow {
            0% { transform: scale(1); box-shadow: 0 0 25px rgba(255, 0, 85, 0.6); }
            50% { transform: scale(1.08); box-shadow: 0 0 45px rgba(255, 0, 85, 0.9); }
            100% { transform: scale(1); box-shadow: 0 0 25px rgba(255, 0, 85, 0.6); }
        }

        .vs-text {
            font-family: var(--font-sport);
            font-size: 2.6rem;
            font-weight: 900;
            color: #ffffff;
            font-style: italic;
            text-shadow: 0 0 12px #ffffff;
        }

        .vs-loading-corner {
            position: absolute;
            bottom: 25px;
            left: 30px;
            display: flex;
            align-items: center;
            gap: 16px;
            z-index: 10;
        }

        #vs-trophy-canvas-container {
            width: 100px;
            height: 140px;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            border-radius: 0 !important;
            overflow: visible;
            display: flex;
            align-items: center;
            justify-content: center;
            filter: drop-shadow(0 0 15px rgba(255, 223, 0, 0.6)) drop-shadow(0 0 25px rgba(0, 243, 255, 0.4));
        }

        .vs-loading-info {
            display: flex;
            flex-direction: column;
        }

        .vs-loading-label {
            font-family: var(--font-sport);
            font-size: 0.95rem;
            color: #ffffff;
            font-weight: 800;
            letter-spacing: 2px;
            text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
            margin-bottom: 6px;
        }

        .vs-progress-track {
            width: 220px;
            height: 7px;
            background: rgba(255, 255, 255, 0.15);
            border-radius: 4px;
            overflow: hidden;
            border: 1px solid rgba(0, 243, 255, 0.3);
        }

        .vs-progress-bar {
            width: 0%;
            height: 100%;
            background: linear-gradient(to right, #00f3ff, #ffdf00);
            border-radius: 4px;
        }

        #fifa-transition-overlay.active {
            display: flex;
            pointer-events: all;
        }
        #fifa-transition-canvas {
            width: 100vw;
            height: 100vh;
        }

        /* ============================================================
           BARRA DE COMENTARISTAS (subtítulo de la narración)
           Se sienta sobre el HUD inferior, sin robarle clics a nada.
           ============================================================ */
        #comentario-barra {
            position: fixed;
            left: 50%;
            bottom: 92px;
            transform: translateX(-50%) translateY(14px);
            max-width: min(880px, 90vw);
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 9px 20px 9px 14px;
            background: linear-gradient(90deg, rgba(0, 8, 20, 0.95), rgba(4, 12, 28, 0.88));
            border-left: 4px solid var(--neon-cyan);
            border-radius: 6px;
            box-shadow: 0 6px 26px rgba(0, 0, 0, 0.7), 0 0 18px rgba(0, 243, 255, 0.18);
            backdrop-filter: blur(8px);
            font-family: var(--font-main);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.22s ease, transform 0.22s ease;
            z-index: 9500;
        }

        #comentario-barra.visible {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        /* El analista se distingue por color: cian el relator, morado el analista */
        #comentario-barra.analista {
            border-left-color: var(--neon-purple);
            box-shadow: 0 6px 26px rgba(0, 0, 0, 0.7), 0 0 18px rgba(189, 0, 255, 0.18);
        }

        #comentario-quien {
            flex: 0 0 auto;
            font-family: var(--font-sport);
            font-size: 0.68rem;
            font-weight: 700;
            letter-spacing: 2px;
            color: var(--neon-cyan);
            text-transform: uppercase;
            padding: 3px 9px;
            border: 1px solid rgba(0, 243, 255, 0.45);
            border-radius: 4px;
            white-space: nowrap;
        }

        #comentario-barra.analista #comentario-quien {
            color: var(--neon-purple);
            border-color: rgba(189, 0, 255, 0.45);
        }

        #comentario-texto {
            font-size: 0.98rem;
            font-weight: 500;
            line-height: 1.35;
            color: #ffffff;
            text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
        }

        @media (max-width: 700px) {
            #comentario-barra {
                bottom: 74px;
                padding: 7px 14px 7px 10px;
            }
            #comentario-texto { font-size: 0.85rem; }
        }