:root {
  --bg-dark: #0a1428;
  --bg-card: #1a2842;
  --gold: #c8aa6e;
  --gold-bright: #f0e6d2;
  --blue: #4285f4;
  --blue-glow: #4a90d9;
  --red: #e84057;
  --red-glow: #e85a6a;
  --green: #3ee07a;
  --gray: #5a6a88;
  --text-dim: #8a9bb5;
  --border: #2a3a5a;
}

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

html, body {
  height: 100%;
  background: var(--bg-dark);
  color: var(--gold-bright);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
button:active { transform: scale(0.97); }

/* ============ 主页 ============ */
.home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a2842, #0a1428);
  padding: 24px;
}
.hero { text-align: center; max-width: 480px; width: 100%; }
.title {
  font-size: 40px;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(200, 170, 110, 0.35);
}
.subtitle { margin-top: 12px; color: var(--text-dim); font-size: 15px; letter-spacing: 1px; }
.mode-buttons {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.mode-btn {
  width: 100%;
  padding: 28px 16px;
  font-size: 20px;
  font-weight: 700;
  color: #15203a;
  background: linear-gradient(135deg, #c8aa6e, #a68b4e);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mode-btn:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(200, 170, 110, 0.3); }
.hint { margin-top: 36px; color: var(--gray); font-size: 13px; line-height: 1.7; }

/* ============ 房间页 ============ */
.room { min-height: 100vh; padding-bottom: 40px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10, 20, 40, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.room-badge { font-size: 14px; color: var(--text-dim); }
.room-badge b { color: var(--gold); letter-spacing: 1px; }
.count {
  font-size: 14px;
  font-weight: 700;
  color: #15203a;
  background: var(--gold);
  padding: 2px 10px;
  border-radius: 10px;
}
.topbar-actions { display: flex; gap: 8px; }
.top-btn {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.top-btn:hover { border-color: var(--gold); color: var(--gold); }

/* 未加入 */
.card-view { display: flex; justify-content: center; padding: 48px 20px; }
.join-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}
.join-card h2 { font-size: 20px; color: var(--gold); font-weight: 700; }
.join-tip { margin-top: 8px; font-size: 12px; color: var(--gray); }
#nameInput {
  width: 100%;
  margin-top: 22px;
  padding: 14px 16px;
  font-size: 16px;
  background: #0f1d36;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--gold-bright);
  outline: none;
}
#nameInput:focus { border-color: var(--gold); }

/* 通用金色按钮 */
.gold-btn {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  color: #15203a;
  background: linear-gradient(135deg, #c8aa6e, #a68b4e);
  border-radius: 12px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}
.gold-btn:hover { transform: translateY(-2px); }
.gold-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  font-size: 15px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.ghost-btn:hover { border-color: var(--red-glow); color: var(--red-glow); }

.danger-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--red-glow);
  background: transparent;
  border: 1px solid var(--red-glow);
  border-radius: 12px;
  transition: background 0.15s ease;
}
.danger-btn:hover { background: rgba(232, 90, 106, 0.12); }

.kick-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--red-glow);
  color: var(--red-glow);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  transition: background 0.15s ease;
}
.kick-btn:hover { background: rgba(232, 90, 106, 0.12); }

/* 等待大厅 */
.lobby { padding: 20px; }
.status-line {
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
  margin: 18px 0 24px;
  letter-spacing: 1px;
}
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-width: 720px;
  margin: 0 auto;
}
.player-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: opacity 0.2s ease;
}
.player-card.me { border: 2px solid var(--gold); box-shadow: 0 0 14px rgba(200, 170, 110, 0.3); }
.player-card.disconnected { opacity: 0.45; }
.avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a3a5a, #1a2842);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}
.pc-info { min-width: 0; }
.pc-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pc-meta { margin-top: 3px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.tag-host {
  background: var(--gold);
  color: #15203a;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 700;
}
.tag-offline { color: var(--red-glow); font-weight: 700; }
.tag-manual { color: var(--gold); }

/* 房主手动添加玩家 */
.manual-add {
  display: flex;
  gap: 10px;
  max-width: 720px;
  margin: 18px auto 0;
}
#manualName {
  flex: 1;
  padding: 12px 14px;
  font-size: 15px;
  background: #0f1d36;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--gold-bright);
  outline: none;
}
#manualName:focus { border-color: var(--gold); }
.add-manual-btn { width: auto; margin-top: 0; padding: 12px 18px; flex-shrink: 0; }
.empty-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--gray);
  font-size: 13px;
  min-height: 66px;
}
.lobby-actions {
  max-width: 360px;
  margin: 32px auto 0;
}

/* 分队结果 */
.banner {
  text-align: center;
  margin: 28px 0 18px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
}
.team-name.blue-text { color: var(--blue-glow); text-shadow: 0 0 16px rgba(74, 144, 217, 0.6); }
.team-name.red-text { color: var(--red-glow); text-shadow: 0 0 16px rgba(232, 90, 106, 0.6); }
.vs { color: var(--text-dim); margin: 0 16px; font-size: 22px; }
.teams {
  display: flex;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}
.team-panel {
  flex: 1;
  border-radius: 16px;
  padding: 18px;
  min-height: 220px;
}
.team-panel.blue { background: linear-gradient(180deg, #1a3a6e, #1a2842); box-shadow: 0 0 24px rgba(74, 144, 217, 0.25); }
.team-panel.red { background: linear-gradient(180deg, #5a1822, #1a2842); box-shadow: 0 0 24px rgba(232, 90, 106, 0.25); }
.team-panel h3 { text-align: center; font-size: 18px; margin-bottom: 14px; color: var(--gold-bright); }
.team-list { list-style: none; }
.team-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: rgba(10, 20, 40, 0.45);
  border-radius: 10px;
  font-size: 14px;
}
.team-list li .avatar { width: 34px; height: 34px; font-size: 15px; }
.me-tag { color: var(--gold); font-weight: 700; font-size: 12px; margin-left: auto; }
.result-actions { max-width: 360px; margin: 28px auto 0; padding: 0 16px; }

/* ============ 历史弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.modal-card h3 { color: var(--gold); font-size: 18px; text-align: center; margin-bottom: 16px; }
.history-list { overflow-y: auto; flex: 1; }
.history-item {
  background: #0f1d36;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.history-head { font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.history-teams { font-size: 13px; line-height: 1.8; }
.history-blue { color: var(--blue-glow); }
.history-red { color: var(--red-glow); }
.history-empty { text-align: center; color: var(--gray); padding: 30px 0; font-size: 14px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: 80%;
  background: rgba(10, 20, 40, 0.95);
  border: 1px solid var(--border);
  color: var(--gold-bright);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

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

/* ============ 响应式 ============ */
@media (max-width: 600px) {
  .title { font-size: 32px; }
  .mode-buttons { grid-template-columns: 1fr; }
  .teams { flex-direction: column; }
  .player-grid { grid-template-columns: 1fr; }
}
