@media (prefers-color-scheme: dark) {
  body {
    background-color: #000;
    color: inherit;
  }

  * {
    color-scheme: dark;
  }
}


/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    color-scheme: dark;
}

/* Definiciones de fuentes locales */
@font-face {
    font-family: 'Press Start 2P';
    src: url('../fonts/PressStart2P-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Font Awesome 6 Free';
    src: url('../fonts/fa-regular-400.woff2') format('woff2'),
         url('../fonts/fa-regular-400.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Font Awesome 6 Free';
    src: url('../fonts/fa-solid-900.woff2') format('woff2'),
         url('../fonts/fa-solid-900.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Font Awesome 6 Brands';
    src: url('../fonts/fa-brands-400.woff2') format('woff2'),
         url('../fonts/fa-brands-400.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Font Awesome 6 Free';
    src: url('../fonts/fa-v4compatibility.woff2') format('woff2'),
         url('../fonts/fa-v4compatibility.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}



/* Prevent selection and right-click */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    color: #fff;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Press Start 2P', monospace;
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: #000;
        color: inherit;
    }
    * {
        color-scheme: dark;
    }
}

/* Game canvas */
#gameCanvas {
    display: block;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Header UI Elements */
#gameHeader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-bottom: 2px solid #7f3f9f;
}

#gameLogo {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: #fff;
    text-shadow: 
        2px 2px 0 #7f3f9f,
        -2px -2px 0 #7f3f9f,
        2px -2px 0 #7f3f9f,
        -2px 2px 0 #7f3f9f;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    animation: glitch 5s infinite;
}

/* Glitch effect */
@keyframes glitch {
    0% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    1% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(-2px, 1px);
    }
    2% {
        text-shadow: -2px -2px 0 #ff00ff, 2px 2px 0 #00ffff;
        transform: translate(2px, -1px);
    }
    3% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    31% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    32% {
        text-shadow: -2px -2px 0 #ff00ff, 2px 2px 0 #00ffff;
        transform: translate(3px, -1px);
    }
    33% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    63% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    64% {
        text-shadow: -2px -2px 0 #ff00ff, 2px 2px 0 #00ffff;
        transform: translate(-2px, 1px);
    }
    65% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
    100% {
        text-shadow: 2px 2px 0 #7f3f9f;
        transform: translate(0);
    }
}

.ui-controls {
    display: flex;
    gap: 10px;
}

.ui-btn {
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #7f3f9f;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #fff;
    font-size: 18px;
    transition: all 0.2s ease;
}

.ui-btn:hover {
    background-color: #7f3f9f;
    transform: scale(1.05);
}

/* Level display */
#levelDisplay {
    position: absolute;
    top: 70px; /* Increased space below header */
    left: 0;
    width: 100%;
    text-align: center;
    color: #7f3f9f;
    font-size: 16px;
    font-family: 'Press Start 2P', monospace;
    z-index: 10;
    text-shadow: 1px 1px 2px #000;
    padding: 5px;
}

/* Language selector */
#languageSelector {
    position: absolute;
    top: 60px;
    right: 10px;
    z-index: 11;
    display: none;
}

#langPanel {
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #7f3f9f;
    border-radius: 8px;
    overflow: hidden;
    width: 150px;
}

.lang-option {
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.lang-option:hover {
    background-color: #7f3f9f;
}

/* Help Panel */
#helpPanel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.help-content {
    background-color: rgba(20, 20, 20, 0.9);
    border: 2px solid #7f3f9f;
    border-radius: 8px;
    padding: 20px;
    max-width: 80%;
    text-align: center;
}

#helpTitle {
    color: #7f3f9f;
    font-size: 20px;
    margin-bottom: 20px;
}

#helpText {
    margin-bottom: 20px;
    font-size: 12px;
    line-height: 1.5;
}

#helpText p {
    margin-bottom: 10px;
}

/* Pause menu */
#pauseMenu, #continueModal, #audioSettingsModal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.lang-option {font-size: 13px;
}

.menu-content {
    background-color: rgba(20, 20, 20, 0.9);
    border: 2px solid #7f3f9f;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    min-width: 300px;
    margin-left: 20px;
    margin-right: 20px;
}

#pauseTitle, #continueTitle, #audioSettingsTitle {
    color: #7f3f9f;
    font-size: 24px;
    margin-bottom: 30px;
}

#saveWarning {
    color: #ff6b6b;
    font-size: 12px;
    margin-bottom: 20px;
}

.menu-btn {
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #7f3f9f;
    border-radius: 8px;
    color: #fff;
    padding: 10px 20px;
    margin: 10px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    transition: all 0.2s ease;
}

.menu-btn:hover {
    background-color: #7f3f9f;
    transform: scale(1.05);
}

/* Debug Controls */
#debugControls {
    position: absolute;
    top: 70px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ff00ff;
    border-radius: 8px;
    padding: 10px;
    display: none;
    z-index: 15;
}

.debug-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#debugLevelInput {
    width: 50px;
    background-color: #222;
    border: 1px solid #7f3f9f;
    color: #fff;
    padding: 5px;
    border-radius: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
}

.debug-btn {
    background-color: #7f3f9f;
    border: none;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
}

#debugJumpLabel {
    font-size: 10px;
    color: #ff00ff;
}

/* Audio Settings */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Switch styling */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #7f3f9f;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Power-up Notification */
#powerUpNotice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffff00;
    border-radius: 8px;
    padding: 20px;
    color: #ffff00;
    font-size: 18px;
    z-index: 25;
    display: none;
    animation: pulsate 2s infinite;
}

/* Debug Mode Notice */
#debugNotice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #ff00ff;
    border-radius: 8px;
    padding: 20px;
    color: #ff00ff;
    font-size: 18px;
    z-index: 30;
    display: none;
    animation: pulsate 2s infinite;
}

@keyframes pulsate {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Footer */
footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10;
    font-size: 12px;
    border-top: 1px solid #7f3f9f;
}

footer a {
    color: #7f3f9f;
    text-decoration: none;
}

/* Loading screen */
#loadingScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.glitch-title {
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 36px;
    position: relative;
    text-shadow: 3px 3px 0 #7f3f9f;
    margin-bottom: 40px;
    letter-spacing: 4px;
}

.glitch-title::before,
.glitch-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-title::before {
    left: 2px;
    text-shadow: -2px 0 #ff00ff;
    animation: glitch-animation-1 2s infinite linear alternate-reverse;
}

.glitch-title::after {
    left: -2px;
    text-shadow: 2px 0 #00ffff;
    animation: glitch-animation-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-animation-1 {
    0% { clip-path: inset(30% 0 70% 0); }
    20% { clip-path: inset(20% 0 80% 0); }
    40% { clip-path: inset(50% 0 50% 0); }
    60% { clip-path: inset(10% 0 90% 0); }
    80% { clip-path: inset(40% 0 60% 0); }
    100% { clip-path: inset(0% 0 100% 0); }
}

@keyframes glitch-animation-2 {
    0% { clip-path: inset(40% 0 60% 0); } 
    20% { clip-path: inset(60% 0 40% 0); }
    40% { clip-path: inset(20% 0 80% 0); }
    60% { clip-path: inset(70% 0 30% 0); }
    80% { clip-path: inset(10% 0 90% 0); }
    100% { clip-path: inset(30% 0 70% 0); }
}

#loadingBar {
    width: 80%;
    max-width: 300px;
    height: 20px;
    border: 2px solid #7f3f9f;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

#loadingProgress {
    width: 0%;
    height: 100%;
    background-color: #7f3f9f;
    border-radius: 8px;
    transition: width 0.3s;
}

#loadingText {
    color: #7f3f9f;
    font-size: 18px;
    letter-spacing: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}



/* Mobile Adjustments */
@media (max-width: 768px) {
    #gameLogo {
        font-size: 18px;
    }
    
    .ui-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .glitch-title {
        font-size: 24px;
    }
    
    #pauseTitle {
        font-size: 17px;
    }
    
    .menu-btn {
        font-size: 12px;
        padding: 8px 16px;
    }
    
    footer {
        padding: 6px;
        font-size: 10px;
    }
    
    #levelDisplay {
        font-size: 14px;
        top: 70px; /* Adjusted for mobile */
    }
    
    .debug-input-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #debugControls {
        min-width: 120px;
    }
}





    
    /* Improved touch target sizes */
    #helpBtn, #pauseBtn, #soundBtn, #langBtn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Improved readability for mobile inputs */
    #debugLevelInput {
        width: 70px;
        font-size: 14px;
        padding: 8px;
    }
    
    /* Ensure full-width modals are easily tappable */
    .menu-content {
        width: 90%;
        max-width: 400px;
        margin: 0 auto;
        padding: 25px;
    }
    
    /* Enhanced button touch targets */
    .menu-btn {
        min-width: 200px;
        margin: 15px auto;
        display: block;
    }
}






/* Enemy Toggle Button - POSICIÓN CORREGIDA */

#enemyToggleBtn {z-index: 1000;}


#enemyToggleBtn {
    position: fixed; /* Cambiado de absolute a fixed para asegurar posición */
    bottom: 50px;
    right: 15px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #e74c3c;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 15; /* Mayor z-index para asegurar que esté por encima */
    transition: all 0.3s ease;
}

#enemyToggleBtn.disabled {
    border-color: #666;
    opacity: 0.7;
}

.enemy-icon {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #e74c3c;
    position: relative;
    transition: all 0.3s ease;
}

/* Ojos del enemigo */
.enemy-icon:before, .enemy-icon:after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: #fff;
    border-radius: 50%;
    top: 6px;
}

.enemy-icon:before {
    left: 5px;
}

.enemy-icon:after {
    right: 5px;
}

#enemyToggleBtn.disabled .enemy-icon {
    background-color: #666;
}

#enemyToggleBtn:hover {
    transform: scale(1.1);
}

/* Texto ON/OFF - POSICIÓN CORREGIDA */
.toggle-status {
    position: absolute;
    top: -18px; /* Ajustado para estar justo encima del botón */
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    background-color: rgba(0, 0, 0, 0.5); /* Fondo para mejorar legibilidad */
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap; /* Evita que el texto se rompa */
}

#enemyToggleBtn .on-text {
    color: #e74c3c;
    display: block;
}

#enemyToggleBtn .off-text {
    display: none;
}

#enemyToggleBtn.disabled .on-text {
    display: none;
}

#enemyToggleBtn.disabled .off-text {
    color: #666;
    display: block;
}


/* Ojos del enemigo CON PUPILAS */
.enemy-icon:before, .enemy-icon:after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: #fff;
    border-radius: 50%;
    top: 6px;
}

.enemy-icon:before {
    left: 5px;
}

.enemy-icon:after {
    right: 5px;
}

/* Añadir pupilas */
.enemy-icon:before::after, .enemy-icon:after::after {
    content: "";
    position: absolute;
    width: 3px;
    height: 3px;
    background-color: #000;
    border-radius: 50%;
    top: 1.5px;
    left: 1.5px;
}

/* Alternativa para las pupilas (si la anterior no funciona) */
.enemy-icon .pupil-left, .enemy-icon .pupil-right {
    position: absolute;
    width: 3px;
    height: 3px;
    background-color: #000;
    border-radius: 50%;
    top: 7.5px;
}

.enemy-icon .pupil-left {
    left: 6.5px;
}

.enemy-icon .pupil-right {
    right: 6.5px;
}


/* Estilos del ícono de enemigo con ojos y pupilas claramente definidos */
.enemy-icon {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #e74c3c;
    position: relative;
    transition: all 0.3s ease;
}

/* Ojos como elementos separados */
.eye {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border-radius: 50%;
    top: 6px;
}

.eye-left {
    left: 2px;
}

.eye-right {
    right: 2px;
}

/* Pupilas como elementos reales */
.pupil {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #000;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

#enemyToggleBtn.disabled .enemy-icon {
    background-color: #666;
}


/* Prevenir el resaltado del botón al hacer clic */
#enemyToggleBtn {
    position: fixed;
    bottom: 50px;
    right: 15px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #551a8b;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 15;
    transition: all 0.3s ease;
    
    /* Propiedades para prevenir el resaltado */
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Aplicar también al texto ON/OFF */
.toggle-status {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    
    /* Prevenir el resaltado del texto */
    user-select: none;
    -webkit-user-select: none;
}