/* BACKROOMS: FIELD RESEARCH DIVISION — VHS camcorder UI */

:root {
  --hud: #e8e2c8;
  --hud-dim: rgba(232, 226, 200, 0.55);
  --hud-shadow: rgba(0, 0, 0, 0.85);
  --good: #9fe6a8;
  --bad: #ff6b5e;
  --warn: #ffd27a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "IBM Plex Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- post overlays ---------- */

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center,
    transparent 42%, rgba(0,0,0,0.42) 78%, rgba(0,0,0,0.78) 100%);
}

#scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.022) 0px, rgba(255,255,255,0.022) 1px,
    rgba(0,0,0,0.05) 2px, rgba(0,0,0,0.05) 3px);
  mix-blend-mode: overlay;
}

#flash {
  position: fixed; inset: 0; background: #fff;
  opacity: 0; pointer-events: none; z-index: 30;
}
#flash.go { animation: flashpop 0.45s ease-out; }
@keyframes flashpop {
  0% { opacity: 0.95; }
  12% { opacity: 0.55; }
  100% { opacity: 0; }
}

#damage {
  position: fixed; inset: 0; pointer-events: none; z-index: 28;
  background: radial-gradient(ellipse at center,
    transparent 30%, rgba(190, 20, 10, 0.55) 100%);
  opacity: 0;
}
#damage.go { animation: dmg 0.7s ease-out; }
@keyframes dmg {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#fade {
  position: fixed; inset: 0; background: #000;
  opacity: 1; pointer-events: none; z-index: 40;
}

/* ---------- HUD ---------- */

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

.hud-box {
  position: absolute;
  color: var(--hud);
  text-shadow: 1px 1px 0 var(--hud-shadow), 0 0 8px rgba(232,226,200,0.25);
  font-size: 14px;
  letter-spacing: 0.08em;
}

#hud-tl { top: 18px; left: 22px; }
#level-name { font-weight: 700; font-size: 16px; }
#objective { margin-top: 5px; color: var(--hud-dim); font-size: 12.5px; }

#hud-tr { top: 18px; right: 22px; text-align: right; }
#rec-row { color: var(--hud); }
#rec-dot {
  color: #ff4038; animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0.15; } }
#tape-label { margin-top: 5px; color: var(--hud-dim); font-size: 12.5px; }

/* film counter — bottom-center LCD, one shared body behind both digits */
#film-counter {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  z-index: 11; pointer-events: none;
  color: var(--hud-dim);
  font-size: 12px; letter-spacing: 0.22em;
}
#film-seg {
  display: flex; gap: 9px;
  background: rgba(4, 8, 6, 0.82);
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 3px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.65), 0 0 10px rgba(0, 0, 0, 0.4);
  padding: 5px 10px;
  transform: skewX(-6deg);
}
.seg-digit {
  position: relative;
  width: 22px; height: 40px;
}
.seg {
  position: absolute;
  background: rgba(159, 216, 230, 0.08);
  transition: background 0.06s, box-shadow 0.06s;
}
.seg.on {
  background: #bfe8f4;
  box-shadow: 0 0 7px rgba(159, 216, 230, 0.75);
}
.seg-a, .seg-g, .seg-d { left: 3px; width: 15px; height: 4px; border-radius: 1.5px; }
.seg-a { top: 3px; }
.seg-g { top: 17px; }
.seg-d { bottom: 3px; }
.seg-f, .seg-b { top: 5px; width: 4px; height: 13px; border-radius: 1.5px; }
.seg-e, .seg-c { bottom: 5px; width: 4px; height: 13px; border-radius: 1.5px; }
.seg-f { left: 3px; }
.seg-b { right: 3px; }
.seg-e { left: 3px; }
.seg-c { right: 3px; }
#film-counter.low #film-counter-text { color: var(--warn); }
#film-counter.low .seg.on { background: var(--warn); box-shadow: 0 0 6px rgba(255, 210, 122, 0.6); }
#film-counter.out #film-counter-text { color: #ff5544; animation: blink 0.5s steps(1) infinite; }

/* end-of-depth summary + album */
#summary-screen { background: rgba(3, 3, 2, 0.93); }
.summary-inner {
  width: min(760px, 94vw); max-height: 92vh;
  overflow-y: auto;
  text-align: center;
}
.sum-title {
  font-size: clamp(22px, 3.4vw, 34px);
  letter-spacing: 0.24em;
  color: #d8c887;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 22px;
}
.sum-grid {
  display: inline-block;
  text-align: left;
  margin-bottom: 24px;
}
.sum-row {
  display: flex; justify-content: space-between; gap: 40px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(232, 226, 200, 0.12);
  font-size: 13px; letter-spacing: 0.14em;
  color: var(--hud-dim);
}
.sum-row b { color: var(--hud); font-weight: 700; }
.album-head {
  display: flex; justify-content: space-between; align-items: baseline;
  width: min(560px, 90vw); margin: 8px auto 10px;
  font-size: 12px; letter-spacing: 0.2em;
  color: var(--hud-dim);
}
#summary-album {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  min-height: 240px;
}
.album-frame {
  position: relative;
  border: 1px solid rgba(232, 226, 200, 0.35);
  outline: 4px solid rgba(0, 0, 0, 0.6);
  background: #000;
}
#summary-photo {
  display: block;
  max-width: min(520px, 76vw);
  max-height: 46vh;
}
#summary-photo-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--hud);
  font-size: 12px; letter-spacing: 0.16em;
  text-align: left;
}
#summary-album.empty::before {
  content: 'NO PHOTOGRAPHS ON THIS TAPE';
  color: var(--hud-dim);
  font-size: 13px; letter-spacing: 0.18em;
  padding: 40px 0;
}
.album-btn {
  background: rgba(20, 18, 10, 0.6);
  border: 1px solid rgba(232, 226, 200, 0.4);
  color: var(--hud);
  font-size: 16px;
  width: 40px; height: 40px;
  cursor: pointer;
  font-family: inherit;
}
.album-btn:hover { background: rgba(232, 226, 200, 0.15); }
.sum-continue {
  margin-top: 24px;
  font-size: 13px; letter-spacing: 0.22em;
  color: var(--warn);
  animation: blink 1.6s steps(1) infinite;
}

/* doom notice */
#doom-msg {
  position: fixed; left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  z-index: 46; text-align: center;
  pointer-events: none;
  opacity: 0;
}
#doom-msg.on { animation: doomfade 6.5s ease-out forwards; }
@keyframes doomfade {
  0% { opacity: 0; }
  8% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
#doom-msg .doom-main {
  font-size: clamp(28px, 4.5vw, 52px);
  letter-spacing: 0.28em;
  font-weight: 800;
  color: #c8382c;
  text-shadow: 0 0 24px rgba(200, 40, 30, 0.5), 3px 3px 0 #000;
}
#doom-msg .doom-sub {
  margin-top: 14px;
  font-size: 14px;
  letter-spacing: 0.22em;
  color: var(--hud-dim);
}

#minimap {
  position: absolute;
  top: 74px; right: 22px;
  width: 150px; height: 150px;
  opacity: 0.85;
  border: 1px solid rgba(232,226,200,0.35);
  outline: 3px solid rgba(0,0,0,0.35);
}

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(240,235,210,0.9);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0,0,0,0.9), inset 0 0 4px rgba(0,0,0,0.7);
}

#prompt {
  position: absolute; left: 50%; top: 57%;
  transform: translateX(-50%);
  color: var(--hud);
  text-shadow: 1px 1px 0 var(--hud-shadow);
  font-size: 15px; letter-spacing: 0.1em;
  opacity: 0; transition: opacity 0.15s;
  background: rgba(8,8,5,0.55);
  padding: 6px 14px;
  border: 1px solid rgba(232,226,200,0.25);
}
#prompt.on { opacity: 1; }

#msglog {
  position: absolute;
  bottom: 92px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse;
  align-items: center; gap: 4px;
  width: 80%; text-align: center;
}
.msg {
  color: var(--hud);
  text-shadow: 1px 1px 0 var(--hud-shadow);
  font-size: 14px; letter-spacing: 0.08em;
  background: rgba(8,8,5,0.45);
  padding: 3px 10px;
  transition: opacity 0.8s;
}
.msg.gone { opacity: 0; }
.msg.good { color: var(--good); }
.msg.bad { color: var(--bad); }
.msg.warn { color: var(--warn); }

#hud-bl { bottom: 18px; left: 22px; }
#health-label { font-size: 11.5px; color: var(--hud-dim); margin-bottom: 4px; }
#health-bar {
  width: 190px; height: 10px;
  border: 1px solid rgba(232,226,200,0.5);
  background: rgba(0,0,0,0.5);
}
#health-fill {
  height: 100%; width: 100%;
  background: var(--hud);
  transition: width 0.3s;
}
#health-fill.low { background: #ff5544; animation: blink 0.8s steps(1) infinite; }

#stamina-bar {
  width: 190px; height: 6px;
  margin-top: 4px;
  border: 1px solid rgba(232,226,200,0.35);
  background: rgba(0,0,0,0.5);
}
#stamina-fill {
  height: 100%; width: 100%;
  background: var(--hud);
  transition: width 0.3s;
}
#stamina-fill.active { background: #9fd8e6; }
#stamina-fill.low { background: #ff5544; animation: blink 0.8s steps(1) infinite; }

.corner {
  position: absolute; width: 26px; height: 26px;
  border: 2px solid rgba(232,226,200,0.4);
}
.corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

/* ---------- screens ---------- */

.screen {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  background: rgba(2, 2, 1, 0.88);
  color: var(--hud);
}
.screen.on { display: flex; align-items: center; justify-content: center; }

.title-inner, .death-inner, .pause-inner, .journal-inner { text-align: center; }

.title-pre {
  font-size: 13px; letter-spacing: 0.3em; color: var(--hud-dim);
  margin-bottom: 18px;
}
.title-inner h1 {
  font-size: clamp(48px, 9vw, 110px);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  font-weight: 800;
  color: #d8c887;
  text-shadow: 0 0 30px rgba(216, 200, 135, 0.35), 3px 3px 0 #000;
}
.title-sub {
  margin-top: 14px;
  font-size: 13.5px; line-height: 1.7;
  color: var(--hud-dim);
}
.title-goal {
  margin: 26px auto 0;
  font-size: 14px; line-height: 1.9; letter-spacing: 0.08em;
  color: var(--warn);
  border-top: 1px solid rgba(232,226,200,0.2);
  border-bottom: 1px solid rgba(232,226,200,0.2);
  padding: 14px 26px;
}
.title-controls {
  margin-top: 24px;
  display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-size: 13px; color: var(--hud-dim);
}
.title-controls b { color: var(--hud); }
.title-start {
  margin-top: 34px;
  font-size: 18px; letter-spacing: 0.25em;
  color: #fff;
  animation: blink 1.6s steps(1) infinite;
  cursor: pointer;
}
.title-warn { margin-top: 20px; font-size: 11px; letter-spacing: 0.2em; color: rgba(232,226,200,0.35); }

/* level card */
#level-card {
  position: fixed; left: 50%; top: 26%;
  transform: translate(-50%, 0);
  z-index: 45; text-align: center;
  color: var(--hud);
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s;
}
#level-card.on { opacity: 1; }
#card-level { font-size: 14px; letter-spacing: 0.4em; color: var(--hud-dim); }
#card-name {
  font-size: 44px; letter-spacing: 0.2em; font-weight: 800;
  color: #d8c887; text-shadow: 3px 3px 0 #000;
  margin: 8px 0 10px;
}
#card-sub { font-size: 13px; letter-spacing: 0.15em; color: var(--warn); }

/* journal */
#journal { background: rgba(4, 4, 2, 0.92); }
.journal-inner {
  width: min(680px, 92vw); max-height: 82vh;
  display: flex; flex-direction: column;
  text-align: left;
}
.j-head-row {
  display: flex; justify-content: space-between;
  letter-spacing: 0.2em; font-size: 14px;
  border-bottom: 1px solid rgba(232,226,200,0.3);
  padding-bottom: 10px; margin-bottom: 14px;
  color: #d8c887;
}
.j-close { color: var(--hud-dim); }
#journal-list { overflow-y: auto; padding-right: 8px; }
.j-empty { color: var(--hud-dim); letter-spacing: 0.1em; font-size: 13px; padding: 30px 0; text-align: center; }
.j-entry {
  border: 1px solid rgba(232,226,200,0.18);
  background: rgba(20, 18, 10, 0.5);
  padding: 12px 16px; margin-bottom: 10px;
}
.j-head { display: flex; gap: 14px; align-items: baseline; }
.j-kind { font-size: 11px; letter-spacing: 0.15em; color: var(--hud-dim); }
.j-kind { color: var(--warn); }
.j-entry.photo .j-kind { color: #9fc8ff; }
.j-name { font-weight: 700; letter-spacing: 0.08em; }
.j-level { margin-left: auto; color: var(--hud-dim); font-size: 12px; }
.j-text {
  margin-top: 8px; font-size: 13px; line-height: 1.65;
  color: rgba(232,226,200,0.8);
}

/* division archive */
#archive-screen { background: rgba(4, 4, 2, 0.92); }
.archive-inner { width: min(760px, 94vw); }
.archive-scroll { overflow-y: auto; padding-right: 8px; }
.arch-section {
  margin: 18px 0 10px;
  font-size: 12px; letter-spacing: 0.3em;
  color: var(--hud-dim);
  border-bottom: 1px solid rgba(232,226,200,0.2);
  padding-bottom: 6px;
}
.arch-section:first-child { margin-top: 0; }
.arch-entry {
  border: 1px solid rgba(232,226,200,0.18);
  background: rgba(20, 18, 10, 0.5);
  padding: 12px 16px; margin-bottom: 10px;
}
.arch-entry.photo .j-kind { color: #9fc8ff; }
.arch-cat-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 6px;
  font-size: 13px; letter-spacing: 0.08em;
  border-left: 2px solid rgba(232,226,200,0.35);
}
.arch-cat-row.missing {
  color: rgba(232,226,200,0.28);
  border-left-color: rgba(232,226,200,0.1);
}
.arch-badge { font-size: 11px; color: var(--warn); width: 16px; }
.arch-badge.photo { color: #9fc8ff; }
.arch-cat-name { flex: 1; }
.arch-cat-state { font-size: 10.5px; letter-spacing: 0.2em; color: var(--good); }
.arch-cat-row.missing .arch-cat-state { color: rgba(232,226,200,0.22); }

.perk-row {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid rgba(232,226,200,0.18);
  background: rgba(20, 18, 10, 0.5);
  padding: 12px 16px; margin-bottom: 10px;
}
.perk-info { flex: 1; }
.perk-name {
  font-weight: 700; letter-spacing: 0.12em;
  display: flex; align-items: center; gap: 10px;
}
.perk-pips { display: inline-flex; gap: 5px; }
.perk-pip {
  width: 9px; height: 9px;
  border: 1px solid rgba(232,226,200,0.45);
  background: transparent;
}
.perk-pip.on { background: #d8c887; border-color: #d8c887; }
.perk-desc { margin-top: 5px; font-size: 11.5px; color: var(--hud-dim); letter-spacing: 0.06em; }
.perk-cost { font-size: 12px; letter-spacing: 0.15em; color: var(--warn); white-space: nowrap; }
.perk-buy {
  font: inherit; font-size: 11.5px; letter-spacing: 0.15em;
  color: var(--hud); cursor: pointer;
  background: transparent;
  border: 1px solid rgba(232,226,200,0.5);
  padding: 6px 12px; white-space: nowrap;
}
.perk-buy:hover:not(:disabled) { background: rgba(232,226,200,0.14); }
.perk-buy:disabled {
  opacity: 0.3; cursor: default; text-decoration: line-through;
}

/* pause */
.pause-title { font-size: 34px; letter-spacing: 0.25em; }
.pause-sub { margin-top: 14px; color: var(--hud-dim); letter-spacing: 0.15em; font-size: 13px; }

/* death */
.death-title {
  font-size: clamp(40px, 7vw, 72px);
  letter-spacing: 0.3em;
  color: #ff5544;
  text-shadow: 3px 3px 0 #000, 0 0 40px rgba(255, 60, 40, 0.4);
  animation: dmgpulse 2.4s ease-in-out infinite;
}
@keyframes dmgpulse { 50% { opacity: 0.75; } }
.death-sub { margin-top: 12px; color: var(--hud-dim); letter-spacing: 0.2em; font-size: 13px; }
#death-cause {
  margin-top: 22px; font-size: 18px; letter-spacing: 0.15em;
  color: var(--bad);
}
#death-stats {
  margin-top: 20px; display: inline-block;
  font-size: 14px; line-height: 2.1; letter-spacing: 0.1em;
  color: var(--hud);
  text-align: left;
}
#death-stats b { color: #d8c887; }
.death-best { margin-top: 10px; color: var(--hud-dim); font-size: 12px; }
.death-restart {
  margin-top: 30px; font-size: 17px; letter-spacing: 0.25em;
  animation: blink 1.6s steps(1) infinite;
}
