/* ROOT & BODY SETUP */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 100%;
}

body {
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centers everything nicely on desktop */
    align-items: center;
    overflow: auto;
    color: #f0f0f0;
    font-family: sans-serif;
}

/* --- MOBILE MODE LOCK --- */
/* Applied by JS when fullscreen is active */
body.mobile-mode {
    justify-content: flex-start; /* Pushes the UI to the absolute top edge */
    overflow: hidden; 
    touch-action: none; 
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* --- UI HEADER (Unscaled layer) --- */
#ui-header {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    z-index: 100;
    position: relative;
}

h1 {
    margin: 0 0 10px 0;
    font-size: 24px;
    text-align: center;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 10px;
    padding: 0 10px;
    box-sizing: border-box;
}

#ui-container { text-align: left; }
#ui-container p { margin: 2px 0; font-size: 14px; }
#gamepad-status { font-size: 12px; color: #aaa; margin-top: 5px !important;}

#help-prompt { text-align: right; color: #aaa; }
#help-prompt p { margin: 2px 0; font-size: 14px; }

/* --- THE SCREEN (Fixed Internal Resolution for Game) --- */
#screen {
    width: 720px;       /* Canvas Width */
    height: 484px;      /* Canvas Height (480) + Borders (4px total) so it doesn't clip */
    background: #1a1a1a;
    position: relative;
    /* Default origin is center, JS overrides this in mobile mode */
    transform-origin: center center;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    flex-shrink: 0;
}

/* --- Game Container --- */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-canvas {
    background-color: #000;
    border-top: 2px solid #555;
    border-bottom: 2px solid #555;
    display: block;
}

/* --- Help Menu Styling --- */
#help-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(20, 20, 20, 0.95);
    border: 2px solid #888;
    border-radius: 10px;
    padding: 20px 40px;
    z-index: 100;
    color: #f0f0f0;
    text-align: center;
}
#help-menu h2 { margin-top: 0; }
#help-menu button {
    padding: 10px 15px; margin: 10px;
    cursor: pointer; font-size: 1em;
}

.hidden { display: none !important; }

/* --- TOGGLE BUTTON --- */
#mobile-btn {
    position: fixed;
    top: 10px; left: 10px;
    z-index: 2000;
    background: #333;
    color: white;
    border: 2px solid white;
    border-radius: 5px;
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
}
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; }

/* --- CONTROL BUTTONS --- */
.mobile-control-btn {
    pointer-events: auto;
    width: 70px; height: 70px;
    background: rgba(255,255,255,0.15);
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    display: flex; justify-content: center; align-items: center;
    user-select: none;
    backdrop-filter: blur(4px);
    margin: 5px;
    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: 10px;
    margin-bottom: 20px; margin-left: 10px;
}
#mobile-action {
    display: flex; gap: 10px;
    margin-bottom: 20px; margin-right: 10px;
}
