:root {
    --bg-color: #1a1a2e;
    --primary-text: #e0e0e0;
    --hud-bg: rgba(0, 0, 0, 0.6);
    --btn-bg: rgba(255, 255, 255, 0.2);
    --btn-active-bg: rgba(255, 255, 255, 0.4);
    --accent: #ff4040;
}

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

html, body { 
    width: 100%; 
    height: 100%; 
    overflow: hidden; 
    background-color: #000;
    color: var(--primary-text); 
    font-family: 'Monaco', 'Consolas', monospace; 
}

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

/* --- FULLSCREEN CANVAS SETUP --- */
.game-container { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    z-index: 1; 
    background: #000;
}

#screen {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    position: absolute;
    top: 0; left: 0;
}

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

/* --- HUD & MENUS --- */
#hud {
    position: fixed; top: 10px; right: 10px;
    background-color: var(--hud-bg); padding: 10px;
    border-radius: 5px; font-size: 14px; text-align: right;
    pointer-events: none; z-index: 10;
}

.overlay-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background-color: rgba(20, 20, 30, 0.95); padding: 25px;
    border: 1px solid var(--primary-text); border-radius: 8px;
    z-index: 100; text-align: left; line-height: 1.6;
    max-width: min(700px, 90vw); box-shadow: 0 0 20px rgba(0,0,0,0.5);
    min-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
}

.overlay-panel.hidden { display: none; }
.overlay-panel h2 { text-align: center; margin: 0 0 15px 0; color: var(--accent); }
.overlay-panel h3 { color: #aaa; border-bottom: 1px solid #444; margin-bottom: 10px; padding-bottom: 5px; font-size: 1.1em;}
.overlay-panel button { display: block; margin: 20px auto 0; padding: 10px 20px; background: var(--btn-bg); color: var(--primary-text); border: 1px solid var(--primary-text); border-radius: 5px; cursor: pointer; }
.overlay-panel button:hover { background: var(--btn-active-bg); }

/* Option Controls */
.option-section { margin-bottom: 15px; }
.option-group { margin: 10px 0; }
.option-group label { display: block; margin-bottom: 5px; font-weight: bold; color: var(--accent); font-size: 0.9em; }
.option-group select { 
    width: 100%; padding: 8px; background: #333; color: white; border: 1px solid #666; border-radius: 4px; 
}
.option-group input[type=range] { width: 100%; cursor: pointer; }
.slider-note { font-size: 10px; color: #888; font-style: italic; margin-top: -2px; }

/* Table */
.overlay-panel table { width: 100%; border-collapse: collapse; }
.overlay-panel th, .overlay-panel td { border: 1px solid #555; padding: 8px; }
.overlay-panel th { background-color: rgba(255,255,255,0.1); }

/* --- CONTROLS OVERLAY --- */
#mobile-btn {
    position: fixed; top: 20px; left: 20px; z-index: 2000;
    background: #333; color: white; border: 3px solid white;
    font-size: 24px; padding: 16px 24px; cursor: pointer; border-radius: 8px;
}
body.mobile-mode #mobile-btn { display: none; }

#mobile-controls {
    position: fixed; bottom: 20px; left: 0; right: 0;
    width: 100%; height: 120px; display: none;
    justify-content: space-between; align-items: flex-end;
    padding: 0 20px; pointer-events: none; z-index: 20; 
}

.mobile-left, .mobile-right { 
    display: flex; 
    gap: 20px; 
}

.mobile-btn {
    width: 100px; height: 100px; 
    border-radius: 50%;
    border: 3px solid var(--primary-text); background-color: var(--btn-bg);
    color: var(--primary-text); 
    font-size: 18px; 
    font-weight: bold;
    display: flex; justify-content: center; align-items: center;
    user-select: none; -webkit-tap-highlight-color: transparent;
    margin-bottom: 10px; backdrop-filter: blur(4px);
    
    pointer-events: auto;
    touch-action: none;
}

.mobile-btn:active { background-color: var(--btn-active-bg); transform: scale(0.95); }

#bottom-ui-bar {
    position: fixed; bottom: 10px; left: 10px;
    z-index: 50; display: flex; gap: 10px;
}

#bottom-ui-bar button {
    background-color: var(--hud-bg); padding: 8px 12px;
    border: 1px solid #444; color: var(--primary-text);
    border-radius: 5px; font-size: 14px; cursor: pointer;
}

/* Touch Device Behaviors */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    #mobile-controls { display: flex; }
    #bottom-ui-bar { bottom: 150px; } 
}

/* Enforce controls if manual fullscreen was toggled */
body.mobile-mode #mobile-controls { display: flex; }
body.mobile-mode #bottom-ui-bar { bottom: 150px; }
