/* Eine Quelle für alle Farben — buehne.js liest sie beim Start von hier. */
:root {
  --grund:            #070a10;
  --feld:             #0f131a;
  --rand:             rgba(255,255,255,.10);
  --schrift:          #eef2f7;
  --leise:            #8b97a8;

  --farbe-ruhe:       #5b7cff;
  --farbe-hoert:      #3ecfff;
  --farbe-denkt:      #b48cff;
  --farbe-spricht:    #e8f0ff;
  --farbe-fehler:     #ff3d5a;

  --farbe-klar:       #3ddc84;
  --farbe-unsicher:   #f5b731;
  --farbe-fraglich:   #ff5c6c;
  --farbe-unbekannt:  #8b97a8;

  --fuss-hoehe: calc(144px + env(safe-area-inset-bottom));
}

/* Der Knopfring trägt den Gesprächszustand — gesetzt wird er von der Bühne. */
body[data-zustand="ruhe"]    { --knopf-farbe: var(--farbe-ruhe); }
body[data-zustand="hoert"]   { --knopf-farbe: var(--farbe-hoert); }
body[data-zustand="denkt"]   { --knopf-farbe: var(--farbe-denkt); }
body[data-zustand="spricht"] { --knopf-farbe: var(--farbe-spricht); }
body:not([data-zustand])     { --knopf-farbe: var(--farbe-ruhe); }

* { box-sizing: border-box; }
/* Ein eigenes display würde das hidden-Attribut aushebeln. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--grund); color: var(--schrift);
  font: 16px/1.55 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Eine einzige, sehr langsam driftende Nebelwolke. Die Zustandsfarbe trägt allein die Kugel. */
body::before {
  content: ""; position: fixed; left: -10vmax; top: 5vh;
  width: 55vmax; height: 55vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(91,124,255,.14), transparent);
  z-index: -1; pointer-events: none;
  animation: nebel 41s ease-in-out infinite alternate;
}
@keyframes nebel { to { transform: translate(14vmax, 10vh); } }

/* Breite und Höhe müssen ausgeschrieben sein: Ein Canvas bringt über seine width/height-
   Attribute eine eigene Größe mit, die inset allein nicht überschreibt. */
#buehne { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

header {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 2;
  display: flex; align-items: center; padding: 0 18px;
  background: linear-gradient(var(--grund), transparent);
}
header h1 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--leise); }
#stand {
  margin-left: auto; padding: 4px 8px; border-radius: 8px; border: none; background: none;
  font: inherit; font-size: 13px; color: var(--leise); font-variant-numeric: tabular-nums; cursor: pointer;
}
#stand:hover, #stand:focus-visible { color: var(--schrift); }

/* Einstellungen — öffnen sich über den Stand in der Kopfzeile, drängen sich nicht auf. */
#einstellungen {
  position: fixed; top: 48px; left: 12px; right: 12px; z-index: 3;
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: rgba(15,19,26,.94); border: 1px solid var(--rand); border-radius: 12px;
  animation: einblenden .2s ease-out;
}
#einstellungen .reihe { display: flex; align-items: center; gap: 8px; }
#einstellungen .reihe > span { font-size: 13px; color: var(--leise); flex: none; }
#stimmenWahl {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; font-size: 14px;
  background: rgba(7,10,16,.6); border: 1px solid rgba(91,124,255,.35);
  border-radius: 8px; color: var(--schrift);
}
#schluessel { display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes einblenden { from { opacity: 0; transform: translateY(-6px); } }
#schluessel input {
  flex: 1; height: 40px; padding: 0 12px; font-size: 15px;
  background: rgba(7,10,16,.6); border: 1px solid rgba(91,124,255,.35);
  border-radius: 8px; color: var(--schrift);
}
#schluessel input.schlecht { border-color: var(--farbe-fraglich); }
#schluessel button {
  height: 40px; padding: 0 16px; font-size: 15px; font-weight: 600;
  background: var(--farbe-ruhe); color: #06080f; border: none; border-radius: 8px; cursor: pointer;
}
#schluessel .fehler { flex-basis: 100%; font-size: 13px; color: var(--leise); }
#schluessel .fehler.schlecht { color: var(--farbe-fraglich); font-size: 14px; }

/* Textspur */
#spur {
  position: fixed; left: 0; right: 0; top: var(--buehne-unten, 52vh); bottom: var(--fuss-hoehe);
  z-index: 1; overflow-y: auto; padding: 8px 18px 12px;
  display: flex; flex-direction: column; gap: 10px; contain: content;
  background: linear-gradient(to bottom, transparent 0, rgba(7,10,16,.9) 12px);
}
@media (min-width: 900px) { #spur { left: max(18px, calc(50% - 360px)); right: max(18px, calc(50% - 360px)); } }
.zeile:first-child { margin-top: auto; }

.zeile {
  max-width: 82%; padding: 11px 15px; border-radius: 16px;
  white-space: pre-wrap; word-break: break-word;
  animation: auftauchen .22s ease-out;
}
@keyframes auftauchen { from { opacity: 0; transform: translateY(8px); } }
.zeile.ich { align-self: flex-end; background: rgba(91,124,255,.22); border: 1px solid rgba(91,124,255,.55); border-bottom-right-radius: 5px; }
.zeile.er { align-self: flex-start; background: rgba(15,19,26,.85); border: 1px solid var(--rand); border-bottom-left-radius: 5px; }
.zeile.hinweis { align-self: center; max-width: 100%; background: none; border: none; padding: 2px 0; font-size: 14px; color: var(--leise); text-align: center; }
.zeile.hinweis.schlecht { color: var(--farbe-fraglich); }
.zeile.hinweis.gut { color: var(--farbe-klar); }
.zeile.vorlaeufig { opacity: .5; }

/* Auftragskarte: hohl = läuft, gefüllt = entschieden. */
.zeile.auftrag {
  align-self: stretch; max-width: 100%; border-radius: 10px;
  padding: 8px 12px 10px 14px; border: none; border-left: 3px solid var(--stufe);
  background: rgba(8,12,20,.6);
}
.zeile.auftrag.klar     { --stufe: var(--farbe-klar); }
.zeile.auftrag.unsicher { --stufe: var(--farbe-unsicher); }
.zeile.auftrag.fraglich { --stufe: var(--farbe-fraglich); }
.zeile.auftrag.fertig      { --stufe: var(--farbe-klar); }
.zeile.auftrag.gescheitert { --stufe: var(--farbe-fehler); }
.auftrag .kopf { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--stufe); }
.auftrag .punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--stufe); flex: none; }
.auftrag.fraglich .punkt { animation: pochen 1.5s ease-in-out 4; }
.auftrag.fertig .punkt, .auftrag.gescheitert .punkt { animation: none; }
@keyframes pochen { 50% { opacity: .5; } }
.auftrag .stufe { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.auftrag .chip {
  margin-left: 8px; padding: 1px 7px; border-radius: 6px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em; background: var(--stufe); color: #071018;
}
.auftrag .hinweis-text { margin-top: 4px; font-size: 14px; color: var(--schrift); }
.auftrag .text { margin-top: 4px; font-size: 15px; color: var(--leise); }

/* Fußleiste */
footer {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--fuss-hoehe); z-index: 2;
  padding: 12px 18px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(7,10,16,.95) 30%);
}
.knopfreihe { display: flex; align-items: center; justify-content: center; gap: 12px; }
.neben { display: flex; flex-direction: column; gap: 8px; }

.pille {
  height: 40px; padding: 0 12px; border-radius: 20px;
  border: 1px solid rgba(127,182,255,.22); background: rgba(12,18,30,.7);
  color: var(--leise); font-size: 13px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s;
}
.pille:hover, .pille:focus-visible { color: var(--schrift); border-color: rgba(127,182,255,.5); }
.pille:has(input:focus-visible) { color: var(--schrift); border-color: rgba(127,182,255,.5); }
/* Die native Box wird versteckt, nicht entfernt — Tastatur und Screenreader brauchen sie. */
.pille input { position: absolute; opacity: 0; width: 0; height: 0; }
.pille span::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; background: rgba(169,180,198,.35); transition: background .15s;
}
.pille input:checked + span::before { background: var(--farbe-klar); }
@media (max-width: 359px) { .pille { font-size: 12px; padding: 0 8px; } }

#knopf {
  width: 76px; height: 76px; border-radius: 50%; flex: none; cursor: pointer;
  background: rgba(7,10,16,.6); color: var(--knopf-farbe);
  border: 2px solid var(--knopf-farbe);
  box-shadow: 0 0 28px color-mix(in srgb, var(--knopf-farbe) 35%, transparent);
  display: flex; align-items: center; justify-content: center;
  transition: border-color .3s, box-shadow .3s, color .3s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
#knopf:active { transform: scale(.94); }
#knopf:focus-visible { outline: 2px solid var(--schrift); outline-offset: 3px; }

#zustand { text-align: center; margin-top: 8px; font-size: 14px; color: var(--leise); min-height: 20px; }

/* Anmeldung */
.mitte {
  position: fixed; left: 50%; transform: translateX(-50%); top: var(--buehne-unten, 52vh);
  z-index: 1; width: min(360px, 88vw); padding: 26px; text-align: center;
  background: rgba(15,19,26,.88); border: 1px solid var(--rand); border-radius: 16px;
}
.mitte h1 { font-size: 21px; margin: 0 0 8px; }
.mitte p { color: var(--leise); margin: 0 0 22px; font-size: 14px; }
.mitte input {
  width: 100%; height: 40px; padding: 0 12px; font-size: 15px;
  background: rgba(7,10,16,.6); border: 1px solid rgba(91,124,255,.35);
  border-radius: 8px; color: var(--schrift);
}
.mitte button {
  width: 100%; height: 40px; margin-top: 11px; font-size: 15px; font-weight: 600;
  background: var(--farbe-ruhe); color: #06080f; border: none; border-radius: 8px; cursor: pointer;
}
.mitte .fehler { color: var(--farbe-fraglich); font-size: 14px; margin-top: 12px; min-height: 20px; }

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .zeile, #schluessel { animation: none; }
  .auftrag.fraglich .punkt { animation: none; }
}
