:root {
  color-scheme: light;
  --bg: #f4f3ee;
  --surface: #ffffff;
  --ink: #1b2023;
  --muted: #657177;
  --line: #cbd2d4;
  --accent: #147d8e;
  --accent-soft: #dceff0;
  --signal: #d6ed55;
  --danger: #ad332e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body[data-game="gruppenzwang"] {
  --accent: #bd3f50;
  --accent-soft: #f5dfe2;
}

body[data-game="knappdaneben"] {
  --accent: #147d8e;
  --accent-soft: #dceff0;
}

body[data-game="gleichklang"] {
  --accent: #4b61b2;
  --accent-soft: #e2e7f7;
}

body[data-game="katastrophenrat"] {
  --accent: #a95a15;
  --accent-soft: #f4e5d6;
}

body[data-game="missionen"] {
  --accent: #267044;
  --accent-soft: #dcecdf;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(42px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  margin-bottom: 46px;
}

.back-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.mini-title {
  font-size: 14px;
  font-weight: 850;
}

.status {
  justify-self: end;
  color: #8a3e38;
  font-size: 12px;
  font-weight: 800;
}

.status.online {
  color: #277044;
}

.screen {
  animation: appear 180ms ease-out;
}

@keyframes appear {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-mark {
  display: block;
  width: 84px;
  height: 84px;
  margin-bottom: 24px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 23px;
}

.subtitle {
  max-width: 540px;
  margin: 18px 0 34px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.field-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #536168;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #b8c2c6;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), white 45%);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.choice-button {
  width: 100%;
  min-height: 52px;
  border-radius: 4px;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.secondary-button {
  border: 1px solid #aeb9bd;
  background: transparent;
  color: #344147;
}

.text-button {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: #7b8589;
  font-size: 12px;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.error {
  min-height: 21px;
  margin: 10px 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 750;
}

.room-code {
  padding: 18px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.room-code span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.room-code strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 48px;
  letter-spacing: 0;
}

.section {
  padding: 25px 0;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.player-list,
.ranking-list,
.result-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-list li,
.ranking-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  border-bottom: 1px solid #d8dddf;
}

.player-name {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.player-meta {
  color: var(--muted);
  font-size: 12px;
}

.kick-button {
  width: 38px;
  min-height: 38px;
  border: 1px solid #ccd3d5;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.lobby-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.game-header h1 {
  font-size: 34px;
}

.round-label {
  flex: none;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.score-strip {
  display: flex;
  gap: 8px;
  margin: 0 -18px 24px;
  padding: 0 18px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.score-strip::-webkit-scrollbar {
  display: none;
}

.score-pill {
  flex: 0 0 auto;
  min-width: 104px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.score-pill.me {
  border-color: var(--accent);
  box-shadow: inset 0 -3px var(--accent);
}

.score-pill span {
  display: block;
  max-width: 120px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill strong {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.prompt-box {
  padding: 24px 0;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.prompt-box p {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.phase-content {
  padding-top: 22px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.choice-button {
  min-height: 64px;
  padding: 12px;
  border: 1px solid #b9c3c6;
  background: var(--surface);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.choice-button.selected,
.choice-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.waiting {
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

.waiting strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 19px;
}

.progress-line {
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 3px;
  background: #dce1e2;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.host-action {
  margin-top: 18px;
}

.reveal-title {
  margin-bottom: 18px;
}

.result-list li {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.result-row strong {
  overflow-wrap: anywhere;
}

.result-row span {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.result-detail {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.vote-bar {
  height: 7px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 3px;
  background: #dce1e2;
}

.vote-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.answer-value {
  color: var(--accent);
  font-size: 34px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.estimate-unit {
  margin: 0 0 15px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.result-list .estimate-result {
  padding-inline: 12px;
}

.estimate-result.earned {
  border-left: 4px solid var(--signal);
  background: color-mix(in srgb, var(--signal), transparent 86%);
}

.round-points {
  min-width: 56px;
  color: var(--muted);
  text-align: right;
}

.estimate-result.earned .round-points {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.group-result {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.group-result.matched {
  box-shadow: inset 4px 0 var(--signal);
  padding-left: 13px;
}

.group-result p {
  margin: 5px 0 0;
  color: var(--muted);
}

.mission-box {
  padding: 22px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
}

.mission-box span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.mission-box p {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
}

.mission-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 15px;
}

.notice {
  margin: 0 0 16px;
  padding: 12px;
  border-left: 4px solid var(--signal);
  background: var(--surface);
  color: #4e5a5f;
}

.review-counts {
  display: flex;
  gap: 20px;
  margin: 18px 0;
  font-weight: 850;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.ranking-list li {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.rank {
  color: var(--accent);
  font-weight: 900;
}

.rank-score {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  h1 {
    font-size: 40px;
  }

  .choice-grid,
  .config-grid {
    grid-template-columns: 1fr;
  }

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

@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #15191b;
    --surface: #22282b;
    --ink: #f2f4f1;
    --muted: #aab4b8;
    --line: #465156;
  }

  input,
  select,
  textarea,
  .choice-button,
  .score-pill,
  .mission-box {
    border-color: #4b565b;
    background: var(--surface);
    color: var(--ink);
  }

  .primary-button {
    border-color: var(--signal);
    background: var(--signal);
    color: #15191b;
  }

  .secondary-button {
    border-color: #5b686d;
    color: #e4e8e6;
  }

  .player-list li,
  .ranking-list li {
    border-color: #3d464a;
  }

  .waiting strong,
  .notice {
    color: var(--ink);
  }

  .notice {
    background: var(--surface);
  }

  .progress-line,
  .vote-bar {
    background: #394246;
  }
}
