/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #2d5a27, #4a7c59);
    color: white;
    overflow: hidden;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameArea {
    position: relative;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    cursor: default;
}

/* UI Styles */
#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#topBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    font-size: 18px;
    font-weight: bold;
}

#coins, #waveInfo, #lives {
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#sidebar {
    position: absolute;
    right: 0;
    top: 0;
    width: 280px;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    padding: 20px;
    overflow-y: auto;
    pointer-events: all;
    animation: slideIn 0.3s ease-out;
}

#sidebar h3 {
    color: #FFD700;
    margin-bottom: 15px;
    text-align: center;
    font-size: 20px;
}

.tower-shop {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tower-card {
    background: linear-gradient(135deg, #2d5a27, #4a7c59);
    border: 2px solid #1e3d1f;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    pointer-events: all;
    opacity: 1;
}

.tower-card.affordable {
    opacity: 1;
}

.tower-card:not(.affordable) {
    opacity: 0.5;
    cursor: not-allowed;
}

.tower-card:not(.affordable):hover {
    transform: none;
    box-shadow: none;
}

.tower-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
}

.tower-card img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

.tower-info {
    text-align: center;
}

.tower-name {
    font-size: 16px;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 5px;
}

.tower-cost {
    font-size: 14px;
    color: #90EE90;
    margin-bottom: 5px;
}

.tower-desc {
    font-size: 12px;
    color: #ccc;
    margin-bottom: 5px;
}

.upgrade-info {
    font-size: 11px;
    color: #aaa;
}

#startWaveBtn {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: linear-gradient(135deg, #FF4500, #FF8C00);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#startWaveBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 69, 0, 0.5);
}

#startWaveBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.upgrade-btn {
    position: absolute;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    z-index: 100;
    pointer-events: all;
}

.upgrade-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

.upgrade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Upgrade paths popup */
.upgrade-paths-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: linear-gradient(135deg, #2d5a27, #4a7c59);
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid #1e3d1f;
}

.popup-content h3 {
    color: #FFD700;
    margin-bottom: 20px;
    text-align: center;
    font-size: 24px;
}

.upgrade-tree {
    margin-bottom: 30px;
}

.upgrade-tree h4 {
    color: #FFD700;
    margin-bottom: 15px;
    font-size: 18px;
}

.upgrade-path {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.upgrade-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
    min-width: 100px;
}

.upgrade-level img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
}

.level-name {
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 5px;
}

.level-cost {
    color: #90EE90;
    font-size: 14px;
    margin-bottom: 5px;
}

.level-desc {
    font-size: 12px;
    color: #ccc;
    text-align: center;
}

.upgrade-arrow {
    font-size: 24px;
    color: #FFD700;
    font-weight: bold;
}

#closeUpgradePaths {
    display: block;
    margin: 20px auto 0;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#closeUpgradePaths:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* Skin management styles */
#skinSelector {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

#skinSelector h3 {
    color: #FFD700;
    margin-bottom: 10px;
}

#openSkinPanel {
    width: 100%;
    padding: 8px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

#openSkinPanel:hover {
    background: #764ba2;
}

/* Achievement notifications */
.skin-unlock-notification {
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive design */
@media (max-width: 1200px) {
    #sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    #sidebar {
        width: 220px;
    }
    
    .tower-card {
        padding: 10px;
    }
    
    .tower-card img {
        height: 60px;
    }
}