/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Tokens ── */
:root {
  --bg: #0d0b1a;
  --surface: rgba(255,255,255,0.07);
  --surface-solid: #1a1630;
  --border: rgba(255,255,255,0.12);
  --primary: #6c8eff;
  --primary-dim: rgba(108,142,255,0.15);
  --success: #4ade80;
  --danger: #f87171;
  --gold: #fbbf24;
  --text: #f0eeff;
  --text-muted: rgba(240,238,255,0.5);
  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

/* ── App container ── */
.app-container {
  flex: 1; display: flex; flex-direction: column;
  max-width: 480px; width: 100%; margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 20px env(safe-area-inset-bottom, 20px);
  overflow: hidden;
}

/* ── Screens ── */
.screen {
  display: none; flex-direction: column; flex: 1;
  animation: fadeUp .25s ease;
  overflow-y: auto; overflow-x: hidden;
}
.screen.active { display: flex; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px; flex-shrink: 0;
}
.topbar-title {
  font-size: 1rem; font-weight: 700; color: var(--text-muted);
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer; flex-shrink: 0;
  transition: transform .1s;
}
.icon-btn:active { transform: scale(.93); }

/* ── Typography ── */
.title {
  font-size: 2.4rem; font-weight: 900;
  letter-spacing: -1px; text-align: center;
}
.subtitle {
  text-align: center; color: var(--text-muted);
  font-size: .95rem; margin-top: 8px;
}

/* ── Buttons ── */
.btn {
  width: 100%; padding: 18px 20px; border-radius: var(--radius);
  border: none; font-size: 1.1rem; font-weight: 800;
  cursor: pointer; transition: transform .1s, opacity .1s;
}
.btn:active { transform: scale(.97); }
.btn + .btn  { margin-top: 10px; }

.btn-green   { background: var(--success); color: #0d1f12; }
.btn-blue    { background: var(--primary); color: #fff; }
.btn-ghost   { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); }
.btn-danger  { background: var(--danger); color: #1a0505; }

/* ── Card ── */
.card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 12px; }

/* ── Home ── */
.logo-text {
  font-size: 3rem; font-weight: 900; letter-spacing: -2px;
  background: linear-gradient(135deg, #6c8eff 0%, #c084fc 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  display: inline-block;
}
.home-btn-group {
  margin-top: auto; display: flex;
  flex-direction: column; gap: 10px; padding-bottom: 10px;
}

/* ── Lang toggle ── */
.lang-toggle { display: flex; gap: 8px; }
.lang-btn {
  flex: 1; padding: 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: background .15s, color .15s;
}
.lang-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary); color: var(--text);
}

/* ── Setup ── */
.player-count-display { text-align: center; padding: 16px 0 8px; }
.player-count-num { font-size: 3rem; font-weight: 900; }
.player-count-label { color: var(--text-muted); font-size: .9rem; }

.slider-wrap { position: relative; padding: 24px 0 12px; }
.slider-emoji {
  position: absolute; top: 0; font-size: 28px;
  transition: left .15s; transform: translateX(-50%);
}
input[type=range] {
  -webkit-appearance: none; width: 100%; height: 6px;
  border-radius: 3px; background: rgba(255,255,255,0.15); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 10px rgba(108,142,255,.5);
  cursor: pointer; margin-top: -10px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: rgba(255,255,255,0.15);
}

.role-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.role-row + .role-row { border-top: 1px solid var(--border); }
.role-name { font-weight: 700; font-size: 1rem; }
.role-count {
  font-size: 1.5rem; font-weight: 900;
  min-width: 36px; text-align: center;
}
.role-ctrl { display: flex; align-items: center; gap: 10px; }

.circle-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.12); color: var(--text);
  font-size: 1.3rem; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.circle-btn:active { background: var(--primary-dim); }
.circle-btn:disabled { opacity: .25; cursor: default; }

/* ── Names input ── */
.name-input-list {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; flex: 1; padding-bottom: 8px;
}
.name-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
}
.name-num { color: var(--text-muted); font-weight: 700; min-width: 28px; font-size: .9rem; }
.name-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1rem; font-weight: 600;
  caret-color: var(--primary);
}
.name-input::placeholder { color: var(--text-muted); }

/* ── Pack buttons ── */
.pack-btn {
  width: 100%; padding: 16px 18px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem; font-weight: 700;
  cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s;
}
.pack-btn.active {
  background: var(--primary-dim); border-color: var(--primary);
}
.pack-btn + .pack-btn { margin-top: 8px; }

/* ── Reveal card ── */
.reveal-card {
  flex: 1; background: #fff; border-radius: 28px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 40px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  cursor: pointer; margin: 16px 0;
  transition: transform .1s;
}
.reveal-card:active { transform: scale(.98); }
.reveal-hint { font-size: 1rem; color: #666; line-height: 1.6; }
.reveal-word {
  font-size: 2.8rem; font-weight: 900; color: #111;
  letter-spacing: -1px; margin: 16px 0 8px;
}
.reveal-role-badge {
  font-size: .85rem; font-weight: 700;
  padding: 5px 14px; border-radius: 20px; margin-top: 8px;
}
.badge-citizen     { background: #dbeafe; color: #1d4ed8; }
.badge-infiltrator { background: #111; color: #fff; }
.badge-captain     { background: #fef3c7; color: #92400e; }

/* ── Play ── */
.alive-grid {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 12px 0;
}
.player-chip {
  padding: 8px 14px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .9rem; font-weight: 600; color: var(--text);
  transition: border-color .15s, background .15s;
}
.player-chip.turn-active {
  border-color: var(--primary); background: var(--primary-dim);
}

/* ── Vote ── */
.vote-btn {
  width: 100%; padding: 15px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.vote-btn + .vote-btn { margin-top: 8px; }
.vote-btn:active {
  background: rgba(248,113,113,.12);
  border-color: var(--danger);
}

/* ── Captain guess ── */
.guess-input {
  width: 100%; padding: 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  background: rgba(108,142,255,.08);
  color: var(--text); font-size: 1.3rem; font-weight: 700;
  text-align: center; outline: none; margin: 16px 0;
}
.guess-input::placeholder { color: var(--text-muted); }

/* ── Result ── */
.result-icon { font-size: 5rem; text-align: center; margin: 16px 0; }
.result-words {
  display: flex; gap: 10px; justify-content: center; margin: 16px 0;
}
.word-pill {
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 800; font-size: 1rem;
}
.word-citizen     { background: #dbeafe; color: #1e3a8a; }
.word-infiltrator { background: #111; color: #fff; }

.score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 10px; font-size: .9rem;
}
.score-row + .score-row { margin-top: 6px; }
.score-citizen     { background: rgba(96,165,250,.12); }
.score-infiltrator { background: rgba(255,255,255,.06); }
.score-captain     { background: rgba(251,191,36,.1); }

/* ── Utility ── */
.scroll-area { overflow-y: auto; flex: 1; }
.spacer      { flex: 1; }
