pre {
    margin: auto;
    margin-top: 0;
    margin-bottom: 0;
    display: table;
    width: 100%;
    max-width: 100vw;
    color: hsl(154 84% 70%);
    text-shadow: 0 0 4px hsl(154 84% 70%);
    box-sizing: border-box;
}

pre#asciiText {
    margin-top: 0;
    padding-top: 0;
    contain: content;
    will-change: contents, opacity;
    /* Hardware acceleration for smoother text rendering */
    /* font-kerning: none; */
    /* text-rendering: optimizeSpeed; */
    /* Reduce browser repaints/reflows during animation */
}

*,
*::before,
*::after {
    box-sizing: border-box;

}

body {
    background: hsl(154 50% 5%);
    color: hsl(154 84% 70%);
    text-shadow: 0 0 4px hsl(154 84% 70%);
    font-family: monospace;
    font-size: 1em;
    overflow-y: auto;
    /* Allows scrolling */
    padding-bottom: 50px;
    /* Adjust this value so it's more than the height of your fixed input container */
    max-width: 100vw;
    width: 100%;
    margin: 0 auto;
    padding-left: 10px;
    padding-right: 10px;
    box-sizing: border-box;
}


:root {
    --background: #031e11;
}
@media (min-width: 800px) {
    :root {
        --size: 1.2;
    }
}
@media (min-width: 1200px) {
    :root {
        --size: 1.5;
    }
}
/* to see yourself like in a mirror */
.self {
    transform: scale(-1, 1);
}
.flicker {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    max-width: 100vw;
    width: 100vw;
    background: rgba(18, 16, 16, 0.2);
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
    animation: flicker 0.12s infinite;
}
@keyframes flicker {
  0% {
    opacity: 0.552;
    max-width: 100vw;
  }
  5% {
    opacity: 0.48287;
    max-width: 100vw;
  }
  10% {
    opacity: 0.59134;
    max-width: 100vw;
  }
  15.0% {
    opacity: 0.79543;
    max-width: 100vw;
  }
  20% {
    opacity: 0.75134;
    max-width: 100vw;
  }
  25% {
    opacity: 0.1956;
    max-width: 100vw;
  }
  30.0% {
    opacity: 0.90687;
    max-width: 100vw;
  }
  35% {
    opacity: 0.122;
    max-width: 100vw;
  }
  40% {
    opacity: 0.62254;
    max-width: 100vw;
  }
  45% {
    opacity: 0.56977;
    max-width: 100vw;
  }
  50% {
    opacity: 0.9925;
    max-width: 100vw;
  }
  55.0% {
    opacity: 0.55487;
    max-width: 100vw;
  }
  60.0% {
    opacity: 0.16607;
    max-width: 100vw;
  }
  65% {
    opacity: 0.12353;
    max-width: 100vw;
  }
  70% {
    opacity: 0.2214;
    max-width: 100vw;
  }
  75% {
    opacity: 0.67908;
    max-width: 100vw;
  }
  80% {
    opacity: 0.97163;
    max-width: 100vw;
  }
  85.0% {
    opacity: 0.1275;
    max-width: 100vw;
  }
  90% {
    opacity: 0.37186;
    max-width: 100vw;
  }
  95% {
    opacity: 0.24475;
    max-width: 100vw;
  }
  100% {
    opacity: 0.37221;
    max-width: 100vw;
  }
}

.scanlines {
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    max-width: 100vw;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,.2) 70%,
        rgba(0,0,0,.6)
    );
    background-size: 100% .3rem;
    position: fixed;
    pointer-events: none;
}
.scanlines:before {
  position: absolute;
  top: 0px;
  width: 100%;
  max-width: 100vw;
  height: 5px;
  background: #fff;
  background: linear-gradient(to bottom,
      rgba(255,0,0,0) 0%,
      rgba(255,250,250,1) 50%,
      rgba(255,255,255,0.98) 51%,
      rgba(255,0,0,0) 100%
  ); /* W3C */
  opacity: .1;
}
.scanlines:after {
  max-width: 100vw;
  width: 100vw;
  box-shadow: 0 2px 6px rgba(25,25,25,0.2),
      inset 0 1px rgba(50,50,50,0.1),
      inset 0 3px rgba(50,50,50,0.05),
      inset 0 3px 8px rgba(64,64,64,0.05),
      inset 0 -5px 10px rgba(25,25,25,0.1);
}

/*
 * MS Edge don't support focus-within and css vars
 * inside pseudo selector
 */
@supports (-ms-ime-align:auto) {
    .scanlines:before {
        content: '';
        animation: vline 3s linear infinite;
    }
}
@keyframes vline {
  to { transform: translate(0, 100vh); max-width: 100vw; }
}

/* turn off animation */
.tv {
    height: 100vh;
    max-width: 100vw;
    width: 100vw;
    position: relative;
}
.tv.collapse {
    animation: size 2s ease-out;
    animation-fill-mode: forwards;
    max-width: 100vw;
}
.tv.collapse:before {
    content: '';
    display: block;
    height: 100%;
    max-width: 100vw;
    width: 100vw;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background: white;
    z-index: 1;
    opacity: 0;
    animation: opacity 2s ease-out;
    animation-fill-mode: forwards;
}

@keyframes opacity {
    to { opacity: 1; max-width: 100vw; }
}
@keyframes size {
    50% {
        transform: scaleX(calc(1 / var(--width)));
        opacity: 1;
        max-width: 100vw;
    }
    98% {
        transform: scaleX(calc(1 / var(--width))) scaleY(calc(1 / var(--height)));
        opacity: 1;
        max-width: 100vw;
    }
    100% {
        transform: scaleX(calc(1 / var(--width))) scaleY(calc(1 / var(--height)));
        opacity: 0;
        max-width: 100vw;
    }
}

/* Terminal Styles - Dynamic height calculation */
#terminal {
    width: 100%;
    max-width: 100vw;
    margin: 20px 0;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid hsl(154 84% 70%);
    border-radius: 5px;
    box-sizing: border-box;
    /* Height will be calculated dynamically by JavaScript */
    min-height: 300px;
    max-height: 80vh; /* Prevent terminal from stretching page when content increases */
    /* Allow JS to fully control height; no hard max-height cap */
}

/* Simple typing animation for terminal welcome message */
.terminal-typing {
    border-right: 2px solid hsl(154 84% 70%);
    animation: terminal-typing 3s steps(50, end), terminal-blink-caret 0.75s step-end infinite;
    white-space: pre;
    overflow: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}

@keyframes terminal-typing {
    from { width: 0; }
    to { width: 100vw; }
}

@keyframes terminal-blink-caret {
    from, to { border-color: transparent; max-width: 100vw; }
    50% { border-color: hsl(154 84% 70%); max-width: 100vw; }
}

/* Ensure terminal content fills the entire height */
#terminal .terminal {
    width: 100%;
    max-width: 100vw;
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Make the terminal scroller fill the entire terminal height with small padding for last line visibility */
#terminal .terminal .terminal-scroller {
    height: calc(100% - 10px) !important;
    max-height: calc(100% - 10px) !important;
    max-width: 100vw;
    padding-bottom: 10px;
}

/* Desktop styles */
@media (min-width: 769px) {
    #terminal {
        margin: 30px 0;
        /* Height calculated dynamically by JS */
    }

    #terminal .terminal {
        padding: 0;
    }

    #terminal .terminal .terminal-scroller {
        height: calc(100% - 10px) !important;
        max-height: calc(100% - 10px) !important;
        max-width: 100vw;
        padding-bottom: 10px;
    }
}

/* Tablet styles */
@media (max-width: 768px) {
    #terminal {
        margin: 15px 0;
        /* Height calculated dynamically by JS */
    }

    #terminal .terminal {
        padding: 0;
        font-size: 14px;
    }

    #terminal .terminal .terminal-scroller {
        height: calc(100% - 10px) !important;
        max-height: calc(100% - 10px) !important;
        max-width: 100vw;
        padding-bottom: 10px;
    }

    /* Make terminal more touch-friendly on mobile */
    .terminal .terminal-output {
        font-size: 12px;
        line-height: 1.4;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .terminal .cmd {
        font-size: 14px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .terminal .prompt {
        font-size: 14px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Improve touch targets */
    .terminal .terminal-scroller {
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    body {
        padding-left: 5px;
        padding-right: 5px;
    }

    #terminal {
        margin: 10px 0;
        /* Height calculated dynamically by JS */
    }

    #terminal .terminal {
        padding: 0;
        font-size: 12px;
    }

    #terminal .terminal .terminal-scroller {
        height: calc(100% - 10px) !important;
        max-height: calc(100% - 10px) !important;
        max-width: 100vw;
        padding-bottom: 10px;
    }

    .terminal .terminal-output {
        font-size: 11px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .terminal .cmd,
    .terminal .prompt {
        font-size: 12px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    body {
        padding-left: 3px;
        padding-right: 3px;
    }

    #terminal {
        margin: 5px 0;
    }
}

.collection {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100vw;
    padding: 10px;
    box-sizing: border-box;
}
.noise {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    max-width: 100vw;
    width: 100vw;
    z-index: 2000;
    opacity: 0.05;
    pointer-events: none;
    background:
        repeating-radial-gradient(#000 0 0.0001%,#fff 0 0.0002%) 50% 0/2500px 2500px,
        repeating-conic-gradient(#000 0 0.0001%,#fff 0 0.0002%) 50% 50%/2500px 2500px;
    background-blend-mode: difference;
    animation: shift .2s infinite alternate;
}
@keyframes shift {
    100% {
        background-position: 50% 0, 50% 60%;
        max-width: 100vw;
    }
}
@media (prefers-reduced-motion) {
    .noise, .flicker, .scanlines:before {
        animation: none !important;
    }
}

/* Footer links styling */
.collection.external.terminal a {
    color: rgb(114, 243, 187) !important;
    text-decoration: underline;
    cursor: pointer;
}

.collection.external.terminal a:hover {
    color: rgb(114, 243, 187) !important;
    text-decoration: none;
}
