@font-face {
    font-family: "Blue Screen";
    src: url("../fonts/Blue%20Screen.woff") format("woff"), url("../fonts/Blue%20Screen.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    height: 100%;
    background: #0c0f12;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: "Blue Screen", monospace;
    color: #cfd4d8;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

button {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
}

#stage {
    position: fixed;
    inset: 0;
}

#c {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: 0;
}

.vig {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.62) 100%);
}

.grain {
    position: absolute;
    inset: -50%;
    pointer-events: none;
    opacity: 0.07;
    background-size: 128px 128px;
    animation: walk-grain 0.9s steps(1) infinite;
}

@keyframes walk-grain {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-7%, 4%); }
    40% { transform: translate(5%, -6%); }
    60% { transform: translate(-3%, -2%); }
    80% { transform: translate(6%, 7%); }
}

/* ---------- HUD (plain text, no boxes) ---------- */

#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.hud-btn {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    pointer-events: auto;
    font-size: 15px;
    letter-spacing: 0.16em;
    color: #b4bbc0;
    text-decoration: none;
    text-shadow: 0 0 6px #000, 0 0 14px #000;
    padding: 6px 4px;
}

.hud-btn:hover,
.hud-btn:focus-visible {
    color: #fff;
    outline: 0;
}

.hud-back {
    z-index: 30;
    left: max(14px, env(safe-area-inset-left));
    font-size: 30px;
    line-height: 1;
    padding: 4px 10px;
}

.hud-caption {
    position: absolute;
    left: 50%;
    bottom: max(30px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
    letter-spacing: 0.16em;
    white-space: nowrap;
    color: #c5cbcf;
    text-shadow: 0 0 6px #000, 0 0 14px #000, 0 0 26px #000;
    animation: walk-fade 0.6s ease both;
}

.hud-caption[hidden],
.hud-caption button[hidden] { display: none; }

.hud-caption button {
    pointer-events: auto;
    font-size: 15px;
    letter-spacing: 0.16em;
    padding: 8px 2px;
    animation: walk-glow 3.2s ease-in-out infinite;
}

@keyframes walk-glow {
    0%, 100% { color: #929292; text-shadow: 0 0 6px #000, 0 0 14px #000; }
    50% { color: #f0f0f0; text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 18px rgba(0, 0, 0, 0.9); }
}

@keyframes walk-fade {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hud-caption .num {
    font-family: ui-monospace, "Courier New", monospace;
    letter-spacing: 0.08em;
}

.hud-hint {
    position: absolute;
    left: 50%;
    bottom: max(34px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    font-size: 13px;
    letter-spacing: 0.16em;
    color: #a5acb1;
    text-shadow: 0 0 6px #000, 0 0 14px #000;
    text-align: center;
    transition: opacity 1.4s ease;
    white-space: nowrap;
}

.hud-hint.is-gone { opacity: 0; }

/* ---------- joystick ---------- */

#joy {
    position: fixed;
    width: 150px;
    height: 150px;
    margin: -75px 0 0 -75px;
    border-radius: 50%;
    border: 1px solid rgba(220, 226, 230, 0.28);
    background: radial-gradient(circle, rgba(220, 226, 230, 0.10), rgba(220, 226, 230, 0.03) 70%);
    pointer-events: none;
    z-index: 6;
    opacity: 0.4;
    transition: opacity 0.25s ease;
}

#joy.is-active { opacity: 1; }

/* ring marking where walking turns into running */
#joy::after {
    content: "";
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    border: 1px dashed rgba(220, 226, 230, 0.16);
}

#knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 62px;
    height: 62px;
    margin: -31px 0 0 -31px;
    border-radius: 50%;
    background: rgba(220, 226, 230, 0.26);
    border: 1px solid rgba(220, 226, 230, 0.5);
    will-change: transform;
}

#joy.is-run #knob {
    background: rgba(240, 244, 246, 0.5);
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.4);
}

/* ---------- photo viewer ---------- */

#viewer {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 5, 6, 0.94);
    animation: walk-vfade 0.35s ease both;
}

#viewer[hidden] { display: none; }

#viewer img {
    max-width: 96vw;
    max-height: 92vh;
    object-fit: contain;
}

#viewClose {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    font-size: 36px;
    line-height: 1;
    color: #cfd4d8;
    padding: 8px 14px;
}

@keyframes walk-vfade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- transitions ---------- */

#flash {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}
#flash.white { background: #e9eef2; }
#flash.on { opacity: 1; }
#flash.slow { transition: opacity 1.8s ease; }

#ending {
    position: fixed;
    inset: 0;
    z-index: 26;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.6s ease;
}
#ending[hidden] { display: none; }
#ending.on { opacity: 1; }
#ending p {
    margin: 0;
    padding: 0 24px;
    font-size: clamp(18px, 5vw, 34px);
    letter-spacing: 0.24em;
    color: #2a2a28;
}

/* ---------- entry screen: same look as the landing page ---------- */

#intro {
    position: fixed;
    inset: 0;
    z-index: 30;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #030403;
    transition: opacity 1.6s ease, visibility 1.6s;
}

#intro.is-gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.slides, .slide, .slide-shade { position: absolute; inset: 0; pointer-events: none; }

.slide {
    background-size: cover;
    background-position: center;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity 2.4s ease-in-out, transform 9s linear;
    will-change: opacity, transform;
}

.slide.on { opacity: 1; transform: scale(1.1); }

.slide-shade {
    background:
        radial-gradient(ellipse at 50% 45%, rgba(3, 4, 3, 0.25) 0%, rgba(3, 4, 3, 0.7) 100%),
        rgba(3, 4, 3, 0.42);
}

.intro-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 3;
    padding: 24px;
}

#intro h1 {
    margin: 0 0 18px;
    font-weight: normal;
    font-size: clamp(22px, 6vw, 56px);
    letter-spacing: 0.2em;
    padding-left: 0.2em;
    color: #868686;
    opacity: 0;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 9px rgba(0, 0, 0, 0.7);
    animation: enter-appear 2s ease 0.8s forwards;
}

#enter {
    position: relative;
    font-size: clamp(17px, 4.6vw, 30px);
    letter-spacing: 0.16em;
    padding: 18px 20px 18px 28px;
    max-width: 92vw;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    color: #868686;
    opacity: 0;
    animation: enter-appear 2s ease 1.1s forwards;
    transition: color 0.4s ease, text-shadow 0.4s ease;
    isolation: isolate;
}

#enter:disabled { color: #4a4a46; cursor: default; }
#enter:not(:disabled) { animation: enter-appear 2s ease 0.2s forwards, enter-breathe 5s ease-in-out 2.2s infinite; }

#enter:not(:disabled):hover,
#enter:not(:disabled):focus-visible {
    color: #bdbdbd;
    text-shadow: 0 0 14px rgba(220, 220, 220, 0.2);
    outline: none;
}

#enter::before,
#enter::after {
    content: attr(data-text);
    position: absolute;
    inset: 18px 26px 18px 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    white-space: nowrap;
    font: inherit;
    letter-spacing: inherit;
    opacity: 0;
}

#enter::before { color: rgba(220, 220, 220, 0.8); clip-path: inset(20% 0 65% 0); }
#enter::after { color: rgba(175, 175, 175, 0.8); clip-path: inset(65% 0 20% 0); }
#enter.glitch::before { animation: glitch-upper 300ms steps(2, end) both; }
#enter.glitch::after { animation: glitch-lower 340ms steps(2, end) both; }

@keyframes enter-appear { from { opacity: 0; } to { opacity: 0.82; } }

@keyframes enter-breathe {
    0%, 100% {
        color: #868686;
        text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 9px rgba(0, 0, 0, 0.7), 0 0 2px rgba(220, 220, 220, 0.08);
    }
    50% {
        color: #a6a6a6;
        text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 9px rgba(0, 0, 0, 0.7), 0 0 5px rgba(225, 225, 225, 0.2), 0 0 13px rgba(220, 220, 220, 0.12);
    }
}

@keyframes glitch-upper {
    0% { opacity: 0; clip-path: inset(20% 0 65% 0); }
    15% { opacity: 0.85; clip-path: inset(12% 0 72% 0); }
    30% { opacity: 0.3; clip-path: inset(30% 0 55% 0); }
    45% { opacity: 0.95; clip-path: inset(24% 0 60% 0); }
    65% { opacity: 0.5; clip-path: inset(15% 0 70% 0); }
    80% { opacity: 0.75; clip-path: inset(35% 0 50% 0); }
    100% { opacity: 0; }
}

@keyframes glitch-lower {
    0% { opacity: 0; clip-path: inset(65% 0 20% 0); }
    20% { opacity: 0.75; clip-path: inset(58% 0 28% 0); }
    40% { opacity: 0.3; clip-path: inset(70% 0 16% 0); }
    60% { opacity: 0.9; clip-path: inset(62% 0 25% 0); }
    80% { opacity: 0.55; clip-path: inset(73% 0 13% 0); }
    100% { opacity: 0; }
}

.intro-keys {
    display: inline-block;
    margin: 30px 0 0;
    text-align: left;
    font-size: 15px;
    letter-spacing: 0.16em;
    line-height: 1;
    color: #868686;
    opacity: 0;
    animation: wordmark-in 1.8s ease 1.4s forwards;
}

.intro-keys div {
    display: grid;
    grid-template-columns: 11.5em auto;
    gap: 14px;
    padding: 7px 0;
}

.intro-keys b {
    font-weight: normal;
    color: #bdbdbd;
}

.wordmark {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    color: #4a4a46;
    font-family: "Courier New", Courier, monospace;
    font-size: 11px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    animation: wordmark-in 1.8s ease 0.8s forwards;
}

@keyframes wordmark-in { from { opacity: 0; } to { opacity: 0.8; } }

.page-fade {
    position: absolute;
    inset: 0;
    z-index: 9;
    background: #030403;
    pointer-events: none;
    animation: fade-from-black 3.5s ease-out forwards;
}

@keyframes fade-from-black { from { opacity: 1; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .grain { animation: none; }
    .slide { transition: opacity 2.4s ease-in-out; transform: none; }
    .slide.on { transform: none; }
    .page-fade { animation-duration: 0.5s; }
    #enter:not(:disabled), .hud-caption button { animation-duration: 0.5s; }
    #enter.glitch::before, #enter.glitch::after { animation: none; }
}

.intro-keys .keys-title {
    margin: 0 0 10px;
    text-align: center;
    color: #868686;
    font-size: 13px;
    letter-spacing: 0.3em;
}

/* controls: left side of the entry screen */
.intro-keys .keys-title { text-align: left; }

@media (min-width: 700px) {
    .intro-inner { position: static; }
    #enter { position: relative; z-index: 3; }
    .intro-keys {
        position: absolute;
        left: clamp(24px, 4vw, 64px);
        bottom: 70px;
        margin: 0;
        z-index: 3;
    }
}
