:root {
  color-scheme: light;
  --paper: #f3e4c8;
  --card: #fffaf2;
  --ink: #241910;
  --muted: #6f5c4b;
  --line: #1c140f;
  --green: #2c6b4a;
  --green-dark: #1e4a33;
  --red: #c73e2a;
  --yellow: #ffd84a;
  --soft: #d7e4ea;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  padding:
    calc(0.8rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.35;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  min-height: 3.25rem;
  padding: 0.7rem 1.15rem;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--green);
  color: var(--card);
  font-weight: 700;
  cursor: pointer;
}

button:active { transform: translateY(1px); }

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button.ghost {
  background: transparent;
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top {
  position: relative;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 0.6rem;
  background: var(--paper);
}

.brand {
  margin: 0;
  font-size: clamp(1.45rem, 3.4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

nav button {
  background: var(--card);
  color: var(--ink);
}

nav button[aria-current="page"],
nav button.nav-info[aria-expanded="true"] {
  background: var(--green);
  color: var(--card);
}

nav button.nav-info {
  width: 3.25rem;
  padding-inline: 0;
}

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel[hidden] { display: none !important; }

.sepp-panel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.face-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 0;
}

.face-wrap canvas {
  width: min(68vmin, 26rem);
  height: min(68vmin, 26rem);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: bob 2.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .face-wrap canvas { animation: none; }
  .quiz-play.is-leaving,
  .quiz-play.is-arriving .quiz-ask,
  .quiz-play.is-arriving .quiz-choices button,
  #quiz-next {
    animation: none;
  }
}

.name-gate {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    7.5rem
    calc(1.2rem + env(safe-area-inset-right))
    calc(1.2rem + env(safe-area-inset-bottom))
    calc(1.2rem + env(safe-area-inset-left));
  overflow: auto;
  background: var(--paper);
}

.name-gate[hidden] { display: none !important; }

.name-card {
  width: min(28rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.name-card p {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
}

.name-card .hint {
  font-size: 1.05rem;
  font-weight: 500;
}

.chat {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  width: min(36rem, 100%);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.2rem 0 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.chat-log > .bubble:first-child { margin-top: auto; }

.chat-empty {
  margin-top: auto;
  align-self: flex-start;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  border: 3px solid var(--line);
  border-radius: 1.15rem 1.15rem 1.15rem 0.35rem;
  background: var(--card);
  text-align: left;
  color: var(--ink);
  font-size: 1.08rem;
}

.bubble {
  max-width: 100%;
  margin: 0;
  padding: 0.55rem 0.85rem;
  border: 3px solid var(--line);
  line-height: 1.3;
  font-size: 1.08rem;
  box-shadow: 0 1px 0 rgba(28, 20, 15, 0.06);
}

.bubble p { margin: 0; }

.bubble.sepp {
  align-self: flex-start;
  text-align: left;
  background: var(--card);
  border-radius: 1.15rem 1.15rem 1.15rem 0.35rem;
}

.bubble.kind {
  align-self: flex-end;
  text-align: right;
  background: var(--green);
  color: var(--card);
  border-radius: 1.15rem 1.15rem 0.35rem 1.15rem;
}

.bubble.pending {
  color: var(--muted);
  letter-spacing: 0.12em;
}

.bubble-meta {
  margin-top: 0.28rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.bubble button {
  min-height: 2.4rem;
  margin-top: 0.45rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.95rem;
}

.stamp {
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.05rem 0.5rem;
  border: 3px solid var(--line);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  transform: rotate(-2deg);
}

.hint,
.lead,
.fine {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.hint { font-size: 1.15rem; }

.lead {
  width: 100%;
  margin-inline: auto;
  font-size: clamp(0.85rem, 1.7vw, 1.2rem);
  white-space: nowrap;
}

.ask {
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.ask input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0.65rem 1rem;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 1.15rem;
}

.ask button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
}

.ask button svg {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
}

.chat .error {
  width: 100%;
  margin-inline: auto;
}

.error {
  margin: 0;
  flex: 0 0 auto;
  padding-block: 0.15rem 0.35rem;
  line-height: 1.4;
  color: var(--red);
  font-weight: 700;
  text-align: center;
}

.error:empty { display: none; }

.heft-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: auto;
}
.heft-panel .lead { align-self: center; }

#editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.heft-sheet {
  --heft-rule: 7.2rem;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

#heft-marks {
  position: absolute;
  z-index: 1;
  left: 3px;
  top: 3px;
  bottom: 3px;
  width: var(--heft-rule);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

#heft-marks span {
  display: block;
  padding-right: 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 2rem;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

textarea {
  width: 100%;
  flex: 1 1 auto;
  min-height: 12rem;
  padding: 0.25rem 1rem 0.25rem calc(var(--heft-rule, 3.55rem) + 1rem);
  border: 3px solid var(--line);
  border-radius: 1rem;
  background-color: var(--card);
  background-image:
    linear-gradient(#e7b2a8, #e7b2a8),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(2rem - 1px),
      #9ecae6 calc(2rem - 1px),
      #9ecae6 2rem
    );
  background-size: 2px 100%, auto;
  background-position: var(--heft-rule, 3.55rem) 0, 0 0.25rem;
  background-repeat: no-repeat, repeat;
  background-attachment: scroll, local;
  font-size: 1.3rem;
  line-height: 2rem;
  resize: vertical;
}

#heft-status {
  margin: 0.4rem 0 0;
  min-height: 1.2em;
  color: var(--green-dark);
  font-weight: 700;
}

::placeholder { color: #8a7764; }

.quiz-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  width: min(34rem, 100%);
  margin-inline: auto;
  padding-block: 0.4rem;
}

.quiz-menu,
.quiz-game {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
}

.quiz-lead,
.quiz-spiel {
  margin: 0;
  text-align: center;
  font-weight: 800;
}

.quiz-lead {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.quiz-spiel {
  color: var(--muted);
  font-size: 0.95rem;
}

.quiz-spiele {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quiz-spiele button {
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  white-space: normal;
  font-weight: 800;
}

#quiz-back {
  align-self: center;
}

.quiz-play,
.quiz-done {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

.quiz-play.is-leaving {
  animation: quiz-leave 0.7s ease forwards;
}

.quiz-play.is-arriving .quiz-ask,
.quiz-play.is-arriving .quiz-choices button {
  animation: quiz-build 0.55s ease both;
}

.quiz-play.is-arriving .quiz-ask { animation-delay: 0.16s; }

.quiz-play.is-arriving .quiz-choices button:nth-child(1) { animation-delay: 0.38s; }
.quiz-play.is-arriving .quiz-choices button:nth-child(2) { animation-delay: 0.56s; }
.quiz-play.is-arriving .quiz-choices button:nth-child(3) { animation-delay: 0.74s; }

@keyframes quiz-leave {
  to {
    opacity: 0;
    transform: translateY(-0.7rem);
  }
}

@keyframes quiz-build {
  from {
    opacity: 0;
    transform: translateY(0.85rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.quiz-progress {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.quiz-progress:empty { display: none; }

.quiz-ask {
  margin: 0;
  text-align: center;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 800;
  line-height: 1.25;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quiz-choices button {
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  white-space: normal;
}

.quiz-choices button.is-wrong { background: #f6d5ce; }

.quiz-choices button.is-right {
  background: var(--green);
  color: var(--card);
}

.quiz-panel:has(.quiz-choices.is-bilder) {
  justify-content: safe center;
}

.quiz-choices.is-bilder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  align-items: stretch;
}

.quiz-choices.is-bilder button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  height: 100%;
  padding: 0.7rem 0.45rem 0.8rem;
}

.quiz-choices.is-bilder button.is-pick {
  background: #fff4c2;
}

.bild-svg {
  display: grid;
  place-items: center;
  width: 100%;
}

.bild-svg svg {
  width: min(100%, 9.5rem);
  height: auto;
  display: block;
}

.bild-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
}

.bild-name {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.2;
}

.bild-untertitel {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
}

.quiz-note {
  margin: 0;
  min-height: 1.4em;
  text-align: center;
  font-weight: 700;
}

.quiz-note:empty { display: none; }

#quiz-next {
  width: 100%;
  animation: quiz-build 0.4s ease both;
}

.quiz-done p {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
}

.quiz-done.is-auswertung {
  border: 3px solid var(--line);
  border-radius: 1.2rem;
  background: var(--card);
  padding: 1.15rem 1.15rem 1.25rem;
}

.quiz-done.is-auswertung #quiz-end {
  font-size: clamp(1.25rem, 2.6vw, 1.5rem);
  line-height: 1.3;
}

.quiz-chart {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quiz-split-bar {
  display: flex;
  height: 1.35rem;
  border: 3px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
}

.quiz-split-bar span {
  display: block;
  min-width: 0.65rem;
}

.quiz-split-bar .is-selbst,
.quiz-split-key .is-selbst { background: var(--green); }

.quiz-split-bar .is-ab,
.quiz-split-key .is-ab { background: #e2b423; }

.quiz-split-key {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 800;
}

.quiz-split-key > span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.quiz-split-key i {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid var(--line);
  border-radius: 0.2rem;
}

#quiz-end-note {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
}

.pause-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  margin: 0;
  background: var(--yellow);
  color: var(--ink);
  pointer-events: auto;
}

.pause-layer p {
  margin: 0;
  font-size: clamp(4.5rem, 18vw, 9rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

html.is-paused,
html.is-paused body {
  overflow: hidden;
  touch-action: none;
}

.info-layer {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding:
    6.5rem
    calc(0.8rem + env(safe-area-inset-right))
    calc(0.8rem + env(safe-area-inset-bottom))
    calc(0.8rem + env(safe-area-inset-left));
  background: var(--paper);
}

.info-card {
  width: min(64rem, 100%);
  margin-block: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.85fr);
  gap: 0.8rem 1.6rem;
  align-items: center;
  padding: 1.15rem 1.3rem 1.4rem;
  border: 3px solid var(--line);
  border-radius: 1.2rem;
  background: var(--card);
}

.info-close {
  grid-column: 1 / -1;
  justify-self: end;
}

.info-copy h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.info-label {
  margin: 1.05rem 0 0.35rem;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.info-copy > .info-label:first-child { margin-top: 0; }

.info-copy p {
  margin: 0;
  font-size: clamp(1.05rem, 1.8vw, 1.22rem);
  line-height: 1.4;
}

.info-points,
.info-places {
  list-style: none;
  margin: 0;
  padding: 0;
}

.info-points {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.info-points li {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--green);
  font-size: clamp(1.02rem, 1.7vw, 1.16rem);
  line-height: 1.35;
}

.info-places {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.info-places li {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 0.45rem;
  align-items: baseline;
  margin: 0;
  font-size: clamp(1.02rem, 1.7vw, 1.16rem);
  line-height: 1.3;
}

.info-copy strong { font-weight: 800; }

.info-share {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-width: 0;
}

.info-kicker,
.info-scan,
.info-url {
  margin: 0;
  text-align: center;
}

.info-kicker {
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  font-weight: 800;
}

.info-kicker:empty { display: none; }

.info-scan {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 700;
}

#info-qr {
  width: min(100%, 24rem, 58vh);
  padding: 0.35rem;
  border: 3px solid var(--line);
  border-radius: 0.9rem;
  background: #fff;
}

#info-qr[hidden] { display: none !important; }

#info-qr svg {
  width: 100%;
  height: auto;
  display: block;
}

.info-url {
  max-width: 100%;
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(0.85rem, 1.5vw, 1.05rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
  user-select: all;
}

.info-url:empty { display: none; }

@media (max-width: 800px) {
  .info-card {
    grid-template-columns: 1fr;
  }

  #info-qr { width: min(100%, 20rem, 70vw); }
}

@media (max-width: 700px) {
  .ask button { width: 3.25rem; padding: 0; }
}
