body {
    margin: 0;
    padding: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari viewport fix */
    font-family: Arial, sans-serif;
    overflow: hidden;
    touch-action: none; /* Prevent mobile scrolling/zooming */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-overflow-scrolling: none;
    position: fixed; /* iOS Safari address bar fix */
    width: 100%;
    height: 100%;
}

#gameContainer {
    position: relative;
    border: 2px solid #333;
}

#gameCanvas {
    background: linear-gradient(to bottom, #000428, #004e92);
    display: block;
}

#ui {
    position: absolute;
    top: 10px;
    left: 10px;
    color: white;
    font-size: 20px;
    z-index: 10;
}

#pauseMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 48px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    display: none;
    z-index: 20;
}

#startScreen, #gameOverScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 30;
}

.screen-title {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.screen-button {
    padding: 15px 30px;
    font-size: 24px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 10px;
    transition: background 0.3s;
}

.screen-button:hover {
    background: #0088ff;
}

.instructions {
    text-align: center;
    margin: 20px 0;
    line-height: 1.5;
}

#gameOverScreen {
    display: none;
}

/* Responsive Game Canvas - iPhone Optimized */
@media (max-width: 900px) and (min-width: 721px) {
    #gameContainer {
        transform: scale(0.85);
        transform-origin: center center;
    }
}

@media (max-width: 720px) and (min-width: 431px) {
    #gameContainer {
        transform: scale(0.7);
        transform-origin: center center;
        margin-bottom: 140px; /* Room for mobile controls */
    }
    
    body {
        align-items: flex-start;
        padding-top: 10px;
    }
}

/* iPhone 12/13/14 Pro Max (428px) and similar */
@media (max-width: 430px) and (min-width: 391px) {
    #gameContainer {
        transform: scale(0.55);
        transform-origin: center center;
        margin-bottom: 120px;
    }
    
    body {
        align-items: flex-start;
        padding-top: 5px;
    }
    
    .screen-title {
        font-size: 28px !important;
    }
    
    .screen-button {
        font-size: 16px !important;
        padding: 8px 16px !important;
    }
}

/* iPhone 12/13/14 (390px) and iPhone 12 mini (375px) */
@media (max-width: 390px) {
    #gameContainer {
        transform: scale(0.48);
        transform-origin: center center;
        margin-bottom: 110px;
    }
    
    body {
        align-items: flex-start;
        padding-top: 2px;
    }
    
    .screen-title {
        font-size: 26px !important;
        margin-bottom: 15px !important;
    }
    
    .screen-button {
        font-size: 14px !important;
        padding: 8px 16px !important;
    }
    
    .instructions {
        font-size: 12px !important;
        line-height: 1.3 !important;
        margin: 15px 0 !important;
    }
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    z-index: 100;
    display: none; /* Hidden by default, shown on mobile */
    pointer-events: none; /* Allow clicks to pass through empty areas */
}

/* Show mobile controls on touch devices and iOS */
@media (pointer: coarse), (hover: none), (-webkit-touch-callout: none) {
    .mobile-controls {
        display: block;
    }
}

/* Force show on detected mobile (JS will control this) */
.mobile-controls.show-mobile {
    display: block !important;
}

/* Joystick Area */
.joystick-area {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
}

.joystick-base {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    backdrop-filter: blur(5px);
}

.joystick-knob {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Action Buttons */
.action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.action-button {
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    user-select: none;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.fire-button {
    background: rgba(255, 0, 0, 0.7);
    border: 3px solid rgba(255, 100, 100, 0.8);
}

.fire-button:active {
    background: rgba(255, 50, 50, 0.9);
    transform: scale(0.95);
}

.pause-button {
    background: rgba(100, 100, 100, 0.7);
    border: 3px solid rgba(200, 200, 200, 0.8);
    font-size: 24px;
}

.pause-button:active {
    background: rgba(150, 150, 150, 0.9);
    transform: scale(0.95);
}

/* Mobile Instructions Overlay */
.mobile-instructions {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 1000;
    display: none;
    pointer-events: auto;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.mobile-instructions p {
    margin: 0 0 15px 0;
    font-size: 16px;
    line-height: 1.4;
}

.close-instructions {
    background: #0066cc;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.2s ease;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.close-instructions:hover {
    background: #0088ff;
}

.close-instructions:active {
    background: #004499;
    transform: scale(0.98);
}

/* Additional mobile optimizations */
@media (max-height: 600px) {
    .mobile-controls {
        height: 150px;
    }
    
    .joystick-area {
        width: 100px;
        height: 100px;
        bottom: 15px;
        left: 15px;
    }
    
    .joystick-knob {
        width: 35px;
        height: 35px;
    }
    
    .action-buttons {
        bottom: 15px;
        right: 15px;
    }
    
    .action-button {
        width: 65px;
        height: 65px;
        font-size: 14px;
    }
    
    .pause-button {
        font-size: 20px;
    }
}

/* Landscape mode adjustments for mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #gameContainer {
        transform: scale(0.7) !important;
        margin-bottom: 80px !important;
    }
    
    .mobile-controls {
        height: 120px;
    }
    
    .joystick-area {
        width: 80px;
        height: 80px;
        bottom: 20px;
        left: 20px;
    }
    
    .joystick-knob {
        width: 30px;
        height: 30px;
    }
    
    .action-buttons {
        bottom: 20px;
        right: 20px;
        gap: 10px;
    }
    
    .action-button {
        width: 55px;
        height: 55px;
        font-size: 12px;
    }
    
    .pause-button {
        font-size: 18px;
    }
} 