/* Kurvenraten – nach DESIGN.md: monochrom, zwei Schriftgrößen, Farbe nur als Rückmeldung. */
:root {
  --leinwand: #111317;
  --weiss: #ffffff;
  --grau: #8a8f98;
  --gedimmt: #3a3d42;
  --spur: #1a1c1f;
  --knopf: #1e2023;
  --knopf-gedrueckt: #282a2d;
  --richtig: #00c389;
  --falsch: #ff5a5f;
  --rand: 24px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--leinwand);
  color: var(--weiss);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.screen {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) var(--rand) calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
}

.meta { color: var(--grau); margin: 0; }
.display { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }

/* Pill-Knöpfe */
.pill {
  height: 56px;
  border-radius: 9999px;
  width: 100%;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.15s;
}
.pill:active { transform: scale(0.98); opacity: 0.85; }
.pill-voll { background: var(--weiss); color: var(--leinwand); }
.pill-schmal { width: auto; padding: 0 48px; }

/* Start */
.screen-start { align-items: center; text-align: center; }
.brand {
  margin: 32px 0 0;
  color: var(--grau);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.start-mitte {
  flex: 1;
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 48px;
  padding-top: 15vh;
}
.kurve-klein { width: 100%; height: 80px; overflow: visible; }
.fehler-text { flex: 1; display: flex; align-items: center; }

/* Kopfzeile */
.kopf {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.icon-knopf, .icon-platz {
  width: 44px; height: 44px;
  margin-left: -10px;
  display: flex; align-items: center; justify-content: center;
}
.icon-platz { margin: 0 -10px 0 0; }
.icon-knopf svg { width: 20px; height: 20px; stroke: var(--grau); stroke-width: 2; stroke-linecap: round; fill: none; }
.icon-knopf:active svg { stroke: var(--weiss); }

/* Zähler */
.zaehler { padding-top: 8px; margin-bottom: 24px; min-height: 88px; }
.zaehler-zeile { display: flex; justify-content: space-between; align-items: baseline; }
.klein-gross {
  color: var(--grau);
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.balken { height: 2px; background: var(--spur); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.balken-fuellung { height: 100%; background: var(--grau); border-radius: 2px; transition: width 0.4s; }
.punkte { font-weight: 600; font-size: 16px; }
.wert-zeile { margin: 8px 0 0; text-align: right; }
.wert-zahl { color: var(--grau); }

/* Diagramm */
.diagramm { margin: 8px 0 0; }
.kurve { display: block; width: 100%; height: 200px; overflow: visible; }
.kurve path.linie {
  fill: none;
  stroke: var(--weiss);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: zeichnen 1.2s ease-out forwards;
}
.kurve.richtig path.linie { stroke: var(--richtig); }
.kurve.falsch path.linie { stroke: var(--falsch); }
.kurve circle { fill: var(--richtig); }
.kurve.falsch circle { fill: var(--falsch); }
.kurve.ohne-animation path.linie { animation: none; stroke-dashoffset: 0; }
@keyframes zeichnen { to { stroke-dashoffset: 0; } }
.achse {
  display: flex; justify-content: space-between;
  margin-top: 12px; padding: 0 2px;
  color: var(--grau);
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* Antworten */
.antworten { display: flex; flex-direction: column; margin-top: 40px; }

/* Hülle: klappt eine ausgeblendete Antwort weich zusammen */
.antwort-huelle {
  display: grid;
  grid-template-rows: 1fr;
  margin-bottom: 16px;
  transition: grid-template-rows 0.45s ease, margin-bottom 0.45s ease, opacity 0.3s ease, transform 0.3s ease;
}
.antwort-huelle > div { min-height: 0; overflow: hidden; }
.antwort-huelle.weg { grid-template-rows: 0fr; margin-bottom: 0; opacity: 0; transform: scale(0.94); }

.antwort {
  width: 100%;
  min-height: 56px;
  padding: 12px 24px;
  border-radius: 9999px;
  background: var(--knopf);
  text-align: left;
  color: var(--weiss);
  transition: background 0.25s, color 0.25s, opacity 0.25s, transform 0.1s;
}
.antwort:active { background: var(--knopf-gedrueckt); transform: scale(0.98); }
.antwort-text, .antwort-unter { display: block; }
.antwort-unter { color: var(--grau); transition: color 0.25s; }
@media (hover: hover) { .antwort:hover { background: var(--knopf-gedrueckt); } }

/* Nach der Auswahl */
.aufgeloest .antwort { pointer-events: none; }
.antwort.gewaehlt { background: var(--weiss); color: var(--leinwand); }
.antwort.gewaehlt .antwort-unter { color: #5d6168; }
.antwort.ist-richtig { background: var(--richtig); color: var(--leinwand); font-weight: 600; animation: hervor 0.4s ease-out; }
.antwort.ist-richtig .antwort-unter { color: rgba(14, 16, 19, 0.65); font-weight: 400; }
.antwort.ist-falsch { background: var(--falsch); color: var(--weiss); animation: wackeln 0.4s ease-in-out; }
.antwort.ist-falsch .antwort-unter { color: rgba(255, 255, 255, 0.75); }

@keyframes hervor { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes wackeln {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* Nachspann: kommt unter der richtigen Antwort herein */
.nachspann { margin-top: 8px; text-align: center; opacity: 0; transform: translateY(12px); transition: opacity 0.4s ease, transform 0.4s ease; }
.nachspann.sichtbar { opacity: 1; transform: none; }
.erklaerung { color: var(--weiss); margin: 8px 0 24px; text-align: left; }
.quelle-zeile { text-align: left; }
.weiter-hinweis { margin-top: 16px; text-align: left; }

/* Punkte springen kurz auf */
.punkte.neu { animation: aufspringen 0.45s ease-out; }
@keyframes aufspringen { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.punkte { display: inline-block; }

/* Kurvenfarbe wechselt weich */
.kurve path.linie { transition: stroke 0.3s; }
.quelle { color: var(--grau); margin: 0; font-size: 13px; line-height: 20px; }

/* Ergebnis */
.ergebnis-mitte {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px;
  padding-bottom: 10vh;
}
.punkte-reihe { display: flex; gap: 8px; margin-bottom: 24px; }
.punkte-reihe span { width: 8px; height: 8px; border-radius: 50%; background: var(--richtig); }
.punkte-reihe span.falsch { background: var(--falsch); }


/* ---------- Mehrspieler ---------- */
.name-feld {
  height: 56px;
  border-radius: 9999px;
  border: 0;
  background: var(--knopf);
  color: var(--weiss);
  font: inherit;
  text-align: center;
  padding: 0 24px;
  outline: none;
}
.name-feld:focus { background: var(--knopf-gedrueckt); }
.name-feld::placeholder { color: var(--grau); }
#name-formular { gap: 16px; }
#name-formular .pill { margin-top: 32px; }

.warte-mitte { gap: 16px; max-width: 342px; }
.spieler-liste { display: flex; flex-direction: column; gap: 8px; margin: 24px 0 32px; text-align: left; }
.spieler-zeile { display: flex; align-items: center; gap: 16px; min-height: 40px; }
.spieler-zeile.neu { animation: einblenden 0.4s ease-out; }
.spieler-name { flex: 1; }
.spieler-rolle { color: var(--grau); font-size: 13px; }
.spieler-zahl { margin-top: 24px; }
.warte-mitte .spieler-liste { margin-top: 8px; }
.warte-punkte { display: flex; justify-content: center; gap: 8px; height: 8px; margin-top: 8px; }
.warte-punkte span { width: 8px; height: 8px; border-radius: 50%; background: var(--grau); animation: pulsieren 1.2s ease-in-out infinite; }
.warte-punkte span:nth-child(2) { animation-delay: 0.2s; }
.warte-punkte span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulsieren { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.kachel {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gedimmt);
  color: var(--weiss);
  font-size: 13px; font-weight: 600; line-height: 1;
  transition: opacity 0.25s, background 0.25s;
}
.kachel.eigen { background: var(--weiss); color: var(--leinwand); }
.kachel.offen { opacity: 0.3; }
.kachel.neu { animation: kachel-rein 0.35s cubic-bezier(.3,1.6,.6,1); }
@keyframes kachel-rein { from { transform: scale(0) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes einblenden { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.beantwortet { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; min-height: 32px; }
.beantwortet .kachel { width: 24px; height: 24px; font-size: 11px; }
.mehrspieler .zaehler { min-height: 104px; }
.zeitbalken { transition: width 0.2s linear, background 0.3s; }
.balken.knapp { height: 4px; background: rgba(255, 90, 95, 0.25); animation: blinken 1s ease-in-out infinite; }
.balken.knapp .zeitbalken { background: var(--falsch); }
.balken.sehr-knapp { animation-duration: 0.5s; }
#restzeit.knapp { color: var(--falsch); font-weight: 600; }
.balken { transition: height 0.2s; }
@keyframes blinken { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.antwort { display: flex; align-items: center; gap: 12px; }
.antwort-texte { flex: 1; min-width: 0; }
.antwort-kacheln { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 45%; }
.antwort-kacheln:empty { display: none; }
.antwort-kacheln .kachel { width: 28px; height: 28px; font-size: 12px; box-shadow: 0 0 0 2px var(--leinwand); }
.antwort.gewaehlt .antwort-kacheln .kachel { box-shadow: 0 0 0 2px var(--weiss); }
.antwort:disabled { cursor: default; }
.aufgeloest .antwort:disabled { opacity: 1 !important; }

.weiter-knopf { margin-top: 24px; }

.rang-mitte { width: 100%; justify-content: flex-start; padding-top: 12vh; gap: 32px; }
.rang-liste { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.rang-zeile {
  display: flex; align-items: center; gap: 16px;
  min-height: 56px; padding: 0 24px;
  border-radius: 9999px;
  background: var(--knopf);
  color: var(--grau);
  animation: einblenden 0.4s ease-out both;
}
.rang-zeile.eigen { background: var(--weiss); color: var(--leinwand); }
.rang-platz { width: 24px; }
.rang-name { flex: 1; text-align: left; color: inherit; }
.rang-zeile:not(.eigen) .rang-name { color: var(--weiss); }
.rang-punkte { font-weight: 600; }

/* ---------- Einrichtung ---------- */
.einricht-formular { display: flex; flex-direction: column; gap: 32px; padding: 16px 0 48px; }
.auswahl-gruppe { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.auswahl-gruppe legend { padding: 0; margin-bottom: 8px; }
.segmente { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.segment {
  height: 56px; border-radius: 9999px;
  background: var(--knopf); color: var(--weiss);
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
.segment:active { transform: scale(0.97); }
.segment.aktiv { background: var(--weiss); color: var(--leinwand); font-weight: 600; }
.name-feld.links { text-align: left; }
.hinweis { color: var(--grau); margin: 0; font-size: 13px; line-height: 20px; }
.link-karte { display: flex; flex-direction: column; gap: 8px; }
.link-titel { margin: 0; font-weight: 600; }
.link-text {
  margin: 0; padding: 16px 24px; border-radius: 24px;
  background: var(--knopf); color: var(--grau);
  font-size: 13px; line-height: 20px;
  word-break: break-all; user-select: all; -webkit-user-select: all;
}
.link-knoepfe { display: flex; gap: 8px; margin-top: 8px; }
.link-knoepfe > * { flex: 1; }
.pill-hell { background: var(--knopf); color: var(--weiss); }
.pill-link { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.warnung { margin: 0; padding: 16px 24px; border-radius: 24px; background: rgba(255, 90, 95, 0.12); color: var(--falsch); font-size: 13px; line-height: 20px; }
.bestaetigung { min-height: 24px; text-align: center; color: var(--richtig); }
a.icon-knopf { color: inherit; }

/* Link zum Mehrspieler auf der Startseite */
.start-link { color: var(--grau); text-decoration: none; text-align: center; padding: 8px; }
.start-link:active { color: var(--weiss); }

.entfernen-knopf {
  height: 32px; padding: 0 14px; border-radius: 9999px;
  background: var(--knopf); color: var(--grau); font-size: 13px;
  transition: background 0.2s, color 0.2s;
}
.entfernen-knopf.sicher { background: var(--falsch); color: var(--weiss); }

/* Countdown bis zur nächsten Frage – dezent über dem Diagramm */
.naechste {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  height: 24px; margin: -8px 0 0;
  color: var(--grau); font-size: 13px;
  opacity: 0; transition: opacity 0.4s ease;
}
.naechste.sichtbar { opacity: 1; }
.naechste-ring { width: 18px; height: 18px; flex: none; transform: rotate(-90deg); }
.naechste-ring circle { fill: none; stroke-width: 2.5; }
.ring-spur { stroke: var(--gedimmt); }
.ring-rest { stroke: var(--grau); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset 0.1s linear, stroke 0.3s; }
.naechste-zahl { color: var(--weiss); font-weight: 600; font-variant-numeric: tabular-nums; }
.naechste.knapp .ring-rest { stroke: var(--richtig); }
.weiter-knopf { margin-top: 12px; }

.aendern-hinweis { text-align: center; margin-top: -4px; animation: einblenden 0.3s ease-out; }

/* ---------- Startseite: drei Wege ---------- */
.start-kopf { display: flex; flex-direction: column; gap: 24px; }
.start-knoepfe { display: flex; flex-direction: column; gap: 12px; }
.start-trenner { margin-top: 20px; font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase; }
.code-feld { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 600; }
.code-feld::placeholder { letter-spacing: 0.02em; font-weight: 400; text-transform: none; }
.pill:disabled { opacity: 0.5; }
button.start-link { font-size: inherit; }

/* ---------- Lobby ---------- */
.screen-start .kopf { width: 100%; }
.warte-mitte { justify-content: flex-start; padding-top: 6vh; }
.einladung {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  margin-top: 16px; padding: 24px; border-radius: 24px;
  background: var(--spur);
}
.raum-code {
  margin: 0 0 8px; font-size: 34px; line-height: 40px; font-weight: 600;
  letter-spacing: 0.18em; text-indent: 0.18em; /* optisch mittig trotz Sperrung */
  user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
}
.einladung .link-knoepfe { margin-top: 0; }
.einladung .link-knoepfe .pill { background: var(--knopf-gedrueckt); }
.qr { align-self: center; width: 200px; padding: 14px; border-radius: 16px; background: var(--weiss); line-height: 0; }
.qr svg { display: block; width: 100%; height: auto; }
#beitritt-titel { margin-bottom: 16px; }
