body {
    margin: 0;
    padding: 20px;
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    height: 100vh;
    height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    overflow: auto;
    position: relative;
}

body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    pointer-events: none;
    z-index: 15;
}

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 100% 4px, 4px 100%;
    pointer-events: none;
    z-index: 10;
    animation: flicker 0.15s infinite;
}

.crt-overlay::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-size: 100% 8px;
    z-index: 11;
    pointer-events: none;
}

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

.rune-pulse {
    animation: runePulse 1.6s ease-in-out infinite;
    display: inline-block;
    will-change: text-shadow, opacity, transform;
}

@keyframes runePulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(0.985);
    }
    50% {
        opacity: 1;
        transform: scale(1.045);
    }
}

#status-bar {
    padding: 2px 20px;
    padding-top: calc(2px + env(safe-area-inset-top));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    display: block;
    z-index: 20;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-sizing: border-box;
}

#status-bar .status-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#status-bar .clickable {
    padding: 0 5px;
}

.terminal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 30px auto 0;
    width: 100%;
    padding-bottom: 20px;
    overflow: hidden;
    transform: perspective(1000px) rotateX(2deg) scale(1.04);
}

#output-wrapper {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    display: block;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#output-wrapper::-webkit-scrollbar {
    display: none;
}

#output {
    white-space: pre-wrap;
}

.input-line {
    display: flex;
    align-items: center;
}

.prompt {
    margin-right: 10px;
    animation: blink 1s step-end infinite;
}

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

input {
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    flex: 1;
}

.clickable {
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    padding: 2px 4px;
    margin: -2px 0;
}

b, strong {
    font-weight: bold;
}

a {
    text-decoration: underline;
}

a:focus, .clickable:focus, button:focus {
    outline-offset: 2px;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
        padding-left: calc(10px + env(safe-area-inset-left));
        padding-right: calc(10px + env(safe-area-inset-right));
    }
    
    .terminal-container {
        margin-top: 40px;
    }
    
    #status-bar {
        padding: 2px 10px;
        font-size: 0.8rem;
    }
    
    input {
        font-size: 16px;
    }
    
    .clickable {
        padding: 6px 4px;
    }
}

#jumpscare-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#ghost-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
    .crt-overlay { animation: none; }
    .crt-overlay::before { animation: none; }
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

body.a11y-mode {
    line-height: 1.6;
}

body.a11y-mode .crt-overlay { display: none; }
body.a11y-mode::after { display: none; }
body.a11y-mode .terminal-container {
    transform: none;
}

#main,
.terminal-container,
#output-wrapper,
#output {
    position: relative;
    z-index: 30;
}
