/* Bandersnatch 1984 – bewusst nur ein dunkles Thema: Kino, Röhrenfernseher, Natriumlicht. */
:root {
  color-scheme: dark;
  --ink: #09090b;
  --ink-2: #131318;
  --paper: #efe9dc;
  --paper-dim: #aaa396;
  --amber: #f2a93b;
  --signal: #d8313f;
  --line: rgba(239, 233, 220, .24);
  --clip: #ece4d0;
  --clip-ink: #1d1a15;
  --zx-blue: #0000d7;
  --zx-grey: #d7d7d7;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-serif: "IBM Plex Serif", Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --f-display: "Big Shoulders Stencil Display", "Arial Narrow", Impact, sans-serif;
  --f-zx: "Press Start 2P", ui-monospace, monospace;
  --f-hand: "Caveat", "Segoe Print", cursive;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-body);
  font-size: 16px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

/* ── Bühne ── */
#app { position: relative; height: 100%; display: grid; place-items: center; background: #000; }
#screen {
  position: relative;
  width: min(100vw, 177.78vh);
  width: min(100vw, 177.78dvh);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#stage { position: absolute; inset: 0; overflow: hidden; }
#art { display: block; width: 100%; height: 100%; image-rendering: crisp-edges; image-rendering: pixelated; }
#grain {
  position: absolute; inset: -50%;
  opacity: .08; mix-blend-mode: overlay; pointer-events: none;
  background-size: 192px 192px;
  animation: grain .5s steps(3) infinite;
}
@keyframes grain { 0% { transform: translate(0, 0); } 33% { transform: translate(-6%, 4%); } 66% { transform: translate(5%, -5%); } 100% { transform: translate(0, 0); } }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, .55) 100%); }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s ease; }
#fade.on { opacity: 1; }

#card {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: .7em;
  padding-inline: 16px;
  text-align: center;
  background: rgba(0, 0, 0, .5);
  pointer-events: none;
}
.card-date { margin: 0; font: 500 clamp(11px, 1.15vw, 16px)/1.2 var(--f-mono); letter-spacing: .28em; text-transform: uppercase; color: var(--amber); }
.card-place { margin: 0; font: 800 clamp(38px, 7vw, 104px)/.9 var(--f-display); letter-spacing: .01em; text-transform: uppercase; text-wrap: balance; }
#card.in .card-place { animation: cardIn 1.2s cubic-bezier(.2, .7, .1, 1) both; }
#card.in .card-date { animation: fadeIn .8s .15s both; }
#card.out { opacity: 0; transition: opacity .45s; }
@keyframes cardIn { from { opacity: 0; letter-spacing: .14em; filter: blur(6px); } to { opacity: 1; letter-spacing: .01em; filter: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#vhs {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .07) 0 2px, transparent 2px 5px);
  animation: vhs .22s linear infinite;
}
#vhs span {
  position: absolute; top: 6%; left: 4%;
  font: 500 clamp(12px, 1.4vw, 18px)/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: #fff; text-shadow: 2px 0 rgba(216, 49, 63, .85), -2px 0 rgba(0, 215, 215, .7);
}
@keyframes vhs { from { background-position: 0 0; } to { background-position: 0 -40px; } }
#screen.fx-rewind #art { animation: rw .16s steps(2) infinite; filter: saturate(.35) contrast(1.35); }
@keyframes rw { 0% { transform: translateX(-1.5%) skewX(-2deg); } 100% { transform: translateX(1.5%) skewX(2deg); } }
#screen.fx-glitch #stage { animation: glitch .14s steps(2) 5; }
@keyframes glitch {
  0% { transform: translate(1.2%, -.6%); filter: hue-rotate(70deg) saturate(3); }
  50% { transform: translate(-1.6%, .8%); clip-path: inset(12% 0 26% 0); }
  100% { transform: none; filter: none; clip-path: none; }
}
#screen.fx-shake #stage { animation: shake .07s linear 8; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translate(-1%, .6%); } 75% { transform: translate(1%, -.6%); } }

/* ── Untertitel und Entscheidungen ── */
#panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; justify-items: center; align-content: end;
  padding: 10% 7% 4.2%;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .5) 45%, rgba(0, 0, 0, .78));
  pointer-events: none;
}
#panel > * { pointer-events: auto; }
.sub {
  max-width: 46ch;
  text-align: center;
  font-size: clamp(15px, 1.7vw, 25px);
  line-height: 1.45;
  text-shadow: 0 1px 2px #000, 0 0 14px rgba(0, 0, 0, .85);
  animation: subIn .3s ease-out both;
}
@keyframes subIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sub .who { margin: 0 0 .35em; font: 500 .6em/1.2 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.sub .txt { margin: 0; text-wrap: pretty; }
.sub .rest { color: transparent; text-shadow: none; }
.sub .next { display: inline-block; margin-left: .35em; color: var(--amber); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sub.is-narration .txt { color: #e4ddcd; }
.sub.is-screen {
  max-width: 40ch;
  padding: 1em 1.2em;
  font: 400 clamp(10px, 1.02vw, 15px)/1.9 var(--f-zx);
  text-transform: uppercase; text-align: left;
  color: #fff; background: var(--zx-blue);
  box-shadow: 0 0 0 6px var(--zx-grey);
  text-shadow: none;
}
.sub.is-screen .next { color: #ffff00; }
.sub.is-letter {
  max-width: 34ch;
  padding: .7em 1.1em;
  font: 500 clamp(21px, 2.3vw, 34px)/1.25 var(--f-hand);
  text-align: left;
  color: #2a241b; background: var(--clip);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6);
  text-shadow: none;
  transform: rotate(-1.2deg);
  animation: fadeIn .4s both;
}
.sub.is-letter .next { color: #9a5b12; }

#choices { width: min(100%, 900px); display: grid; gap: 12px; }
#choices.show { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.bar { height: 3px; background: rgba(239, 233, 220, .14); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--paper); transform-origin: 50% 50%; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#choices.three .opts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt {
  display: flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 3.1em; padding: .8em 1em;
  font-weight: 500; font-size: clamp(14px, 1.45vw, 21px); line-height: 1.2; text-align: center;
  color: var(--paper); background: rgba(12, 12, 14, .62);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .25s, opacity .35s;
}
.opt:hover, .opt.sel { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.opt.picked { background: var(--paper); color: var(--ink); border-color: var(--paper); transform: scale(1.04); }
.opt.fade { opacity: 0; transform: scale(.97); }
.opt.secret { border-color: var(--signal); box-shadow: inset 0 0 0 1px var(--signal), 0 0 26px rgba(216, 49, 63, .4); }
.opt.secret.sel, .opt.secret:hover { background: var(--signal); color: #fff; border-color: var(--signal); }
.g { width: 1.3em; height: 1.3em; flex: none; }
.g circle, .g path, .title-glyph circle, .title-glyph path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.g circle, .g path { stroke-width: 8; }
.hint { margin: 0; text-align: center; font: 400 12px/1.4 var(--f-mono); letter-spacing: .04em; color: var(--paper-dim); }

#inputbox { width: min(100%, 640px); display: grid; gap: 10px; }
#inputbox label { font: 500 clamp(15px, 1.6vw, 22px)/1.3 var(--f-body); text-align: center; text-shadow: 0 1px 2px #000; }
.input-row { display: flex; gap: 8px; }
#free-text {
  flex: 1; min-width: 0;
  padding: 12px 14px;
  font: 500 17px/1.2 var(--f-mono);
  color: #fff; background: var(--zx-blue);
  border: 3px solid var(--zx-grey); border-radius: 0;
  caret-color: #ffff00;
}
#free-text::placeholder { color: rgba(255, 255, 255, .55); }
#free-text:focus { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ── Knöpfe ── */
.btn {
  padding: 15px 22px;
  font: 500 13px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--paper); background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--paper); background: rgba(239, 233, 220, .07); }
.btn.primary { color: #1b1206; background: var(--amber); border-color: var(--amber); }
.btn.primary:hover { background: #ffbd55; border-color: #ffbd55; }
.linkbtn {
  justify-self: center;
  padding: 6px;
  font: 400 12px/1.3 var(--f-mono); letter-spacing: .08em;
  color: var(--paper-dim); background: none; border: 0;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--paper); }
.linkbtn.armed { color: #ff8a8a; }

#hud { position: fixed; z-index: 20; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; display: flex; gap: 6px; }
.hud-btn {
  padding: 8px 10px;
  font: 500 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper-dim); background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(239, 233, 220, .16);
  cursor: pointer;
}
.hud-btn:hover { color: var(--paper); border-color: var(--line); }
.hud-btn[aria-pressed="true"] { color: var(--amber); border-color: rgba(242, 169, 59, .5); }

/* ── Überlagerungen ── */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  overflow-y: auto;
  padding-block: calc(env(safe-area-inset-top, 0px) + 32px) calc(env(safe-area-inset-bottom, 0px) + 32px);
  padding-inline: 20px;
}
.eyebrow { margin: 0; font: 500 12px/1.3 var(--f-mono); letter-spacing: .26em; text-transform: uppercase; color: var(--amber); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.actions.left { justify-content: flex-start; }

#title { background: radial-gradient(ellipse at 50% 42%, rgba(9, 9, 11, .45), rgba(9, 9, 11, .94) 72%); }
.title-inner { max-width: 760px; display: grid; justify-items: center; gap: 18px; text-align: center; }
.title-glyph { width: clamp(78px, 11vw, 124px); color: var(--signal); overflow: visible; }
.title-glyph circle, .title-glyph path { stroke-width: 5; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.8s .1s cubic-bezier(.6, .1, .3, 1) forwards; }
.title-glyph path { animation-delay: .7s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.logo {
  margin: 0;
  font: 800 clamp(52px, 12vw, 156px)/.86 var(--f-display);
  letter-spacing: .03em; text-transform: uppercase;
  animation: chroma 7s 2s infinite;
}
@keyframes chroma {
  0%, 92%, 100% { text-shadow: none; transform: none; }
  93% { text-shadow: 3px 0 rgba(216, 49, 63, .85), -3px 0 rgba(0, 215, 215, .7); transform: translateX(1px); }
  95% { text-shadow: -4px 0 rgba(216, 49, 63, .85), 4px 0 rgba(0, 215, 215, .7); transform: translateX(-2px); }
  97% { text-shadow: none; transform: none; }
}
.tagline { margin: 0; max-width: 42ch; font-size: clamp(16px, 1.6vw, 20px); line-height: 1.5; text-wrap: balance; }
.meta { margin: 0; font: 400 13px/1.5 var(--f-mono); color: var(--paper-dim); }
.fine { margin: 14px 0 0; max-width: 58ch; font-size: 12px; line-height: 1.55; color: #857f73; }

#ending { background: rgba(6, 6, 8, .93); }
.end-inner { width: min(100%, 660px); display: grid; gap: 22px; }
.end-title { margin: 0; font: 800 clamp(44px, 8.5vw, 96px)/.88 var(--f-display); text-transform: uppercase; text-wrap: balance; }
.badge { display: inline-block; margin-left: 10px; padding: 3px 7px; color: #fff; background: var(--signal); letter-spacing: .12em; }
.clip {
  margin: 0;
  display: grid; gap: 12px;
  padding: 20px 22px 22px;
  color: var(--clip-ink); background: var(--clip);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  transform: rotate(-.6deg);
}
.clip-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid currentColor;
  font: 800 22px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase;
}
.clip blockquote { margin: 0; font: 400 clamp(16px, 1.7vw, 19px)/1.55 var(--f-serif); }
.stars { display: inline-flex; align-items: center; }
.stars svg { width: 104px; height: 20px; display: block; }
.s-off { fill: rgba(29, 26, 21, .16); }
.s-on { fill: #b8322a; }
.nostars { font: 500 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.clip.news { background: #d6d3c9; }
.clip.news blockquote { font-style: italic; }
.clip.console { color: #ff7070; background: #0d0e11; box-shadow: 0 0 0 1px #2a2d33, 0 18px 50px rgba(0, 0, 0, .55); transform: none; }
.clip.console .clip-head { color: #8f96a0; border-color: #2a2d33; font: 500 12px/1 var(--f-mono); letter-spacing: .1em; }
.clip.console blockquote { font: 500 15px/1.5 var(--f-mono); }
.epilog { margin: 0; font-size: clamp(17px, 1.8vw, 21px); line-height: 1.55; }
.unlock { margin: 0; padding: 12px 14px; font: 400 14px/1.5 var(--f-mono); color: #ffc7cc; border: 1px dashed var(--signal); }

#gallery { z-index: 35; background: var(--ink); }
.gal-inner { width: min(100%, 940px); display: grid; gap: 22px; }
.gal-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.gal-head h2 { margin: 6px 0 0; font: 800 clamp(40px, 6vw, 72px)/.9 var(--f-display); text-transform: uppercase; }
.gal-grid { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gal-card { display: grid; align-content: start; gap: 8px; min-height: 150px; padding: 16px; background: var(--ink-2); border: 1px solid var(--line); }
.gal-card.locked { background: transparent; border-style: dashed; }
.gal-num { font: 500 11px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.gal-title { margin: 0; font: 800 clamp(22px, 2.3vw, 27px)/.95 var(--f-display); text-transform: uppercase; overflow-wrap: anywhere; hyphens: auto; }
.locked .gal-title { color: #5b574f; }
.gal-hint { margin: 0; font-size: 14px; line-height: 1.45; color: var(--paper-dim); }
.gal-stars svg { width: 88px; height: 17px; display: block; }
.gal-stars .s-off { fill: rgba(239, 233, 220, .16); }
.gal-stars .s-on { fill: var(--amber); }
.gal-stars .nostars { color: var(--paper-dim); }

#credits { z-index: 36; background: #000; overflow: hidden; cursor: pointer; }
.roll { display: grid; gap: 34px; text-align: center; animation: roll 25s linear forwards; }
@keyframes roll { from { transform: translateY(70vh); } to { transform: translateY(-115%); } }
.credit { display: grid; gap: 6px; }
.role { margin: 0; font: 500 12px/1.2 var(--f-mono); letter-spacing: .24em; text-transform: uppercase; color: var(--amber); }
.name { margin: 0; font-size: clamp(18px, 2vw, 26px); }
.big { margin: 0; font: 800 clamp(52px, 10vw, 120px)/.9 var(--f-display); text-transform: uppercase; }
.quote { margin: 0 auto; max-width: 26ch; font: 500 clamp(26px, 3.2vw, 42px)/1.2 var(--f-hand); }

/* ── ZX Spectrum ── */
#zx {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: #000;
}
#zx-canvas {
  width: min(100%, calc((100vh - 150px) * 4 / 3));
  width: min(100%, calc((100dvh - 150px) * 4 / 3));
  height: auto; aspect-ratio: 4 / 3;
  image-rendering: crisp-edges; image-rendering: pixelated;
  border-radius: 10px / 14px;
  box-shadow: 0 0 0 10px #151515, 0 0 70px rgba(120, 150, 255, .14);
  cursor: pointer;
}
#zx-msg { margin: 0; min-height: 1.4em; font: 500 12px/1.4 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; text-align: center; color: #a8a8a8; }
.zx-bar { display: flex; align-items: center; gap: 22px; }
.dpad { display: none; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 4px; }
.dpad button { font-size: 18px; color: #ddd; background: #1a1a1a; border: 1px solid #333; touch-action: none; }
.dpad button:active { background: #333; }
.dpad .u { grid-column: 2; grid-row: 1; }
.dpad .l { grid-column: 1; grid-row: 2; }
.dpad .r { grid-column: 3; grid-row: 2; }
.dpad .d { grid-column: 2; grid-row: 3; }
@media (pointer: coarse) {
  .dpad { display: grid; }
  #zx-canvas { width: min(100%, calc((100dvh - 330px) * 4 / 3)); }
}

/* ── Hochformat und schmale Fenster: Bild oben, Text darunter ── */
@media (max-aspect-ratio: 1/1), (max-width: 640px) {
  #app { display: block; }
  #screen { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; display: flex; flex-direction: column; }
  #stage { position: relative; inset: auto; flex: none; width: 100%; aspect-ratio: 16 / 9; }
  #panel {
    position: relative; flex: 1;
    align-content: start;
    padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
    background: var(--ink);
    overflow-y: auto;
  }
  .sub { font-size: 18px; text-shadow: none; }
  .sub.is-screen { font-size: 11px; }
  .sub.is-letter { font-size: 26px; }
  #choices.three .opts { grid-template-columns: 1fr; }
  .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #hud { top: calc(env(safe-area-inset-top, 0px) + 8px); right: 8px; }
}
@media (max-width: 460px) {
  .opts { grid-template-columns: 1fr; }
  .gal-grid { grid-template-columns: 1fr; }
}
@media (min-width: 641px) and (max-width: 900px) and (min-aspect-ratio: 1/1) {
  .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  #grain, .logo, .sub .next, #vhs { animation: none; }
  .title-glyph circle, .title-glyph path { animation: none; stroke-dashoffset: 0; }
  .roll { animation: none; }
  #screen.fx-rewind #art, #screen.fx-glitch #stage, #screen.fx-shake #stage { animation: none; }
}

/* ── Sprachauswahl ── */
#langpick { z-index: 38; background: radial-gradient(ellipse at 50% 40%, rgba(9, 9, 11, .55), rgba(9, 9, 11, .95) 70%); }
#fatal { z-index: 50; background: var(--ink); }
#fatal code { font-family: var(--f-mono); font-size: .9em; color: var(--amber); }
.lang-inner { width: min(100%, 720px); display: grid; justify-items: center; gap: 18px; text-align: center; }
.lang-title { margin: 0; font: 800 clamp(34px, 6vw, 64px)/.95 var(--f-display); text-transform: uppercase; text-wrap: balance; }
.lang-grid { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .lang-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lang-btn {
  display: grid; gap: 6px; justify-items: center;
  padding: 18px 14px;
  color: var(--paper); background: rgba(19, 19, 24, .85);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.lang-btn:hover, .lang-btn:focus-visible { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.lang-btn.current { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.lang-name { font: 800 26px/1 var(--f-display); text-transform: uppercase; letter-spacing: .02em; }
.lang-en { font: 500 11px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.lang-missing { margin: 8px 0 0; max-width: 56ch; font-size: 14px; line-height: 1.55; color: var(--paper-dim); }
.lang-missing a { color: var(--amber); text-underline-offset: 3px; }
#btn-lang { margin-top: -4px; }
