:root {
  --ink: #1b1814;
  --paper: #e8dec6;
  --paper-dim: #b9ad92;
  --blue: #34548c;
  --blue-soft: #6f8bbd;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --type: "American Typewriter", "Courier Prime", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--paper); overflow: hidden;
  font-family: var(--serif); -webkit-font-smoothing: antialiased; }
button { font: inherit; }
.hidden { display: none !important; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; image-rendering: crisp-edges;
  cursor: grab; touch-action: none; }
#gl.drag { cursor: grabbing; }
#gl.point { cursor: pointer; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#crumb { position: absolute; left: 20px; top: 16px; font: 13px/1.3 var(--type); letter-spacing: .08em; color: var(--paper-dim); text-shadow: 0 1px 2px #000; }
#hint { position: absolute; left: 50%; bottom: 7vh; transform: translateX(-50%); padding: 8px 16px;
  font: 15px/1.3 var(--type); color: var(--paper); background: rgba(10, 8, 6, .62); border: 1px solid rgba(232, 222, 198, .18);
  opacity: 0; transition: opacity .25s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#hint.on { opacity: 1; }
#symbols { position: absolute; right: 18px; top: 14px; display: flex; gap: 6px; }
#symbols svg { width: 30px; height: 30px; stroke: var(--paper); stroke-width: 2.2; fill: none; opacity: .9;
  filter: drop-shadow(0 1px 2px #000); }
#symbols svg.todo { opacity: .18; }

#touch { position: fixed; right: 18px; bottom: 18px; display: none; flex-direction: column; gap: 10px; }
#touch button { width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(232,222,198,.35);
  background: rgba(10,8,6,.5); color: var(--paper); font-size: 20px; }
@media (hover: none) and (pointer: coarse) { #touch.show { display: flex; } }

/* Screens */
.screen { position: fixed; inset: 0; z-index: 10; }
.btn { background: var(--paper); color: var(--ink); border: 0; padding: 11px 22px; font: 15px/1 var(--type);
  letter-spacing: .06em; cursor: pointer; transition: transform .15s, background .15s; }
.btn:hover { background: #fff6e0; transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--paper); border: 1px solid rgba(232,222,198,.45); }
.btn.ghost:hover { background: rgba(232,222,198,.1); }

#start { background: radial-gradient(ellipse at 50% 40%, #2a2016 0%, #0b0806 70%); display: grid; place-items: center; padding: 24px; }
.start-inner { max-width: 620px; text-align: center; }
.kicker { font: 12px/1 var(--type); letter-spacing: .3em; text-transform: uppercase; color: var(--paper-dim); margin: 0 0 18px; }
#start h1 { font-weight: 400; font-size: clamp(40px, 7vw, 76px); line-height: 1; margin: 0; letter-spacing: -.01em; }
#start .sub { font-style: italic; font-size: 20px; color: var(--paper-dim); margin: 14px 0 40px; }
.controls { font: 13px/1.7 var(--type); color: var(--paper-dim); margin: 34px 0 0; }
.note { font-size: 14px; line-height: 1.55; color: #8f8570; margin: 26px auto 0; max-width: 520px; }

#view { background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 24px; }
#view figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 1100px; }
#view img { max-width: 100%; max-height: 72vh; display: block; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#view figcaption { font: 17px/1.5 var(--type); text-align: center; max-width: 720px; }
#view .close { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); }

/* Raum */
#room { background: #080604; }
#room .stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden; }
#room .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: contrast(1.04);
  animation: breathe 18s ease-in-out infinite alternate; }
@keyframes breathe { from { transform: scale(1); } to { transform: scale(1.025); } }
#room .grain { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .5;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.65) 100%); }
.hotspots { position: absolute; inset: 0; }
.hot { position: absolute; cursor: pointer; border-radius: 40%; }
.hot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: rgba(255, 244, 214, .85); box-shadow: 0 0 12px 4px rgba(255, 238, 200, .45);
  animation: glint 2.8s ease-in-out infinite; }
.hot:hover::after { animation: none; opacity: 1; transform: scale(1.4); }
.hot.found::after { display: none; }
.hot.found { cursor: default; }
@keyframes glint { 0%, 100% { opacity: .15; transform: scale(.7); } 50% { opacity: .9; transform: scale(1); } }
#room .person { position: absolute; transform: translateX(-50%); opacity: 0; cursor: pointer; pointer-events: none;
  filter: sepia(.25) contrast(1.05) drop-shadow(0 10px 18px rgba(0,0,0,.55)); transition: opacity 2.4s ease, filter 2.4s; }
#room .person.in { opacity: 1; pointer-events: auto; }
#room .person.in:hover { filter: sepia(.25) contrast(1.05) brightness(1.08) drop-shadow(0 0 16px rgba(255,238,200,.35)); }
#room .person.heard { cursor: default; }
#room .memory { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s; pointer-events: none; }
#room .memory.on { opacity: 1; }

.room-head { position: absolute; left: 22px; top: 18px; display: flex; gap: 14px; align-items: baseline; text-shadow: 0 1px 3px #000; }
.room-head .year { font: 13px/1 var(--type); letter-spacing: .2em; color: var(--paper-dim); }
.room-head .title { font-size: 24px; font-style: italic; }
.tray { position: absolute; right: 22px; top: 16px; display: flex; gap: 14px; align-items: center; font: 13px/1 var(--type); color: var(--paper-dim); text-shadow: 0 1px 3px #000; }
.tray .order { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(232,222,198,.18); } }
.caption { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); width: min(760px, 92vw);
  background: rgba(16, 13, 10, .9); border-left: 3px solid var(--paper); padding: 16px 20px; }
.caption p { margin: 0; font: 17px/1.55 var(--type); }
.caption .who { display: block; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 6px; }
#room .leave { position: absolute; left: 22px; bottom: 20px; }

.puzzle, .done { position: absolute; inset: 0; background: rgba(8, 6, 4, .93); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; gap: 18px; overflow-y: auto; }
.puzzle h2 { font-weight: 400; font-style: italic; font-size: 26px; margin: 0; text-align: center; }
.slots, .pool { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: min(1100px, 100%); }
.slot { min-height: 150px; border: 1px dashed rgba(232,222,198,.35); position: relative; }
.slot::before { content: attr(data-n); position: absolute; left: 8px; top: 6px; font: 12px var(--type); color: var(--paper-dim); }
.card { background: var(--paper); color: var(--ink); padding: 26px 14px 14px; font: 13px/1.45 var(--type); cursor: pointer; min-height: 150px;
  position: relative; box-shadow: 0 6px 16px rgba(0,0,0,.4); transition: transform .15s; }
.card:hover { transform: translateY(-2px) rotate(-.4deg); }
.card b { position: absolute; left: 14px; top: 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #6c5d45; }
.slot .card { height: 100%; }
.slot.right .card { outline: 3px solid var(--blue-soft); }
.pool .card.used { visibility: hidden; }
.feedback { min-height: 1.4em; margin: 0; font: 15px var(--type); color: var(--paper-dim); }
.puzzle-actions { display: flex; gap: 12px; }
@media (max-width: 760px) {
  .slots, .pool { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card, .slot { min-height: 120px; font-size: 12px; }
}

.done .seal { width: 120px; height: 120px; border: 2px solid var(--paper); border-radius: 50%; display: grid; place-items: center;
  animation: stamp .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.done .seal svg { width: 64px; height: 64px; stroke: var(--paper); stroke-width: 2; fill: none; }
@keyframes stamp { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.done .year { font: 13px var(--type); letter-spacing: .25em; color: var(--paper-dim); margin: 0; }
.done .text { font-size: 21px; line-height: 1.55; max-width: 680px; text-align: center; margin: 0; }

/* Ende */
#end { background: #eceae6; color: #1e1e1e; overflow-y: auto; }
.end-inner { max-width: 760px; margin: 0 auto; padding: 9vh 24px 12vh; }
#end .kicker { color: #777; text-align: left; }
#end h2 { font-weight: 400; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.3; margin: 0 0 40px; }
.chapters { list-style: none; padding: 0; margin: 0 0 32px; border-top: 1px solid #cfccc6; }
.chapters li { display: grid; grid-template-columns: 44px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid #cfccc6; font-size: 17px; line-height: 1.55; }
.chapters svg { width: 36px; height: 36px; stroke: #1e1e1e; stroke-width: 2; fill: none; }
#end .note { color: #666; margin: 0 0 44px; max-width: none; font-size: 16px; }
#end h3 { font-weight: 400; font-style: italic; font-size: 28px; margin: 0 0 8px; }
.prompt { color: #555; margin: 0 0 16px; font-size: 17px; line-height: 1.5; }
#own { width: 100%; font: 17px/1.6 var(--type); padding: 16px; border: 1px solid #bdb9b1; background: #fff; color: #1e1e1e; resize: vertical; }
.end-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
#end .btn { background: #1e1e1e; color: #f2f0ec; }
#end .btn.ghost { background: transparent; color: #1e1e1e; border-color: #999; }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 50; transition: opacity .7s ease; }
#fade.on { opacity: 1; pointer-events: auto; }
#fade.white { background: #f4f4f2; }

#room .exit-room { position: absolute; right: 22px; bottom: 20px; z-index: 5; background: rgba(12,10,8,.78); color: var(--paper);
  border: 1px solid rgba(232,222,198,.5); padding: 11px 18px; font: 15px/1 var(--type); letter-spacing: .06em; cursor: pointer; }
#room .exit-room:hover { background: rgba(232,222,198,.16); }

#end .closing { font-size: clamp(30px, 4.6vw, 52px); line-height: 1.2; font-style: italic; margin: 18vh 0 16vh; letter-spacing: -.01em; }

/* Nebengeschichte: mehrere Bildschirme und Gespräche */
#room .scenes { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; z-index: 3; }
#room .scenes button.prev, #room .scenes button.next { width: 38px; height: 38px; border: 1px solid rgba(232,222,198,.45); background: rgba(12,10,8,.7); color: var(--paper); font-size: 22px; cursor: pointer; }
#room .scenes .tabs { display: flex; gap: 4px; }
#room .scenes .tabs button { background: rgba(12,10,8,.7); color: var(--paper-dim); border: 1px solid rgba(232,222,198,.2); padding: 9px 12px; font: 13px/1 var(--type); cursor: pointer; }
#room .scenes .tabs button.on { color: var(--ink); background: var(--paper); }
#room .scenes .tabs button.new::after { content: " •"; color: #d9785f; }
#room .dialog { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); width: min(820px, 94vw); z-index: 4;
  background: rgba(14, 11, 9, .94); border-left: 3px solid #b8563f; padding: 18px 22px; max-height: 62vh; overflow-y: auto; }
#room .dialog .who { font: 12px/1 var(--type); letter-spacing: .2em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 10px; }
#room .dialog .line { font: 17px/1.55 var(--type); margin: 0 0 14px; min-height: 2.6em; }
#room .dialog .gain { display: block; margin-top: 10px; color: #e3a08c; font-size: 14px; letter-spacing: .04em; }
#room .dialog .questions { display: flex; flex-direction: column; gap: 6px; }
#room .dialog .questions button { text-align: left; background: transparent; color: var(--paper); border: 1px solid rgba(232,222,198,.25); padding: 10px 14px; font: 15px/1.35 var(--serif); cursor: pointer; }
#room .dialog .questions button::before { content: "› "; color: #d9785f; }
#room .dialog .questions button:hover { background: rgba(232,222,198,.08); border-color: rgba(232,222,198,.5); }
#room .dialog .questions button.asked { color: var(--paper-dim); border-color: rgba(232,222,198,.12); }
#room .dialog .questions button.fresh { border-color: #d9785f; }
#room .dialog .close-dialog { margin-top: 12px; background: none; border: 0; color: var(--paper-dim); font: 13px var(--type); cursor: pointer; padding: 4px 0; }
#room .person.talk { cursor: pointer; }
