/* ============================================
   COCHES LOCOS · Bumper Arena
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #07071a;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(233,30,99,0.15), transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(0,229,255,0.12), transparent 50%),
        #07071a;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============ Pantallas ============ */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: rgba(7, 7, 26, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.screen.active { display: flex; }

/* ============ Selección de personaje ============ */
.title-block {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #00e5ff 0%, #ff4081 50%, #ffd700 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 30px rgba(255,64,129,0.5));
    animation: titlePulse 3s ease-in-out infinite;
}

.subtitle {
    color: #aaa;
    font-size: 1.1rem;
    letter-spacing: 6px;
    margin-top: 4px;
    text-transform: uppercase;
}

.select-prompt {
    font-size: 1.3rem;
    color: #ddd;
    font-weight: 300;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.characters {
    display: flex;
    gap: 22px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.character-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 22px 18px;
    width: 210px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    backdrop-filter: blur(4px);
    position: relative;
}

.character-card:hover {
    transform: translateY(-10px);
    border-color: rgba(255,255,255,0.25);
    box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}

.character-portrait {
    width: 170px;
    height: 190px;
    margin: 0 auto 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 30%, rgba(255,255,255,0.08), rgba(0,0,0,0.25));
    border: 1px solid rgba(255,255,255,0.08);
}

.character-portrait::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.02) 0px,
        rgba(255,255,255,0.02) 8px,
        transparent 8px,
        transparent 16px
    );
    pointer-events: none;
}

.character-canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
}

.character-portrait.yago {
    box-shadow: inset 0 0 40px rgba(25,118,210,0.35);
}
.character-portrait.inside {
    box-shadow: inset 0 0 40px rgba(46,125,50,0.35);
}
.character-portrait.alma {
    box-shadow: inset 0 0 40px rgba(233,30,99,0.35);
}
.character-portrait.rul {
    box-shadow: inset 0 0 40px rgba(103,58,183,0.45);
}
.character-portrait.pau {
    box-shadow: inset 0 0 40px rgba(255,112,67,0.40);
}

.character-card h3 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.badge-blue   { background: #1976d2; color: #fff; }
.badge-green  { background: #2e7d32; color: #fff; }
.badge-pink   { background: #e91e63; color: #fff; }
.badge-purple { background: #673ab7; color: #fff; }
.badge-orange { background: #ff7043; color: #fff; }

.character-card .ability {
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #ffd54f;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(255, 213, 79, 0.45);
}

.stats {
    list-style: none;
    text-align: left;
    font-size: 0.78rem;
}
.stats li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.stats li span {
    width: 70px;
    color: #aaa;
}
.stats .bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.stats .bar div {
    height: 100%;
    background: linear-gradient(90deg, #00e5ff, #ff4081);
    border-radius: 3px;
}

.controls-block {
    background: rgba(0,0,0,0.4);
    border-radius: 12px;
    padding: 14px 24px;
    border: 1px solid rgba(255,255,255,0.08);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    color: #ccc;
    font-size: 0.9rem;
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    background: linear-gradient(180deg, #2a2a40, #15152b);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3);
    font-weight: 700;
    color: #00e5ff;
}
.key-wide { padding: 0 14px; font-size: 0.78rem; }

/* ============ HUD ============ */
.hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: none;
    z-index: 50;
}
.hud.active { display: block; }

.hud-top {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    gap: 14px;
    align-items: stretch;
}

.hud-panel {
    background: rgba(7, 7, 26, 0.7);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 8px 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
}

.panel-label {
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: #888;
    margin-bottom: 4px;
}

.bar-bg {
    width: 180px;
    height: 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
}

.bar-fill {
    height: 100%;
    width: 100%;
    border-radius: 6px;
    transition: width 0.15s ease;
}

.health-fill {
    background: linear-gradient(90deg, #ff5252, #ff9800, #4caf50);
    background-size: 200% 100%;
    background-position: right;
}

.turbo-fill {
    background: linear-gradient(90deg, #00e5ff, #2979ff);
}

#health-text, #turbo-text {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

.enemies-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

.big-number {
    font-size: 1.8rem;
    font-weight: 900;
    color: #ff5252;
    line-height: 1;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.damage-overlay {
    background: radial-gradient(ellipse at center, transparent 30%, rgba(255,30,30,0.55) 100%);
}
.damage-overlay.active { opacity: 1; }

.oil-overlay {
    background:
        repeating-linear-gradient(45deg,
            rgba(60,30,15,0.18) 0 14px,
            rgba(120,60,30,0.18) 14px 28px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 90px;
}
.oil-overlay.active { opacity: 1; }

.oil-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffeb3b;
    background: rgba(0,0,0,0.6);
    padding: 8px 18px;
    border-radius: 8px;
    letter-spacing: 2px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.turbo-message {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.4rem;
    font-weight: 900;
    color: #00e5ff;
    text-shadow: 0 0 24px #00e5ff, 0 0 48px #2979ff;
    opacity: 0;
    letter-spacing: 4px;
    transition: opacity 0.2s ease;
}
.turbo-message.active {
    opacity: 1;
    animation: turboFloat 0.5s ease-in-out infinite alternate;
}

.powerup-toast {
    position: absolute;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 10px 22px;
    border-radius: 24px;
    font-weight: 700;
    border: 2px solid #4caf50;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    letter-spacing: 1px;
}
.powerup-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============ Pantallas finales ============ */
.end-screen {
    background: rgba(7, 7, 26, 0.85);
}
.end-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(0,0,0,0.4));
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 50px 70px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.victory-title {
    font-size: 4.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd700, #ff9800, #ff4081);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 30px #ffd700);
    margin-bottom: 16px;
    animation: bounce 1.2s ease-in-out infinite alternate;
}

.defeat-title {
    font-size: 4rem;
    font-weight: 900;
    color: #ff5252;
    text-shadow: 0 0 30px #ff1744;
    margin-bottom: 16px;
}

.end-card p {
    color: #ccc;
    font-size: 1.15rem;
    margin-bottom: 8px;
}
.end-stat {
    color: #fff !important;
    font-size: 1rem !important;
    margin-bottom: 24px !important;
    letter-spacing: 1px;
}
.end-stat span {
    color: #00e5ff;
    font-weight: 700;
}

.big-btn {
    margin-top: 16px;
    padding: 14px 36px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    background: linear-gradient(135deg, #ff4081, #9c27b0);
    color: #fff;
    box-shadow: 0 6px 20px rgba(255,64,129,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
.big-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 30px rgba(255,64,129,0.6);
}
.big-btn:active {
    transform: scale(1.02);
}

/* ============ Animaciones ============ */
@keyframes titlePulse {
    0%, 100% { filter: drop-shadow(0 0 30px rgba(255,64,129,0.5)); }
    50% { filter: drop-shadow(0 0 50px rgba(0,229,255,0.7)); }
}

@keyframes turboFloat {
    from { transform: translateX(-50%) scale(1); }
    to { transform: translateX(-50%) scale(1.12); }
}

@keyframes bounce {
    from { transform: scale(1) translateY(0); }
    to { transform: scale(1.04) translateY(-6px); }
}

/* ============ YouTube host (oculto) ============ */
#youtube-host {
    position: fixed;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: -9999px;
    pointer-events: none;
    opacity: 0;
}

/* ============ Top menu (botones de menú principal) ============ */
.top-menu {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    gap: 10px;
    z-index: 5;
}

.menu-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, border-color 0.2s;
    backdrop-filter: blur(6px);
}
.menu-btn:hover {
    background: rgba(255,64,129,0.22);
    border-color: rgba(255,64,129,0.6);
    transform: translateY(-2px);
}

/* ============ Score panel ============ */
.score-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 110px;
}
.score-panel .big-number {
    color: #ffd54f;
    text-shadow: 0 0 14px rgba(255, 213, 79, 0.6);
}

/* ============ Pantallas finales mejoradas ============ */
.end-card {
    max-width: 720px;
    padding: 40px 50px;
}

.end-row {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.end-car-preview {
    width: 220px;
    height: 240px;
    background: radial-gradient(ellipse at 50% 35%, rgba(255,255,255,0.08), rgba(0,0,0,0.5));
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    filter: drop-shadow(0 6px 20px rgba(0,0,0,0.6));
}

.end-stats-block {
    text-align: left;
    min-width: 280px;
}
.end-stats-block p { margin-bottom: 6px; }
.end-stat.big {
    font-size: 1.4rem !important;
    color: #ffd54f !important;
    margin-top: 12px !important;
}
.end-stat.big span {
    color: #ffd54f;
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.6);
}

.end-detail {
    list-style: none;
    margin-top: 8px;
    padding: 0;
}
.end-detail li {
    color: #bbb;
    font-size: 0.95rem;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
.end-detail li span {
    color: #00e5ff;
    font-weight: 700;
}

/* ============ Formulario registro récord ============ */
.register-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 18px 0;
    flex-wrap: wrap;
}

.register-form input[type="text"] {
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(0,229,255,0.4);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    outline: none;
    min-width: 220px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.register-form input[type="text"]:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 16px rgba(0,229,255,0.4);
}

.register-form .big-btn {
    margin-top: 0;
    padding: 12px 24px;
    font-size: 0.95rem;
}

.big-btn.ghost {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: none;
}
.big-btn.ghost:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.end-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ============ Bloque de récords (top 10) ============ */
.records-block {
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 14px 18px;
    margin-top: 10px;
    max-height: 280px;
    overflow-y: auto;
    text-align: left;
}

.records-block h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
    color: #ffd54f;
    text-align: center;
}

.records-block .empty {
    color: #888;
    text-align: center;
    font-size: 0.9rem;
    padding: 14px 0;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.records-table th,
.records-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.records-table th {
    color: #888;
    font-weight: 600;
    text-align: left;
    letter-spacing: 1px;
    font-size: 0.7rem;
    text-transform: uppercase;
}
.records-table td.rank {
    color: #ffd54f;
    font-weight: 700;
    width: 32px;
}
.records-table td.score {
    color: #00e5ff;
    font-weight: 700;
    text-align: right;
}
.records-table td.character-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}
.character-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 6px currentColor;
}
.records-table tr.highlight td { background: rgba(255, 213, 79, 0.08); }
.records-table tr.highlight td.rank { color: #ffd54f; }

/* ============ Modales ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(7, 7, 26, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.active {
    display: flex;
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: linear-gradient(160deg, rgba(36, 18, 60, 0.96), rgba(15, 10, 35, 0.96));
    border: 2px solid rgba(255,64,129,0.3);
    border-radius: 18px;
    padding: 36px 44px;
    min-width: 380px;
    max-width: 540px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 60px rgba(255,64,129,0.12);
}
.modal-content h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 22px;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #00e5ff, #ff4081);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.records-modal-content {
    max-width: 640px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    color: #ddd;
}
.option-row label {
    min-width: 90px;
    font-size: 0.95rem;
    letter-spacing: 1px;
}
.option-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, #1976d2, #ff4081);
    border-radius: 3px;
    outline: none;
}
.option-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,64,129,0.7);
}
.option-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,64,129,0.7);
}
.option-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ff4081;
    margin-right: 8px;
    vertical-align: middle;
}
.option-row span {
    min-width: 36px;
    text-align: right;
    font-weight: 700;
    color: #00e5ff;
}

.option-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.option-note {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
    margin: -6px 0 6px;
    letter-spacing: 0.5px;
}

.select-input {
    flex: 1;
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(0,229,255,0.4);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    outline: none;
    cursor: pointer;
}
.select-input:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0,229,255,0.4);
}
.select-input option {
    background: #1a1a2e;
    color: #fff;
}

/* Créditos */
.credits-content .credit-section {
    margin-bottom: 16px;
}
.credits-content h3 {
    color: #ffd54f;
    font-size: 1.1rem;
    margin-bottom: 4px;
    letter-spacing: 1px;
}
.credits-content h4 {
    color: #00e5ff;
    font-size: 0.9rem;
    margin-bottom: 4px;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.credits-content p {
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.45;
    margin: 0;
}
.credits-content p.muted {
    color: #888;
    font-size: 0.85rem;
}
.credits-content a {
    color: #ff4081;
    text-decoration: none;
}
.credits-content a:hover {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .end-card { padding: 28px 22px; }
    .end-row { flex-direction: column; }
    .modal-content { min-width: 0; padding: 26px 22px; }
    .top-menu { top: 10px; right: 10px; gap: 6px; }
    .menu-btn { padding: 6px 10px; font-size: 0.78rem; }
}
