:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --card: #ffffff;
  --accent: #1a1a1a;
  --accent-fg: #ffffff;
  --error: #b00020;
  --good: #1f7a3a;
  --bad: #b00020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

#app {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 { font-size: 1.8rem; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); min-height: 1.2em; }
.hidden { display: none !important; }

.screen { display: flex; flex-direction: column; gap: 16px; }

label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 8px;
}

input[type="text"], input[type="number"], textarea {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  font-size: 1rem;
  font-family: inherit;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--fg);
}

textarea { resize: vertical; }

button {
  padding: 10px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--fg); }
button.link { background: none; border: none; color: var(--muted); padding: 0; text-decoration: underline; cursor: pointer; }

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

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .grid-two { grid-template-columns: 1fr; }
}

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

.letter-box { text-align: center; }
.letter {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--fg);
  min-width: 60px;
  text-align: right;
}
.timer.warn { color: var(--error); }

ul#player-list { list-style: none; padding: 0; margin: 0; }
ul#player-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
ul#player-list li:last-child { border-bottom: none; }
.host-tag { font-size: 0.7rem; background: var(--fg); color: var(--accent-fg); padding: 2px 6px; border-radius: 4px; margin-left: 6px; }
.you-tag { font-size: 0.7rem; color: var(--muted); margin-left: 6px; }

.cat-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.cat-row label { margin: 0; color: var(--fg); }
.cat-row input { margin: 0; }

@media (max-width: 480px) {
  .cat-row { grid-template-columns: 1fr; gap: 4px; }
}

.vote-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--card);
}
.vote-block h4 { margin: 0 0 8px; font-size: 1rem; }

.vote-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.vote-row:first-of-type { border-top: none; }
.vote-row .name { color: var(--muted); font-size: 0.85rem; }
.vote-row .answer { font-weight: 500; }
.vote-row .answer.empty { color: var(--muted); font-style: italic; }

.vote-buttons { display: flex; gap: 4px; }
.vote-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.vote-btn.active.yes { background: var(--good); color: white; border-color: var(--good); }
.vote-btn.active.no { background: var(--bad); color: white; border-color: var(--bad); }
.vote-tally { font-size: 0.8rem; color: var(--muted); min-width: 48px; text-align: right; }

.result-cat {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.result-cat:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.result-cat h4 { margin: 0 0 6px; font-size: 0.95rem; }
.result-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.95rem;
}
.result-row .pts { font-weight: 600; min-width: 40px; text-align: right; }
.result-row.invalid { color: var(--muted); text-decoration: line-through; }

ol#scoreboard, ol#final-scoreboard {
  padding-left: 24px;
  margin: 8px 0 0;
}
ol#scoreboard li, ol#final-scoreboard li {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
}
ol#scoreboard li strong, ol#final-scoreboard li strong { font-variant-numeric: tabular-nums; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}
