* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16131c;
  --panel: #221d2e;
  --panel2: #2c2540;
  --gold: #f5c542;
  --red: #e5484d;
  --green: #46a758;
  --text: #efeae2;
  --muted: #a89f94;
  --accent: #7c5cff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ---------- Home ---------- */
#screen-home {
  min-height: 100vh;
  align-items: center; justify-content: center;
}
#screen-home.active { display: flex; }
.home-card {
  background: var(--panel);
  padding: 40px 44px;
  border-radius: 18px;
  max-width: 460px; width: 92%;
  text-align: center;
  border: 1px solid #3a3350;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo {
  font-size: 2.6rem;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -1px;
}
.logo span { color: var(--gold); }
.logo.small { font-size: 1.2rem; }
.tagline { color: var(--muted); margin: 12px 0 24px; line-height: 1.5; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #463f5e;
  background: #191524;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
}
input:focus { outline: 2px solid var(--accent); }
#code-input { text-transform: uppercase; letter-spacing: 4px; width: 110px; text-align: center; }
.join-row { display: flex; gap: 10px; justify-content: center; }
.join-row button { flex: 1; }
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: var(--panel2);
  color: var(--text);
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform .06s, filter .15s;
}
button:hover { filter: brightness(1.15); }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.big { padding: 14px 18px; width: 100%; margin-bottom: 12px; font-size: 1.05rem; }
button.gold { background: var(--gold); color: #1c1607; }
button.danger { background: var(--red); color: #fff; }
button.good { background: var(--green); color: #fff; }
.error { color: var(--red); min-height: 1.2em; margin-top: 8px; }
.fineprint { color: var(--muted); font-size: .82rem; margin-top: 14px; line-height: 1.4; }

/* ---------- Room ---------- */
#room-header {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid #3a3350;
}
#room-code-badge {
  background: var(--panel2);
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
}
.media-controls { margin-left: auto; display: flex; gap: 8px; }
.media-controls button { font-size: 1.1rem; padding: 8px 12px; }
.media-controls button.off { background: var(--red); }

/* ---------- Video strip ---------- */
#video-strip {
  display: flex; gap: 10px;
  padding: 12px 18px;
  overflow-x: auto;
  background: #1a1626;
  min-height: 128px;
}
.tile {
  position: relative;
  width: 160px; min-width: 160px; height: 110px;
  background: #0e0b15;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #3a3350;
}
.tile.me { border-color: var(--accent); }
.tile.leader { border-color: var(--gold); box-shadow: 0 0 10px rgba(245,197,66,.4); }
.tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #0e0b15;
}
.tile .tile-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 3px 8px;
  font-size: .75rem; font-weight: 700;
  background: rgba(0,0,0,.6);
  display: flex; justify-content: space-between; align-items: center;
}
.tile .novideo {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.tile .badges { font-size: .7rem; }

/* ---------- Panels ---------- */
.panel {
  max-width: 760px;
  margin: 20px auto;
  padding: 22px 26px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid #3a3350;
  width: 94%;
}
.panel h2 { margin-bottom: 10px; }
.code-inline { color: var(--gold); letter-spacing: 3px; }
.player-list { list-style: none; margin: 14px 0; }
.player-list li {
  padding: 8px 12px;
  background: var(--panel2);
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex; justify-content: space-between;
}
.player-list .tag { color: var(--gold); font-size: .8rem; }
.player-list .off { color: var(--red); font-size: .8rem; }

/* ---------- Game ---------- */
#quest-track { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.quest-node {
  flex: 1; min-width: 110px;
  background: var(--panel2);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  border: 2px solid transparent;
}
.quest-node .qsize { font-size: 1.5rem; font-weight: 800; }
.quest-node .qname { font-size: .68rem; color: var(--muted); line-height: 1.25; margin-top: 4px; }
.quest-node.current { border-color: var(--gold); }
.quest-node.success { background: rgba(70,167,88,.25); border-color: var(--green); }
.quest-node.fail { background: rgba(229,72,77,.25); border-color: var(--red); }
.quest-node .qmark { font-size: .95rem; font-weight: 700; }
#vote-track { color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
#vote-track .pip { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--panel2); margin-right: 4px; vertical-align: middle; }
#vote-track .pip.used { background: var(--red); }

.rolecard {
  background: linear-gradient(135deg, #2c2540, #201a30);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.rolecard h3 { margin-bottom: 6px; }
.rolecard.good h3 { color: var(--green); }
.rolecard.evil h3 { color: var(--red); }
.rolecard p { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.rolecard .knows { margin-top: 8px; font-size: .9rem; }
.rolecard .knows strong { color: var(--gold); }
.rolecard-toggle { font-size: .8rem; padding: 4px 10px; float: right; }

#phase-box h2 { margin-bottom: 8px; }
#phase-box .sub { color: var(--muted); margin-bottom: 14px; line-height: 1.45; }
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.pick-list button { background: var(--panel2); }
.pick-list button.picked { background: var(--accent); color: #fff; }
.action-row { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.action-row button { flex: 1; min-width: 150px; padding: 14px; font-size: 1.02rem; }
.result-box {
  background: var(--panel2);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: .92rem;
  line-height: 1.5;
}
.result-box.win-good { border: 1px solid var(--green); }
.result-box.win-evil { border: 1px solid var(--red); }
.vote-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vote-chips span { padding: 3px 10px; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.vote-chips .yes { background: rgba(70,167,88,.3); }
.vote-chips .no { background: rgba(229,72,77,.3); }
.reveal-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.reveal-table td { padding: 6px 10px; border-bottom: 1px solid #3a3350; font-size: .9rem; }
.reveal-table .good { color: var(--green); }
.reveal-table .evil { color: var(--red); }

/* ---------- How to Play ---------- */
.linklike {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: .85rem;
  padding: 6px 4px;
}
.linklike:hover { color: var(--gold); filter: none; }
.media-controls .btn-help {
  font-weight: 800;
  color: var(--gold);
  border: 1px solid #463f5e;
  background: var(--panel2);
}
#help-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 8, 16, .75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
#help-modal {
  background: var(--panel);
  border: 1px solid #3a3350;
  border-radius: 16px;
  max-width: 640px; width: 100%;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 12px;
  border-bottom: 1px solid #3a3350;
}
.help-head h2 { font-style: italic; }
#help-close { background: var(--panel2); padding: 6px 12px; }
.help-body {
  overflow-y: auto;
  padding: 8px 22px 22px;
}
.help-body h3 {
  color: var(--gold);
  margin: 16px 0 8px;
  font-size: 1.02rem;
}
.help-body ul { list-style: none; }
.help-body li {
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
  padding: 3px 0 3px 16px;
  position: relative;
}
.help-body li::before {
  content: '›';
  position: absolute; left: 2px;
  color: var(--accent);
  font-weight: 800;
}
.tc-good { color: var(--green); }
.tc-evil { color: var(--red); }
.phase-hint {
  background: rgba(124, 92, 255, .12);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: .82rem;
  padding: 6px 10px;
  margin-bottom: 12px;
}

#toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--gold); color: #1c1607;
  padding: 10px 20px; border-radius: 10px;
  font-weight: 700;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  z-index: 100;
}
#toast.show { opacity: 1; }

@media (max-width: 640px) {
  .tile { width: 110px; min-width: 110px; height: 80px; }
  .home-card { padding: 26px 20px; }
}
