:root {
  --bg-main: #0f172a;
  --bg-alt: #020617;
  --card-bg: rgba(15, 23, 42, 0.8);
  --card-border: rgba(148, 163, 184, 0.3);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.18);
  --accent-strong: #22c55e;
  --accent-gold: #fbbf24;
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;
  --danger: #f97373;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --shadow-soft: 0 24px 80px rgba(15, 23, 42, 0.75);
  --blur-strong: 26px;
  --transition-fast: 0.18s ease-out;
  --transition-med: 0.3s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* 禁止 iOS 横竖屏切换时字体放大 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #020617 100%);
  -webkit-font-smoothing: antialiased;
  /* 触屏设备优化 */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* 动态视口，避免移动端地址栏影响 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  /* 刘海屏/安全区 */
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.screen {
  display: none;
  width: 100%;
  max-width: 960px;
  max-height: 720px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: block;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 28px 26px 26px;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 55%),
    radial-gradient(circle at bottom right, rgba(236, 201, 75, 0.2), transparent 55%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.85));
  border: 1px solid rgba(148, 163, 184, 0.5);
  backdrop-filter: blur(var(--blur-strong));
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.gate-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 30px 26px;
}

.analyzing-card {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.result-card {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.28), transparent 70%),
    rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.title {
  margin: 20px 0 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-soft);
}

.input-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-soft);
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

input[type="password"] {
  flex: 1;
  padding: 11px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.95));
  color: var(--text-main);
  outline: none;
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    transform 0.08s ease-out;
}

input[type="password"]::placeholder {
  color: rgba(148, 163, 184, 0.8);
}

input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.error-text {
  min-height: 18px;
  margin: 6px 0 2px;
  font-size: 12px;
  color: var(--danger);
}

.helper-text {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 24px;
  min-height: 44px; /* 触控友好 */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color var(--transition-fast), transform 0.08s ease-out,
    box-shadow var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.primary-btn {
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #0b1120;
  box-shadow: 0 10px 30px rgba(56, 189, 248, 0.4);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 40px rgba(56, 189, 248, 0.6);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.secondary-btn {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(148, 163, 184, 0.8);
}

.secondary-btn:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--accent);
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.7);
}

.ghost-btn {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid rgba(75, 85, 99, 0.7);
}

.ghost-btn:hover {
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.9);
  background: rgba(15, 23, 42, 0.6);
}

/* 免费领取指南 - 链接按钮 */
.guide-btn {
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 24px;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(251, 191, 36, 0.12));
  border: 1px solid rgba(251, 191, 36, 0.6);
  transition: background-color var(--transition-fast), transform 0.08s ease-out,
    box-shadow var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.guide-btn:hover {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.35), rgba(251, 191, 36, 0.2));
  border-color: var(--accent-gold);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.25);
  transform: translateY(-1px);
}

.guide-btn:active {
  transform: translateY(0);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 4px 4px 4px 6px;
}

.progress-wrapper {
  position: relative;
  flex: 1;
  max-width: 420px;
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 0 0 1px rgba(30, 64, 175, 0.6);
}

.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e, #facc15);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.9);
  transition: width 0.35s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.progress-text {
  margin-left: 14px;
  font-size: 13px;
  color: var(--text-soft);
  min-width: 90px;
  text-align: right;
}

.quiz-main {
  height: calc(100% - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-card {
  max-width: 720px;
  width: 100%;
  min-height: 360px;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-soft);
}

.question-index {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.question-tag {
  opacity: 0.85;
}

.question-text {
  margin: 0;
  font-size: 20px;
  font-weight: 550;
  line-height: 1.6;
}

.options-container {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-card {
  position: relative;
  padding: 12px 14px 11px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(75, 85, 99, 0.9);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  min-height: 44px; /* 触控友好 */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    transform 0.08s ease-out, background var(--transition-fast);
}

.option-card:hover {
  border-color: rgba(148, 163, 184, 0.95);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.9);
  transform: translateY(-1px);
}

.option-card:active {
  transform: translateY(0);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.85);
}

.option-badge {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.7), rgba(37, 99, 235, 0.8));
  color: #0b1120;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
}

.option-text {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
}

.option-footnote {
  font-size: 11px;
  color: var(--text-soft);
}

.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: var(--accent);
  border-right-color: #22c55e;
  border-bottom-color: #facc15;
  margin: 24px auto 16px;
  animation: spin 1.1s linear infinite;
}

.analyzing-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 550;
}

.analyzing-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.result-title {
  margin: 10px 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.score-block {
  flex: 1;
  min-width: 160px;
  padding: 12px 14px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 65%),
    rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.8);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-label {
  font-size: 12px;
  color: var(--text-soft);
}

.score-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(120deg, #fbbf24, #facc15, #e5e7eb);
  -webkit-background-clip: text;
  color: transparent;
}

.rank-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-gold);
}

.mirror-section,
.prescription-section {
  margin-top: 4px;
}

.section-title {
  margin: 0 0 6px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.mirror-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-main);
}

.prescription-list {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.prescription-item {
  padding: 10px 11px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.22), transparent 60%),
    rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(34, 197, 94, 0.7);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-main);
}

.prescription-index {
  font-weight: 600;
  margin-right: 4px;
  color: #bbf7d0;
}

.actions-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.slide-in {
  animation: slideIn 0.28s cubic-bezier(0.25, 0.85, 0.4, 1) forwards;
}

.slide-out-left {
  animation: slideOutLeft 0.26s cubic-bezier(0.4, 0.1, 0.9, 0.25) forwards;
}

.shake {
  animation: shake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px) translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-24px) scale(0.98);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(-6px);
  }
  30% {
    transform: translateX(6px);
  }
  45% {
    transform: translateX(-5px);
  }
  60% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
  90% {
    transform: translateX(3px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 768px) {
  #app {
    padding: 16px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .screen {
    max-height: none; /* 允许整页滚动 */
  }

  .card {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }

  .gate-card {
    padding: 22px 18px 18px;
  }

  .title {
    font-size: 22px;
    margin: 16px 0 4px;
  }

  .subtitle {
    font-size: 13px;
    margin-bottom: 18px;
  }

  /* 准入页：小屏时输入与按钮竖排 */
  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .input-row .primary-btn {
    width: 100%;
  }

  input[type="password"] {
    min-height: 44px;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }

  .progress-wrapper {
    max-width: none;
    order: 1;
    width: 100%;
  }

  .progress-text {
    order: 0;
    margin-left: 0;
    min-width: auto;
    font-size: 12px;
  }

  .quiz-main {
    height: auto;
    min-height: 50vh;
    align-items: flex-start;
    padding-top: 8px;
  }

  .question-card {
    min-height: 0;
    padding: 18px 16px 16px;
    gap: 14px;
  }

  .question-text {
    font-size: 18px;
    line-height: 1.55;
  }

  .option-card {
    padding: 14px 12px;
  }

  .option-text {
    font-size: 13px;
  }

  .result-card {
    gap: 16px;
  }

  .result-title {
    font-size: 20px;
  }

  .score-row {
    flex-direction: column;
    gap: 10px;
  }

  .score-block {
    min-width: 0;
  }

  .score-value {
    font-size: 24px;
  }

  .rank-title {
    font-size: 15px;
  }

  .mirror-text {
    font-size: 13px;
    line-height: 1.75;
  }

  .prescription-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .prescription-item {
    font-size: 12px;
    padding: 12px 11px;
  }

  .actions-row {
    flex-direction: column;
    justify-content: stretch;
  }

  .actions-row .secondary-btn,
  .actions-row .guide-btn,
  .actions-row .ghost-btn {
    width: 100%;
  }
}

/* 平板横屏 / 小平板 */
@media (min-width: 769px) and (max-width: 1024px) {
  #app {
    padding: 20px 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  .screen {
    max-height: 85vh;
  }

  .gate-card {
    padding: 28px 24px 24px;
  }

  .title {
    font-size: 24px;
  }

  .question-card {
    max-width: 100%;
    padding: 20px 20px 18px;
  }

  .question-text {
    font-size: 19px;
  }

  .result-card {
    max-width: 100%;
  }

  .prescription-list {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* 手机竖屏（小屏） */
@media (max-width: 480px) {
  #app {
    padding: 12px 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .card {
    padding: 18px 14px 14px;
    border-radius: 16px;
  }

  .gate-card {
    padding: 18px 14px 14px;
  }

  .badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  .title {
    font-size: 20px;
    margin: 14px 0 4px;
  }

  .subtitle {
    font-size: 12px;
    margin-bottom: 16px;
  }

  .input-label {
    font-size: 13px;
  }

  .helper-text,
  .error-text {
    font-size: 11px;
  }

  .top-bar {
    padding: 2px 0;
    margin-bottom: 10px;
  }

  .progress-text {
    font-size: 11px;
  }

  .question-card {
    padding: 14px 12px 12px;
    gap: 12px;
  }

  .question-meta {
    font-size: 11px;
  }

  .question-index {
    padding: 2px 8px;
  }

  .question-text {
    font-size: 16px;
    line-height: 1.5;
  }

  .options-container {
    gap: 8px;
  }

  .option-card {
    padding: 12px 10px;
    min-height: 48px;
  }

  .option-badge {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: 12px;
  }

  .option-text {
    font-size: 12px;
    line-height: 1.55;
  }

  .analyzing-card {
    padding: 24px 16px;
  }

  .analyzing-title {
    font-size: 16px;
  }

  .analyzing-subtitle {
    font-size: 12px;
  }

  .loader {
    width: 40px;
    height: 40px;
    margin: 20px auto 12px;
  }

  .result-title {
    font-size: 18px;
  }

  .score-block {
    padding: 10px 12px;
  }

  .score-value {
    font-size: 22px;
  }

  .rank-title {
    font-size: 14px;
  }

  .section-title {
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  .mirror-text {
    font-size: 12px;
    line-height: 1.7;
  }

  .prescription-item {
    font-size: 11px;
    padding: 10px;
  }

  .primary-btn,
  .secondary-btn,
  .guide-btn,
  .ghost-btn {
    font-size: 13px;
    padding: 10px 20px;
    min-height: 46px;
  }
}

/* 超小屏（部分老旧机或折叠屏内屏） */
@media (max-width: 360px) {
  .title {
    font-size: 18px;
  }

  .question-text {
    font-size: 15px;
  }

  .option-text {
    font-size: 11px;
  }

  .score-value {
    font-size: 20px;
  }
}


