:root {
    --bg-color: #0a0a0a;
    --text-color: #00ff41;
    --font-family: 'Courier New', Courier, monospace;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    margin: 0;
    /* Base padding with safe-area side insets for notched devices */
    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;
    /* Allow page scroll (output wrapper remains scrollable) */
    overflow: auto;
    position: relative;
}

body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: radial-gradient(circle, rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 100%),
                radial-gradient(circle, rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 15;
}

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    ), linear-gradient(
        90deg,
        rgba(255, 0, 0, 0.02),
        rgba(0, 255, 0, 0.01),
        rgba(0, 0, 255, 0.02)
    );
    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: linear-gradient(rgba(18, 16, 16, 0) 0%, rgba(32, 255, 128, 0.01) 50%, rgba(18, 16, 16, 0) 100%);
    background-size: 100% 8px;
    z-index: 11;
    pointer-events: none;
    /* animation: scanline 6s linear infinite; - Removed moving scanline */
}

@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

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

#status-bar {
    background-color: var(--text-color);
    color: var(--bg-color);
    /* Include safe-area top/side padding to avoid notches */
    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; /* full-bleed bar; contents centered via inner wrapper */
    font-weight: bold;
    z-index: 20;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    text-shadow: none;
    width: 100%;
    box-sizing: border-box;
}

/* Center and constrain contents inside the full-bleed status bar */
#status-bar .status-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

#status-bar .clickable:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
    text-decoration: none;
}

.terminal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 30px auto 0;
    width: 100%;
    text-shadow: 0 0 3px rgba(0, 255, 65, 0.6), 0 0 6px rgba(0, 255, 65, 0.3);
    padding-bottom: 20px;
    overflow: hidden; /* Contain children */
    transform: perspective(1000px) rotateX(2deg) scale(1.04);
    filter: contrast(1.2) brightness(1.1);
}

#output-wrapper {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    display: block; /* Changed from flex to block to allow natural flow */
}

#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;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1rem;
    outline: none;
    flex: 1;
}

/* Hide scrollbar for Chrome, Safari and Opera */
#output-wrapper::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
#output-wrapper {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.clickable {
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
    display: inline-block; /* Larger touch target */
    padding: 2px 4px;
    margin: -2px 0;
    text-shadow: 0 0 2px rgba(0, 255, 65, 0.4), 0 0 4px rgba(0, 255, 65, 0.2);
}

b, strong {
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0, 255, 65, 0.4), 0 0 4px rgba(0, 255, 65, 0.2);
}

a {
    color: #00ff41; /* A slightly different shade of green */
    text-decoration: underline;
}

a:hover {
    color: var(--bg-color);
    background-color: var(--text-color);
    text-shadow: none;
}

/* Visible focus styles for keyboard users */
a:focus, .clickable:focus, button:focus {
    outline: 2px solid #00ff41;
    outline-offset: 2px;
}

/* The text input already shows a caret; avoid a full-width outline that looks like a line */
input:focus {
    outline: none;
}

@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; /* Prevents iOS zoom on focus */
    }
    
    .clickable {
        padding: 6px 4px; /* Even larger touch target on mobile */
    }
}

.clickable:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

#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;
}

/* Respect reduced motion preferences to improve performance/accessibility */
@media (prefers-reduced-motion: reduce) {
    .crt-overlay { animation: none; }
    .crt-overlay::before { animation: none; }
}

/* Visually hidden utility for screen reader-only content */
.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;
}

/* Completely hidden (not announced) */
.hidden { display: none !important; }

/* Accessibility mode: higher contrast, reduced effects, larger line-height */
body.a11y-mode {
    line-height: 1.6;
    text-shadow: none;
}

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