:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1e222b;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --text-dim: #9098a8;
  --accent: #c8322b;
  --accent-hover: #d94840;
  --liberal: #4a90d9;
  --fascist: #c8322b;
  --hitler: #1a1a1a;
  --success: #4ac26b;
  --warn: #e0a83d;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 0 0 8px; font-size: 15px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
p  { margin: 0 0 12px; color: var(--text-dim); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.brand {
  text-align: center;
  padding: 20px 0 28px;
}
.brand-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.brand-title .accent { color: var(--accent); }
.brand-sub { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, transform .05s ease;
  min-height: 44px;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #262b36; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elev-2); color: var(--text); }

.btn-full { width: 100%; }

input, select {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }

.tabs {
  display: flex;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 14px;
  min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}
.tab.active { background: var(--bg-elev); color: var(--text); }

.player-list { display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.player .name { font-weight: 600; }
.player .name.unset { color: var(--text-dim); font-style: italic; font-weight: 400; }
.player .badges { display: flex; gap: 6px; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 600;
}
.badge.host { color: var(--warn); border-color: rgba(224,168,61,.4); }
.badge.you { color: var(--liberal); border-color: rgba(74,144,217,.4); }
.badge.disconnect { color: #e04d4d; border-color: rgba(224,77,77,.4); }

.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.name-chip {
  padding: 10px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}
.name-chip:hover { background: #262b36; }
.name-chip.taken { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.name-chip.mine { background: var(--accent); border-color: var(--accent); color: white; }

.copy-link {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 12px;
}
.copy-link input {
  border: none; background: transparent; padding: 8px 0; min-height: 32px; flex: 1;
  color: var(--text-dim); font-size: 13px;
}
.copy-link button { padding: 8px 14px; min-height: 36px; font-size: 13px; }

.helper { font-size: 13px; color: var(--text-dim); }
.helper.warn { color: var(--warn); }
.helper.err { color: #ff6b6b; }
.helper.ok { color: var(--success); }

.role-card {
  padding: 32px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  color: white;
  margin-bottom: 16px;
}
.role-card.liberal { background: linear-gradient(160deg, #4a90d9, #2a5f96); }
.role-card.fascist { background: linear-gradient(160deg, #c8322b, #7a1a15); }
.role-card.hitler  { background: linear-gradient(160deg, #2a2a2a, #000); border: 1px solid #444; }
.role-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.15em; opacity: .7;
  margin-bottom: 8px;
}
.role-name { font-size: 42px; font-weight: 800; letter-spacing: -0.02em; }

.teammate-list { display: flex; flex-direction: column; gap: 8px; }
.teammate {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.teammate .role-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.role-tag.fascist { background: rgba(200,50,43,.2); color: #ff8a83; }
.role-tag.hitler { background: rgba(0,0,0,.6); color: #ddd; border: 1px solid #444; }

.header-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.room-code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 20px; font-weight: 700; letter-spacing: 0.05em;
}

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; }

.hint-block {
  padding: 12px 14px;
  background: var(--bg-elev-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.count-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.count-box .cell {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}
.count-box .cell .k { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.count-box .cell .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.cell.liberal .v { color: var(--liberal); }
.cell.fascist .v { color: var(--fascist); }
.cell.hitler .v { color: #ddd; }
