:root {
  --bg: #0b1020;
  --bg-elev: #121a30;
  --bg-card: #16203a;
  --bg-hover: #1c294a;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e8eefc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.14);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.14);
  --cyan: #38bdf8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 12% 0%, #172554 0%, var(--bg) 42%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  color: #93c5fd;
}

.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 22px;
  background: rgba(18, 26, 48, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.brand-time {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: #7dd3fc;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.brand-time.time-upcoming {
  color: var(--amber);
}

.brand-time.time-ended {
  color: var(--red);
}

.hidden {
  display: none !important;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.contest-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  max-width: 260px;
  outline: none;
  cursor: pointer;
}

.contest-select:focus {
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  text-decoration: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  padding: 7px 12px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

/* 规则卡片 */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.rule-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.tag-blue {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.tag-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.tag-red {
  background: var(--red-bg);
  color: var(--red);
}

.tag-green {
  background: var(--green-bg);
  color: var(--green);
}

.rule-value {
  font-size: 17px;
  font-weight: 700;
}

.rule-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 上手指南 */
.guide-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.guide-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  user-select: none;
}

.guide-summary::-webkit-details-marker {
  display: none;
}

.guide-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.guide-steps {
  border-top: 1px solid var(--border);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.guide-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.guide-step p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* 统计条 */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stat-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-num {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-ac {
  color: var(--green);
}

.stat-ai {
  color: var(--cyan);
}

/* 排行榜卡片 */
.board-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.board-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.board-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.board-title-group h2 {
  margin: 0;
  font-size: 17px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.28);
  padding: 2px 9px;
  border-radius: 999px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.updated-at {
  font-size: 12px;
  color: var(--text-muted);
}

.board-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  width: 170px;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--primary);
  color: #fff;
}

/* 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  font-size: 13.5px;
}

.board-table th {
  text-align: center;
  padding: 11px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(11, 16, 32, 0.55);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.board-table th.col-user,
.board-table td.col-user {
  text-align: left;
  padding-left: 16px;
}

.board-table td {
  text-align: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.board-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  border-radius: 8px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rank-1 { background: rgba(250, 204, 21, 0.22); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.45); }
.rank-2 { background: rgba(203, 213, 225, 0.18); color: #e2e8f0; border: 1px solid rgba(203, 213, 225, 0.35); }
.rank-3 { background: rgba(251, 146, 60, 0.2); color: #fdba74; border: 1px solid rgba(251, 146, 60, 0.4); }
.rank-other { color: var(--text-muted); }

.user-name {
  font-weight: 700;
  color: var(--text);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.status-pill {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
}

.status-active {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.status-finished {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.ac-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.total-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.time-breakdown {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.prob-cell {
  border-radius: 8px;
  padding: 5px 8px;
  min-width: 78px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.prob-ac {
  background: var(--green-bg);
  border: 1px solid rgba(34, 197, 94, 0.32);
  color: #86efac;
}

.prob-wrong {
  background: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fca5a5;
}

.prob-none {
  color: #475569;
}

.prob-main {
  font-weight: 700;
  font-size: 12.5px;
}

.prob-sub {
  font-size: 11px;
  opacity: 0.85;
}

.empty-cell {
  padding: 42px 16px !important;
  color: var(--text-muted);
  font-size: 14px;
}

.board-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(11, 16, 32, 0.35);
}

@media (max-width: 960px) {
  .rules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .guide-steps {
    grid-template-columns: 1fr;
  }
  .stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .rules-grid {
    grid-template-columns: 1fr;
  }
}
