:root {
    --bg: #000000;
    --fg: #f3f3f3;
    --muted: #a8a8a8;
    --accent: #d9d9d9;
    --border: #444444;
    --ascii-height: 116px;
    --ascii-orientation-scale: 1;
    --page-pad: 20px;
    --app-vh: 100dvh;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: "Courier New", Courier, monospace;
    background-color: var(--bg);
    color: var(--fg);
    margin: 0;
    padding: var(--page-pad);
    overflow: hidden;
    height: var(--app-vh);
}

.landing-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: #020202;
    overflow: hidden;
}

.landing-dither {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.06), transparent 45%),
        radial-gradient(circle at 80% 75%, rgba(255, 255, 255, 0.04), transparent 50%),
        repeating-radial-gradient(circle at center, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px),
        #050505;
    filter: contrast(120%);
    animation: ditherPulse 4s ease-in-out infinite alternate;
}

.landing-content {
    position: relative;
    z-index: 1;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

.landing-ascii {
    margin: 0;
    color: #ececec;
    font-size: clamp(10px, 1.35vw, 19px);
    line-height: 1.1;
    white-space: pre;
    text-align: center;
    text-shadow: 0 0 14px rgba(255, 255, 255, 0.14);
}

.landing-link {
    color: #92b8ff;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.78rem;
    line-height: 1.05;
    margin: 0;
    white-space: pre;
    border: none;
    padding: 8px 12px;
    border-radius: 3px;
    background: transparent;
    user-select: none;
}

.landing-link:hover {
    color: #d7e6ff;
    border-color: #7ea4df;
    box-shadow: 0 0 10px rgba(116, 168, 255, 0.45);
}

.landing-panels {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

@media (min-width: 900px) {
    .landing-link {
        font-size: 0.96rem;
        padding: 10px 14px;
    }

    .landing-panels {
        gap: 16px;
    }
}

.landing-door {
    border: none;
    background: transparent;
    color: #d8d8d8;
    cursor: pointer;
    padding: 0;
    transform: translateY(0);
    transition: transform 120ms ease, filter 120ms ease;
}

.landing-door:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 7px rgba(160, 200, 255, 0.45));
}

.landing-door pre {
    margin: 0;
    font-family: inherit;
    font-size: clamp(10px, 1.15vw, 16px);
    line-height: 1;
}

.landing-overlay.opening {
    animation: landingFade 700ms ease forwards;
}

.terminal-title {
    color: var(--muted);
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 700;
    font-style: italic;
    letter-spacing: 0.02em;
}

.header-loading {
    color: var(--accent);
    font-size: 0.95rem;
    font-style: italic;
    margin-left: 2px;
}

.output {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    white-space: pre-wrap;
    font-size: 1.35vw;
    display: flex;
    flex-direction: column-reverse;
    padding: 2px 0;
    position: relative;
}

.output::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 34%;
    pointer-events: none;
    background: linear-gradient(to bottom, #000000 0%, rgba(0, 0, 0, 0) 100%);
}

.output > div {
    color: var(--accent);
    margin-bottom: 10px;
    line-height: 1.25;
}

.output > div:nth-child(odd) {
    font-style: italic;
}

.ascii-art {
    text-align: center;
    font-size: calc(0.92vw * var(--ascii-scale, 1) * var(--ascii-orientation-scale));
    white-space: pre;
    color: var(--fg);
    text-shadow: 0 0 5px #1f1f1f;
    font-weight: 700;
    transition: opacity 180ms ease-in-out;
    margin: 0;
    max-width: 100%;
    overflow: hidden;
}

.ascii-stage {
    height: var(--ascii-height);
    border-top: 1px solid var(--border);
    margin-bottom: 2px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.ascii-stage.easter-egg-stage {
    position: fixed;
    inset: 0;
    z-index: 200;
    height: auto;
    margin: 0;
    border: none;
    background: #000000;
    align-items: center;
}

body.chat-mode .ascii-stage {
    display: none;
}

body.chat-mode .output {
    flex: 1;
    min-height: 0;
    border-top: 1px solid #1d1d1d;
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    padding-right: 4px;
}

body.chat-mode .control-panel {
    opacity: 0.9;
}

body.chat-mode #header-loading {
    display: none !important;
}

.ascii-art.easter-egg-art {
    font-size: clamp(12px, 1.4vw, 26px);
    line-height: 1.05;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    text-shadow: 0 0 10px #000000;
}

#terminal-app {
    height: calc(var(--app-vh) - (var(--page-pad) * 2));
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.ascii-star {
    font-size: 0.4vw;
    display: block;
    margin: 0 auto;
    color: var(--muted);
    font-style: italic;
}

#input-container {
    display: flex;
    align-items: center;
    margin-top: 12px;
    background: #121212;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 6px 10px;
}

.control-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 0 2px 0;
    width: 100%;
    min-height: 48px;
}

.control-panel.is-typing {
    visibility: hidden;
    pointer-events: none;
}

.cp-btn {
    border: none;
    background: transparent;
    color: #92b8ff;
    font-family: inherit;
    font-size: 0.72rem;
    line-height: 1;
    white-space: pre;
    font-weight: 700;
    font-style: normal;
    letter-spacing: 0.08em;
    padding: 4px 8px;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 80ms ease;
    box-shadow: none;
    text-align: center;
}

.cp-btn:hover {
    color: #d7e6ff;
    box-shadow: 0 0 10px rgba(116, 168, 255, 0.45);
}

.cp-btn.primary {
    color: #92b8ff;
    box-shadow: none;
}

.cp-btn.primary:hover {
    box-shadow: 0 0 10px rgba(116, 168, 255, 0.45);
}

.cp-btn:active {
    transform: translateY(1px);
}

.prompt {
    margin-right: 2px;
    font-size: 1.35vw;
    color: var(--fg);
    font-weight: 700;
    font-style: italic;
}

.prompt-cursor {
    display: inline-block;
    width: 0.16em;
    height: 1.08em;
    margin-left: 0;
    margin-right: 6px;
    background: #f2f2f2;
    border-radius: 0;
    font-size: 1.35vw;
    animation: promptBlink 0.9s steps(1, end) infinite;
}

#input-container.has-input .prompt-cursor {
    opacity: 0;
    animation: none;
}

.input {
    flex: 1;
    margin-left: -6px;
    font-size: 1.35vw;
    color: var(--fg);
    background-color: var(--bg);
    border: none;
    outline: none;
    caret-color: transparent;
    font-style: italic;
}

#profile-image {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

@media (max-width: 600px) {
    #profile-image {
        width: 70px;
        height: 70px;
    }

    .terminal-title {
        font-size: 0.85rem;
    }

    :root {
        --ascii-height: 180px;
    }

    .ascii-art {
        font-size: calc(1.45vw * var(--ascii-scale, 1) * var(--ascii-orientation-scale));
    }
}

@media (orientation: portrait) {
    :root {
        --ascii-height: min(11dvh, 108px);
        --ascii-orientation-scale: 1.23;
        --page-pad: 8px;
    }

    .terminal-title,
    .header-loading {
        font-size: 0.42rem;
    }

    .output {
        font-size: 3.5vw;
        padding: 4px 0;
    }

    .prompt,
    .input,
    .prompt-cursor {
        font-size: 4.2vw;
    }

    .cp-btn {
        font-size: 0.82rem;
        padding: 6px 11px;
    }

    .control-panel {
        gap: 6px;
        margin-top: 6px;
        padding: 3px 0 1px 0;
        min-height: 54px;
    }

    #input-container {
        margin-top: 6px;
        position: sticky;
        bottom: 0;
        z-index: 40;
        background: #101010;
        padding-top: 4px;
    }

    .ascii-stage {
        margin-bottom: 1px;
    }
}

body.keyboard-open #input-container {
    border-top: 1px solid #1d1d1d;
}

.input-glow {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 14px !important;
}

.chat-event-line {
    color: #6ea8ff !important;
    font-size: 0.82em;
    font-style: normal !important;
    font-weight: 600;
}

.chat-line {
    margin-bottom: 8px;
    line-height: 1.2;
}

.chat-username {
    font-weight: 800;
}

.spam-alert-line {
    font-size: 3em;
    font-weight: 900 !important;
    line-height: 1;
    letter-spacing: 0.06em;
}

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

.ascii-art-border {
    border: 1px solid var(--border);
    padding: 10px;
    margin: 20px 0;
}

.ascii-cart {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.ascii-cart-border {
    border: 1px solid var(--border);
    padding: 10px;
    margin: 20px 0;
}

.cart-shortcut {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: #101010;
    color: var(--fg);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    font-style: italic;
    cursor: pointer;
}

.cart-shortcut:hover {
    background: #1a1a1a;
}

.hidden {
    display: none;
}

.ascii-flash {
    animation: asciiFlash 300ms ease-in-out 3;
}

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

@keyframes landingFade {
    0% { opacity: 1; filter: blur(0); }
    100% { opacity: 0; filter: blur(4px); }
}

@keyframes ditherPulse {
    0% { transform: scale(1); opacity: 0.92; }
    100% { transform: scale(1.02); opacity: 1; }
}

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