/* ====== CSS 变量 & 重置 ====== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@600;700;900&display=swap');

:root {
  --primary: #c9a96e;
  --primary-dark: #b8944f;
  --primary-light: #e2c891;
  --accent: #5db8a3;
  --accent-dark: #459e8a;
  --danger: #d66878;
  --warning: #e8a838;
  --bg-base: #0f1620;
  --bg-elevated: rgba(22, 33, 48, 0.88);
  --bg-card: rgba(25, 38, 55, 0.82);
  --bg-card-hover: rgba(32, 48, 68, 0.92);
  --bg-input: rgba(18, 28, 42, 0.9);
  --text-primary: #ddd5c8;
  --text-secondary: #8d9bab;
  --text-muted: #5c6c7e;
  --border-color: rgba(80, 110, 150, 0.22);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.3);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 480px;
  --font-display: 'Noto Serif SC', 'STSong', 'SimSun', 'Songti SC', serif;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background:
    radial-gradient(ellipse 900px 700px at 15% 5%, rgba(180, 145, 75, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 85% 90%, rgba(65, 130, 155, 0.05) 0%, transparent 55%),
    linear-gradient(170deg, #0f1620 0%, #131f2e 45%, #0d1a24 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

/* ====== 页面切换 ====== */
.page {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.page.active {
  display: flex;
  flex-direction: column;
  animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== 通用组件 ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 1;
  cursor: not-allowed;
  transform: none;
  background: rgba(40, 55, 75, 0.6) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
  border-color: var(--border-color) !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  box-shadow: 0 4px 16px rgba(201, 169, 110, 0.35);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 28px rgba(201, 169, 110, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #0d1a16;
  box-shadow: 0 4px 16px rgba(93, 184, 163, 0.3);
  font-weight: 700;
}

.btn-accent:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(93, 184, 163, 0.45);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c0475a);
  color: #fff;
  box-shadow: 0 4px 16px rgba(214, 104, 120, 0.3);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 18px;
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  font-size: 20px;
}

.btn-send {
  background: var(--primary);
  color: #1a1410;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-family);
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-group input, .input-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: var(--transition);
  font-family: var(--font-family);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.18);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.name-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: rgba(18, 28, 42, 0.6);
  color: var(--text-secondary);
  font-size: 13px;
}

.account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.profile-stat-item {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.profile-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.profile-stat-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-recent {
  margin-top: 10px;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
}

.profile-recent-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.75);
}

.profile-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-tab-btn {
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.profile-tab-btn.active {
  background: linear-gradient(135deg, var(--primary), #8f99ff);
  border-color: transparent;
  color: #fff;
}

.profile-tab-panel {
  display: none;
}

.profile-tab-panel.active {
  display: block;
}

.profile-filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.profile-filter-row select {
  width: auto;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-primary);
}

.profile-match-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.profile-match-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-match-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-empty {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
}

.profile-password-form .input-group {
  margin-bottom: 10px;
}

.profile-password-form .btn {
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 16px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.divider span {
  color: var(--text-muted);
  font-size: 14px;
}

.page-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.page-header h2 {
  font-size: 18px;
  flex: 1;
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: var(--font-family);
}

/* ====== 首页 ====== */
.home-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

.logo-section {
  text-align: center;
  margin-bottom: 40px;
}

.logo-icon {
  font-size: 72px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.logo-title {
  font-size: 36px;
  font-weight: 800;
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--primary-light), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 6px;
}

.logo-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 8px;
  letter-spacing: 2px;
}

.home-actions {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.home-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.back-to-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(15, 22, 32, 0.5);
  backdrop-filter: blur(6px);
  transition: var(--transition);
  letter-spacing: 1px;
}

.back-to-site:hover {
  color: var(--primary-light);
  border-color: var(--primary);
  background: rgba(201, 169, 110, 0.08);
}

.back-to-site-icon {
  font-size: 15px;
  transition: transform 0.3s ease;
}

.back-to-site:hover .back-to-site-icon {
  transform: translateX(-3px);
}

/* ====== 剧本选择页 ====== */
.scripts-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.script-card-item {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid var(--border-color);
}

.script-card-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.script-card-item .script-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.script-card-item .script-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.script-card-item .script-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.script-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ====== 大厅页 ====== */
.lobby-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  flex: 1;
}

.room-info-card {
  background: linear-gradient(135deg, rgba(201, 169, 110, 0.15), rgba(93, 184, 163, 0.1));
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
}

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.room-code-display .label {
  font-size: 14px;
  opacity: 0.8;
}

.room-code-display .code {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  font-family: var(--font-mono);
  color: var(--primary-light);
}

.btn-copy {
  background: rgba(201, 169, 110, 0.15);
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-copy:hover {
  background: rgba(201, 169, 110, 0.25);
}

.room-script-name {
  font-size: 16px;
  opacity: 0.9;
}

.players-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.players-section h3 span {
  color: var(--primary-light);
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.player-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: var(--transition);
  position: relative;
}

.player-card.is-host {
  border-color: var(--warning);
}

.player-card.is-ready {
  border-color: var(--accent);
}

.player-card.is-offline {
  opacity: 0.4;
}

.player-card .player-avatar {
  font-size: 36px;
  margin-bottom: 8px;
}

.player-card .player-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.player-card .player-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.player-tag.host {
  background: rgba(232, 168, 56, 0.15);
  color: var(--warning);
}

.player-tag.ready {
  background: rgba(93, 184, 163, 0.15);
  color: var(--accent);
}

.player-tag.waiting {
  background: rgba(80, 100, 130, 0.15);
  color: var(--text-muted);
}

.lobby-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.lobby-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* ====== 游戏页面 ====== */
#page-game {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#page-game.active {
  display: flex;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.game-phase-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.phase-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.round-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.game-char-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-avatar {
  font-size: 24px;
}

.char-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-light);
}

.game-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.phase-panel {
  display: none;
  padding: 16px;
  padding-bottom: 132px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.phase-panel.active {
  display: block;
}

.phase-action {
  position: sticky;
  bottom: 72px;
  padding: 10px 12px;
  margin-top: 10px;
  background: linear-gradient(180deg, rgba(15, 22, 32, 0), rgba(15, 22, 32, 0.8) 30%, rgba(15, 22, 32, 0.96));
  backdrop-filter: blur(8px);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 8;
}

.ready-status {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 6px 16px;
  border-radius: 20px;
}

/* ====== 阅读剧本阶段 ====== */
.script-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.script-header {
  padding: 20px;
  background: linear-gradient(135deg, #1a1230, #0e1a2e);
  border-bottom: 1px solid rgba(201, 169, 110, 0.15);
  position: relative;
  overflow: hidden;
}

.script-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(201, 169, 110, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.script-header h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.script-header .script-desc {
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
}

.script-public-info, .script-personal {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.script-public-info h4, .script-personal h4 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--primary-light);
}

.script-personal h4 {
  color: var(--danger);
}

.info-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ====== 搜证阶段 ====== */
.investigate-container h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.phase-tip {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.location-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.location-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.location-card:active {
  transform: scale(0.96);
}

.location-card .loc-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.location-card .loc-name {
  font-size: 14px;
  font-weight: 600;
}

.location-card .loc-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.clues-section, .shared-clues-section {
  margin-bottom: 20px;
}

.clues-section h4, .shared-clues-section h4 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.clues-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clue-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}

.clue-item.shared {
  border-left-color: var(--accent);
}

.clue-item .clue-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clue-item .clue-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.clue-item .clue-location {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.clue-item .btn-share {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-family);
  white-space: nowrap;
}

.clue-item .clue-shared-by {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 36px 20px;
  border: 2px dashed rgba(80, 110, 150, 0.2);
  border-radius: var(--radius);
  background: rgba(18, 28, 42, 0.3);
  line-height: 1.6;
}

/* ====== 讨论阶段 ====== */
.discuss-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  height: calc(100dvh - 180px);
}

.discuss-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

#tab-chat {
  display: none;
}

#tab-chat.active {
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
}

.chat-system-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
  background: rgba(201, 169, 110, 0.08);
  border-radius: 20px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-msg.is-self {
  flex-direction: row-reverse;
}

.chat-msg .msg-avatar {
  font-size: 28px;
  flex-shrink: 0;
}

.chat-msg .msg-bubble {
  max-width: 75%;
  background: var(--bg-input);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
}

.chat-msg.is-self .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px 12px 4px 12px;
  color: #1a1410;
}

.chat-msg .msg-name {
  font-size: 12px;
  color: var(--primary-light);
  margin-bottom: 4px;
  font-weight: 600;
}

.chat-msg.is-self .msg-name {
  color: rgba(26, 20, 16, 0.6);
  text-align: right;
}

.chat-msg .msg-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg .msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-msg.is-self .msg-time {
  text-align: right;
  color: rgba(26, 20, 16, 0.45);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-family: var(--font-family);
}

.chat-input-area input:focus {
  border-color: var(--primary);
}

/* 讨论阶段：结束讨论区域不再固定悬浮，避免遮挡输入框 */
#phase-discuss .phase-action {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  padding: 8px 0 0;
  margin-top: 10px;
  background: transparent;
  z-index: auto;
}

.tab-clues-inner {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.tab-clues-inner h4 {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 12px 0 8px;
}

.chars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px;
  overflow-y: auto;
}

.char-info-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.char-info-card .char-avatar-lg {
  font-size: 40px;
}

.char-info-card .char-details {
  flex: 1;
}

.char-info-card .char-details h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.char-info-card .char-details p {
  font-size: 13px;
  color: var(--text-secondary);
}

.char-info-card .char-player-name {
  font-size: 12px;
  color: var(--primary-light);
  background: rgba(201, 169, 110, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ====== 投票阶段 ====== */
.vote-container {
  max-width: 500px;
  margin: 0 auto;
}

.vote-container h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.vote-card {
  background: var(--bg-card);
  border: 3px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.vote-card:hover {
  border-color: var(--danger);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(214, 104, 120, 0.25);
}

.vote-card.selected {
  border-color: var(--danger);
  background: rgba(214, 104, 120, 0.1);
  box-shadow: 0 0 0 4px rgba(214, 104, 120, 0.15), 0 8px 24px rgba(214, 104, 120, 0.2);
  transform: translateY(-2px);
}

.vote-card .vote-avatar {
  font-size: 48px;
  margin-bottom: 8px;
}

.vote-card .vote-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.vote-card .vote-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.vote-status {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
}

/* ====== 结果阶段 ====== */
.result-container {
  max-width: 540px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.result-header {
  text-align: center;
  padding: 30px 20px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
}

.result-header.correct {
  background: linear-gradient(135deg, rgba(0, 184, 148, 0.2), rgba(0, 184, 148, 0.05));
  border: 2px solid var(--accent);
}

.result-header.wrong {
  background: linear-gradient(135deg, rgba(225, 112, 85, 0.2), rgba(225, 112, 85, 0.05));
  border: 2px solid var(--danger);
}

.result-header .result-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.result-header .result-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-header .result-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

.result-votes {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.result-votes h3 {
  font-size: 17px;
  margin-bottom: 16px;
}

.result-vote-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.result-vote-item:last-child {
  border-bottom: none;
}

.result-vote-item .rvi-name {
  font-weight: 600;
}

.result-vote-item .rvi-count {
  color: var(--primary-light);
  font-size: 14px;
}

.result-vote-item .rvi-voters {
  font-size: 12px;
  color: var(--text-muted);
}

.result-truth {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

.result-truth h3 {
  font-size: 17px;
  margin-bottom: 12px;
  color: var(--danger);
}

.result-truth .truth-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ====== 底部导航 ====== */
.game-bottom-nav {
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.nav-btn {
  flex: 1;
  padding: 10px 4px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 54px;
  position: relative;
}

.nav-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active {
  color: var(--primary-light);
}

.nav-btn.active::before {
  transform: translateX(-50%) scaleX(1);
}

.nav-btn.disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ====== 模态弹窗 ====== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 17px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(214, 104, 120, 0.15);
  color: var(--danger);
}

.modal-body {
  padding: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--border-color);
}

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--primary);
  pointer-events: auto;
}

.toast.success {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-20px); opacity: 0; }
}

/* ====== 加载动画 ====== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====== 响应式 ====== */
@media (min-width: 768px) {
  :root {
    --max-width: 540px;
  }
  
  .home-container {
    padding: 60px 24px;
  }
  
  .logo-icon {
    font-size: 96px;
  }
  
  .logo-title {
    font-size: 48px;
  }

  .locations-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .vote-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .phase-action {
    bottom: 72px;
  }

  .discuss-container {
    height: calc(100vh - 160px);
  }
}

@media (min-width: 1024px) {
  .game-bottom-nav {
    max-width: 640px;
    margin: 0 auto;
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
  }
}

/* ====== 安全区域 (iPhone等) ====== */
@supports (padding: env(safe-area-inset-bottom)) {
  .game-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .phase-action {
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* ====== 滚动条美化 ====== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ====== 确认投票弹窗特殊样式 ====== */
.vote-confirm-content {
  text-align: center;
}

.vote-confirm-content .confirm-avatar {
  font-size: 64px;
  margin-bottom: 12px;
}

.vote-confirm-content .confirm-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.vote-confirm-content .confirm-warning {
  color: var(--danger);
  font-size: 14px;
}

/* ====== 暗夜剧场主题覆盖 ====== */
.home-actions,
.script-card-item,
.players-section,
.script-card,
.investigate-container,
.discuss-container,
.vote-container,
.result-container,
.clues-section,
.shared-clues-section,
.chat-messages,
.tab-content,
.modal {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.room-info-card {
  backdrop-filter: blur(10px);
}

.page-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.logo-title {
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--primary-light), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-subtitle,
.home-footer {
  color: var(--text-muted);
}

.phase-tip {
  color: var(--text-secondary);
}

.btn-secondary {
  background: rgba(22, 33, 48, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(201, 169, 110, 0.4);
  background: rgba(30, 44, 62, 0.85);
}

.btn-send {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  box-shadow: 0 4px 12px rgba(201, 169, 110, 0.25);
}

.input-group input,
.input-group select,
.chat-input-area input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.input-group input:focus,
.chat-input-area input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.15);
}

.player-card,
.location-card,
.clue-item,
.vote-card,
.char-info-card {
  background: rgba(22, 33, 48, 0.7);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.phase-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  box-shadow: 0 4px 12px rgba(201, 169, 110, 0.2);
  font-weight: 700;
}

.round-info {
  background: rgba(22, 33, 48, 0.6);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.game-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.game-bottom-nav {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
}

.nav-btn {
  color: var(--text-muted);
}

.nav-btn.active {
  color: var(--primary-light);
}

.tab-btn {
  background: rgba(22, 33, 48, 0.5);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  border-color: transparent;
  font-weight: 700;
}

.toast {
  background: rgba(22, 33, 48, 0.96);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.profile-stat-item {
  background: rgba(22, 33, 48, 0.6);
  border-color: var(--border-color);
}

.profile-recent-item {
  background: rgba(22, 33, 48, 0.5);
  border-color: var(--border-color);
}

.profile-tab-btn {
  background: rgba(22, 33, 48, 0.5);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.profile-tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent;
  color: #1a1410;
}

.profile-filter-row select {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.profile-match-item {
  background: rgba(22, 33, 48, 0.5);
  border-color: var(--border-color);
}

.profile-empty {
  background: rgba(18, 28, 42, 0.3);
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* ====== 阶段计时器 ====== */
.game-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  width: 100%;
  margin-top: 6px;
}

.timer-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 1s linear;
  width: 100%;
}

.timer-fill.timer-warning {
  background: linear-gradient(90deg, var(--warning), #c89020);
}

.timer-fill.timer-danger {
  background: linear-gradient(90deg, var(--danger), #b83c50);
  animation: timerPulse 0.8s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-text {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ====== 观战模式 ====== */
.spectator-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  background: rgba(93, 184, 163, 0.12);
  padding: 2px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

.btn-ghost {
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  margin-top: 6px;
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(201, 169, 110, 0.06);
}

.spectator-overlay {
  pointer-events: none;
  opacity: 0.5;
}

/* ====== 平票重投通知 ====== */
.revote-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(232, 168, 56, 0.1);
  border: 1px solid rgba(232, 168, 56, 0.3);
  border-radius: var(--radius);
  margin-top: 12px;
  animation: fadeSlideIn 0.3s ease;
}

.revote-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.revote-msg {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ====== 阶段面板入场动画 ====== */
.phase-panel.active {
  display: block;
  animation: phaseEnter 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes phaseEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== 列表交错入场 ====== */
.player-card,
.script-card-item,
.location-card,
.vote-card,
.clue-item,
.char-info-card {
  animation: itemReveal 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes itemReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.player-card:nth-child(1), .location-card:nth-child(1), .vote-card:nth-child(1) { animation-delay: 0.03s; }
.player-card:nth-child(2), .location-card:nth-child(2), .vote-card:nth-child(2) { animation-delay: 0.07s; }
.player-card:nth-child(3), .location-card:nth-child(3), .vote-card:nth-child(3) { animation-delay: 0.11s; }
.player-card:nth-child(4), .location-card:nth-child(4), .vote-card:nth-child(4) { animation-delay: 0.15s; }
.player-card:nth-child(5), .location-card:nth-child(5), .vote-card:nth-child(5) { animation-delay: 0.19s; }
.player-card:nth-child(6), .location-card:nth-child(6) { animation-delay: 0.23s; }

/* ====== 按钮加载态 ====== */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(200, 200, 200, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  left: 50%;
  top: 50%;
  margin: -9px 0 0 -9px;
}

.btn-primary.is-loading::after { border-top-color: #1a1410; }
.btn-accent.is-loading::after { border-top-color: #0d1a16; }
.btn-danger.is-loading::after { border-top-color: #fff; }

/* ====== 阶段氛围差异 ====== */
#phase-reading .script-card {
  border: 1px solid rgba(201, 169, 110, 0.15);
}

#phase-investigate .investigate-container {
  border-color: rgba(93, 184, 163, 0.15);
}

#phase-vote .vote-container {
  border-color: rgba(214, 104, 120, 0.15);
}

#phase-result .result-header.correct {
  background: linear-gradient(135deg, rgba(93, 184, 163, 0.15), rgba(93, 184, 163, 0.05));
  border-color: var(--accent);
}

#phase-result .result-header.wrong {
  background: linear-gradient(135deg, rgba(214, 104, 120, 0.15), rgba(214, 104, 120, 0.05));
  border-color: var(--danger);
}

/* ====== 投票卡选中动画 ====== */
.vote-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  animation: checkPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vote-card {
  position: relative;
}

@keyframes checkPop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ====== 增强空态 ====== */
.empty-hint::before {
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.4;
}

#myCluesList .empty-hint::before { content: '🔍'; }
#sharedCluesList .empty-hint::before { content: '📢'; }
#discussSharedClues .empty-hint::before { content: '📢'; }
#discussMyClues .empty-hint::before { content: '📎'; }
#discussCharsList .empty-hint::before { content: '👥'; }

/* ====== 大标题使用衬线体 ====== */
.logo-title,
.vote-container h3,
.investigate-container h3,
.result-header .result-title,
.script-header h3,
.result-votes h3,
.result-truth h3 {
  font-family: var(--font-display);
}

/* ====== 滚动条 (暗色) ====== */
::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 130, 160, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 130, 160, 0.35);
}
