/* Reset Margins and Padding */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body Styles */
body {
    overflow: hidden;
    background-color: #000;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed from center to flex-start to prevent cut-off */
    padding-top: 20px; /* Added padding to provide space at the top */
    height: 100vh;
}

/* Game Container */
#gameContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* Ensure it's relative for absolute children */
    width: 100%;
    max-width: 1024px;
    margin-top: 20px; /* Ensure there's space at the top */
}

/* Game Content Container */
#gameContent {
    display: flex;
    flex-direction: row;
    align-items: center; /* Vertically center the pause button with the canvas */
    width: 100%;
    position: relative;
}

/* Game Canvas */
#gameCanvas {
    background-color: #5c94fc;
    image-rendering: pixelated;
    width: 100%;
    height: auto;
    border: 2px solid #fff;
    z-index: 1;
    margin-right: 20px; /* Space between canvas and pause button */
}

/* Pause Button Positioned to the Right of the Canvas */
#pauseButtonDesktop {
    width: 80px;
    height: 80px;
    font-size: 20px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    z-index: 1004; /* Ensure it's above other elements */
}

#pauseButtonDesktop:hover {
    background-color: rgba(255, 255, 255, 1);
}

#pauseButtonDesktop:active {
    transform: scale(0.95);
}

#pauseButtonDesktop span {
    color: #000;
    font-size: 16px;
    margin-top: 5px;
}

/* Divider */
.divider {
    width: 80%;
    border: 0;
    height: 1px;
    background: #fff;
    margin: 20px 0;
}

@media (max-width: 600px) {
    .divider {
        width: 90%;
    }
}

/* Overlay Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1003; /* Ensure overlays are above everything except desktop controls */
    color: #fff;
    text-align: center;
    padding: 20px;
}

/* Specific Override for Start Screen */
#startScreen {
    z-index: 1003;
}

/* Hidden Class */
.hidden {
    display: none;
}

/* Button Styles */
.btn {
    padding: 15px 30px;
    margin: 10px;
    font-size: 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #28a745;
    color: #fff;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn:hover {
    background-color: #218838;
}

.btn:active {
    transform: scale(0.98);
}

/* Pause Menu Specific Styles */
#pauseMenu h2 {
    margin-bottom: 20px;
}

/* Mobile Controls Container */
#mobileControls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    width: 100%;
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

/* Controls Row */
.controls-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 600px;
}

/* Control Buttons */
.control-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    color: #000;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:hover {
    background-color: rgba(255, 255, 255, 1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Desktop Control Buttons */
#desktopControls .control-btn {
    /* Removed because pauseButtonDesktop is now outside desktopControls */
}

/* Responsive Adjustments for Mobile Devices */
@media (max-width: 600px) {
    /* Show Mobile Controls and Hide Desktop Controls */
    #mobileControls {
        display: flex;
    }
    
    #pauseButtonDesktop {
        display: none;
    }

    /* Controls Row */
    .controls-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }

    /* Adjust button sizes for mobile */
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    /* Resize Canvas for Mobile */
    #gameCanvas {
        width: 100%;
        max-width: 512px;
        height: auto;
        border: 2px solid #fff;
    }
}

/* Show Desktop Controls on Larger Screens */
@media (min-width: 601px) {
    /* Hide Mobile Controls */
    #mobileControls {
        display: none;
    }

    /* Show Desktop Controls */
    #pauseButtonDesktop {
        display: flex;
    }

    /* Controls Row */
    .controls-row {
        justify-content: center;
        gap: 20px;
        max-width: 800px;
    }

    /* Desktop Control Buttons */
    #desktopControls .control-btn {
        width: 80px;
        height: 80px;
        font-size: 20px;
        border-radius: 10px;
        background-color: rgba(255, 255, 255, 0.9);
        color: #000;
        flex-direction: column;
        padding: 10px;
    }

    #desktopControls .control-btn span {
        color: #000;
        font-size: 16px;
    }

    #desktopControls .control-btn i {
        margin-bottom: 5px;
        font-size: 24px;
    }
}

/* Game Over Screen Styles */
#gameOverScreen input {
    padding: 10px;
    font-size: 18px;
    margin: 10px;
    width: 250px;
    border-radius: 5px;
    border: none;
}

#gameOverScreen p {
    font-size: 24px;
    margin: 20px 0;
}

/* Top Scores Screen Styles */
#topScoresScreen ol {
    list-style: decimal;
    padding-left: 0;
    text-align: left;
    max-width: 300px;
    width: 100%;
}

#topScoresScreen li {
    font-size: 20px;
    margin: 5px 0;
    color: #fff;
}

/* Controls & Gameplay Screen Styles */
#controlsScreen .controls-content {
    max-width: 600px;
    text-align: left;
    margin: 20px;
}

#controlsScreen h3 {
    margin-top: 20px;
    margin-bottom: 10px;
}

#controlsScreen ul {
    list-style: disc;
    margin-left: 20px;
}

#controlsScreen p {
    font-size: 18px;
}

/* Credits Screen Styles */
#creditsScreen .credits-content {
    max-width: 600px;
    text-align: left;
    margin: 20px;
}

#creditsScreen ul {
    list-style: disc;
    margin-left: 20px;
}

#creditsScreen p {
    font-size: 18px;
}
