:root {
            --bg: #050510;
            --gold: #ffd700;
            --red: #ff3333;
            --blue: #33ccff;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            background: var(--bg);
            background-image: radial-gradient(circle at center, #1a1a3a 0%, #000 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            font-family: 'Impact', 'Arial Black', sans-serif;
            flex-direction: column;
            overflow: hidden;
            user-select: none;
            color: white;
        }
        canvas {
            border: 4px solid var(--gold);
            border-radius: 8px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.2);
            background: #000;
			image-rendering: pixelated; 
		    max-width: 100vw;
			max-height: 100vh;
			aspect-ratio: 1024 / 576;
			width: 100%;
			/* Si el juego está en un móvil, quitamos el borde para ganar espacio */
			box-sizing: border-box;
        }
        .info {
            color: #aaa;
            font-size: 14px;
            margin-top: 15px;
            text-align: center;
            text-shadow: 1px 1px 2px #000;
            background: rgba(0,0,0,0.5);
            padding: 10px 20px;
            border-radius: 8px;
            border: 1px solid #333;
            line-height: 1.6;
        }
        .info kbd {
            background: #222;
            border: 1px solid var(--gold);
            padding: 2px 6px;
            border-radius: 4px;
            color: var(--gold);
            font-weight: bold;
            box-shadow: 0 2px 0 #886b00;
            margin: 0 2px;
        }
		/* --- FONDO ESPECÍFICO PARA LA PANTALLA DE INICIO --- */
/* --- PANTALLA DE INICIO A PANTALLA COMPLETA --- */
#startScreen {
    width: 100vw;            /* Ocupa el 100% del ancho de la ventana */
    height: 100vh;           /* Ocupa el 100% del alto de la ventana */
    max-width: none;         /* Anula el ancho máximo de la clase menu-box */
    border-radius: 0;        /* Quita las esquinas redondeadas */
    border: none;            /* Quita el borde azul/dorado */
    box-shadow: none;        /* Quita la sombra de la caja */
    
    /* Fondo con la imagen a pantalla completa */
    background: linear-gradient(rgba(10, 10, 20, 0.4), rgba(10, 10, 20, 0.8)), url('texturas/start.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    
    /* Centrado interno */
    justify-content: center; /* Centra los elementos verticalmente */
    align-items: center;     /* Centra los elementos horizontalmente */
}

/* Hacemos el título principal un poco más grande para aprovechar el espacio */
#startScreen h1 {
    font-size: 75px; 
}

/* --- BOTONES DE LA PANTALLA DE INICIO MÁS PEQUEÑOS Y CENTRADOS --- */
#startScreen .menu-btn {
    font-size: 18px;         /* Tamaño de letra más pequeño */
    padding: 10px 20px;      /* Menos espacio de relleno interno */
    width: 200px;            /* Ancho fijo para que los dos botones sean iguales */
    margin: 5px 0;           /* Separación vertical entre ellos */
}
        
        /* --- ESTILOS COMPARTIDOS PARA TODAS LAS PANTALLAS --- */
        .menu-box {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(10, 10, 20, 0.95);
            padding: 40px;
            border-radius: 15px;
            text-align: center;
            color: white;
            border: 2px solid var(--blue);
            box-shadow: 0 0 50px rgba(51, 204, 255, 0.3) inset, 0 20px 50px rgba(0,0,0,0.9);
            display: flex;
            flex-direction: column;
            gap: 15px;
            z-index: 10;
            max-width: 700px;
            width: 90%;
            backdrop-filter: blur(5px);
        }
        .menu-box h1 {
            margin: 0 0 5px 0;
            font-size: 52px;
            letter-spacing: 4px;
            color: var(--gold);
            text-shadow: 0 4px 0 #b38f00, 0 0 20px rgba(255,215,0,0.6);
            font-style: italic;
        }
        .menu-box h2 { margin: 0; font-size: 24px; color: #ddd; letter-spacing: 2px; }
        
        .menu-btn {
            padding: 15px 30px;
            font-family: 'Impact', sans-serif;
            font-size: 24px;
            background: linear-gradient(to bottom, #ff5555, #cc0000);
            color: white;
            border: 2px solid #fff;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;
            letter-spacing: 2px;
            text-transform: uppercase;
            box-shadow: 0 6px 0 #880000;
            margin-top: 10px;
        }
        .menu-btn.blue { background: linear-gradient(to bottom, #33ccff, #0088cc); box-shadow: 0 6px 0 #005588; }
        .menu-btn.blue:hover { box-shadow: 0 4px 0 #005588, 0 0 20px #33ccff; }
        .menu-btn.blue:active { box-shadow: 0 0 0 #005588; }
        
        .menu-btn:hover { transform: translateY(2px); box-shadow: 0 4px 0 #880000, 0 0 20px #ff4444; }
        .menu-btn:active { transform: translateY(6px); box-shadow: 0 0 0 #880000; }
        
        .char-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;
            margin: 10px 0;
        }
        .char-btn {
            padding: 10px 5px;
            font-family: 'Impact', sans-serif;
            font-size: 14px;
            background: linear-gradient(to bottom, #333, #111);
            color: #fff;
            border: 2px solid #555;
            border-radius: 8px;
            cursor: pointer;
            transition: 0.2s;
            text-align: center;
        }
        .char-btn:hover { border-color: #888; background: linear-gradient(to bottom, #444, #222); }
        .char-btn.selected {
            border-color: var(--gold);
            background: linear-gradient(to bottom, #554400, #221100);
            box-shadow: 0 0 15px rgba(255,215,0,0.6) inset;
            transform: scale(1.05);
        }
        .char-btn .icon { font-size: 32px; display: block; margin-bottom: 5px; text-shadow: 0 2px 4px #000; }
        .char-btn .cname { font-size: 16px; font-weight: bold; letter-spacing: 1px; }
        .char-btn .beast { font-size: 11px; color: var(--gold); display: block; margin-top: 3px; }
        
        .difficulty-row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
        .diff-btn {
            padding: 8px 20px;
            font-family: 'Impact', sans-serif;
            font-size: 16px;
            border: 2px solid #555;
            background: #222;
            color: #aaa;
            border-radius: 6px;
            cursor: pointer;
            transition: 0.2s;
        }
        .diff-btn.selected { background: var(--blue); color: #000; border-color: #fff; box-shadow: 0 0 10px var(--blue); }
        
        .ranking-list { text-align: left; background: rgba(0,0,0,0.5); padding: 20px; border-radius: 10px; border: 1px solid #444; }
        .ranking-list p { margin: 10px 0; font-size: 20px; font-family: 'Arial Black', sans-serif; letter-spacing: 1px; }
        .rank-1 { color: #ffd700; }
        .rank-2 { color: #c0c0c0; }
        .rank-3 { color: #cd7f32; }
canvas {
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 1024 / 576;
    width: 100%;
    /* Si el juego está en un móvil, quitamos el borde para ganar espacio */
    box-sizing: border-box;
}

/* --- CONTROLES MÓVILES TÁCTILES --- */
#mobileControls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none; /* Permite clickar cosas debajo si no es el botón */
    z-index: 5;
}
.m-btn {
    pointer-events: auto; /* Reactiva el toque en los botones */
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none; /* Evita que la pantalla haga zoom o scroll al pulsar */
    backdrop-filter: blur(2px);
}
.m-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.9);
}
.dpad { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.dpad-middle { display: flex; gap: 40px; } /* Separación central para no pulsar mal */
.action-btns { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; justify-content: flex-end; }
.act-row { display: flex; gap: 10px; }

/* --- MEDIA QUERIES (Para móviles) --- */
@media (max-width: 768px) {
    /* En móvil, mostramos 2 personajes por fila en vez de 4 */
    .char-grid { grid-template-columns: repeat(2, 1fr); }
    .menu-box { padding: 20px; width: 95%; }
    .menu-box h1 { font-size: 32px; }
    #startScreen h1 { font-size: 40px; }
    .m-btn { width: 50px; height: 50px; font-size: 20px; } /* Botones un poco más pequeños */
    .dpad-middle { gap: 30px; }
}
/* Permitir interacciones y pegado solo dentro del input */
input {
    user-select: text !important;
    -webkit-user-select: text !important;
}