body {
    margin: 0;
    background-color: #0d1b2a;
    color: #fca311;
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    border: 4px solid #fca311;
    box-shadow: 0 0 20px rgba(252, 163, 17, 0.5);
    /* Make the container responsive */
    width: 95vw;
    max-width: 800px; /* The game's native width */
    max-height: calc(95vw * 0.75); /* Maintain 4:3 aspect ratio based on width */
    aspect-ratio: 4 / 3;
}
@media (min-aspect-ratio: 4/3) {
    #game-container {
        width: auto;
        height: 95vh;
        max-height: 600px; /* The game's native height */
    }
}
canvas {
    display: block;
    /* Background is now controlled by JS, so remove it from here */
    /* Make canvas fill the responsive container */
    width: 100%;
    height: 100%;
}
#ui {
    position: absolute;
    /* Adjust UI position to be outside the container's top border */
    top: -2.5em; 
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: clamp(10px, 2.5vw, 16px); /* Responsive font size */
    user-select: none;
    align-items: flex-start; /* Align items to the top */
}
.ui-btn {
    padding: 5px 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(8px, 2vw, 12px);
    background-color: #e63946;
    color: #f1faee;
    border: 2px solid #0d1b2a;
    cursor: pointer;
    box-shadow: 0 2px #780000;
    transition: all 0.1s ease-in-out;
    display: none; /* Hidden by default */
}
.ui-btn:hover {
    transform: translateY(1px);
    box-shadow: 0 1px #780000;
}
.ui-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0px #780000;
}
.score-group, .stats-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.left-ui {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}
.stats-group {
    align-items: flex-end;
}
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    z-index: 10;
}

#start-screen h1 {
    font-size: 2em;
    color: #e63946;
    text-shadow: 2px 2px #fca311;
}

#start-screen p {
    font-size: 1em;
    margin-top: 20px;
    animation: blink 1.5s linear infinite;
}
#start-screen-subtitle {
    font-size: 0.8em;
    color: #f1faee;
    max-width: 80%;
    line-height: 1.5;
    margin-top: -10px;
    margin-bottom: 30px;
    animation: none; /* Disable blinking for the subtitle */
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
#new-high-score-message {
    display: none; /* Hidden by default */
    color: #ffdd00;
    font-size: 1.5em;
    margin: 10px 0;
    text-shadow: 3px 3px #e63946;
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}
#game-over-options {
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}
#main-menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
#level-select-container {
    display: none; /* Initially hidden */
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    max-width: 90%;
    margin-top: 20px;
}
#level-select-container .level-btn {
    padding: 8px 12px;
    font-size: 14px;
    min-width: 50px;
}
.level-btn.locked {
    background-color: #6c757d;
    color: #343a40;
    box-shadow: 0 4px #495057;
    cursor: not-allowed;
    transform: none;
}
.level-btn.locked:hover {
    transform: none;
    box-shadow: 0 4px #495057;
}
.menu-btn {
    padding: 10px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    background-color: #fca311;
    color: #0d1b2a;
    border: 3px solid #0d1b2a;
    cursor: pointer;
    box-shadow: 0 4px #e63946;
    transition: all 0.1s ease-in-out;
}
.menu-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 2px #e63946;
}
.menu-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px #e63946;
    transform: translateY(4px);
    box-shadow: 0 0px #e63946;
}
#level-instructions {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none; /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 15;
}
#level-instructions p {
    font-size: 1.1em;
    color: #f1faee;
    max-width: 80%;
    line-height: 1.6;
    animation: none;
}
#level-instructions strong {
    color: #fca311;
}
#victory-options {
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}
#touch-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}
/* Show controls only on touch devices or smaller screens */
@media (hover: none) and (pointer: coarse), (max-width: 800px) {
    #touch-controls {
        display: flex;
    }
}
.touch-btn {
    background-color: rgba(252, 163, 17, 0.4);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 30px;
    font-family: 'Press Start 2P', cursive;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; /* Disable tap highlight */
}
.touch-btn:active {
    background-color: rgba(252, 163, 17, 0.7);
}
#touch-shoot {
    width: 120px;
    height: 60px;
    border-radius: 15px;
    font-size: 20px;
}
/* Media query for smaller screens to improve readability */
@media (max-width: 600px) {
    #start-screen h1 {
        font-size: 1.6em;
        line-height: 1.2;
    }
    #start-screen-subtitle {
        font-size: 0.75em;
        max-width: 90%;
    }
    .menu-btn {
        font-size: 14px;
        padding: 10px 15px;
    }
    #game-over-options {
        gap: 10px;
    gap: 10px;
    margin-top: 25px;
  }
}
#confirm-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}
.modal-content {
    background-color: #0d1b2a;
    padding: 2em;
    border: 4px solid #fca311;
    text-align: center;
    box-shadow: 0 0 20px rgba(252, 163, 17, 0.5);
    max-width: 80%;
}
.modal-content p {
    font-size: clamp(14px, 3vw, 16px);
    color: #f1faee;
    line-height: 1.5;
    margin: 0 0 1.5em 0;
    animation: none; /* Override blinking text animation */
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}
#confirm-yes-btn {
    background-color: #e63946;
    box-shadow: 0 4px #780000;
}
#confirm-yes-btn:hover {
    box-shadow: 0 2px #780000;
}
#confirm-yes-btn:active {
    box-shadow: 0 0 #780000;
}