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

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

#game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* --- THE SCREEN (Fixed Internal Resolution) --- */
#screen {
    width: 960px;  /* Base Width */
    height: 720px; /* Base Height */
    background: #111;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    flex-shrink: 0;
}

#three-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; 
}

#ui-layer {
    position: absolute;
    top: 0; left: 0;
    z-index: 10; 
    width: 100%;
    height: 100%;
    pointer-events: none; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Make UI Tighter by reducing margins/paddings */
h1 {
    text-align: center;
    margin-top: 5px;
    margin-bottom: 0px;
    text-shadow: 0 0 10px #00ffcc;
    color: #00ffcc;
    font-size: 1.8em;
}

.game-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    width: 100%;
    padding-top: 5px; /* Tighter padding */
}

.player-info {
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px; /* Tighter padding */
    border-radius: 10px;
    border: 1px solid #444;
    min-width: 180px;
    pointer-events: auto;
}

.center-info {
    text-align: center;
    color: #aaa;
    margin-top: 10px; /* Tighter margin */
}

h2 { margin: 0 0 10px 0; color: #fff; font-size: 1.2em; }

.score-box {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffcc00;
    margin-bottom: 10px;
}

#autoModeDisplay1, #autoModeDisplay2 { color: #00ffff; font-weight: bold; }
.gamepad-status { color: #00ff00; font-size: 0.8em; margin-top: 5px; }

/* Overlays Positioned over 3D areas */
#play-area-overlays {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.overlay-text {
    display: none; 
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 8em;
    font-weight: 900;
    color: #ff3333;
    text-shadow: 4px 4px 0 #000, 0 0 20px rgba(255, 0, 0, 0.8);
    background: rgba(0,0,0,0.4);
    padding: 20px 40px;
    border-radius: 10px;
    border: 4px solid #fff;
}

.p1-overlay { left: 25%; }
.p2-overlay { left: 75%; }

.paused-message {
    display: none;
    font-size: 2.5em;
    font-weight: 900;
    color: #ffff00;
    text-shadow: 2px 2px 0 #000;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

.bottom-bar {
    text-align: center;
    padding-bottom: 10px; /* Tighter */
    pointer-events: auto;
}

button {
    background: #006699;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 0 5px #006699;
}
button:hover { background: #0088cc; }

/* Help Modal positioned absolutely to scale with Screen */
#help-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.hidden { display: none !important; }

.help-content {
    background: #222;
    border: 2px solid #00ffcc;
    padding: 30px;
    border-radius: 10px;
    max-width: 700px;
    width: 90%;
    text-align: center;
}

.help-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.controls-section {
    background: #333;
    padding: 15px;
    border-radius: 5px;
    flex: 1;
    min-width: 180px;
    text-align: left;
}
.controls-section h3 { border-bottom: 1px solid #555; padding-bottom: 5px; color: #00ffcc; }
.controls-section p { margin: 5px 0; font-size: 0.9em; }

/* --- 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;
}
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; /* Let clicks pass through to empty space */
    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: 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: 26px;
    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: 10px;
    margin-bottom: 10px;
}
#mobile-action {
    display: flex;
    gap: 15px; 
    margin-right: 10px;
    margin-bottom: 10px;
}
