.gate {
    position: absolute;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
    min-width: 80px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: move;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
    touch-action: none;
}

.gate:hover {
    border-color: var(--high);
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-1px);
}

.gate.selected {
    border-color: var(--high);
    border-width: 3px;
    box-shadow: 0 4px 16px rgba(48, 130, 184, 0.4);
}

@media (max-width: 768px) {
    .gate {
        min-width: 70px;
        min-height: 55px;
        padding: 10px;
    }
}

.gate.pop-animation {
    animation: pop 0.3s ease;
}

@keyframes pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.gate-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 6px;
}

.gate-svg {
    width: 50px;
    height: 50px;
}

@media (max-width: 768px) {
    .gate-label {
        font-size: 10px;
    }
    
    .gate-svg {
        width: 40px;
        height: 40px;
    }
}

.gate-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--low);
    text-shadow: 0 0 10px currentColor;
}

.gate-value.high {
    color: var(--high);
}

.pin {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--border);
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: crosshair;
    transition: all 0.2s ease;
    z-index: 10;
    touch-action: none;
}

.pin:hover {
    background: var(--high);
    border-color: var(--high);
    box-shadow: 0 0 8px var(--high);
    transform: scale(1.3);
}

@media (max-width: 768px) {
    .pin {
        width: 14px;
        height: 14px;
        border-width: 3px;
    }
    
    .pin.input-pin {
        left: -8px;
    }
    
    .pin.output-pin {
        right: -8px;
    }
}

.pin.input-pin {
    left: -6px;
}

.pin.output-pin {
    right: -6px;
}

.pin.active {
    background: var(--high);
    border-color: var(--high);
    box-shadow: 0 0 8px var(--high);
}

.gate.INPUT .gate-body,
.gate.OUTPUT .gate-body {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gate.INPUT {
    cursor: pointer;
    min-width: 70px;
    min-height: 70px;
}

.gate.INPUT:hover {
    transform: scale(1.03);
    border-color: var(--high);
}

.gate.INPUT .gate-value {
    font-size: 28px;
}

.gate.OUTPUT .gate-value {
    font-size: 36px;
}

.add-input-btn,
.remove-input-btn {
    position: absolute;
    bottom: 5px;
    width: 20px;
    height: 20px;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 3px;
    color: var(--accent);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 20;
}

.add-input-btn {
    right: 5px;
}

.remove-input-btn {
    right: 28px;
}

.add-input-btn:hover,
.remove-input-btn:hover {
    background: var(--accent);
    color: var(--bg);
    box-shadow: 0 0 8px var(--accent);
    transform: scale(1.1);
}

.add-input-btn:active,
.remove-input-btn:active {
    transform: scale(0.95);
}
