:root {
    --background: #1a1a1a;
    --text: #ffb000;
    --prompt: #ffb000;
    --link: #00e5e5;
}

body,
html {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--background);
    color: var(--text);
    font-family: 'VT323', monospace;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    line-height: 1.4;
    overflow: hidden;
    /* Prevent body scroll */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Optimize touch scrolling */
    -webkit-overflow-scrolling: touch;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
    /* Optimize touch actions */
    touch-action: manipulation;
}

/* Let's make it look like a retro monitor */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    animation: flicker .5s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.27861;
    }

    5% {
        opacity: 0.34769;
    }

    10% {
        opacity: 0.54583;
    }

    15% {
        opacity: 0.96584;
    }

    20% {
        opacity: 0.18388;
    }

    25% {
        opacity: 0.83891;
    }

    30% {
        opacity: 0.65583;
    }

    35% {
        opacity: 0.67807;
    }

    40% {
        opacity: 0.26559;
    }

    45% {
        opacity: 0.84693;
    }

    50% {
        opacity: 0.96019;
    }

    55% {
        opacity: 0.08594;
    }

    60% {
        opacity: 0.20313;
    }

    65% {
        opacity: 0.71988;
    }

    70% {
        opacity: 0.53455;
    }

    75% {
        opacity: 0.37288;
    }

    80% {
        opacity: 0.71428;
    }

    85% {
        opacity: 0.70428;
    }

    90% {
        opacity: 0.7003;
    }

    95% {
        opacity: 0.36108;
    }

    100% {
        opacity: 0.24387;
    }
}

#terminal {
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    padding: clamp(8px, 2vw, 15px);
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#output {
    /* Output content flows naturally without taking all available space */
    flex-shrink: 0;
}

.output-line {
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.prompt-symbol {
    margin-right: clamp(4px, 1vw, 8px);
    color: var(--prompt);
    flex-shrink: 0;
}


@keyframes blinker {
    from,
    to {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

#command-input {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: inherit;
    outline: none;
    flex-grow: 1;
    caret-color: transparent;
}


.input-line {
    display: flex;
    align-items: center;
    position: relative;
    margin-top: 0;
    min-height: 44px; /* Minimum touch target size */
    padding: 4px 0;
}

/* Blinking cursor */
.cursor {
    color: var(--text);
    animation: blinker .5s step-end infinite;
    font-weight: normal;
}

/* Custom scrollbar for the terminal window */
#terminal::-webkit-scrollbar {
    width: 8px;
}

#terminal::-webkit-scrollbar-track {
    background: var(--background);
}

#terminal::-webkit-scrollbar-thumb {
    background: var(--prompt);
    border-radius: 4px;
}

#terminal::-webkit-scrollbar-thumb:hover {
    background: var(--text);
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    /* Reduce flicker effect intensity on mobile for better performance */
    body::before {
        animation-duration: 1s;
        opacity: 0.3;
    }

    /* Larger touch targets on mobile */
    .input-line {
        min-height: 48px;
        padding: 6px 0;
    }

    /* Optimize scrollbar for mobile */
    #terminal::-webkit-scrollbar {
        width: 4px;
    }

    /* Better text selection on mobile */
    .output-line {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
}

@media (max-width: 480px) {
    /* Very small screens */
    #terminal {
        padding: clamp(4px, 1.5vw, 8px);
    }

    .prompt-symbol {
        margin-right: 4px;
    }

    /* Disable flicker on very small screens for performance */
    body::before {
        display: none;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #terminal {
        padding: 8px;
    }

    .input-line {
        min-height: 40px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    body::before {
        background-size: 100% 1px, 2px 100%;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none;
    }

    .cursor {
        animation: none;
        opacity: 1;
    }
}
