/* --- VARIABLES GLOBALES (Couleurs) --- */
:root {
    --bg-color: #1e272e;
    --panel-bg: #2f3640;
    --text-color: #f5f6fa;
    --accent: #00a8ff;
    --success: #4cd137;
    --warning: #fbc531;
    --danger: #e84118;
}

/* --- STYLE GÉNÉRAL --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    overflow: hidden;
    display: flex;
    height: 100vh;
    user-select: none; /* Empêche la sélection de texte */
}

/* --- ZONE DE JEU --- */
#game-area {
    flex-grow: 1; /* Prend tout l'espace restant */
    position: relative;
    /* Motif de fond quadrillé */
    background-image: 
        radial-gradient(#353b48 15%, transparent 16%),
        radial-gradient(#353b48 15%, transparent 16%);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
    cursor: crosshair; /* Curseur viseur */
}

/* --- BARRE LATÉRALE --- */
#sidebar {
    width: 340px;
    background-color: var(--panel-bg);
    padding: 15px;
    display: flex;
    flex-direction: column;
    border-left: 4px solid var(--accent);
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    z-index: 30;
    overflow-y: auto; /* Scroll si trop d'éléments */
}

/* --- HUD (Stats) --- */
.stat-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.stat-box {
    flex: 1;
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #444;
}
.stat-value { font-size: 1.4rem; font-weight: bold; display: block; color: var(--warning); }
.stat-label { font-size: 0.75rem; color: #7f8fa6; text-transform: uppercase; }

/* --- BOUTIQUE --- */
h2 { margin-top: 0; color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 5px; font-size: 1.1rem; margin-bottom: 10px; }

.shop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.shop-item {
    background: #dcdde1;
    color: #2f3640;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    position: relative;
    opacity: 0.8;
    border: 3px solid transparent;
}
.shop-item:hover:not(.disabled) { transform: translateY(-2px); opacity: 1; background: #fff; }
.shop-item.disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(100%); }
.shop-item.selected { border-color: var(--warning); background: #fff; transform: scale(1.05); opacity: 1; z-index: 10; }

.item-icon { font-size: 1.8rem; display: block; margin-bottom: 2px; }
.item-name { font-weight: bold; display: block; font-size: 0.85rem; }
.item-cost { color: #c23616; font-weight: bold; font-size: 0.85rem; }

/* BOUTONS D'AMÉLIORATION */
.upgrade-btn {
    background: #ecf0f1;
    color: #2c3e50;
    border: none;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    position: relative;
    width: 100%;
}
.upgrade-btn:hover:not(.disabled) { background: #fff; transform: translateX(5px); }
.upgrade-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.upgrade-name { font-weight: bold; display: block; font-size: 0.9rem; }
.upgrade-cost { float: right; color: var(--danger); font-weight: bold; }
.upgrade-desc { font-size: 0.75rem; color: #666; display: block; }

/* PANNEAU D'AMÉLIORATION DYNAMIQUE */
#upgrade-panel {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    margin-top: auto; /* Pousse vers le bas */
    display: none;
    border: 2px dashed #7f8fa6;
}
#upgrade-panel.active { display: block; animation: fadeIn 0.3s; }

/* --- ÉCRANS (Overlays) --- */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    text-align: center;
}

h1 { font-size: 3rem; margin-bottom: 10px; color: var(--accent); text-shadow: 0 0 20px var(--accent); }
p { font-size: 1.2rem; max-width: 600px; margin-bottom: 30px; line-height: 1.6; }

.btn-start {
    padding: 15px 40px;
    font-size: 1.5rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 6px 0 #218c74;
    transition: transform 0.1s;
}
.btn-start:hover { transform: scale(1.05); }
.btn-start:active { transform: translateY(6px); box-shadow: none; }

.hidden { display: none !important; }

/* --- BARRE DE VIE --- */
#hp-container {
    position: absolute;
    bottom: 20px; left: 50%; transform: translateX(-50%);
    width: 500px; height: 25px;
    background: #222;
    border-radius: 15px;
    border: 3px solid #555;
    overflow: hidden;
    z-index: 10;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}
#hp-fill {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #e84118, #fbc531, #4cd137);
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#hp-text {
    position: absolute; width: 100%; text-align: center;
    line-height: 25px; font-weight: bold; text-shadow: 0 0 3px #000;
    font-size: 0.9rem; pointer-events: none;
}

/* --- TIMER VAGUE --- */
#wave-timer {
    position: absolute;
    top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 10px 30px;
    border-radius: 30px;
    border: 2px solid var(--warning);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--warning);
    z-index: 15;
    display: none;
}
#skip-btn {
    margin-left: 15px;
    font-size: 1rem;
    padding: 5px 15px;
    background: var(--warning);
    color: #333;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}
#skip-btn:hover { background: #fff; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }