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

:root {
  /* 翡翠绿主色调 */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;

  --cyan-50: #ecfeff;
  --cyan-100: #cffafe;

  --text: #064e3b;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --white: #ffffff;
  --border: #e5e7eb;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: linear-gradient(135deg, #ecfdf5 0%, #ecfeff 100%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ========== 导航栏（毛玻璃浅色） ========== */
.game-navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--emerald-200);
}
.nav-container {
  max-width: 1100px; margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex; justify-content: space-between; align-items: center;
}
.game-logo {
  font-size: 1.2rem; font-weight: 700;
  color: var(--emerald-700);
  text-decoration: none;
  letter-spacing: 0.3px;
}
.nav-links { display: flex; align-items: center; gap: 1.25rem; }
.nav-link {
  color: var(--emerald-700);
  text-decoration: none;
  font-size: 0.92rem; font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
}
.nav-link:hover {
  background: var(--emerald-50);
  color: var(--emerald-800);
}

/* 登录用户区域 */
.user-area { display: flex; align-items: center; gap: 0.6rem; }
.user-name {
  color: var(--emerald-700); font-size: 0.875rem; font-weight: 500;
}

/* ========== 按钮 ========== */
.btn {
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 0.55rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: var(--emerald-500);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.btn-primary:hover {
  background: var(--emerald-600);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: var(--emerald-300);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-outline {
  background: transparent;
  color: var(--emerald-700);
  border: 1px solid var(--emerald-300);
}
.btn-outline:hover {
  background: var(--emerald-50);
  border-color: var(--emerald-500);
}
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }

/* ========== 主体布局 ========== */
.game-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 6rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ========== 游戏卡片 ========== */
.game-card {
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.08);
}
.game-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.25rem;
}
.game-title {
  font-size: 1.5rem; font-weight: 700;
  color: var(--emerald-800);
  margin-bottom: 0.2rem;
}
.game-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.rule-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--emerald-100);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
  font-size: 1rem; font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.rule-btn:hover {
  background: var(--emerald-200);
  transform: scale(1.08);
}

/* ========== 进度条 ========== */
.progress-wrap { margin-bottom: 1.25rem; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.progress-bar {
  height: 12px;
  background: var(--emerald-50);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--emerald-100);
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--emerald-400), var(--emerald-600));
  border-radius: 6px;
  transition: width 0.4s ease, background 0.4s ease;
}
.progress-fill.warning {
  background: linear-gradient(90deg, #f87171, var(--danger));
}

/* ========== 输入区 ========== */
.input-row {
  display: flex; gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.input-row input {
  flex: 1; min-width: 180px;
  padding: 0.85rem 1.1rem;
  background: var(--white);
  border: 2px solid var(--emerald-400);
  border-radius: 0.6rem;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
}
.input-row input:focus {
  outline: none;
  border-color: var(--emerald-600);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2), 0 2px 10px rgba(16, 185, 129, 0.18);
}
.input-row input::placeholder { color: var(--text-light); font-weight: 500; font-size: 1rem; }

/* 大尺寸猜测按钮 */
.btn-guess {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
}

/* 重新开始按钮单独一行居中 */
.restart-row {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

/* ========== 反馈 ========== */
.feedback {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.75rem;
  border-radius: 0.6rem;
  background: var(--emerald-50);
  color: var(--emerald-700);
  margin-bottom: 1.25rem;
  min-height: 2.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.25s;
}
.feedback.higher {
  background: var(--danger-light);
  color: var(--danger);
}
.feedback.lower {
  background: var(--emerald-50);
  color: var(--emerald-700);
}
.feedback.win {
  background: var(--emerald-100);
  color: var(--emerald-800);
}
.feedback.lose {
  background: var(--danger-light);
  color: var(--danger);
}

/* ========== 猜测历史 ========== */
.history-wrap { margin-top: 0.5rem; }
.history-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}
.history-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  min-height: 36px;
}
.history-empty {
  color: var(--text-light);
  font-size: 0.85rem;
  font-style: italic;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
}
.chip.correct {
  background: var(--emerald-500);
  color: var(--white);
}
.chip.wrong {
  background: var(--danger);
  color: var(--white);
}
.chip .chip-num { font-weight: 700; }
.chip .chip-hint { font-size: 0.75rem; opacity: 0.9; }

/* ========== 排行榜与历史成绩并排 ========== */
.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
/* 当只有排行榜（未登录）时，让排行榜占满整行 */
.scores-grid:has(#my-scores-card.hidden) {
  grid-template-columns: 1fr;
}

/* ========== 排行榜 ========== */
.leaderboard-card {
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.08);
}
.leaderboard-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.3rem;
}
.leaderboard-title {
  font-size: 1.25rem; font-weight: 700;
  color: var(--emerald-800);
}
.leaderboard-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  /* 精致自定义滚动条 */
  scrollbar-width: thin;
  scrollbar-color: var(--emerald-300) transparent;
  border-radius: 0 0 12px 12px;
}
/* 超过 30 行时才启用垂直滚动 */
.table-wrap.scroll-enabled {
  overflow-y: auto;
  max-height: 70vh;
}
.table-wrap::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--emerald-300);
  border-radius: 3px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--emerald-500);
}

/* 表头固定，滚动时表头不消失 */
.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}
.leaderboard-table thead th {
  position: sticky;
  top: 0;
  background: var(--emerald-50);
  color: var(--emerald-700);
  font-weight: 600;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 2px solid var(--emerald-200);
  z-index: 1;
}
.leaderboard-table th:first-child { border-radius: 0; }
.leaderboard-table th:last-child { border-radius: 0; }
.leaderboard-table td {
  padding: 0.55rem 0.8rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.leaderboard-table tbody tr:nth-child(odd) { background: var(--white); }
.leaderboard-table tbody tr:nth-child(even) { background: var(--emerald-50); }
.leaderboard-table tbody tr:hover { background: var(--emerald-100); }

/* 成绩详情展开行 */
.score-name-cell {
  cursor: pointer;
  font-weight: 600;
  transition: color 0.2s;
}
.score-name-cell:hover {
  color: var(--emerald-700);
}
.detail-toggle {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-left: 2px;
}
.score-detail-row td {
  padding: 0;
  background: var(--emerald-50) !important;
}
.score-detail {
  padding: 1rem 1.2rem;
  background: linear-gradient(180deg, var(--emerald-50) 0%, #fff 100%);
}
.score-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--emerald-700);
}
.score-detail-target {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.score-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.score-detail-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--white);
  border: 1px solid var(--emerald-200);
  border-radius: 999px;
  font-size: 0.78rem;
}
.score-detail-item.correct {
  background: var(--emerald-100);
  border-color: var(--emerald-400);
  color: var(--emerald-800);
}
.score-detail-item.higher {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}
.score-detail-item.lower {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}
.detail-step {
  font-size: 0.7rem;
  opacity: 0.7;
}
.detail-guess {
  font-weight: 700;
}
.detail-hint {
  font-size: 0.72rem;
}
.empty-row {
  text-align: center;
  color: var(--text-light);
  padding: 1.5rem !important;
  font-style: italic;
}
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--emerald-100);
  color: var(--emerald-700);
  font-weight: 700;
  font-size: 0.8rem;
}
.rank-badge.gold { background: #fef3c7; color: #b45309; }
.rank-badge.silver { background: #e5e7eb; color: #4b5563; }
.rank-badge.bronze { background: #fed7aa; color: #9a3412; }
.result-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.result-tag.win { background: var(--emerald-100); color: var(--emerald-700); }
.result-tag.lose { background: var(--danger-light); color: var(--danger); }

/* 用户菜单 */
.user-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-name {
  font-weight: 600;
  color: var(--emerald-700);
}
.user-name-clickable {
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  transition: background 0.2s;
}
.user-name-clickable:hover {
  background: var(--emerald-100);
}
.user-avatar-img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.user-avatar-emoji {
  font-size: 1.2rem;
  margin-right: 0.3rem;
}
.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.15);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
}
.user-menu-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.user-menu-item:hover {
  background: var(--emerald-50);
}
.user-menu-item-danger {
  color: var(--danger);
}
.user-menu-item-danger:hover {
  background: var(--danger-light);
}

/* 弹窗样式 */
.modal-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: 2000;
}
.modal-content {
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--emerald-100);
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--emerald-800);
}
.modal-close {
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: background 0.2s;
}
.modal-close:hover {
  background: var(--emerald-100);
  color: var(--emerald-700);
}
.modal-body {
  padding: 1.5rem;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}
.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--emerald-200);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--emerald-500);
}
.modal-spacer {
  margin: 1rem 0;
}

/* 个人中心 */
.profile-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--emerald-50);
  border-radius: 12px;
}
.profile-avatar-wrap {
  flex-shrink: 0;
}
.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--white);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.profile-avatar-emoji {
  font-size: 3rem;
}
.profile-detail {
  flex: 1;
}
.profile-detail div {
  margin-bottom: 0.3rem;
}

/* 头像设置 */
.avatar-modal {
  max-width: 500px;
}
.avatar-options {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.avatar-option-group label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.5rem;
}
.avatar-grid-item {
  width: 100%;
  aspect-ratio: 1;
  font-size: 1.5rem;
  border: 2px solid var(--emerald-200);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
}
.avatar-grid-item:hover {
  border-color: var(--emerald-500);
  transform: scale(1.1);
}
.avatar-grid-item.avatar-selected {
  border-color: var(--emerald-500);
  background: var(--emerald-50);
  box-shadow: 0 0 0 2px var(--emerald-200);
}
.upload-area {
  border: 2px dashed var(--emerald-300);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-area:hover {
  border-color: var(--emerald-500);
}
.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.upload-text {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.upload-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* 裁剪 */
#avatar-crop-canvas {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  border: 2px solid var(--emerald-200);
  display: block;
  margin: 0 auto 1rem;
}
/* 游戏页裁剪弹窗：左侧预览，右侧裁剪画布 */
.game-crop-main {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  justify-content: center;
}
.game-crop-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--emerald-50);
  border: 2px solid var(--emerald-200);
  border-radius: 12px;
  padding: 0.75rem;
}
.game-crop-stage > canvas {
  display: block;
  width: 280px;
  height: 280px;
  max-width: 100%;
  cursor: grab;
  touch-action: none;
  background: #000;
  border-radius: 8px;
}
.game-crop-stage > canvas:active { cursor: grabbing; }

/* 左侧预览区域 */
.game-crop-preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}
.game-crop-preview-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
  text-transform: uppercase;
}
.game-crop-preview-box {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--emerald-500);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3), 0 0 0 4px rgba(16, 185, 129, 0.1);
  background: #000;
}
.game-crop-preview-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.game-crop-preview-size {
  font-size: 0.7rem;
  color: var(--text-light);
  margin: 0;
  font-family: monospace;
}

/* 响应式：小屏幕预览在上，裁剪在下 */
@media (max-width: 560px) {
  .game-crop-main { flex-direction: column; align-items: center; gap: 0.75rem; }
  .game-crop-stage > canvas { width: 100%; height: auto; aspect-ratio: 1/1; max-width: 260px; }
}
.crop-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.crop-controls input[type="range"] {
  width: 100%;
  max-width: 200px;
}

/* 登录/注册弹窗样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden {
  display: none;
}
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  z-index: 1;
  /* 自定义滚动条 */
  scrollbar-width: thin;
  scrollbar-color: var(--emerald-300) transparent;
}
.modal-content::-webkit-scrollbar {
  width: 6px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
  background: var(--emerald-300);
  border-radius: 3px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--emerald-500);
}
/* 个人中心弹窗：高度为视口的80% */
.modal-profile { max-height: 80vh !important; overflow-y: auto !important; }
/* 头像裁剪弹窗：高度为视口的70% */
.modal-avatar-crop { max-height: 70vh !important; overflow-y: auto !important; }
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  border: 1px solid var(--emerald-200);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  transition: all 0.2s;
  margin: -1rem -0.5rem 0.5rem auto;
}
.modal-close:hover {
  background: var(--emerald-50);
  border-color: var(--emerald-400);
  color: var(--emerald-700);
  transform: rotate(90deg);
}
.modal-title {
  clear: both;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--emerald-800);
  margin-bottom: 1.5rem;
  text-align: center;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--emerald-200);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.form-group input:focus {
  outline: none;
  border-color: var(--emerald-500);
}
.captcha-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: nowrap;
}
.captcha-row > div {
  flex: 1;
}
.captcha-btn, .captcha-display {
  padding: 0.75rem 1rem;
  white-space: nowrap;
  border: 2px solid var(--emerald-200);
  border-radius: 10px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  min-width: 90px;
  text-align: center;
}
.captcha-btn:hover {
  border-color: var(--emerald-500);
}
.checkbox-row {
  margin-bottom: 1rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.form-error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  text-align: center;
}
.btn-primary {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  background: var(--emerald-500);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: var(--emerald-600);
}
.btn-primary:disabled {
  background: var(--emerald-300);
  cursor: not-allowed;
}
.switch-text {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.switch-text a {
  color: var(--emerald-600);
  font-weight: 600;
  text-decoration: none;
}
.w-full {
  width: 100%;
}

/* 我的历史成绩卡片 */
.my-scores-card {
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.08);
}
.result-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.result-badge.won { background: var(--emerald-100); color: var(--emerald-700); }
.result-badge.lost { background: var(--danger-light); color: var(--danger); }

/* ========== 弹窗 ========== */
.modal {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(6, 78, 59, 0.45);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--white);
  border: 2px solid var(--emerald-200);
  border-radius: 16px;
  padding: 1.75rem;
  width: 90%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(6, 78, 59, 0.3);
  animation: slideUp 0.3s ease;
  z-index: 2001;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute; top: 0.85rem; right: 1rem;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--emerald-50);
  color: var(--emerald-700);
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--emerald-800);
  margin-bottom: 1rem;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  margin-top: 1.25rem;
}

/* 规则列表 */
.rule-list {
  list-style: none;
  padding: 0;
}
.rule-list li {
  padding: 0.5rem 0 0.5rem 1.4rem;
  position: relative;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  border-bottom: 1px dashed var(--emerald-100);
}
.rule-list li:last-child { border-bottom: none; }
.rule-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0.5rem;
  color: var(--emerald-500);
  font-weight: 700;
}
.rule-list strong { color: var(--emerald-700); }

/* ========== 表单（保存对话框） ========== */
.form-group {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-bottom: 1rem;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--emerald-700);
}
.form-group input {
  padding: 0.6rem 0.9rem;
  background: var(--emerald-50);
  border: 1px solid var(--emerald-200);
  border-radius: 0.55rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--emerald-500);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.form-hint.error { color: var(--danger); }
.form-hint.success { color: var(--emerald-600); }

/* ========== 结束弹窗内容 ========== */
.end-modal-content { max-width: 500px; }
.end-summary {
  background: var(--emerald-50);
  border-radius: 0.6rem;
  padding: 1rem;
  margin-bottom: 1rem;
}
.end-summary .summary-row {
  display: flex; justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}
.end-summary .summary-label { color: var(--text-muted); }
.end-summary .summary-value {
  color: var(--emerald-700);
  font-weight: 600;
}
.end-history { margin-top: 0.5rem; }
.end-actions { justify-content: space-between; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border: 1px solid var(--emerald-200);
  color: var(--emerald-800);
  padding: 0.7rem 1.4rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(6, 78, 59, 0.15);
  z-index: 2000;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== 烟花画布 ========== */
.fireworks-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .nav-container { padding: 0.85rem 1rem; }
  .nav-links { gap: 0.75rem; }
  .nav-link { display: none; }
  .game-main { padding: 5rem 1rem 2rem; gap: 1rem; }
  .game-card, .leaderboard-card { padding: 1.25rem; }
  .game-title { font-size: 1.25rem; }
  .game-subtitle { font-size: 0.8rem; }
  /* 输入区：移动端纵向堆叠 */
  .input-row { flex-direction: column; gap: 0.6rem; }
  .input-row input, .input-row .btn { width: 100%; }
  .input-row input { font-size: 1.05rem; padding: 0.75rem 1rem; }
  .btn-guess { padding: 0.75rem 1.25rem; }
  /* 重新开始按钮在移动端仍居中 */
  .restart-row { margin-bottom: 0.75rem; }
  /* 排行榜与历史成绩在移动端上下堆叠 */
  .scores-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  /* 即使已登录，移动端也堆叠 */
  .scores-grid:has(#my-scores-card.hidden) {
    grid-template-columns: 1fr;
  }
  .leaderboard-title { font-size: 1.1rem; }
  .leaderboard-table { font-size: 0.78rem; }
  .leaderboard-table th, .leaderboard-table td { padding: 0.45rem 0.4rem; }
  .leaderboard-subtitle { font-size: 0.72rem; margin-bottom: 0.6rem; }
  /* 移动端：超过 30 行时表格滚动高度更小 */
  .table-wrap.scroll-enabled { max-height: 50vh; }
  .modal-content { padding: 1.25rem; max-width: 95%; }
  .end-actions { flex-direction: column-reverse; gap: 0.5rem; }
  .end-actions .btn { width: 100%; }
  /* 移动端成绩详情更紧凑 */
  .score-detail { padding: 0.75rem 0.9rem; }
  .score-detail-item { font-size: 0.72rem; padding: 0.2rem 0.5rem; }
}

/* 中等屏幕：若同时显示两个表格，适当压缩内边距 */
@media (max-width: 1100px) and (min-width: 769px) {
  .scores-grid { gap: 1rem; }
  .leaderboard-card { padding: 1.25rem; }
  .leaderboard-table { font-size: 0.85rem; }
}

/* ========== 登录/注册 Tab 弹窗（与首页一致） ========== */
.auth-modal-content { max-width: 400px; }
.auth-tabs {
  display: flex; gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--emerald-50);
  border-radius: 0.5rem;
  padding: 0.25rem;
}
.auth-tab {
  flex: 1;
  padding: 0.55rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
  font-family: inherit;
}
.auth-tab:hover { color: var(--emerald-700); }
.auth-tab.active {
  background: var(--emerald-500);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.auth-form { display: flex; flex-direction: column; }
.auth-form.hidden { display: none; }

/* 全宽按钮 */
.btn-full { width: 100%; padding: 0.75rem; }

/* 错误提示 */
.error-msg {
  color: var(--danger);
  font-size: 0.825rem;
  text-align: center;
  min-height: 1.2rem;
  margin-top: 0.5rem;
}

/* 密码强度 */
.password-strength {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  min-height: 1rem;
}
.password-strength-bar {
  height: 3px;
  border-radius: 2px;
  margin-top: 0.2rem;
  transition: all 0.3s;
}
.strength-weak { color: var(--danger); }
.strength-medium { color: var(--warning); }
.strength-strong { color: var(--emerald-600); }
.bar-weak { background: var(--danger); width: 33%; }
.bar-medium { background: var(--warning); width: 66%; }
.bar-strong { background: var(--emerald-500); width: 100%; }

/* 验证码（覆盖旧的 captcha-row 样式） */
.captcha-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
}
.captcha-row input { flex: 1; min-width: 0; }
.captcha-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  padding: 0.55rem 0.85rem;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-family: 'Courier New', monospace;
  transition: opacity 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.captcha-code:hover { opacity: 0.85; }

/* 记住用户名复选框 */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.form-check input { width: auto; }
.form-check label { cursor: pointer; margin: 0; font-weight: 500; }
