/* ROOT & BODY SETUP */
body {
    margin: 0;
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Prevent scrolling */
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* --- MOBILE MODE LOCK --- */
body.mobile-mode {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    touch-action: none;
}

/* --- CONTAINER & SCREEN SCALING --- */
#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#screen {
    /* MATCHES GAME_WIDTH / GAME_HEIGHT IN JS */
    width: 1600px;
    height: 900px;
    position: relative;
    background-color: #000;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    flex-shrink: 0;
    transform-origin: center center;
    border: 4px solid #444;
    border-radius: 4px;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}

/* --- TOGGLE BUTTON --- */
#mobile-btn {
    position: fixed;
    top: 10px; left: 10px;
    z-index: 2000;
    background: #333;
    color: white;
    border: 2px solid white;
    font-size: 12px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
}
body.mobile-mode #mobile-btn { display: none; }

/* --- MOBILE CONTROLS OVERLAY --- */
#mobile-controls {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3000;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px;
    box-sizing: border-box;
}
body.mobile-mode #mobile-controls { display: flex; }

.mobile-control-btn {
    pointer-events: auto;
    width: 90px; height: 90px;
    background: rgba(255,255,255,0.15);
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    color: white;
    font-size: 40px;
    display: flex; justify-content: center; align-items: center;
    user-select: none;
    backdrop-filter: blur(4px);
    margin-bottom: 20px;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.mobile-control-btn:active { 
    background: rgba(255,255,255,0.4); 
    transform: scale(0.95);
}
#mobile-dpad { display: flex; gap: 15px; margin-left: 20px; margin-bottom: 20px; }
#mobile-action { margin-right: 40px; margin-bottom: 40px; }

/* --- HUD --- */
#hud {
    position: absolute;
    top: 20px; left: 20px; right: 20px;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 24px; font-weight: bold; color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10;
}

#health-container, #fuel-container {
    display: flex; align-items: center;
    background: rgba(0,0,0,0.4);
    padding: 8px 15px; border-radius: 15px;
}
#health-bar-outer, #fuel-bar-outer {
    width: 200px; height: 20px;
    background-color: rgba(50, 50, 50, 0.8);
    border: 1px solid #888; border-radius: 8px;
    margin-left: 15px; overflow: hidden;
}
#health-bar-inner { width: 100%; height: 100%; background-color: #4CAF50; transition: width 0.2s linear; }
#fuel-bar-inner { width: 100%; height: 100%; background-color: #FFC107; transition: width 0.2s linear; }

/* --- OVERLAYS & UI SCREENS --- */
.overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(245, 245, 255, 0.98);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #ccc;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 500px;
    max-height: 90%;
    overflow-y: auto;
    z-index: 20;
    color: #333;
}

#start-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.9), rgba(10, 10, 20, 0.95));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 20;
}
#start-screen h2 { margin-bottom: 10px; font-size: 4rem; text-shadow: 0 0 10px #0af; margin-top: 0; }

.button-row { display: flex; gap: 20px; margin: 25px 0; }
.difficulty-setting-main { margin-bottom: 20px; font-size: 1.2rem; }
.difficulty-setting-main select { font-size: 1rem; padding: 5px; border-radius: 5px; }
.slider-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: -10px; }

/* --- PAUSE INDICATOR --- */
#pause-indicator {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px; font-weight: 900;
    color: white;
    text-shadow: 4px 4px 0 #000;
    letter-spacing: 10px;
    pointer-events: none;
    display: none;
    z-index: 50;
    text-transform: uppercase;
}

/* --- BUTTONS --- */
button:not(.mobile-control-btn) {
    padding: 15px 35px;
    font-size: 18px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
button:not(.mobile-control-btn):hover { transform: translateY(-2px); box-shadow: 0 6px 8px rgba(0,0,0,0.3); }

#start-day-button { background: #3498db; color: white; }
#start-night-button { background: #2c3e50; color: white; }
#help-button { background: #f1c40f; color: #222; }
#restart-button { background: #e74c3c; color: white; }
#close-help-button { background: #333; color: white; }

/* --- MISC --- */
.overlay-text {
    position: absolute; top: 20%; left: 50%;
    transform: translateX(-50%);
    font-size: 32px; font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0 5px #000;
    pointer-events: none;
    display: none;
    z-index: 15;
    background: rgba(0,0,0,0.3);
    padding: 5px 20px; border-radius: 20px;
}
#autobot-countdown {
    position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
    font-size: 20px; color: #aaa; z-index: 30;
}
#bottom-help-hint {
    width: 100%; margin-top: 10px; color: #888; text-align: center; font-size: 16px;
}

.slider-control { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.slider-control label { width: 90px; text-align: left; font-size: 14px; }
.slider-control input { flex: 1; }
.slider-control span { font-family: monospace; background: #eee; padding: 2px 5px; border-radius: 3px; }

#help-screen ul { text-align: left; margin: 10px 0; padding-left: 20px; }
#help-screen li { margin-bottom: 5px; }
