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

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  line-height: 1.6;
  min-height: 100vh;
  /* 背景图：根目录 bg.png；不存在时退化为纯色 */
  background: #f4f6fb url('/public/bg.png') center/cover fixed no-repeat;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(244, 246, 251, 0.86);
  z-index: -1;
}

.topbar {
  background: rgba(30, 41, 59, 0.95);
  color: #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
}
.brand { font-weight: 700; font-size: 18px; color: #fff; }
.topbar nav { display: flex; gap: 6px; flex: 1; }
.topbar nav a {
  color: #cbd5e1; text-decoration: none; padding: 6px 12px; border-radius: 6px;
}
.topbar nav a:hover, .topbar nav a.active { background: #334155; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.link-btn { background: none; border: none; color: #93c5fd; cursor: pointer; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }
#user-badge { color: #fbbf24; font-weight: 600; }

.container { max-width: 900px; margin: 24px auto; padding: 0 16px 60px; }
.view { display: block; }
.view.hidden, .hidden { display: none !important; }

h2 { margin-bottom: 16px; color: #111827; }

.card {
  background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 6px rgba(0,0,0,.08);
  margin-bottom: 16px;
}
.card-title { font-weight: 700; margin-bottom: 8px; color: #374151; }
.narrow { max-width: 420px; margin: 0 auto; }

.problem { font-size: 16px; }
.problem p { margin-bottom: 10px; }
.problem-rating {
  display: inline-block; background: #eef2ff; color: #4338ca; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; font-size: 13px; margin-bottom: 10px;
}

.hints { margin-bottom: 14px; }
.hint-item {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 6px; font-size: 14px;
}

.btn-row { display: flex; gap: 10px; margin-bottom: 12px; }
.btn {
  border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; cursor: pointer;
  color: #fff; transition: opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-hint { background: #3b82f6; }
.btn-submit { background: #22c55e; }
.btn-giveup { background: #9ca3af; }

.answer-input {
  width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 10px;
  font-size: 15px; font-family: inherit; resize: vertical; margin-bottom: 12px;
}

.feedback { margin-bottom: 12px; font-weight: 600; }
.feedback.ok { color: #16a34a; }
.feedback.bad { color: #dc2626; }

label { display: block; margin-bottom: 12px; font-size: 14px; color: #374151; }
label input[type=email], label input[type=password], label input:not([type]) {
  width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; margin-top: 4px;
  font-size: 15px;
}
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; margin: 0; }
.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { flex: 1; margin-top: 0; }
.row-between { display: flex; justify-content: space-between; margin-top: 12px; }

.rank-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.rank-table th, .rank-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; }
.rank-table th { background: #f8fafc; color: #475569; font-weight: 600; }

.help-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
#help-content { line-height: 1.8; white-space: pre-wrap; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100;
  font-size: 14px;
}

.muted { color: #6b7280; }

#records-chart { background: #fff; border-radius: 10px; padding: 10px; }
