/*
 * style.css — Traffic Racer: Peru Ultimate
 * Secciones:
 *   BASE · CHICHA · HUD · SEMÁFORO · AVISOS · FRENO
 *   MENÚS · BOTONES · LEADERBOARD · INPUT · RANGO
 *   CRASH FX · ANIMACIONES · VISIÓN (CV) · RESPONSIVE
 */
        body {
            margin: 0;
            overflow: hidden;
            background-color: #87CEEB;
            font-family: 'Nunito', sans-serif;
            touch-action: none;
            user-select: none;
        }

        #game-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 1;
        }

        .ui-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 10;
        }

        .hidden {
            display: none !important;
            pointer-events: none;
        }

        /* UI CHICHA */
        .chicha-panel {
            background: linear-gradient(45deg, rgba(255, 0, 85, 0.8), rgba(255, 170, 0, 0.8));
            border: 3px solid rgba(204, 255, 0, 0.9);
            box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(2px);
            color: #fff;
            transform: skewX(-5deg);
            text-shadow: 2px 2px 0 #000;
        }

        .score-panel {
            padding: 8px 15px;
            border-radius: 5px;
            font-size: 1.5rem;
            font-family: 'Bangers', cursive;
            margin-bottom: 10px;
        }

        /* INPUT Y RANKING */
        .chicha-input {
            background: #fff;
            border: 4px solid #ff0055;
            color: #000;
            font-family: 'Bangers', cursive;
            font-size: 2rem;
            text-align: center;
            padding: 10px;
            width: 80%;
            max-width: 300px;
            transform: rotate(-2deg);
            box-shadow: 5px 5px 0 #000;
            outline: none;
            margin-bottom: 15px;
            text-transform: uppercase;
        }

        .chicha-input:focus {
            background: #ffffcc;
            transform: rotate(0deg) scale(1.05);
        }

        .leaderboard-box {
            background: rgba(0, 0, 0, 0.9);
            border: 4px solid #00ccff;
            box-shadow: 8px 8px 0 #ff0055;
            padding: 15px;
            width: 90%;
            max-width: 400px;
            margin-top: 20px;
            max-height: 200px;
            overflow-y: auto;
            transform: rotate(1deg);
        }

        .leaderboard-title {
            color: #ffff00;
            font-family: 'Bangers', cursive;
            font-size: 1.8rem;
            text-align: center;
            text-shadow: 2px 2px 0 #ff0000;
            margin-bottom: 10px;
            text-transform: uppercase;
        }

        .leaderboard-list {
            list-style: none;
            padding: 0;
            margin: 0;
            font-family: 'Nunito', sans-serif;
            font-weight: 800;
            color: white;
            font-size: 1rem;
        }

        .leaderboard-item {
            display: flex;
            justify-content: space-between;
            padding: 5px 10px;
            border-bottom: 2px dashed #555;
        }

        .leaderboard-item:nth-child(1) {
            color: #ffff00;
            text-shadow: 0 0 10px #ffff00;
            font-size: 1.2rem;
        }

        .leaderboard-item:nth-child(2) {
            color: #cccccc;
        }

        .leaderboard-item:nth-child(3) {
            color: #cd7f32;
        }

        /* RANGO BADGE */
        .rank-badge {
            background: linear-gradient(to bottom, #00ccff, #0000ff);
            border: 6px solid #ffff00;
            box-shadow: 8px 8px 0px #000000;
            transform: rotate(-2deg);
            padding: 15px 20px;
            margin: 20px 0;
            animation: pulse-rank 1s infinite alternate;
            text-align: center;
        }

        @keyframes pulse-rank {
            from {
                transform: rotate(-2deg) scale(1);
            }

            to {
                transform: rotate(-2deg) scale(1.05);
            }
        }

        .rank-label {
            color: #ffff00;
            font-family: 'Nunito', sans-serif;
            font-weight: 900;
            font-size: 1.2rem;
            text-transform: uppercase;
            text-shadow: 2px 2px 0 #000;
            margin-bottom: 5px;
        }

        .rank-title {
            font-family: 'Bangers', cursive;
            font-size: 3.5rem;
            line-height: 1;
            color: #ffffff;
            -webkit-text-stroke: 2px black;
            text-shadow: 4px 4px 0 #ff0055;
        }

        /* HUD MEJORADO PARA MOBILE */
        .hud-top {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            display: grid;
            grid-template-columns: 1fr auto 1fr; /* Izquierda, Centro, Derecha */
            align-items: start;
            padding: 15px;
            pointer-events: none;
            z-index: 10;
        }

        .score-container {
            display: flex;
            flex-direction: column;
            gap: 5px;
            transform-origin: top left;
            transform: scale(0.85);
            justify-self: start;
        }

        .score-panel {
            padding: 5px 10px;
            border-radius: 5px;
            font-size: 1.2rem;
            font-family: 'Bangers', cursive;
            text-shadow: 1px 1px 0 #000;
        }

        /* --- SEMÁFORO (GRID CENTRADO) --- */
        .traffic-light {
            background: #222;
            padding: 10px;
            border-radius: 12px;
            display: flex;
            gap: 8px;
            border: 4px solid #ffcc00;
            box-shadow: 0 8px 15px rgba(0,0,0,0.6);
            transform: scale(1.5); /* Grande en PC */
            transform-origin: top center;
            justify-self: center; /* Centrado en su celda del grid */
            margin-top: 5px;
        }

        /* Ajustes para móviles */
        @media (max-width: 768px) {
            .traffic-light {
                transform: scale(1.1); /* Un poco más chico en móvil para que quepa */
                margin-top: 0;
            }
            .score-container {
                transform: scale(0.75); /* Reducir un poco el score si es necesario */
            }
            .hud-top {
                padding: 10px;
                gap: 5px;
            }
        }

        .light {
            width: 25px;
            height: 25px;
            border-radius: 50%;
            background: #444;
            border: 2px solid rgba(0, 0, 0, 0.2);
            transition: 0.2s;
        }

        .light.red.active {
            background: #ff0000;
            box-shadow: 0 0 15px #ff0000;
            transform: scale(1.1);
        }

        .light.yellow.active {
            background: #ffdd00;
            box-shadow: 0 0 15px #ffdd00;
            transform: scale(1.1);
        }

        .light.green.active {
            background: #00ff00;
            box-shadow: 0 0 15px #00ff00;
            transform: scale(1.1);
        }

        /* MUTE BTN Wrapper */
        .mute-wrapper {
            justify-self: end;
            pointer-events: auto;
        }

        /* AVISOS */
        .warning-msg {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            font-family: 'Bangers', cursive;
            text-shadow: 3px 3px 0 black;
            z-index: 15;
            pointer-events: none;
            white-space: nowrap;
        }

        #trainWarning {
            top: 180px;
            background: #ff0000;
            color: yellow;
            padding: 10px 30px;
            font-size: 2.5rem;
            border: 5px solid yellow;
            box-shadow: 5px 5px 0 black;
            animation: blink 0.2s infinite alternate;
            display: none;
        }
        
        #curveWarning {
            top: 250px;
            color: #ffff00;
            font-size: 4rem;
            text-shadow: 4px 4px 0 #000;
            text-stroke: 2px #000;
            -webkit-text-stroke: 2px #000;
            display: none;
            animation: slideIn 0.5s ease-out;
        }

        #yellowAlert {
            top: 160px; /* Debajo del semáforo */
            font-size: 3.5rem;
            color: #ffff00;
            text-shadow: 4px 4px 0 #000;
            display: none;
            animation: blink 0.3s infinite alternate;
            width: 100%;
            text-align: center;
        }

        @keyframes slideIn {
            from { transform: translateX(-200%) skewX(-20deg); opacity: 0; }
            to { transform: translateX(-50%) skewX(0deg); opacity: 1; }
        }

        #bonusMsg {
            position: absolute;
            top: 300px;
            left: 50%;
            transform: translateX(-50%);
            font-family: 'Bangers', cursive;
            font-size: 4rem;
            color: #00ff00;
            text-shadow: 3px 3px 0 #000, 0 0 20px #00ff00;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.5s;
            width: 100%;
            text-align: center;
        }

        #collisionMsg {
            position: absolute;
            top: 300px;
            left: 50%;
            transform: translateX(-50%);
            font-family: 'Bangers', cursive;
            font-size: 4rem;
            color: #ff0000;
            text-shadow: 3px 3px 0 #000, 0 0 20px #ff0000;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.5s;
            width: 100%;
            text-align: center;
        }

        #weatherMsg {
            position: absolute;
            top: 150px;
            left: 50%;
            transform: translateX(-50%);
            font-family: 'Bangers', cursive;
            font-size: 3rem;
            color: #aaddff;
            text-shadow: 3px 3px 0 #000;
            pointer-events: none;
            opacity: 0;
            transition: opacity 1s;
            width: 100%;
            text-align: center;
        }

        #nitroOverlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, transparent 50%, rgba(0, 100, 255, 0.3) 100%);
            pointer-events: none;
            display: none;
            z-index: 5;
            mix-blend-mode: screen;
        }

        @keyframes blink {
            from {
                transform: translateX(-50%) scale(1) rotate(-2deg);
            }

            to {
                transform: translateX(-50%) scale(1.1) rotate(2deg);
            }
        }

        /* CONTROLES */
        .brake-container {
            position: absolute;
            bottom: 10px;
            left: 10px;
            z-index: 15;
            pointer-events: auto;
            touch-action: none;
        }

        .brake-btn {
            width: 90px;
            height: 90px;
            background: linear-gradient(to bottom, #ff0000, #990000);
            border-radius: 15px;
            border: 3px solid #ffff00;
            color: yellow;
            font-family: 'Bangers', cursive;
            font-size: 1.1rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            box-shadow: 3px 3px 0px #000;
            transition: 0.1s;
            cursor: pointer;
            text-shadow: 1px 1px 0 #000;
            -webkit-tap-highlight-color: transparent;
        }

        .brake-btn span {
            font-size: 2.5rem;
            margin-bottom: -5px;
        }

        .brake-btn:active,
        .brake-btn.pressed {
            transform: translate(3px, 3px);
            box-shadow: none;
            background: #cc0000;
        }

        /* MENUS */
        .overlay-bg {
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(5px);
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            text-align: center;
            border: 10px solid #ccff00;
            box-sizing: border-box;
            overflow-y: auto;
            padding: 20px;
        }

        .title-chicha {
            font-family: 'Bangers', cursive;
            font-size: 4rem;
            color: #ff0066;
            text-shadow: 4px 4px 0 #ffff00, 8px 8px 0 #000;
            transform: rotate(-3deg);
            margin-bottom: 20px;
            line-height: 1;
            margin-top: 10px;
        }

        .info-card {
            background: #fff;
            padding: 20px;
            border: 4px solid #000;
            box-shadow: 10px 10px 0 #ff0066;
            margin-bottom: 20px;
            color: #000;
            font-weight: bold;
            transform: rotate(1deg);
            max-width: 85%;
            text-align: left;
            font-size: 1rem;
        }

        .btn-container {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 20px;
            margin-bottom: 20px;
        }

        @keyframes heartbeat {
            0% {
                transform: scale(1);
                box-shadow: 5px 5px 0 #ff0066;
            }

            50% {
                transform: scale(1.05);
                box-shadow: 5px 5px 15px #ff0066;
                filter: brightness(1.1);
            }

            100% {
                transform: scale(1);
                box-shadow: 5px 5px 0 #ff0066;
            }
        }

        .btn-start {
            background: #ccff00;
            border: 4px solid #000;
            color: #000;
            padding: 12px 25px;
            font-size: 1.3rem;
            font-family: 'Bangers', cursive;
            cursor: pointer;
            box-shadow: 5px 5px 0 #ff0066;
            text-transform: uppercase;
            margin: 5px;
            position: relative;
            animation: heartbeat 1.5s infinite ease-in-out;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }

        .btn-start:active {
            animation: none;
            transform: translate(4px, 4px) scale(0.98);
            box-shadow: 1px 1px 0 #ff0066;
        }

        .btn-hard {
            background: #ff3300;
            color: #f9f3f3;
            border-color: #ffff00;
            box-shadow: 5px 5px 0 #000000;
            animation: heartbeat 1.5s infinite ease-in-out reverse;
        }

        .btn-hard:active {
            box-shadow: 1px 1px 0 #000;
        }

        .crash-anim {
            animation: crash-flash 0.2s infinite;
        }

        @keyframes crash-flash {
            0% {
                background-color: rgba(255, 0, 0, 0.5);
            }

            50% {
                background-color: rgba(255, 255, 255, 0.8);
            }

            100% {
                background-color: rgba(255, 0, 0, 0.5);
            }
        }

        .crash-text-anim {
            animation: text-pop 0.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        @keyframes text-pop {
            0% {
                transform: scale(0) rotate(0deg);
                opacity: 0;
            }

            50% {
                transform: scale(1.5) rotate(-15deg);
                opacity: 1;
            }

            100% {
                transform: scale(1) rotate(-15deg);
                opacity: 1;
            }
        }

        #gameOverScreen .btn-start {
            padding: 15px 10px;
            font-size: 1.4rem;
        }

        /* CONTROL POR VISIÓN (TIMÓN) */
        #cv-container {
            position: fixed;
            bottom: 10px;
            right: 10px;
            z-index: 100;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            gap: 5px;
            pointer-events: auto;
        }

        #cv-canvas {
            width: 160px;
            height: 120px;
            border: 3px solid #ccff00;
            border-radius: 8px;
            box-shadow: 3px 3px 0 #000;
            transform: scaleX(-1);
            background: #000;
        }

        #cv-status {
            font-family: 'Bangers', cursive;
            font-size: 1rem;
            color: #ccff00;
            text-shadow: 1px 1px 0 #000;
            background: rgba(0,0,0,0.7);
            padding: 3px 8px;
            border-radius: 4px;
            text-align: right;
        }

        #steering-indicator {
            font-family: 'Bangers', cursive;
            font-size: 3.5rem;
            line-height: 1;
            filter: drop-shadow(2px 2px 0 #000);
            transition: transform 0.1s;
        }

        #cv-toggle-btn {
            pointer-events: auto;
            background: linear-gradient(to bottom, #ccff00, #88aa00);
            border: 3px solid #000;
            border-radius: 6px;
            padding: 4px 10px;
            font-family: 'Bangers', cursive;
            font-size: 1rem;
            cursor: pointer;
            box-shadow: 2px 2px 0 #000;
            color: #000;
        }
        #cv-toggle-btn:active { transform: translate(2px,2px); box-shadow: none; }
