:root {
    --bg: #1f1f1f;
    --panel: #2d2d2d;
    --panel2: #3a3a3a;
    --border: #555;
    --text: #f2f2f2;
    --blue: #4d8df5;
    --green: #42b96f;
    --gold: #d9b44a;
    --red: #d85a5a;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#hud {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    z-index: 1000;
}

.stat-item {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 14px
}

.stat-label {
    font-size: 11px;
    color: #bbb
}

#money {
    color: var(--green);
    font-weight: bold
}

#data-count {
    color: var(--blue)
}

#main-container {
    display: flex;
    flex: 1;
    overflow: hidden
}

#shop {
    width: 250px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 15px;
    overflow: auto
}

#shop h2 {
    margin: 0 0 12px
}

#shop-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px
}

.filter-btn,
.shop-item,
.tool-item {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px;
    cursor: pointer;
    transition: .15s;
}

.filter-btn.active,
.shop-item.active,
.tool-item.active {
    border-color: var(--blue);
}

.filter-btn:hover,
.shop-item:hover,
.tool-item:hover {
    background: #444;
}

.shop-item {
    margin-bottom: 10px
}

.shop-item .name {
    display: block;
    font-weight: bold
}

.shop-item .price {
    color: var(--gold)
}

.shop-item .desc {
    font-size: 12px;
    color: #bbb
}

.shop-item.locked {
    opacity: .5;
    pointer-events: none
}

#workspace {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #202020;
    background-image:
        linear-gradient(#2f2f2f 1px, transparent 1px),
        linear-gradient(90deg, #2f2f2f 1px, transparent 1px);
    background-size: 52px 52px;
}

#viewport {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0
}

#grid {
    display: grid;
    grid-template-columns: repeat(100, 50px);
    grid-template-rows: repeat(100, 50px);
    gap: 2px;
    background: #333;
    border: 2px solid #444;
}

.cell {
    width: 50px;
    height: 50px;
    background: #262626
}

.cell.hover {
    background: #3b3b3b
}

#connections-layer {
    position: absolute;
    inset: 0;
    pointer-events: none
}

.connection-path {
    stroke-dasharray: 6;
    animation: flow 1s linear infinite
}

@keyframes flow {
    from {
        stroke-dashoffset: 12
    }

    to {
        stroke-dashoffset: 0
    }
}

.chip {
    position: absolute;
    width: 80px;
    min-height: 60px;
    background: #3b3b3b;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: .15s;
}

.chip:hover {
    border-color: var(--blue)
}

.chip.selected {
    outline: 2px solid var(--blue)
}

.port {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid #fff;
}

.port.in {
    top: -4px;
    left: 50%;
    transform: translateX(-50%)
}

.port.out {
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%)
}

.power {
    background: var(--blue)
}

.data {
    background: var(--green)
}

.speed {
    background: var(--gold)
}

.energy {
    background: var(--red)
}

.energy-bar-container {
    width: 80%;
    height: 5px;
    margin-top: 6px;
    background: #222;
    border: 1px solid #444;
}

.energy-bar-fill {
    height: 100%;
    width: 0;
    background: var(--red)
}

#utility-bar {
    position: fixed;
    right: 15px;
    bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-item {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.context-menu {
    position: fixed;
    display: none;
    background: var(--panel);
    border: 1px solid var(--border);
    min-width: 160px;
}

.context-menu-item {
    padding: 10px;
    cursor: pointer;
}

.context-menu-item:hover {
    background: #444
}

#custom-cursor {
    display: none
}

#version-display {
    position: fixed;
    right: 8px;
    top: 8px;
    color: #888;
    font-size: 10px;
    font-family: monospace;
}
