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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    width: 100%;
    max-width: 1200px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.game-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-header h1 {
    font-size: 1.8rem;
}

.back-btn {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border: 2px solid white;
    border-radius: 8px;
    transition: all 0.3s;
}

.back-btn:hover {
    background: white;
    color: #667eea;
}

.game-wrapper {
    padding: 20px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f7fafc;
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat .label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 600;
}

.stat .value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2d3748;
}

.stat .value.health {
    color: #48bb78;
}

.game-area {
    background: #2d3748;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 20px;
    position: relative;
}

#gameCanvas {
    width: 100%;
    height: 500px;
    display: block;
    background: #1a202c;
    border-radius: 8px;
}

.defense-shop {
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
}

.defense-shop h3 {
    margin-bottom: 15px;
    color: #2d3748;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.shop-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.shop-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.shop-item.selected {
    border-color: #48bb78;
    background: #f0fff4;
}

.shop-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.defense-name {
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 5px;
}

.defense-cost {
    color: #667eea;
    font-weight: bold;
    margin-bottom: 5px;
}

.defense-desc {
    font-size: 0.85rem;
    color: #718096;
}

/* Overlays */
.game-overlay {
    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;
}

.game-overlay.hidden {
    display: none;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
}

.overlay-content h2 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 2rem;
}

.overlay-content p {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.instructions {
    text-align: left;
    margin: 20px 0;
}

.instructions h3,
.instructions h4 {
    color: #2d3748;
    margin: 15px 0 10px;
}

.instructions ul {
    margin-left: 20px;
    color: #4a5568;
}

.instructions li {
    margin: 8px 0;
    line-height: 1.6;
}

.game-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    font-weight: 600;
    margin: 10px;
    pointer-events: auto;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.final-stats {
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
}

.final-stats p {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1rem;
}

.final-stats span {
    font-weight: bold;
    color: #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    .game-header h1 {
        font-size: 1.3rem;
    }

    #gameCanvas {
        height: 350px;
    }

    .stats-bar {
        gap: 10px;
    }

    .stat .value {
        font-size: 1.1rem;
    }

    .shop-items {
        grid-template-columns: 1fr 1fr;
    }

    .overlay-content {
        padding: 25px;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    #gameCanvas {
        height: 300px;
    }

    .shop-items {
        grid-template-columns: 1fr;
    }
}
