:root {
    --primary-color: #ff6b6b;
    --accent-color: #4ecdc4;
    --text-color: #ffffff;
    --font-family: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    /* Prevent zoom/scroll on mobile */
    height: 100%;
    color: var(--text-color);
    /* Keep existing color */
}

html {
    height: 100%;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    box-shadow: none;
    /* Remove shadow */
    display: block;
    /* Remove flex centering */
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    /* Let clicks pass through to canvas mostly */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#stats-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

#score-container {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    color: var(--text-color);
}

#health-bar-container {
    width: 200px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ff8e8e);
    transition: width 0.3s ease;
}

#boss-health-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    max-width: 80%;
    height: 30px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid rgba(255, 50, 50, 0.8);
    pointer-events: auto;
}

#boss-health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff0000, #ff5050);
    transition: width 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

#boss-health-container.hidden {
    display: none;
}

/* Drone cursor during boss battle */
body.boss-battle {
    cursor: none;
}

#drone {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 120px;
    height: auto;
    pointer-events: none;
    z-index: 150;
    transform: translateX(-50%);
    transition: left 0.05s ease-out;
}

#drone.hidden {
    display: none;
}

#drone img {
    width: 100%;
    height: auto;
    display: block;
}

#controls-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

#controls-container button {
    background: #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

#controls-container button:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

#controls-container button:active {
    transform: scale(0.95);
}

#bomb-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    pointer-events: auto;
    transition: transform 0.2s;
}

#clock-container {
    position: absolute;
    bottom: 120px;
    /* Above bomb */
    right: 20px;
    pointer-events: auto;
    transition: transform 0.2s;
}

#bomb-icon-wrapper,
#clock-icon-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    background: #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

#bomb-icon-wrapper.active,
#clock-icon-wrapper.active {
    box-shadow: 0 0 20px #ff6b6b;
    border-color: #ff6b6b;
    animation: pulse 1s infinite;
}

#clock-icon-wrapper.active {
    box-shadow: 0 0 20px #4ecdc4;
    border-color: #4ecdc4;
}

#bomb-icon,
#clock-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.5));
}

#bomb-count,
#clock-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b6b;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
    border: 2px solid white;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#loading-content {
    text-align: center;
    color: #fff;
}

#loading-content h1 {
    font-size: 3rem;
    margin-bottom: 30px;
    font-family: 'Outfit', sans-serif;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

#loading-bar-container {
    width: 300px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
    transition: width 0.3s ease;
}

#loading-text {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
}

#loading-screen.hidden {
    display: none;
}

#tutorial-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
    backdrop-filter: blur(10px);
    cursor: default;
}

#tutorial-modal.hidden {
    display: none;
}

#boss-tutorial-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    /* Match tutorial-modal */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 600;
    /* Keep higher z-index */
    backdrop-filter: blur(10px);
    /* Match tutorial-modal */
    cursor: default;
}

#boss-tutorial-modal.hidden {
    display: none;
}

#boss-tutorial-content {
    background: rgba(20, 20, 20, 0.95);
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

#boss-tutorial-content h2 {
    font-size: 2.5rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

#boss-tutorial-steps {
    margin-bottom: 20px;
    padding-left: 22px;
}

#boss-tutorial-steps li {
    font-size: 1.2rem;
    color: #fff;
    margin: 15px 0;
    line-height: 1.6;
    font-family: 'Outfit', sans-serif;
}

#boss-tutorial-close {
    width: 100%;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 1.8rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

#boss-tutorial-close:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6);
}

#boss-tutorial-close:active {
    transform: scale(0.98);
}

#tutorial-content {
    background: rgba(20, 20, 20, 0.95);
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

#tutorial-content h2 {
    font-size: 2.5rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

#tutorial-rules {
    margin-bottom: 30px;
}

#tutorial-rules p {
    font-size: 1.2rem;
    color: #fff;
    margin: 15px 0;
    line-height: 1.6;
    font-family: 'Outfit', sans-serif;
}

#tutorial-rules strong {
    color: #ffcc00;
}

#start-game-btn {
    width: 100%;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 1.8rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

#start-game-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6);
}

#start-game-btn:active {
    transform: scale(0.98);
}

#pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(10px);
    cursor: default;
}

#pause-overlay h1 {
    font-size: 5rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    animation: pulse 1.5s ease-in-out infinite;
}

#pause-overlay.hidden {
    display: none;
}

#resume-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    padding: 15px 40px;
    font-size: 1.8rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    margin-top: 30px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#resume-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

#resume-btn:active {
    transform: scale(0.95);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

#start-screen {
    background: url('imagen/portada.jpg') no-repeat center center;
    background-size: contain;
    /* Fit without stretching */
    background-color: #000;
    /* Black bars */
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    cursor: default;
}

#game-over-screen {
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 0;
    left: 0;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    transition: opacity 0.3s ease;
    z-index: 100;
    /* Ensure it covers properly if reused */
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: default;
}

#game-title {
    position: absolute;
    top: 10%;
    /* Safer top margin */
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 80%;
    max-width: 400px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

#start-btn {
    position: absolute;
    bottom: 15%;
    /* Anchor to bottom */
    top: auto;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 200px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.5));
}

#start-btn:hover {
    transform: scale(1.05);
}

#start-btn:active {
    transform: scale(0.95);
}

#rank-container {
    height: 150px;
    /* Space for the image */
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

#rank-image {
    max-height: 100%;
    max-width: 100%;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.hidden {
    opacity: 0;
    pointer-events: none !important;
    display: none !important;
}

h1 {
    font-size: 4rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #ecf0f1;
}

button {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-family: var(--font-family);
    font-weight: 700;
    color: white;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    pointer-events: auto;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6);
}

button:active {
    transform: translateY(1px);
}


.boss-battle {
    cursor: default !important;
}

/* Victory Modal */
#victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 700;
    backdrop-filter: blur(10px);
    cursor: default;
}

#victory-content {
    background: linear-gradient(135deg, rgba(20, 20, 20, 0.95), rgba(40, 40, 40, 0.95));
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #ffcc00;
    box-shadow: 0 0 50px rgba(255, 204, 0, 0.5);
    text-align: center;
    max-width: 500px;
    color: #fff;
}

#victory-stats p {
    font-size: 1.2rem;
    margin: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

#player-name {
    padding: 15px;
    font-size: 1.5rem;
    border-radius: 10px;
    border: none;
    margin: 20px 0;
    text-align: center;
    width: 80%;
    font-family: 'Outfit', sans-serif;
}

#submit-score-btn {
    background: #ffcc00;
    color: #000;
    width: 100%;
}

/* Leaderboard Modal */
#leaderboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 800;
    backdrop-filter: blur(5px);
    cursor: default;
}

#leaderboard-content {
    background: #1a1a1a;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border: 2px solid #4ecdc4;
    display: flex;
    flex-direction: column;
}

#leaderboard-list-container {
    overflow-y: auto;
    flex-grow: 1;
    margin: 20px 0;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
    font-family: 'Outfit', sans-serif;
}

#leaderboard-table th,
#leaderboard-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard-table th {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
}

#leaderboard-close-btn {
    align-self: center;
    background: #ff6b6b;
}