:root {
  --primary: #6ba83a;
  --primary-dark: #4d7a28;
  --primary-light: #8ec765;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-top: 64px;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============ Header ============ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: relative;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.nav-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 4px;
}

.nav-logo-icon span {
  background: #fff;
  border-radius: 2px;
}

.nav-logo-icon span:nth-child(1),
.nav-logo-icon span:nth-child(5),
.nav-logo-icon span:nth-child(9) { background: var(--accent); }

.nav-menu {
  display: flex;
  gap: 4px;
  list-style: none;
  flex: 0 0 auto;
  justify-content: center;
}

.nav-menu a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-menu a:hover {
  color: var(--primary);
  background: #f0f7e8;
}

.nav-menu a.active {
  color: var(--primary);
  background: #f0f7e8;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  gap: 5px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s;
  position: relative;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-toggle:hover {
  background: #f0f7e8;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* ============ Hero ============ */
.hero {
  padding: 80px 0 60px;
  background: linear-gradient(135deg, #6ba83a 0%, #4d7a28 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 50%);
}

.hero-content {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.hero-text h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.2;
}

.hero-text p {
  font-size: 18px;
  opacity: 0.9;
  margin-bottom: 30px;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: #fff;
  color: var(--primary);
}

.btn-primary:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.5);
}

.btn-outline:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: #fff;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 16px;
}

/* Sudoku preview in hero */
.hero-puzzle {
  display: flex;
  justify-content: center;
}

.demo-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: #1e293b;
  border-radius: 10px;
  width: min(360px, 92vw);
  height: min(360px, 92vw);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  border: 3px solid #1e293b;
}

.demo-cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
}

.demo-cell:nth-child(9n) { border-right: none; }
.demo-cell:nth-last-child(-n+9) { border-bottom: none; }
.demo-cell.thick-right { border-right: 3px solid #1e293b !important; }
.demo-cell.thick-bottom { border-bottom: 3px solid #1e293b !important; }

.demo-cell.given { color: var(--primary); }
.demo-cell.user { color: var(--accent); }

/* ============ Sections ============ */
.section {
  padding: 80px 0;
  scroll-margin-top: 80px;
}

.section-title {
  text-align: center;
  margin-bottom: 50px;
}

.section-title h2 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}

.section-title p {
  font-size: 17px;
  color: var(--text-secondary);
}

/* ============ Stats ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-number {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.25;
  padding-bottom: 2px;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 14px;
}

/* ============ Features ============ */
.features {
  background: #fff;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.feature-card {
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.feature-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
}

.feature-card:nth-child(1) .feature-icon { background: #f0f7e8; color: var(--primary); }
.feature-card:nth-child(2) .feature-icon { background: #fef3c7; color: var(--accent); }
.feature-card:nth-child(3) .feature-icon { background: #d1fae5; color: var(--success); }
.feature-card:nth-child(4) .feature-icon { background: #fce7f3; color: #ec4899; }
.feature-card:nth-child(5) .feature-icon { background: #dbeafe; color: #3b82f6; }
.feature-card:nth-child(6) .feature-icon { background: #f3e8ff; color: #a855f7; }

.feature-card h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ============ Knowledge ============ */
.knowledge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

.knowledge-text h3 {
  font-size: 24px;
  margin-bottom: 16px;
  color: var(--primary-dark);
}

.knowledge-text p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.knowledge-list {
  list-style: none;
}

.knowledge-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.knowledge-list li::before {
  content: '✓';
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-top: 2px;
}

.knowledge-board-demo {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.mini-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  background: #1e293b;
  border: 3px solid #1e293b;
  border-radius: 6px;
  overflow: hidden;
}

.mini-cell {
  background: #fff;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
}

.mini-cell:nth-child(9n) { border-right: none; }
.mini-cell:nth-last-child(-n+9) { border-bottom: none; }
.mini-cell.thick-right { border-right: 3px solid #1e293b !important; }
.mini-cell.thick-bottom { border-bottom: 3px solid #1e293b !important; }

.mini-cell.given { color: var(--text); background: #f1f5f9; }
.mini-cell.highlight { background: #f0f7e8; }

/* ============ Difficulty Badges ============ */
.diff-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.diff-easy { background: #d1fae5; color: #065f46; }
.diff-medium { background: #fef3c7; color: #92400e; }
.diff-hard { background: #fee2e2; color: #991b1b; }
.diff-expert { background: #fce7f3; color: #9d174d; }

/* ============ Puzzle Card ============ */
.puzzle-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 768px) {
  .puzzle-list {
    grid-template-columns: 1fr;
  }
  .puzzle-card {
    padding: 16px;
  }
  .puzzle-card-top {
    flex-direction: column;
    gap: 14px;
  }
  .puzzle-info {
    align-items: center;
    text-align: center;
  }
  .puzzle-thumb {
    align-self: center;
  }
  .puzzle-thumb-board {
    width: 120px;
    height: 120px;
  }
  .puzzle-thumb {
    padding: 4px;
  }
  .container {
    padding: 0 14px;
  }
  .quick-nav {
    display: none;
  }
}

.puzzle-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  border: 1px solid transparent;
  cursor: pointer;
}

.puzzle-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.puzzle-card-top {
  display: flex;
  gap: 18px;
  align-items: stretch;
}

.puzzle-thumb {
  flex-shrink: 0;
  padding: 6px;
  background: linear-gradient(135deg, #f0f7e8, #faf5ff);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-thumb-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 140px;
  height: 140px;
  background: #1e293b;
  border: 2px solid #1e293b;
  border-radius: 4px;
  overflow: hidden;
  box-sizing: border-box;
}

.puzzle-thumb-board .pt-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #e2e8f0;
  font-weight: 400;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  font-size: 12px;
  line-height: 1;
  box-sizing: border-box;
}

.puzzle-thumb-board .pt-cell.pt-given {
  background: #f0f7e8;
  color: #6ba83a;
  font-weight: 700;
}

.puzzle-thumb-board .pt-cell:nth-child(9n) {
  border-right: none;
}

.puzzle-thumb-board .pt-cell.pt-tr {
  border-right: 2px solid #1e293b !important;
}

.puzzle-thumb-board .pt-cell.pt-tb {
  border-bottom: 2px solid #1e293b !important;
}

@supports not (display: grid) {
  .puzzle-thumb-board {
    display: block;
  }
  .puzzle-thumb-board .pt-cell {
    float: left;
    width: 11.11%;
    height: 11.11%;
  }
  .puzzle-thumb-board::after {
    content: '';
    display: table;
    clear: both;
  }
}

.puzzle-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.puzzle-date {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.puzzle-diff {
  margin-bottom: 8px;
}

.puzzle-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.puzzle-id {
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', Consolas, monospace;
}

.puzzle-time {
  color: var(--primary);
  font-weight: 500;
}

.puzzle-card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: flex-end;
}

.solved-badge {
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
}

.try-badge {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

/* ============ Filter Bar ============ */
.filter-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 40px;
  position: sticky;
  top: 64px;
  z-index: 50;
}

.filter-row {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group-diff {
  flex: 1;
  min-width: 0;
}

.filter-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-select {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 110px;
}

.filter-select:hover {
  border-color: var(--primary-light);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.diff-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.diff-chip {
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}

.diff-chip:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
}

.diff-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
}

.filter-stats {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-stats strong {
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  margin: 0 3px;
}

/* ============ Ranking Table ============ */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background: #f1f5f9;
}

.table th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table td {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  background: #f1f5f9;
  color: var(--text-secondary);
}

.rank-badge.top1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-badge.top2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-badge.top3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }

.time-cell {
  font-family: 'SF Mono', Consolas, monospace;
  font-weight: 600;
  color: var(--primary);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* ============ Page Header ============ */
.page-header {
  padding: 60px 0 40px;
  background: linear-gradient(135deg, #6ba83a 0%, #4d7a28 100%);
  color: #fff;
}

.page-header h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 8px;
}

.page-header p {
  opacity: 0.9;
}

/* ============ Tabs ============ */
.tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 32px;
}

.tab {
  flex: 1;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  background: transparent;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ============ Loading ============ */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ============ Footer ============ */
.footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 48px 0 24px;
  margin-top: 80px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
  justify-items: center;
}

.footer-qrcode-col {
  justify-self: center;
}

.footer-col h4 {
  color: #fff;
  font-size: 14px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 10px;
}

.footer-col a {
  color: #94a3b8;
  font-size: 14px;
  transition: color 0.2s;
}

.footer-col a:hover {
  color: #fff;
}

.footer-bottom {
  border-top: 1px solid #334155;
  padding-top: 24px;
  padding-bottom: 8px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.footer-bottom p {
  margin: 0;
}

.footer-bottom a {
  color: #94a3b8;
}

.footer-bottom a:hover {
  color: #fff;
}

.footer-brand-name {
  color: #fff !important;
  font-size: 15px !important;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ============ Quick Nav ============ */
.quick-nav {
  position: fixed;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.qn-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.9);
  color: #fff;
  border: none;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.qn-btn:hover {
  background: rgba(118, 75, 162, 0.95);
}

.qn-btn:active {
  transform: scale(0.93);
}

.qn-btn.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 769px) {
  .quick-nav {
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
  }
  .qn-btn {
    width: 46px;
    height: 46px;
    font-size: 17px;
  }
}

.btn-login {
  background: linear-gradient(135deg, #6ba83a, #4d7a28);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn-login:hover {
  opacity: 0.9;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.user-area:hover {
  opacity: 0.8;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.btn-logout:hover {
  color: #e74c3c;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .nav { gap: 0; height: 56px; justify-content: flex-start; }
  .nav-logo-text { font-size: 15px; white-space: nowrap; }
  .nav-logo-icon { width: 28px; height: 28px; }
  .nav-menu {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    gap: 2px;
    z-index: 9999;
  }
  .nav-menu li {
    width: 100%;
  }
  .nav-menu a {
    padding: 14px 24px;
    border-radius: 0;
    font-size: 16px;
    border-left: 3px solid transparent;
  }
  .nav-menu a:hover,
  .nav-menu a.active {
    background: #f5f3ff;
    border-left-color: var(--primary);
  }
  .nav-menu.open { display: flex !important; }
  .nav-toggle {
    display: flex;
    position: static;
    z-index: 100;
  }
  .nav-logo {
    position: static;
    flex: 1;
    align-items: center;
    justify-content: flex-start;
    pointer-events: auto;
    min-width: 0;
  }
  .nav-logo-text {
    max-width: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-user {
    position: static;
    flex-shrink: 0;
    margin-left: auto;
    z-index: 10;
  }
  .btn-login { padding: 5px 10px; font-size: 11px; }
  .user-name { display: none; }
  .user-avatar { width: 28px; height: 28px; }

  .hero-content { grid-template-columns: 1fr; text-align: center; place-items: center; }
  .hero-puzzle { width: 100%; display: flex; justify-content: center; align-items: center; }
  .hero-text h1 { font-size: 32px; }
  .hero-buttons { justify-content: center; }
  .demo-board { margin: 0 auto; }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .feature-grid { grid-template-columns: 1fr; }
  .knowledge { grid-template-columns: 1fr; }

  .footer-grid { grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
  .footer-qrcode-col { grid-column: 1 / -1; }

  .table-container { overflow-x: auto; }
}

@media (max-width: 480px) {
  .hero-text h1 { font-size: 28px; }
  .section { padding: 60px 0; }
  .section-title h2 { font-size: 28px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-number { font-size: clamp(22px, 6.5vw, 32px); }
}
/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 600px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #e2e8f0;
  transform: rotate(90deg);
}

.modal-body {
  padding: 28px 24px;
  text-align: center;
}

.modal-body .sudoku-board {
  margin: 12px auto;
  display: grid;
}

.modal-body .sudoku-cell.given {
  color: var(--primary);
}

.modal-body .hint-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
  text-align: left;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* ============ Sudoku Board (通用) ============ */
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 40px);
  grid-template-rows: repeat(9, 40px);
  background: #1e293b;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 3px solid #1e293b;
  width: max-content;
  height: max-content;
}

.sudoku-cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  position: relative;
}

.sudoku-cell:nth-child(9n) {
  border-right: none;
}

.sudoku-cell:nth-last-child(-n+9) {
  border-bottom: none;
}

.sudoku-cell.thick-right {
  border-right: 3px solid #1e293b !important;
}

.sudoku-cell.thick-bottom {
  border-bottom: 3px solid #1e293b !important;
}

.sudoku-cell.given {
  color: var(--primary);
  background: #f8fafc;
}

@media (max-width: 768px) {
  .sudoku-board {
    grid-template-columns: repeat(9, 30px);
    grid-template-rows: repeat(9, 30px);
    border-width: 2px;
  }
  .sudoku-cell { font-size: 14px; }
  .sudoku-cell.thick-right { border-right-width: 2px !important; }
  .sudoku-cell.thick-bottom { border-bottom-width: 2px !important; }
}

.puzzle-card {
  cursor: pointer;
}

.tip-card {
  cursor: pointer;
  position: relative;
}

.tip-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.tip-card-hint {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}

.tip-card:hover .tip-card-hint {
  opacity: 1;
}

.tip-detail {
  text-align: left;
  padding: 24px 28px;
}

.tip-detail h2 {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tip-detail h3 {
  font-size: 16px;
  margin: 20px 0 10px;
  color: var(--primary-dark);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}

.tip-detail p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 12px;
  font-size: 14px;
}

.tip-detail ul {
  list-style: none;
  padding: 0;
}

.tip-detail ul li {
  padding: 8px 0 8px 20px;
  position: relative;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.tip-detail ul li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--primary);
  font-weight: 700;
}

.tip-detail .tip-diff {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}

.tip-diff.easy { background: #d1fae5; color: #065f46; }
.tip-diff.medium { background: #fef3c7; color: #92400e; }
.tip-diff.hard { background: #fee2e2; color: #991b1b; }

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-qrcode-col {
  min-width: 240px;
  text-align: center;
}

.footer-qrcode-hint {
  font-size: 12px;
  color: #64748b;
  margin: 4px 0 8px;
}

.footer-qrcodes {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  justify-content: center;
}

.footer-qrcode {
  text-align: center;
}

.footer-qrcode img.qr-img {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  border: 2px solid #334155;
  background: #fff;
  display: block;
  margin: 0 auto;
  transition: transform 0.2s;
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
  cursor: zoom-in;
}

.footer-qrcode img.qr-img:hover {
  transform: scale(1.05);
}

.footer-qrcode span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
  }
  .footer-qrcode-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .footer-qrcode-col {
    grid-column: 1 / -1;
  }
  .footer-qrcodes {
    justify-content: center;
  }
}
/* ============ 手机浏览器适配 768px ============ */
@media (max-width: 768px) {
  body {
    padding-top: 56px;
  }
  .header {
    position: fixed;
    z-index: 100;
    left: 0;
    right: 0;
  }
  .filter-bar {
    position: sticky;
    top: 56px;
    z-index: 50;
    border-radius: 0;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .filter-group {
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .filter-group-diff {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-select {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    font-size: 16px;
  }
  .diff-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .diff-chips::-webkit-scrollbar { display: none; }
  .diff-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
  }
  .filter-stats {
    text-align: right;
    margin-left: 0;
    font-size: 13px;
  }
  .filter-stats strong {
    font-size: 18px;
  }

  .stat-card {
    flex: 1 1 45% !important;
    min-width: 0 !important;
  }

  .demo-board {
    margin: 0 auto;
  }

  .modal-overlay {
    align-items: center;
    padding: 10px 0;
  }
  .modal {
    width: 94%;
    max-width: 94%;
    max-height: calc(100vh - 20px);
    border-radius: 16px;
    margin: 0 auto;
  }
  .modal-body {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .tip-detail {
    padding: 20px 18px;
  }

  .page-header {
    padding: 32px 20px 24px;
  }
  .page-header h1 {
    font-size: 24px;
  }

  .puzzle-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .footer-qrcodes {
    flex-wrap: wrap;
  }
  .footer-qrcode img.qr-img {
    width: 130px;
    height: 130px;
  }

  .sudoku-board {
    grid-template-columns: repeat(9, 28px);
    grid-template-rows: repeat(9, 28px);
  }
  .sudoku-cell { font-size: 13px; }
}

/* ============ 手机浏览器适配 480px ============ */
@media (max-width: 480px) {
  .demo-board {
    margin: 0 auto;
  }

  .sudoku-board {
    grid-template-columns: repeat(9, 25px);
    grid-template-rows: repeat(9, 25px);
  }
  .sudoku-cell { font-size: 12px; }
  .sudoku-cell-note { font-size: 7px; }

  .stat-card {
    flex: 1 1 100% !important;
  }

  .filter-select {
    flex: 1 1 100%;
  }
}

/* ============ iOS 输入框防自动 zoom ============ */
input, select, textarea {
  font-size: 16px;
}

/* ============ 安全区 ============ */
.footer {
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* ============ 触屏优化 ============ */
@media (hover: none) {
  .tip-card:hover {
    transform: none;
  }
  .tip-card-hint {
    opacity: 1;
  }
  .puzzle-card:active,
  .tip-card:active {
    transform: scale(0.98);
  }
}
/* ============ Ranking 表格 → 手机卡片列表 ============ */
@media (max-width: 768px) {
  .table-container {
    overflow-x: visible;
  }
  .table:not(.ranking-table),
  .table:not(.ranking-table) thead,
  .table:not(.ranking-table) tbody,
  .table:not(.ranking-table) th,
  .table:not(.ranking-table) td,
  .table:not(.ranking-table) tr {
    display: block;
  }
  .table:not(.ranking-table) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table:not(.ranking-table) tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .table:not(.ranking-table) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    text-align: right;
  }
  .table:not(.ranking-table) td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
    padding-right: 12px;
    flex-shrink: 0;
  }
  .table:not(.ranking-table) td:first-child {
    justify-content: flex-start;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 6px;
  }
  .table:not(.ranking-table) td:first-child::before {
    display: none;
  }
  .table:not(.ranking-table) td:first-child {
    gap: 12px;
  }
  .user-cell {
    justify-content: flex-start;
  }
}
.intro-section {
  background: linear-gradient(135deg, #f8f9ff 0%, #fff 50%, #fdf6ff 100%);
  padding: 60px 0;
}

.intro-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.1);
}

.intro-text h2 {
  font-size: 28px;
  margin-bottom: 20px;
  color: #1a1a2e;
}

.intro-text p {
  color: #4a4a68;
  font-size: 15px;
  line-height: 1.9;
  margin-bottom: 14px;
}

.intro-text b {
  color: #6ba83a;
}

.intro-stats {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed #e2e8f0;
}

.intro-stat {
  text-align: center;
  flex: 1;
}

.intro-stat b {
  display: block;
  font-size: 24px;
  color: #6ba83a;
}

.intro-stat span {
  font-size: 12px;
  color: #94a3b8;
}

.intro-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.demo-intro {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  font-size: 16px;
}

@media (max-width: 768px) {
  .intro-card {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
  }
  .intro-text h2 {
    font-size: 22px;
  }
  .intro-stats {
    gap: 12px;
  }
}
.tip-modal h3 {
  font-size: 20px;
  color: #1a1a2e;
}

.tip-steps, .tip-example, .tip-tips {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: 12px;
}

.tip-steps {
  background: #f0faf0;
  border-left: 4px solid #27ae60;
}

.tip-steps h4 {
  font-size: 15px;
  color: #1e8449;
  margin-bottom: 10px;
}

.tip-steps ol {
  padding-left: 22px;
  margin: 0;
}

.tip-steps li {
  color: #333;
  font-size: 14px;
  line-height: 1.9;
  margin-bottom: 4px;
}

.tip-example {
  background: #fef9e7;
  border-left: 4px solid #f39c12;
}

.tip-example h4 {
  font-size: 15px;
  color: #b7791f;
  margin-bottom: 8px;
}

.tip-example p {
  color: #614300;
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}

.tip-tips {
  background: #eaf2f8;
  border-left: 4px solid #3498db;
}

.tip-tips h4 {
  font-size: 15px;
  color: #2471a3;
  margin-bottom: 8px;
}

.tip-tips p {
  color: #1b4f72;
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
  font-style: italic;
}
.modal-body .tip-board-wrap {
    overflow: visible;
    min-width: 280px;
}