:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-alt: #e9eeea;
  --ink: #18211d;
  --muted: #647069;
  --line: #cbd3ce;
  --accent: #275f4b;
  --accent-soft: #deebe5;
  --signal: #d9ed58;
  --danger: #a72f2b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body[data-game="chaoskette"] {
  --accent: #a92f61;
  --accent-soft: #f4dce7;
}

body[data-game="rankingrumble"] {
  --accent: #3e57a6;
  --accent-soft: #e2e7f5;
}

body[data-game="captionbattle"] {
  --accent: #a8481f;
  --accent-soft: #f3e2d9;
}

body[data-game="bombenwort"] {
  --accent: #a52d2d;
  --accent-soft: #f3dddd;
}

body[data-game="zweiwahrheiten"] {
  --accent: #267154;
  --accent-soft: #dcece4;
}

* {
  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;
}

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

.app {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(44px, 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: 44px;
}

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

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

.status {
  justify-self: end;
  color: #923d38;
  font-size: 12px;
  font-weight: 850;
}

.status.online {
  color: #267154;
}

.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: 88px;
  height: 88px;
  margin-bottom: 24px;
  border-radius: 8px;
}

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

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

h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1.03;
  overflow-wrap: anywhere;
}

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

.subtitle {
  max-width: 560px;
  margin: 16px 0 32px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.48;
}

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

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

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

textarea {
  min-height: 126px;
  resize: vertical;
  line-height: 1.45;
}

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

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

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

.secondary-button {
  border: 1px solid #aab6b0;
  background: transparent;
  color: #34423a;
}

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

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: #7a8680;
  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: 800;
}

.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: 15px;
}

.player-list,
.ranking-list,
.result-list,
.order-list,
.chain-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 #d7ded9;
}

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

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

.lobby-hint {
  margin-top: 20px;
}

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

.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 240px);
}

.lobby-actions,
.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 23px;
}

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

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

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

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

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

.score-pill {
  flex: 0 0 auto;
  min-width: 103px;
  padding: 9px 11px;
  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: 118px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

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

.prompt p {
  margin: 0;
  font-size: 24px;
  font-weight: 850;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.prompt-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 17px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-alt);
}

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

.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: #dce2de;
}

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

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

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

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

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

.choice-button:disabled {
  opacity: 0.52;
}

.drawing-shell {
  display: grid;
  gap: 12px;
}

.drawing-source {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.35;
}

.drawing-canvas-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #ffffff;
}

.drawing-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.drawing-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.tool-button,
.color-button,
.size-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #b9c3be;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
}

.color-button::before {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 50%;
  background: var(--swatch);
  content: "";
}

.tool-button.active,
.color-button.active,
.size-button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.size-dot {
  border-radius: 50%;
  background: currentColor;
}

.source-drawing {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
}

.order-list {
  display: grid;
  gap: 8px;
  counter-reset: rank;
}

.order-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  counter-increment: rank;
}

.order-item::before {
  color: var(--accent);
  font-weight: 900;
  content: counter(rank) ".";
}

.order-name {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.order-controls {
  display: flex;
  gap: 5px;
}

.order-control {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid #b9c3be;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.direction-label {
  margin: 0 0 13px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
}

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

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

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

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

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

.result-detail {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.correct-order {
  display: grid;
  gap: 0;
  margin-bottom: 24px;
  padding: 0;
  list-style: none;
  counter-reset: correct;
}

.correct-order li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: correct;
}

.correct-order li::before {
  color: var(--accent);
  font-weight: 900;
  content: counter(correct) ".";
}

.correct-order small {
  color: var(--muted);
}

.caption-option {
  text-align: left;
}

.caption-option small {
  color: var(--muted);
}

.bomb-stage {
  display: grid;
  justify-items: center;
  padding: 18px 0 24px;
  text-align: center;
}

.bomb-timer {
  display: grid;
  place-items: center;
  width: 142px;
  height: 142px;
  border: 8px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 46px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.bomb-current {
  margin: 17px 0 4px;
  font-size: 22px;
  font-weight: 900;
}

.word-history {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.word-chip {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
}

.word-chip strong {
  color: var(--accent);
}

.statement-list {
  display: grid;
  gap: 12px;
  margin-bottom: 15px;
}

.statement-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.lie-radio {
  width: 22px;
  min-height: 22px;
  margin: 14px 0 0 7px;
  accent-color: var(--accent);
}

.inspiration-list {
  margin: 0 0 18px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.45;
}

.truth-option.lie {
  border-color: var(--danger);
  box-shadow: inset 4px 0 var(--danger);
}

.truth-option.truth {
  border-color: #4d8d69;
}

.chain-list {
  display: grid;
  gap: 34px;
}

.chain {
  padding-top: 17px;
  border-top: 3px solid var(--ink);
}

.chain h3 {
  margin: 0 0 14px;
  font-size: 20px;
}

.chain-step {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.chain-step-label {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.chain-step p {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.4;
}

.chain-step img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 5px;
  object-fit: contain;
  background: #ffffff;
}

.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: 520px) {
  h1 {
    font-size: 38px;
  }

  .game-header {
    align-items: start;
  }

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

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

  .prompt p {
    font-size: 21px;
  }

  .order-item {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  .correct-order li {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .correct-order small {
    grid-column: 2;
  }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #171b19;
    --surface: #242a27;
    --surface-alt: #303834;
    --ink: #f1f4f1;
    --muted: #aab5ae;
    --line: #48534d;
  }

  input,
  select,
  textarea,
  .choice-button,
  .score-pill,
  .order-item,
  .word-chip,
  .tool-button,
  .color-button,
  .size-button,
  .bomb-timer {
    border-color: #505c55;
    background: var(--surface);
    color: var(--ink);
  }

  .secondary-button {
    border-color: #5a665f;
    color: #e5eae6;
  }

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

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

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

  .progress-line {
    background: #39413d;
  }
}
