:root {
  --bg: #f6f2ea;
  --surface: #ffffff;
  --ink: #1c1a17;
  --muted: #6b665e;
  --line: #e0d9cc;
  --accent: #1c1a17;
  --accent-ink: #ffffff;
  --good: #1f8a5b;
  --bad: #c23b3b;

  --cat-people: #e2552b;
  --cat-history: #8b6a2f;
  --cat-fiction: #2f6fb0;
  --cat-internet: #7a4bb5;
  --cat-myth: #1f8a6b;
  --cat-odd: #b3780a;
  --cat-custom: #c0407a;
  --cat-adult: #9c1c3a;

  --team-0: #e2552b;
  --team-1: #2f6fb0;
  --team-2: #1f8a6b;
  --team-3: #7a4bb5;

  --radius: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #23211e;
    --ink: #f3efe8;
    --muted: #a39d93;
    --line: #38352f;
    --accent: #f3efe8;
    --accent-ink: #161513;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.45; }

h1, h2 { line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
small { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 4px;
}
.brand { font-weight: 800; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 14px; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen.center {
  min-height: calc(100dvh - 60px);
  justify-content: center;
  text-align: center;
  align-items: stretch;
}

.logo { font-size: 3.2rem; letter-spacing: -0.04em; }
.huge { font-size: 2.8rem; }
.lead { margin: 0; font-size: 1.1rem; }
.muted { margin: 0; color: var(--muted); }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.error { margin: 0; color: var(--bad); font-weight: 600; }

/* Buttons */
.primary {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 16px 20px;
  min-height: 56px;
}
.primary.small { min-height: 44px; padding: 8px 18px; font-size: 1rem; }
.ghost {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  font-weight: 600;
  padding: 12px 16px;
  min-height: 48px;
}
.ghost.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; border-radius: 10px; }
.link {
  border: 0;
  background: none;
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.icon {
  border: 0;
  background: none;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
}

/* Setup */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel h2 { font-size: 1rem; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}
.row + .row { border-top: 1px solid var(--line); padding-top: 10px; }

.team-input { display: flex; align-items: center; gap: 10px; }
input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
input[type="text"]:focus-visible, button:focus-visible {
  outline: 3px solid var(--cat-fiction);
  outline-offset: 2px;
}

.dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot.big { width: 18px; height: 18px; margin-right: 10px; }
.team-0 { background: var(--team-0); }
.team-1 { background: var(--team-1); }
.team-2 { background: var(--team-2); }
.team-3 { background: var(--team-3); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 1.3rem;
  font-weight: 700;
}
.stepper output { min-width: 2.2ch; text-align: center; font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.segmented { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 0 14px; height: 44px; font-weight: 700; }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }

.check { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.check small { flex-basis: 100%; margin-left: 32px; }

.howto { color: var(--muted); font-size: 0.95rem; }
.howto summary { font-weight: 700; color: var(--ink); padding: 8px 0; cursor: pointer; }
.howto ol, .howto ul { padding-left: 1.2rem; margin: 8px 0; }
.howto li { margin-bottom: 6px; }

/* House cards */
.add { display: flex; gap: 8px; }
.custom-list, .results { list-style: none; margin: 0; padding: 0; }
.custom-list li, .results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.results li span { flex: 1; font-weight: 600; }
.results li b { color: var(--good); font-variant-numeric: tabular-nums; }
.results .undone span { text-decoration: line-through; color: var(--muted); }
.empty { color: var(--muted); }

/* Draft */
.hand { display: flex; flex-direction: column; gap: 10px; }
.mini {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 2px solid var(--line);
  border-left: 10px solid var(--cat);
  border-radius: 14px;
  background: var(--surface);
  padding: 10px 12px;
  min-height: 64px;
}
.mini-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mini strong { font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.mini em { color: var(--muted); font-size: 0.85rem; }
.mini .cat { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cat); }
.mini .pts {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  font-weight: 800;
}
.mini.picked { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, var(--surface)); }
.mini.picked .pts { background: var(--cat); color: #fff; }

.sticky {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}

.cat-people { --cat: var(--cat-people); }
.cat-history { --cat: var(--cat-history); }
.cat-fiction { --cat: var(--cat-fiction); }
.cat-internet { --cat: var(--cat-internet); }
.cat-myth { --cat: var(--cat-myth); }
.cat-odd { --cat: var(--cat-odd); }
.cat-custom { --cat: var(--cat-custom); }
.cat-adult { --cat: var(--cat-adult); }

/* Turn */
.turn { min-height: calc(100dvh - 60px); }
.turnbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-weight: 600;
  font-size: 0.95rem;
}
.turnbar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turnbar span:last-child { text-align: right; color: var(--muted); }
.timer { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.low { color: var(--bad); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); transition: width 0.25s linear; }

.card {
  position: relative;
  flex: 1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  border-radius: 24px;
  background: var(--cat);
  color: #fff;
  text-align: center;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 10px 0 color-mix(in srgb, var(--cat) 60%, #000);
  margin-bottom: 10px;
}
.card h2 { font-size: clamp(1.9rem, 9vw, 3rem); font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.card .hint { margin: 0; font-size: 1.05rem; opacity: 0.9; }
.card .cat {
  position: absolute;
  top: 18px;
  left: 22px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}
.card .pts {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--cat);
  font-weight: 800;
  font-size: 1.2rem;
}
.card.to-got { outline: 6px solid var(--good); }
.card.to-skip { outline: 6px solid var(--muted); }

.rule { margin: 0; text-align: center; color: var(--muted); font-weight: 600; }
.actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
.actions button {
  border: 0;
  border-radius: var(--radius);
  min-height: 76px;
  font-size: 1.3rem;
  font-weight: 800;
}
.skip { background: var(--surface); border: 2px solid var(--line) !important; }
.got { background: var(--good); color: #fff; }
.turn .link { align-self: center; }
.paused {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

/* Scores */
.strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; color: var(--muted); font-size: 0.95rem; }
.strip span { display: inline-flex; align-items: center; gap: 2px; }
.strip .now { color: var(--ink); font-weight: 700; }
.strip b { margin-left: 4px; font-variant-numeric: tabular-nums; }

.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scores th { text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.scores td { text-align: right; padding: 12px 6px; }
.scores th { padding: 12px 6px 12px 0; }
.scores thead td { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.scores tbody tr { border-top: 1px solid var(--line); }
.scores .total { font-weight: 800; font-size: 1.2rem; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .bar i { transition: none; }
}
