:root {
    --primary-color: #4dfaff;
    --secondary-color: #bc13fe;
    --scan-color: #00ff41;
    --lock-color: #ffcc00;
    --bg-color: #050508;
}

body {
    margin: 0; padding: 0; height: 100vh; width: 100vw;
    height: 100svh;
    min-height: 100svh;
    background-color: var(--bg-color);
    font-family: 'Consolas', monospace;
    color: var(--primary-color);
    overflow: hidden;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    background-image: radial-gradient(circle at center, #111 0%, #000 100%);
}

/* --- Boot Screen --- */
#boot-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    padding: 40px;
    box-sizing: border-box;
    overflow: hidden;
}

#boot-left {
    flex: 0 0 35%; display: flex; flex-direction: column; justify-content: flex-end;
    padding-right: 30px; border-right: 1px solid rgba(77, 250, 255, 0.2);
    position: relative; z-index: 10;
}

#boot-right {
    flex: 1; position: relative; overflow: hidden; display: flex;
    justify-content: center; align-items: center;
    mask-image: radial-gradient(circle at center, black 50%, transparent 100%);
    -webkit-mask-image: radial-gradient(circle at center, black 50%, transparent 100%);
}

canvas#hiveCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.boot-log-line {
    font-size: 0.9rem; color: var(--primary-color); margin-bottom: 5px; opacity: 0;
    animation: type-in 0.1s forwards; text-shadow: 0 0 3px var(--primary-color); white-space: nowrap;
    font-family: 'Consolas', monospace;
}

.boot-success { color: var(--scan-color); }
.boot-warning { color: var(--lock-color); }
.boot-highlight { color: var(--secondary-color); font-weight: bold; font-size: 1.1rem; }
.boot-motto { color: #fff; font-size: 1.4rem; font-weight: bold; margin: 15px 0; text-shadow: 0 0 15px #fff; border-left: 5px solid var(--secondary-color); padding-left: 15px; background: linear-gradient(to right, rgba(188, 19, 254, 0.2), transparent); }
.boot-motto-sub { color: #ccc; font-size: 1.1rem; margin-left: 20px; margin-bottom: 4px; text-shadow: 0 0 5px #fff; }

@keyframes type-in { to { opacity: 1; } }

.system-off { animation: power-down 0.8s forwards; pointer-events: none; }
@keyframes power-down {
    0% { opacity: 1; filter: brightness(1); }
    40% { opacity: 1; filter: brightness(5); transform: scaleX(1.1); }
    100% { opacity: 0; transform: scaleY(0); }
}

/* --- 3D Core Reactor --- */
.reactor-container {
    position: relative;
    width: 200px; height: 200px;
    perspective: 1000px;
    margin-bottom: 60px;
}

.cube {
    width: 100%; height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    animation: rotate 20s infinite linear;
}

.face {
    position: absolute;
    width: 200px; height: 200px;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 15px rgba(77, 250, 255, 0.2);
    background: rgba(77, 250, 255, 0.05);
    display: flex; justify-content: center; align-items: center;
    font-size: 4rem; opacity: 0.8;
}

/* Cube Faces */
.front  { transform: rotateY(0deg) translateZ(100px); }
.back   { transform: rotateY(180deg) translateZ(100px); }
.right  { transform: rotateY(90deg) translateZ(100px); }
.left   { transform: rotateY(-90deg) translateZ(100px); }
.top    { transform: rotateX(90deg) translateZ(100px); }
.bottom { transform: rotateX(-90deg) translateZ(100px); }

/* Inner Core */
.inner-core {
    position: absolute; top: 50px; left: 50px;
    width: 100px; height: 100px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 50px var(--primary-color);
    transform-style: preserve-3d;
    animation: pulse 2s infinite ease-in-out;
    opacity: 0.8;
}

@keyframes rotate {
    from { transform: rotateX(0deg) rotateY(0deg); }
    to { transform: rotateX(360deg) rotateY(360deg); }
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.9; box-shadow: 0 0 80px var(--primary-color); }
    100% { transform: scale(0.8); opacity: 0.5; }
}

/* --- Text Block --- */
.hero-text {
    text-align: center;
    z-index: 10;
}

.main-title {
    font-size: 2.5rem; letter-spacing: 10px;
    text-shadow: 0 0 20px var(--primary-color);
    margin-bottom: 20px;
}

.sub-text {
    font-size: 1rem; color: #888;
    min-height: 1.2em;
}

.cursor {
    display: inline-block; width: 10px; height: 1.2em;
    background: var(--primary-color);
    vertical-align: bottom;
    animation: blink 1s infinite;
}

/* --- Background Grid (Replaced by Canvas) --- */
#neural-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at center, #111 0%, #000 100%);
}

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

/* === Mobile Boot Layout === */
@media (max-width: 768px) {
    #boot-screen {
        flex-direction: column;
        padding: 20px;
    }

    #boot-left {
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 1px solid rgba(77, 250, 255, 0.2);
        padding-right: 0;
        padding-bottom: 20px;
        margin-bottom: 20px;
    }

    #boot-right {
        flex: 1;
        min-height: 200px;
    }

    .boot-log-line {
        font-size: 0.7rem;
    }

    .boot-motto {
        font-size: 1rem;
        padding-left: 10px;
        border-left: 3px solid var(--secondary-color);
    }

    .boot-motto-sub {
        font-size: 0.85rem;
        margin-left: 15px;
    }
}

@media (max-width: 480px) {
    .boot-log-line {
        font-size: 0.65rem;
    }

    .boot-motto {
        font-size: 0.9rem;
    }
}

/* --- Neural Dialogue Interface --- */
.ndi-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(380px, 92vw);
    background: rgba(5, 5, 8, 0.9);
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 18px rgba(77, 250, 255, 0.35), inset 0 0 12px rgba(77, 250, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--primary-color);
    font-family: 'Consolas', monospace;
    z-index: 9500;
    clip-path: polygon(
        18px 0, calc(100% - 18px) 0, 100% 18px,
        100% calc(100% - 18px), calc(100% - 18px) 100%,
        18px 100%, 0 calc(100% - 18px), 0 18px
    );
}

.ndi-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid rgba(77, 250, 255, 0.35);
    box-shadow: 0 0 12px rgba(77, 250, 255, 0.4);
    pointer-events: none;
    clip-path: inherit;
}

.ndi-panel.closed {
    display: none;
}

.ndi-panel.expanded {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(620px, 90vw);
    z-index: 9800;
}

.ndi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(90deg, rgba(77, 250, 255, 0.12), rgba(77, 250, 255, 0.02));
    border-bottom: 1px solid rgba(77, 250, 255, 0.2);
    letter-spacing: 1px;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.ndi-signal {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #bafcff;
}

.ndi-signal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4dfaff;
    box-shadow: 0 0 8px #4dfaff;
    animation: ndi-pulse 1.5s infinite ease-in-out;
}

.ndi-controls {
    display: flex;
    gap: 6px;
}

.ndi-btn {
    width: 22px;
    height: 18px;
    border: 1px solid rgba(77, 250, 255, 0.4);
    background: rgba(0, 0, 0, 0.4);
    color: var(--primary-color);
    font-family: 'Consolas', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ndi-btn:hover {
    background: rgba(77, 250, 255, 0.15);
    box-shadow: 0 0 10px rgba(77, 250, 255, 0.4);
}

.ndi-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px 14px 14px;
}

.ndi-panel.minimized .ndi-body {
    display: none;
}

.ndi-panel.expanded .ndi-messages {
    max-height: 360px;
    font-size: 0.9rem;
}

.ndi-messages {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.ndi-messages::-webkit-scrollbar {
    width: 4px;
}

.ndi-messages::-webkit-scrollbar-thumb {
    background: rgba(77, 250, 255, 0.4);
}

.ndi-message {
    line-height: 1.4;
    text-shadow: 0 0 6px rgba(77, 250, 255, 0.2);
}

.ndi-message.user {
    align-self: flex-end;
    color: #e8feff;
    text-align: right;
}

.ndi-message.system {
    align-self: flex-start;
    color: #9cf6ff;
}

.ndi-message.system.decoding {
    animation: ndi-flicker 0.12s infinite;
}

.ndi-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(77, 250, 255, 0.15);
    padding-top: 8px;
}

.ndi-input {
    flex: 1;
    min-height: 22px;
    outline: none;
    color: #e8feff;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.ndi-input:empty::before {
    content: attr(data-placeholder);
    color: rgba(156, 246, 255, 0.35);
}

.ndi-input-cursor {
    width: 8px;
    height: 1.1em;
    background: var(--primary-color);
    box-shadow: 0 0 8px rgba(77, 250, 255, 0.8);
    animation: blink 1s infinite;
}

@keyframes ndi-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes ndi-flicker {
    0% { text-shadow: 0 0 6px rgba(77, 250, 255, 0.2); }
    50% { text-shadow: 0 0 10px rgba(77, 250, 255, 0.9); }
    100% { text-shadow: 0 0 4px rgba(77, 250, 255, 0.3); }
}

@media (max-width: 600px) {
    .ndi-panel {
        right: 12px;
        bottom: 12px;
        width: min(340px, 94vw);
    }

    .ndi-messages {
        max-height: 180px;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 70px;
        box-sizing: border-box;
    }

    .reactor-container {
        transform: scale(0.7);
        margin-bottom: 30px;
    }

    .hero-text {
        padding: 0 16px;
    }

    .main-title {
        font-size: 1.6rem;
        letter-spacing: 6px;
    }

    .sub-text {
        font-size: 0.85rem;
    }

    .ndi-panel {
        left: 10px;
        right: 10px;
        width: auto;
    }

    .ndi-panel.expanded {
        width: min(520px, 94vw);
    }
}

@media (max-width: 480px) {
    .reactor-container {
        transform: scale(0.6);
        margin-bottom: 20px;
    }

    .main-title {
        font-size: 1.3rem;
        letter-spacing: 4px;
    }

    .sub-text {
        font-size: 0.8rem;
    }

    .ndi-header {
        font-size: 0.6rem;
    }

    .ndi-btn {
        width: 20px;
        height: 16px;
    }
}
