/* Self-hosted fonts (latin subsets) — licences in assets/fonts/ */
@font-face { font-family: 'Anton'; font-style: normal; font-weight: 400; font-display: swap; src: url(../assets/fonts/anton.woff2) format('woff2'); }
@font-face { font-family: 'Oswald'; font-style: normal; font-weight: 200 700; font-display: swap; src: url(../assets/fonts/oswald.woff2) format('woff2'); }
@font-face { font-family: 'Special Elite'; font-style: normal; font-weight: 400; font-display: swap; src: url(../assets/fonts/special-elite.woff2) format('woff2'); }
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: swap; src: url(../assets/fonts/vt323.woff2) format('woff2'); }

:root {
  --ink: #e9e2cf;
  --ink-dim: #a9a18c;
  --blood: #9e1b14;
  --blood-hi: #d8321f;
  --paper: #e8dfc6;
  --paper-ink: #2b2a26;
  --panel: rgba(12, 12, 11, 0.86);
  --edge: #5a5246;
  --amber: #e2a647;
  --display: 'Anton', Impact, 'Arial Narrow Bold', sans-serif;
  --body: 'Oswald', 'Arial Narrow', Arial, sans-serif;
  --type: 'Special Elite', 'Courier New', Courier, monospace;
  --term: 'VT323', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #050505;
  color: var(--ink);
  overflow: hidden;
  font-family: var(--body);
  -webkit-user-select: none;
  user-select: none;
}

#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #0b0b0b; }
#game.nocursor { cursor: none; }
#game.grey { filter: grayscale(1) contrast(1.1) brightness(0.8); transition: filter 2.5s ease; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ---------- shared ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadein .5s ease both;
}
.screen.out { animation: fadeout .5s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; } }

.grain::after {
  content: ''; position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: .09; pointer-events: none;
  animation: grain .6s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } 100% { transform: translate(1%, 3%); }
}
.scan::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
}
.vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.75) 100%); }

.btn {
  font-family: var(--display); letter-spacing: .08em; font-size: 20px;
  color: var(--ink); background: transparent; border: 1px solid var(--edge);
  padding: 8px 22px; cursor: pointer; text-transform: uppercase;
}
.btn:hover, .btn.sel { background: var(--blood); border-color: var(--blood-hi); color: #fff; }

.hint { font-family: var(--body); font-size: 13px; letter-spacing: .2em; color: var(--ink-dim); text-transform: uppercase; }
.blink { animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- boot ---------- */
.boot { background: #000; cursor: pointer; }
.boot .b-title { font-family: var(--display); font-size: 22px; letter-spacing: .5em; color: #6d675a; margin-bottom: 26px; }
.boot .b-go { font-family: var(--type); font-size: 20px; color: var(--ink); }
.boot .b-sub { margin-top: 40px; font-size: 12px; letter-spacing: .25em; color: #5e584c; text-transform: uppercase; text-align: center; line-height: 2; }

/* ---------- emergency broadcast cold open ---------- */
.ebs { background: #000; overflow: hidden; }
.ebs .bars { position: absolute; inset: 0 0 32% 0; display: flex; filter: saturate(.75) brightness(.8); }
.ebs .bars i { flex: 1; }
.ebs .bars2 { position: absolute; left: 0; right: 0; top: 68%; height: 8%; display: flex; }
.ebs .bars2 i { flex: 1; }
.ebs .low { position: absolute; left: 0; right: 0; top: 76%; bottom: 0; background: #0b0b0b; }
.ebs .box {
  position: relative; z-index: 2; background: rgba(0,0,0,.88); border: 3px solid #ddd;
  padding: 26px 46px; text-align: center; font-family: var(--term); color: #eee;
  box-shadow: 0 0 60px rgba(0,0,0,.8);
}
.ebs .box h1 { font-size: 46px; margin: 0; letter-spacing: .06em; font-weight: normal; }
.ebs .box h2 { font-size: 28px; margin: 8px 0 0; font-weight: normal; color: #f3c14b; }
.ebs .crawl-wrap { position: absolute; left: 0; right: 0; bottom: 7%; z-index: 2; overflow: hidden; height: 44px; background: #000; border-top: 2px solid #b10f0f; border-bottom: 2px solid #b10f0f; }
.ebs .crawl { position: absolute; white-space: nowrap; font-family: var(--term); font-size: 34px; line-height: 44px; color: #fff; will-change: transform; }
.ebs .skip { position: absolute; right: 22px; top: 16px; z-index: 3; }
.ebs .jitter { animation: jitter .18s steps(2) infinite; }
@keyframes jitter { 0% { transform: translate(0,0); } 50% { transform: translate(1px,-1px); } 100% { transform: translate(-1px,1px); } }

/* ---------- title ---------- */
.title { align-items: flex-start; justify-content: flex-end; padding: 0 0 7vh 7vw;
  background: linear-gradient(90deg, rgba(0,0,0,.78) 0%, rgba(0,0,0,.35) 38%, transparent 62%); }
.title .logo { position: absolute; left: 6vw; top: 9vh; width: min(760px, 62vw); filter: drop-shadow(0 8px 18px rgba(0,0,0,.8)); }
.title .logo.slam { animation: slam .9s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes slam { 0% { transform: scale(1.6); opacity: 0; filter: blur(8px); } 60% { opacity: 1; filter: blur(0) drop-shadow(0 8px 18px rgba(0,0,0,.8)); } 100% { transform: scale(1); } }
.title .tag { position: absolute; left: calc(6vw + 8px); top: calc(9vh + min(760px, 62vw) * .31); font-family: var(--type); font-size: clamp(14px, 1.4vw, 20px); color: var(--ink-dim); letter-spacing: .12em; }
.menu { display: flex; flex-direction: column; gap: 2px; position: relative; z-index: 2; }
.menu .mi {
  font-family: var(--display); font-size: clamp(22px, 2.6vw, 34px); letter-spacing: .06em; text-transform: uppercase;
  color: #b9b09a; padding: 2px 0 2px 34px; position: relative; cursor: pointer; transition: color .12s, transform .12s;
}
.menu .mi.dis { color: #4f4a40; cursor: default; }
.menu .mi.sel { color: #fff; transform: translateX(6px); }
.menu .mi.sel::before {
  content: ''; position: absolute; left: 4px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  background: var(--blood-hi); border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 0 12px rgba(216,50,31,.7);
}
.menu .mi small { display: block; font-family: var(--body); font-size: 13px; letter-spacing: .15em; color: var(--ink-dim); margin-top: -4px; text-transform: none; }
.title .foot { position: absolute; right: 22px; bottom: 16px; font-size: 12px; letter-spacing: .2em; color: #6e685b; text-transform: uppercase; text-align: right; line-height: 1.8; }

/* ---------- panels (options / controls / credits / pause) ---------- */
.dim { background: rgba(0,0,0,.72); }
.panel {
  background: var(--panel); border: 1px solid var(--edge); padding: 28px 36px; min-width: 460px; max-width: 820px;
  box-shadow: 0 20px 80px rgba(0,0,0,.8); position: relative;
}
.panel h2 { font-family: var(--display); font-weight: normal; font-size: 34px; letter-spacing: .08em; margin: 0 0 18px; text-transform: uppercase; }
.panel h2 span { color: var(--blood-hi); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 17px; }
.row input[type=range] { width: 220px; accent-color: var(--blood-hi); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; font-size: 16px; }
.keys kbd { font-family: var(--term); font-size: 20px; background: #2a2723; border: 1px solid #4b463d; border-bottom-width: 3px; padding: 0 8px; border-radius: 3px; color: #f1e6c9; white-space: nowrap; }
.panel .actions { display: flex; gap: 12px; margin-top: 22px; justify-content: flex-end; }
.credits { font-family: var(--type); font-size: 16px; line-height: 1.7; color: var(--ink); max-width: 640px; }
.credits b { font-family: var(--display); font-weight: normal; letter-spacing: .1em; color: var(--amber); }

/* ---------- difficulty ---------- */
.skill .mi { font-size: 28px; }

/* ---------- level card ---------- */
.card { background: #000; }
.card .day { font-family: var(--type); font-size: 20px; letter-spacing: .3em; color: var(--ink-dim); }
.card .name { font-family: var(--display); font-size: clamp(48px, 7vw, 96px); letter-spacing: .06em; text-transform: uppercase; margin: 10px 0 4px; color: #efe6cf; text-shadow: 0 0 30px rgba(158,27,20,.35); }
.card .place { font-family: var(--body); font-size: 16px; letter-spacing: .4em; text-transform: uppercase; color: #b3a98f; }
.card .map-id { position: absolute; bottom: 30px; font-family: var(--term); font-size: 22px; color: #6d675a; letter-spacing: .2em; }
.card .line { width: 0; height: 2px; background: var(--blood); margin: 18px 0; animation: grow 1.4s .2s ease forwards; }
@keyframes grow { to { width: 320px; } }

/* ---------- paper (notes / diary) ---------- */
.paper {
  background:
    radial-gradient(circle at 80% 18%, rgba(120,80,30,.16) 0 34px, rgba(120,80,30,.06) 36px, transparent 40px),
    repeating-linear-gradient(to bottom, transparent 0 29px, rgba(70,110,160,.22) 29px 30px),
    linear-gradient(135deg, #efe7cf, #ddd1b0);
  color: var(--paper-ink); font-family: var(--type); box-shadow: 0 18px 60px rgba(0,0,0,.7), inset 0 0 60px rgba(120,90,40,.25);
  position: relative;
}
.paper::before { content: ''; position: absolute; left: 54px; top: 0; bottom: 0; width: 1px; background: rgba(190,60,60,.35); }
.note .paper { width: min(620px, 90vw); max-height: 82vh; overflow: auto; padding: 44px 50px 40px 76px; transform: rotate(-.6deg); }
.note .paper h3 { margin: 0 0 16px; font-weight: normal; font-size: 22px; line-height: 30px; text-decoration: underline; text-decoration-thickness: 1px; }
.note .paper p { margin: 0 0 30px; font-size: 17px; line-height: 30px; white-space: pre-wrap; }
.note .paper .sig { text-align: right; font-style: italic; }
.note .paper.clip { background: linear-gradient(#f4f1e8, #e6e1d2); }
.note .paper.clip::before { display: none; }
.note .paper.type { font-family: var(--term); background: linear-gradient(#e9eef0, #d5dbd9); }
.note .paper.type p { font-size: 21px; }
.note .tape { position: absolute; top: -12px; left: 45%; width: 110px; height: 30px; background: rgba(230,220,170,.55); transform: rotate(3deg); }
.note .close { margin-top: 18px; }

/* ---------- intermission ---------- */
.inter { background: radial-gradient(ellipse at center, #1c1a17 0%, #070707 100%); gap: 0; }
.inter .sheet { display: flex; gap: 0; align-items: stretch; transform: rotate(-.4deg); }
.inter .paper { width: min(440px, 44vw); padding: 36px 34px 30px 78px; }
.inter .paper h3 { font-weight: normal; margin: 0; font-size: 15px; letter-spacing: .25em; color: #6b5f4a; }
.inter .paper h1 { font-family: var(--display); font-weight: normal; font-size: 40px; margin: 2px 0 24px; letter-spacing: .04em; color: #2d2a23; }
.inter .stat { display: flex; justify-content: space-between; font-size: 24px; line-height: 50px; border-bottom: 1px dashed rgba(0,0,0,.18); }
.inter .stat b { font-family: var(--display); font-weight: normal; font-size: 30px; color: #7d1510; min-width: 110px; text-align: right; }
.inter .mapbox { background: #d9ceb0; padding: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.7); position: relative; }
.inter .mapbox canvas { display: block; width: min(460px, 44vw); height: auto; }
.inter .foot { margin-top: 26px; }

/* ---------- story ---------- */
.story { background: #080807; }
.story .page { width: min(760px, 88vw); font-family: var(--type); font-size: clamp(16px, 1.45vw, 21px); line-height: 1.75; color: #ddd4bd; white-space: pre-wrap; min-height: 50vh; }
.story .page .cur { display: inline-block; width: .6em; height: 1.1em; background: #ddd4bd; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
.story .head { font-family: var(--display); letter-spacing: .3em; color: var(--blood-hi); font-size: 18px; margin-bottom: 26px; width: min(760px, 88vw); }

/* ---------- death ---------- */
.death { background: radial-gradient(ellipse at center, rgba(40,0,0,.15), rgba(0,0,0,.85)); }
.death h1 { font-family: var(--type); font-weight: normal; font-size: clamp(34px, 5vw, 64px); margin: 0; color: #f1e8d1; letter-spacing: .04em; text-shadow: 0 4px 30px #000; }
.death .by { font-family: var(--type); font-size: 20px; color: #c9bfa6; margin: 18px 0 6px; }
.death .time { font-family: var(--body); font-size: 15px; letter-spacing: .3em; color: #8d8574; text-transform: uppercase; }
.death .actions { display: flex; gap: 14px; margin-top: 44px; }

/* ---------- ending ---------- */
.ending { background: #000; }
.ending .page { width: min(760px, 88vw); font-family: var(--type); font-size: clamp(16px, 1.45vw, 21px); line-height: 1.8; color: #e2dac5; white-space: pre-wrap; }
.ending .big { font-family: var(--display); font-size: clamp(40px, 6vw, 80px); letter-spacing: .08em; color: #efe6cf; margin-bottom: 22px; }
.roll { position: absolute; left: 0; right: 0; top: 100%; text-align: center; font-family: var(--type); color: #cfc6ae; line-height: 2.1; font-size: 18px; }
.roll h4 { font-family: var(--display); font-weight: normal; letter-spacing: .3em; color: var(--amber); margin: 38px 0 4px; font-size: 20px; }

/* ---------- loading ---------- */
.loading { background: #000; font-family: var(--term); font-size: 24px; color: #8b8474; }

@media (max-width: 700px) {
  .panel { min-width: 0; width: 92vw; padding: 20px; }
  .inter .sheet { flex-direction: column; }
  .inter .paper, .inter .mapbox canvas { width: 88vw; }
}
