:root {
  --bg: #121016;
  --panel: #1d1a24;
  --panel-2: #262230;
  --line: #34303f;
  --text: #f1eef6;
  --muted: #a39db0;
  --accent: #e8b04b;
  --accent-text: #1b1406;
  --mafia: #e0565b;
  --town: #4fa3e3;
  --doctor: #4cc38a;
  --detective: #b18cf0;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }

.hero { text-align: center; padding: 40px 0 16px; }
.hero .emoji { font-size: 64px; line-height: 1; margin-bottom: 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

button, .button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 650;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
}
button.primary { background: var(--accent); color: var(--accent-text); }
button.danger { background: transparent; color: var(--mafia); border: 1px solid var(--line); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.icon { width: 40px; height: 40px; padding: 0; border-radius: 10px; flex: none; font-size: 20px; }

input {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--accent);
}

.qr {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  border-radius: 12px;
  background: #fff;
  aspect-ratio: 1;
}
.link { word-break: break-all; font-size: 14px; color: var(--muted); text-align: center; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--doctor); flex: none; }
.dot.off { background: var(--line); }

.badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  flex: none;
}
.badge.mafia { background: var(--mafia); color: #fff; }
.badge.doctor { background: var(--doctor); color: #062015; }
.badge.detective { background: var(--detective); color: #180d2b; }
.badge.villager { background: var(--town); color: #04182a; }
.badge.hidden { background: var(--panel-2); color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.stepper .label { flex: 1; font-weight: 600; }
.stepper .value { width: 32px; text-align: center; font-size: 20px; font-weight: 700; }

.note { color: var(--mafia); font-size: 15px; text-align: center; min-height: 1.4em; }

/* The press-and-hold role card */
.card {
  position: relative;
  min-height: 340px;
  border-radius: 24px;
  border: 2px dashed var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 22px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.card .big { font-size: 56px; line-height: 1; margin-bottom: 12px; }
.card.shown { border-style: solid; transform: scale(.985); }
.card.shown.mafia { background: #3a1517; border-color: var(--mafia); }
.card.shown.doctor { background: #10301f; border-color: var(--doctor); }
.card.shown.detective { background: #261a3d; border-color: var(--detective); }
.card.shown.villager { background: #0f2638; border-color: var(--town); }
.card .role-title { font-size: 40px; font-weight: 800; margin-bottom: 10px; }
.card.shown.mafia .role-title { color: var(--mafia); }
.card.shown.doctor .role-title { color: var(--doctor); }
.card.shown.detective .role-title { color: var(--detective); }
.card.shown.villager .role-title { color: var(--town); }

.banner {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--accent);
  color: var(--accent-text);
  text-align: center;
  font-weight: 650;
  padding: 8px;
}
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: 448px;
  margin: 0 auto;
  background: #2c1a1c;
  border: 1px solid var(--mafia);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  z-index: 10;
  text-align: center;
}
[hidden] { display: none !important; }
