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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

#game-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-color: #2d5a27;
    max-width: 100%;
    max-height: 100%;
}

#hud {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    color: #fff;
    font-size: 12px;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 10;
}

#hud.hidden {
    display: none;
}

#score {
    font-size: 14px;
    color: #ffff00;
}

#score-value {
    color: #ffffff;
}

#lives {
    color: #ff0000;
    font-size: 14px;
}

#weapons {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 10px;
}

.weapon {
    color: #00ff00;
}

.weapon.empty {
    color: #666;
}

#status-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: #ff0000;
    text-shadow: 2px 2px 0 #000;
    z-index: 15;
    animation: flash 0.5s infinite;
    pointer-events: none;
}

#status-message.hidden {
    display: none;
}

@keyframes flash {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 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-color: rgba(0, 0, 0, 0.95);
    color: #fff;
    z-index: 20;
}

.screen.hidden {
    display: none;
}

.screen h1 {
    font-size: 36px;
    color: #ff0000;
    text-shadow: 4px 4px 0 #800000;
    margin-bottom: 30px;
    letter-spacing: 4px;
    text-align: center;
}

.screen h2 {
    font-size: 18px;
    color: #ffff00;
    margin-bottom: 20px;
}

.screen p {
    font-size: 12px;
    margin: 8px 0;
    text-align: center;
}

.blink {
    animation: blink 1s infinite;
}

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

.controls-info {
    margin-top: 30px;
    text-align: center;
    color: #888;
    font-size: 10px;
}

.controls-info p {
    font-size: 10px;
    margin: 4px 0;
}

#pause-screen h1 {
    color: #ffff00;
    text-shadow: 4px 4px 0 #888800;
}

#game-over-screen #final-score {
    color: #00ff00;
    font-size: 24px;
}

#high-score-display {
    color: #ffff00;
    margin-top: 10px;
}

#continue-section {
    margin: 15px 0;
    text-align: center;
}

#continues-remaining {
    color: #00ff00;
    font-size: 10px;
    margin-bottom: 10px;
}

#continue-btn {
    background: #005500;
    border-color: #00ff00;
}

#continue-btn:hover {
    background: #007700;
}

#continue-btn:disabled {
    background: #333;
    color: #666;
    border-color: #555;
    cursor: not-allowed;
}

#continue-section.hidden {
    display: none;
}

/* Retro CRT effect (optional) */
#game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 100;
    opacity: 0.3;
}

/* Loading indicator */
#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    z-index: 30;
}

#loading.hidden {
    display: none;
}

/* Enemy/vehicle indicators on HUD */
.vehicle-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
}

/* Touch Controls Overlay */
#touch-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#touch-controls.hidden {
    display: none;
}

/* Virtual Joystick */
#joystick-area {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transition: background 0.1s;
}

/* Touch Buttons */
#touch-buttons {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.touch-btn:active,
.touch-btn.active {
    transform: scale(0.95);
}

/* Fire button - larger */
.fire-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 50, 50, 0.4);
}

.fire-btn:active,
.fire-btn.active {
    background: rgba(255, 100, 100, 0.7);
}

/* Weapon buttons */
#weapon-buttons {
    display: flex;
    gap: 8px;
}

.weapon-btn {
    width: 60px;
    height: 45px;
    font-size: 8px;
    background: rgba(50, 150, 50, 0.4);
}

.weapon-btn:active,
.weapon-btn.active {
    background: rgba(100, 200, 100, 0.7);
}

/* Responsive canvas scaling */
@media (max-width: 600px) {
    #hud {
        padding: 5px 10px;
        font-size: 10px;
    }

    #score {
        font-size: 11px;
    }

    #lives {
        font-size: 11px;
    }

    #weapons {
        font-size: 8px;
    }

    .screen h1 {
        font-size: 24px;
    }

    .screen h2 {
        font-size: 14px;
    }

    .screen p {
        font-size: 10px;
    }

    .controls-info {
        display: none;
    }

    #joystick-area {
        width: 100px;
        height: 100px;
        bottom: 20px;
        left: 20px;
    }

    #joystick-knob {
        width: 40px;
        height: 40px;
    }

    .fire-btn {
        width: 70px;
        height: 70px;
    }

    .weapon-btn {
        width: 50px;
        height: 40px;
        font-size: 7px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    #joystick-area {
        bottom: 15px;
        left: 15px;
        width: 80px;
        height: 80px;
    }

    #joystick-knob {
        width: 35px;
        height: 35px;
    }

    #touch-buttons {
        bottom: 15px;
        right: 15px;
    }

    .fire-btn {
        width: 60px;
        height: 60px;
        font-size: 9px;
    }

    .weapon-btn {
        width: 45px;
        height: 35px;
        font-size: 6px;
    }
}

/* Settings Menu */
.title-buttons {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.menu-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border: 2px solid #666;
    cursor: pointer;
    margin: 5px;
}

.menu-btn:hover {
    background: #555;
    border-color: #888;
}

.menu-btn:active {
    background: #222;
}

#settings-screen {
    justify-content: flex-start;
    padding-top: 40px;
    overflow-y: auto;
}

#settings-screen h1 {
    margin-bottom: 20px;
}

.settings-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
    width: 100%;
    max-width: 300px;
}

.settings-group label {
    font-size: 10px;
    color: #888;
    margin-bottom: 5px;
}

.settings-group input[type="range"] {
    width: 200px;
    height: 20px;
    background: #333;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.settings-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 20px;
    background: #ffff00;
    cursor: pointer;
}

.settings-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 20px;
    background: #ffff00;
    cursor: pointer;
    border: none;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
}

.diff-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 8px;
    padding: 8px 12px;
    background: #333;
    color: #888;
    border: 2px solid #555;
    cursor: pointer;
}

.diff-btn:hover {
    background: #444;
}

.diff-btn.active {
    background: #005500;
    color: #00ff00;
    border-color: #00ff00;
}

.loadout-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.load-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 7px;
    padding: 6px 10px;
    background: #333;
    color: #888;
    border: 2px solid #555;
    cursor: pointer;
}

.load-btn:hover {
    background: #444;
}

.load-btn.active {
    background: #005555;
    color: #00ffff;
    border-color: #00ffff;
}

#settings-back {
    margin-top: 20px;
}

/* FPS Counter */
#fps-counter {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 8px;
    color: #00ff00;
    text-shadow: 1px 1px 0 #000;
    z-index: 60;
    pointer-events: none;
}

#fps-counter.hidden {
    display: none;
}

/* Controls/Key Bindings Screen */
#controls-screen {
    justify-content: flex-start;
    padding-top: 30px;
}

.controls-hint {
    color: #888;
    font-size: 8px;
    margin-bottom: 15px;
}

.key-bindings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 250px;
}

.key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
}

.key-row span {
    color: #888;
}

.key-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 8px;
    padding: 6px 12px;
    min-width: 80px;
    background: #333;
    color: #fff;
    border: 2px solid #555;
    cursor: pointer;
}

.key-btn:hover {
    background: #444;
}

.key-btn.listening {
    background: #550000;
    border-color: #ff0000;
    animation: pulse-key 0.5s infinite;
}

@keyframes pulse-key {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.controls-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
