* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    color: #fff;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 800px;
    height: 600px;
    background: #000;
    border: 4px solid #304cb2;
    box-shadow: 0 0 20px rgba(48, 76, 178, 0.5);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000;
}

.screen.hidden {
    display: none;
}

/* Start Screen */
#start-screen #logo {
    max-width: 600px;
    margin-bottom: 40px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.instruction {
    font-size: 24px;
    color: #ffbf27;
    margin: 20px 0;
    animation: blink 1s infinite;
}

.controls {
    font-size: 16px;
    color: #888;
    margin-top: 10px;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Game Screen */
#game-screen.hidden #hud {
    display: none;
}

#gameCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    pointer-events: none;
    z-index: 10;
}

#score, #wave, #lives {
    font-weight: bold;
}

#score-value {
    color: #ffbf27;
}

#wave-value {
    color: #304cb2;
}

#lives-value {
    color: #c8102e;
}

/* Game Over Screen */
#game-over-screen h1 {
    font-size: 72px;
    color: #c8102e;
    margin-bottom: 30px;
    text-shadow: 4px 4px 8px #000;
}

.final-score {
    font-size: 32px;
    color: #ffbf27;
    margin: 20px 0;
}

.high-score {
    font-size: 24px;
    color: #304cb2;
    margin: 10px 0 30px 0;
}

/* Mobile controls - hidden by default */
.mobile-only {
    display: none;
}

#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 20;
}

#direction-controls {
    display: flex;
    gap: 15px;
}

#shoot-controls {
    display: flex;
    align-items: center;
}

.control-btn {
    width: 80px;
    height: 80px;
    background: rgba(48, 76, 178, 0.7);
    border: 3px solid #304cb2;
    border-radius: 50%;
    color: #fff;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-btn:active {
    background: rgba(48, 76, 178, 1);
    transform: scale(0.95);
}

.shoot-btn {
    width: 100px;
    height: 100px;
    background: rgba(200, 16, 46, 0.7);
    border-color: #c8102e;
}

.shoot-btn:active {
    background: rgba(200, 16, 46, 1);
}

/* Mobile/Portrait Mode */
@media (max-width: 768px), (orientation: portrait) {
    body {
        align-items: flex-start;
        padding: 0;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        border: none;
        box-shadow: none;
        max-width: 100%;
        max-height: 100%;
    }

    #game-screen:not(.hidden) {
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 10px;
    }

    #start-screen, #game-over-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .screen.hidden {
        display: none !important;
    }

    #gameCanvas {
        width: 100vw !important;
        height: calc(100vh - 380px) !important;
        max-height: none;
        object-fit: contain;
    }

    #start-screen #logo {
        max-width: 80%;
        margin-bottom: 20px;
    }

    .instruction {
        font-size: 20px;
    }

    .controls:not(.mobile-only) {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    #game-screen:not(.hidden) #mobile-controls {
        display: flex;
        bottom: 60px;
        padding-bottom: env(safe-area-inset-bottom, 60px);
    }

    #hud {
        font-size: 16px;
        top: 5px;
        left: 5px;
        right: 5px;
    }

    #game-over-screen h1 {
        font-size: 48px;
    }

    .final-score {
        font-size: 24px;
    }

    .high-score {
        font-size: 18px;
    }
}

/* Desktop/Landscape Mode */
@media (min-width: 769px) and (orientation: landscape) {
    #game-container {
        width: 800px;
        height: 600px;
    }
}
