/* ============================================
   TOWER DEFENSE - STYLES GLOBAUX
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: #0d0d1a;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    display: flex;
    gap: 12px;
    background: #1a1a2e;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 0 50px rgba(0,0,0,0.6);
    align-items: flex-start;
}

/* ====== CANVAS ====== */
#game-canvas {
    border: 2px solid #333;
    border-radius: 8px;
    cursor: crosshair;
    display: block;
    image-rendering: pixelated;
}

/* ====== PANNEAU LATÉRAL ====== */
#side-panel {
    width: 270px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-section {
    background: #16213e;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #252545;
}

.panel-title {
    font-size: 13px;
    font-weight: bold;
    color: #e94560;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 1px solid #252545;
    padding-bottom: 6px;
}

/* ====== RESOURCES ====== */
.resource-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}
.resource-label { color: #888; }
.resource-value { font-weight: bold; }
.gold-value { color: #ffd700; }
.lives-value { color: #e94560; }
.level-value { color: #00b4d8; }
.wave-value { color: #48bb78; }

/* ====== GRILLE DE TOURS ====== */
.tower-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.tower-btn {
    width: 46px;
    height: 46px;
    border: 2px solid #333;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
    transition: all 0.15s ease;
}
.tower-btn:hover {
    border-color: #fff;
    transform: scale(1.12);
    z-index: 2;
}
.tower-btn.selected {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(255,255,255,0.6);
    transform: scale(1.12);
}
.tower-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.tower-btn.disabled:hover {
    transform: none;
    border-color: #333;
}

/* Badge niveau d'upgrade */
.tower-btn .up-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ffd700;
    color: #000;
    border-radius: 50%;
    width: 17px;
    height: 17px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tooltip */
.tower-btn .tooltip {
    display: none;
    position: absolute;
    bottom: 54px;
    left: 50%;
    transform: translateX(-50%);
    background: #0a0a1a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 10px;
    width: 190px;
    z-index: 100;
    font-size: 11px;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    pointer-events: none;
}
.tower-btn:hover .tooltip { display: block; }
.tooltip-name { color: #fff; font-weight: bold; margin-bottom: 3px; font-size: 12px; }
.tooltip-stat { color: #aaa; }
.tooltip-stat span { color: #fff; font-weight: bold; }
.tooltip-cost { color: #ffd700; font-weight: bold; margin-top: 3px; }

/* ====== COMBOS ====== */
.combo-bar {
    font-size: 11px;
    color: #f6e05e;
    min-height: 24px;
    max-height: 48px;
    overflow-y: auto;
    line-height: 1.4;
}
.combo-none { color: #555 !important; }

/* ====== BOUTONS D'ACTION ====== */
.action-btn {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.action-btn:hover:not(:disabled) { transform: scale(1.03); filter: brightness(1.15); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: none; }

#btn-start-wave { background: #e94560; color: #fff; }
#btn-start-wave:hover:not(:disabled) { background: #ff6b81; }

#btn-upgrades { background: #00b4d8; color: #fff; margin-top: 5px; }
#btn-upgrades:hover:not(:disabled) { background: #48cae4; }

#btn-time-speed { background: #9b59b6; color: #fff; margin-top: 5px; }
#btn-time-speed:hover:not(:disabled) { background: #8e44ad; }

/* ====== MODALE UPGRADES ====== */
#upgrade-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
#upgrade-modal.active { display: flex; }

.upgrade-content {
    background: #16213e;
    border: 1px solid #252545;
    border-radius: 12px;
    padding: 20px;
    max-width: 750px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.upgrade-title {
    color: #e94560;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
}
.upgrade-subtitle {
    color: #aaa;
    font-size: 13px;
    margin-bottom: 15px;
}
.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.upgrade-item {
    background: #1a1a2e;
    border: 1px solid #252545;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: border-color 0.15s;
}
.upgrade-item:hover { border-color: #444; }

.upgrade-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.upgrade-info { flex: 1; min-width: 0; }
.upgrade-name { font-weight: bold; font-size: 13px; color: #fff; }

.upgrade-levels { display: flex; gap: 3px; margin-top: 4px; }

.upgrade-lvl {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #444;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.upgrade-lvl.active { background: #48bb78; border-color: #48bb78; color: #fff; }
.upgrade-lvl.available {
    border-color: #00b4d8;
    cursor: pointer;
}
.upgrade-lvl.available:hover { background: #00b4d8; color: #fff; }
.upgrade-lvl.locked { color: #444; }

.upgrade-effect {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.upgrade-cost {
    color: #ffd700;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}
.upgrade-cost.maxed { color: #48bb78; }

/* Affichage de l'or dans le modal upgrades */
.upgrade-or-info {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    padding: 12px 0 8px 0;
    border-bottom: 1px solid #252545;
    margin-bottom: 4px;
}

.upgrade-close {
    width: 100%;
    padding: 10px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
}
.upgrade-close:hover { background: #ff6b81; }

/* ====== OVERLAY (Game Over / Victoire) ====== */
#overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(6px);
}
#overlay.active { display: flex; }

.overlay-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255,255,255,0.2);
}
.overlay-subtitle {
    font-size: 18px;
    color: #aaa;
    margin-bottom: 30px;
}
.overlay-buttons { display: flex; gap: 10px; }

.overlay-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.15s;
}
.overlay-btn:hover { transform: scale(1.05); }
.btn-restart { background: #e94560; color: #fff; }
.btn-restart:hover { background: #ff6b81; }
.btn-next { background: #48bb78; color: #fff; }
.btn-next:hover { background: #68d391; }

/* ====== BONUS DISPLAY ====== */
.bonus-display {
    font-size: 11px;
    color: #888;
    min-height: 24px;
    line-height: 1.4;
}

/* ====== MODALE OPTIONS ====== */
#options-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1500;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
#options-modal.active { display: flex; }

.options-content {
    background: #16213e;
    border: 1px solid #252545;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.options-title {
    color: #e94560;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
}

.options-subtitle {
    color: #aaa;
    font-size: 13px;
    margin-bottom: 20px;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.options-item {
    background: #1a1a2e;
    border: 1px solid #252545;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.options-item-info {
    flex: 1;
    min-width: 0;
}

.options-item-name {
    font-weight: bold;
    font-size: 14px;
    color: #fff;
    margin-bottom: 2px;
}

.options-item-desc {
    font-size: 11px;
    color: #888;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333;
    border-radius: 26px;
    transition: 0.2s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #48bb78;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.3);
}

.options-close {
    width: 100%;
    padding: 10px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
}
.options-close:hover { background: #ff6b81; }

/* ====== SCROLLBAR ====== */
.upgrade-content::-webkit-scrollbar,
.panel-section::-webkit-scrollbar { width: 6px; }
.upgrade-content::-webkit-scrollbar-track,
.panel-section::-webkit-scrollbar-track { background: #111; }
.upgrade-content::-webkit-scrollbar-thumb,
.panel-section::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
