:root {
    --background: #000000;
    --terminal: #0a0a0a;
    --green: #ffffff;
    --green-light: #f3f4f6;
    --green-dark: #4b5563;
    --cyan: #9ca3af;
    --yellow: #e5e7eb;
    --red: #ef4444;
    --text: #e5e7eb;
    --muted: #6b7280;
    --border: rgba(255, 255, 255, 0.15);
    --font: "Cascadia Code", "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.03), transparent 45%), var(--background);
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 0, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 4px);
    opacity: 0.2;
}

.terminal {
    position: absolute;
    width: min(1100px, calc(100vw - 40px));
    height: min(760px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.01), transparent 70%), var(--terminal);
    border: 1px solid rgba(0, 255, 200, 0.4);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 35px rgba(0, 255, 200, 0.15), inset 0 0 50px rgba(0, 0, 0, 0.9);
    animation: rgbGlow 10s linear infinite;
    transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
    touch-action: none;
}

.terminal.minimized {
    height: 42px !important;
    overflow: hidden;
}

.terminal.minimized .terminal-screen {
    display: none;
}

.terminal.maximized {
    width: 100vw !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    transform: none !important;
}

.terminal.closed {
    display: none !important;
}

.terminal-bar {
    height: 42px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.terminal-bar:active {
    cursor: grabbing;
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green-light);
    font-weight: 700;
    letter-spacing: 1px;
}

.terminal-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.terminal-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.terminal-version {
    color: var(--muted);
    font-size: 10px;
}

.terminal-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.3);
}

.close-btn:hover {
    background: var(--red);
    color: #ffffff;
    border-color: var(--red);
}

.terminal-screen {
    flex: 1;
    min-height: 0;
    padding: 25px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--green-dark) transparent;
}

.terminal-screen::-webkit-scrollbar { width: 6px; }
.terminal-screen::-webkit-scrollbar-track { background: transparent; }
.terminal-screen::-webkit-scrollbar-thumb { background: var(--green-dark); border-radius: 10px; }

.terminal-output {
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-line {
    min-height: 1.65em;
    margin: 0;
}

.output-command { color: var(--green-light); font-weight: 500; }
.output-normal { color: var(--text); }
.output-muted { color: var(--muted); }
.output-success { color: var(--green); }
.output-info { color: var(--cyan); }
.output-warning { color: var(--yellow); }
.output-error { color: var(--red); }

.ascii {
    margin: 0 0 22px 0;
    color: var(--green);
    font-family: var(--font);
    font-size: clamp(7px, 1.25vw, 14px);
    line-height: 1.1;
    white-space: pre;
    user-select: none;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.2);
}

.terminal-input-line {
    display: flex;
    align-items: center;
    position: relative;
    min-height: 25px;
    margin-top: 5px;
    font-size: 13px;
}

.prompt {
    flex-shrink: 0;
    margin-right: 8px;
    color: var(--green-light);
    font-weight: 600;
}

.input-container {
    display: inline-flex;
    align-items: center;
    position: relative;
    flex: 1;
}

#commandInput {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 2;
    cursor: text;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
}

.input-container::before {
    content: attr(data-value);
    color: var(--text);
    white-space: pre;
    visibility: visible;
}

.cursor {
    width: 8px;
    height: 16px;
    display: inline-block;
    background: var(--green);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
    animation: cursorBlink 1s steps(1) infinite;
    margin-left: 1px;
    vertical-align: middle;
}

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

@keyframes rgbGlow {
    0% {
        border-color: rgba(0, 255, 200, 0.45);
        box-shadow: 0 0 35px rgba(0, 255, 200, 0.2), inset 0 0 30px rgba(0, 255, 200, 0.03);
    }
    25% {
        border-color: rgba(0, 150, 255, 0.45);
        box-shadow: 0 0 35px rgba(0, 150, 255, 0.2), inset 0 0 30px rgba(0, 150, 255, 0.03);
    }
    50% {
        border-color: rgba(180, 0, 255, 0.45);
        box-shadow: 0 0 35px rgba(180, 0, 255, 0.2), inset 0 0 30px rgba(180, 0, 255, 0.03);
    }
    75% {
        border-color: rgba(255, 0, 120, 0.45);
        box-shadow: 0 0 35px rgba(255, 0, 120, 0.2), inset 0 0 30px rgba(255, 0, 120, 0.03);
    }
    100% {
        border-color: rgba(0, 255, 200, 0.45);
        box-shadow: 0 0 35px rgba(0, 255, 200, 0.2), inset 0 0 30px rgba(0, 255, 200, 0.03);
    }
}

@media (max-width: 700px) {
    body { padding: 10px; }
    .terminal { width: calc(100vw - 20px); height: calc(100vh - 20px); }
    .terminal-screen { padding: 18px 14px; }
    .terminal-output, .terminal-input-line { font-size: 12px; }
    .ascii { font-size: 6px; margin-bottom: 18px; }
    .terminal-bar { padding: 0 12px; }
}