/* Layout: single narrow column, phone-first, one spotlight accent on a dark stage. */
:root {
  --stage: #16121d;        /* page background */
  --panel: #221c2c;        /* cards */
  --line: #3a3147;         /* borders */
  --ink: #f3eef8;          /* main text */
  --muted: #a99db8;        /* secondary text */
  --spot: #ffcf3f;         /* spotlight accent */
  --spot-ink: #1d1605;     /* text on accent */
  --danger: #ff5d73;       /* imposter / caught */
  --safe: #5fd6a4;         /* crew / escaped-state positives */
  --font-display: "Bricolage Grotesque", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bs-body-bg: var(--stage);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { background: var(--stage); color: var(--ink); }
body {
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-image: radial-gradient(ellipse 80% 40% at 50% -5%, rgba(255, 207, 63, .10), transparent 70%);
  background-attachment: fixed;
}

.app {
  max-width: 480px;
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-block: 16px 96px;
}

.screen { display: flex; flex-direction: column; gap: 14px; animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(6px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

/* iOS zooms into inputs under 16px — keep them at 16px+ */
.form-control, .form-select { font-size: 16px; background: #1a1522; border-color: var(--line); color: var(--ink); }
.form-control-lg { font-size: 18px; }
.form-control:focus { background: #1a1522; color: var(--ink); border-color: var(--spot); box-shadow: 0 0 0 .2rem rgba(255, 207, 63, .2); }
.form-control::placeholder { color: #6f6480; }

.btn { border-radius: 12px; font-weight: 600; touch-action: manipulation; }
.btn-lg { padding-block: .8rem; }
.btn-accent { background: var(--spot); color: var(--spot-ink); border: 0; }
.btn-accent:hover, .btn-accent:focus-visible, .btn-accent:active { background: #ffdb6b !important; color: var(--spot-ink) !important; }
.btn-accent:disabled { background: #5b5040; color: #a99a7a; }
.btn:focus-visible { outline: 3px solid var(--spot); outline-offset: 2px; }

.label-caps { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.section-title { font-family: var(--font-display); font-weight: 700; }
.hint { color: var(--muted); font-size: .92rem; margin: 0; }

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

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  margin-top: calc(-1 * env(safe-area-inset-top, 0px));
  background: rgba(22, 18, 29, .92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.code-chip {
  font-family: var(--font-display); font-weight: 800; letter-spacing: .18em;
  background: var(--spot); color: var(--spot-ink); padding: 2px 10px; border-radius: 8px;
}
.offline-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20; text-align: center;
  background: var(--danger); color: #fff; font-weight: 600; font-size: .85rem;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px;
}

/* Home */
.hero { text-align: center; padding-block: 28px 8px; }
.display-title {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 16vw, 4.4rem);
  letter-spacing: -.03em; line-height: .95; margin: 14px 0 6px;
}
.lead-sub { color: var(--muted); margin: 0; text-wrap: balance; }
.mask {
  width: 84px; height: 46px; margin: 0 auto; position: relative;
  background: var(--spot); border-radius: 46px 46px 38px 38px / 30px 30px 46px 46px;
  transform: rotate(-6deg);
}
.mask::before, .mask::after {
  content: ""; position: absolute; top: 15px; width: 22px; height: 11px;
  background: var(--stage); border-radius: 50% 50% 45% 45%;
}
.mask::before { left: 14px; transform: rotate(8deg); }
.mask::after { right: 14px; transform: rotate(-8deg); }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-family: var(--font-display); font-weight: 700; text-align: center; }
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 18px 0 14px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.howto { color: var(--muted); padding-inline: 4px; }
.howto summary { cursor: pointer; color: var(--ink); font-weight: 600; padding-block: 6px; }
.howto ol { padding-left: 1.2rem; margin: 6px 0 0; display: grid; gap: 4px; }

/* Lobby */
.big-code { font-family: var(--font-display); font-weight: 800; font-size: 3.6rem; letter-spacing: .2em; line-height: 1.1; padding-left: .2em; color: var(--spot); }
.player-list { display: grid; gap: 6px; }
.player-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 12px; background: #1a1522; min-width: 0;
}
.player-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.player-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 6px; background: #342b41; color: var(--muted); }
.tag-host { background: rgba(255, 207, 63, .15); color: var(--spot); }
.tag-you { background: rgba(95, 214, 164, .15); color: var(--safe); }
.tag-away { background: rgba(255, 93, 115, .15); color: var(--danger); }
.tag-done { background: rgba(95, 214, 164, .15); color: var(--safe); }
.score-pill { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); min-width: 2ch; text-align: right; }
.kick-btn { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 2px 6px; }

/* Role card */
.role-card {
  border-radius: 20px; padding: 22px 18px; text-align: center;
  background: var(--panel); border: 2px solid var(--spot);
}
.role-card .label-caps { color: var(--spot); }
.role-card .prompt-text { font-family: var(--font-display); font-weight: 700; font-size: 1.55rem; line-height: 1.2; margin: 8px 0 0; text-wrap: balance; }
.role-card.imposter { border-color: var(--danger); background: linear-gradient(160deg, rgba(255, 93, 115, .18), var(--panel) 70%); }
.role-card.imposter .label-caps { color: var(--danger); }
.role-card.imposter .prompt-text { font-size: 1.8rem; }
.role-card .sub { color: var(--muted); font-size: .9rem; margin: 10px 0 0; }

.locked-answer { font-size: 1.15rem; font-weight: 600; margin: 4px 0 10px; overflow-wrap: anywhere; }
.progress-line { color: var(--muted); font-size: .9rem; text-align: center; }
.prompt-recap .prompt-text { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; line-height: 1.25; text-wrap: balance; }

/* Vote + reveal answers */
.answer-btn {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; width: 100%;
  text-align: left; padding: 14px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 1.05rem; line-height: 1.35;
}
.answer-btn .txt { overflow-wrap: anywhere; min-width: 0; }
.answer-btn:disabled { opacity: .55; }
.answer-btn.selected { border-color: var(--spot); background: rgba(255, 207, 63, .10); }
.answer-btn:not(:disabled):active { transform: scale(.99); }

.reveal-item { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.reveal-item.imp { border: 2px solid var(--danger); background: linear-gradient(160deg, rgba(255, 93, 115, .14), var(--panel) 75%); }
.reveal-item .txt { font-size: 1.05rem; overflow-wrap: anywhere; }
.reveal-item .who { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: .85rem; color: var(--muted); }
.votes { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); white-space: nowrap; }

.reveal-banner { text-align: center; padding: 22px 16px; border-radius: 20px; background: var(--panel); border: 2px solid var(--line); }
.reveal-banner .big { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1.05; margin: 6px 0; text-wrap: balance; }
.reveal-banner.caught { border-color: var(--safe); }
.reveal-banner.caught .big { color: var(--safe); }
.reveal-banner.escaped { border-color: var(--danger); }
.reveal-banner.escaped .big { color: var(--danger); }
.reveal-banner .gain { color: var(--spot); font-weight: 700; margin-top: 6px; }

.score-list { padding-left: 1.4rem; display: grid; gap: 4px; }
.score-list li { font-variant-numeric: tabular-nums; }
.score-list li span.pts { float: right; font-weight: 700; }

/* Host bar */
.host-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(34, 28, 44, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: min(92vw, 420px); }
.toast { background: #3a3147; color: var(--ink); width: 100%; }
.toast.error { background: #6b2533; }
