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

body {
    font-family: 'Outfit', system-ui, sans-serif;
    background: #0a0a1a;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.screen { display: none; position: fixed; inset: 0; z-index: 10; }
.screen.active { display: flex; align-items: center; justify-content: center; }

/* ===== MENU ===== */
#menu-screen {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}
.menu-content { text-align: center; max-width: 700px; padding: 40px; }
.game-title {
    font-size: 4rem; font-weight: 900; letter-spacing: -2px;
    background: linear-gradient(135deg, #f7971e, #ffd200, #ff6b6b);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 8px; line-height: 1.1;
}
.game-title span {
    font-size: 3rem;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.game-subtitle { color: #8888bb; font-size: 1.1rem; margin-bottom: 40px; }

.image-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; max-width: 520px; margin: 0 auto;
}
.image-option {
    background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 16px 12px; cursor: pointer;
    transition: all 0.3s ease; display: flex; flex-direction: column;
    align-items: center; gap: 10px;
}
.image-option:hover {
    border-color: #ffd200; background: rgba(255,210,0,0.08);
    transform: translateY(-4px); box-shadow: 0 8px 30px rgba(255,210,0,0.15);
}
.image-option canvas { border-radius: 8px; width: 80px; height: 80px; }
.image-option span { font-size: 0.85rem; font-weight: 600; color: #aaa; }
.image-option:hover span { color: #ffd200; }
.upload-option .upload-icon { font-size: 2.5rem; line-height: 80px; }

/* ===== LOADING ===== */
#loading-screen { background: #0a0a1a; }
.loading-content { text-align: center; }
.spinner {
    width: 50px; height: 50px; border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #ffd200; border-radius: 50%; margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== GAME ===== */
#game-screen { z-index: 1; }
#game-canvas { width: 100%; height: 100%; display: block; }

/* Palette */
#palette-panel {
    position: fixed; top: 50%; right: 20px; transform: translateY(-50%);
    background: rgba(10,10,30,0.85); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 16px;
    padding: 16px; min-width: 70px; z-index: 50;
}
#palette-panel h3 {
    font-size: 0.8rem; text-align: center; color: #888;
    margin-bottom: 12px; letter-spacing: 1px;
}
#palette-colors { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.palette-swatch {
    width: 48px; height: 48px; border-radius: 10px; cursor: pointer;
    border: 3px solid transparent; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 1.1rem; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    position: relative;
}
.palette-swatch:hover { transform: scale(1.15); }
.palette-swatch.selected {
    border-color: #fff; transform: scale(1.2);
    box-shadow: 0 0 20px rgba(255,255,255,0.4);
}
#selected-color-label {
    text-align: center; font-size: 0.7rem; color: #666;
    margin-top: 10px; min-height: 16px;
}

#mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
}

/* Progress */
#progress-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px;
    background: rgba(10,10,30,0.85); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 50px;
    padding: 8px 20px; z-index: 50;
}
#progress-bar {
    width: 200px; height: 8px; background: rgba(255,255,255,0.1);
    border-radius: 4px; overflow: hidden;
}
#progress-fill {
    height: 100%; width: 0%; border-radius: 4px;
    background: linear-gradient(90deg, #ffd200, #ff6b6b);
    transition: width 0.3s ease;
}
#progress-text { font-size: 0.8rem; color: #aaa; font-weight: 600; white-space: nowrap; }

/* Controls Hint */
#controls-hint {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(10,10,30,0.7); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 12px;
    padding: 8px 20px; font-size: 0.75rem; color: #666; z-index: 50;
    white-space: nowrap;
}
kbd {
    background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 4px;
    font-family: inherit; font-size: 0.7rem; color: #aaa;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ===== VICTORY ===== */
#victory-screen { background: rgba(10,10,30,0.95); }
.victory-content { text-align: center; }
.victory-content h1 { font-size: 3.5rem; margin-bottom: 10px; }
.victory-content p { color: #aaa; margin-bottom: 30px; font-size: 1.1rem; }
#victory-canvas { border-radius: 12px; max-width: 300px; border: 3px solid rgba(255,255,255,0.2); }
.btn-primary {
    margin-top: 30px; padding: 14px 40px; border: none; border-radius: 50px;
    background: linear-gradient(135deg, #ffd200, #ff6b6b); color: #000;
    font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: scale(1.05); box-shadow: 0 8px 30px rgba(255,210,0,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .game-title { font-size: 2.5rem; }
    .image-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    
    #controls-hint { display: none; } /* Hide PC hint on mobile */

    #progress-container { padding: 6px 14px; top: 10px; }
    #progress-bar { width: 120px; }

    /* Mobile Joystick & Speed Slider */
    #mobile-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
        bottom: 20px;
        width: 100%;
        padding: 0 20px;
    }
    
    #speed-control {
        display: flex;
        align-items: center;
        gap: 10px;
        background: rgba(10,10,30,0.8);
        padding: 8px 16px;
        border-radius: 30px;
        border: 1px solid rgba(255,255,255,0.15);
        backdrop-filter: blur(8px);
        width: 100%;
        max-width: 250px;
    }
    #speed-control input[type="range"] {
        flex: 1;
        accent-color: #ffd200;
    }

    #joystick-zone {
        width: 120px;
        height: 120px;
        position: relative;
        touch-action: none;
    }
    #joystick-base {
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        position: absolute;
        top: 0; left: 0;
        box-shadow: 0 4px 15px rgba(0,0,0,0.4);
        backdrop-filter: blur(5px);
    }
    #joystick-knob {
        width: 50px;
        height: 50px;
        background: linear-gradient(135deg, #ffd200, #ff6b6b);
        border-radius: 50%;
        position: absolute;
        top: 50%; left: 50%;
        transform: translate(-50%, -50%);
        box-shadow: 0 4px 10px rgba(0,0,0,0.5);
        pointer-events: none;
        transition: transform 0.05s linear;
    }

    /* Palette Panel Above Controls */
    #palette-panel { 
        top: auto; 
        bottom: 200px; 
        right: 50%;
        transform: translateX(50%);
        padding: 8px; 
        min-width: 95vw;
        border-radius: 12px;
    }
    #palette-colors { 
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        grid-auto-rows: min-content;
        gap: 4px;
        justify-content: center;
    }
    .palette-swatch { 
        width: 100%; 
        aspect-ratio: 1/1; 
        height: auto;
        font-size: 0.7rem; 
        border-radius: 6px;
        border-width: 2px;
    }
    #palette-panel h3 { display: none; } /* Hide "Cores" title to save space */
}
