/*
 * ECHO-7-Terminal. Bühne 1080 × 1920 px; display.js skaliert sie auf den
 * Bildschirm. Maße und Farben folgen der Vorlage „ECHO-7 · Systemübersicht“.
 *
 *   Z1    0–600  Emblem, Kennung (im Bühnenbild)
 *   Z2  640–1290 Reiter der Akten (640–712), Akte im Vordergrund (710–1290)
 *   Z3 1312–1680 Code-Eingabe
 *   Z4 1710–1870 Einsatzzeit (rot: Verbindung unterbrochen)
 */

body { display: flex; align-items: center; justify-content: center; background: #000; }

/* Kein Mauszeiger auf dem Terminal – auf jedem Element, auch über Overlays und dem Video. */
html, html * { cursor: none !important; }

#viewport { position: relative; flex: none; overflow: hidden; isolation: isolate; background: var(--bg); }

#monitor {
  position: absolute; top: 0; left: 0; width: 1080px; height: 1920px;
  transform-origin: top left; overflow: hidden;
  background-color: var(--bg);
  background-image: var(--stage-image, none);
  background-size: 1080px 1920px;
  background-repeat: no-repeat;
  color: var(--sand);
}
#monitor:focus { outline: none; }
/* Bildzeilen und Vignette innerhalb des Rahmens */
#monitor::after {
  content: ''; position: absolute; inset: 50px 50px 48px; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.085) 0, rgba(0, 0, 0, 0.085) 1px, transparent 1px, transparent 4px);
  box-shadow: inset 0 0 85px rgba(0, 0, 0, 0.23);
}

/* ------------------------------------------------------------------ Z2: Hinweis der Spielleitung */

/* liegt unten über dem Aktenfenster und bleibt, bis die Spielleitung ihn ausblendet */
#mission { position: absolute; left: 92px; width: 896px; top: 1110px; height: 90px; z-index: 6; pointer-events: none; }
#mission.message {
  padding: 10px 22px 10px 18px; overflow: hidden;
  color: var(--amber); font-size: 26px; line-height: 1.3; letter-spacing: 0.035em; text-shadow: 0 0 9px rgba(232, 169, 58, 0.25);
  background: rgba(3, 15, 15, 0.97); border: 2px solid rgba(232, 169, 58, 0.75); border-left-width: 5px;
  animation: viewer-in 0.3s ease-out;
}
#mission.message .label { color: var(--dim); text-shadow: none; margin-right: 0.6em; }
#mission.long { font-size: 22px; }
[data-stage='standby'] #mission, [data-stage='finale'] #mission, [data-stage='ended'] #mission { display: none; }

/* ------------------------------------------------------------------ Z2: Reiter der Akten */

/* Reiter wie Karteikarten: die Akte im Vordergrund geht nahtlos ins Fenster über */
#tabs {
  position: absolute; top: 640px; left: 72px; width: 936px; height: 72px; z-index: 6; padding: 0 28px;
  display: flex; gap: 6px; align-items: flex-end;
}
[data-stage='standby'] #tabs, [data-stage='ask'] #tabs, [data-stage='intro'] #tabs, [data-stage='finale'] #tabs, [data-stage='ended'] #tabs { display: none; }
.tab {
  flex: 1 1 0; min-width: 0; height: 56px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px;
  background: linear-gradient(rgba(10, 30, 28, 0.96), rgba(4, 16, 16, 0.96));
  border: 2px solid rgba(161, 155, 113, 0.42); border-bottom: 0; border-radius: 14px 14px 0 0;
  color: var(--dim); font-size: 23px; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden;
  box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.35);
  transition: height 0.2s, background 0.2s, color 0.2s;
}
.tab-icon svg { display: block; width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 6; stroke-linecap: square; }
.tab-state { font-family: Arial, sans-serif; font-size: 19px; color: var(--red); }
.tab-label { overflow: hidden; text-overflow: ellipsis; }
/* fünf Reiter (mit Aktenkoffer): ohne Symbol, damit die Namen ganz passen */
#tabs.many .tab-icon { display: none; }
#tabs.many .tab { gap: 8px; font-size: 21px; letter-spacing: 0.05em; }
.tab.open { color: var(--sand); border-color: rgba(159, 214, 164, 0.5); }
.tab.open .tab-state { color: var(--ok); }
/* Akte im Vordergrund: höher, hell, gleiche Farbe wie das Fenster, überdeckt dessen Oberkante */
.tab.active {
  height: 72px; margin-bottom: -2px; background: rgb(7, 27, 22); color: var(--cream); font-weight: 500;
  border-color: rgba(159, 214, 164, 0.62); box-shadow: 0 -4px 14px rgba(159, 214, 164, 0.12); text-shadow: 0 0 9px rgba(255, 255, 225, 0.2);
}
.tab.master.open { border-color: rgba(232, 169, 58, 0.6); }
.tab.master.open .tab-state { color: var(--amber); }
.tab.master.active { border-color: var(--amber); }
.tab.flash { animation: unlock-flash 380ms 3; }
@keyframes unlock-flash { 50% { border-color: var(--cream); box-shadow: 0 0 25px rgba(255, 255, 225, 0.36); background: rgba(255, 255, 225, 0.12); } }

/* ------------------------------------------------------------------ Z2: Inhalte */

#viewer {
  position: absolute; z-index: 4; left: 72px; width: 936px; top: 710px; height: 580px;
  background: rgb(7, 27, 22);
  border: 2px solid rgba(159, 214, 164, 0.62);
  clip-path: polygon(0 22px, 22px 0, calc(100% - 22px) 0, 100% 22px, 100% calc(100% - 22px), calc(100% - 22px) 100%, 22px 100%, 0 calc(100% - 22px));
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.44);
  animation: viewer-in 0.32s ease-out;
}
#viewer[hidden] { display: none; }
#viewer::before {
  content: ''; position: absolute; inset: 10px; pointer-events: none;
  border: 1px solid rgba(161, 155, 113, 0.13);
  clip-path: polygon(0 15px, 15px 0, calc(100% - 15px) 0, 100% 15px, 100% calc(100% - 15px), calc(100% - 15px) 100%, 15px 100%, 0 calc(100% - 15px));
}
@keyframes viewer-in { from { opacity: 0; transform: translateY(10px); } }
/* Ohne Reiter (Intro, Finale, Ende): Fenster bis zum Fuß, die Eingabe ist ausgeblendet */
#viewer.full { top: 636px; height: 1013px; border-color: var(--line); background: rgba(3, 15, 15, 0.94); }
/* Vor den Akten (Übertragung): gleiche Höhe wie die Akten, aber ohne Reiter darüber */
#viewer.plain { background: rgba(3, 15, 15, 0.93); border-color: var(--line); }
#viewer.full .viewer-body { bottom: 40px; }
/* Finale und Ende: keine Eingabe, keine Laufzeit – das Fenster reicht fast bis zum Rahmen */
[data-stage='finale'] #viewer.full, [data-stage='ended'] #viewer.full { height: 1190px; }
/* Karte: Bühnenbild scheint durch, nur Rahmen und Kopf bleiben */
#viewer.map { background: linear-gradient(rgb(7, 27, 22) 0, rgb(7, 27, 22) 78px, rgba(3, 15, 15, 0.05) 78px); box-shadow: none; }
#viewer.map .viewer-title { display: none; }
#viewer.map .viewer-kicker { color: var(--cream); font-weight: 500; font-size: 26px; letter-spacing: 0.1em; }
#viewer.map .viewer-body .seq-lines { top: auto; bottom: 0; }
#viewer.map .viewer-body .seq-lines .ref { margin: 0; padding: 6px 16px; background: rgba(3, 15, 15, 0.94); }
#viewer.map .viewer-head { border-bottom: 1px solid rgba(161, 155, 113, 0.3); padding-bottom: 12px; height: 54px; }

.viewer-head {
  position: absolute; top: 24px; left: 34px; right: 30px; height: 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.viewer-kicker { font-size: 24px; color: var(--dim); letter-spacing: 0.13em; white-space: nowrap; }
.viewer-state {
  display: flex; align-items: center; height: 40px; padding: 0 16px;
  border: 1px solid currentColor; color: var(--ok); background: rgba(159, 214, 164, 0.075);
  font-size: 23px; letter-spacing: 0.04em; white-space: nowrap;
}
.viewer-state:empty { display: none; }
.viewer-state.amber { color: var(--amber); background: rgba(232, 169, 58, 0.07); }
.viewer-state.amber::before { content: '●'; margin-right: 10px; animation: blink 1.2s steps(1) infinite; }
.viewer-state.red { color: var(--red); background: rgba(226, 87, 63, 0.06); }
.viewer-title {
  position: absolute; top: 68px; left: 34px; right: 34px;
  font-size: 34px; font-weight: 500; letter-spacing: 0.1em; color: var(--cream);
  text-shadow: 0 0 11px rgba(245, 228, 181, 0.2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viewer-title::after {
  content: ''; display: block; height: 1px; margin-top: 12px;
  background: linear-gradient(90deg, rgba(161, 155, 113, 0.55), rgba(161, 155, 113, 0.08));
}
.viewer-body { position: absolute; top: 132px; left: 36px; right: 36px; bottom: 62px; overflow: hidden; }
#viewer:not(.full) .viewer-body { bottom: 34px; }
/* Fußleiste der Akte: Ziffer des Mastercodes – eigener Bereich, überdeckt nichts */
.viewer-foot {
  position: absolute; left: 2px; right: 2px; bottom: 2px; height: 70px; padding: 0 34px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-top: 1px solid rgba(232, 169, 58, 0.45); background: rgba(3, 15, 15, 0.97);
}
.viewer-foot[hidden] { display: none; }
#viewer.has-foot .viewer-body { bottom: 92px; }
.foot-label { font-size: 21px; letter-spacing: 0.12em; color: var(--dim); }
.foot-value { display: flex; align-items: center; gap: 22px; }
/* „Stelle X“ hinterlegt, damit sie sich von der Ziffer abhebt */
.foot-pos { padding: 6px 14px; font-size: 22px; letter-spacing: 0.12em; color: var(--amber); background: rgba(232, 169, 58, 0.12); border: 1px solid rgba(232, 169, 58, 0.35); }
.foot-value b { font-size: 50px; font-weight: 500; line-height: 1; color: var(--cream); text-shadow: 0 0 16px rgba(232, 169, 58, 0.5); }
.viewer-foot.appear { animation: viewer-in 0.5s ease-out, glow-foot 1.2s ease-in-out 3; }
@keyframes glow-foot { 50% { background: rgba(232, 169, 58, 0.16); } }

/* Inhalte aus Sequenzen im Fenster */
.viewer-body .seq { position: absolute; inset: 0; z-index: auto; background: transparent; }
.viewer-body .seq-lines {
  left: 0; right: 0; top: 0; bottom: auto;
  font-size: 24px; line-height: 1.45; letter-spacing: 0.03em;
  text-shadow: 0 0 8px rgba(245, 228, 181, 0.16);
}
.viewer-body .seq-lines p:last-child::after { content: '▌'; margin-left: 4px; color: var(--cream); animation: blink 1s steps(1) infinite; }
.viewer-body .seq-title { gap: 20px; padding: 0 20px; }
.viewer-body .seq-title h1 { font-size: 64px; letter-spacing: 0.14em; }
.viewer-body .seq-title p { font-size: 26px; letter-spacing: 0.18em; }
.viewer-body .seq-media img, .viewer-body .seq-media video { object-fit: contain; }

/* Funksprüche: Uhrzeit · Sprecher · Text */
.viewer-body .seq-lines .say {
  display: grid; grid-template-columns: 82px 236px 1fr; align-items: baseline;
  font-size: 23px; line-height: 1.38; margin-bottom: 8px;
}
.viewer-body .seq-lines .say p { margin: 0; color: var(--cream); }
.say-time { color: var(--dim); }
.say-from { font-weight: 500; letter-spacing: 0.06em; color: var(--sand); }
.say-from[data-tone='ok'] { color: var(--ok); }
.say-from[data-tone='amber'] { color: var(--amber); }
.say-from[data-tone='red'] { color: var(--red); }
.say-from[data-tone='dim'] { color: #9ec8d6; }
.viewer-body .seq-lines .say:last-child p::after { content: '▌'; margin-left: 4px; color: var(--cream); animation: blink 1s steps(1) infinite; }
.viewer-body .seq-lines .say p::after, .viewer-body .seq-lines p:not(:last-child)::after { content: none; }

/* Diagnose-Ansicht (Relais R-04): grüne Messwerte, eigene Optik statt Funktext */
.viewer-body .seq[data-style='diag'] .seq-lines p { color: var(--ok); font-size: 24px; line-height: 1.5; letter-spacing: 0.04em; text-shadow: 0 0 8px rgba(159, 214, 164, 0.3); }
.viewer-body .seq[data-style='diag'] .seq-lines p:first-child { color: var(--cream); }
.viewer-body .seq[data-style='diag']::after {
  content: ''; position: absolute; right: 0; top: 4px; width: 150px; height: 70px;
  background: repeating-linear-gradient(90deg, var(--ok) 0 6px, transparent 6px 12px);
  opacity: 0.55; animation: signal 1.1s steps(6) infinite; transform-origin: bottom;
  -webkit-mask: linear-gradient(to top, #000 0 100%); clip-path: polygon(0 100%, 8% 55%, 16% 80%, 24% 30%, 32% 70%, 40% 15%, 48% 60%, 56% 40%, 64% 85%, 72% 25%, 80% 65%, 88% 45%, 100% 100%);
}
@keyframes signal { 50% { transform: scaleY(0.55); } }

/* Verweise auf gedruckte Unterlagen */
.viewer-body .seq-lines .ref {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; margin: 10px 0 12px;
  padding: 10px 16px; border: 1px solid rgba(232, 169, 58, 0.55); border-left: 4px solid var(--amber); background: rgba(232, 169, 58, 0.06);
}
.ref-icon { font-size: 36px; color: var(--amber); line-height: 1; }
.viewer-body .seq-lines .ref b { display: block; font-size: 27px; font-weight: 500; letter-spacing: 0.1em; color: var(--cream); }
.viewer-body .seq-lines .ref p { margin: 2px 0 0; font-size: 21px; color: var(--sand); }
.viewer-body .seq-lines .ref p::after, .viewer-body .seq-lines .ref b::after { content: none !important; }

/* Funk (Protokoll, Aufnahme): Zeilen wie aus dem Empfänger */
.viewer-body .seq.radio .seq-lines p { color: var(--sand); }
.viewer-body .seq.radio .seq-lines p:first-child { color: var(--dim); }

/* Feste Seiten (Frage R-04, Beweisarchiv) */
.card-lines { font-size: 27px; line-height: 1.55; letter-spacing: 0.035em; text-shadow: 0 0 8px rgba(245, 228, 181, 0.16); }
.card-lines p { margin: 0; min-height: 1.55em; }
.card-lines p:last-child { color: var(--cream); font-weight: 500; }

/* Noch keine Akte offen */
.card-lines.overview { margin-top: 40px; color: var(--sand); }

/* Aktenkoffer */
.typed.briefcase { font-size: 25px; line-height: 1.42; }
#viewer.full .typed.story { font-size: 25px; line-height: 1.45; letter-spacing: 0.03em; }
.typed.story div { margin-bottom: 14px; }
.typed.story div:first-child { color: var(--amber); }

/* Prüfsumme: Dechiffrier-Animation */
.checksum { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px; }
.checksum-code { font-size: 96px; font-weight: 500; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.checksum-code span { display: inline-block; min-width: 0.62em; text-align: center; }
.checksum-code .run { color: var(--dim); opacity: 0.75; }
.checksum-code .locked { color: var(--cream); text-shadow: 0 0 16px rgba(255, 255, 225, 0.35); }
.checksum-code .fixed { color: var(--dim); }
.checksum-bar { width: 640px; height: 18px; border: 2px solid var(--line); padding: 3px; }
.checksum-bar i { display: block; height: 100%; width: 0; background: var(--sand); transition: width 0.1s linear; }
.checksum-verdict { min-height: 110px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.checksum-verdict b { font-size: 48px; font-weight: 500; letter-spacing: 0.12em; }
.checksum-verdict span { font-size: 27px; letter-spacing: 0.08em; color: var(--sand); }
.checksum.ok .checksum-code .locked, .checksum.ok b { color: var(--ok); text-shadow: 0 0 22px rgba(159, 214, 164, 0.55); }
.checksum.ok .checksum-bar i { background: var(--ok); }
.checksum.fail .checksum-code .locked, .checksum.fail b { color: var(--red); text-shadow: 0 0 22px rgba(226, 87, 63, 0.55); }
.checksum.fail .checksum-bar i { background: var(--red); }
.checksum.fail .checksum-code { animation: shake 0.4s linear; }

/* Übertragung (Intro ohne Video, Schlussbotschaft ohne Video) */
.typed { font-size: 25px; line-height: 1.38; letter-spacing: 0.035em; text-shadow: 0 0 8px rgba(245, 228, 181, 0.16); }
#viewer.full .typed { font-size: 30px; line-height: 1.5; }
.typed.big {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px; text-align: center;
  font-size: 44px; font-weight: 500; line-height: 1.25; letter-spacing: 0.08em; color: var(--cream);
}
.typed.big div:first-child { color: var(--ok); font-size: 52px; }

/* Wahrheiten */
.truth { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 40px; text-align: center; padding: 0 30px; animation: viewer-in 0.5s ease-out; }
.truth-number { font-size: 30px; letter-spacing: 0.2em; color: var(--amber); }
.truth-text { font-size: 54px; font-weight: 500; line-height: 1.3; letter-spacing: 0.06em; color: var(--cream); text-shadow: 0 0 18px rgba(255, 255, 225, 0.25); }
.typed div { min-height: 1.38em; white-space: pre-wrap; }
.typed div.current::after { content: '▌'; margin-left: 4px; color: var(--cream); animation: blink 1s steps(1) infinite; }

/* Ergebnis */
.end { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; text-align: center; }
.end-title {
  font-size: 54px; font-weight: 500; letter-spacing: 0.12em; line-height: 1.1; color: var(--ok);
  text-shadow: 0 0 22px rgba(159, 214, 164, 0.3);
}
.end-label { margin-top: 60px; font-size: 30px; letter-spacing: 0.2em; color: var(--dim); }
.end-time {
  font-size: 128px; font-weight: 500; line-height: 1; letter-spacing: 0.02em; color: var(--cream);
  text-shadow: 0 0 26px rgba(255, 255, 225, 0.3); font-variant-numeric: tabular-nums;
}
.end-time small { font-size: 74px; color: var(--sand); }
.end-sub { margin-top: 70px; font-size: 40px; letter-spacing: 0.16em; color: var(--sand); }
/* Unten steht die Endzeit schon groß – die Laufzeit-Zeile bleibt im Finale weg */
[data-stage='finale'] #runtime, [data-stage='ended'] #runtime { visibility: hidden; }
.end.aborted .end-title { color: var(--amber); text-shadow: 0 0 22px rgba(232, 169, 58, 0.3); }

/* Kurslinien und Wegpunkte auf der Karte */
.seq-route { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; overflow: visible; }
.seq-route polyline {
  fill: none; stroke: var(--red); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(226, 87, 63, 0.6));
  stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw 2.4s ease-in-out forwards;
}
.seq-route.reported polyline { stroke: var(--sand); stroke-width: 3; stroke-dasharray: 1.6 1.4; stroke-dashoffset: 0; opacity: 0; filter: none; animation: fade 1.2s forwards; }
.seq-route.forged polyline { stroke-dasharray: 5 4; stroke-linecap: butt; stroke-dashoffset: 0; opacity: 0; animation: fade-full 1.2s forwards; }
.seq-point.forged .dot { background: none; border: 3px solid var(--red); box-shadow: none; }
.seq-route.instant polyline { animation-duration: 0s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 0.75; } }
.seq-point { position: absolute; width: 0; height: 0; opacity: 0; animation: fade-full 0.4s forwards; }
@keyframes fade-full { to { opacity: 1; } }
.seq-point .dot {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 10px rgba(226, 87, 63, 0.8);
}
.seq-point.reported .dot { background: var(--sand); box-shadow: none; left: -5px; top: -5px; width: 10px; height: 10px; }
.seq-point.ring .dot::after {
  content: ''; position: absolute; left: -20px; top: -20px; width: 48px; height: 48px; border: 3px solid var(--red); border-radius: 50%;
  animation: ping 1.8s ease-out infinite;
}
.seq-point.storm .dot {
  left: -46px; top: -46px; width: 92px; height: 92px; border-radius: 50%; background: none;
  border: 4px dashed rgba(232, 169, 58, 0.85); box-shadow: 0 0 16px rgba(232, 169, 58, 0.4); animation: spin 6s linear infinite;
}
.seq-point.storm .seq-point-label { border-color: var(--amber); }
.seq-point.storm.left .seq-point-label { right: 62px; }
@keyframes spin { to { transform: rotate(360deg); } }
.seq-point.station .dot { left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 0; background: none; border: 3px solid var(--ok); box-shadow: 0 0 10px rgba(159, 214, 164, 0.6); transform: rotate(45deg); }
.seq-point-label {
  position: absolute; left: 18px; top: -16px; white-space: nowrap; padding: 4px 9px;
  background: rgba(3, 15, 15, 0.85); border-left: 2px solid var(--red);
  display: flex; flex-direction: column;
}
.seq-point-label:has(b:empty) { display: none; }
.seq-point.left .seq-point-label { left: auto; right: 18px; border-left: 0; border-right: 2px solid var(--red); text-align: right; }
.seq-point.below .seq-point-label { left: -50px; top: 20px; }
.seq-point.left.below .seq-point-label { left: auto; right: -12px; }
.seq-point.above .seq-point-label { top: -78px; left: 22px; }
.seq-point.reported .seq-point-label { border-color: var(--sand); }
.seq-point.station .seq-point-label { border-color: var(--ok); }
.seq-point-label b { font-weight: 500; font-size: 22px; letter-spacing: 0.1em; color: var(--cream); }
.seq-point-label span { font-size: 18px; letter-spacing: 0.06em; color: var(--sand); }
.seq-point-label span:empty { display: none; }
.seq-legend {
  position: absolute; right: 98px; top: 800px; padding: 8px 16px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(3, 15, 15, 0.88); border: 1px solid rgba(161, 155, 113, 0.35); font-size: 20px; letter-spacing: 0.08em;
}
.seq-legend div { display: flex; align-items: center; gap: 12px; }
.seq-legend .swatch { display: inline-block; width: 46px; height: 0; border-top: 4px solid var(--red); }
.seq-legend .swatch.reported { border-top: 3px dashed var(--sand); }
.seq-legend .swatch.forged { border-top: 4px dashed var(--red); }

/* Quadratraster über der Karte (Schritt "grid") */
.seq-grid {
  position: absolute; display: grid; grid-auto-rows: 1fr;
  border: 1px solid rgba(194, 178, 124, 0.45); animation: fade-full 0.6s forwards; opacity: 0;
}
.seq-grid i { border: 1px solid rgba(194, 178, 124, 0.16); }
.seq-grid i.zone {
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 14px; letter-spacing: 0.06em; color: var(--red);
  background: repeating-linear-gradient(-45deg, rgba(226, 87, 63, 0.38) 0 3px, rgba(226, 87, 63, 0.06) 3px 10px);
  border: 2px solid rgba(226, 87, 63, 0.8);
}
.seq-grid b { position: absolute; font-weight: 500; font-size: 17px; color: var(--sand); opacity: 0.85; transform: translate(-50%, -50%); }
.seq-grid b.col { top: -14px; }
.seq-grid b.row { left: -16px; }

/* Markierung auf der Karte */
/* unter dem Fenster: dessen Kopf deckt die Markierung ab, der durchsichtige Teil zeigt sie */
#markers { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.seq-marker { position: absolute; width: 0; height: 0; animation: viewer-in 0.4s ease-out; }
.seq-marker .ring {
  position: absolute; left: -34px; top: -34px; width: 68px; height: 68px;
  border: 3px solid var(--red); border-radius: 50%; box-shadow: 0 0 14px rgba(226, 87, 63, 0.55);
}
.seq-marker .ring-2 { animation: ping 1.8s ease-out infinite; }
@keyframes ping { from { transform: scale(0.6); opacity: 1; } to { transform: scale(2.3); opacity: 0; } }
.seq-marker .cross::before, .seq-marker .cross::after { content: ''; position: absolute; background: var(--red); box-shadow: 0 0 8px rgba(226, 87, 63, 0.6); }
.seq-marker .cross::before { left: -54px; top: -1.5px; width: 108px; height: 3px; }
.seq-marker .cross::after { left: -1.5px; top: -48px; width: 3px; height: 102px; }
.seq-marker-label {
  position: absolute; left: 62px; top: 26px; min-width: 300px; padding: 12px 18px;
  border: 1px solid rgba(226, 87, 63, 0.75); background: rgba(3, 15, 15, 0.9);
  display: flex; flex-direction: column; gap: 4px; white-space: nowrap;
}
.seq-marker.left .seq-marker-label { left: auto; right: 66px; }
.seq-marker-label b { font-weight: 500; font-size: 32px; letter-spacing: 0.12em; color: var(--cream); }
.seq-marker-label span { font-size: 22px; color: var(--sand); letter-spacing: 0.08em; }
.seq-marker-label em { font-style: normal; font-size: 21px; color: var(--red); letter-spacing: 0.08em; }
.seq-marker-label :empty { display: none; }

/* ------------------------------------------------------------------ Z3: Eingabe */

#input-panel {
  position: absolute; z-index: 5; left: 72px; top: 1312px; width: 936px; height: 368px;
  background: rgba(3, 15, 15, 0.91); border: 2px solid var(--line);
  clip-path: polygon(0 22px, 22px 0, calc(100% - 22px) 0, 100% 22px, 100% calc(100% - 22px), calc(100% - 22px) 100%, 22px 100%, 0 calc(100% - 22px));
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.44);
}
#input-panel::before {
  content: ''; position: absolute; inset: 10px; pointer-events: none; border: 1px solid rgba(161, 155, 113, 0.13);
  clip-path: polygon(0 15px, 15px 0, calc(100% - 15px) 0, 100% 15px, 100% calc(100% - 15px), calc(100% - 15px) 100%, 15px 100%, 0 calc(100% - 15px));
}
#panel-heading {
  position: absolute; left: 20px; right: 20px; top: 22px; text-align: center;
  font-size: 47px; font-weight: 500; letter-spacing: 0.12em; color: var(--cream);
  text-shadow: 0 0 11px rgba(245, 228, 181, 0.2); white-space: nowrap;
}
#feedback {
  position: absolute; top: 84px; left: 22px; right: 22px; height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--dim); font-size: 26px; line-height: 1.4; letter-spacing: 0.005em;
}
#feedback.warning { color: var(--red); }
#feedback.confirm { color: var(--ok); font-size: 28px; }
#feedback.complete { color: var(--cream); font-size: 24px; }
#feedback.duplicate { color: var(--amber); font-size: 28px; }
#digits { position: absolute; top: 172px; left: 0; right: 0; display: flex; justify-content: center; gap: 24px; }

/* Prüfcodes: Segmente und „Prüfcode 1/3“ als eigene Zeile unter der Überschrift */
#slots { position: absolute; top: 82px; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
#slots[hidden] { display: none; }
#slots i { width: 52px; height: 14px; border: 2px solid rgba(232, 169, 58, 0.55); }
#slots i.done { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 8px rgba(232, 169, 58, 0.5); }
#slots i.now { border-color: var(--amber); animation: blink 1s steps(1) infinite; }
[data-stage='verify'] #feedback { top: 112px; height: 40px; font-size: 21px; }
#slots b { order: -1; margin-right: 14px; font-size: 26px; font-weight: 500; letter-spacing: 0.1em; color: var(--amber); font-variant-numeric: tabular-nums; }
.digit {
  position: relative; width: 128px; height: 148px;
  border: 2px solid var(--line); background: rgba(17, 30, 28, 0.92);
  display: flex; align-items: center; justify-content: center;
  font-size: 88px; line-height: 1; font-weight: 500; color: var(--cream);
  text-shadow: 0 0 12px rgba(245, 228, 181, 0.26); font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, opacity 0.3s;
}
.digit.is-next { border-color: rgba(159, 214, 164, 0.75); }
.digit.is-next::after {
  content: ''; position: absolute; bottom: -17px; left: calc(50% - 36px); width: 72px; height: 4px;
  background: var(--cream); box-shadow: 0 0 9px rgba(255, 255, 225, 0.6); animation: blink 1s steps(1) infinite;
}
#input-panel.invalid .digit { border-color: var(--red); color: var(--red); }
/* Richtiger Code: Felder kurz weiß */
#input-panel.accepted .digit { border-color: var(--cream); background: rgba(255, 255, 225, 0.85); color: var(--bg); text-shadow: none; transition: none; }
#input-panel.invalid #digits { animation: shake 0.4s linear; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
/* Übertragung (Intro ohne Video): Fortschritt statt Ziffernfeldern */
#progress { position: absolute; top: 184px; left: 110px; right: 110px; display: none; }
[data-stage='intro'] #progress { display: block; }
[data-stage='intro'] #digits { display: none; }
/* Finale: keine Eingabe mehr */
[data-stage='finale'] #input-panel, [data-stage='ended'] #input-panel { display: none; }
#progress .bar {
  position: relative; height: 54px; border: 2px solid var(--line); background: rgba(17, 30, 28, 0.92); padding: 6px;
}
#progress-fill {
  display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--ok) 0 22px, transparent 22px 30px);
  box-shadow: 0 0 12px rgba(159, 214, 164, 0.35); transition: width 0.25s linear;
}
#progress-text { margin-top: 26px; text-align: center; font-size: 30px; letter-spacing: 0.14em; color: var(--sand); font-variant-numeric: tabular-nums; }
#progress-text::after { content: '▌'; margin-left: 6px; color: var(--cream); animation: blink 1s steps(1) infinite; }

/* Eingabe gesperrt (Standby, Übertragung, Wiedergabe) */
#input-panel.locked #panel-heading { color: var(--dim); text-shadow: none; }
#input-panel.locked .digit { opacity: 0.45; }
/* Aktenkoffer: Wahrheiten prüfen */
[data-stage='verify'] #panel-heading { color: var(--amber); }

/* Kurzmeldung „FUNK · FREIGEGEBEN“ */
#notice {
  position: absolute; left: 114px; right: 114px; top: 800px; z-index: 20; transform: translateY(-50%);
  text-align: center; border: 1px solid var(--ok); padding: 11px 20px; background: rgba(3, 19, 15, 0.98);
  font-size: 28px; color: var(--ok); opacity: 0; pointer-events: none; transition: opacity 0.18s;
}
#notice.show { opacity: 1; }

/* ------------------------------------------------------------------ Z4: Status und Fuß */

/* Laufzeit des Einsatzes, unten */
#runtime { position: absolute; left: 72px; top: 1738px; width: 936px; text-align: center; }
#runtime-label { font-size: 23px; letter-spacing: 0.16em; color: var(--dim); }
#runtime-label.red { color: var(--red); animation: blink 1s steps(1) infinite; }
#runtime-value {
  margin-top: 6px; font-size: 64px; font-weight: 500; line-height: 1; letter-spacing: 0.04em;
  color: var(--cream); text-shadow: 0 0 12px rgba(245, 228, 181, 0.22); font-variant-numeric: tabular-nums; white-space: nowrap;
}
#runtime-cs { font-size: 40px; color: var(--sand); margin-left: 2px; }
[data-stage='standby'] #runtime-value { color: var(--dim); text-shadow: none; }
[data-stage='standby'] #runtime-cs { color: var(--dim); }
#monitor.paused #runtime-value { animation: pulse 2s infinite; }
#lamp {
  position: absolute; right: 84px; top: 1824px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 11px rgba(159, 214, 164, 0.65);
}
#lamp.amber { background: var(--amber); box-shadow: 0 0 11px rgba(232, 169, 58, 0.65); animation: blink 1.6s steps(1) infinite; }
#lamp.red { background: var(--red); box-shadow: 0 0 11px rgba(226, 87, 63, 0.7); animation: blink 0.8s steps(1) infinite; }

/* ------------------------------------------------------------------ Flackern */

/* Ständiges leichtes Flimmern (unregelmäßig, kaum sichtbar) */
#flicker {
  position: absolute; inset: 0; z-index: 45; pointer-events: none; background: #000; opacity: 0;
  animation: mains 9.7s steps(1) infinite;
}
@keyframes mains {
  0% { opacity: 0; } 7% { opacity: 0.035; } 8% { opacity: 0; } 23% { opacity: 0.02; } 24% { opacity: 0; }
  41% { opacity: 0.045; } 41.6% { opacity: 0.01; } 42.4% { opacity: 0; } 63% { opacity: 0.025; } 64% { opacity: 0; }
  78% { opacity: 0.04; } 78.5% { opacity: 0; } 91% { opacity: 0.02; } 92% { opacity: 0; }
}
/* Einbruch der Spannung – Werte setzt flicker.js */
#monitor.dip { transition: none; }

/* ------------------------------------------------------------------ Pause */

#paused {
  position: absolute; inset: 50px 50px 48px; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 12, 13, 0.8); opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#monitor.paused #paused { opacity: 1; }
.paused-box {
  min-width: 760px; padding: 52px 60px; text-align: center;
  border: 2px solid rgba(232, 169, 58, 0.7); background: rgba(3, 15, 15, 0.96);
  clip-path: polygon(0 22px, 22px 0, calc(100% - 22px) 0, 100% 22px, 100% calc(100% - 22px), calc(100% - 22px) 100%, 22px 100%, 0 calc(100% - 22px));
}
#paused-title { font-size: 46px; font-weight: 500; letter-spacing: 0.12em; color: var(--amber); animation: pulse 2s infinite; }
#paused-sub { margin-top: 18px; font-size: 25px; letter-spacing: 0.14em; color: var(--dim); }
#paused-sub:empty { display: none; }

/* ------------------------------------------------------------------ Video */

/* Videos hochkant über der ganzen Bühne; Bildzeilen und Flackern bleiben darüber */
#video { position: absolute; inset: 0; z-index: 44; background: #000; }
#video[hidden] { display: none; }
#video video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ------------------------------------------------------------------ Vorlauf */

/* Schwarz über allem: erst der Cursor, dann die Bootsequenz */
#boot { position: absolute; inset: 0; z-index: 58; background: #000; display: none; overflow: hidden; }
[data-stage='dark'] #boot, [data-stage='boot'] #boot { display: block; }
#dark { position: absolute; left: 80px; top: 110px; display: none; font-size: 30px; letter-spacing: 0.08em; color: #d8d8d0; }
[data-stage='dark'] #dark { display: block; }
#dark .cursor { animation: blink 1s steps(1) infinite; }
#boot-lines {
  position: absolute; left: 60px; right: 40px; bottom: 60px; top: 40px;
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  font-size: 21px; line-height: 1.3; color: #f2f2ee; text-shadow: 0 0 6px rgba(255, 255, 255, 0.35); white-space: pre;
}

/* Frage: eingehende Nachricht */
#ask { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(2, 12, 13, 0.55); }
#ask[hidden] { display: none; }
.ask-box {
  min-width: 820px; padding: 56px 60px; text-align: center; animation: viewer-in 0.3s ease-out;
  border: 3px solid var(--amber); background: rgba(3, 15, 15, 0.97); box-shadow: 0 0 40px rgba(232, 169, 58, 0.25);
  clip-path: polygon(0 22px, 22px 0, calc(100% - 22px) 0, 100% 22px, 100% calc(100% - 22px), calc(100% - 22px) 100%, 22px 100%, 0 calc(100% - 22px));
}
#ask-title { font-size: 40px; font-weight: 500; letter-spacing: 0.14em; color: var(--amber); animation: blink 1.2s steps(1) infinite; }
#ask-question { margin-top: 26px; font-size: 50px; font-weight: 500; letter-spacing: 0.1em; color: var(--cream); }
.ask-options { margin-top: 44px; display: flex; justify-content: center; gap: 70px; font-size: 40px; letter-spacing: 0.12em; }
#ask-yes { color: var(--ok); }
#ask-no { color: var(--red); }
