@font-face { font-family: 'VT323'; src: url(../assets/fonts/VT323-400.woff2) format('woff2'); }
@font-face { font-family: 'Plex'; font-weight: 400; src: url(../assets/fonts/IBMPlexMono-400.woff2) format('woff2'); }
@font-face { font-family: 'Plex'; font-weight: 600; src: url(../assets/fonts/IBMPlexMono-600.woff2) format('woff2'); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: #e9e4d4; font-family: 'Plex', ui-monospace, monospace; user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255,255,255,.55); transition: transform .15s, background .15s; }
#crosshair.active { transform: scale(2.4); background: rgba(255,255,255,.9); }
#prompt { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); font: 22px 'VT323', monospace; letter-spacing: 2px; color: #fff; text-shadow: 0 0 8px #000, 0 0 2px #000; white-space: nowrap; }
#holdring { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; opacity: 0; transition: opacity .2s; }
#holdring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#holdring circle { fill: none; stroke: #fff; stroke-width: 2.5; stroke-dasharray: 100.5; stroke-dashoffset: 100.5; filter: drop-shadow(0 0 3px #000); }
#objective { position: absolute; left: 34px; top: 30px; max-width: 460px; text-shadow: 0 0 6px #000; }
#objective .lvl { font: 18px 'VT323'; letter-spacing: 3px; opacity: .7; }
#objective .txt { font: 600 15px 'Plex'; margin-top: 4px; line-height: 1.45; }
#meters { position: absolute; left: 34px; bottom: 34px; display: flex; flex-direction: column; gap: 8px; }
.meter { width: 170px; height: 5px; background: rgba(255,255,255,.12); position: relative; transition: opacity .6s; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: rgba(255,255,255,.75); }
#battery span { position: absolute; left: 0; top: -17px; font: 14px 'VT323'; letter-spacing: 2px; opacity: .7; }
#battery.low i { background: #ff5a4a; }
#rec { position: absolute; right: 34px; top: 30px; font: 22px 'VT323'; letter-spacing: 3px; text-shadow: 0 0 6px #000; }
#rec b { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #e33; margin-right: 6px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#subtitle { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%); max-width: 70%; text-align: center; font: 20px 'Plex'; color: #fff; text-shadow: 0 0 8px #000, 0 0 3px #000; opacity: 0; transition: opacity .6s; }
#subtitle.show { opacity: 1; }
#toast { position: absolute; right: 34px; bottom: 34px; font: 20px 'VT323'; letter-spacing: 2px; text-align: right; opacity: 0; transition: opacity .5s; text-shadow: 0 0 6px #000; }
#toast.show { opacity: 1; }

/* ---------- reader ---------- */
#reader { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
#reader .paper { background: #ece6d3; color: #2a2620; width: min(560px, 86vw); padding: 38px 42px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.8); transform: rotate(-1deg); font: 17px/1.6 'Plex'; position: relative; }
#reader .paper::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(transparent 0 27px, rgba(70,90,140,.13) 27px 28px); pointer-events: none; }
#reader .paper.photo { background: #f4f1ea; padding: 18px 18px 60px; width: min(460px, 80vw); transform: rotate(1.5deg); }
#reader .paper.photo::before { display: none; }
#reader .paper.photo img { width: 100%; display: block; filter: sepia(.25) contrast(1.05); }
#reader .paper.photo .cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font: 22px 'VT323'; color: #333; }
#reader .hint { margin-top: 20px; font: 15px 'VT323'; letter-spacing: 2px; opacity: .55; text-align: right; }
#reader .paper.photo .hint { position: absolute; right: 16px; bottom: -34px; color: #ddd; }

/* ---------- card ---------- */
#card { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-shadow: 0 0 20px #000; animation: cardIn 5.5s forwards; }
#card .n { font: 24px 'VT323'; letter-spacing: 10px; opacity: .7; }
#card .t { font: 600 54px 'Plex'; letter-spacing: 12px; margin: 6px 0; }
#card .s { font: 16px 'Plex'; opacity: .75; max-width: 600px; text-align: center; }
@keyframes cardIn { 0% { opacity: 0; filter: blur(8px); } 15% { opacity: 1; filter: blur(0); } 75% { opacity: 1; } 100% { opacity: 0; } }

#fade { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; transition: opacity 1.2s ease; }
#fade.white { background: #fff; }

/* ---------- menus ---------- */
.screen { position: fixed; inset: 0; }
#menu { background: #000; }
#menu .keyart { position: absolute; inset: -4%; background: url(../assets/img/keyart.webp) center/cover; filter: saturate(.85) brightness(.75); animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02) translate(0,0); } to { transform: scale(1.1) translate(-2%, -1%); } }
#menu .vhs { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,.85) 100%); pointer-events: none; }
.menu-inner { position: absolute; left: 8vw; top: 50%; transform: translateY(-50%); }
.logo { font: 600 clamp(48px, 7vw, 92px) 'Plex'; letter-spacing: .32em; margin: 0; color: #f3efe2; text-shadow: 0 0 30px rgba(120,255,230,.25), 2px 0 rgba(255,0,60,.35), -2px 0 rgba(0,200,255,.35); animation: jitter 6s infinite; }
@keyframes jitter { 0%, 96%, 100% { transform: none; } 97% { transform: translateX(3px) skewX(4deg); } 98% { transform: translateX(-4px); } }
.tag { font: 20px 'VT323'; letter-spacing: 6px; opacity: .75; margin: 4px 0 40px 4px; }
nav { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
nav button, .back, #levelList button { background: none; border: 0; color: #e9e4d4; font: 28px 'VT323'; letter-spacing: 4px; cursor: pointer; padding: 4px 0; opacity: .78; transition: all .15s; text-align: left; }
nav button:hover, .back:hover, #levelList button:hover:not(:disabled) { opacity: 1; padding-left: 14px; color: #fff; text-shadow: 0 0 12px rgba(160,255,240,.6); }
nav button:disabled { opacity: .25; cursor: default; }
.foot { margin-top: 48px; font: 12px 'Plex'; opacity: .45; max-width: 560px; }
.panel-screen { background: rgba(0,0,0,.78); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.panel { width: min(620px, 90vw); }
.panel h2 { font: 600 30px 'Plex'; letter-spacing: 8px; margin: 0 0 26px; }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 14px 0; font-size: 15px; }
.panel label.chk { justify-content: flex-start; }
.panel select, .panel input[type=range] { width: 300px; accent-color: #9ff; }
.panel select { background: #111; color: #eee; border: 1px solid #444; padding: 6px; font: 13px 'Plex'; }
.panel .back { margin-top: 26px; }
.keys { width: 100%; border-collapse: collapse; font-size: 16px; }
.keys td { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.keys td:first-child { font: 22px 'VT323'; letter-spacing: 2px; width: 40%; color: #aff; }
#levelList button { display: block; width: 100%; font-size: 26px; }
#levelList button small { font: 13px 'Plex'; letter-spacing: 0; opacity: .6; margin-left: 12px; }
#levelList button:disabled { opacity: .2; cursor: default; }

#death { background: radial-gradient(ellipse, rgba(60,0,0,.55), rgba(0,0,0,.95)); display: flex; align-items: center; justify-content: center; animation: dIn 1.2s; }
@keyframes dIn { from { opacity: 0; } }
.death-inner { text-align: center; }
.death-inner nav { align-items: center; margin-top: 30px; }
.d1 { font: 64px 'VT323'; letter-spacing: 16px; color: #ff4b3e; text-shadow: 0 0 24px rgba(255,0,0,.6); }
.d2 { font: 18px 'Plex'; opacity: .8; }

#ending { background: #fff; color: #333; display: flex; align-items: center; justify-content: center; animation: eIn 4s; }
@keyframes eIn { from { background: #fff; color: transparent; } }
.end-inner { text-align: center; max-width: 720px; }
.e1 { font: 600 46px 'Plex'; letter-spacing: 6px; }
.e2 { font: 17px 'Plex'; margin: 14px 0 30px; opacity: .7; }
.e3 { font: 22px 'VT323'; letter-spacing: 3px; margin-bottom: 30px; }
.credits p { font-size: 12px; opacity: .6; margin: 4px; }
#ending nav { align-items: center; margin-top: 30px; }
#ending nav button { color: #333; }

#loading { background: #000; display: flex; align-items: center; justify-content: center; }
.load-inner { width: 340px; text-align: center; }
.lt { font: 24px 'VT323'; letter-spacing: 12px; opacity: .7; }
.bar { height: 2px; background: #222; margin: 14px 0; }
.bar i { display: block; height: 100%; width: 0; background: #cfc; transition: width .2s; }
#loadTxt { font: 12px 'Plex'; opacity: .5; }

#clickToPlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); font: 28px 'VT323'; letter-spacing: 6px; cursor: pointer; }
#fatal { position: fixed; inset: 0; background: #000; color: #f88; padding: 40px; font: 14px 'Plex'; white-space: pre-wrap; z-index: 99; overflow: auto; }

#grain { position: fixed; inset: -50%; pointer-events: none; opacity: .0; }
