@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@200;300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&family=VT323&display=swap');

:root {
  --accent1: #225bce;
  --accent2: #0055ff;
  --accent3: #242ae5;
  --panel-bg: rgba(4, 6, 16, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --text-dim: rgba(255, 255, 255, 0.55);
  --error: #ff5566;
  /* Untertitel: Rot wie das Daten-Overlay der Maske (mask.js overlayColor) */
  --sub: #ff3a2a;
  --glow-pad: 90px; /* Platz um Untertitel fuer den Schein (Weichzeichner 36 px ~ 2,5x bis zum Ausklingen) */
  --sub-glow: 0 0 7px rgba(255, 50, 30, 0.45), 0 0 18px rgba(255, 40, 20, 0.3), 0 0 36px rgba(255, 30, 10, 0.16);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: radial-gradient(ellipse at 50% 34%, #03050f 0%, #010207 55%, #000 85%);
  overflow: hidden;
  font-family: 'Oxanium', sans-serif;
  color: #fff;
}

#maskCanvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ── START OVERLAY ── */
#startOverlay {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(ellipse at 50% 50%, #060818 0%, #000 80%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  transition: opacity 0.8s ease, visibility 0.8s;
}
#startOverlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#startOverlay h1 {
  font-size: clamp(2.2rem, 7vw, 4.5rem); font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent2), var(--accent1), var(--accent3));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 0.6rem;
}
#startOverlay .sub {
  font-size: 0.85rem; opacity: 0.45; letter-spacing: 0.08em; margin-bottom: 1.4rem;
}
/* Ergebnis: rote Pille Speichern + blaue Pille Neue Prophezeiung, nebeneinander mittig */
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px; }
.action-btn.action-btn-red {
  display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #ff3a2a, #c4161c);
}
.action-btn.action-btn-red:hover:not(:disabled) { box-shadow: 0 0 40px rgba(255, 50, 30, 0.4); }
/* QR-Code zum Mitnehmen: unten rechts, weiss hinterlegt (dunkle QRs scannen schlecht).
   Am Handy unnoetig - da gibt es "Als Bild speichern". */
.qr-box {
  position: fixed; right: 24px; bottom: 24px; z-index: 150;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 0.75rem; letter-spacing: 0.08em; color: var(--text-dim);
}
.qr-box div { background: #fff; } /* Breite setzt main.js: 3 px pro QR-Punkt */
.qr-box svg { display: block; width: 100%; height: auto; shape-rendering: crispEdges; }
.qr-box[hidden] { display: none; }
@media (pointer: coarse) { .qr-box { display: none; } }
/* Unter ~1750 px Breite wuerde der QR-Code die Prophezeiung ueberdecken: rechts Platz lassen,
   schon ab Beginn des Ergebnisses, damit die Schriftgroesse (main.js showResult) passt. */
@media (pointer: fine) and (max-width: 1750px) {
  #panel:has(#screen-result.active) { padding-right: 400px; }
}
.start-tips {
  list-style: none; padding: 0; margin: 0 0 2.2rem; max-width: 34rem;
  font-size: 0.8rem; line-height: 1.7; letter-spacing: 0.04em; opacity: 0.7;
}

/* ── PANEL ── */
#panel {
  position: fixed; inset: 0; z-index: 100;
  /* Panel sitzt unten, damit die Maske oben frei bleibt */
  display: flex; align-items: flex-end; justify-content: center;
  padding: 24px 24px max(64px, 8vh); /* unten Platz fuer den Sprach-Hinweis */
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.8s ease, visibility 0.8s;
}
#panel.visible { opacity: 1; visibility: visible; pointer-events: auto; }

/* Keine Box: alles steht als Untertitel frei ueber der Szene */
.screen {
  display: none;
  width: 100%; max-width: 960px;
  padding: 0 16px;
  text-align: center;
}
.screen.active { display: block; }

/* Untertitel: rot, leuchtend, leicht pixelig (Pixelschrift + feine Rasterzeilen). Sichtbar sind nur die
   letzten Zeilen - aeltere wandern nach oben raus, waehrend die Stimme weiterspricht. */
.reveal-text {
  font-family: 'VT323', monospace;
  font-size: clamp(1.4rem, 2.5vw, 2rem); line-height: 1.2;
  color: var(--sub); text-shadow: var(--sub-glow);
  min-height: 1.2em; max-height: calc(3 * 1.2em);
  /* Rand = Platz fuer den Schein (siehe --glow-pad), sonst schneidet overflow ihn an der Kante ab; die negativen
     Raender gleichen das aus, das Layout bleibt wie vorher. */
  box-sizing: content-box; padding: var(--glow-pad); margin: calc(-1 * var(--glow-pad)) calc(-1 * var(--glow-pad)) calc(1.6rem - var(--glow-pad)); /* 1.6rem: Luft zu Knoepfen und Eingaben darunter */
  pointer-events: none;
  /* safe: laeuft der Text ueber, bleibt er oben scrollbar (typewriter rollt mit) */
  display: flex; flex-direction: column; justify-content: safe flex-end; overflow: hidden;
  white-space: pre-line;
  text-align: justify; text-align-last: center; hyphens: auto; /* Blocksatz, letzte Zeile mittig */
  -webkit-mask-image: repeating-linear-gradient(to bottom, #000 0 2px, rgba(0, 0, 0, 0.6) 2px 3px);
  mask-image: repeating-linear-gradient(to bottom, #000 0 2px, rgba(0, 0, 0, 0.6) 2px 3px);
}
.untyped { visibility: hidden; } /* noch nicht gesprochen, haelt aber schon den Platz (typewriter) */
.reveal-text.camera-title-big { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.1; letter-spacing: 0.06em; max-height: none; }

.progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase;
  opacity: 0.4; margin-bottom: 14px;
}

.prophecy { max-height: calc(100vh - 420px - 2 * var(--glow-pad)); margin-bottom: calc(2.6rem - var(--glow-pad)); } /* waechst von unten bis fast ganz nach oben (main.js showResult) */
.prophecy::-webkit-scrollbar { width: 4px; }
.prophecy::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.error { color: var(--error); }

.dots span {
  opacity: 0; animation: blink 1.4s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } }

#questionForm {
  margin-top: 22px;
  display: flex; flex-direction: column; gap: 14px;
}

textarea#answerInput {
  width: 100%; resize: vertical;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: #fff; font-family: 'Oxanium', sans-serif; font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, visibility 0.2s;
}
textarea#answerInput:focus { border-color: rgba(0, 130, 255, 0.5); }

.action-btn {
  align-self: center;
  padding: 0.9rem 2.6rem;
  font-family: 'Oxanium', sans-serif; font-size: 0.9rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: #000;
  background: linear-gradient(135deg, var(--accent2), var(--accent1));
  border: none; border-radius: 60px; cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s, visibility 0.2s, opacity 0.2s;
}
.action-btn:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 0 40px rgba(0, 100, 255, 0.35);
}
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── MODUS-WAHL (Startscreen) ── */
.start-modes {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px;
}
.mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 250px; padding: 1.1rem 2.2rem;
  font-family: 'Oxanium', sans-serif; color: #000;
  background: linear-gradient(135deg, var(--accent2), var(--accent1));
  border: 1px solid transparent; border-radius: 60px; cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}
.mode-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 50px rgba(0, 100, 255, 0.35);
}
.mode-btn-secondary {
  background: transparent; color: #fff;
  border-color: rgba(90, 150, 255, 0.55);
}
.mode-title {
  font-size: 1rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
}
.mode-desc {
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; letter-spacing: 0.06em; opacity: 0.7;
}

/* ── STILLE FRAGEN (Blick-Modus) ── */
.silent-text { font-size: 1.3rem; }
.silent-hint {
  margin-top: 14px;
  font-size: 0.75rem; letter-spacing: 0.08em; color: var(--text-dim);
}
.silent-bar {
  margin: 22px auto 0; width: 60%; height: 2px;
  background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden;
}
#silentBarFill {
  width: 0; height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent1));
}

[hidden] { display: none !important; }

/* ── KAMERA-EINWILLIGUNG (v2) ── */
.camera-sub {
  margin-top: 14px;
  font-size: 0.95rem; line-height: 1.6; opacity: 0.8;
}
.camera-privacy {
  margin-top: 18px;
  font-size: 0.75rem; line-height: 1.6; color: var(--text-dim);
  list-style: none; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
}
.camera-privacy b { color: rgba(255, 255, 255, 0.85); font-weight: 500; }

/* ── STECKBRIEF (Blitzorakel) ── */
.profile-form {
  display: flex; flex-direction: column; gap: 12px; text-align: left;
}
.profile-form label {
  display: flex; flex-direction: column; gap: 5px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim);
}
.profile-form .optional { text-transform: none; letter-spacing: 0; opacity: 0.7; }
.profile-form input, .profile-form select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px;
  color: #fff; font-family: 'Oxanium', sans-serif; font-size: 0.95rem;
  text-transform: none; letter-spacing: 0;
  outline: none; transition: border-color 0.2s;
}
.profile-form input:focus, .profile-form select:focus { border-color: rgba(0, 130, 255, 0.5); }
.profile-form select option { background: #070b1f; }
.profile-privacy { font-size: 0.7rem; line-height: 1.5; color: var(--text-dim); }
.profile-form .action-btn { margin-top: 4px; }
.profile-hint { margin-bottom: calc(6px - var(--glow-pad)); }

/* ── SPRACHEINGABE ── */
.mic-status {
  min-height: 1.4em; margin: 10px 0;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; letter-spacing: 0.06em;
  color: var(--text-dim);
}
.mic-status.listening::before {
  content: "●"; margin-right: 0.6em; color: var(--error);
  animation: blink 1.4s infinite;
}
.mic-status.error { color: var(--error); }
/* Was die Person gesagt hat: heller Untertitel unter dem roten des Orakels */
.mic-status.heard {
  font-family: 'VT323', monospace; font-size: clamp(1.2rem, 2.2vw, 1.6rem); letter-spacing: 0;
  color: rgba(255, 255, 255, 0.85); text-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}
/* Mit Mikro nur Stimme: Steckbrief-Felder und Antwortfeld erst ohne Mikro (main.js: body.no-mic) */
body:not(.no-mic) #answerInput, body:not(.no-mic) #submitAnswer,
body:not(.no-mic) .profile-form label, body:not(.no-mic) .profile-form .action-btn { display: none; }
.mic-test {
  margin: 28px auto 0; width: min(420px, 100%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--text-dim);
}
.mic-test[hidden] { display: none; }
.mic-meter {
  position: relative; width: 100%; height: 12px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 6px;
}
#micLevel { height: 100%; width: 0; background: var(--text-dim); transition: width 0.05s; }
#micLevel.loud { background: var(--accent1); }
#micMark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--error); }
.mic-test label { display: flex; align-items: center; gap: 8px; }
#voiceStatus {
  position: fixed; bottom: 18px; left: 16px; right: 16px; z-index: 300;
  margin: 0; text-align: center; pointer-events: none;
}
.camera-actions {
  margin-top: 26px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.link-btn {
  background: none; border: none; cursor: pointer;
  font-family: 'Oxanium', sans-serif; font-size: 0.8rem; letter-spacing: 0.08em;
  color: var(--text-dim); text-decoration: underline; text-underline-offset: 4px;
}
.link-btn:hover:not(:disabled) { color: #fff; }
.link-btn:disabled, .camera-actions .action-btn:disabled { opacity: 0.3; cursor: default; }
.camera-status {
  margin-top: 16px; min-height: 1.4em;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; letter-spacing: 0.06em;
  color: var(--text-dim);
}
.camera-status.error { color: var(--error); }

#camVideo {
  /* muss "abgespielt" werden, damit MediaPipe Frames bekommt - aber unsichtbar bleiben */
  position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

#faceDebug {
  position: fixed; right: 12px; bottom: 12px; z-index: 300; /* rechts: links oben steht das HUD */
  max-width: min(420px, calc(100vw - 24px)); max-height: 60vh; overflow: auto;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.8); border: 1px solid var(--border); border-radius: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; line-height: 1.45;
  color: #9fc0ff; white-space: pre-wrap;
}

@media (max-width: 600px) {
  .screen { padding: 28px 22px; border-radius: 16px; }
}

/* ── TITEL: zurueck zur Hauptseite (auf der Startseite steht schon die grosse Ueberschrift) ── */
.home-link {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 300;
  color: #fff; text-decoration: none; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 600;
  font-size: 0.95rem; opacity: 0.75; text-shadow: 0 0 4px #000, 0 0 10px #000;
}
.home-link:hover { opacity: 1; }
body:has(#startOverlay:not(.hidden)) .home-link { display: none; }
.mobile .home-link { top: max(14px, env(safe-area-inset-top)); }

/* ── TON AN/AUS ── */
.sound-btn {
  position: fixed; top: 14px; right: 16px; z-index: 300;
  text-decoration: none; text-transform: uppercase;
}

/* ── SCAN-HUD: gemessene Werte jedes Gesichtsscans ── */
#scanHud {
  position: fixed; top: 14px; left: 16px; z-index: 150; margin: 0;
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; line-height: 1.45; letter-spacing: 0.04em;
  color: rgba(170, 225, 255, 0.8); text-shadow: 0 0 6px rgba(80, 160, 255, 0.6);
  white-space: pre; pointer-events: none;
}
@media (max-width: 600px) { #scanHud { font-size: 0.5rem; } }

/* Ohne Box: kleine Texte bekommen einen dunklen Schein, damit sie ueber der Szene lesbar bleiben */
.camera-sub, .camera-privacy, .camera-status, .progress, .mic-status:not(.heard), .profile-privacy, .silent-hint {
  text-shadow: 0 0 4px #000, 0 0 10px #000, 0 0 18px rgba(0, 0, 0, 0.9);
}

/* Kamera-Einwilligung: Unterschrift und Hinweise je in einer zentrierten Zeile (Schrift skaliert mit der Breite) */
#screen-camera { max-width: none; }
.camera-sub, .camera-privacy li { white-space: nowrap; text-align: center; }
.camera-sub { font-size: clamp(0.55rem, 1.35vw, 0.95rem); }
.camera-privacy { align-items: center; font-size: clamp(0.5rem, 1.1vw, 0.75rem); }

/* Blocksatz wie bei den Untertiteln (.reveal-text), letzte Zeile mittig */
.start-tips, .profile-privacy, .silent-hint, .camera-status, .mic-status {
  text-align: justify; text-align-last: center; hyphens: auto;
}
/* Tipps als ein Textblock: sonst ist jeder Satz eine einzelne (mittige) letzte Zeile */
.start-head { width: fit-content; max-width: 100%; }
.start-tips { max-width: none; width: 0; min-width: 90%; margin-inline: auto; } /* Breite gibt die Ueberschrift vor */
.start-tips li { display: inline; }
.start-tips { hyphens: manual; } /* keine Silbentrennung (z. B. "intui-tiv") */

/* Datenschutz-Hinweis: nur auf dem Kamera-Screen, vor der Einwilligung (nicht waehrend des Gespraechs) */
.camera-privacy-note {
  margin: 14px auto 0; max-width: 46rem; font-size: 0.72rem; line-height: 1.5; color: var(--text-dim);
  text-align: justify; text-align-last: center; hyphens: auto;
  text-shadow: 0 0 4px #000, 0 0 10px #000;
}

/* ── SPRACHWECHSEL (unter Ton an/aus) ── */
.lang-btn {
  position: fixed; top: 44px; right: 16px; z-index: 300;
  text-decoration: none; text-transform: uppercase;
}

/* Die lange Ansprache vor dem Interview: mehr Zeilen sichtbar (waechst nach oben), damit der Anfang nicht wegrutscht */
#screen-intro .reveal-text { max-height: calc(10 * 1.2em); }
