:root {
  --brand: #f4557f;
  --brand-light: #ff8fa9;
  --ink: #2f2b33;
  --muted: #9d8f96;
  --line: #f0e7eb;
  --card-shadow: 0 12px 32px rgba(214, 110, 145, 0.16);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ffd3e2 0%, #ffe1ec 38%, #fff5f8 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}

.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.blob-1 {
  width: 320px;
  height: 320px;
  top: -110px;
  left: -90px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}
.blob-2 {
  width: 380px;
  height: 380px;
  bottom: -160px;
  right: -120px;
  background: radial-gradient(circle, rgba(255, 176, 200, 0.75), rgba(255, 176, 200, 0));
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------------- 视图切换 ---------------- */

.view {
  display: none;
  width: 100%;
  max-width: 460px;
  flex: 1;
  flex-direction: column;
  justify-content: center;
}
.view.active { display: flex; }
.view.fading-out { animation: fadeOut 0.2s ease forwards; }
.view.fading-in { animation: fadeIn 0.3s ease both; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-4px); }
}

/* ---------------- 卡片 ---------------- */

.card {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--card-shadow);
}

/* ---------------- 主页 ---------------- */

.home-card {
  margin-top: 44px;
  padding: 58px 22px 26px;
}

.avatar-wrap {
  position: absolute;
  top: -44px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 96px;
  padding: 4px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(214, 110, 145, 0.22);
}
.avatar-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  background: #f7eef2;
}

.badge {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 5px 10px;
  font-size: 11px;
  color: #ef6d92;
  background: #fff0f5;
  border-radius: 999px;
  white-space: nowrap;
}

.title {
  margin: 16px 0 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  letter-spacing: 2px;
  white-space: pre-line;
}

.info {
  margin: 18px 0 20px;
  padding: 12px 16px;
  background: #f7f7fa;
  border-radius: 12px;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  line-height: 2.1;
  color: #6d6672;
}
.info-row .ico {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.btn-primary {
  display: block;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff;
  font-size: 17px;
  font-family: inherit;
  letter-spacing: 3px;
  box-shadow: 0 10px 22px rgba(244, 85, 127, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.btn-primary:active { transform: translateY(1px) scale(0.995); }

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  color: #c3aab4;
  white-space: pre-line;
}

/* ---------------- 缓冲页 ---------------- */

.loading-card {
  align-self: center;
  width: auto;
  min-width: 220px;
  padding: 42px 28px;
  text-align: center;
}
.loading-text {
  margin: 0 0 18px;
  font-size: 20px;
  letter-spacing: 4px;
  color: #4a4450;
}
.dots { display: flex; justify-content: center; gap: 8px; }
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  animation: bounce 1s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: 0.16s; }
.dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ---------------- 答题页 ---------------- */

#view-quiz {
  max-width: 520px;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 6vh;
}
.quiz { width: 100%; }

.ring-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
}
.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}
.ring-bg { stroke: rgba(255, 255, 255, 0.85); }
.ring-fg {
  stroke: var(--brand);
  transition: stroke-dashoffset 0.08s linear, stroke 0.2s ease;
}
.ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
  color: #6b5560;
  transition: color 0.2s ease, font-size 0.2s ease;
}
.ring-wrap.danger .ring-fg { stroke: #ff4d5e; }
.ring-wrap.danger .ring-text { color: #ff4d5e; }
.ring-wrap.timeout .ring-fg { stroke: #ffc2cb; }
.ring-wrap.timeout .ring-text { color: #ff4d5e; font-size: 32px; }

.qbox {
  position: relative;
  min-height: 112px;
  padding: 18px 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(214, 110, 145, 0.1);
}
.q-index {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 11px;
  color: #c3aab4;
}
.q-content {
  margin: 10px 0 0;
  font-size: 19px;
  line-height: 1.75;
  color: #33313a;
  word-break: break-word;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 13px 16px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(214, 110, 145, 0.08);
  font-family: inherit;
  font-size: 16.5px;
  line-height: 1.5;
  text-align: left;
  color: #3a3540;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease, transform 0.08s ease;
}
.opt:active { transform: scale(0.995); }
.opt .letter { min-width: 18px; font-size: 17px; font-weight: 700; color: #c9b3bd; }
.opt .text { flex: 1; word-break: break-word; }
.opt .mark {
  width: 24px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.opt.correct { background: #eafaf0; border-color: #37b46a; }
.opt.correct .letter { color: #2e9e5b; }
.opt.correct .mark { opacity: 1; color: #2e9e5b; }

.opt.wrong { background: #fdeeee; border-color: #e35b5b; }
.opt.wrong .letter { color: #d63d3d; }
.opt.wrong .mark { opacity: 1; color: #d63d3d; }

.opt.dim { opacity: 0.5; }
.opt.locked { cursor: default; }

.next-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.btn-next {
  height: 48px;
  padding: 0 28px;
  border: none;
  border-radius: 999px;
  background: #ececf2;
  color: #a9a2ac;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 1px;
  cursor: not-allowed;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.btn-next.ready {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff;
  box-shadow: 0 8px 18px rgba(244, 85, 127, 0.32);
  cursor: pointer;
}

/* ---------------- 结算页 ---------------- */

.result-card {
  padding: 28px 22px 24px;
  text-align: center;
}
.result-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: #3a3540;
  white-space: pre-line;
  letter-spacing: 1px;
}
.result-grid {
  display: flex;
  gap: 10px;
}
.result-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 6px;
  background: #f7f7fa;
  border-radius: 14px;
}
.result-item b { font-size: 30px; font-weight: 700; color: var(--brand); }
.result-item span { font-size: 13px; color: var(--muted); }

.rate-box { margin: 20px 0 24px; }
.rate b { font-size: 44px; font-weight: 700; color: var(--ink); }
.rate i { font-style: normal; margin-left: 2px; font-size: 20px; color: var(--muted); }
.rate-label { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

/* ---------------- 备案信息 ---------------- */

.beian {
  flex: 0 0 auto;
  width: 100%;
  padding: 10px 0 2px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}
.beian a {
  color: rgba(120, 90, 105, 0.72);
  text-decoration: none;
}
.beian a:active { opacity: 0.7; }

/* ---------------- 提示条 ---------------- */

.toast {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: 86vw;
  padding: 10px 18px;
  background: rgba(47, 43, 51, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 999px;
  text-align: center;
  animation: fadeIn 0.2s ease both;
}
