/* PixelFlow Lemmings - Retro C64 Style CSS */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #1E40A0 0%, #4169E1 100%);
    color: #FFFFFF;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Header */
.header {
    background: #000000;
    border-bottom: 4px solid #4169E1;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.title {
    font-size: 18px;
    color: #00FFFF;
    text-shadow: 2px 2px 0px #000000, -1px -1px 0px #004444;
    letter-spacing: 2px;
}

.game-info {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 10px;
    color: #FFD700;
}

.level-display, .objective, .time-remaining {
    background: #333333;
    border: 2px solid #555555;
    padding: 4px 8px;
    border-radius: 4px;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Buttons */
.btn {
    background: linear-gradient(180deg, #4169E1 0%, #1E40A0 100%);
    border: 2px solid #6495ED;
    border-radius: 4px;
    color: #FFFFFF;
    padding: 6px 12px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    box-shadow: 
        2px 2px 0px #000080,
        inset 1px 1px 0px rgba(255, 255, 255, 0.3);
}

.btn:hover {
    background: linear-gradient(180deg, #6495ED 0%, #4169E1 100%);
    transform: translateY(-1px);
    box-shadow: 
        3px 3px 0px #000080,
        inset 1px 1px 0px rgba(255, 255, 255, 0.5);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 
        1px 1px 0px #000080,
        inset 1px 1px 0px rgba(0, 0, 0, 0.3);
}

.btn.active {
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    color: #000000;
    border-color: #FFFF00;
    box-shadow: 
        2px 2px 0px #CC8800,
        inset 1px 1px 0px rgba(255, 255, 255, 0.5);
}

.btn.nuke {
    background: linear-gradient(180deg, #FF4500 0%, #DC143C 100%);
    border-color: #FF6347;
    animation: pulse-nuke 2s infinite;
}

@keyframes pulse-nuke {
    0%, 100% { 
        box-shadow: 2px 2px 0px #8B0000, inset 1px 1px 0px rgba(255, 255, 255, 0.3);
    }
    50% { 
        box-shadow: 2px 2px 0px #8B0000, inset 1px 1px 0px rgba(255, 255, 255, 0.3), 0 0 20px #FF0000;
    }
}

/* Main Container */
.main-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    align-items: center;
    justify-content: center;
}

.canvas-area {
    position: relative;
    margin: 20px;
    border: 4px solid #FFFFFF;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(65, 105, 225, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    background: #000000;
}

#canvas {
    display: block;
    background: #1E40A0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border-radius: 4px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #333333;
    border: 2px solid #555555;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00FF00 0%, #32CD32 100%);
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Skill Toolbar */
.skill-toolbar {
    background: #000000;
    border: 4px solid #4169E1;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin: 0 20px;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 2px 0px rgba(255, 255, 255, 0.1);
}

.skill-section {
    display: flex;
    gap: 12px;
    padding: 0 12px;
    border-right: 2px solid #555555;
}

.skill-section:last-child {
    border-right: none;
}

.skill-btn {
    position: relative;
    background: linear-gradient(180deg, #333333 0%, #111111 100%);
    border: 2px solid #555555;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 50px;
    box-shadow: 
        2px 2px 0px #000000,
        inset 1px 1px 0px rgba(255, 255, 255, 0.1);
}

.skill-btn:hover {
    background: linear-gradient(180deg, #555555 0%, #333333 100%);
    border-color: #777777;
    transform: translateY(-1px);
    box-shadow: 
        3px 3px 0px #000000,
        inset 1px 1px 0px rgba(255, 255, 255, 0.2);
}

.skill-btn.selected {
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    border-color: #FFFF00;
    box-shadow: 
        2px 2px 0px #CC8800,
        inset 1px 1px 0px rgba(255, 255, 255, 0.3),
        0 0 15px #FFD700;
}

/* Pixel Art Skill Icons */
.skill-icon {
    width: 32px;
    height: 32px;
    background-size: 32px 32px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.climber-icon {
    background: conic-gradient(from 0deg, #8B4513 0%, #A0522D 25%, #8B4513 50%, #654321 75%);
    position: relative;
}

.climber-icon::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #654321;
    top: 8px;
    left: 8px;
    border-radius: 2px;
}

.climber-icon::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 12px;
    background: #8B4513;
    top: 20px;
    left: 12px;
    border-radius: 1px;
}

.floater-icon {
    background: radial-gradient(circle, #87CEEB 30%, #4169E1 80%);
    position: relative;
}

.floater-icon::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 3px;
    background: #000;
    top: 15px;
    left: 6px;
}

.floater-icon::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #87CEEB;
    top: 2px;
    left: 8px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.bomber-icon {
    background: linear-gradient(45deg, #FF4500 0%, #DC143C 50%, #8B0000 100%);
    position: relative;
}

.bomber-icon::before {
    content: '💣';
    position: absolute;
    font-size: 20px;
    top: 6px;
    left: 6px;
    filter: hue-rotate(20deg);
}

.blocker-icon {
    background: linear-gradient(180deg, #FF0000 0%, #DC143C 50%, #8B0000 100%);
    position: relative;
    border-radius: 4px;
}

.blocker-icon::before {
    content: 'STOP';
    position: absolute;
    font-size: 6px;
    color: white;
    font-weight: bold;
    top: 12px;
    left: 4px;
    font-family: 'Press Start 2P', monospace;
}

.builder-icon {
    background: linear-gradient(135deg, #DEB887 0%, #8B7355 50%, #654321 100%);
    position: relative;
}

.builder-icon::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 4px;
    background: #8B4513;
    top: 14px;
    left: 6px;
}

.builder-icon::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 16px;
    background: #654321;
    top: 8px;
    left: 18px;
}

.basher-icon {
    background: linear-gradient(45deg, #C0C0C0 0%, #808080 50%, #555555 100%);
    position: relative;
}

.basher-icon::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 6px;
    background: #654321;
    top: 13px;
    left: 4px;
    border-radius: 1px;
}

.basher-icon::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #C0C0C0;
    top: 10px;
    left: 20px;
    border-radius: 1px;
}

.miner-icon {
    background: linear-gradient(-45deg, #C0C0C0 0%, #808080 50%, #555555 100%);
    position: relative;
}

.miner-icon::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 20px;
    background: #654321;
    top: 6px;
    left: 13px;
    border-radius: 1px;
    transform: rotate(45deg);
}

.miner-icon::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #C0C0C0;
    top: 4px;
    left: 8px;
    border-radius: 1px;
    transform: rotate(45deg);
}

.digger-icon {
    background: linear-gradient(180deg, #DEB887 0%, #CD853F 50%, #8B7355 100%);
    position: relative;
}

.digger-icon::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 20px;
    background: #654321;
    top: 6px;
    left: 14px;
    border-radius: 1px;
}

.digger-icon::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 8px;
    background: #8B7355;
    top: 18px;
    left: 10px;
    border-radius: 2px;
}

.skill-count {
    background: #000000;
    color: #00FFFF;
    border: 1px solid #004444;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 8px;
    min-width: 20px;
    text-align: center;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Spawn Controls */
.spawn-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: linear-gradient(180deg, #333333 0%, #111111 100%);
    border: 2px solid #555555;
    border-radius: 6px;
    box-shadow: 
        2px 2px 0px #000000,
        inset 1px 1px 0px rgba(255, 255, 255, 0.1);
}

.spawn-btn {
    background: linear-gradient(180deg, #4169E1 0%, #1E40A0 100%);
    border: 2px solid #6495ED;
    border-radius: 4px;
    color: #FFFFFF;
    width: 24px;
    height: 24px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}

.spawn-btn:hover {
    background: linear-gradient(180deg, #6495ED 0%, #4169E1 100%);
    transform: scale(1.1);
}

.spawn-btn:active {
    transform: scale(0.95);
}

#spawnRate {
    color: #FFD700;
    font-size: 10px;
    min-width: 24px;
    text-align: center;
    background: #000000;
    padding: 4px;
    border: 1px solid #333333;
    border-radius: 3px;
}

/* CRT Effects */
@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.98; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px
        );
    pointer-events: none;
    z-index: 1000;
    animation: flicker 0.15s infinite linear;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 8px;
    }
    
    .title {
        font-size: 14px;
    }
    
    .game-info, .controls {
        gap: 8px;
        font-size: 8px;
    }
    
    .btn {
        padding: 4px 8px;
        font-size: 6px;
    }
    
    .skill-toolbar {
        flex-wrap: wrap;
        margin: 10px;
        padding: 8px;
    }
    
    .skill-btn {
        min-width: 40px;
        padding: 4px;
    }
    
    .skill-icon {
        width: 24px;
        height: 24px;
    }
    
    #canvas {
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 300px);
    }
}

/* Special Effects */
.explosion-flash {
    animation: explosion-flash 0.1s;
}

@keyframes explosion-flash {
    0% { filter: brightness(1); }
    50% { filter: brightness(2) saturate(2); }
    100% { filter: brightness(1); }
}

/* Scrollbar Styling for Retro Look */
::-webkit-scrollbar {
    width: 12px;
    background: #111111;
}

::-webkit-scrollbar-track {
    background: #333333;
    border: 1px solid #555555;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4169E1 0%, #1E40A0 100%);
    border: 1px solid #6495ED;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6495ED 0%, #4169E1 100%);
}

/* Loading States */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Pixel Perfect Grid Overlay (for development) */
.pixel-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}