/* 谁是卧底 - 简洁现代风格 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff5c75;
  --text-primary: #f5f5f5;
  --text-secondary: #a8a8b8;
  --text-dim: #6c6c80;
  --success: #4caf50;
  --warning: #ff9800;
  --info: #2196f3;
  --border: rgba(255, 255, 255, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- 顶部状态栏 ---------- */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-info .label {
  color: var(--text-dim);
}

.room-id {
  font-family: "SF Mono", "Monaco", monospace;
  font-weight: bold;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 2px;
}

.me-info {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 50%;
  overflow: hidden;
}

#me-name {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#me-tags {
  display: flex;
  gap: 4px;
  font-size: 12px;
}

#me-tags .tag {
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

#me-tags .tag.host {
  background: var(--info);
}

#me-tags .tag.spy {
  background: var(--accent);
}

/* ---------- 视图切换 ---------- */
#main-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

/* ---------- Hero / 标题 ---------- */
.hero {
  text-align: center;
  padding: 40px 0 24px;
}

.hero h1 {
  font-size: 36px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), #ff9966);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.footer-hint {
  text-align: center;
  margin-top: 32px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- 表单卡片 ---------- */
.form-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 16px;
}

.form-card label {
  display: block;
  margin-bottom: 16px;
}

.form-card label span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.form-card input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-card input[type="text"]:focus {
  border-color: var(--accent);
}

.form-card input[type="text"]::placeholder {
  color: var(--text-dim);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.button-group .or {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff6b88);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), #ff7a92);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

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

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
}

.btn-big {
  padding: 18px 24px;
  font-size: 18px;
}

.btn-mini {
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
}

.btn-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
}

.btn-circle:active {
  transform: scale(0.92);
}

/* ---------- 错误提示 ---------- */
.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 14px;
  display: none;
}

.error-msg.show {
  display: block;
}

/* ---------- 等待大厅 ---------- */
.waiting-header {
  text-align: center;
  margin-bottom: 24px;
}

.waiting-header h2 {
  margin-bottom: 12px;
}

.big-room-id {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.big-room-id .room-id {
  font-size: 28px;
  letter-spacing: 4px;
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 8px;
}

.hint-mini {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
}

/* ---------- 设置行 ---------- */
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.setting-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.setting-item .label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 10px;
}

.n-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.n-control span {
  font-size: 24px;
  font-weight: bold;
  min-width: 32px;
}

.spy-master-display {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 8px;
  min-height: 24px;
}

.spy-master-display .placeholder {
  color: var(--text-dim);
  font-weight: normal;
  font-style: italic;
}

/* ---------- 出题人面板 ---------- */
.spy-master-panel {
  background: rgba(233, 69, 96, 0.08);
  border: 1px solid rgba(233, 69, 96, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.spy-master-panel h3 {
  margin-bottom: 12px;
  color: var(--accent);
}

.word-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.word-inputs label span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.word-inputs input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.word-inputs input:focus {
  border-color: var(--accent);
}

.word-display {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  min-height: 18px;
}

.word-display.has-words {
  color: var(--accent);
  font-weight: bold;
}

/* ---------- 玩家列表 ---------- */
.players-section {
  margin-bottom: 16px;
}

.players-section h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.player-list, .spy-players, .reveal-players, .vote-list, .order-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  transition: all 0.2s;
}

.player-item:active {
  cursor: grabbing;
}

.player-item.dragging {
  opacity: 0.5;
  background: rgba(233, 69, 96, 0.2);
}

.player-item.dead {
  opacity: 0.4;
  text-decoration: line-through;
}

.player-item.me {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.player-item.spy-master {
  border-color: var(--warning);
  background: rgba(255, 152, 0, 0.1);
}

.player-name {
  flex: 1;
  font-weight: 500;
}

.player-tags {
  display: flex;
  gap: 4px;
  font-size: 11px;
}

.player-tag {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.player-tag.host {
  background: var(--info);
}

.player-tag.spy {
  background: var(--accent);
}

.player-tag.alive {
  background: var(--success);
}

.player-tag.dead {
  background: var(--text-dim);
}

.player-tag.role-undercover {
  background: #9c27b0;
}

.player-tag.role-civilian {
  background: var(--success);
}

.drag-handle {
  color: var(--text-dim);
  font-size: 18px;
  cursor: grab;
}

/* ---------- 房主面板 ---------- */
.host-panel {
  margin-top: 16px;
  text-align: center;
}

/* ---------- 我的词卡片 ---------- */
.my-word-card {
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.15), rgba(255, 152, 0, 0.15));
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
}

.big-word {
  font-size: 48px;
  font-weight: bold;
  margin: 8px 0;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
}

.big-word-small {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
}

.role-hint {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---------- 出题人游戏视角 ---------- */
.spy-master-game-panel {
  background: rgba(255, 152, 0, 0.08);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.spy-master-game-panel h3 {
  color: var(--warning);
  margin-bottom: 8px;
  font-size: 14px;
}

.spy-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.spy-players .player-item {
  padding: 6px 10px;
  font-size: 13px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.spy-players .player-word {
  font-weight: bold;
  color: var(--accent);
}

/* ---------- 当前发言者 ---------- */
.current-speaker-card {
  background: rgba(33, 150, 243, 0.1);
  border: 2px solid var(--info);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(33, 150, 243, 0); }
}

.current-speaker-card h3 {
  font-size: 20px;
  color: var(--info);
}

/* ---------- 发言顺序进度 ---------- */
.order-progress {
  margin-bottom: 20px;
}

.order-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.order-item {
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  border: 1px solid var(--border);
}

.order-item.current {
  background: var(--info);
  color: white;
  font-weight: bold;
  transform: scale(1.1);
}

.order-item.done {
  opacity: 0.4;
  text-decoration: line-through;
}

.order-item.dead {
  opacity: 0.2;
}

/* ---------- 操作区 ---------- */
.action-area {
  text-align: center;
  margin: 20px 0;
}

/* ---------- 投票 ---------- */
.vote-instruction {
  text-align: center;
  margin-bottom: 16px;
}

.vote-instruction h3 {
  margin-bottom: 6px;
}

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

.vote-list .player-item {
  cursor: pointer;
}

.vote-list .player-item.selected {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.2);
}

.vote-list .vote-count {
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: bold;
  min-width: 28px;
  text-align: center;
}

.vote-list .player-item.selected-self .vote-count {
  background: var(--success);
}

.vote-progress {
  text-align: center;
  margin-top: 16px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---------- 结果 ---------- */
.result-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.result-card h2 {
  margin-bottom: 12px;
}

.winner-card {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(33, 150, 243, 0.2));
  border: 2px solid var(--success);
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.winner-card h1 {
  font-size: 32px;
  margin-bottom: 12px;
}

.winner-card.undercover-wins {
  background: linear-gradient(135deg, rgba(156, 39, 176, 0.2), rgba(233, 69, 96, 0.2));
  border-color: #9c27b0;
}

.reveal-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.reveal-card h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

.reveal-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.reveal-players .player-item {
  padding: 6px 10px;
  font-size: 13px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 200;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 工具类 ---------- */
.hidden {
  display: none !important;
}