/* Core Reset */
body, html { margin: 0; padding: 0; overflow: hidden; background-color: #020617; touch-action: none; font-family: 'Segoe UI', system-ui, sans-serif; height: 100%; width: 100%; user-select: none; -webkit-user-select: none; transition: background-color 0.5s; }

/* Game Layer */
#game-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
canvas { display: block; width: 100%; height: 100%; outline: none; }

/* UI Screens */
.ui-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; display: flex; flex-direction: column; }
.interactive { pointer-events: auto; }
.hidden { display: none !important; }

/* Minimap */
#minimap-wrapper {
    width: 240px; height: 240px; 
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    overflow: hidden;
    display: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    margin-top: 10px;
}

/* Timer */
#game-timer {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 99px;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #22d3ee;
    z-index: 30;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}
#game-timer.danger { color: #ef4444; animation: pulse-red 1s infinite; }
#game-timer.turbo { color: #f59e0b; border-color: #f59e0b; }

/* Timer Styles for 2D Mode (Moved to bottom) */
body.view-2d #game-timer {
    top: auto;
    bottom: 30px;
    opacity: 0.6;
    background: rgba(15, 23, 42, 0.6);
}
body.view-2d #game-timer:hover {
    opacity: 1;
}

@keyframes pulse-red { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Controls */
#controls-ui { 
    display: none; 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    top: 0; 
    left: 0; 
    
    /* FIX: Lower Z-Index so buttons (z-20+) sit on top */
    z-index: 10; 
    
    touch-action: none; 
}

/* Remove old joystick visual classes if you want to keep the file clean */
.stick-zone, .stick-base, .stick-thumb {
    display: none !important;
}

/* Active State Visuals */
.stick-zone:active .stick-base,
.stick-zone:focus-within .stick-base {
    border-color: rgba(34, 211, 238, 0.8);
    background: rgba(34, 211, 238, 0.1);
    box-shadow: 0 0 25px rgba(34, 211, 238, 0.2);
}

/* Editor Default (Night Mode) */
.grid-cell { box-sizing: border-box; border: 1px solid rgba(255,255,255,0.05); cursor: pointer; }
.c-wall { background: #475569; }
.c-path { background: #0f172a; }
.c-start { background: #10b981; }
.c-end { background: #ef4444; }

/* Editor Day Mode Overrides */
.theme-day .c-wall { background: #15803d; border-color: #166534; } /* Green Hedge */
.theme-day .c-path { background: #86efac; border-color: #4ade80; } /* Light Grass */
.theme-day .grid-cell { border: 1px solid rgba(0,0,0,0.05); }

/* Editor Tool Icons in Day Mode */
.theme-day .icon-wall-preview { background-color: #15803d !important; border-color: #166534 !important; }
.theme-day .icon-path-preview { background-color: #86efac !important; border-color: #4ade80 !important; }

#editor-viewport { overflow: auto; touch-action: pan-x pan-y; cursor: grab; }
#editor-viewport.mode-draw { touch-action: none; cursor: crosshair; }
#editor-grid { display: grid; box-shadow: 0 20px 50px rgba(0,0,0,0.8); margin: auto; transform-origin: center; }

/* Technical Background Pattern for Editor */
.bg-grid-pattern {
    background-color: #020617;
    background-image: radial-gradient(rgba(51, 65, 85, 0.4) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Day Mode Grid Pattern */
.theme-day .bg-grid-pattern {
    background-color: #f0f9ff; /* Sky 50 */
    background-image: radial-gradient(rgba(14, 165, 233, 0.2) 1px, transparent 1px);
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(34, 211, 238, 0.2); }
    50% { box-shadow: 0 0 20px rgba(34, 211, 238, 0.6); }
    100% { box-shadow: 0 0 5px rgba(34, 211, 238, 0.2); }
}
.input-glow:focus { animation: glow 2s infinite; }

/* Mobile specific adjustments */
@media (max-width: 768px) {
    #minimap-wrapper { width: 160px; height: 160px; }
    .btn-game-ui span { display: none; }
    .btn-game-ui { padding: 8px 12px; }
    #ui-code-display { font-size: 0.65rem; padding: 4px 8px; }
}

/* Keyboard Badge */
.key-badge {
    background: rgba(255,255,255,0.1);
    padding: 0px 6px;
    border-radius: 4px;
    font-size: 0.7em;
    margin-left: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    color: #94a3b8;
}

/* Menu Focus Ring for Keyboard Navigation */
.menu-focus {
    outline: 2px solid #22d3ee;
    outline-offset: 2px;
    transform: scale(1.02);
    background-color: rgb(30 41 59) !important; /* slate-800 */
}

/* Custom Scrollbar for editor panel */
.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-track { background: #0f172a; }
.custom-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Mode Selectors */
.mode-btn.active { background-color: #0891b2; color: white; border-color: #22d3ee; }
.mode-btn { background-color: #1e293b; color: #94a3b8; border: 1px solid #334155; }

/* Day Mode Button Overrides */
.theme-day .mode-btn { background-color: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.theme-day .mode-btn.active { background-color: #0284c7; color: white; border-color: #0ea5e9; }
.theme-day .menu-focus { background-color: #f0f9ff !important; outline-color: #0ea5e9; }
