/* ROOT & BODY SETUP */
body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: #1e272e; /* Dark theme */
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Prevent scrolling for a tighter game feel */
    box-sizing: border-box;
}

/* --- MOBILE MODE LOCK --- */
body.mobile-mode {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    touch-action: none;
    justify-content: center;
    background-color: #000;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 800px;
    max-width: 100vw;
    padding: 10px 20px;
    box-sizing: border-box;
    background: #2c3e50;
    border-bottom: 2px solid #34495e;
}

body.mobile-mode #top-bar {
    display: none; /* Auto-hide when scaled to mobile */
}

#top-bar h1 {
    margin: 0;
    font-size: 1.2rem;
    color: #e74c3c;
    text-align: right; /* Aligns header to the right */
}

.top-buttons {
    display: flex;
}

.top-buttons button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin-right: 10px; /* Space to the right of each button */
    transition: background 0.2s ease;
}

.top-buttons button:last-child {
    margin-right: 0; /* Removes margin on the last button */
}

.top-buttons button:hover { background: #c0392b; }

#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    width: 100%;
}

/* --- THE SCREEN (Fixed Internal Resolution) --- */
#screen {
    width: 800px;  /* Base Width matching canvas */
    height: 600px; /* Base Height matching canvas */
    background: #000;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

#gameArea, canvas {
    display: block;
    width: 100%; 
    height: 100%;
    position: absolute;
    top: 0; left: 0;
}

/* --- MOBILE CONTROLS OVERLAY --- */
#mobile-controls {
    position: absolute;
    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: 30px;
    box-sizing: border-box;
}

body.mobile-mode #mobile-controls {
    display: flex;
}

.mobile-control-btn {
    pointer-events: auto;
    width: 75px; height: 75px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    color: white;
    font-size: 30px;
    display: flex; justify-content: center; align-items: center;
    user-select: none;
    backdrop-filter: blur(4px);
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-control-btn:active, .mobile-control-btn.active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

#mobile-dpad { display: flex; gap: 20px; }

/* --- OPTIONS MODAL --- */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.7);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal.hidden { display: none; }

.modal-content {
    background-color: #34495e;
    border-radius: 8px;
    padding: 25px;
    width: 350px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 25px rgba(0,0,0,0.8);
    color: #ecf0f1;
}

.close-btn {
    position: absolute;
    top: 15px; right: 20px;
    color: #ecf0f1;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover { color: #e74c3c; }

/* Original Controls Menu Formatting */
.controls-info h2 { margin-top: 0; color: #e74c3c; border-bottom: 1px solid #7f8c8d; padding-bottom: 8px; font-size: 20px;}
.gamepad-info { background-color: #2c3e50; border: 1px solid #7f8c8d; padding: 10px; margin-bottom: 15px; border-radius: 5px; }
.gamepad-info p { margin: 0; font-size: 0.85em; color: #bdc3c7; line-height: 1.4; }
.gamepad-info strong { color: #1abc9c; }
#autoFollowStatus { margin-top: 10px; font-weight: bold; color: #1abc9c; text-align: center; }

.button-row { margin-bottom: 12px; }
.control-description { display: block; margin-bottom: 5px; font-size: 0.85em; color: #ecf0f1; }
.control-description strong { color: #f1c40f; }
.action-buttons { display: flex; gap: 8px; }
.action-buttons button { flex-grow: 1; }
.button-controls-container button {
    background-color: #5D6D7E; color: #ecf0f1; border: 1px solid #7F8C8D;
    padding: 8px 10px; border-radius: 5px; cursor: pointer; font-size: 0.85em;
    transition: background 0.2s ease; width: 100%; box-sizing: border-box; text-align: center;
    font-weight: bold;
}
.button-controls-container button:hover { background-color: #718497; }
.button-controls-container button:active { background-color: #4A5B6A; transform: translateY(1px); }
.button-controls-container button strong { color: #f1c40f; margin-right: 5px; }
