/* === Design Tokens === */
:root {
  --brand: #8BB667;
  --brand-dark: #6ba15b;
  --brand-light: #a8cc8e;
  --brand-faint: #d6eac5;
  --text-primary: #4A6633;
  --text-secondary: #6b7c5a;
  --text-body: #444;
  --text-muted: #999;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fbf5;
  --bg-accent: #eaf5e1;
  --border: #d4e4c8;
  --border-light: #e8f0e0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(107,161,91,0.08);
  --shadow-md: 0 4px 20px rgba(107,161,91,0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--text-body);
  background: var(--bg-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* === Screen Management === */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Container === */
.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* === Buttons === */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
  text-align: center;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  padding: 14px 40px;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:active { transform: scale(0.97); }
.btn-outline {
  background: transparent;
  color: var(--brand-dark);
  border: 1.5px solid var(--border);
  padding: 13px 40px;
}
.btn-outline:hover { background: var(--bg-accent); }
.btn-lg {
  width: 100%;
  max-width: 320px;
  padding: 16px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* === Start Screen === */
.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  text-align: center;
  padding-top: 60px;
  padding-bottom: 60px;
}
.start-icon {
  font-size: 2.5rem;
  margin-bottom: 24px;
  opacity: 0.7;
}
.start-title {
  font-size: 1.75rem;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.start-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.start-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 48px;
  line-height: 1.8;
}

/* === Progress Bar === */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-light);
  z-index: 100;
}
.progress-fill {
  height: 100%;
  background: var(--brand);
  transition: width 0.35s var(--ease);
  width: 0%;
}

/* === Quiz Screen === */
.quiz-container {
  padding-top: 48px;
  padding-bottom: 40px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--font);
}
.btn-back:hover { color: var(--text-primary); }
.quiz-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.chapter-label {
  font-size: 0.8rem;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 500;
}
.quiz-title {
  font-size: 1.35rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 8px;
}
.quiz-body {
  font-size: 1rem;
  color: var(--text-body);
  margin-bottom: 28px;
  line-height: 1.7;
}

/* === Options === */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 20px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  font-family: var(--font);
}
.opt-title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.opt-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 400;
}
.option-btn:hover {
  background: var(--bg-accent);
  border-color: var(--brand-light);
}
.option-btn:hover .opt-title { color: var(--brand-dark); }
.option-btn.selected {
  background: var(--brand);
  border-color: var(--brand);
  transform: scale(0.98);
}
.option-btn.selected .opt-title { color: #fff; }
.option-btn.selected .opt-sub { color: rgba(255,255,255,0.8); }
.btn-neutral {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  font-family: var(--font);
}
.btn-neutral:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* === Loading Screen === */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  text-align: center;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* === Result Screen === */
.result-container {
  padding-top: 48px;
  padding-bottom: 60px;
}
.result-label {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: 36px;
}
.result-score {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.result-name {
  font-size: 1.75rem;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 4px;
}
.result-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.result-region {
  display: inline-block;
  padding: 3px 12px;
  background: var(--bg-accent);
  color: var(--brand-dark);
  border-radius: 100px;
  font-size: 0.8rem;
  margin-bottom: 16px;
}
.result-desc {
  font-size: 1rem;
  color: var(--text-body);
  line-height: 1.6;
}

/* === Report Section === */
.report-section { margin-bottom: 36px; }
.report-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  font-size: 0.95rem;
  color: var(--text-body);
  line-height: 1.85;
  min-height: 120px;
}
.report-content h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  font-weight: 600;
  margin: 20px 0 8px 0;
}
.report-content h3:first-child { margin-top: 0; }
.report-content p { margin-bottom: 10px; }
.report-content strong { color: var(--text-primary); }
.report-content em { color: var(--brand-dark); font-style: normal; }
.report-content ul, .report-content ol {
  padding-left: 1.2em;
  margin-bottom: 10px;
}
.report-content li { margin-bottom: 4px; }
.report-content hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 16px 0;
}
.report-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.report-placeholder .loading-spinner { margin-bottom: 12px; }
.report-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--brand);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

/* === Runners === */
.runners-title {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 16px;
}

/* === Runners === */
.runners-section { margin-bottom: 36px; }
.runners-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.runner-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 12px;
}
.runner-name {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 2px;
}
.runner-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.runner-score {
  font-size: 0.85rem;
  color: var(--brand);
  font-weight: 600;
}

/* === Actions === */
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.toast {
  text-align: center;
  font-size: 0.85rem;
  color: var(--brand-dark);
  margin-top: 12px;
  min-height: 1.5em;
}

/* === Responsive === */
@media (max-width: 480px) {
  .start-title { font-size: 1.5rem; }
  .quiz-title { font-size: 1.2rem; }
  .option-btn { padding: 14px 16px; font-size: 0.9rem; }
  .result-card { padding: 24px 16px; }
  .runners-grid { grid-template-columns: 1fr; }
  .result-actions { flex-direction: column; align-items: center; }
  .result-actions .btn { width: 100%; max-width: 280px; }
}

/* === CTA Reader Banner === */
.cta-reader-wrap { margin-bottom: 24px; }
.cta-reader-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 8px;
  padding: 0 4px;
}
.cta-reader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
  background: var(--bg-accent);
  border: 1px solid var(--brand-faint);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all 0.2s var(--ease);
}
.cta-reader:hover {
  background: var(--brand-faint);
  border-color: var(--brand-light);
}
.cta-reader-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.03em;
  line-height: 1.6;
}
.cta-reader-badge.full {
  background: #e8f5e1;
  color: #5a9a3f;
}
.cta-reader-badge.info {
  background: #fff3e0;
  color: #c77c2a;
}
.cta-reader-text {
  flex: 1;
  color: var(--text-body);
}
.cta-reader-text strong {
  color: var(--brand-dark);
}
.cta-reader-arrow {
  font-size: 1.4rem;
  color: var(--brand-light);
  flex-shrink: 0;
  line-height: 1;
}

/* === Share Overlay === */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s var(--ease);
}
.share-panel {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 420px;
  width: 90vw;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.share-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.share-close:hover { color: var(--text-body); }
.share-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  margin-top: 4px;
}
.share-img-wrap {
  width: 100%;
  max-height: 60dvh;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.share-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
}
.share-download {
  width: 100%;
  max-width: 280px;
}

/* === Watermark === */
.watermark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  font-size: 0.75rem;
  color: var(--brand-light);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s var(--ease);
  letter-spacing: 0.02em;
}
.watermark:hover {
  opacity: 1;
}
.watermark-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
