/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273344;
  --border: #334155;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --danger: #f87171;
  --success: #34d399;
  --warning: #fbbf24;
  --card-w: 68px;
  --card-h: 96px;
  --radius: 10px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Views ─────────────────────────────────────────────────── */
.view { min-height: 100vh; }

/* ── Landing ───────────────────────────────────────────────── */
#view-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 2rem;
}

#view-landing header { text-align: center; }
#view-landing h1 { font-size: 2.5rem; }
.subtitle { color: var(--text-muted); margin-top: .4rem; }

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 680px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2rem;
  align-items: start;
}

.divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
}

@media (max-width: 580px) {
  .two-col { grid-template-columns: 1fr; }
  .divider { width: 100%; height: 1px; }
}

form { display: flex; flex-direction: column; gap: .75rem; }

label { font-size: .85rem; color: var(--text-muted); }

input[type="text"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .55rem .75rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
input[type="text"]:focus,
select:focus { border-color: var(--accent); }
select { cursor: pointer; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }

.form-error { color: var(--danger); font-size: .85rem; min-height: 1.2rem; }

/* ── Room header ───────────────────────────────────────────── */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: .5rem;
}

.room-header h1 { font-size: 1.4rem; }

.room-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .9rem;
}

#btn-copy-code {
  background: transparent;
  color: var(--text-muted);
  padding: .2rem .4rem;
  font-size: .9rem;
}
#btn-copy-code:hover { color: var(--text); background: transparent; }

/* ── Room body ─────────────────────────────────────────────── */
.room-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  height: calc(100vh - 60px);
}

@media (max-width: 640px) {
  .room-body { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .75rem; }

#participant-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }

#participant-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  background: var(--surface2);
}

.participant-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-you { font-size: .7rem; background: var(--accent); color: #fff; border-radius: 4px; padding: .1rem .35rem; }
.badge-mod { font-size: .7rem; background: var(--warning); color: #000; border-radius: 4px; padding: .1rem .35rem; }
.badge-role { font-size: .65rem; border-radius: 4px; padding: .1rem .3rem; font-weight: 600; }
.badge-role--backend  { background: #1e3a5f; color: #60a5fa; }
.badge-role--frontend { background: #3b1f5e; color: #c084fc; }
.badge-role--both     { background: #1a3a2e; color: #6ee7b7; }
.vote-indicator { font-size: .75rem; }
.voted { color: var(--success); }
.not-voted { color: var(--text-muted); }
.participant-inactive { opacity: .45; }

/* ── Main area ─────────────────────────────────────────────── */
.main-area {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Story label ───────────────────────────────────────────── */
.story-label {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: 1rem;
  color: var(--text-muted);
}
.story-label strong { color: var(--text); }

/* ── Moderator controls ────────────────────────────────────── */
#moderator-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

#ctrl-voter-filter {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.voter-filter-label { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
#voter-filter-select { font-size: .85rem; padding: .35rem .6rem; }

#ctrl-waiting { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
#story-label-input { flex: 1; min-width: 180px; }
#btn-start { white-space: nowrap; }
#btn-reveal { background: #f59e0b; }
#btn-reveal:hover { background: #d97706; }
#btn-reset { background: #64748b; }
#btn-reset:hover { background: #475569; }

/* ── Not-voting message ────────────────────────────────────── */
.not-voting-msg {
  color: var(--text-muted);
  font-size: .9rem;
  text-align: center;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Card deck ─────────────────────────────────────────────── */
#card-deck h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 1rem; }

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card:hover { border-color: var(--accent); transform: translateY(-4px); }
.card.selected { border-color: var(--accent); background: var(--accent); color: #fff; transform: translateY(-6px); }

/* ── Results panel ─────────────────────────────────────────── */
#results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#results-consensus {
  font-size: 1.3rem;
  text-align: center;
}

.results-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
}

.result-card .card-face {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
}

.result-card.outlier .card-face {
  border-color: var(--warning);
  background: rgba(251, 191, 36, .12);
  color: var(--warning);
}

.result-card .player-name {
  font-size: .75rem;
  color: var(--text-muted);
  max-width: var(--card-w);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  font-size: .9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.stat { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.stat-value { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
