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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #222240;
  --primary: #e94560;
  --primary-dark: #c73350;
  --secondary: #533483;
  --accent: #0f3460;
  --text: #eee;
  --text-dim: #999;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
}

.screen { display: none; flex-direction: column; gap: 16px; animation: fadeIn 0.3s; }
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Logo */
.logo { text-align: center; padding: 40px 0 20px; }
.logo-icon { font-size: 72px; margin-bottom: 8px; }
.logo h1 { font-size: 42px; letter-spacing: 8px; color: var(--primary); text-shadow: 0 0 30px rgba(233,69,96,0.5); }
.subtitle { color: var(--text-dim); margin-top: 4px; font-size: 14px; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Inputs */
input, select {
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus { border-color: var(--primary); }
select { padding-right: 36px; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
input::placeholder { color: var(--text-dim); }

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--secondary); }
.btn-danger { background: var(--danger); color: white; }
.btn-large { padding: 18px; font-size: 18px; }
.btn-icon { background: none; border: none; font-size: 24px; cursor: pointer; padding: 8px; }
.btn-vote {
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 14px 20px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}
.btn-vote:hover { border-color: var(--primary); background: var(--surface); }
.btn-vote.selected { border-color: var(--primary); background: rgba(233,69,96,0.15); }

.divider { text-align: center; color: var(--text-dim); font-size: 14px; position: relative; }
.divider span { background: var(--surface); padding: 0 12px; position: relative; z-index: 1; }
.divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--surface2); }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.code-badge {
  background: var(--primary);
  padding: 4px 14px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 20px;
  letter-spacing: 3px;
}

/* Player list */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
  font-size: 15px;
}
.player-list .crown { color: var(--warning); }
.player-list .bot-badge {
  background: #6c5ce7; color: white; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; margin-left: 4px;
}
.player-list .player-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--surface2);
}

/* Settings */
.setting-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 16px; }
.setting-row select { max-width: 55%; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.stepper span { font-size: 18px; font-weight: 600; min-width: 40px; text-align: center; }

/* Role reveal */
.role-reveal { text-align: center; padding: 40px 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.role-badge { font-size: 80px; animation: pulse 2s infinite; }
.word-display {
  font-size: 36px;
  font-weight: 800;
  padding: 20px 32px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 3px solid var(--primary);
  min-width: 200px;
}
.word-display.impostor { border-color: var(--danger); color: var(--danger); }
.category-hint { color: var(--text-dim); font-size: 14px; }

/* Timer */
.timer {
  font-size: 28px;
  font-weight: 700;
  font-family: monospace;
  color: var(--primary);
  min-width: 60px;
  text-align: right;
}
.timer.warning { color: var(--warning); animation: pulse 1s infinite; }
.timer.danger { color: var(--danger); animation: pulse 0.5s infinite; }

/* My word hint */
.my-word-hint {
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
}
.my-word-hint.crew { background: rgba(46,204,113,0.15); color: var(--success); }
.my-word-hint.impostor { background: rgba(231,76,60,0.15); color: var(--danger); }

/* Turn order */
.turn-order { padding-left: 24px; display: flex; flex-direction: column; gap: 6px; }
.turn-order li { padding: 6px 0; font-size: 15px; }

/* Vote */
.vote-list { display: flex; flex-direction: column; gap: 8px; }

/* Results */
.result-banner {
  text-align: center;
  padding: 24px;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 700;
}
.result-banner.crew-win { background: linear-gradient(135deg, rgba(46,204,113,0.2), rgba(46,204,113,0.05)); color: var(--success); }
.result-banner.impostor-win { background: linear-gradient(135deg, rgba(231,76,60,0.2), rgba(231,76,60,0.05)); color: var(--danger); }
.result-word { font-size: 24px; color: var(--primary); }

.vote-details { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.vote-details li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--surface2); font-size: 14px; }
.vote-details .voter { color: var(--text-dim); }

.scoreboard { padding-left: 24px; }
.scoreboard li { padding: 6px 0; font-size: 15px; }
.scoreboard li:first-child { color: var(--warning); font-weight: 700; font-size: 17px; }

#result-actions { display: flex; flex-direction: column; gap: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  transition: transform 0.3s;
  z-index: 100;
  border: 1px solid var(--surface2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }

.error { color: var(--danger); font-size: 14px; text-align: center; animation: shake 0.3s; }
.hint { color: var(--text-dim); font-size: 14px; text-align: center; }

/* Colors for avatars */
.avatar-0 { background: #e94560; }
.avatar-1 { background: #533483; }
.avatar-2 { background: #0f3460; }
.avatar-3 { background: #2ecc71; }
.avatar-4 { background: #f39c12; }
.avatar-5 { background: #9b59b6; }
.avatar-6 { background: #1abc9c; }
.avatar-7 { background: #e67e22; }
.avatar-8 { background: #3498db; }
.avatar-9 { background: #e74c3c; }
.avatar-10 { background: #2c3e50; }
.avatar-11 { background: #8e44ad; }

/* Current turn */
.current-turn { text-align: center; padding: 8px 0; }
.turn-label { font-size: 14px; color: var(--text-dim); display: block; }
.turn-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0;
  animation: fadeIn 0.3s;
}
.turn-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface2);
}
.turn-counter { font-size: 13px; color: var(--text-dim); }
.turn-card { border: 2px solid var(--primary); }

.turn-order li.active-turn {
  background: rgba(233,69,96,0.15);
  border-left: 3px solid var(--primary);
  font-weight: 700;
}
.turn-order li.done-turn {
  opacity: 0.4;
  text-decoration: line-through;
}

@media (max-width: 380px) {
  .logo h1 { font-size: 32px; letter-spacing: 4px; }
  .logo-icon { font-size: 56px; }
  .word-display { font-size: 28px; padding: 16px 24px; }
}
