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

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

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #111;
    border: 2px solid #333;
}

#canvas {
    display: block;
    background: #000;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

#ui-overlay > * {
    pointer-events: auto;
}

#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0px #000;
}

#fuel-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#fuel-bar {
    width: 80px;
    height: 8px;
    background: #333;
    border: 1px solid #fff;
    position: relative;
}

#fuel-level {
    height: 100%;
    background: #00FF00;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.menu-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border: 2px solid #fff;
    min-width: 200px;
}

#main-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.95);
    padding: 30px;
    border: 2px solid #FFD700;
}

#main-menu h1 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #FFD700;
    text-shadow: 2px 2px 0px #000;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

button {
    background: #333;
    color: #fff;
    border: 2px solid #fff;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

button:hover {
    background: #fff;
    color: #000;
}

button:active {
    transform: scale(0.95);
}

#game-over-menu, #pause-menu, #settings-menu, #controls-menu, #high-scores-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.95);
    padding: 20px;
    border: 2px solid #fff;
    min-width: 250px;
}

#game-over-menu h2, #pause-menu h2, #settings-menu h2, #controls-menu h2, #high-scores-menu h2 {
    margin-bottom: 15px;
    color: #FFD700;
}

#final-score, #final-distance {
    margin: 10px 0;
    font-size: 14px;
}

#new-record {
    color: #FFD700;
    font-weight: bold;
    margin: 10px 0;
    animation: blink 1s infinite;
}

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

.setting {
    margin: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting label {
    font-size: 12px;
}

select, input[type="range"] {
    background: #333;
    color: #fff;
    border: 1px solid #fff;
    padding: 5px;
    font-family: inherit;
}

.controls-info p {
    margin: 8px 0;
    font-size: 14px;
}

.score-entry {
    margin: 8px 0;
    font-size: 14px;
    text-align: left;
}

#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

#dpad {
    display: grid;
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    width: 120px;
    height: 120px;
}

.dpad-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
}

.dpad-btn[data-direction="up"] {
    grid-column: 2;
    grid-row: 1;
}

.dpad-row {
    grid-column: 1 / 4;
    grid-row: 2;
    display: flex;
    gap: 5px;
}

.dpad-btn[data-direction="down"] {
    grid-column: 2;
    grid-row: 3;
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#fire-btn, #pause-btn {
    width: 80px;
    height: 50px;
    background: rgba(255, 0, 0, 0.7);
    font-size: 12px;
}

#pause-btn {
    background: rgba(255, 255, 0, 0.7);
    color: #000;
}

.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 600px) {
    #game-container {
        width: 100vw;
        height: 100vh;
    }
    
    .menu-container, #main-menu, #game-over-menu, #pause-menu, #settings-menu, #controls-menu, #high-scores-menu {
        max-width: 90vw;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    #hud {
        font-size: 10px;
    }
    
    #mobile-controls {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }
    
    #dpad {
        width: 100px;
        height: 100px;
    }
    
    .dpad-btn {
        font-size: 16px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #mobile-controls {
        bottom: 5px;
        left: 5px;
        right: 5px;
    }
    
    #dpad {
        width: 80px;
        height: 80px;
    }
    
    #fire-btn, #pause-btn {
        width: 60px;
        height: 35px;
        font-size: 10px;
    }
}