:root {
  --ink: #16131f; --panel: #221d30; --panel2: #2d2740; --line: #3b3452;
  --paper: #f5eedc; --paper-ink: #2a2433; --text: #efeaf7; --muted: #a79fbd;
  --red: #e8414b; --gold: #f3c452; --green: #5fd08a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--panel2);
  color: var(--text); font-weight: 600; min-height: 44px; }
button:active { transform: scale(.97); }
button.primary { background: var(--red); color: #fff; }
button.gold { background: var(--gold); color: #2a2100; }
button.ghostly { background: transparent; border: 1px solid var(--line); }
button.small { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 10px; }
button:disabled { opacity: .45; cursor: default; }
input, textarea { width: 100%; background: #110e19; border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 48px; outline: none; }
input:focus, textarea:focus { border-color: var(--gold); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }

#app { max-width: 640px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; }
#top:empty, #people:empty, #action:empty { display: none; }

/* top bar */
#top { padding: 10px 12px 6px; }
.toprow { display: flex; align-items: center; gap: 8px; }
.brand { font-family: Georgia, serif; font-weight: 700; letter-spacing: .5px; color: var(--red); font-size: 18px; }
.meta { color: var(--muted); font-size: 13px; flex: 1; }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; min-width: 36px; text-align: right; }
.clock.low { color: var(--red); }
.bar { height: 5px; background: var(--panel2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s linear; }
.bar i.low { background: var(--red); }

/* players strip */
#people { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 8px; }
.chip { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; white-space: nowrap; min-height: 0; font-weight: 500; }
.chip b { font-weight: 700; }
.chip.me { border-color: var(--gold); }
.chip.dead { opacity: .55; text-decoration: line-through; }
.chip.off { opacity: .4; }
.chip.gavel { background: var(--gold); color: #2a2100; }

/* story feed */
#feed { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.ln { background: var(--paper); color: var(--paper-ink); border-radius: 4px 14px 14px 14px; padding: 10px 12px;
  font-family: "Courier New", Courier, monospace; font-size: 17px; font-weight: 600; position: relative;
  animation: pop .25s ease-out; }
.ln.opening { background: #e7dcbf; font-style: italic; }
.ln.murder { box-shadow: inset 5px 0 0 var(--red); }
.ln.auto { background: #d9d3ea; }
.ln .tags { font: 600 12px/1.3 system-ui, sans-serif; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; color: #5b5470; }
.ln .tags .ok { color: #17713c; }
.ln .tags .kill { color: #b3202a; }
.ln .tags .who { color: #2a2433; background: #fff7; padding: 1px 6px; border-radius: 6px; }
.ln .rx { position: absolute; right: 6px; top: 6px; display: flex; gap: 2px; }
.ln .rx button { background: transparent; padding: 2px 5px; min-height: 0; font-size: 15px; border-radius: 8px; opacity: .45; color: var(--paper-ink); }
.ln .rx button.on { opacity: 1; background: #0001; }
.ln .txt { padding-right: 92px; display: block; }
.sys { align-self: center; text-align: center; color: var(--muted); font-size: 13px; padding: 2px 10px; }
.sys.big { color: #fff; background: #5c1a26; border: 1px solid var(--red); border-radius: 10px; padding: 6px 12px; font-weight: 600; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* action panel */
#action { background: var(--panel); border-top: 1px solid var(--line); padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0; max-height: 58dvh; overflow-y: auto; }
#action h3 { font-size: 18px; margin-bottom: 6px; }
#action p { margin: 4px 0 8px; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.letter { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--gold);
  color: #2a2100; font: 800 26px Georgia, serif; flex: none; }
.mine h3 { color: var(--gold); }
.hint { font-size: 13px; color: var(--muted); }
.hint b { color: var(--gold); }
.killbox { border: 1px dashed var(--red); border-radius: 12px; padding: 8px; margin-bottom: 8px; }
.pickline { text-align: left; background: var(--paper); color: var(--paper-ink); font-family: "Courier New", monospace; border-radius: 10px; }
.pickline.sel, .sel { outline: 3px solid var(--gold); }
.waiting { display: flex; align-items: center; gap: 10px; }
.dots::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.objection { background: #fff; color: var(--red); border: 2px solid var(--red); font-family: Georgia, serif; }

/* home + lobby */
.center { margin: auto; width: 100%; max-width: 420px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.logo { font-size: 44px; color: var(--red); text-align: center; line-height: 1; }
.tag { text-align: center; color: var(--muted); margin-bottom: 8px; }
.code { font: 800 54px/1 Georgia, serif; letter-spacing: 10px; text-align: center; color: var(--gold); padding-left: 10px; }
.or { text-align: center; color: var(--muted); font-size: 13px; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.plist > div { background: var(--panel); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.plist .grow { flex: 1; }
.badge { font-size: 11px; background: var(--panel2); padding: 2px 7px; border-radius: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.badge.killer { background: var(--red); color: #fff; }
.badge.detective { background: #4aa3ff; color: #06203d; }
.err { color: #ff9aa0; font-size: 14px; min-height: 20px; }

/* results */
.verdict { text-align: center; padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.verdict h2 { font-size: 26px; color: var(--gold); }
.score { background: var(--panel); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.score .pts { font-weight: 800; font-size: 20px; grid-row: span 2; align-self: center; }
.score small { color: var(--muted); }
.score.win { border: 1px solid var(--gold); }

/* modal, flash, toasts */
#modal:empty { display: none; }
#modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: end center; z-index: 10; }
.sheet { background: var(--panel); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.cardface { background: var(--paper); color: var(--paper-ink); border-radius: 14px; padding: 14px; }
.cardface h2 { font-size: 24px; }
.cardface .role { font-weight: 800; letter-spacing: 1px; text-transform: uppercase; font-size: 13px; }
.cardface .role.killer { color: #b3202a; }
.cardface .words span { display: inline-block; background: #fff8; border-radius: 8px; padding: 3px 9px; margin: 4px 4px 0 0; font-weight: 700; }
.cardface .words span.used { background: #bfe8cf; }
.notice { background: var(--panel2); border-left: 3px solid var(--gold); padding: 8px 10px; border-radius: 8px; font-size: 14px; }
#flash { pointer-events: none; position: fixed; inset: 0; display: none; place-items: center; background: #7a0f1dee; z-index: 20; text-align: center; padding: 24px;
  font: 700 30px/1.25 Georgia, serif; color: #fff; }
#flash.show { display: grid; animation: flash 2.8s forwards; }
@keyframes flash { 0% { opacity: 0; transform: scale(1.15); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#toasts { position: fixed; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 30; pointer-events: none; padding: 0 12px; }
.toast { background: #fff; color: #222; border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; max-width: 480px;
  box-shadow: 0 6px 24px #0008; animation: pop .2s; }

.sys.judge { color: #e9dcff; background: #33295a; border: 1px solid #6b5bb5; border-radius: 10px; padding: 6px 12px; font-style: italic; align-self: stretch; }
.sys.judge b { font-style: normal; color: var(--gold); }
.narr { background: var(--paper); color: var(--paper-ink); border-radius: 14px; padding: 6px 16px; font-family: Georgia, serif; font-size: 17px; line-height: 1.55; }
details summary { cursor: pointer; padding: 8px 0; }
#app.shake { animation: shake .5s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
#modal .sheet h3 { margin-bottom: 4px; }

/* landing page pieces: only the desktop stylesheet shows these */
.homebg, .homenav, .tagline, .verbs, .cta, .backbtn, .howto { display: none; }
.homeform { display: contents; }
.wordmark b, .wordmark i { font: inherit; }

/* The desktop 3D room sits over the card view. Phones never show it. */
#roombox { display: none; position: fixed; inset: 0; z-index: 5; background: #070506; }
#roomframe { position: absolute; inset: 0; }
#roombox > button { position: absolute; left: 12px; bottom: 12px; z-index: 6; opacity: .75; }
.wideonly { display: none; }
@media (min-width: 900px) { .wideonly { display: inline-block; } }
