/* ==========================================================================
   26 天文大赛 · 翻翻卡
   星空深蓝底 + 蓝紫渐变翻卡；纯原生 CSS，无任何外部资源（双击 file:// 可用）。
   ========================================================================== */

:root {
  --primary: #3b65d9;
  --primary-light: #6488ed;
  --primary-dark: #385aca;
  --deep: #0b1b3a;
  --deep-2: #0e2148;
  --ink: #1b2540;
  --text: #eaf0ff;
  --muted: #9fb0d0;
  --ok: #2e9e6b;
  --bad: #d9534f;
  --warn: #c98a2b;
  --card-radius: 28px;
  --shadow: 0 26px 64px rgba(2, 8, 24, 0.5);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 620px at 50% -12%, #1e3a78 0%, transparent 62%),
    radial-gradient(820px 520px at 88% 108%, #1b2f63 0%, transparent 58%),
    linear-gradient(180deg, #0b1b3a 0%, #0e1e42 52%, #09152c 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* 细微星点：平铺的径向渐变，避免额外图片与请求 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(1.5px 1.5px at 26px 34px, rgba(255, 255, 255, 0.85), transparent 58%),
    radial-gradient(1px 1px at 148px 96px, rgba(255, 255, 255, 0.55), transparent 58%),
    radial-gradient(1.7px 1.7px at 262px 188px, rgba(186, 212, 255, 0.7), transparent 58%),
    radial-gradient(1px 1px at 74px 244px, rgba(255, 255, 255, 0.45), transparent 58%),
    radial-gradient(1.2px 1.2px at 208px 40px, rgba(255, 255, 255, 0.5), transparent 58%);
  background-size: 320px 300px;
  animation: twinkle 9s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.45; }
  to { opacity: 0.85; }
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
}

.glow-a {
  width: 520px;
  height: 420px;
  top: -160px;
  left: -120px;
  background: rgba(72, 118, 226, 0.32);
}

.glow-b {
  width: 460px;
  height: 400px;
  right: -140px;
  bottom: -120px;
  background: rgba(109, 78, 214, 0.24);
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 28px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  font-size: 26px;
  color: #cfe0ff;
  background: linear-gradient(150deg, rgba(120, 158, 255, 0.35), rgba(70, 104, 208, 0.2));
  border: 1px solid rgba(150, 180, 255, 0.35);
  box-shadow: 0 10px 26px rgba(24, 58, 140, 0.35);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.35;
  white-space: nowrap;
}

.brand-copy p {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.stats {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 5px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.stats > div {
  min-width: 54px;
  padding: 5px 8px;
  text-align: center;
  border-radius: 10px;
}

.stats dt {
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.stats dd {
  margin: 1px 0 0;
  font-size: 16px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.stat-right dd {
  color: #6fe3ae;
}

.stat-wrong dd {
  color: #ff9a94;
}

.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.ghost-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

/* ---------------------------------------------------------------- 主区 */

.shell {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 34px;
}

/* ------------------------------------------------------------ 题包信息条 */

.pack-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 12px;
}

.pack-badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.6px;
  color: #cddcff;
  background: rgba(100, 136, 237, 0.22);
  border: 1px solid rgba(130, 165, 255, 0.35);
}

.pack-title {
  min-width: 0;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0.2px;
  color: #fff;
}

.pack-level {
  padding: 2px 8px;
  border-radius: 7px;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  color: #d8c48c;
  background: rgba(201, 138, 43, 0.16);
  border: 1px solid rgba(201, 138, 43, 0.3);
}

.pack-level:empty {
  display: none;
}

.pack-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* 云端同步状态：离线 / 待补交时才出现，不占常驻视觉空间 */
.sync-hint {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.2px;
  color: rgba(255, 196, 120, 0.85);
}

.sync-hint:empty {
  display: none;
}

.progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6488ed, #a5bcff);
  box-shadow: 0 0 14px rgba(130, 166, 255, 0.65);
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.progress-text {
  flex: none;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 0 0 12px;
  padding-left: 2px;
  font-size: 12.5px;
  letter-spacing: 0.4px;
  color: var(--muted);
}

/* ------------------------------------------------------------ 翻翻卡 */

.card-stage {
  perspective: 1600px;
}

.flashcard {
  position: relative;
  display: grid;
  cursor: pointer;
  border-radius: var(--card-radius);
  transform-style: preserve-3d;
  transition: transform 0.58s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard:focus-visible {
  box-shadow: 0 0 0 3px rgba(155, 185, 255, 0.85);
}

.face {
  grid-area: 1 / 1 / 2 / 2;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  padding: 40px 38px 34px;
  border-radius: var(--card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face-front {
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(600px 320px at 78% 8%, rgba(255, 255, 255, 0.22), transparent 62%),
    linear-gradient(150deg, #7095f6 0%, #3d65d5 52%, #2e4db4 100%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.face-back {
  gap: 16px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
  transform: rotateY(180deg);
}

.badge {
  flex: none;
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: #eaf1ff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.badge-dark {
  color: #5a6b8f;
  background: #f0f4fd;
  border-color: #e2e9f7;
}

.stem {
  margin: 0;
  max-width: 95%;
  font-size: clamp(20px, 2.7vw, 26px);
  font-weight: 600;
  line-height: 1.78;
  letter-spacing: 0.2px;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.flip-hint {
  flex: none;
  font-size: 12px;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.62);
}

.face-back .flip-hint {
  padding-top: 4px;
  color: #9aa7c0;
}

/* ------------------------------------------------------------ 选项按钮 */

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-block: auto; /* 选项在卡片里垂直居中，避免下方留一大块空白 */
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 78px;
  padding: 15px 15px;
  border: 1.5px solid #e3e9f5;
  border-radius: 16px;
  background: #f7f9fe;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, background 0.16s, box-shadow 0.16s;
}

.option .letter {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--primary-dark);
  background: #e8eefc;
  transition: background 0.16s, color 0.16s;
}

.option .text {
  padding-top: 2px;
}

.option:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #b9cbf2;
  background: #fff;
  box-shadow: 0 12px 26px rgba(59, 101, 217, 0.14);
}

.option:focus-visible {
  outline: 3px solid rgba(120, 158, 246, 0.7);
  outline-offset: 2px;
}

.option:disabled {
  cursor: default;
}

.option.is-correct {
  border-color: var(--ok);
  background: #eaf7f1;
}

.option.is-correct .letter {
  color: #fff;
  background: var(--ok);
}

.option.is-correct::after {
  content: "✓";
  margin-left: auto;
  padding: 2px 0 0 8px;
  font-weight: 800;
  color: var(--ok);
}

.option.is-wrong {
  border-color: var(--bad);
  background: #fdedec;
}

.option.is-wrong .letter {
  color: #fff;
  background: var(--bad);
}

.option.is-wrong::after {
  content: "×";
  margin-left: auto;
  padding: 2px 0 0 8px;
  font-weight: 800;
  color: var(--bad);
}

.option.is-dim {
  opacity: 0.45;
}

/* ------------------------------------------------------------ 答题反馈 */

.feedback {
  margin-top: 18px;
  padding: 20px 22px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.feedback.is-right {
  border-color: rgba(46, 158, 107, 0.5);
  box-shadow: 0 18px 44px rgba(20, 90, 60, 0.22);
}

.feedback.is-wrong {
  border-color: rgba(217, 83, 79, 0.48);
  box-shadow: 0 18px 44px rgba(110, 32, 30, 0.22);
}

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

.feedback-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.feedback-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.is-right .feedback-icon {
  background: var(--ok);
}

.is-wrong .feedback-icon {
  background: var(--bad);
}

.feedback-head strong {
  font-size: 18px;
  letter-spacing: 0.3px;
}

.feedback-next {
  margin-left: auto;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
  color: #c3cfe6;
  white-space: nowrap;
}

.feedback-answer {
  margin: 13px 0 0;
  font-size: 15.5px;
  font-weight: 600;
  color: #fff;
  overflow-wrap: anywhere;
}

/* 详细讲解：写给一年级小朋友，句子短、有比喻 */
.explain-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.explain-kicker {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 1px;
  color: #bcd0ff;
  background: rgba(100, 136, 237, 0.18);
}

.explain-text {
  margin: 9px 0 0;
  font-size: 13.5px;
  line-height: 1.9;
  color: #c8d4e9;
  overflow-wrap: anywhere;
}

/* 真配图：小体积 WebP，米白纸面像科普书里夹的一页 */
.figure-card {
  margin: 14px 0 0;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(150, 180, 255, 0.3);
  background: #f6f2e8;
  overflow: hidden;
}

.figure-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #f6f2e8;
}

.figure-card figcaption {
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(60, 80, 120, 0.12);
  font-size: 12px;
  line-height: 1.7;
  color: #41506c;
  background: #f6f2e8;
}

/* 配图占位：没有真图或图片加载失败时的回退 */
.figure-placeholder {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1.5px dashed rgba(150, 180, 255, 0.42);
  background: rgba(100, 136, 237, 0.1);
}

.figure-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 15px;
  color: #b9ccff;
  background: rgba(120, 155, 240, 0.22);
}

.figure-copy {
  min-width: 0;
}

.figure-copy small {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  color: #9db4e8;
}

.figure-copy p {
  margin: 5px 0 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: #c3cfe6;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- 按钮 */

.primary-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #6488ed, #3b65d9 60%, #385aca);
  box-shadow: 0 14px 32px rgba(59, 101, 217, 0.38);
  transition: transform 0.16s, filter 0.16s, box-shadow 0.16s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
  box-shadow: 0 18px 38px rgba(59, 101, 217, 0.45);
}

.primary-btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.primary-btn:focus-visible {
  outline: 3px solid rgba(155, 185, 255, 0.85);
  outline-offset: 3px;
}

/* 说明：讲解较长时「下一题」会落在视口下方，靠正常滚动即可；
   不做 sticky，避免按钮悬浮时盖住正在读的讲解文字。 */

/* ------------------------------------------------------------ 完成态 */

.done {
  padding: 56px 28px 44px;
  border-radius: var(--card-radius);
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.done-emblem {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 38px;
  color: #dce9ff;
  background: radial-gradient(circle at 32% 26%, rgba(150, 182, 255, 0.55), rgba(59, 101, 217, 0.24) 60%, rgba(59, 101, 217, 0.05));
  border: 1px solid rgba(160, 190, 255, 0.35);
  box-shadow: 0 0 42px rgba(110, 150, 255, 0.35), inset 0 0 24px rgba(255, 255, 255, 0.12);
}

.done h2 {
  margin: 16px 0 0;
  font-size: 23px;
  letter-spacing: 0.3px;
}

.done p {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--muted);
}

.done-next {
  color: #cbd7ee !important;
}

.done-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  margin: 24px auto 0;
}

.done-actions .ghost-btn {
  min-height: 44px;
}

/* ---------------------------------------------------------------- 底栏 */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 24px 34px;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: rgba(159, 176, 208, 0.7);
}

.footer .dot {
  opacity: 0.5;
}

/* 底栏的小文字按钮：迁移旧进度用（导出 → 在新站点导入） */
.footer-link {
  padding: 2px 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: rgba(198, 213, 238, 0.85);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.16s;
}

.footer-link:hover {
  color: #fff;
}

/* ------------------------------------------------------------ 响应式 */

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 22px 18px 16px;
  }

  .topbar-side {
    justify-content: space-between;
  }

  .brand-copy h1 {
    font-size: 19px;
    white-space: normal;
  }

  .shell {
    padding: 0 16px 28px;
  }
}

@media (max-width: 560px) {
  .pack-row {
    gap: 7px;
  }

  .pack-title {
    font-size: 15.5px;
  }

  .pack-count {
    margin-left: 0;
  }

  .stats > div {
    min-width: 48px;
    padding: 4px 6px;
  }

  .face {
    min-height: 340px;
    padding: 28px 20px 24px;
  }

  .stem {
    font-size: 19px;
    line-height: 1.72;
    max-width: 100%;
  }

  .options {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .option {
    min-height: 58px;
    padding: 12px 13px;
    font-size: 14.5px;
  }

  .feedback {
    padding: 17px 16px;
  }

  .feedback-next {
    margin-left: 0;
  }

  .primary-btn {
    min-height: 50px;
  }
}

/* 尊重系统「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
