:root {
    color-scheme: dark;
    --bg-primary: #040711;
    --window: #080c18;
    --window-bg: linear-gradient(#141d33 0 20%, #11182c 20% 40%, #0d1324 40% 60%, #0a0f1d 60% 80%, #080c18 80%);
    --frame: #ff8c00;
    --ink: #03050c;
    --field: #050814;
    --accent-orange: #ff8c00;
    --accent-yellow: #ffb347;
    --accent-blue: #38d9ff;
    --accent-green: #2eff7b;
    --accent-red: #ff2a4b;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.78);
    --text-muted: rgba(255, 255, 255, 0.55);
    --border-color: rgba(255, 140, 0, 0.25);
    --px: 4px;
    --window-frame:
        0 calc(var(--px) * -1) 0 0 var(--frame),
        0 var(--px) 0 0 var(--frame),
        calc(var(--px) * -1) 0 0 0 var(--frame),
        var(--px) 0 0 0 var(--frame),
        0 calc(var(--px) * -2) 0 0 var(--ink),
        0 calc(var(--px) * 2) 0 0 var(--ink),
        calc(var(--px) * -2) 0 0 0 var(--ink),
        calc(var(--px) * 2) 0 0 0 var(--ink),
        0 0 0 var(--px) var(--ink),
        calc(var(--px) * 3) calc(var(--px) * 3) 0 0 #000,
        0 0 24px rgba(0, 0, 0, 0.6);
    --nav-height: 52px;
    --page-width: 960px;
    --gutter: 20px;
    --font-pixel: "Press Start 2P", "Courier New", monospace;
    --font-body: "Inter", system-ui, sans-serif;
    --font-code: "JetBrains Mono", "Courier New", monospace;
}

body {
    min-height: 100vh;
    background:
        repeating-linear-gradient(transparent 0 2px, rgba(3, 5, 12, 0.5) 2px 4px),
        radial-gradient(circle at center, #10182e 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    font-family: var(--font-body);
}

.layout-wide {
    --page-width: 1312px;
}

/* Same inset formula as .nav so page content lines up with the nav links */
.page {
    box-sizing: border-box;
    padding: calc(var(--nav-height) + 32px) max(var(--gutter), (100% - var(--page-width)) / 2) 48px;
}

.window {
    position: relative;
    margin: calc(var(--px) * 2);
    padding: 24px;
    background-color: var(--window);
    background-image: var(--window-bg);
    box-shadow: var(--window-frame);
}

.window,
.window-open {
    animation: window-open 0.2s steps(4) backwards;
}

@keyframes window-open {
    from {
        transform: scaleY(0);
    }
}

@keyframes palette-cycle {
    33% {
        color: var(--accent-yellow);
        text-shadow: 0 0 12px var(--accent-orange);
    }

    66% {
        color: var(--text-primary);
        text-shadow: 0 0 16px var(--accent-orange);
    }
}

.window-title {
    margin: 0 0 16px;
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--accent-orange);
}

.page-title {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: 0;
    color: var(--accent-orange);
    text-shadow: 0.125em 0.125em 0 var(--ink), 0 0 20px rgba(255, 102, 0, 0.45);
}

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    height: var(--nav-height);
    padding: 0 max(var(--gutter), (100% - var(--page-width)) / 2);
    background: var(--ink);
    border-bottom: var(--px) solid var(--frame);
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    line-height: 1;
}

.nav a {
    color: var(--text-primary);
    text-decoration: none;
}

.nav a:hover,
.nav a:focus-visible {
    color: var(--accent-orange);
    text-shadow: 0 0 10px var(--accent-orange);
    animation: palette-cycle 0.6s steps(1) infinite;
}

.nav-home {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nav-home::before {
    content: "";
    width: 10px;
    height: 18px;
    background: url("sprites/cursor.svg") no-repeat center / contain;
    transform: scaleX(-1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 6px 14px;
    border: 2px solid var(--frame);
    border-radius: 0;
    background: var(--field);
    color: var(--accent-yellow);
    font: 500 0.875rem/1.2 var(--font-body);
    cursor: pointer;
}

.btn[hidden] {
    display: none;
}

.btn:hover {
    background: var(--accent-orange);
    color: #000;
    box-shadow: 0 0 16px var(--accent-orange);
}

.btn:focus-visible {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

.btn-primary {
    border-color: var(--accent-orange);
    background: var(--accent-orange);
    color: #000;
}

.btn-primary:hover {
    border-color: var(--accent-yellow);
    background: var(--accent-yellow);
    color: #000;
    box-shadow: 0 0 16px var(--accent-orange);
}

@media (max-width: 720px) {
    :root {
        --gutter: 12px;
    }

    .page-title {
        font-size: 1rem;
    }

    .nav {
        font-size: 0.625rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .window,
    .window-open,
    .nav a {
        animation: none !important;
    }
}
