:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --ink: #18231f;
  --muted: #65736e;
  --line: #d8dfd6;
  --accent: #176b5d;
  --accent-strong: #0f4f45;
  --coral: #c9563d;
  --amber: #c98b20;
  --violet: #63558c;
  --ok: #23714f;
  --bad: #ad3b2d;
  --shadow: 0 18px 45px rgba(24, 35, 31, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(238, 244, 239, 0.9), rgba(246, 247, 242, 0.95)),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
}

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

button,
.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  font-weight: 700;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

button.secondary,
.button.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--surface-2);
}

button.warn {
  background: var(--coral);
}

button.warn:hover {
  background: #9d3f2d;
}

button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border-color: var(--line);
}

button:disabled,
.button.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}

input[type="checkbox"] {
  width: auto;
  min-width: 18px;
  min-height: 18px;
}

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

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 700;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0 22px;
}

.brand {
  display: grid;
  gap: 3px;
}

.brand h1,
.brand h2 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  line-height: 1.05;
}

.brand p {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.card {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 1rem;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.88rem;
}

.code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  font-size: clamp(2.25rem, 10vw, 5.4rem);
  font-weight: 900;
  color: var(--accent-strong);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: var(--surface-2);
  color: var(--accent-strong);
  font-weight: 800;
  white-space: nowrap;
}

.pill.warn {
  background: #fae7df;
  color: var(--coral);
}

.pill.gold {
  background: #f6ead3;
  color: #7b4f09;
}

.pill.violet {
  background: #ece8f6;
  color: var(--violet);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  flex: 0 0 auto;
}

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

.player-list {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fbfcf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.timer {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--coral);
}

.question {
  font-size: clamp(1.35rem, 4vw, 2.65rem);
  line-height: 1.16;
  font-weight: 900;
}

.host-question {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  line-height: 1.2;
  font-weight: 900;
}

.truth-box {
  border-left: 5px solid var(--accent);
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 8px;
}

.reveal-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

.reveal-head strong {
  flex: 1 1 280px;
  min-width: 0;
}

.reveal-head .pill {
  flex: 0 0 auto;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.option-card {
  min-height: 72px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  justify-content: flex-start;
  text-align: left;
  line-height: 1.25;
  font-weight: 800;
}

.option-card.correct {
  border-color: var(--ok);
  background: #edf8f1;
}

.option-card.own {
  border-style: dashed;
}

.submission {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf8;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.display-shell {
  min-height: 100vh;
  width: min(1500px, calc(100% - 56px));
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  align-content: center;
  gap: 22px;
}

.display-lobby {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 34px;
  align-items: center;
}

.qr {
  width: min(420px, 80vw);
  border: 12px solid white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.leader {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.rank {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.json-editor {
  min-height: 260px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
}

.phase-band {
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
}

@media (max-width: 820px) {
  .grid.two,
  .grid.three,
  .display-lobby {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .panel {
    padding: 14px;
  }

  .display-shell {
    width: min(100% - 24px, 900px);
    padding: 18px 0;
  }
}
