.container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem;
    font-family: Arial, sans-serif;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.logic-gate {
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.label {
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
    order: -1;
}

.gate-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
}

.gate {
    width: 120px;
    height: 80px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 0 40px 40px 0;
    position: relative;
    margin: 0 auto;
}

.not-gate {
    width: 100px;
    height: 60px;
}

.not-output::after {
    content: '';
    position: absolute;
    right: 35px;
    top: 50%;
    width: 8px;
    height: 8px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    transform: translate(50%, -50%);
}

.input {
    position: absolute;
    left: -40px;
    width: 40px;
    height: 2px;
    background: #333;
}

.input-1 { top: 33%; }
.input-2 { top: 66%; }
.not-input { top: 50%; }

.output {
    position: absolute;
    right: -40px;
    top: 50%;
    width: 40px;
    height: 2px;
    background: #333;
    transform: translateY(-50%);
}

.nand-output::after {
    content: '';
    position: absolute;
    right: 35px;
    top: 50%;
    width: 8px;
    height: 8px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    transform: translate(50%, -50%);
}

.switch {
    position: absolute;
    width: 40px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
    left: -80px;
}

.switch-1 { top: calc(33% - 12px); }
.switch-2 { top: calc(66% - 12px); }
.not-switch { top: calc(50% - 12px); }

.switch.active {
    background: #4CAF50;
}

.result {
    position: absolute;
    right: -80px;
    top: calc(50% - 12px);
    width: 40px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    transition: background 0.3s;
}

.result.active {
    background: #4CAF50;
}

.gate-symbol {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 1.25rem;
}

.truth-table {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    border-collapse: collapse;
}

.truth-table th, 
.truth-table td {
    border: 1px solid #333;
    padding: 0.5rem;
    text-align: center;
}

.truth-table th {
    background-color: #eee;
}

.truth-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }

    .gate {
        width: 100px;
        height: 60px;
    }

    .not-gate {
        width: 80px;
        height: 50px;
    }

    .input, .output {
        width: 30px;
    }

    .input { left: -30px; }
    .output { right: -30px; }

    .switch, .result {
        width: 36px;
        height: 20px;
    }

    .switch { left: -75px; }
    .result { right: -75px; }

    .switch-1 { top: calc(33% - 10px); }
    .switch-2 { top: calc(66% - 10px); }
    .not-switch { top: calc(50% - 10px); }
    
    .result { top: calc(50% - 10px); }

    .label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    .nand-output::after {
        width: 6px;
        height: 6px;
        right: -3px;
    }

    .truth-table th, 
    .truth-table td {
        padding: 0.25rem;
        font-size: 0.875rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    .logic-gate {
        flex-direction: row;
        padding: 2rem;
        align-items: flex-start;
        justify-content: space-between;
    }

    .gate-container {
        width: 45%;
        margin: 0;
    }

    .label {
        margin-bottom: 1.5rem;
    }

    .truth-table {
        width: 45%;
        margin: 0;
    }

    /* .not-output::after,
    .nand-output::after {
        width: 6px;
        height: 6px;
        right: 25px;
    } */
}

@media (min-width: 1024px) {
    .gate {
        width: 140px;
        height: 90px;
    }

    .not-gate {
        width: 120px;
        height: 70px;
    }
}