:root {
  --bg: #0e0c0a;
  --bg-2: #15120f;
  --panel: #1b1814;
  --panel-2: #24201a;
  --line: #3a3229;
  --ink: #f2e9dc;
  --muted: #a69c8e;
  --gold: #d4af6a;
  --gold-soft: rgba(212, 175, 106, 0.14);
  --gold-dim: #8d7546;
  --red: #c94a4a;
  --red-soft: rgba(201, 74, 74, 0.14);
  --green: #6fae7c;
  --paper: #efe4cf;
  --paper-ink: #2a2118;
  --radius: 14px;
  --display: 'Limelight', 'Didot', Georgia, serif;
  --serif: Georgia, 'Times New Roman', serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: radial-gradient(120% 60% at 50% 0%, #1d1812 0%, var(--bg) 60%) fixed, var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  transition: background-color 0.6s;
}
body.murder-mood { background: radial-gradient(120% 70% at 50% 10%, #2a1312 0%, #0c0908 65%) fixed, #0c0908; }
#app { max-width: 520px; margin: 0 auto; padding: 0 16px 104px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; color: var(--gold); margin: 0 0 8px; letter-spacing: 0.02em; line-height: 1.15; }
h1 { font-size: 46px; text-align: center; }
h2 { font-size: 25px; }
h3 { font-size: 19px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.right { text-align: right; }
.red-text { color: var(--red); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.even { align-items: stretch; }
.row.even > * { flex: 1 1 0; }
.grow { flex: 1; min-width: 0; }

/* Marquee + landing */
.marquee { padding-top: 34px; text-align: center; }
.marquee h1 { margin: 0; text-shadow: 0 0 22px rgba(212, 175, 106, 0.25); }
.marquee-rule { margin: 10px auto 0; width: 160px; height: 10px; background:
  linear-gradient(var(--gold-dim), var(--gold-dim)) center/100% 1px no-repeat,
  linear-gradient(45deg, transparent 42%, var(--gold) 42% 58%, transparent 58%) center/10px 10px no-repeat; }
.tagline { text-align: center; color: var(--muted); margin: 14px 0 22px; }
.deco { display: flex; align-items: center; gap: 10px; color: var(--gold-dim); margin: 16px 0 12px; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; }
.deco::before, .deco::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-dim), transparent); }

/* Top bar in a game */
.topbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; margin: 0 -16px 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(14, 12, 10, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.topbar .me-name { color: var(--gold); font-weight: 600; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { width: 16px; height: 16px; border: 1.5px solid var(--gold-dim); border-radius: 50%; position: relative; flex: none; }
.clock::before, .clock::after { content: ''; position: absolute; left: 50%; top: 50%; width: 1.5px; background: var(--gold); transform-origin: top center; }
.clock::before { height: 5px; transform: translateX(-50%) rotate(180deg); }
.clock::after { height: 4px; transform: translateX(-50%) rotate(270deg); }
.help { min-height: 32px; width: 32px; padding: 0; border-radius: 50%; color: var(--gold); border-color: var(--gold-dim); background: transparent; font-weight: 700; }

/* Cards */
.card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.gold { border-color: var(--gold-dim); box-shadow: inset 0 0 0 1px rgba(212, 175, 106, 0.1); }
.card.victim { border-color: rgba(201, 74, 74, 0.6); }
.card.killer { border-color: var(--red); background: linear-gradient(180deg, #241514, var(--bg-2)); }
.card + .card, .card + .banner, .banner + .card, .banner + .banner, .card + .hint-line, .hint-line + .card { margin-top: 12px; }
.label { display: block; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.answer { font-size: 18px; }
.hint-line { color: var(--muted); font-size: 14px; text-align: center; padding: 0 8px; }
.waiting { color: var(--muted); text-align: center; font-size: 14px; margin-top: 14px; }

/* Form controls */
input[type=text] { width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font: inherit; font-size: 17px; }
input[type=text]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
input.code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-weight: 700; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); padding: 12px 14px; min-height: 46px; -webkit-tap-highlight-color: transparent; transition: background-color 0.15s, border-color 0.15s, transform 0.08s; }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(180deg, #e0bd7a, var(--gold)); color: #1a1408; border-color: var(--gold); font-weight: 700; }
button.ghost { background: transparent; }
button.block { display: block; width: 100%; }
button.link { background: none; border: none; color: var(--gold); padding: 4px; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.dim { opacity: 0.45; }
.chip { min-height: 42px; padding: 9px 14px; border-radius: 999px; font-size: 15px; }
.chip.on { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 600; }
.chip.struck { text-decoration: line-through; color: var(--muted); background: transparent; border-style: dashed; }
.option { display: block; width: 100%; text-align: left; margin-top: 8px; }
.option.on { border-color: var(--gold); background: var(--gold-soft); }

/* Steps in multi-part choices */
.step { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; font-weight: 600; font-size: 15px; color: var(--muted); }
.step-n { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--gold-dim); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.step.current { color: var(--ink); }
.step.current .step-n { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.step.done .step-n { background: var(--gold-soft); color: var(--gold); }
.step.done .step-n::after { content: ''; }

/* Testimony cards: little paper notes */
.tcards { display: grid; gap: 10px; }
.tcard { display: block; position: relative; width: 100%; text-align: left; background: var(--paper); color: var(--paper-ink); border: 1px solid #cdbb96; border-radius: 6px; padding: 12px 14px 12px 16px; box-shadow: 0 2px 0 rgba(0,0,0,0.35), 0 8px 18px rgba(0,0,0,0.25); font-family: var(--body); min-height: 0; }
.tcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 6px 0 0 6px; background: var(--gold-dim); }
.tcard.k-sighting::before { background: #4f7f5a; }
.tcard.k-smudged { background: #ddd4c4; color: #5a5046; }
.tcard.k-smudged::before { background: #9b8f80; }
.tcard-title { display: block; font-family: var(--display); font-size: 18px; color: var(--paper-ink); letter-spacing: 0.01em; }
.tcard-detail { display: block; font-family: var(--serif); font-style: italic; font-size: 15px; margin-top: 4px; color: #4d4135; }
.tcard-hour { position: absolute; top: 10px; right: 12px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #8a7a62; }
button.tcard { cursor: pointer; }
button.tcard.on { outline: 3px solid var(--gold); outline-offset: 2px; }
button.tcard.on::after { content: 'Selected'; position: absolute; bottom: 8px; right: 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #7a5b1d; }

/* Lobby bits */
.code-big { font-family: var(--display); font-size: 56px; color: var(--gold); letter-spacing: 0.2em; text-align: center; line-height: 1.1; text-shadow: 0 0 20px rgba(212, 175, 106, 0.2); }
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.players li:last-child { border-bottom: none; }
.rank { width: 22px; color: var(--gold-dim); font-family: var(--display); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: var(--muted); opacity: 0.5; }
.badge { display: inline-block; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--gold-dim); color: var(--gold); border-radius: 6px; padding: 1px 6px; vertical-align: middle; }
.badge.red { border-color: var(--red); color: var(--red); }
.check { color: var(--green); font-weight: 700; }

/* Open Floor */
.timer { font-family: var(--display); font-size: 68px; text-align: center; color: var(--ink); line-height: 1; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--red); animation: pulse 1s ease-in-out infinite; }
.chime { text-align: center; font-family: var(--serif); font-style: italic; color: var(--gold); margin: 4px 0 12px; animation: chime 2.6s var(--ease) both; }
.banner { display: block; width: 100%; text-align: left; border: none; border-left: 3px solid var(--gold); background: var(--panel-2); padding: 10px 12px; border-radius: 8px; font-size: 15px; color: var(--ink); min-height: 0; }
.banner.red { border-left-color: var(--red); }
.block-banner { cursor: pointer; animation: glow 2.4s ease-out 1; }

/* Tap to reveal */
.secret { position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; border-radius: 10px; }
.secret .content { filter: blur(10px); opacity: 0.3; transform: scale(0.985); transition: filter 0.35s var(--ease), opacity 0.35s var(--ease), transform 0.35s var(--ease); pointer-events: none; }
.secret .hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.secret .hint span { color: var(--gold); font-weight: 600; font-size: 15px; letter-spacing: 0.04em; border: 1px solid var(--gold-dim); border-radius: 999px; padding: 8px 16px; background: rgba(14, 12, 10, 0.75); }
.secret.revealed .content { filter: none; opacity: 1; transform: none; }
.secret.revealed .hint { display: none; }
.secret.revealed::after { content: 'Tap to hide'; display: block; text-align: right; font-size: 12px; color: var(--muted); margin-top: 8px; }
.task { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.role-murderer, .role-accomplice { color: var(--red); }

/* Feed + tables */
.feed { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.feed li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.feed li:last-child { border-bottom: none; }
.feed li.warrant { border-left: 2px solid var(--gold-dim); padding-left: 10px; }
.rules-mini { padding-left: 18px; margin: 6px 0 4px; }
table.ballots { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ballots th, table.ballots td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ballots th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; }
table.ballots .right { text-align: right; }

/* Bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(14, 12, 10, 0.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; z-index: 5; }
.tabs button { flex: 1; max-width: 130px; min-height: 50px; font-size: 14px; background: transparent; border: none; color: var(--muted); border-radius: 10px; position: relative; }
.tabs button.on { color: var(--gold); background: var(--panel); }
.tabs .pip { position: absolute; top: 9px; right: 14%; width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse 1.6s ease-in-out infinite; }

/* Private Word received */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; animation: fade 0.25s ease-out both; overflow-y: auto; }
.envelope { max-width: 420px; width: 100%; max-height: calc(100dvh - 40px); overflow-y: auto; text-align: center; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: var(--radius); padding: 18px; animation: popin 0.4s var(--ease) both; }
.envelope .from { margin: 12px 0 0; text-align: left; font-size: 14px; color: var(--muted); }
@keyframes popin { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
.envelope .tcard { margin: 12px 0; text-align: left; }

/* Murder step */
.hush h2 { color: var(--red); }

/* Verdict */
.verdict.play .s1, .verdict.play .s2, .verdict.play .s3, .verdict.play .s4, .verdict.play .s5 { animation: rise 0.7s var(--ease) both; }
.verdict.play .s2 { animation-delay: 0.9s; }
.verdict.play .s3 { animation-delay: 1.4s; }
.verdict.play .s4 { animation-delay: 1.7s; }
.verdict.play .s5 { animation-delay: 2s; }
.verdict-card { padding: 26px 16px; }
.verdict-card .headline { font-size: 30px; }
.verdict.play .headline { animation: settle 1.2s var(--ease) both; }
.verdict-sub { font-family: var(--serif); font-style: italic; font-size: 18px; }
.verdict.play .verdict-sub { animation: fade 0.8s ease-out 0.6s both; }
.verdict.win .verdict-card { border-color: var(--gold); }
.verdict.play.win .verdict-card { animation: rise 0.7s var(--ease) both, glow 2.4s ease-out 0.4s 1; }
.verdict.lose .verdict-card { border-color: var(--red); background: linear-gradient(180deg, #2a1514, var(--bg-2)); }
.verdict.lose .headline { color: #e7b9a6; }

/* How to play */
.rules-page { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: fade 0.2s ease-out both; }
.rules-inner { max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
.rules-inner h3 { margin-top: 22px; }
.rules-inner ul, .rules-inner ol { padding-left: 20px; margin: 0 0 10px; }
.rules-inner li { margin-bottom: 6px; }
.rules-inner .lead { font-family: var(--serif); font-size: 17px; }
.rules-inner table { margin: 6px 0 8px; }
.rules-inner > .primary { margin-top: 22px; }

/* Toast + connection */
#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--red); color: white; padding: 10px 16px; border-radius: 10px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: 90vw; z-index: 40; }
#toast.show { opacity: 1; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: white; text-align: center; font-size: 13px; padding: 4px; z-index: 50; }

/* Entrances and effects: subtle, and only when a new step begins */
.enter > * { animation: rise 0.45s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: 0.06s; }
.enter > *:nth-child(3) { animation-delay: 0.12s; }
.enter > *:nth-child(4) { animation-delay: 0.18s; }
.enter > *:nth-child(n+5) { animation-delay: 0.24s; }
.tcard.fresh { animation: deal 0.6s var(--ease) both, shimmer 2.2s ease-out 0.4s 1; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes flip { from { opacity: 0; transform: rotateX(-70deg) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { box-shadow: 0 0 0 0 rgba(212, 175, 106, 0.7), 0 8px 18px rgba(0,0,0,0.25); } 100% { box-shadow: 0 0 0 10px rgba(212, 175, 106, 0), 0 8px 18px rgba(0,0,0,0.25); } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(212, 175, 106, 0.45); } 100% { box-shadow: 0 0 0 14px rgba(212, 175, 106, 0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes chime { 0% { opacity: 0; letter-spacing: 0.2em; } 30% { opacity: 1; letter-spacing: 0.02em; } 100% { opacity: 0.8; } }
@keyframes settle { from { opacity: 0; letter-spacing: 0.12em; filter: blur(3px); } to { opacity: 1; letter-spacing: 0.02em; filter: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Bad blood (grudges) */
.grudges { margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(201, 74, 74, 0.45); }
.grudge-list { list-style: none; padding: 0; margin: 8px 0 0; }
.grudge-list li { padding: 8px 0 8px 12px; border-left: 2px solid rgba(201, 74, 74, 0.6); margin-top: 6px; }
.grudge-list li.you { border-left-color: var(--gold); background: var(--gold-soft); border-radius: 0 8px 8px 0; }
.grudge-line { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 15px; }
