:root {
  --bg: #12131a; --panel: #1c1e29; --panel2: #252838; --line: #333750;
  --text: #e8e9f2; --muted: #9a9db5; --accent: #8b7cf6; --accent-text: #fff;
  --good: #4cc38a; --evil: #ef5b6b; --warn: #f0b429; --neutral: #f0b429;
  --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f2f3f8; --panel: #fff; --panel2: #eceef6; --line: #d5d8e8; --text: #1b1d2b; --muted: #62667f; --neutral: #a8730a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, sans-serif; }
#app { max-width: 1200px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--evil); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
input, textarea, select { font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.game-card { text-align: left; padding: 24px; }
a.game-card { display: block; color: inherit; text-decoration: none; }
.game-card .big { font-size: 3rem; }
.error { color: var(--evil); min-height: 1.4em; }

.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--panel2);
  display: inline-grid; place-items: center; font-weight: 700; flex: none; border: 2px solid var(--line); }
.avatar.lg { width: 80px; height: 80px; font-size: 1.8rem; }
.avatar-pick { display: flex; gap: 12px; align-items: center; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.role-row { display: flex; gap: 10px; align-items: center; padding: 10px; background: var(--panel2); border-radius: 10px; }
.role-row .info { flex: 1; min-width: 0; } .role-row .info b { display: block; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { padding: 2px 10px; } .stepper output { min-width: 1.5em; text-align: center; font-weight: 700; }
.team-good { color: var(--good); } .team-evil { color: var(--evil); } .team-neutral { color: var(--neutral); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* room */
.room-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--panel2); font-size: .85rem; border: 1px solid var(--line); }
.badge.night { background: #1d2248; color: #b9c2ff; } .badge.day { background: #4b3a12; color: #ffe29a; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.2rem; }
.room-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .room-grid { grid-template-columns: 340px 1fr 340px; align-items: start; } }

.role-card { text-align: center; padding: 20px; cursor: pointer; user-select: none; border-width: 2px; }
.role-card .icon { font-size: 3.5rem; line-height: 1; }
.role-card.good { border-color: var(--good); } .role-card.evil { border-color: var(--evil); } .role-card.neutral { border-color: var(--neutral); }
.role-card.hidden { background: repeating-linear-gradient(45deg, var(--panel2), var(--panel2) 10px, var(--panel) 10px, var(--panel) 20px); }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.player { display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--panel2); border: 2px solid transparent;
  border-radius: 10px; text-align: left; width: 100%; min-width: 0; }
.player .meta { min-width: 0; flex: 1; } .player .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.dead { opacity: .55; } .player.dead .name { text-decoration: line-through; }
.player.selectable { cursor: pointer; border-color: var(--line); } .player.selectable:hover { border-color: var(--accent); }
.player.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel2)); }
.player.me .name::after { content: ' (you)'; font-weight: 400; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 4px; }
.dot.off { background: var(--muted); }
.tally { margin-left: auto; font-weight: 700; color: var(--warn); }

.log, .chat-list { max-height: 260px; overflow-y: auto; font-size: .92rem; }
.log p, .chat-list p { margin: 4px 0; }
.log .phase { color: var(--accent); font-weight: 600; margin-top: 10px; } .log .death { color: var(--evil); } .log .win { color: var(--good); font-weight: 700; }
.chat-list .ch-dead { color: var(--muted); font-style: italic; } .chat-list .ch-evil { color: var(--evil); }
.chat-list .ch-dm { color: var(--accent); font-style: italic; }
.log .chat { color: var(--muted); }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form select { width: auto; max-width: 38%; flex: none; }
.settings-list { margin: 0; padding-left: 18px; }
.ghost-banner { text-align: center; margin-bottom: 12px; border-width: 2px; }
.ghost-evil { border-color: var(--evil); color: var(--evil); } .ghost-good { border-color: var(--good); color: var(--good); }
.player.marked { border-color: var(--evil); } .player .flag { color: var(--evil); font-weight: 600; }
.note { border-left: 3px solid var(--warn); padding-left: 10px; margin: 6px 0; }
.qr { background: #fff; padding: 8px; border-radius: 12px; width: 220px; height: 220px; }
.code { font: 700 2rem/1 ui-monospace, monospace; letter-spacing: .15em; }
.winner-banner { text-align: center; font-size: 1.3rem; padding: 16px; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--evil); color: #fff;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 10; }
#toast.show { opacity: 1; }

/* modal (camera) */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal-box { max-width: 360px; width: 100%; }
.cam { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: #000; }

/* popup: night action, hunter shot, vote */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 12px; overflow-y: auto; }
.dialog-overlay[hidden] { display: none; }
.dialog-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 480px; max-height: 94vh; overflow-y: auto; }
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.target { display: flex; gap: 8px; align-items: center; padding: 8px; text-align: left; border: 2px solid var(--line); background: var(--panel2); border-radius: 10px; min-width: 0; }
.target .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.target.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel2)); }
.target .small { display: block; }
.cap-note { color: var(--warn); }

/* ghost trait row in setup: black name on a light chip so it stays readable in dark mode */
.ghost-name { color: #000; background: #dcdde8; padding: 0 .4em; border-radius: 6px; font-weight: 700; }

/* rules popup: above the night/vote popup (40) */
.rules-overlay { z-index: 60; }
.rules-box { max-width: 720px; }
.rules-box h2 { font-size: 1.1rem; }

/* Impostor game */
.imp-grid { grid-template-columns: 1fr; }
@media (min-width: 900px) { .imp-grid { grid-template-columns: 2fr 1fr; } }
.imp-q { font-size: 1.15rem; font-weight: 600; margin: 4px 0; }
.imp-you { border-color: var(--evil); }
.imp-qs { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.imp-answers, .imp-board, .imp-pairs { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.imp-answers li.speaking, .imp-board li.speaking { background: color-mix(in srgb, var(--accent) 20%, var(--panel2)); border-radius: 6px; padding: 2px 6px; }
