.game-container {
    position: relative;
    width: 100%;
    max-width: 1800px; /* Increased to fill more of the desktop screen */
    margin: 0 auto;
    aspect-ratio: 16/9;
    margin-bottom: 30px; /* Add margin to ensure buttons don't get cut off */
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    overflow: hidden;
}

/* Mobile Menu Styles */
.mobile-menu-toggle {
    display: none;  /* Hidden by default, will show on mobile */
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 64, 0.8);
    color: #fff;
    font-size: 24px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    text-align: center;
    line-height: 45px;
    z-index: 200;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 255, 0.3);
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 3px 8px rgba(0, 0, 255, 0.3);
    }
    50% {
        box-shadow: 0 3px 15px rgba(0, 200, 255, 0.7);
    }
    100% {
        box-shadow: 0 3px 8px rgba(0, 0, 255, 0.3);
    }
}

.mobile-menu-toggle:hover {
    background: rgba(60, 100, 200, 0.8);
    transform: scale(1.1);
}

.mobile-menu {
    display: none;  /* Hidden by default */
    position: absolute;
    top: 65px;
    right: 10px;
    background: linear-gradient(135deg, rgba(15, 15, 45, 0.95), rgba(0, 0, 30, 0.9));
    border-radius: 12px;
    padding: 20px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 100, 255, 0.5);
    flex-direction: column;
    min-width: 200px;
    backdrop-filter: blur(8px);
    border: 2px solid rgba(100, 150, 255, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
    transform-origin: top right;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mobile-menu.active {
    display: flex;
}

.menu-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.menu-btn:hover {
    background: rgba(60, 60, 100, 0.8);
    transform: translateY(-2px);
}

/* Mute button styling */
#mobileMuteButton {
    background: rgba(0, 128, 128, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#mobileMuteButton:hover {
    background: rgba(0, 128, 128, 0.8);
}

#mobileMuteIcon {
    font-size: 20px;
    margin-right: 8px;
    display: inline-block;
}

.fire-btn {
    background: linear-gradient(to bottom, #dc3545, #bb2d3b);
    font-weight: bold;
}

.fire-btn:hover {
    background: linear-gradient(to bottom, #bb2d3b, #a52632);
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-top: 12px;
}

.menu-link {
    color: #fff;
    text-decoration: none;
    padding: 12px 0;
    margin: 4px 0;
    transition: all 0.2s ease;
    text-align: center;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-link:before {
    content: "→ ";
    margin-right: 5px;
}

.menu-link:hover {
    color: #00ffff;
    background: rgba(0, 0, 255, 0.2);
    transform: translateY(-2px);
}

/* Audio Controls Styles */
.audio-controls {
    margin: 15px 0;
}

#startGameBtn {
    transition: all 0.3s ease;
    font-weight: bold;
    padding: 8px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#startGameBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#toggleMuteBtn {
    padding: 8px 15px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#toggleMuteBtn:hover {
    background-color: var(--bs-secondary);
    color: var(--bs-light);
}

#muteIcon {
    font-size: 1.2em;
    margin-right: 5px;
}

/* iPad and tablet specific styles */
@media only screen and (min-width: 601px) and (max-width: 1024px) {
    .game-container {
        width: 100%;
        height: 80vh;
        max-width: none;
        aspect-ratio: auto;
        margin: 0;
    }
    
    /* Make sure desktop buttons are hidden */
    .desktop-mute-btn {
        display: none !important;
    }
    
    /* Modify restart button for tablet */
    #restartButton {
        display: flex !important;
        position: absolute;
        bottom: 20px;
        left: 20px;
        padding: 10px 15px;
        border-radius: 10px;
        background-color: rgba(108, 117, 125, 0.8);
        align-items: center;
        justify-content: center;
    }
    
    #restartIcon {
        font-size: 18px;
        margin-right: 6px;
    }
    
    #restartText {
        display: inline !important;
        font-size: 16px;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
    }

    .hud {
        font-size: 1.1em;
        background: rgba(0, 0, 0, 0.5);
        padding: 15px;
        border-radius: 12px;
    }

    /* Hide the CSS fire button on tablets - use only the JavaScript pulsating button */
    #fireButton {
        display: none !important;
    }

    #fireButton:active {
        transform: scale(0.95);
        background-color: rgba(200, 35, 51, 0.9);
    }

    #restartButton {
        bottom: 50px;
        left: 40px;
        padding: 25px 50px;
        font-size: 1.4em;
    }
}

@media (max-width: 768px), (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 2) {
    /* Override desktop rules for mobile and iPads/tablets */
    body {
        background-color: var(--bs-dark);
    }
    
    .game-container {
        width: 100%;
        height: 90vh; /* Use more screen space now that bottom buttons are removed */
        max-width: none;
        aspect-ratio: auto;
        margin: 0;
    }
    
    /* Hide desktop-only controls */
    .desktop-mute-btn {
        display: none !important;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
    }

    .hud {
        background: rgba(0, 0, 0, 0.5);
        padding: 10px;
        border-radius: 8px;
    }

    /* Keep Fire button visible, but hide the restart button */
    #restartButton {
        display: none !important;
    }
    
    /* Style the fire button for mobile */
    #fireButton {
        display: block !important;
        position: absolute;
        bottom: 10px; /* Move even closer to bottom */
        right: 15px;
        padding: 18px 35px;
        font-size: 1.3em;
        z-index: 50;
        border-radius: 12px;
        background-color: rgba(220, 53, 69, 0.9);
        border: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    }
    
    /* Hide the bottom navigation on mobile */
    .audio-controls, .nav {
        display: none !important;
    }
    
    /* Show the mobile menu toggle button */
    .mobile-menu-toggle {
        display: flex !important;
        justify-content: center;
        align-items: center;
    }
    
    /* Adjust mobile dropdown positioning */
    .mobile-menu {
        width: 200px;
    }
    
    /* Make menu buttons easier to tap */
    .menu-btn {
        padding: 15px;
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    /* Give fire button more prominence */
    .fire-btn {
        padding: 18px;
        font-size: 18px;
    }
    
    /* Ensure the container is tall enough but doesn't overflow */
    .container {
        height: auto;
        overflow: hidden;
        padding-bottom: 0;
    }
}
    
    /* Mobile audio controls */
    .audio-controls {
        margin: 10px 0;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    #startGameBtn, #toggleMuteBtn {
        width: auto;
        min-width: 120px;
        padding: 10px 15px;
        font-size: 1em;
    }
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: var(--bs-dark);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Device-specific display classes */
.desktop-only {
    display: none;
}

.mobile-only {
    display: none;
}

/* For iPads and other tablets, we use the mobile styles */
/* iPad-specific media query */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px), 
       only screen and (min-device-width: 810px) and (max-device-width: 1080px) {
    /* Controls for iPad specifically */
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .desktop-mute-btn,
    .audio-controls {
        display: none !important;
    }
    
    /* Game container for iPad */
    .game-container {
        width: 100%;
        height: 85vh; 
        margin: 0 auto;
    }
    
    /* Fire button has been removed - only mobile pulsating button remains */
}

/* General tablet/mobile styles */
@media only screen and (max-width: 1024px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    /* Mobile menu button should show on tablets */
    .mobile-menu-btn {
        display: flex !important;
    }
}

/* Desktop specific styles */
@media (min-width: 1025px) {
    .desktop-only {
        display: block;
    }
    
    .mobile-only {
        display: none !important;
    }
    body {
        background-color: #1a1a2e;
    }
    
    /* Hide mobile menu button on desktop */
    .mobile-menu-btn {
        display: none !important;
    }
    
    .container {
        max-width: 1800px;
        padding: 0 20px;
    }
    
    .game-container {
        max-width: 90%;
        width: 90%;
        height: 75vh;
        margin-bottom: 30px;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        box-shadow: 0 0 40px rgba(0, 0, 40, 0.7);
    }
    
    .hud {
        font-size: 1.2em;
        top: 25px;
        left: 25px;
        background: rgba(0, 0, 0, 0.6);
        padding: 15px;
        border-radius: 10px;
    }
    
    #fireButton {
        bottom: 40px;
        right: 40px;
        padding: 15px 40px;
        font-size: 1.4em;
        border-radius: 12px;
        background-color: #dc3545;
        border: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
        transition: all 0.2s ease;
    }
    
    #fireButton:hover {
        transform: scale(1.05);
        background-color: #c82333;
    }
    
    #restartButton {
        bottom: 40px;
        left: 40px;
        padding: 15px 40px;
        font-size: 1.4em;
        border-radius: 12px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
        transition: all 0.2s ease;
    }
    
    #restartButton:hover {
        transform: scale(1.05);
    }
    
    /* Enhance other elements on desktop */
    h1 {
        font-size: 3rem;
        margin-bottom: 1.5rem;
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    }
    
    /* Hide fire button on desktop, use spacebar instead */
    #fireButton {
        display: none !important; 
    }
    
    .nav-link {
        font-size: 1.2em;
        padding: 12px 24px;
        margin: 0 10px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    .nav-link:hover {
        transform: translateY(-3px);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }
}

.hud {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--bs-light);
    font-size: 0.9em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.controls-info {
    margin-top: 10px;
    font-size: 0.8em;
    opacity: 0.8;
}

#fireButton {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: none; /* Hidden by default (desktop) */
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 10px;
}

/* Make fire button visible on mobile and tablet */
@media only screen and (max-width: 1024px) {
    #fireButton {
        display: block !important;
    }
}

#restartButton {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

/* Game Modal Styles */
.game-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.game-modal.active {
    display: flex;
    opacity: 1;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    border: 2px solid #4a4a8a;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    color: #fff;
    max-width: 90%;
    width: 400px;
    transform: scale(0.7);
    opacity: 0;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 0 20px rgba(0, 0, 255, 0.2);
}

.game-modal.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-title {
    font-size: 24px;
    margin-bottom: 20px;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.modal-text {
    font-size: 18px;
    margin-bottom: 25px;
    line-height: 1.4;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(45deg, #4a4a8a, #2a2a4a);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 255, 0.2);
}

.modal-button.primary {
    background: linear-gradient(45deg, #00a8ff, #0097e6);
}

.modal-button.victory {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #000;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.modal-button.secondary {
    background: linear-gradient(45deg, #4a4a8a, #2a2a4a);
}

.modal-score {
    font-size: 24px;
    color: #00ffff;
    margin: 12px 0 24px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    white-space: pre-line;
    line-height: 1.2;
}

.modal-score .score-line {
    display: block;
    margin: 4px 0;
}

/* High score styling */
.form-control {
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #4a4a8a;
    background: rgba(0, 0, 0, 0.6);
    color: #00ffff;
    font-size: 16px;
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

.high-scores-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.high-score-entry {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 1fr;
    padding: 5px 10px;
    border-radius: 5px;
    background: rgba(0, 0, 255, 0.1);
    font-size: 14px;
    align-items: center;
}

.high-score-entry:nth-child(odd) {
    background: rgba(0, 0, 255, 0.2);
}

.high-score-entry:nth-child(1) {
    background: rgba(255, 215, 0, 0.3);
    font-weight: bold;
}

.high-score-entry:nth-child(2) {
    background: rgba(192, 192, 192, 0.3);
}

.high-score-entry:nth-child(3) {
    background: rgba(205, 127, 50, 0.3);
}

.high-score-entry .rank {
    font-weight: bold;
}

.high-score-entry .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.high-score-entry .score,
.high-score-entry .time {
    text-align: right;
}