:root {
  --primary: #165dff;
  --primary-light: #4080ff;
  --success: #00b42a;
  --danger: #f53f3f;
  --warning: #ff7d00;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #667085;
  --line: #e5e7ef;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(22, 93, 255, 0.18), transparent 32%),
    linear-gradient(180deg, #eef4ff 0%, var(--bg) 42%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  color: #fff;
  padding: 34px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 18px 44px rgba(22, 93, 255, 0.28);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.back-link {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  margin-top: 22px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  letter-spacing: 0.08em;
  position: relative;
  z-index: 1;
}

.hero h1 {
  margin: 14px 0 8px;
  font-size: clamp(30px, 5vw, 48px);
  position: relative;
  z-index: 1;
}

.hero p {
  max-width: 680px;
  margin: 0 0 24px;
  opacity: 0.92;
  line-height: 1.8;
  position: relative;
  z-index: 1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  position: relative;
  z-index: 1;
}

.stats div {
  padding: 16px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  text-align: center;
}

.stats strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.stats span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.9;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

.muted,
.hint {
  color: var(--muted);
  line-height: 1.7;
}

.hint {
  font-size: 13px;
  margin: 14px 0 0;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.quick,
.primary,
.danger,
.ghost {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.quick {
  background: #f2f5fb;
  color: var(--muted);
}

.quick.active,
.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}

.danger {
  background: linear-gradient(135deg, var(--danger), #ff7676);
  color: #fff;
}

.ghost {
  background: #f2f5fb;
  color: var(--muted);
}

button:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 93, 255, 0.08);
}

.start-actions,
.nav-actions {
  display: flex;
  gap: 12px;
}

.start-actions button,
.nav-actions button {
  flex: 1;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
}

.tag {
  color: var(--primary);
  background: rgba(22, 93, 255, 0.08);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 700;
}

.progress {
  height: 10px;
  background: #edf1f7;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.25s ease;
}

.question-card h2 {
  font-size: 22px;
  line-height: 1.8;
  margin: 0 0 20px;
}

.question-image {
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
  cursor: zoom-in;
}

.image-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.question-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #fff;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 18px 38px;
  background: rgba(15, 23, 42, 0.86);
  overflow: auto;
}

.image-modal img {
  display: block;
  max-width: none;
  max-height: 82vh;
  width: min(1120px, 180vw);
  height: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.35);
}

.image-modal p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.image-modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  font-size: 30px;
  line-height: 1;
  box-shadow: var(--shadow);
}

body.modal-open {
  overflow: hidden;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.option-label {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f2f5fb;
  font-weight: 800;
}

.option.correct {
  border-color: var(--success);
  background: rgba(0, 180, 42, 0.07);
}

.option.correct .option-label {
  color: #fff;
  background: var(--success);
}

.option.wrong {
  border-color: var(--danger);
  background: rgba(245, 63, 63, 0.07);
}

.option.wrong .option-label {
  color: #fff;
  background: var(--danger);
}

.explain {
  margin-top: 18px;
  padding: 16px;
  border-left: 5px solid var(--primary);
  border-radius: 14px;
  background: #f0f6ff;
}

.explain p {
  color: var(--muted);
  line-height: 1.8;
  margin: 8px 0 0;
}

.score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.score span {
  font-size: 88px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}

.score small {
  color: var(--muted);
  font-weight: 700;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.result-summary div,
.wrong-item {
  border-radius: 14px;
  background: #f7f9fc;
  padding: 14px;
}

.result-summary strong {
  display: block;
  font-size: 24px;
  margin-bottom: 4px;
}

.result-summary span,
.wrong-item p {
  color: var(--muted);
  line-height: 1.7;
}

.wrong-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.wrong-item strong {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 40px));
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 99;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .hero,
  .panel {
    padding: 20px;
  }

  .stats,
  .quick-grid,
  .result-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .start-actions,
  .nav-actions {
    flex-direction: column;
  }
}
