/* ── Theme ────────────────────────────────────────────────────────────────
   Restyle the whole app by editing these variables. Markup hooks are
   documented in README ("Restyling"). */
:root {
  --c-bg: #111318;
  --c-card: #1b1e26;
  --c-border: #2a2f3a;
  --c-text: #f2f3f5;
  --c-muted: #9aa1ad;
  --c-accent: #7c9cff;
  --c-in: #2fbf71;
  --c-maybe: #f2b63c;
  --c-out: #e5606a;
  --c-confetti: #e879f9;
  --c-on-color: #0d0f13;
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --tap: 56px;            /* height of the big RSVP buttons */
}
body[data-group="trivia"]     { --c-accent: #a78bfa; }
body[data-group="basketball"] { --c-accent: #fb923c; }

/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--c-bg); color: var(--c-text);
  font: 16px/1.4 var(--font);
}
a { color: var(--c-accent); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); margin: 12px 0 6px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 1rem; margin: 12px 0 6px; }
input {
  font: inherit; color: var(--c-text); background: var(--c-bg);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus { outline: 2px solid var(--c-accent); border-color: transparent; }
.muted { color: var(--c-muted); }
[hidden] { display: none !important; }

.page {
  max-width: 480px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--gap);
}
.card { background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  padding: 0 14px; min-height: 44px; color: var(--c-on-color); background: var(--c-border);
  transition: transform .08s ease, opacity .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-small { min-height: 40px; font-size: .9rem; color: var(--c-text); }
.btn-ghost { background: transparent; color: var(--c-muted); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--c-accent); cursor: pointer; text-decoration: underline; }

/* ── Event header ─────────────────────────────────────────────────────── */
.event-title { font-size: 1.9rem; line-height: 1.15; }
.event-title #emoji { cursor: default; user-select: none; }
.event-when { margin-top: 4px; font-size: 1.05rem; }
.event-where { margin-top: 2px; color: var(--c-muted); }
.event-where a { color: inherit; }
.past-banner { background: var(--c-border); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 12px; font-size: .9rem; }
.headcount { margin: 16px 0 12px; font-size: 1.25rem; font-weight: 700; }

/* ── RSVP buttons ─────────────────────────────────────────────────────── */
.rsvp-buttons { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.rsvp-buttons .btn { min-height: var(--tap); font-size: 1.05rem; opacity: .55; }
.rsvp-buttons .btn.is-selected { opacity: 1; box-shadow: 0 0 0 3px var(--c-text) inset; }
.rsvp-buttons:not(:has(.is-selected)) .btn { opacity: 1; }
.btn-in { background: var(--c-in); }
.btn-maybe { background: var(--c-maybe); }
.btn-out { background: var(--c-out); }

.me { margin-top: 14px; font-size: .9rem; color: var(--c-muted); display: flex; flex-direction: column; gap: 8px; }
.note-form, .venue-form { display: flex; gap: 8px; }

/* ── People ───────────────────────────────────────────────────────────── */
.count { color: var(--c-text); }
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.people-list li { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 999px; padding: 6px 12px; display: flex; flex-direction: column; }
.people-list li.empty { background: none; border: 0; padding: 0; color: var(--c-muted); }
.people-list li.is-me { border-color: var(--c-accent); }
.people-list-muted li { color: var(--c-muted); }
.person-note { font-size: .78rem; color: var(--c-muted); }

/* ── Venues ───────────────────────────────────────────────────────────── */
.venue-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.venue { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
.venue.is-leading { border-color: var(--c-accent); }
.venue.is-leading .venue-name::before { content: "👑 "; }
.btn-vote.is-selected { background: var(--c-accent); color: var(--c-on-color); }

/* ── Trivia fact ──────────────────────────────────────────────────────── */
.fact p { margin-bottom: 6px; }

/* ── Stats ────────────────────────────────────────────────────────────── */
.stats summary { cursor: pointer; font-weight: 700; }
.leaderboard, .history { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: grid; grid-template-columns: 2em 1fr auto 3em; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--c-border); }
.lb-stat { color: var(--c-muted); font-size: .9rem; }
.lb-streak { text-align: right; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--c-border); }
.history-names { display: block; font-size: .85rem; color: var(--c-muted); }

/* ── Footer, home ─────────────────────────────────────────────────────── */
.footer { text-align: center; color: var(--c-muted); font-size: .9rem; }
.home-title { font-size: 1.8rem; margin: 8px 0; }
.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.group-link { display: flex; align-items: center; gap: 14px; padding: 18px; text-decoration: none; color: var(--c-text);
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius); }
.group-emoji { font-size: 2rem; }
.group-text { display: flex; flex-direction: column; flex: 1; }
.group-text small { color: var(--c-muted); }
.group-count { font-weight: 700; color: var(--c-in); }

/* ── Name sheet ───────────────────────────────────────────────────────── */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px; background: var(--c-card); color: var(--c-text);
  border-radius: var(--radius) var(--radius) 0 0; }
.sheet::backdrop { background: rgba(0, 0, 0, .55); }
.sheet form { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--c-text); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-border); border-radius: 999px; padding: 10px 14px; cursor: pointer; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet-actions .btn-in { min-width: 96px; }

/* ── Toast + confetti ─────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--c-text); color: var(--c-bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; z-index: 10; }
.confetti-piece { position: fixed; top: -12px; width: 8px; height: 12px; border-radius: 2px; z-index: 20; pointer-events: none;
  animation: confetti-fall 1.4s ease-in forwards; }
@keyframes confetti-fall {
  to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .8; }
}
