:root {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d2d;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #2dd4bf; 
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 1200px;
    height: 800px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(45, 212, 191, 0.1);
    overflow: hidden;
    background-color: #000; /* For FOW base */
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass to canvas */
}

#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(15, 17, 26, 0.9), transparent);
    z-index: 10;
}

.stat {
    font-size: 1.1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat span {
    color: var(--border);
    font-weight: 800;
    font-size: 1.3rem;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s;
    pointer-events: auto; /* Catch clicks */
    z-index: 20;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active .overlay-content {
    transform: translateY(0);
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--border), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.intro-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 30px;
    text-align: left;
}

.controls {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.control-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.control-item:last-child {
    margin-bottom: 0;
}

.key {
    background: var(--bg-dark);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.9rem;
    margin-right: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 0 rgba(0,0,0,0.5);
    min-width: 80px;
    text-align: center;
}

button {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

.final-stats {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.highlight {
    color: var(--warning);
    font-size: 2rem;
    display: block;
    margin-top: 10px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

input[type="text"] {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-family: inherit;
    font-size: 1.1rem;
    padding: 12px 16px;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

#leaderboard {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 20px;
    text-align: left;
}

#leaderboard h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

#leaderboard-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.95rem;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

.lb-name {
    font-weight: 500;
}

.lb-score {
    color: var(--border);
    font-weight: 800;
}

/* Custom scrollbar for leaderboard */
#leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
#leaderboard-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
#leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

/* Upgrade Panel */
#upgrade-panel {
    position: absolute;
    top: 60px;
    right: 15px;
    background: rgba(15, 17, 26, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(45, 212, 191, 0.25);
    border-radius: 14px;
    padding: 14px;
    pointer-events: auto;
    z-index: 15;
    display: none;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.25s ease;
}

#upgrade-panel.visible {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.upgrade-title {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--border);
    margin-bottom: 10px;
    text-align: center;
}

.upgrade-hint {
    font-size: 0.7rem;
    opacity: 0.5;
    font-weight: 300;
}

.upgrade-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.upgrade-btn:last-child {
    margin-bottom: 0;
}

.upgrade-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

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

.upgrade-btn.maxed {
    opacity: 0.4;
    pointer-events: none;
}

.upgrade-cost {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    font-weight: 800;
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 6px;
}

.upgrade-cost::before {
    content: '⭐ ';
}
