:root {
  --bg: #1b1630;
  --bg2: #2a2148;
  --card: #2f2652;
  --line: #463a75;
  --text: #f4f1ff;
  --muted: #b6acd9;
  --accent: #ffcc33;
  --accent-ink: #2a1d00;
  --pink: #ff5c8a;
  --teal: #3ee0c0;
  --danger: #ff6b6b;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg));
  background-color: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0.4em 0; line-height: 1.15; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

.logo {
  font-size: 2.6rem;
  text-align: center;
  margin: 28px 0 8px;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo.small { font-size: 2rem; }

.sub { color: var(--muted); font-size: 0.95rem; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label { font-weight: 600; font-size: 0.95rem; }

input {
  width: 100%;
  font: inherit;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }

.code-input {
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.3em;
  font-weight: 800;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: var(--bg2);
  width: 100%;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: transparent; border-color: var(--teal); color: var(--teal); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { padding: 18px; font-size: 1.15rem; margin-top: 8px; }
.btn.small { padding: 8px 12px; font-size: 0.9rem; width: auto; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.error {
  color: var(--danger);
  font-weight: 600;
  margin: 0;
}

.footer-link { text-align: center; margin-top: 30px; }
.footer-link a { color: var(--muted); }

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--pink);
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 8px;
}

/* avatars */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
}
.avatar-btn {
  font-size: 2rem;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.avatar-btn.selected { border-color: var(--accent); background: var(--bg2); }
.avatar-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* game */
.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.pill strong { letter-spacing: 0.12em; color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.chip .avatar { font-size: 1.6rem; }
.chip .num { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.chip .pname { font-weight: 600; overflow-wrap: anywhere; }

.tag {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}
.tag.you { background: var(--teal); color: #00302a; }
.tag.off { background: var(--line); color: var(--muted); }

.player-list, .tally, .scores, .room-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.player-list li.me { border-color: var(--teal); }

.waiting {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  margin: 18px 0;
}

.question { text-align: center; }
.round {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--pink);
}
.qtext { font-size: 1.45rem; font-weight: 800; margin: 4px 0; }

.vote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-height: 108px;
}
.vote-btn .avatar { font-size: 2.2rem; }
.vote-btn .num { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.vote-btn .pname { font-weight: 700; overflow-wrap: anywhere; text-align: center; }
.vote-btn.selected { border-color: var(--accent); background: var(--bg2); box-shadow: 0 0 0 3px rgba(255, 204, 51, 0.25); }

.big-emoji { font-size: 3rem; margin: 0; text-align: center; }
.headline { font-size: 1.2rem; font-weight: 700; margin: 0; text-align: center; }
.headline .avatar { font-size: 1.6rem; }

.tally li { display: flex; flex-direction: column; gap: 4px; }
.tally-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tally .count { font-weight: 800; font-size: 1.2rem; }
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; background: var(--teal); border-radius: 999px; transition: width 0.4s ease; }
.tally li.win .fill { background: var(--accent); }
.tally li.win .count { color: var(--accent); }

.scores li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.scores li:last-child { border-bottom: 0; }
.scores li.me .pname { color: var(--teal); }
.scores li.lost .pname { color: var(--danger); }
.scores .score { font-weight: 800; min-width: 1.5em; text-align: right; }
.pips { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 120px; }
.pip { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.pip.on { background: var(--pink); }

.host-bar {
  margin-top: 18px;
  padding: 14px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.host-bar .btn.small { align-self: center; }
.host-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.gameover h2 { font-size: 2rem; margin: 0; }

/* end-of-game summary */
.awards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.award {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.award.lose { border-color: var(--danger); background: linear-gradient(180deg, rgba(255, 107, 107, 0.18), var(--card)); }
.award.second { border-color: var(--accent); }
.award.least { border-color: var(--teal); }
.award-icon { font-size: 1.8rem; }
.award-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.award-people { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.award-person { display: flex; flex-direction: column; align-items: center; }
.award-person .avatar { font-size: 2.2rem; line-height: 1.1; }
.award.lose .award-person .avatar { font-size: 2.8rem; }
.award-person .pname { font-weight: 800; overflow-wrap: anywhere; }
.award.lose .pname { color: var(--danger); font-size: 1.1rem; }
.award-detail { font-size: 0.8rem; color: var(--muted); }

.votes-total { font-size: 0.8rem; white-space: nowrap; }

.round-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.round-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.round-item:last-child { border-bottom: 0; }
.round-q { font-weight: 700; margin: 2px 0 8px; }
.mini-tally { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mini-tally li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.mini-tally li .avatar { font-size: 1.2rem; }
.mini-tally li .pname { overflow-wrap: anywhere; }
.mini-tally li .count { font-weight: 800; min-width: 1.5em; text-align: right; }
.mini-tally li:not(.win) .tag { visibility: hidden; }
.mini-tally li.win .pname, .mini-tally li.win .count { color: var(--accent); }

/* host page */
.limit-row { display: flex; gap: 8px; }
.chip-btn { flex: 1; border-color: var(--line); }
.chip-btn.selected { border-color: var(--accent); color: var(--accent); }
.deck-btn { flex-direction: column; gap: 2px; }
.deck-count { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.room-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.room-list li:last-child { border-bottom: 0; }
.room-list .code { letter-spacing: 0.15em; color: var(--accent); font-size: 1.1rem; }
.row { display: flex; gap: 8px; }
