:root {
  --bg: #000; --fg: #b9e8bd; --dim: #5d7a60; --accent: #6dff8a; --bad: #ff5a5a; --paper: #d9d2bd; --ink: #1d1a14;
  --mono: "VT323", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--mono); font-size: 20px; overflow: hidden; cursor: default; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 0.8em; }
.warn, .bad { color: var(--bad); }
button { font-family: var(--mono); font-size: 1em; background: #071108; color: var(--fg); border: 1px solid #1f3a23; padding: 0.35em 0.9em; margin: 0.2em; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #10261320; border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; border-color: #142516; color: var(--dim); }
button.mini { padding: 0.15em 0.6em; font-size: 0.9em; }
kbd { font-family: var(--mono); color: var(--accent); margin-right: 0.3em; }
.row { display: flex; gap: 0.4em; flex-wrap: wrap; align-items: center; justify-content: center; }

.screen { position: fixed; inset: 0; }
.center { display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }
.panel { max-width: 640px; background: rgba(2, 8, 3, 0.92); border: 1px solid #142a17; padding: 1.6em 2em; text-align: left; }
.panel h2 { margin-top: 0; letter-spacing: 0.2em; font-weight: normal; }
.logo { font-size: 3.4em; letter-spacing: 0.35em; font-weight: normal; margin: 0 0 0.3em; color: #d6ffd8; text-shadow: 0 0 18px rgba(109, 255, 138, 0.35); animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .78; letter-spacing: .35em; } 45% { opacity: 1; letter-spacing: .4em; } }
.field { display: block; margin: 1em 0; color: var(--dim); }
.field input { display: block; width: 100%; margin-top: .3em; background: #000; border: 1px solid #1f3a23; color: var(--fg); font-family: var(--mono); font-size: 1.1em; padding: .3em .5em; }
.chk { display: block; margin: .45em 0; }
.chk input { accent-color: #3c8f4a; }

/* Menü */
#menu canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.menuBox { position: absolute; left: 7vw; bottom: 12vh; max-width: 560px; }
.menuBox button { display: block; margin: .4em 0; min-width: 280px; text-align: left; }

/* Intro / Traum */
.introNum { font-size: 1.4em; letter-spacing: .6em; color: var(--dim); }
.introTitle { font-size: 2.6em; letter-spacing: .25em; margin: .2em 0 1em; }
.hand { font-family: "Reenie Beanie", cursive; font-size: 1.8em; color: #c9b9a0; }
#dreamText { max-width: 700px; }
#dreamText p, #endText p { opacity: 0; transition: opacity 2.2s; font-size: 1.6em; margin: .7em 0; }
#dreamText p.in, #endText p.in { opacity: 1; }
.type { font-family: var(--mono); font-size: 1.6em; }
.big { font-size: 1.8em; line-height: 1.5; }

/* HUD */
#hud { display: flex; flex-direction: column; padding: 8px; gap: 8px; }
#top { display: flex; align-items: center; gap: 1em; padding: 0 6px; height: 34px; }
#nightLabel { color: var(--dim); letter-spacing: .15em; white-space: nowrap; }
#msg { flex: 1; text-align: center; transition: opacity 1.2s; opacity: 0; }
#msg.hint { color: #e5ffd0; }
#msg.bad { color: var(--bad); }
#clock { font-size: 1.6em; color: #d6ffd8; letter-spacing: .1em; }
#mainRow { flex: 1; display: flex; gap: 8px; min-height: 0; }
#mainView { position: relative; flex: 1; min-width: 0; background: #000; border: 1px solid #0f2412; display: flex; align-items: center; justify-content: center; }
#cam { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
#camInfo { position: absolute; left: 14px; bottom: 10px; color: var(--dim); font-size: .9em; }
#sub { position: absolute; left: 0; right: 0; bottom: 12%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#sub .line { background: rgba(0, 0, 0, .7); padding: .1em .7em; font-size: 1.15em; color: #e8ffe8; transition: opacity 1.1s; max-width: 80%; text-align: center; }
#sub .line.fade { opacity: 0; }
#sub .line.me { color: var(--dim); }
#sub .line.bad { color: var(--bad); }
#sub .line.twin { transform: translate(2px, -2px); opacity: .55; }
#sub .line.hallu { color: #9fb; background: transparent; letter-spacing: .3em; opacity: .5; }
#side { width: 250px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
#thumbs { display: flex; flex-direction: column; gap: 6px; }
.thumb { position: relative; border: 1px solid #0f2412; cursor: pointer; }
.thumb canvas { display: block; width: 100%; aspect-ratio: 16/10; }
.thumb.sel { border-color: var(--accent); box-shadow: 0 0 10px rgba(109, 255, 138, .25); }
.thumb.lost .coh { color: var(--bad); }
.tl { position: absolute; left: 4px; right: 4px; top: 2px; display: flex; justify-content: space-between; font-size: .72em; color: #bfe; text-shadow: 0 0 3px #000; }
#mirrorBox { display: flex; align-items: center; gap: 8px; }
#mirror { width: 90px; height: 68px; border: 2px solid #2a2a22; border-radius: 40% 40% 6px 6px; }
#bottomRow { display: flex; gap: 8px; height: 170px; }
#eeg { flex: 1; min-width: 0; height: 100%; border: 1px solid #0f2412; }
#controls { width: 780px; display: grid; grid-template-columns: 1fr 1fr 1.1fr; gap: 0 8px; overflow: hidden; }
.grp { display: flex; flex-direction: column; }
.grp button { text-align: left; margin: 2px 0; padding: .1em .6em; font-size: .95em; position: relative; }
.gl { font-size: .75em; color: var(--dim); letter-spacing: .2em; }
button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: var(--bad); color: #000; font-size: .7em; padding: 0 5px; }
#protoList { list-style: none; margin: 0; padding: .2em .6em; font-family: 'Caveat', cursive; font-size: .95em; background: #d9d2bd; color: #1d1a14; overflow: hidden; line-height: 1.15; }
#protoList b { font-family: var(--mono); font-weight: normal; color: #5a5040; font-size: .8em; }
#protoList li.bad { color: #7a1a12; }
#tapePanel { position: absolute; left: 14px; top: 46px; max-width: 46%; background: rgba(0, 0, 0, .78); border: 1px solid #1f3a23; padding: .5em .8em; }
#tapePanel b { color: var(--dim); font-weight: normal; letter-spacing: .1em; }
#tapePanel p { margin: .3em 0; font-size: 1.1em; }
#hud.shake { animation: shake .15s linear infinite; }
@keyframes shake { 0% { transform: translate(0, 0); } 25% { transform: translate(3px, -2px); } 50% { transform: translate(-2px, 2px); } 75% { transform: translate(2px, 3px); } }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); }
#turn { z-index: 30; background: #000; }
#turn canvas { width: 100%; height: 100%; }
.bookWrap { display: flex; flex-direction: column; align-items: center; gap: .5em; max-height: 96vh; }
.page { width: min(620px, 92vw); max-height: 78vh; overflow-y: auto; background: var(--paper); color: var(--ink); padding: 1.6em 2em; box-shadow: 0 0 60px rgba(0, 0, 0, .9), inset 0 0 80px rgba(80, 60, 20, .35); }
.page.typed { font-family: "Special Elite", monospace; font-size: .82em; line-height: 1.55; }
.page.typed h3 { font-weight: normal; border-bottom: 1px solid #8a8070; padding-bottom: .4em; font-size: 1em; }
.page.hand { font-family: "Reenie Beanie", cursive; font-size: 1.6em; line-height: 1.15; color: #2a1d12; transform: rotate(-1.2deg); }
.page.hand .big { font-size: 1.5em; }
.page.copy { font-size: 1em; line-height: 1.2; color: #2a1d12; }
.page .small { font-size: .82em; color: #5a5040; }
#tapeList { list-style: none; padding: 0; }
#tapeList li { padding: .3em .2em; cursor: pointer; border-bottom: 1px solid #0f2412; }
#tapeList li:hover { color: #fff; }
.crashBox { background: #f0f0f0; color: #222; font-family: system-ui, sans-serif; font-size: 15px; padding: 1.4em 1.6em; max-width: 420px; box-shadow: 0 10px 40px #000; border-radius: 6px; }
.crashBox button { font-family: system-ui, sans-serif; background: #e3e3e3; color: #222; border: 1px solid #aaa; border-radius: 4px; font-size: 14px; }
#crash { background: rgba(0, 0, 0, .35); z-index: 40; }
#blackout { position: fixed; inset: 0; background: #000; z-index: 50; }
#pause { z-index: 45; }
#pause .panel button { display: block; width: 100%; text-align: left; }

/* Gang, Enden, Tod */
#walk canvas, #ending canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.walkUi { position: absolute; left: 50%; bottom: 8vh; transform: translateX(-50%); width: min(720px, 92vw); text-align: center; background: rgba(0, 0, 0, .65); padding: 1em; }
.walkUi p { font-size: 1.25em; }
#endText { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; pointer-events: none; }
#endText button { pointer-events: auto; margin-top: 2em; }
#endText .credit { font-size: 1.2em; margin: .25em 0; color: #b0c4b0; }
#endText .title { letter-spacing: .3em; color: #fff; }
#endText .type { font-size: 2em; color: #e8ffe8; }
#scare { position: absolute; inset: 0; width: 100%; height: 100%; }
#deadText { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#deadText h2 { font-size: 2.4em; letter-spacing: .25em; color: var(--bad); font-weight: normal; }

/* Epilepsie-Modus: keine Animationen */
body.epi * { animation: none !important; }

/* Kleine Bildschirme */
@media (max-width: 1100px) {
  html, body { font-size: 16px; overflow: auto; }
  #hud { position: relative; min-height: 100vh; }
  #mainRow { flex-direction: column; }
  #side { width: 100%; flex-direction: row; overflow-x: auto; }
  #thumbs { flex-direction: row; }
  .thumb { width: 150px; flex: none; }
  #bottomRow { flex-direction: column; height: auto; }
  #eeg { height: 120px; }
  #controls { width: 100%; }
  .menuBox { left: 16px; right: 16px; }
  .menuBox button { min-width: 0; width: 100%; }
}
