* { 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: 1rem;
  flex-wrap: wrap;
}
.input-row input {
  flex: 1; min-width: 180px;
  padding: 0.6rem 0.9rem;
  background: var(--emerald-50);
  border: 1px solid var(--emerald-200);
  border-radius: 0.55rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s;
}
.input-row input:focus {
  outline: none;
  border-color: var(--emerald-500);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.input-row input::placeholder { color: var(--text-light); }

/* ========== 反馈 ========== */
.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; }

/* ========== 排行榜 ========== */
.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; }
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.leaderboard-table th {
  background: var(--emerald-50);
  color: var(--emerald-700);
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 2px solid var(--emerald-200);
}
.leaderboard-table th:first-child { border-radius: 0.5rem 0 0 0; }
.leaderboard-table th:last-child { border-radius: 0 0.5rem 0 0; }
.leaderboard-table td {
  padding: 0.65rem 0.85rem;
  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); }
.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); }

/* ========== 弹窗 ========== */
.modal {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  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;
}
@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: 1500;
}

/* ========== 响应式 ========== */
@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; }
  .game-card, .leaderboard-card { padding: 1.25rem; }
  .game-title { font-size: 1.25rem; }
  .input-row { flex-direction: column; }
  .input-row input, .input-row .btn { width: 100%; }
  .leaderboard-table { font-size: 0.82rem; }
  .leaderboard-table th, .leaderboard-table td { padding: 0.5rem 0.55rem; }
  .modal-content { padding: 1.25rem; }
}
