:root {
    --bg: #020403;
    --panel: #06110d;
    --line: #1d5b3f;
    --text: #9cff9c;
    --dim: #6fbe79;
    --warn: #ffd85a;
}

    /* Theme overrides (CMD-style) */
    :root[data-theme="blue"] {
        --text: #6fb6ff;
        --dim: #7aa7d6;
        --line: #2b6fb3;
    }

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: #000;
    color: var(--text);
    font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
}

/* For full-bleed terminal requirement: remove default body padding so terminal can occupy all viewport space */
body {
    display: block;
    padding: 0;
    overflow: hidden; /* keep page from scrolling; terminal panel scrolls internally */
}

.center-status-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    white-space: pre-line;
    pointer-events: none;
    opacity: 0;
    color: #f7fff7;
    text-shadow: 0 0 18px rgba(0, 0, 0, 0.9), 0 0 28px rgba(0, 0, 0, 0.75);
    font-size: clamp(2rem, 7vw, 5.5rem);
    font-weight: 700;
    letter-spacing: 0.16em;
    line-height: 1.1;
    background: rgba(0, 0, 0, 0.32);
    transition: opacity 120ms ease-in-out;
}

.center-status-overlay.is-visible {
    opacity: 1;
}

body.screen-clarity::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background: #fff;
    opacity: 0;
    mix-blend-mode: screen;
    animation: screen-clarity-pulse 3000ms ease-in-out 1;
}

body.screen-fade::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    background: #000;
    opacity: 0;
    animation: screen-fade-pulse 900ms ease-in-out infinite;
}

body.screen-damage-flash .terminal-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: rgba(255, 20, 20, 0.92);
    opacity: 0;
    animation: screen-damage-flash 20ms linear 1;
}

body.screen-shake .crt,
body.screen-shake .terminal-shell,
body.screen-shake .site-links {
    animation: screen-shake 120ms linear infinite;
}

body.screen-victory-burst .terminal-shell {
    animation: screen-victory-burst 620ms cubic-bezier(.18, 1, .22, 1) 1;
}

body.screen-victory-glow .terminal-shell {
    animation: screen-victory-shell-glow 480ms ease-in-out infinite;
}

body.screen-victory-glow .site-links {
    animation: screen-victory-text-glow 480ms ease-in-out infinite;
}

body.screen-victory-prism .crt {
    animation: screen-victory-prism 340ms linear infinite;
}

body.screen-victory-prism .center-status-overlay.is-visible {
    color: #fff7bf;
    text-shadow: 0 0 12px rgba(255, 238, 145, .95), 0 0 30px rgba(255, 185, 76, .92), 0 0 55px rgba(255, 130, 64, .62);
}

@keyframes screen-shake {
    0% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-10px, 7px, 0); }
    40% { transform: translate3d(9px, -6px, 0); }
    60% { transform: translate3d(-7px, -4px, 0); }
    80% { transform: translate3d(8px, 5px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

@keyframes screen-fade-pulse {
    0% { opacity: 0; }
    50% { opacity: 0.72; }
    100% { opacity: 0; }
}

@keyframes screen-damage-flash {
    0% { opacity: 0.95; }
    100% { opacity: 0; }
}

@keyframes screen-victory-burst {
    0% {
        transform: scale(.985);
        filter: brightness(1) saturate(1);
    }
    35% {
        transform: scale(1.012);
        filter: brightness(1.45) saturate(1.75);
    }
    100% {
        transform: scale(1);
        filter: brightness(1) saturate(1);
    }
}

@keyframes screen-victory-shell-glow {
    0% {
        border-color: #1d5b3f;
        box-shadow: 0 0 40px rgba(30, 255, 110, .2), inset 0 0 40px rgba(0, 0, 0, .65);
    }
    50% {
        border-color: #ffe680;
        box-shadow: 0 0 64px rgba(255, 226, 122, .62), inset 0 0 34px rgba(255, 230, 166, .2);
    }
    100% {
        border-color: #1d5b3f;
        box-shadow: 0 0 40px rgba(30, 255, 110, .2), inset 0 0 40px rgba(0, 0, 0, .65);
    }
}

@keyframes screen-victory-text-glow {
    0% { text-shadow: 0 0 0 rgba(255, 255, 255, 0); }
    50% { text-shadow: 0 0 14px rgba(255, 245, 176, .95), 0 0 26px rgba(255, 206, 107, .7); }
    100% { text-shadow: 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes screen-victory-prism {
    0% { filter: hue-rotate(0deg) saturate(1.15) brightness(1); }
    50% { filter: hue-rotate(28deg) saturate(1.6) brightness(1.25); }
    100% { filter: hue-rotate(0deg) saturate(1.15) brightness(1); }
}

@keyframes screen-heal-bg-pulse {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes screen-clarity-pulse {
    0% { opacity: 0; }
    50% { opacity: 0.55; }
    100% { opacity: 0; }
}

.crt {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, .32) 50%), linear-gradient(90deg, rgba(255, 0, 0, .04), rgba(0, 255, 0, .03), rgba(0, 0, 255, .04));
    background-size: 100% 3px, 4px 100%;
}

.terminal-shell {
    position: fixed; /* occupy the viewport with a small inset */
    inset: 16px; /* leave a small outer margin so the glow is visible */
    z-index: 2;
    isolation: isolate;
    border: 2px solid var(--line);
    background: radial-gradient(circle at top, #0d1d15 0%, var(--panel) 50%, #010403 100%);
    box-shadow: 0 0 40px rgba(30, 255, 110, .2), inset 0 0 40px rgba(0, 0, 0, .65);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
}

body.screen-heal-bg .terminal-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(196, 255, 196, .92) 0%, rgba(136, 255, 136, .42) 52%, rgba(136, 255, 136, 0) 100%);
    animation: screen-heal-bg-pulse 2000ms ease-in-out 1;
}

.terminal-shell.has-footer {
    inset: 16px 16px 56px;
}

.site-links {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 12px;
    z-index: 2;
    text-align: center;
    color: var(--dim);
    font-size: clamp(0.72rem, 0.8vw, 0.92rem);
}

.site-links a {
    color: var(--text);
    text-decoration: none;
}

.site-links a:hover {
    color: var(--warn);
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    color: var(--dim);
    font-size: .9rem;
    gap: 12px;
}

.terminal-header,
.terminal-output,
.inventory-strip,
.terminal-prompt {
    position: relative;
    z-index: 1;
}

#clock {
    min-width: 170px;
    text-align: right;
}

.terminal-output {
    padding: 8px 36px; /* give horizontal room inside full-bleed shell */
    overflow-y: auto;
    line-height: 1.05;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
    /* Reserve space for scrollbar so content width doesn't jump and scrollbar aligns */
    scrollbar-gutter: stable both-edges;
    box-sizing: border-box;
}

.inventory-strip {
    border-top: 1px solid var(--line);
    padding: 10px 12px;
    min-height: 108px;
}

.inventory-strip[hidden] {
    display: none;
}

.inventory-strip-label {
    color: var(--dim);
    font-size: 0.76rem;
    letter-spacing: 0.14em;
    margin-bottom: 8px;
}

.inventory-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 72px;
}

.inventory-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    max-width: 72px;
    flex: 0 0 auto;
    overflow: hidden;
    opacity: 1;
    margin-right: 8px;
    padding: 4px;
    border: 1px solid rgba(29, 91, 63, 0.9);
    background: rgba(0, 0, 0, 0.32);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45);
    transition: opacity 220ms ease, max-width 220ms ease, margin-right 220ms ease, padding 220ms ease, border-width 220ms ease;
}

.inventory-item.is-collapsed {
    opacity: 0;
    max-width: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    border-left-width: 0;
    border-right-width: 0;
}

.inventory-item img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.scene-image-wrap {
    margin: 0 0 8px;
}

.scene-image {
    display: block;
    width: auto;
    max-width: min(375px, 100%);
    height: auto;
    image-rendering: pixelated;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.35);
}

/* ASCII/banner rendering */
.line.ascii {
    line-height: 1;
}

.line.ascii-blue {
    color: #6fb6ff;
}

.line.scene-story {
    color: #6fb6ff;
}

/* Terminal typography: slightly smaller and denser for better skimming */
.terminal-output,
.terminal-prompt,
.terminal-header {
    font-size: clamp(0.72rem, 0.8vw, 0.92rem);
}

    /* Make paragraph lines feel like a real terminal (no extra margins) */
    .terminal-output .line {
        margin: 0;
        padding: 0;
    }

        .terminal-output .line + .line {
            margin-top: 0.15rem; /* slight separation, closer to PowerShell */
        }

    /* Platform-consistent thin scrollbar inside the terminal output */
    .terminal-output::-webkit-scrollbar {
        width: 12px;
    }

    .terminal-output::-webkit-scrollbar-track {
        background: transparent;
    }

    .terminal-output::-webkit-scrollbar-thumb {
        background-color: rgba(16, 128, 64, 0.35);
        border: 1px solid rgba(30, 255, 110, 0.12);
        border-radius: 6px;
    }

/* Firefox: use scrollbar-width and appearance */
.terminal-output {
    scrollbar-width: thin;
    scrollbar-color: rgba(16,128,64,0.35) transparent;
}

/* Resume specific styles */
.resume-container {
    padding: 6px 10px;
}

.resume-text {
    white-space: normal; /* allow wrapping */
    overflow-wrap: anywhere;
    word-break: break-word;
    font-family: inherit;
    /* responsive font sizing: scales with viewport but stays bounded */
    font-size: clamp(0.78rem, 0.9vw, 1.12rem);
    line-height: 1.32; /* tighter within paragraphs */
    max-width: 100%;
}

    .resume-text .line {
        margin: 0 0 0.18rem 0; /* tight between normal lines */
        color: var(--text);
    }

    /* Darker detail text so job/section headers stand out */
    .resume-text .detail {
        margin: 0 0 0.18rem 0.4rem;
        color: color-mix(in srgb, var(--text) 68%, #000);
    }

    .resume-text .blank {
        height: 1.4rem;
    }

    .resume-text .top-gap {
        height: 0.4rem;
    }

    .resume-text .section-header {
        display: block;
        margin-top: 1.6rem;
        margin-bottom: 0.9rem;
        color: var(--dim);
        letter-spacing: 2px;
        font-weight: 600;
        border-top: 1px solid rgba(29, 91, 63, 0.15);
        padding-top: 0.5rem;
    }

    .resume-text .job-header {
        display: block;
        margin-top: 2.1rem;
        margin-bottom: 0.5rem;
        font-weight: 800;
        color: var(--text);
    }

/* Treat "blank" lines as paragraph breaks (more space than a normal line) */

/* Make the terminal larger on wide displays so it doesn't look tiny */
/* Remove arbitrary sizing on very large screens so the shell remains fluid and uses inset for margin */
.resume-download {
    margin-top: 0.8rem;
    color: var(--dim);
}

    .resume-download a {
        color: var(--text);
        text-decoration: underline;
    }

/* Larger screens: use more space and increase spacing for readability */
@media (min-width: 1200px) {
    /* On wider screens increase typographic scale and spacing but keep shell fluid */
    .resume-text {
        font-size: 1.06rem;
        line-height: 1.38;
    }

        .resume-text .line {
            margin-bottom: 0.2rem;
        }
}

/* Mobile: shrink font and tighten layout so the terminal fits well */
@media (max-width: 700px) {
    .terminal-shell {
        /* keep small inset on mobile so glow is visible but terminal fits */
        inset: 8px;
    }

    .terminal-shell.has-footer {
        inset: 8px 8px 52px;
    }

    .site-links {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .terminal-header {
        font-size: .68rem;
    }

    .terminal-output {
        padding: 10px;
    }

    .inventory-strip {
        min-height: 96px;
        padding: 8px 10px;
    }

    .inventory-bar {
        min-height: 64px;
    }

    .inventory-item {
        width: 64px;
        height: 64px;
        max-width: 64px;
        margin-right: 6px;
    }

    .resume-text {
        font-size: 0.78rem;
        line-height: 1.3;
    }

        .resume-text .line {
            margin-bottom: 0.16rem;
        }
}

.line {
    margin: 0 0 8px;
}

    .line.warn {
        color: var(--warn);
    }

.terminal-prompt {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding: 10px 12px;
}

.terminal-prompt.prompt-disabled {
    opacity: 0.5;
}

.prompt-label {
    color: var(--dim);
}

#cmdInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    outline: none;
}

#cmdInput:disabled {
    cursor: not-allowed;
}

.term-link {
    color: var(--text);
    text-decoration: none;
}

    .term-link:hover {
        color: var(--warn);
    }

@media (max-width: 700px) {
    .terminal-header {
        font-size: .74rem;
    }

    .prompt-label {
        display: none;
    }
}
