/* Matches the iOS app: dark gradient, yellow accent, teal crew, red imposter. */
:root {
  --accent: #ffc733;
  --crew: #33d9bf;
  --imposter: #ff4d59;
  --card: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.15);
  --text: #fff;
  --muted: rgba(235, 235, 245, 0.6);
  --bg-top: #171229;
  --bg-bottom: #08080f;
  --rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg-bottom); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(var(--bg-top), var(--bg-bottom)) fixed;
  color: var(--text);
  font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- top bar ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(23, 18, 41, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#title { font-weight: 600; text-align: center; }
.conn { justify-self: end; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--crew); }
.conn.bad::before { background: var(--imposter); }
.conn.wait::before { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

.link { background: none; border: 0; padding: 6px 0; color: var(--accent); justify-self: start; }
.link.small { font-size: 15px; }
.link.danger { color: var(--imposter); }

/* ---------- type ---------- */
h1, h2, h3 { margin: 0; font-family: var(--rounded); }
h1 { font-size: 34px; font-weight: 800; text-align: center; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.pad { padding: 24px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; min-height: 12px; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--card); font-weight: 600; }
.center-pill { align-self: center; }

/* ---------- buttons ---------- */
.big {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #000;
  transition: transform 0.08s, opacity 0.15s;
}
.big:active:not(:disabled) { transform: scale(0.98); opacity: 0.8; }
.big:disabled { opacity: 0.45; }
.big.plain { background: var(--card); color: var(--text); }
.big.crew { background: var(--crew); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 28px 0 8px; }
.hero img { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.hero h1 { margin-top: 14px; font-size: 40px; }
.field {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
}
.field:focus { border-color: var(--accent); }
.code-field { font: 700 26px ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.join-row .big { width: auto; padding: 0 22px; }
.error { color: var(--imposter); font-weight: 600; }

/* ---------- lobby ---------- */
.code-box { text-align: center; }
.code-box .code {
  font: 900 56px ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.15em;
  margin-right: -0.15em;
  color: var(--accent);
  line-height: 1.1;
}
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.players li { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.players li:first-child { border-top: 0; }
.player { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; background: none; border: 0; text-align: left; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--crew); flex: none; }
.dot.off { background: #777; }
.crown { color: var(--accent); }
.player-actions { display: flex; gap: 8px; padding: 0 0 10px 18px; }
.chip-btn { border: 0; border-radius: 10px; padding: 8px 12px; background: var(--card); font-size: 14px; font-weight: 600; }
.chip-btn.danger { color: var(--imposter); }

.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.stepper { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 10px; }
.stepper button { border: 0; background: none; width: 40px; height: 34px; font-size: 20px; }
.stepper button:disabled { opacity: 0.3; }
.stepper span { min-width: 24px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(120, 120, 128, 0.36); transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--crew); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled { cursor: default; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.cat { display: flex; align-items: center; gap: 6px; padding: 10px; border: 0; border-radius: 10px; background: var(--card); font-size: 15px; font-weight: 600; text-align: left; }
.cat.on { background: rgba(255, 199, 51, 0.18); }
.cat .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .tick { color: var(--accent); }
.locked { pointer-events: none; }
.locked .switch, .locked .stepper, .locked .cat { opacity: 0.6; }

/* ---------- role card ---------- */
.role-card {
  position: relative;
  height: 340px;
  border-radius: 28px;
  background: var(--card);
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.role-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.role-card.crew { background: rgba(51, 217, 191, 0.18); border-color: var(--crew); }
.role-card.imposter { background: rgba(255, 77, 89, 0.18); border-color: var(--imposter); }
.role-card .icon { font-size: 50px; line-height: 1; }
.role-card .word { font: 800 40px/1.1 var(--rounded); color: var(--crew); word-break: break-word; }
.role-card .imp { font: 800 28px/1.1 var(--rounded); color: var(--imposter); }
.hint { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-weight: 700; font-size: 20px; }

/* ---------- clues ---------- */
.order { display: flex; flex-direction: column; gap: 8px; }
.order .item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: var(--card); font-weight: 600; }
.num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--card); font-variant-numeric: tabular-nums; flex: none; }
.num.first { background: var(--accent); color: #000; }

/* ---------- voting ---------- */
.note { display: flex; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255, 77, 89, 0.18); font-size: 15px; }
.ballot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ballot button {
  min-height: 64px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  font-weight: 600;
  padding: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ballot button.on { background: var(--accent); color: #000; }
.big-icon { font-size: 64px; line-height: 1; text-align: center; }

/* ---------- results ---------- */
.banner { text-align: center; padding: 20px; border-radius: 20px; display: flex; flex-direction: column; gap: 6px; }
.banner.crew { color: var(--crew); background: rgba(51, 217, 191, 0.12); }
.banner.imposter { color: var(--imposter); background: rgba(255, 77, 89, 0.12); }
.banner .title { font: 800 34px/1.1 var(--rounded); }
.banner .icon { font-size: 54px; line-height: 1; }
.reveal-word { font: 800 36px/1.15 var(--rounded); color: var(--crew); }
.reveal-imps { font: 700 24px/1.2 var(--rounded); color: var(--imposter); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 24px 28px; align-items: center; gap: 10px; font-weight: 600; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 22px; }
.bar-row .fill { height: 100%; min-width: 6px; border-radius: 6px; background: var(--crew); }
.bar-row .fill.imp { background: var(--imposter); }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }
.score-row { display: flex; justify-content: space-between; }
.score-row b { font-variant-numeric: tabular-nums; }

/* ---------- toast + dialogs ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--imposter);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
