/* Handy-Ansicht für Teilnehmende. Mobile First, ab 360 Pixel Breite. */

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

.app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  --col: 560px;
  --pad-l: calc(20px + env(safe-area-inset-left));
  --pad-r: calc(20px + env(safe-area-inset-right));
}

/* Kopfzeile */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--pad-r) 0 var(--pad-l);
  background: var(--bg);
}
.logo { flex: none; display: block; height: 30px; width: auto; }
.bar-title {
  flex: 1; min-width: 0;
  padding-left: 12px; border-left: 1px solid var(--line-strong);
  font-family: var(--font-text); font-size: 14px; font-weight: 500; letter-spacing: 0; line-height: 1.25; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-btn {
  flex: none; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: transparent;
  font-size: 13.5px; font-weight: 500; color: var(--navy);
}
.bar-btn:active { background: var(--tint); }

.progress { flex: none; height: 2px; background: var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--navy); transition: width var(--t) var(--ease); }

/* Inhalt */
.main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.view {
  display: flex; flex-direction: column;
  min-height: 100%;
  max-width: var(--col); margin: 0 auto;
  padding: 28px var(--pad-r) 28px var(--pad-l);
  animation: view-in var(--t) var(--ease) both;
}
@keyframes view-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.view.center { justify-content: center; }

.q-title { font-size: clamp(26px, 7.4vw, 36px); overflow-wrap: anywhere; }
/* Lange Fragen kleiner, damit die Eingabe ohne langes Scrollen erreichbar bleibt */
.q-title.is-long { font-size: clamp(21px, 5.9vw, 28px); letter-spacing: -.025em; line-height: 1.12; }
.q-title.is-xlong { font-size: clamp(18px, 5vw, 23px); letter-spacing: -.02em; line-height: 1.18; }
.q-desc { margin-top: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.q-hint { margin-top: 12px; font-size: 14px; color: var(--muted); }
.q-body { margin-top: 28px; }

/* Countdown */
.timer { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.timer-track { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.timer-track i { display: block; height: 100%; width: 100%; background: var(--navy); transform-origin: 0 50%; }
.timer b { flex: none; min-width: 2.2em; text-align: right; font-family: var(--font-display); font-weight: 500; font-size: 20px; font-variant-numeric: tabular-nums; }
.timer.is-low .timer-track i { background: var(--neg); }
.timer.is-low b { color: var(--neg); }

/* Fußleiste mit Hauptaktion */
.dock { flex: none; background: var(--bg); }
.dock-main { max-width: var(--col); margin: 0 auto; padding: 0 var(--pad-r) 0 var(--pad-l); }
.dock-main:not(:empty) { padding-top: 12px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.btn.big { min-height: 54px; font-size: 17px; flex: 1; }
/* Zwei Knöpfe nebeneinander: Der Nebenknopf nimmt nur, was er braucht, der Hauptknopf den Rest */
.dock-main .btn.ghost:not(:only-child) { flex: 0 0 auto; padding: 0 16px; }
.dock.is-quiet .react { display: none; }

/* Auswahl-Optionen */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 12px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
  text-align: left; font-size: 16.5px; line-height: 1.3; overflow-wrap: anywhere;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-fast) var(--ease);
}
.opt:active { transform: scale(.985); }
.opt span { flex: 1; }
.opt-mark { flex: none; position: relative; width: 22px; height: 22px; border: 1.5px solid var(--line-strong); border-radius: 50%; transition: border-color var(--t-fast) ease, background var(--t-fast) ease; }
.opt-mark.is-box { border-radius: var(--r-s); }
.opt-mark::after { content: ""; position: absolute; inset: 4px; border-radius: inherit; background: #fff; transform: scale(0); transition: transform var(--t-fast) var(--ease); }
.opt.is-on { border-color: var(--navy); background: var(--navy); color: #fff; }
.opt.is-on .opt-mark { border-color: #fff; }
.opt.is-on .opt-mark::after { transform: scale(1); }
.opt:disabled { opacity: .5; }
.opt.is-on:disabled { opacity: 1; }

/* Quiz-Kacheln: teilen sich die freie Höhe, damit alle Antworten ohne Scrollen und groß da sind */
.view.is-fill .q-body { flex: 1; display: flex; flex-direction: column; }
.tiles { display: grid; gap: 10px; grid-auto-rows: minmax(64px, 1fr); }
.view.is-fill .tiles { flex: 1; max-height: calc(var(--rows, 4) * 128px); }
.tile {
  min-height: 64px; padding: 14px 16px; border: 1px solid var(--navy); border-radius: var(--r);
  background: var(--navy); color: #fff; font-size: 17px; font-weight: 500; line-height: 1.3; text-align: left; overflow-wrap: anywhere;
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) ease, background var(--t-fast) ease;
}
.tile:nth-child(4n+2) { background: var(--blue); border-color: var(--blue); }
.tile:nth-child(4n+3) { background: #FFFFFF; color: var(--navy); }
.tile:nth-child(4n+4) { background: #45618F; border-color: #45618F; }
.tile:active { transform: scale(.98); }
.tile:disabled { opacity: .35; }
.tile.is-on:disabled { opacity: 1; }

/* Texteingaben */
.stack { display: flex; flex-direction: column; gap: 10px; }
.count { margin-top: 6px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mine { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.mine h3 { font-family: var(--font-text); font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-bottom: 8px; }
.mine p { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }

/* Skala */
.scale-item + .scale-item { margin-top: 26px; }
.scale-item > p { font-weight: 500; margin-bottom: 10px; overflow-wrap: anywhere; }
.segs { display: flex; gap: 6px; }
.segs.is-wrap { display: grid; grid-template-columns: repeat(var(--half, 5), 1fr); }
.seg {
  flex: 1; min-width: 0; min-height: 48px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
  font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) var(--ease);
}
.seg:active { transform: scale(.94); }
.seg.is-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.ends { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* Ranking */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-item { transition: transform var(--t) var(--ease); }
.rank-num { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border: 1.5px solid var(--line-strong); border-radius: var(--r-s); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; color: transparent; }
.opt.is-on .rank-num { border-color: #fff; color: #fff; }

/* 100 Punkte, Schätzfrage, Matrix */
.points-left { position: sticky; top: 0; z-index: 2; margin: -8px 0 16px; padding: 8px 0; background: var(--bg); font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.points-left b { font-family: var(--font-display); font-size: 22px; font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; margin-right: 6px; }
.slide-item + .slide-item { margin-top: 18px; }
.slide-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.slide-head span { font-weight: 500; overflow-wrap: anywhere; }
.slide-head b { flex: none; font-family: var(--font-display); font-weight: 500; font-size: 20px; font-variant-numeric: tabular-nums; }
.slide-row { display: flex; align-items: center; gap: 8px; }
.slide-row .btn.icon { flex: none; }
.slide-sub { display: flex; align-items: center; gap: 12px; }
.slide-sub small { flex: none; width: 5.5em; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-value { display: flex; align-items: baseline; max-width: 100%; font-family: var(--font-display); font-weight: 500; font-size: clamp(56px, 20vw, 88px); letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; margin-bottom: 8px; cursor: text; }
.guess-value small { flex: none; font-size: .35em; letter-spacing: -.01em; color: var(--muted); margin-left: .25em; }
.guess-value.is-unset { color: var(--faint); }
/* Je länger die Zahl, desto kleiner, damit auch Millionen in eine Zeile passen */
.guess-value.is-wide { font-size: clamp(38px, 12.5vw, 60px); }
.guess-value.is-xwide { font-size: clamp(27px, 8.6vw, 42px); }
.guess-input {
  flex: 0 1 auto; min-width: 1.4ch; width: 1.4ch; max-width: 100%; height: 1.16em; padding: 0; margin: 0;
  border: 0; border-bottom: 2px solid var(--line-strong); border-radius: 0; background: transparent;
  font: inherit; letter-spacing: inherit; color: var(--fg); font-variant-numeric: tabular-nums;
  -webkit-appearance: none; appearance: none;
}
.guess-input:focus { outline: none; border-bottom-color: var(--accent); }
.guess-input::placeholder { color: var(--faint); opacity: 1; }
.guess-hint { margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.guess-hint.is-error { color: var(--neg); font-weight: 500; }

/* Ideenboard */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
  font-size: 15px; font-weight: 500; transition: background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.chip.is-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.hints { margin: 18px 0 0; padding: 0 0 0 16px; border-left: 2px solid var(--blue); list-style: none; color: var(--muted); font-size: 15px; animation: view-in var(--t) var(--ease) both; }
.hints li + li { margin-top: 8px; }
.board-form { margin-top: 20px; }

/* Bestätigung und Meldungen */
.state { text-align: left; }
.state h2 { font-size: clamp(34px, 10vw, 52px); }
.state p { margin-top: 12px; color: var(--muted); font-size: 17px; }
.tick { width: 56px; height: 56px; margin-bottom: 24px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; animation: pop var(--t) var(--ease) both; }
.tick svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s .15s var(--ease) forwards; }
.tick.is-neg { background: var(--neg); }
.tick.is-pos { background: var(--pos); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pulse { display: flex; gap: 6px; margin-top: 28px; }
.pulse i { width: 8px; height: 8px; border-radius: 50%; background: var(--navy); opacity: .25; animation: dot 1.3s ease-in-out infinite; }
.pulse i:nth-child(2) { animation-delay: .18s; }
.pulse i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 100% { opacity: .2; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.result-note { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 14px; font-weight: 500; color: var(--pos); }
.result-note.is-muted { color: var(--muted); }
.results { margin-top: 26px; }
.results .viz-cloud { height: 46vh; min-height: 240px; }
.results .viz-cards { columns: 1; }
.results .viz-board { grid-auto-flow: row; }
.results .viz-donut { gap: 1.5em; }
.results .guess-big { gap: 1em 2em; }
.results .guess-big div b { font-size: 2em; }

.big-num { font-family: var(--font-display); font-weight: 500; font-size: clamp(64px, 24vw, 120px); letter-spacing: -.05em; line-height: .95; font-variant-numeric: tabular-nums; }
.big-num small { display: block; margin-top: 10px; font-family: var(--font-text); font-size: 16px; letter-spacing: 0; line-height: 1.4; color: var(--muted); }
.score-line { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
.score-line span { color: var(--muted); }
.score-line b { font-family: var(--font-display); font-weight: 500; font-size: 20px; font-variant-numeric: tabular-nums; }

/* Inhaltsfolie */
.content-body { margin-top: 18px; font-size: 17px; overflow-wrap: anywhere; }
.content-body p + p, .content-body ul + p, .content-body p + ul { margin-top: 12px; }
.content-body ul { margin: 0; padding-left: 1.2em; }
.content-body li + li { margin-top: 6px; }
.content-img { display: block; width: 100%; height: auto; margin-top: 22px; border-radius: var(--r); }

/* Beitreten */
.join-logo { display: block; width: 132px; height: auto; margin-bottom: 44px; }
.join h2 { font-size: clamp(40px, 12vw, 64px); }
.join p { margin-top: 12px; color: var(--muted); font-size: 17px; }
.join form { margin-top: 32px; }
.code-input {
  display: block; width: 100%; height: 76px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
  font-family: var(--font-display); font-weight: 500; font-size: 40px; letter-spacing: .08em; text-align: center; font-variant-numeric: tabular-nums;
}
.code-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(48, 89, 157, .18); }
.code-input::placeholder { color: var(--line-strong); }
.join .btn { margin-top: 12px; }
.error { margin-top: 12px; color: var(--neg); font-size: 15px; font-weight: 500; min-height: 1.5em; }
.name-box { margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); }
.name-box p { margin: 0 0 12px; font-size: 15px; }
.name-row { display: flex; gap: 8px; }
.name-row .input { flex: 1; min-width: 0; }

/* Reaktionen */
.react { display: flex; justify-content: center; gap: 10px; padding: 8px var(--pad-r) calc(10px + env(safe-area-inset-bottom)) var(--pad-l); }
.dock-main:not(:empty) + .react { padding-top: 0; margin-top: -4px; }
.dock-main:not(:empty):has(+ .react:not([hidden])) { padding-bottom: 12px; }
.react button {
  position: relative; display: grid; place-items: center; width: 52px; height: 44px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: transparent; color: var(--navy);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) ease;
}
.react button:active { transform: scale(.9); background: var(--tint); }
.fly { position: fixed; z-index: 50; pointer-events: none; color: var(--blue); animation: fly 1s var(--ease) forwards; }
@keyframes fly { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-140px) scale(1.5); } }

/* Hinweise erscheinen oben, damit sie den Absenden-Knopf nicht verdecken */
.toast { position: absolute; bottom: auto; top: calc(66px + env(safe-area-inset-top)); max-width: calc(100% - 32px); transform: translate(-50%, -12px); }

/* Verbindungshinweis */
.banner {
  position: absolute; left: 50%; top: calc(62px + env(safe-area-inset-top)); z-index: 40; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: var(--r); background: var(--navy); color: #fff; font-size: 14px;
  box-shadow: 0 10px 30px -10px rgba(10, 20, 40, .5);
}

/* Fragen-Blatt */
.sheet {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg);
  animation: sheet-in var(--t) var(--ease) both;
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 10px var(--pad-l); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 22px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; }
.sheet-body > div { max-width: var(--col); margin: 0 auto; padding: 20px var(--pad-r) calc(24px + env(safe-area-inset-bottom)) var(--pad-l); }
.qa-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.qa-form .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qa-form .row small { color: var(--muted); font-size: 13px; }
.qa-empty { padding: 28px 0; color: var(--muted); }

.noscript { padding: 24px; }

/*
 * Die Tastatur ist offen (Klasse kommt aus app.js): Kopfzeile und Reaktionen machen
 * Platz, damit auf kleinen Handys Frage, Eingabe und Absenden-Knopf zugleich sichtbar sind.
 */
.kb .bar, .kb .progress, .kb .react, .kb .join-logo { display: none; }
.kb .view { padding-top: 16px; padding-bottom: 12px; animation: none; }
.kb .view.center { justify-content: flex-start; }
.kb .q-body { margin-top: 16px; }
.kb .dock-main:not(:empty) { padding-top: 8px; padding-bottom: 8px; }
.kb .join h2 { font-size: 30px; }
.kb .join form { margin-top: 16px; }
.kb .toast, .kb .banner { top: 8px; }
.kb .sheet-head { padding-top: 8px; padding-bottom: 6px; }

/* Finger statt Maus */
.app textarea.input { resize: none; overflow: hidden; }
.app button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (pointer: coarse) {
  /*
   * Regler reagieren nur am Griff, nicht auf der Linie. Sonst verstellt man beim
   * Scrollen durch eine Seite voller Regler ungewollt Werte. Der Griff hat dafür
   * eine fingerbreite, unsichtbare Fläche um sich.
   */
  .app input[type="range"] { pointer-events: none; touch-action: pan-y; }
  .app input[type="range"]::-webkit-slider-runnable-track { background-repeat: no-repeat; background-position: 9px 0; background-size: calc(100% - 18px) 100%; }
  .app input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto; width: 44px; height: 44px; margin-top: -20px;
    border: 9px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 3px var(--surface);
  }
  .app input[type="range"]::-moz-range-thumb {
    pointer-events: auto; width: 26px; height: 26px;
    border: 9px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 3px var(--surface);
  }
}

@media (min-width: 560px) {
  .segs.is-wrap { grid-template-columns: repeat(var(--n, 10), 1fr); }
}
@media (min-width: 700px) {
  .view { padding-top: 56px; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
