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

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 4px 20px rgba(255, 87, 34, 0.4));
}

#logoCanvas {
    display: block;
}

#game-container {
    position: relative;
    width: 1400px;
    height: 800px;
    background: #0f0f23;
    border-radius: 12px;
    box-shadow: 0 0 60px rgba(0, 200, 255, 0.3), 
                inset 0 0 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 12px;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    pointer-events: auto;
}

#stats {
    display: flex;
    gap: 30px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.stat-icon {
    font-size: 20px;
}

.stat span:last-child {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

#game-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(145deg, #4CAF50, #2E7D32);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

.control-btn:active {
    transform: translateY(0);
}

#tower-panel {
    position: absolute;
    right: 10px;
    top: 80px;
    width: 180px;
    background: linear-gradient(180deg, rgba(20,20,40,0.95) 0%, rgba(10,10,30,0.95) 100%);
    border-radius: 12px;
    padding: 15px;
    pointer-events: auto;
    border: 2px solid rgba(100,150,255,0.3);
    box-shadow: 0 0 30px rgba(0,100,255,0.2);
}

#tower-panel h3 {
    color: #fff;
    text-align: center;
    margin-bottom: 15px;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(255,200,100,0.5);
}

#tower-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tower-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(145deg, rgba(60,60,80,0.8), rgba(40,40,60,0.8));
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.tower-btn:hover {
    background: linear-gradient(145deg, rgba(80,80,100,0.9), rgba(60,60,80,0.9));
    border-color: rgba(255,200,100,0.5);
    transform: scale(1.02);
}

.tower-btn.selected {
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255,215,0,0.5);
}

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

.tower-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.tower-details {
    flex: 1;
}

.tower-name {
    font-weight: bold;
    font-size: 13px;
}

.tower-cost {
    font-size: 12px;
    color: #FFD700;
}

#tower-info {
    position: absolute;
    left: 10px;
    top: 80px;
    width: 200px;
    background: linear-gradient(180deg, rgba(20,20,40,0.95) 0%, rgba(10,10,30,0.95) 100%);
    border-radius: 12px;
    padding: 15px;
    pointer-events: auto;
    border: 2px solid rgba(100,150,255,0.3);
    box-shadow: 0 0 30px rgba(0,100,255,0.2);
}

#tower-info h3 {
    color: #fff;
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
}

#info-content {
    color: #ccc;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 15px;
}

#info-content .stat-line {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#upgrade-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.upgrade-btn {
    padding: 10px;
    background: linear-gradient(145deg, #2196F3, #1565C0);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    position: relative;
    z-index: 100;
}
    transition: all 0.2s ease;
}

.upgrade-btn:hover {
    background: linear-gradient(145deg, #42A5F5, #1976D2);
    transform: scale(1.02);
}

.upgrade-btn.disabled {
    background: #555;
    cursor: not-allowed;
}

.sell-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(145deg, #f44336, #c62828);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sell-btn:hover {
    background: linear-gradient(145deg, #ef5350, #d32f2f);
}

.hidden {
    display: none !important;
}

#game-over, #victory {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

#game-over h1 {
    color: #f44336;
    font-size: 64px;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(244,67,54,0.5);
}

#victory h1 {
    color: #FFD700;
    font-size: 64px;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255,215,0,0.5);
}

#game-over p, #victory p {
    color: #fff;
    font-size: 24px;
    margin-bottom: 15px;
}

#restart-btn, #play-again-btn {
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(145deg, #4CAF50, #2E7D32);
    color: white;
    margin-top: 20px;
    transition: all 0.2s ease;
}

#restart-btn:hover, #play-again-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(76,175,80,0.5);
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    pointer-events: none;
    z-index: 1000;
    max-width: 250px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Range indicator */
.range-indicator {
    position: absolute;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 50%;
    pointer-events: none;
}

/* Portrait mode warning overlay */
#rotate-device {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.rotate-content {
    text-align: center;
    color: #fff;
    padding: 40px;
}

.rotate-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.rotate-content h2 {
    font-size: 28px;
    margin-bottom: 15px;
    color: #FF5722;
    text-shadow: 0 0 20px rgba(255, 87, 34, 0.5);
}

.rotate-content p {
    font-size: 18px;
    color: #aaa;
}

/* Show rotate warning in portrait on mobile/tablet */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    #rotate-device {
        display: flex;
    }
    
    #game-wrapper {
        display: none;
    }
}

/* Mobile landscape adjustments */
@media screen and (max-width: 1024px) and (orientation: landscape) {
    body {
        padding: 0;
    }
    
    #game-wrapper {
        gap: 0;
        width: 100%;
        height: 100%;
    }
    
    #logo-container {
        display: none;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    #gameCanvas {
        border-radius: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    #tower-panel {
        right: 5px;
        top: 60px;
        width: 140px;
        padding: 10px;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }
    
    #tower-panel h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .tower-btn {
        padding: 8px;
        gap: 6px;
    }
    
    .tower-icon {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .tower-name {
        font-size: 11px;
    }
    
    .tower-cost {
        font-size: 10px;
    }
    
    #tower-info {
        left: 5px;
        top: 60px;
        width: 160px;
        padding: 10px;
    }
    
    #top-bar {
        padding: 8px 10px;
    }
    
    #stats {
        gap: 10px;
    }
    
    .stat {
        padding: 4px 8px;
        gap: 4px;
    }
    
    .stat-icon {
        font-size: 14px;
    }
    
    .stat span:last-child {
        font-size: 13px;
    }
    
    .control-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Drag preview for tower placement on mobile */
#drag-preview {
    display: none;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    font-size: 48px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

#drag-preview.active {
    display: block;
}
