* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #111;
    color: #fff;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    height: 100vh;
    width: 100vw;
}

/* Loading screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loading-image {
    width: 90%;
    max-width: 500px;
    height: auto;
}



/* Main game container */
#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    background-color: #222;
    display: block;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* UI Elements */
#uiOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#levelDisplay, #enemiesRemaining {
    position: absolute;
    top: 10px;
    font-size: 16px;
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
}

#levelDisplay {
    left: 10px;
}

#enemiesRemaining {
    right: 10px;
}

/* Menu Screens */
#menuScreen, #gameOverScreen, #levelCompleteScreen, #pauseScreen, #levelsScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
    text-align: center;
}

#menuScreen {
    background-color: rgba(56, 15, 9, 1.0);
    background-image: url(assets3/star.png);
}

#gameOverScreen, #levelCompleteScreen, #pauseScreen, #levelsScreen {
    background-color: rgba(21, 6, 56, 0.8);
}

#game-title {
    font-size: 2.5rem;
    margin-bottom: 30px;
    color: #856f43;
    text-shadow: 0 0 10px #da2736;
    font-family:Arial;
    letter-spacing: 2px;
    padding: 0 10px;
}

.screenTitle, #levelsTitle {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #2ca6ec;
    padding: 0 10px;
}

.menuButton {
    background-color: #856F43;
    color: white;
    border: none;
    padding: 12px 20px;
    margin: 8px;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    pointer-events: auto;
    width: 80%;
    max-width: 250px;
    text-align: center;
    box-shadow: 0 0 5px white;
}

.menuButton:hover {
    transform: scale(1.05);
}

/* Game UI Elements */
#detectionMeter {
    position: absolute;
    bottom: 80px;
    left: 10px;
    width: 120px;
    height: 15px;
    background-color: rgba(255, 255, 0, 0.3);
    border: 2px solid #fff;
    border-radius: 5px;
    overflow: hidden;
    display: none;
}

#detectionFill {
    height: 100%;
    width: 0%;
    background-color: #ffcc00;
    transition: width 0.1s;
}

#instructions, #controlsInfo {
    position: absolute;
    bottom: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 5px;
    font-size: 12px;
    width: 90%;
    max-width: 300px;
    pointer-events: none;
}

#instructions {
    left: 10px;
    text-align: left;
}

#controlsInfo {
    right: 10px;
    text-align: right;
}

#controlsInfo p {
    margin: 3px 0;
}

#pauseButton {
    position: absolute;
    top: 7%;
    left: 7%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid white;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 5;
    font-size: 14px;
}

/* Levels Screen */
/* Levels Screen - Responsive Grid */
#levelsScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow-y: auto;
    display: none;
}

#levelsGrid {
    display: grid;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 800px;
    margin: 20px 0;
    padding: 10px;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

.levelButton {
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: none;
    color: white;
}

/* Level Button States */
.levelButton.locked {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
}

.levelButton.unlocked {
    background-color: #e74c3c;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.levelButton.unlocked:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 10px rgba(231, 76, 60, 0.3);
}

.levelButton.current {
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.levelButton.completed {
    background-color: #2ecc71;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #levelsGrid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 10px;
    }
    
    .levelButton {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    #levelsGrid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    .levelButton {
        font-size: 1rem;
    }
    #levelsScreen{
        overflow-y: scroll;
    }
}

@media (min-width: 1200px) {
    #levelsGrid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 15px;
    }
    
    .levelButton {
        font-size: 1.8rem;
    }
}

/* Landscape orientation specific styles */
@media (orientation: landscape) {
    #game-title {
        font-size: 3rem;
        margin-bottom: 20px;
    }
    
    .screenTitle, #levelsTitle {
        font-size: 2.5rem;
    }
    
    .menuButton {
        padding: 15px 30px;
        font-size: 1.2rem;
    }
    
    #levelDisplay, #enemiesRemaining {
        font-size: 20px;
    }
    
    #levelsGrid {
        grid-template-columns: repeat(5, 1fr);
        max-width: 800px;
    }
    
    #instructions, #controlsInfo {
        width: auto;
        max-width: 40%;
    }
    
    #instructions {
        left: 20px;
        bottom: 20px;
    }
    
    #controlsInfo {
        right: 20px;
        bottom: 20px;
    }
    
    #detectionMeter {
        bottom: 100px;
        left: 20px;
        width: 150px;
        height: 20px;
    }
}

/* Very small screens */
@media (max-width: 420px) {
    #game-title {
        font-size: 2rem;
    }
    
    .screenTitle, #levelsTitle {
        font-size: 1.5rem;
    }
    
    .menuButton {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}