:root {
    --ui-cyan: #00ffff;
    --ammo-yellow: #ffdd00;
    --fuel-green: #39ff14;
    --fuel-orange: #ffaa00;
    --buy-green: #39ff14;
    --danger-red: #ff2222;
    --panel-bg: rgba(6, 10, 25, 0.95);
    
    --tab-ship: #00ffff;
    --tab-tech: #d500f9;
    --tab-life: #ff1744;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }

body { 
    background: #000; 
    overflow: hidden; 
    font-family: 'Courier New', monospace; 
    position: fixed; width: 100%; height: 100%; 
    touch-action: none; 
    cursor: crosshair;
    display: flex; justify-content: center; align-items: center;
}

/* EFFET SCANLINES SUBTIL */
body::after { 
    content: " "; display: block; position: absolute; top: 0; left: 0; bottom: 0; right: 0; 
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.05) 50%), radial-gradient(circle, rgba(0,0,0,0) 50%, rgba(0,0,0,0.4) 100%); 
    background-size: 100% 4px, 100% 100%; z-index: 1000; pointer-events: none; 
}

#gameContainer {
    position: relative;
    box-shadow: 0 0 80px rgba(0, 255, 255, 0.1);
    overflow: hidden;
    background: radial-gradient(circle at center, #0b1221 0%, #000000 100%);
    border: 1px solid #111;
}

#gameCanvas { 
    display: block; 
    width: 100%; 
    height: 100%; 
    cursor: none; 
}

.ui-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
#damageOverlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; background: red; opacity: 0; transition: opacity 0.1s; z-index: 5; mix-blend-mode: overlay; }
#flashOverlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; background: white; opacity: 0; transition: opacity 0.05s; z-index: 6; mix-blend-mode: screen; }

/* POPUP DEBLOCAGE */
#unlockOverlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 50;
    display: flex; justify-content: center; align-items: center;
}

.unlock-popup {
    background: rgba(0, 20, 30, 0.95); border: 3px solid #39ff14;
    padding: 1.5rem; border-radius: 12px; text-align: center;
    color: #fff; box-shadow: 0 0 60px rgba(57, 255, 20, 0.4), inset 0 0 20px rgba(57, 255, 20, 0.2);
    animation: popInBounce 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
    width: 85%; max-width: 450px;
    backdrop-filter: blur(10px);
}

.unlock-title { 
    font-size: 1.4rem; color: #39ff14; font-weight: 900; margin-bottom: 10px; 
    text-transform: uppercase; letter-spacing: 2px; text-shadow: 0 0 15px #39ff14;
}
.unlock-text { font-size: 0.9rem; color: #fff; line-height: 1.4; font-weight: bold; }

@keyframes popInBounce {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ANIMATION OBJET DEBLOQUÉ */
.new-item-glow {
    animation: glowPulse 1s infinite alternate;
    border-color: #39ff14 !important;
    position: relative;
    z-index: 2;
}
@keyframes glowPulse {
    from { box-shadow: 0 0 5px #39ff14; }
    to { box-shadow: 0 0 25px #39ff14, inset 0 0 10px rgba(57, 255, 20, 0.3); transform: scale(1.02); }
}

/* ALERTE ONGLET */
.tab-alert { position: relative; overflow: visible; }
.tab-alert::after {
    content: "!"; position: absolute; top: -5px; right: -5px;
    background: #39ff14; color: #000; font-size: 12px; font-weight: 900;
    width: 20px; height: 20px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; box-shadow: 0 0 10px #39ff14;
    animation: bounceAlert 0.8s infinite; z-index: 10;
}
@keyframes bounceAlert { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }


/* MENU STYLES */
.menu {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: var(--ui-cyan); text-shadow: 0 0 15px currentColor;
    pointer-events: auto; background: var(--panel-bg); padding: 1.5rem;
    border: 2px solid var(--ui-cyan); 
    box-shadow: 0 0 60px rgba(0, 255, 255, 0.25), inset 0 0 30px rgba(0, 255, 255, 0.05);
    border-radius: 16px; width: 90%; max-width: 550px; max-height: 90%;
    display: flex; flex-direction: column; backdrop-filter: blur(15px);
    overflow-y: auto;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    
    z-index: 100;
    
    transition: border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

/* VARIANTES DE COULEURS DU MENU */
.menu.menu-ship {
    border-color: var(--tab-ship);
    color: var(--tab-ship);
    box-shadow: 0 0 60px rgba(0, 255, 255, 0.25), inset 0 0 30px rgba(0, 255, 255, 0.05);
}
.menu.menu-tech {
    border-color: var(--tab-tech);
    color: var(--tab-tech);
    box-shadow: 0 0 60px rgba(213, 0, 249, 0.25), inset 0 0 30px rgba(213, 0, 249, 0.05);
}
.menu.menu-life {
    border-color: var(--tab-life);
    color: var(--tab-life);
    box-shadow: 0 0 60px rgba(255, 23, 68, 0.25), inset 0 0 30px rgba(255, 23, 68, 0.05);
}

@keyframes popIn { from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.menu::-webkit-scrollbar { width: 4px; }
.menu::-webkit-scrollbar-thumb { background: currentColor; border-radius: 2px; }

.menu h1 { 
    font-size: clamp(1.5rem, 6vw, 2.5rem); margin-bottom: 0.2rem; letter-spacing: 0.15em; color: #fff; flex-shrink: 0; font-weight: 900; 
    text-shadow: 0 0 10px currentColor;
}
.menu h2 { font-size: 0.8rem; color: #fff; margin-bottom: 1.5rem; letter-spacing: 0.1em; flex-shrink: 0; text-transform: uppercase; font-weight: bold; opacity: 0.8; }

.tabs-container { display: flex; width: 100%; margin-bottom: 15px; border-bottom: 2px solid rgba(255,255,255,0.1); gap: 4px; }
.tab-btn { flex: 1; padding: 12px 5px; background: rgba(255,255,255,0.03); border: none; color: #888; font-family: inherit; font-weight: 800; font-size: 0.75rem; cursor: pointer; transition: all 0.2s; border-top-left-radius: 8px; border-top-right-radius: 8px; position: relative; top: 2px; }
.tab-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.tab-btn.active { background: linear-gradient(to top, rgba(255,255,255,0.1), transparent); color: #fff; border-bottom: 2px solid currentColor; top: 0; text-shadow: 0 0 20px currentColor; }

.tab-btn[data-cat="VAISSEAU"].active { color: var(--tab-ship); }
.tab-btn[data-cat="ARSENAL"].active { color: var(--tab-tech); }
.tab-btn[data-cat="STRUCTURE"].active { color: var(--tab-life); }

.upgrade-container { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding: 5px; touch-action: pan-y; min-height: 250px; }
.upgrade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; animation: fadeInUp 0.3s ease-out; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.upgrade-item { 
    border: 1px solid rgba(255,255,255,0.1); padding: 10px; display: flex; flex-direction: column; 
    justify-content: space-between; background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(0,0,0,0.4)); 
    min-height: 110px; border-radius: 8px; transition: transform 0.1s, border-color 0.2s;
}
.upgrade-item:hover { border-color: rgba(255,255,255,0.3); background: linear-gradient(160deg, rgba(255,255,255,0.08), rgba(0,0,0,0.4)); }

.upgrade-name { font-weight: 900; color: #fff; font-size: 0.85rem; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; text-shadow: 0 0 5px rgba(255,255,255,0.3); }
.upgrade-desc { font-size: 0.65rem; color: #ccc; line-height: 1.3; margin-bottom: 8px; }
.upgrade-level { font-size: 0.75rem; color: var(--ammo-yellow); font-weight: bold; display: flex; justify-content: space-between; align-items: center; }

.btn { 
    background: rgba(0, 255, 255, 0.1); border: 2px solid var(--ui-cyan); color: #ffffff; 
    text-shadow: 0 0 15px var(--ui-cyan); padding: 1rem 1.5rem; font-size: 1.2rem; cursor: pointer; 
    margin: 0.5rem; font-family: inherit; font-weight: 900; border-radius: 8px; text-transform: uppercase; 
    transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; overflow: hidden; letter-spacing: 2px;
}
.btn:hover { background: rgba(0, 255, 255, 0.3); color: #fff; transform: scale(1.05); box-shadow: 0 0 30px rgba(0, 255, 255, 0.4); border-color: #fff; }
.btn.danger { border-color: var(--danger-red); color: var(--danger-red); background: rgba(255, 34, 34, 0.1); text-shadow: 0 0 15px var(--danger-red); }

.upgrade-btn { width: 100%; padding: 10px; font-size: 0.9rem; margin-top: auto; border-width: 2px; font-weight: bold; cursor: pointer; border-radius: 6px; letter-spacing: 1px; }
.upgrade-btn.buyable { border-color: var(--buy-green); color: #000; background: var(--buy-green); box-shadow: 0 0 20px rgba(57, 255, 20, 0.4); }
.upgrade-btn.locked { border-color: #444; color: #666; background: transparent; cursor: not-allowed; }
.upgrade-btn.maxed { border-color: #666; color: #666; background: transparent; cursor: default; opacity: 0.6; }

/* --- GAMEPAD NAVIGATION --- */
@keyframes focusPulse {
    0% { box-shadow: 0 0 15px #fff, inset 0 0 10px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 25px #fff, inset 0 0 20px rgba(255, 255, 255, 0.7); }
    100% { box-shadow: 0 0 15px #fff, inset 0 0 10px rgba(255, 255, 255, 0.5); }
}

.gamepad-focus {
    border-color: #fff !important;
    background: rgba(255, 255, 255, 0.15) !important;
    animation: focusPulse 1.5s infinite;
    transform: scale(1.05);
    color: #fff !important;
    text-shadow: 0 0 10px #fff;
    outline: none;
    z-index: 10;
}

/* SPECIFIQUE POUR INPUT RANGE */
input[type=range].gamepad-focus {
    filter: drop-shadow(0 0 5px #fff);
}

/* INDICATIONS MANETTE (Glyphs) */
#gamepadHints {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 200;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.hint-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-shadow: 0 0 5px #000;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
}

.btn-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #222;
    border: 2px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}
.btn-icon.green { border-color: #39ff14; color: #39ff14; box-shadow: 0 0 8px rgba(57, 255, 20, 0.3); }
.btn-icon.red { border-color: #ff2222; color: #ff2222; box-shadow: 0 0 8px rgba(255, 34, 34, 0.3); }
.btn-icon.rect { border-radius: 6px; width: 40px; } /* Pour L1/R1 */

.level-select-container, .control-select-container, .orientation-select-container { margin: 8px 0; border: 1px solid rgba(0, 255, 255, 0.3); padding: 8px; border-radius: 8px; background: rgba(0, 20, 40, 0.6); }
select { background: transparent; color: var(--ui-cyan); border: none; padding: 5px; font-family: inherit; font-size: 1.1rem; font-weight: bold; width: 100%; outline: none; text-align: center; text-shadow: 0 0 5px currentColor; cursor: pointer; }
option { background: #050a10; color: var(--ui-cyan); }

/* SLIDER STYLES */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; margin: 5px 0; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%; background: var(--ui-cyan); cursor: pointer; margin-top: -7px; box-shadow: 0 0 10px var(--ui-cyan); border: 2px solid #fff; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: rgba(0,255,255,0.3); border-radius: 2px; }

.highscore { color: var(--thrust-orange); font-size: 1.3rem; margin: 0.8rem; font-weight: 900; letter-spacing: 1px; text-shadow: 0 0 20px var(--thrust-orange); }
.score-value { color: #fff; text-shadow: 0 0 15px #fff; }

.pause-btn { position: absolute; top: 20px; right: 20px; width: 50px; height: 50px; border: 2px solid var(--ui-cyan); border-radius: 50%; color: var(--ui-cyan); font-size: 22px; font-weight: 900; display: flex; align-items: center; justify-content: center; cursor: pointer; background: rgba(0,0,0,0.5); pointer-events: auto; z-index: 20; backdrop-filter: blur(4px); box-shadow: 0 0 15px var(--ui-cyan); transition: transform 0.2s; }

/* CONTROLES TACTILES */
.touch-controls { 
    position: absolute; bottom: 0; width: 100%; height: 100%; 
    pointer-events: none; 
    touch-action: none; 
    transition: opacity 0.3s;
    z-index: 50; 
}

.control-zone { position: absolute; pointer-events: auto; }
.joystick-zone { left: 20px; bottom: 20px; width: 160px; height: 160px; opacity: 0.5; }
.button-zone { right: 20px; bottom: 20px; pointer-events: auto; }
.control-btn { position: absolute; width: 90px; height: 90px; border: 3px solid; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 1.8rem; cursor: pointer; opacity: 0.4; pointer-events: auto; backdrop-filter: blur(4px); transition: transform 0.1s, opacity 0.1s; }
.control-btn.thrust { border-color: var(--thrust-orange); color: var(--thrust-orange); background: rgba(255, 119, 0, 0.1); box-shadow: 0 0 10px rgba(255, 119, 0, 0.3); }
.control-btn.fire { border-color: var(--reload-red); color: var(--reload-red); background: rgba(255, 51, 51, 0.1); box-shadow: 0 0 10px rgba(255, 51, 51, 0.3); }
.control-btn:active { transform: scale(0.92); opacity: 1; background: rgba(255,255,255,0.15); }

/* CLASSE UTILITAIRE CRITIQUE */
.hidden { display: none !important; }

/* ========================================= */
/* --- AJOUT CHIRURGICAL: GAMEPAD FOCUS --- */
/* ========================================= */

/* SELECT (Mission & Controls) */
select.gamepad-focus {
    background-color: rgba(0, 255, 255, 0.2) !important;
    border-color: #39ff14 !important;
    color: #fff !important;
    box-shadow: 0 0 15px #39ff14, inset 0 0 10px rgba(57, 255, 20, 0.3) !important;
    transform: scale(1.05);
    /* Petit effet visuel pour indiquer la direction possible */
    background-image: linear-gradient(to right, transparent 0%, rgba(57,255,20,0.2) 50%, transparent 100%);
    transition: all 0.2s ease-out;
}

/* BOUTON ENGAGE (Animation spéciale) */
#mainMenu button.gamepad-focus {
    animation: pulseEngage 0.8s infinite alternate;
    background-color: rgba(57, 255, 20, 0.2) !important;
    border-color: #39ff14 !important;
}

@keyframes pulseEngage {
    from { box-shadow: 0 0 10px #39ff14; transform: scale(1.02); }
    to { box-shadow: 0 0 25px #39ff14; transform: scale(1.06); }
}
