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

html {
    overflow-x: hidden;
}

body {
    background: #0a0e1a;
    color: #f0f0f0;
    font-family: 'Press Start 2P', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    line-height: 2.2;
    overflow-x: hidden;
    /* 8px grid */
    background-image:
        repeating-linear-gradient(to right, rgba(100, 200, 255, 0.06) 0px, rgba(100, 200, 255, 0.06) 1px, transparent 1px, transparent 8px),
        repeating-linear-gradient(to bottom, rgba(100, 200, 255, 0.06) 0px, rgba(100, 200, 255, 0.06) 1px, transparent 1px, transparent 8px);
    background-size: 8px 8px;
}

/* Scanlines */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 3px
    );
}

/* Bubble layer */
.bubble-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.pixel-bubble {
    position: absolute;
    border-radius: 0;
    animation: bubbleRise 3s linear forwards;
}

.pixel-bubble.true-bubble {
    background: #40ff80;
}

.pixel-bubble.false-bubble {
    background: #ff4040;
    animation-name: bubbleFall;
}

@keyframes bubbleRise {
    0% { opacity: 0.8; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-200px); }
}

@keyframes bubbleFall {
    0% { opacity: 0.6; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(200px); }
}

/* System load indicator */
.system-load {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

.load-label {
    color: #80b0c0;
}

.load-percent {
    color: #ff8040;
    min-width: 40px;
}

.load-bar {
    width: 120px;
    height: 8px;
    border: 1px solid #40ff80;
    display: flex;
}

.load-fill {
    height: 100%;
    width: 0%;
    background: #40ff80;
    transition: width 0.5s steps(15);
}

/* BIOS Screen */
.bios-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px;
    position: relative;
    z-index: 5;
}

.bios-text {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    color: #40ff80;
    white-space: pre-wrap;
    max-width: 600px;
}

.bios-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: #40ff80;
    animation: cursorBlink 0.5s step-end infinite;
    margin-top: 8px;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Module Rows */
.module-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 40px;
    min-height: 80vh;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: center;
    position: relative;
    z-index: 5;
}

/* Module */
.module {
    width: 320px;
    border: 2px solid #40ff80;
    background: rgba(100, 200, 255, 0.04);
    opacity: 0;
    transition: opacity 0.4s steps(8);
}

.module.booted {
    opacity: 1;
}

.module-wide {
    width: 680px;
}

.module-table {
    border-color: #40e0ff;
}

.module-syllogism {
    border-color: #ff40c0;
}

.module-paradox {
    border-color: #ffe040;
}

/* Module header */
.module-header {
    height: 32px;
    background: rgba(100, 255, 180, 0.1);
    padding: 0 16px;
    display: flex;
    align-items: center;
    font-family: 'Silkscreen', sans-serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: #40ff80;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(100, 255, 180, 0.2);
}

.header-cyan {
    background: rgba(64, 224, 255, 0.1);
    color: #40e0ff;
    border-bottom-color: rgba(64, 224, 255, 0.2);
}

.header-magenta {
    background: rgba(255, 64, 192, 0.1);
    color: #ff40c0;
    border-bottom-color: rgba(255, 64, 192, 0.2);
}

.header-yellow {
    background: rgba(255, 224, 64, 0.1);
    color: #ffe040;
    border-bottom-color: rgba(255, 224, 64, 0.2);
}

/* Module content */
.module-content {
    padding: 16px;
}

/* Gate icon */
.gate-icon {
    margin-bottom: 12px;
}

.pixel-icon {
    filter: drop-shadow(0 0 8px rgba(64, 255, 128, 0.3));
}

/* Gate formula */
.gate-formula {
    font-family: 'VT323', monospace;
    font-size: 1rem;
    color: #40ff80;
    margin-top: 12px;
    padding: 8px;
    border: 1px solid rgba(64, 255, 128, 0.2);
    text-align: center;
}

.formula-yellow {
    color: #ffe040;
    border-color: rgba(255, 224, 64, 0.2);
}

/* Module desc */
.module-desc {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.65rem, 0.8vw, 0.75rem);
    color: #80b0c0;
    line-height: 2;
}

/* Truth values */
.val-true {
    color: #40ff80;
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

.val-false {
    color: rgba(255, 64, 64, 0.6);
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

.val-glitch {
    color: #ffe040;
    animation: glitch 0.3s steps(2) infinite;
}

@keyframes glitch {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Truth table */
.truth-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

.truth-table th {
    color: #40e0ff;
    border-bottom: 2px solid #40e0ff;
    padding: 4px 8px;
    text-align: center;
}

.truth-table td {
    padding: 4px 8px;
    text-align: center;
}

.truth-table tbody tr:nth-child(odd) {
    background: rgba(64, 224, 255, 0.02);
}

.truth-table tbody tr:nth-child(even) {
    background: rgba(64, 224, 255, 0.05);
}

/* Syllogism */
.syllogism-chain {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.syl-box {
    border: 2px solid #ff40c0;
    padding: 12px;
    text-align: center;
    min-width: 160px;
}

.syl-conclusion {
    border-width: 3px;
    box-shadow: 0 0 12px rgba(255, 64, 192, 0.2);
}

.syl-label {
    display: block;
    font-family: 'VT323', monospace;
    font-size: 0.85rem;
    color: #ff40c0;
    margin-bottom: 4px;
}

.syl-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: #f0f0f0;
    line-height: 1.8;
}

.syl-arrow {
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    color: #ff40c0;
}

/* Paradox */
.paradox-statement {
    font-family: 'Silkscreen', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: #ffe040;
    text-align: center;
    margin-bottom: 12px;
    text-transform: uppercase;
}

/* Final message */
.final-row {
    justify-content: center;
    align-items: center;
    min-height: 40vh;
}

.final-message {
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s steps(8);
}

.final-message.visible {
    opacity: 1;
}

.final-line {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    color: #40ff80;
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .module {
        width: 100%;
    }

    .module-wide {
        width: 100%;
    }

    .module-row {
        padding: 20px;
    }

    .syllogism-chain {
        flex-direction: column;
    }

    .system-load {
        font-size: 0.8rem;
    }

    .load-bar {
        width: 60px;
    }
}
