/* ============================================================================
 * 物理逻辑思维趣味小测验 · 移动端优先样式表（微信浏览器深度适配）
 * ============================================================================ */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #f59e0b;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --border: #e2e8f0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
}

.view {
  display: none;
  animation: fadeSlideIn 0.28s ease-out;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== 入口页 ==================== */
.hero-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 62%, #0284c7 100%);
  color: #ffffff;
  border-radius: 24px;
  padding: 26px 20px 24px;
  text-align: center;
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.24);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  top: -60px;
  right: -50px;
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
  letter-spacing: 0.4px;
}

.hero-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.hero-sub {
  font-size: 14px;
  opacity: 0.92;
  margin-bottom: 18px;
}

.pill-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.24);
  padding: 5px 11px;
  border-radius: 999px;
}

.panel-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 18px 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 16px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  gap: 8px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
}

.label-row .form-label {
  margin-bottom: 0;
}

.text-btn {
  background: var(--primary-soft);
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.text-btn:active {
  transform: scale(0.96);
}

input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-size: 16px; /* 16px 可防止 iOS 微信聚焦时自动放大页面 */
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.error-banner {
  background: var(--red-soft);
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.primary-btn {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.26);
  transition: transform 0.15s, opacity 0.15s;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.secondary-btn:active {
  background: #f1f5f9;
  transform: scale(0.98);
}

.privacy-note {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ==================== 答题页 ==================== */
.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.q-counter {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.q-counter strong {
  font-size: 19px;
  color: var(--primary);
}

.q-tag-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 800;
  color: #0f766e;
  background: #ccfbf1;
  padding: 4px 12px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s, color 0.2s;
}

.timer-badge.warn {
  background: #fef3c7;
  color: #b45309;
}

.timer-badge.danger {
  background: #fee2e2;
  color: #dc2626;
  animation: pulseFast 0.7s ease-in-out infinite;
}

@keyframes pulseFast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.timer-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #22c55e);
  border-radius: 999px;
  transition: background 0.25s;
}

.timer-bar.warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.timer-bar.danger {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.illus-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.illus-container svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.question-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px 15px 15px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.question-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1.55;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
}

.option-btn:active {
  transform: scale(0.985);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.16);
}

.opt-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}

.option-btn.selected .opt-key {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.timeout-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 14px;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

/* ==================== 过渡加载页 ==================== */
.loading-card {
  margin-top: 64px;
  background: var(--surface);
  border-radius: 24px;
  padding: 42px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.atom-spinner {
  font-size: 54px;
  display: inline-block;
  margin-bottom: 14px;
  animation: spinSlow 2.2s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ==================== 成绩单页 ==================== */
.result-hero {
  background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 55%, #2563eb 100%);
  color: #ffffff;
  border-radius: 24px;
  padding: 20px 18px 20px;
  box-shadow: 0 16px 36px rgba(30, 58, 138, 0.28);
  margin-bottom: 14px;
}

.result-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  opacity: 0.92;
  margin-bottom: 16px;
}

.result-user {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-time {
  flex-shrink: 0;
  white-space: nowrap;
}

.score-stage {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.score-ring {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 3px solid rgba(253, 224, 71, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-num {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  color: #fde047;
  font-variant-numeric: tabular-nums;
}

.score-unit {
  font-size: 11px;
  opacity: 0.88;
  margin-top: 3px;
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-badge-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.rank-emoji {
  font-size: 22px;
}

.rank-title {
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.3;
}

.rank-subtitle {
  font-size: 13px;
  color: #dbeafe;
  line-height: 1.45;
}

.result-dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.dot-item {
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.dot-item.ok {
  background: rgba(16, 185, 129, 0.9);
  color: #ffffff;
}

.dot-item.wrong {
  background: rgba(239, 68, 68, 0.88);
  color: #ffffff;
}

.dot-item.timeout {
  background: rgba(245, 158, 11, 0.92);
  color: #ffffff;
}

.ai-box {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 13px 14px;
}

.ai-box-head {
  font-size: 12px;
  font-weight: 700;
  color: #fde047;
  margin-bottom: 6px;
}

.ai-comment-text {
  font-size: 14px;
  line-height: 1.6;
  color: #ffffff;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.poster-btn {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  box-shadow: 0 8px 18px rgba(234, 88, 12, 0.28);
}

/* ==================== 逐题解析 ==================== */
.review-section {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.review-header h2 {
  font-size: 16px;
  font-weight: 800;
}

.filter-tabs {
  display: flex;
  gap: 6px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
  background: #f8fafc;
}

.review-item.is-wrong {
  border-color: #fecaca;
  background: #fffbfb;
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.review-qnum {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.status-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}

.status-chip.ok {
  background: var(--green-soft);
  color: #047857;
}

.status-chip.wrong {
  background: var(--red-soft);
  color: #b91c1c;
}

.status-chip.timeout {
  background: #fef3c7;
  color: #b45309;
}

.review-qtext {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.review-ans-line {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.review-explain {
  font-size: 13px;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 9px 11px;
  line-height: 1.55;
}

.empty-wrong {
  text-align: center;
  padding: 24px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #047857;
}

/* ==================== 海报弹窗 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  background: #ffffff;
  border-radius: 20px;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.poster-tip {
  font-size: 12px;
  color: #9a3412;
  background: #ffedd5;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 10px;
}

.poster-preview-wrap {
  overflow-y: auto;
  border-radius: 12px;
  background: #0f172a;
}

#poster-img {
  width: 100%;
  height: auto;
  display: block;
}

/* ==================== 10 张卡通 SVG 配图微动画（无损保留） ==================== */
@keyframes floatY {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}
@keyframes pulseQ {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(1.06); }
}
@keyframes dashMove {
  to { stroke-dashoffset: -24; }
}
.anim-float {
  animation: floatY 2.4s ease-in-out infinite;
}
.anim-pulse {
  animation: pulseQ 1.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.anim-dash {
  stroke-dasharray: 6 6;
  animation: dashMove 1.1s linear infinite;
}
