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

body {
    font-family: 'Special Elite', cursive;
    background: #1a1510;
    color: #d4c4a8;
    overflow: hidden;
    min-height: 100vh;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    background: linear-gradient(135deg, #2a2015 0%, #1a1510 50%, #0f0a05 100%);
}

/* Header */
#game-header {
    background: linear-gradient(180deg, #3a2a1a 0%, #2a1a0a 100%);
    border-bottom: 3px solid #654321;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

#game-header h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vw, 20px);
    color: #ffd700;
    text-shadow: 2px 2px 0 #000, 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
}

#header-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 2vw, 12px);
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #654321;
}

.stat img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

/* Main Game Area */
#game-main {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

#canvas {
    flex: 1;
    display: block;
    cursor: crosshair;
}

/* Tower Panel */
#tower-panel {
    width: 200px;
    background: linear-gradient(180deg, #3a2a1a 0%, #2a1a0a 100%);
    border-left: 3px solid #654321;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#tower-panel h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #ffd700;
    text-align: center;
    border-bottom: 2px solid #654321;
    padding-bottom: 10px;
}

#tower-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.tower-option {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #654321;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.tower-option:hover {
    border-color: #ffd700;
    transform: scale(1.05);
}

.tower-option.selected {
    border-color: #0f0;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.tower-option img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.tower-cost {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: #ffd700;
}

#tower-info {
    font-size: 11px;
    line-height: 1.6;
    color: #a89070;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    min-height: 80px;
}

/* Footer Controls */
#game-footer {
    background: linear-gradient(180deg, #2a1a0a 0%, #3a2a1a 100%);
    border-top: 3px solid #654321;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

#start-wave-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    background: linear-gradient(180deg, #4a0 0%, #360 100%);
    color: #fff;
    border: 2px solid #5b0;
    padding: 12px 25px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    text-shadow: 1px 1px 0 #000;
}

#start-wave-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5b0 0%, #4a0 100%);
    transform: scale(1.05);
}

#start-wave-btn:disabled {
    background: #444;
    border-color: #666;
    cursor: not-allowed;
}

#speed-controls {
    display: flex;
    gap: 5px;
}

.speed-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: #d4c4a8;
    border: 2px solid #654321;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.speed-btn:hover {
    border-color: #ffd700;
}

.speed-btn.active {
    background: #654321;
    border-color: #ffd700;
    color: #ffd700;
}

#pause-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: #d4c4a8;
    border: 2px solid #654321;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

#pause-btn:hover {
    border-color: #ffd700;
}

/* Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#overlay.hidden {
    display: none;
}

#overlay-content {
    background: linear-gradient(180deg, #3a2a1a 0%, #2a1a0a 100%);
    border: 4px solid #654321;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 90%;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#overlay-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(20px, 5vw, 32px);
    color: #ffd700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #000, 0 0 20px rgba(255, 215, 0, 0.5);
}

#overlay-message {
    font-size: 16px;
    margin-bottom: 15px;
}

#overlay-score {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #ffd700;
    margin-bottom: 25px;
}

#restart-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    background: linear-gradient(180deg, #4a0 0%, #360 100%);
    color: #fff;
    border: 3px solid #5b0;
    padding: 15px 30px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

#restart-btn:hover {
    background: linear-gradient(180deg, #5b0 0%, #4a0 100%);
    transform: scale(1.05);
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1510;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-content h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vw, 18px);
    color: #ffd700;
    margin-bottom: 30px;
}

.loading-bar {
    width: 300px;
    max-width: 80vw;
    height: 20px;
    background: #2a1a0a;
    border: 2px solid #654321;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4a0, #ffd700);
    transition: width 0.3s;
}

#loading-text {
    font-size: 14px;
    color: #a89070;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #tower-panel {
        position: absolute;
        bottom: 60px;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        border-left: none;
        border-top: 3px solid #654321;
        padding: 10px;
        gap: 10px;
        background: rgba(42, 26, 10, 0.95);
    }
    
    #tower-panel h3 {
        display: none;
    }
    
    #tower-options {
        display: flex;
        gap: 10px;
    }
    
    .tower-option {
        padding: 8px;
    }
    
    #tower-info {
        display: none;
    }
    
    #game-footer {
        padding: 8px 10px;
        gap: 10px;
    }
    
    #start-wave-btn {
        font-size: 10px;
        padding: 10px 15px;
    }
    
    .speed-btn {
        font-size: 8px;
        padding: 6px 10px;
    }
    
    #pause-btn {
        font-size: 8px;
        padding: 8px 10px;
    }
}

/* Footer credit */
#game-footer::after {
    content: 'Inspired by the 1863 DeRussy Defense Plan • Made with 🍓 at berrry.app';
    display: block;
    width: 100%;
    text-align: center;
    font-size: 9px;
    color: #666;
    margin-top: 5px;
}

@media (max-width: 600px) {
    #game-footer::after {
        font-size: 7px;
    }
}