/* AI Hunter - Global Styles */

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-hover: #f0f0f0;
  --primary: #378ADD;
  --primary-hover: #185FA5;
  --text: #222;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e0e0e0;
  --danger: #E24B4A;
  --success: #639922;
  --warning: #BA7517;
  --purple: #7F77DD;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--surface);
  position: relative;
}

/* --- Pages --- */
.page {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}
.page.active {
  display: flex;
}

/* --- Landing --- */
.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  text-align: center;
}
.game-title {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.game-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}
.landing-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Buttons --- */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-full { width: 100%; margin-top: 16px; }

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.btn-back:hover { color: var(--text); }

.btn-send {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
}
.btn-send:hover { background: var(--primary-hover); }

/* --- Form --- */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h2 { font-size: 18px; font-weight: 600; }

.form-card {
  padding: 24px 20px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(55,138,221,0.15);
}
.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Nicknames --- */
.nickname-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}
@media (max-width: 480px) {
  .nickname-grid { grid-template-columns: repeat(2, 1fr); }
}

.nickname-btn {
  padding: 14px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}
.nickname-btn:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.nickname-btn.selected {
  border-color: var(--primary);
  background: #e0f0ff;
  font-weight: 600;
}

/* --- Waiting Room --- */
.waiting-content {
  padding: 24px 20px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}
.waiting-info { font-size: 16px; color: var(--text-secondary); margin-bottom: 20px; }
.room-code-badge {
  background: #f0f7ff;
  color: var(--primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.2s;
}
.room-code-badge:hover { background: #d0e8ff; }
.hint-text { color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px 0; }

/* --- Player List --- */
.player-list { margin-bottom: 20px; }
.player-item {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.player-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.player-dot.alive { background: var(--success); }
.player-dot.dead { background: var(--danger); }
.player-item.eliminated { opacity: 0.6; }
.player-item.ai-revealed { background: #fff0e6; }

/* --- Game Room --- */
#game-room {
  display: none;
  flex-direction: column;
  height: 100vh;
}
#game-room.active { display: flex; }

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.game-header-left { display: flex; align-items: center; gap: 12px; }
.game-phase-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.phase-discuss { background: #e0f0ff; color: var(--primary); }
.phase-vote { background: #fff0e0; color: var(--warning); }
.phase-tie { background: #f0e0ff; color: var(--purple); }
.phase-result { background: #e0ffe0; color: var(--success); }

.round-info { font-size: 14px; color: var(--text-secondary); }
.timer { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* --- Game Body --- */
.game-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.player-sidebar {
  width: 180px;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
  display: none;
}
.player-sidebar .sidebar-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 12px;
}
.player-sidebar .sidebar-title:first-child { margin-top: 0; }

@media (min-width: 640px) {
  .player-sidebar { display: block; }
}

/* --- Chat --- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-message {
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  word-break: break-word;
}
.chat-message.self {
  background: #e0f0ff;
  align-self: flex-end;
}
.chat-message.system {
  background: transparent;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px;
  max-width: 100%;
}
.chat-message strong {
  color: var(--primary);
  margin-right: 6px;
}

.discussion-topic {
  padding: 10px 16px;
  background: #fff8e0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--warning);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.chat-input-area input:focus { border-color: var(--primary); }

/* --- Overlays --- */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.overlay-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 450px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.overlay-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
  text-align: center;
}
.overlay-content p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

/* --- Vote --- */
.vote-countdown {
  text-align: center;
  font-size: 36px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 20px;
}
.vote-candidates {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 400px) {
  .vote-candidates { grid-template-columns: 1fr; }
}

.vote-candidate-btn {
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
}
.vote-candidate-btn:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.vote-candidate-btn.selected {
  border-color: var(--primary);
  background: #e0f0ff;
  box-shadow: 0 0 0 2px rgba(55,138,221,0.2);
}

/* --- Result --- */
.elimination-banner {
  text-align: center;
  padding: 20px;
  margin-bottom: 20px;
}
.eliminated-name {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}
.eliminated-label {
  display: block;
  font-size: 16px;
  color: var(--danger);
  margin-bottom: 8px;
}
.identity-unknown {
  font-size: 18px;
  color: var(--purple);
}

.vote-breakdown h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-secondary); }
.vote-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.vote-name {
  width: 80px;
  font-size: 13px;
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vote-bar-container {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.vote-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
  min-width: 4px;
  transition: width 0.5s ease;
}
.vote-count {
  width: 30px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Game Over --- */
.gameover-content { max-width: 500px; }
#gameover-banner {
  text-align: center;
  font-size: 72px;
  margin-bottom: 8px;
}
#gameover-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
}

.gameover-identities h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.identity-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.identity-card .identity-icon { font-size: 20px; }
.identity-card .identity-name { flex: 1; font-weight: 500; font-size: 14px; }
.identity-card .identity-type { font-size: 12px; color: var(--text-secondary); }
.identity-card .identity-status { font-size: 12px; font-weight: 500; }
.identity-card .identity-status.alive { color: var(--success); }
.identity-card .identity-status.dead { color: var(--danger); }
.identity-card.ai { background: #fff0e6; }
.identity-card.human { background: #f0f7ff; }
.identity-card.eliminated { opacity: 0.7; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }
