@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f6f1e7;
  --card: #fffdf8;
  --soft: #f1ebde;
  --ink: #2b2a27;
  --muted: #645f55;
  --line: #ded5c3;
  --edge: #8f846f;
  --brand: #05060a;
  --you-bg: #eaf5e0;
  --you-ink: #1f5e30;
  --accent: #2e4a6b;
  --accent-ink: #ffffff;
  --mark: rgba(140, 214, 96, 0.55);
  --ok: #2f7d44;
  --ok-ink: #ffffff;
  --again: #b8741f;
  --rec: #b83a2e;
  --star: #d29a1e;
  --wrong: #b8741f;
  --wrong-bg: rgba(232, 160, 60, 0.35);
  --missing: #b83a2e;
  --shadow: 0 2px 10px rgba(60, 45, 20, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13171d;
    --card: #1c222b;
    --soft: #242b36;
    --ink: #ece8df;
    --muted: #b0a99c;
    --line: #333c49;
    --edge: #6b7787;
    --brand: #ffffff;
    --you-bg: #22331f;
    --you-ink: #9fdcae;
    --accent: #9dbbe0;
    --accent-ink: #10151c;
    --mark: rgba(104, 170, 72, 0.45);
    --ok: #74c486;
    --ok-ink: #0f1a12;
    --again: #e3a75d;
    --rec: #e2665a;
    --star: #e7b648;
    --wrong: #f0b670;
    --wrong-bg: rgba(227, 167, 93, 0.3);
    --missing: #ef8a7f;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

h1, h2 {
  line-height: 1.2;
}

h2, .phase {
  text-wrap: balance;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.top {
  --inline: max(1rem, calc((100% - 40rem) / 2 + 1rem));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 0.8rem;
  padding: calc(env(safe-area-inset-top) + 0.6rem) var(--inline) 0.8rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex: 1 1 8rem;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.brand > div {
  min-width: 0;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}

.top:has(#role-switch:not([hidden])) .sub {
  display: none;
}

@media (max-width: 29.99rem) {
  .top:has(#role-switch:not([hidden])) .brand img {
    display: none;
  }
}

.sub {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

.scene-filter {
  flex: 1 1 100%;
}

@media (min-width: 40rem) {
  .scene-filter {
    flex: 0 1 18rem;
  }
}

select {
  width: 100%;
  min-height: 52px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: 14px;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom));
}

.view[hidden] {
  display: none;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0 max(0px, calc((100% - 40rem) / 2)) env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}

.tabs button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: 68px;
  font: inherit;
  font-size: 1rem;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  font-weight: 700;
  color: var(--accent);
}

.tabs button[aria-selected="true"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 4px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}

.tabs[hidden],
.scene-filter[hidden],
#role-switch[hidden] {
  display: none;
}

#role-switch {
  flex: 0 0 auto;
  padding-inline: 0.8rem;
}

.picker h2,
.role-group h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.role-group {
  margin-top: 1.6rem;
}

.role-group h2 {
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.role-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.6rem;
}

.btn.role {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.1rem;
  min-height: 72px;
  text-align: left;
  font-weight: 700;
  line-height: 1.25;
}

.btn.role[aria-pressed="true"] {
  background: var(--you-bg);
  border-color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok);
}

.btn.role[aria-pressed="true"]::after {
  content: "✓ deine Rolle";
  font-size: 1rem;
  color: var(--you-ink);
}

.role-count {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

.picker {
  padding-bottom: 1.1rem;
}

.picker h2 {
  font-size: 1.5rem;
}

.picker .help {
  margin-bottom: 0;
}

#view-rolle .actions {
  grid-template-columns: 1fr;
  margin-top: 1.2rem;
}

.cue.own .speaker {
  color: var(--muted);
}

.cue.start .text {
  color: var(--muted);
}

.play-card[data-phase="you"] {
  background: var(--you-bg);
  border: 3px solid var(--ok);
  box-shadow: none;
}

.play-card[data-phase="you"] .phase {
  font-size: 2.1rem;
  color: var(--you-ink);
}

.play-card[data-phase="you"] .help {
  font-weight: 700;
  color: var(--ink);
}

.play-card[data-phase="you"] .josef {
  border-top-color: var(--ok);
}

.play-card[data-phase="you"] .cover .bar {
  border-color: var(--ok);
}

.play-card[data-phase="you"] .speaker {
  color: var(--you-ink);
}

.play-card[data-phase="end"] {
  text-align: center;
}

.play-card .josef .btn {
  margin-top: 0.6rem;
}

.tabs .ico {
  font-size: 1.4rem;
  line-height: 1;
}

.card {
  padding: 1.1rem 1.1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 1rem;
}

.scene {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

.direction {
  margin: 0.4rem 0 0;
  font-size: 1rem;
  font-style: italic;
  color: var(--muted);
}

.speaker {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}

.text {
  margin: 0;
  font-size: 1.2rem;
  white-space: pre-line;
}

.cue {
  margin: 1rem 0 0.7rem;
}

.josef {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--line);
}

.josef-text {
  margin: 0 0 0.6rem;
  font-size: 1.45rem;
  line-height: 1.75;
}

.mark {
  padding: 0.08em 0.3em;
  background: linear-gradient(176deg, transparent 6%, var(--mark) 10%, var(--mark) 88%, transparent 94%);
  border-radius: 0.35em 0.2em 0.4em 0.25em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.josef-text.hint {
  letter-spacing: 0.12em;
}

.josef-text.hint .mark {
  background: none;
  border-bottom: 3px dotted var(--mark);
  border-radius: 0;
}

.cover {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.3rem 0 0.6rem;
}

.cover .bar {
  display: block;
  height: 1.3rem;
  max-width: 100%;
  border: 2px solid var(--line);
  border-radius: 0.6rem;
  background: repeating-linear-gradient(45deg, var(--soft) 0 10px, transparent 10px 20px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 56px;
  min-width: 48px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn:focus-visible,
select:focus-visible,
.tabs button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn.small {
  min-height: 48px;
  font-size: 1rem;
}

.btn.primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.btn.ok {
  color: var(--ok-ink);
  background: var(--ok);
  border-color: var(--ok);
}

.btn.warn {
  border-color: var(--again);
}

.btn.ghost {
  background: transparent;
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn.play {
  margin-top: 0.2rem;
}

.actions {
  position: sticky;
  bottom: calc(68px + env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 0.4rem;
  padding: 0.6rem 0;
  background: var(--bg);
}

.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.count {
  margin: 0;
  font-size: 1rem;
}

.round-head .btn {
  flex: 0 0 auto;
  padding-inline: 0.7rem;
  font-size: 1rem;
  color: var(--muted);
  border-color: var(--line);
}

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0.6rem 0 1rem;
  padding: 0;
  list-style: none;
}

.dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--line);
  border: 3px solid transparent;
  border-radius: 50%;
}

.dot.ok {
  background: var(--ok);
}

.dot.ok::after {
  content: "✓";
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  color: var(--ok-ink);
}

.dot.again {
  background: var(--again);
}

.dot.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.done {
  text-align: center;
}

.done h2 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
}

.done .btn {
  margin-top: 1.2rem;
}

.big-star {
  margin: 0;
  font-size: 3.5rem;
}

.setting {
  margin-bottom: 1rem;
}

.label {
  margin: 0 0 0.4rem;
  font-weight: 700;
}

.seg {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 0.5rem;
}

.seg:has(> :nth-child(4)) {
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: row;
}

@media (min-width: 30rem) {
  .seg:has(> :nth-child(4)) {
    grid-template-columns: repeat(4, 1fr);
  }
}

.seg .btn[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.phase {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
}

.help {
  margin: 0.2rem 0 0.8rem;
  color: var(--muted);
}

.countdown {
  height: 16px;
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--line);
  border-radius: 8px;
}

.countdown span {
  display: block;
  height: 100%;
  background: var(--star);
  transform-origin: left;
  animation-name: fill;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.listen-actions {
  grid-template-columns: 1fr 2fr 1fr;
}

.listen-actions .btn {
  min-height: 64px;
  font-size: 1.3rem;
}

.note {
  margin: 1rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.notice {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  font-weight: 700;
  background: var(--soft);
  border-left: 6px solid var(--rec);
  border-radius: 12px;
}

.progress {
  height: 16px;
  margin: 0.6rem 0 0.9rem;
  overflow: hidden;
  background: var(--line);
  border-radius: 8px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--ok);
  transition: width 0.3s;
}

.status {
  font-size: 1rem;
  color: var(--muted);
}

.status.has {
  font-weight: 700;
  color: var(--ok);
}

.status.live {
  font-weight: 700;
  color: var(--rec);
  font-variant-numeric: tabular-nums;
}

#toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: 30rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  color: var(--bg);
  background: var(--ink);
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#toast.show {
  opacity: 1;
}

.take {
  margin: 1rem 0 0.4rem;
  padding: 0.9rem 1rem;
  background: var(--soft);
  border: 3px solid transparent;
  border-radius: 14px;
  scroll-margin-top: 0.8rem;
}

.take[data-phase="cue"],
.take[data-phase="starting"] {
  border-color: var(--accent);
}

.take[data-phase="listen"] {
  background: var(--you-bg);
  border-color: var(--ok);
}

.take[data-phase="listen"] .phase {
  font-size: 2.1rem;
  color: var(--you-ink);
}

.take[data-phase="listen"] .help {
  font-weight: 700;
  color: var(--ink);
}

.take[data-result="pass"] {
  background: var(--you-bg);
  border-color: var(--ok);
}

.take[data-result="pass"] .phase {
  color: var(--you-ink);
}

.take[data-result="fail"] {
  border-color: var(--again);
}

.take[data-phase="silent"],
.take[data-phase="error"] {
  border-color: var(--rec);
}

.take .help {
  margin-bottom: 0;
}

.take .countdown {
  margin: 0.7rem 0 0;
}

.take[data-phase="listen"] .phase::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-left: 0.4em;
  vertical-align: middle;
  background: var(--rec);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

.meter {
  height: 14px;
  margin-top: 0.7rem;
  overflow: hidden;
  background: var(--line);
  border-radius: 7px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ok);
  transition: width 0.08s linear;
}

.josef-text.checked .mark {
  background: none;
  padding: 0;
}

.w {
  display: inline-block;
  margin-block: 0.1em;
  padding: 0 0.2em;
  vertical-align: top;
  border-radius: 0.3em;
}

.w-ok {
  background: var(--mark);
}

.w-wrong {
  background: var(--wrong-bg);
  text-decoration: underline wavy var(--wrong);
  text-underline-offset: 0.2em;
}

.w-missing {
  color: var(--missing);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  outline: 2px dashed var(--missing);
  outline-offset: -2px;
}

.heard {
  display: block;
  padding-bottom: 0.15em;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
}

.heard::before {
  content: "gehört: ";
}

.extra {
  margin: 0 0 0.6rem;
  color: var(--muted);
}

.take-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.listen-actions + .actions {
  position: static;
  grid-template-columns: 1fr;
  margin-top: 0;
  padding-top: 0;
}

.listen-actions + .actions .btn.primary {
  color: var(--ink);
  background: var(--card);
  border-color: var(--edge);
}

#view-stueck .setting {
  margin: 1.1rem 0 0;
}

#view-stueck .actions + .setting,
#view-stueck .actions + .actions + .setting {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.tabs button:focus-visible {
  outline-offset: -4px;
}

@media (prefers-reduced-motion: reduce) {
  .take[data-phase="listen"] .phase::after {
    animation: none;
  }

  .countdown span {
    animation: none;
    transform: scaleX(1);
  }

  .progress span,
  .meter span,
  #toast {
    transition: none;
  }

  .btn:not(:disabled):active {
    transform: none;
  }
}

.sender {
  display: flex;
  justify-content: center;
  margin-top: 3rem;
  padding: 1.5rem 0 0.5rem;
  border-top: 1px solid var(--line);
  color: var(--brand);
}

.wordmark {
  display: block;
  width: 144px;
  height: auto;
}

.brand-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  text-decoration: none;
  min-height: 48px;
  min-width: 48px;
  color: inherit;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.powered {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.guide {
  margin: 0 0 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.guide summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 1rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}

.guide summary::-webkit-details-marker {
  display: none;
}

.guide summary::after {
  content: "▾";
  margin-left: auto;
  transition: transform 0.2s;
}

.guide[open] summary::after {
  transform: rotate(180deg);
}

.guide summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 16px;
}

.guide-body {
  padding: 0 1rem 1rem;
}

.guide-body p {
  margin: 0 0 0.6rem;
}

.guide-body ol,
.guide-body ul {
  margin: 0 0 0.6rem;
  padding-left: 1.4rem;
}

.guide-body li + li {
  margin-top: 0.4rem;
}

.guide-body ul {
  color: var(--muted);
  margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
  .guide summary::after {
    transition: none;
  }
}
