:root {
    --bg: #000;
    --panel: rgba(4, 4, 4, 0.95);
    --line: rgba(255, 255, 255, 0.1);
    --text: #f0f0f0;
    --muted: #b8b8b8;
    --danger: #861717;
    --danger-bright: #ff3c3c;
}

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

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: "Courier New", monospace;
    touch-action: none;
    overscroll-behavior: none;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
}

#aspect-wrapper {
    position: relative;
    width: 100vw;
    height: 177.77vw;
    max-height: 100vh;
    max-width: 56.25vh;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}

#game-canvas,
#ui-layer,
#vignette,
#film-grain,
#jumpscare-overlay,
#hud,
#reticle {
    position: absolute;
    inset: 0;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#vignette {
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(circle at center, rgba(0,0,0,0) 28%, rgba(0,0,0,0.5) 68%, rgba(0,0,0,0.92) 100%);
}

#film-grain {
    pointer-events: none;
    z-index: 4;
    opacity: 0.15;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 50%, rgba(0,0,0,0.12) 50%),
        linear-gradient(90deg, rgba(255,255,255,0.02), rgba(0,0,0,0.03), rgba(255,255,255,0.015));
    background-size: 100% 3px, 4px 100%;
    animation: grainShift 0.18s steps(2) infinite;
}

#reticle {
    pointer-events: none;
    z-index: 5;
}

#reticle::before,
#reticle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.75);
}

#reticle::before { width: 18px; height: 1px; }
#reticle::after { width: 1px; height: 18px; }

#jumpscare-overlay {
    pointer-events: none;
    z-index: 12;
    opacity: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, rgba(255,70,70,0.65) 28%, rgba(90,0,0,0.88) 72%, rgba(0,0,0,0.96) 100%);
    transition: opacity 70ms linear;
    mix-blend-mode: screen;
}

#jumpscare-overlay.flash { opacity: 1; }

#hud {
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: env(safe-area-inset-top, 12px) 10px env(safe-area-inset-bottom, 16px);
}

#hud.hidden { display: none; }

#hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.hud-chip {
    background: rgba(0,0,0,0.85);
    border: 1px solid rgba(255,255,255,0.12);
    color: #ececec;
    padding: 7px 8px;
    border-radius: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

#objective-chip.alert {
    color: #fff1f1;
    border-color: rgba(255, 60, 60, 0.45);
    box-shadow: 0 0 0 1px rgba(255, 60, 60, 0.18);
}

#subtitle {
    align-self: center;
    width: min(92%, 410px);
    min-height: 44px;
    padding: 9px 12px;
    margin-bottom: 8px;
    border-radius: 0;
    background: rgba(0,0,0,0.88);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    letter-spacing: 0.03em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
}

#subtitle.show {
    opacity: 1;
    transform: translateY(0);
}

#ui-layer {
    z-index: 20;
    pointer-events: none;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.8);
    pointer-events: auto;
}

.panel {
    width: min(100%, 410px);
    padding: 18px 16px;
    border-radius: 0;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.94);
    color: var(--text);
    text-align: center;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset;
}

.eyebrow {
    color: #bdbdbd;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

h1, h2 {
    margin: 0 0 10px;
    line-height: 1.1;
    text-transform: uppercase;
}

h1 { font-size: 28px; }
h2 { font-size: 20px; }

p {
    margin: 0 0 10px;
    color: #d8d8d8;
    line-height: 1.45;
    font-size: 14px;
}

.small {
    color: #a6a6a6;
    font-size: 12px;
}

button {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.18);
    background: #101010;
    color: #fff;
    padding: 12px 14px;
    border-radius: 0;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 8px;
    width: 100%;
}

button:active {
    transform: translateY(1px);
    background: #181818;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    margin: 14px auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-1px, 1px); }
    100% { transform: translate(1px, -1px); }
}
