:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app { max-width: 900px; margin: 0 auto; min-height: 100vh; }

.header {
  text-align: center;
  padding: 32px 16px 16px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.2);
}

.header h1 { font-size: 1.5rem; }
.header p { opacity: 0.9; margin-top: 4px; }

.page { display: none; padding: 20px 16px 40px; }
.page.active { display: block; }

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  text-align: center;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.card-icon { font-size: 2.8rem; margin-bottom: 12px; }
.card h2 { font-size: 1.25rem; margin-bottom: 8px; color: var(--primary-dark); }
.card p { color: var(--muted); font-size: 0.95rem; }

.badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--danger);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.progress { font-weight: 600; color: var(--muted); }
.timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.timer.warning { color: var(--warning); }
.timer.danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.question-box {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.q-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.q-type-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  margin-right: 8px;
  background: #e0e7ff;
  color: var(--primary-dark);
  vertical-align: middle;
}

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.option:hover { border-color: var(--primary); background: #f5f7ff; }
.option-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.option.selected { border-color: var(--primary); background: #eef2ff; }
.option.correct { border-color: var(--success); background: #f0fdf4; }
.option.wrong { border-color: var(--danger); background: #fef2f2; }
.option.disabled { cursor: default; pointer-events: none; }

.fill-input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  margin-bottom: 12px;
}
.fill-input:focus { outline: none; border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
  background: #e5e7eb;
  color: var(--text);
  transition: background 0.15s;
}
.btn:hover { background: #d1d5db; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-back { background: transparent; padding-left: 0; }
.btn-submit { background: var(--success); color: #fff; }
.btn-submit:hover { background: #16a34a; }
.btn-danger { background: var(--danger); color: #fff; }

.explanation {
  margin-top: 20px;
  padding: 16px;
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  color: #1e3a8a;
}

.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  justify-content: center;
}
.nav-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f9fafb;
  border-radius: 16px;
  padding: 12px;
  min-width: 80px;
}
.nav-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}
.nav-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.nav-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.nav-dot.answered { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-dot.current { box-shadow: 0 0 0 3px rgba(79,70,229,0.3); }

.result-card {
  background: var(--card);
  border-radius: 24px;
  padding: 36px 24px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  max-width: 480px;
  margin: 40px auto;
}
.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 24px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  background: conic-gradient(var(--success) 0deg, var(--success) var(--score-deg), var(--border) var(--score-deg));
  position: relative;
}
.score-circle::after {
  content: attr(data-text);
  position: absolute;
  inset: 12px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.wrong-list { display: flex; flex-direction: column; gap: 16px; }
.wrong-item {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.wrong-item .q-title { margin-bottom: 12px; }
.wrong-meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.wrong-count { color: var(--danger); font-weight: 700; }
.empty-tip {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .header h1 { font-size: 1.25rem; }
  .timer { font-size: 1.25rem; }
}
