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

body {
    overflow: hidden;
    background: #0a0e14;
    font-family: 'IBM Plex Sans', sans-serif;
    color: #c0c8d8;
    user-select: none;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

canvas {
    display: block;
}

/* HUD styles */
#hud-top-left {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#money-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: #39ff14;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.5), 0 0 40px rgba(57, 255, 20, 0.2);
    background: rgba(10, 14, 20, 0.85);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(57, 255, 20, 0.2);
    backdrop-filter: blur(10px);
}

#power-display, #temp-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #00f0ff;
    background: rgba(10, 14, 20, 0.85);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    backdrop-filter: blur(10px);
}

#hud-top-right {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

#throughput-display, #server-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #ffbf00;
    background: rgba(10, 14, 20, 0.85);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 191, 0, 0.15);
    backdrop-filter: blur(10px);
}

#hud-bottom {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

#toolbar {
    display: flex;
    gap: 8px;
    background: rgba(10, 14, 20, 0.9);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    backdrop-filter: blur(10px);
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(45, 45, 68, 0.6);
    border: 1px solid rgba(0, 240, 255, 0.1);
    color: #8899aa;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.4);
    color: #00f0ff;
    transform: translateY(-2px);
}

.toolbar-btn.active {
    background: rgba(0, 240, 255, 0.15);
    border-color: #00f0ff;
    color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.toolbar-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.rack-icon.basic { background: linear-gradient(135deg, #555, #333); border: 1px solid #666; }
.rack-icon.advanced { background: linear-gradient(135deg, #1a4a8a, #0a2a5a); border: 1px solid #2a6acc; }
.rack-icon.enterprise { background: linear-gradient(135deg, #8a6a1a, #5a4a0a); border: 1px solid #ccaa2a; }
.cooler-icon { background: linear-gradient(135deg, #1a5a5a, #0a3a3a); border: 1px solid #2acccc; border-radius: 50%; }
.pdu-icon { background: linear-gradient(135deg, #5a1a5a, #3a0a3a); border: 1px solid #cc2acc; }

#hud-bottom-right {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    gap: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #556677;
    background: rgba(10, 14, 20, 0.7);
    padding: 6px 12px;
    border-radius: 6px;
}

/* Terminal */
#terminal {
    position: fixed;
    top: 20px;
    right: 20px;
    bottom: 60px;
    width: 480px;
    max-width: calc(100vw - 40px);
    background: rgba(10, 14, 20, 0.95);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 12px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.1), inset 0 0 60px rgba(0, 0, 0, 0.3);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
    overflow: hidden;
}

#terminal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 240, 255, 0.01) 2px,
        rgba(0, 240, 255, 0.01) 4px
    );
    pointer-events: none;
    z-index: 1;
}

.terminal-hidden {
    transform: translateX(520px);
    opacity: 0;
    pointer-events: none !important;
}

#terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.1);
    position: relative;
    z-index: 2;
}

.terminal-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #00f0ff;
    animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
    50% { opacity: 0.7; }
}

#terminal-close {
    background: none;
    border: 1px solid rgba(255, 51, 51, 0.3);
    color: #ff3333;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#terminal-close:hover {
    background: rgba(255, 51, 51, 0.2);
    border-color: #ff3333;
}

#terminal-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 12px 0;
    border-bottom: 1px solid rgba(0, 240, 255, 0.08);
    position: relative;
    z-index: 2;
}

.tab-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #556677;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #8899aa;
}

.tab-btn.active {
    color: #00f0ff;
    border-bottom-color: #00f0ff;
}

#terminal-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    position: relative;
    z-index: 2;
}

.tab-panel {
    display: none;
    position: relative;
}

.tab-panel.active {
    display: block;
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, 0.05) 1px,
        rgba(0, 0, 0, 0.05) 2px
    );
    pointer-events: none;
    z-index: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
}

.stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #556677;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 700;
    color: #00f0ff;
}

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #667788;
}

.bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00f0ff, #39ff14);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.bar-fill.bar-cool {
    background: linear-gradient(90deg, #39ff14, #00f0ff);
}

/* Build tab */
.build-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.build-item {
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.build-item:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.3);
    transform: translateY(-1px);
}

.build-item-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #00f0ff;
    margin-bottom: 4px;
}

.build-item-cost {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #39ff14;
    margin-bottom: 6px;
}

.build-item-desc {
    font-size: 11px;
    color: #556677;
    line-height: 1.4;
}

#expand-btn-container {
    margin-top: 16px;
}

#expand-room-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 191, 0, 0.08);
    border: 1px solid rgba(255, 191, 0, 0.3);
    color: #ffbf00;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#expand-room-btn:hover {
    background: rgba(255, 191, 0, 0.15);
    border-color: #ffbf00;
}

/* Server list */
.server-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 240, 255, 0.02);
    border: 1px solid rgba(0, 240, 255, 0.06);
    border-radius: 6px;
    margin-bottom: 6px;
}

.server-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.server-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #aabbcc;
}

.server-stats {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #556677;
}

.server-toggle {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    background: transparent;
}

.server-toggle.online {
    color: #39ff14;
    border-color: rgba(57, 255, 20, 0.3);
}

.server-toggle.offline {
    color: #ff3333;
    border-color: rgba(255, 51, 51, 0.3);
}

/* Finance */
.finance-stats {
    margin-bottom: 16px;
}

.finance-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 240, 255, 0.05);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.profit-pos { color: #39ff14; }
.profit-neg { color: #ff3333; }

.finance-graph {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

#finance-canvas {
    width: 100%;
    height: 150px;
}

/* Alerts */
#alert-log {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.alert-entry {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 3px solid;
    background: rgba(0, 0, 0, 0.2);
}

.alert-entry.info { color: #00f0ff; border-color: #00f0ff; }
.alert-entry.warn { color: #ffbf00; border-color: #ffbf00; }
.alert-entry.error { color: #ff3333; border-color: #ff3333; }
.alert-entry.success { color: #39ff14; border-color: #39ff14; }

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 8px;
    background: rgba(10, 14, 20, 0.95);
    border: 1px solid rgba(57, 255, 20, 0.3);
    color: #39ff14;
    backdrop-filter: blur(10px);
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.15);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Placement info */
#placement-info {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    background: rgba(10, 14, 20, 0.9);
    border: 1px solid rgba(0, 240, 255, 0.3);
    padding: 12px 24px;
    border-radius: 8px;
    text-align: center;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

#placement-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #00f0ff;
    display: block;
    margin-bottom: 4px;
}

.placement-hint {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #556677;
}

.hidden {
    display: none !important;
}

/* Footer */
#footer-link {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

#footer-link a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(0, 240, 255, 0.3);
    text-decoration: none;
    transition: color 0.2s;
}

#footer-link a:hover {
    color: rgba(0, 240, 255, 0.6);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.3);
}

@media (max-width: 600px) {
    #terminal {
        width: calc(100vw - 16px);
        right: 8px;
        top: 8px;
        bottom: 50px;
    }

    #toolbar {
        gap: 4px;
        padding: 6px 10px;
    }

    .toolbar-btn {
        padding: 6px 8px;
        font-size: 9px;
    }

    .toolbar-icon {
        width: 22px;
        height: 22px;
    }

    #money-display {
        font-size: 20px;
        padding: 6px 10px;
    }
}