:root {
    --bg-color: #121212;
    --panel-bg: rgba(30, 30, 30, 0.9);
    --primary-color: #3a86ff;
    --secondary-color: #ff006e;
    --accent-color: #8338ec;
    --text-color: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#hud {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    pointer-events: auto;
}

.resource-display, .stats-display {
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

#money-display {
    color: #4cd137;
}

#controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.icon-btn {
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.icon-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

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

#build-menu {
    background: var(--panel-bg);
    backdrop-filter: blur(5px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    pointer-events: auto;
    overflow-x: auto;
    display: flex;
    gap: 15px;
    align-items: center;
}

.build-category h3 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: #aaa;
}

.build-items {
    display: flex;
    gap: 10px;
}

.build-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 60px;
    transition: background 0.2s;
}

.build-item.active {
    background: rgba(58, 134, 255, 0.3);
    border-color: var(--primary-color);
}

.build-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.build-item img, .build-item .icon {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
}

.build-item .cost {
    font-size: 0.8rem;
    color: #4cd137;
}

.hidden {
    display: none !important;
}

#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #444;
    padding: 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 100;
    font-size: 0.9rem;
    max-width: 200px;
}

#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 1000;
}

#modal-content {
    background: #1e1e1e;
    padding: 20px;
    border-radius: var(--border-radius);
    min-width: 300px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid #333;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

#leaderboard-list li {
    padding: 8px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
}

#close-modal {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}
