/* ===== CSS变量定义 ===== */
:root {
  --primary-color: #4a6fa5;
  --secondary-color: #6c63ff;
  --accent-color: #ff6584;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --gray-light: #e9ecef;
  --gray-medium: #adb5bd;
  --gradient-blue: linear-gradient(135deg, #4a6fa5 0%, #6c63ff 100%);
  --gradient-green: linear-gradient(135deg, #28a745 0%, #7bed9f 100%);
  --gradient-orange: linear-gradient(135deg, #ff9a3c 0%, #ff6b6b 100%);
  --gradient-purple: linear-gradient(135deg, #6c63ff 0%, #b063ff 100%);
  --gradient-light: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  --card-shadow: 0 6px 22px rgba(0, 0, 0, 0.07);
  --card-shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.11);
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 12px;
  --page-max: 920px;
}

/* ===== 全局重置与基础样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gradient-light);
  color: var(--dark-color);
  line-height: 1.6;
  padding: clamp(10px, 1.5vw, 20px) clamp(10px, 1.4vw, 18px);
  padding-bottom: calc(clamp(10px, 1.5vw, 20px) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.7s ease-out;
}

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

/* ===== 头部样式 ===== */
header {
  text-align: center;
  padding: clamp(1.05rem, 0.85rem + 1vw, 1.5rem) clamp(0.9rem, 0.8rem + 0.8vw, 1.35rem);
  background: var(--gradient-blue);
  color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: clamp(0.9rem, 1.2vw, 1.25rem);
  position: relative;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(30deg);
  z-index: 0;
}

h1 {
  font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.55rem);
  margin-bottom: 0.35rem;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1vw, 12px);
  line-height: 1.3;
  flex-wrap: wrap;
}

h1 i {
  color: #ffd166;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.subtitle {
  font-size: clamp(0.88rem, 0.85rem + 0.25vw, 0.98rem);
  opacity: 0.95;
  max-width: 640px;
  margin: 0 auto;
  font-weight: 300;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

/* ===== 信息框样式 ===== */
.info-box {
  background: white;
  border-radius: var(--border-radius);
  padding: clamp(1rem, 0.9rem + 0.7vw, 1.35rem);
  margin-bottom: clamp(0.9rem, 1.2vw, 1.25rem);
  box-shadow: var(--card-shadow);
  border-left: 5px solid var(--primary-color);
  transition: var(--transition);
}

.info-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.info-box h2 {
  color: var(--primary-color);
  margin-bottom: 0.7rem;
  font-size: clamp(1.08rem, 1rem + 0.35vw, 1.22rem);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.info-box h2 i {
  color: var(--secondary-color);
  font-size: 1.15em;
}

.info-box p {
  margin-bottom: 0.7rem;
  color: #555;
  font-size: clamp(0.9rem, 0.87rem + 0.2vw, 0.98rem);
  line-height: 1.65;
}

.info-box strong {
  color: var(--primary-color);
  font-weight: 600;
}

.auto-next-hint {
  background: linear-gradient(135deg, rgba(74, 111, 165, 0.08) 0%, rgba(108, 99, 255, 0.08) 100%);
  padding: 0.85rem 1rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1a6db3;
  border-left: 4px solid var(--primary-color);
  margin-top: 1rem;
  margin-bottom: 0;
  font-weight: 500;
  font-size: clamp(0.86rem, 0.84rem + 0.18vw, 0.94rem);
}

.auto-next-hint i {
  font-size: 1.25rem;
  color: var(--warning-color);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

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

/* ===== 进度条样式 ===== */
.progress-container {
  background: white;
  border-radius: var(--border-radius);
  padding: clamp(0.85rem, 0.75rem + 0.5vw, 1.15rem);
  margin-bottom: clamp(0.9rem, 1.2vw, 1.25rem);
  box-shadow: var(--card-shadow);
  position: sticky;
  top: clamp(6px, 1vw, 12px);
  z-index: 100;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  font-weight: 600;
  color: var(--primary-color);
  font-size: clamp(0.9rem, 0.87rem + 0.2vw, 1rem);
}

#progressText {
  background: var(--gradient-blue);
  color: white;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  font-weight: 700;
  box-shadow: var(--shadow-light);
  font-size: 0.92em;
}

.progress-bar-bg {
  height: 9px;
  background: var(--gray-light);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-blue);
  width: 0;
  border-radius: 10px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== 问题卡片样式 ===== */
.question-card {
  background: white;
  border-radius: var(--border-radius);
  padding: clamp(1.05rem, 0.95rem + 0.7vw, 1.5rem);
  margin-bottom: clamp(0.9rem, 1.2vw, 1.25rem);
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.question-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.question-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--gradient-blue);
  border-radius: 6px 0 0 6px;
}

.question-number {
  position: absolute;
  top: 0.6rem;
  right: 1rem;
  font-size: clamp(1.5rem, 1.3rem + 0.8vw, 2rem);
  font-weight: 800;
  color: rgba(74, 111, 165, 0.08);
  line-height: 1;
  z-index: 0;
  user-select: none;
}

.question-title {
  font-size: clamp(1.02rem, 0.96rem + 0.35vw, 1.15rem);
  color: var(--dark-color);
  margin-bottom: clamp(1rem, 1.4vw, 1.4rem);
  font-weight: 600;
  line-height: 1.55;
  position: relative;
  z-index: 1;
  overflow-wrap: break-word;
}

/* ===== 选项容器样式 ===== */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: clamp(1.1rem, 1.5vw, 1.6rem);
}

.option {
  padding: clamp(0.7rem, 0.62rem + 0.4vw, 0.95rem) clamp(0.9rem, 0.8rem + 0.5vw, 1.15rem);
  border: 2px solid var(--gray-light);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}

.option:hover {
  border-color: var(--primary-color);
  background: rgba(74, 111, 165, 0.03);
  transform: translateY(-2px);
}

.option.selected {
  border-color: var(--secondary-color);
  background: rgba(108, 99, 255, 0.05);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.15);
  transform: translateY(-2px);
}

.option.selected::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--secondary-color);
  border-radius: 0 6px 6px 0;
}

.option-value {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  background: var(--gray-light);
  border-radius: 50%;
  margin-right: 12px;
  font-weight: 700;
  color: #555;
  flex-shrink: 0;
  font-size: 0.98rem;
  transition: var(--transition);
}

.option.selected .option-value {
  background: var(--gradient-blue);
  color: white;
  box-shadow: 0 3px 8px rgba(108, 99, 255, 0.3);
}

.option-text {
  font-size: clamp(0.92rem, 0.89rem + 0.2vw, 1rem);
  font-weight: 500;
  color: #444;
  line-height: 1.45;
}

/* ===== 按钮组样式 ===== */
.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

button {
  padding: clamp(0.65rem, 0.6rem + 0.35vw, 0.85rem) clamp(1.1rem, 1rem + 0.7vw, 1.5rem);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(0.92rem, 0.89rem + 0.2vw, 1rem);
  font-family: inherit;
  flex: 1;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--gradient-blue);
  color: white;
  box-shadow: 0 4px 12px rgba(74, 111, 165, 0.3);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(74, 111, 165, 0.4);
}

.btn-secondary {
  background: white;
  color: var(--primary-color);
  border: 2px solid var(--gray-light);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 111, 165, 0.2);
}

.btn-accent {
  background: var(--gradient-orange);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-accent:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(255, 107, 107, 0.4);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ===== 结果卡片样式 ===== */
.result-card {
  background: white;
  border-radius: var(--border-radius);
  padding: clamp(1.2rem, 1rem + 1vw, 1.9rem);
  box-shadow: var(--card-shadow);
  text-align: center;
  display: none;
  animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.result-card h2 {
  color: var(--primary-color);
  margin-bottom: clamp(0.9rem, 1.3vw, 1.3rem);
  font-size: clamp(1.25rem, 1.15rem + 0.6vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-card h2 i {
  color: var(--secondary-color);
  font-size: 1.1em;
}

/* ===== 总分样式 ===== */
.total-score {
  font-size: clamp(1.55rem, 1.35rem + 1vw, 1.95rem);
  font-weight: 800;
  color: var(--primary-color);
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: rgba(74, 111, 165, 0.05);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border: 2px solid rgba(74, 111, 165, 0.1);
  position: relative;
  overflow: hidden;
}

.total-score::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-blue);
}

/* ===== 结果容器样式 - 所有屏幕双排显示 ===== */
.result-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1.4rem 0;
}

/* ===== 结果项样式 ===== */
.result-item {
  padding: clamp(0.85rem, 0.75rem + 0.5vw, 1.15rem);
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.result-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.09);
}

.result-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.85rem;
  position: relative;
  z-index: 1;
}

.result-label {
  font-weight: 700;
  color: var(--dark-color);
  font-size: clamp(0.9rem, 0.88rem + 0.18vw, 0.98rem);
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-label::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--secondary-color);
  display: inline-block;
  flex-shrink: 0;
}

.result-value {
  font-weight: 800;
  font-size: clamp(0.95rem, 0.92rem + 0.25vw, 1.1rem);
  color: var(--primary-color);
  background: rgba(74, 111, 165, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  white-space: nowrap;
}

.result-bar-container {
  height: 9px;
  background: var(--gray-light);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-top: auto;
}

.result-bar {
  height: 100%;
  background: var(--gradient-blue);
  width: 0%;
  border-radius: 10px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.result-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

/* ===== 结果说明样式 ===== */
.interpretation {
  background: linear-gradient(135deg, rgba(74, 111, 165, 0.05) 0%, rgba(108, 99, 255, 0.05) 100%);
  border-radius: 12px;
  padding: clamp(1rem, 0.9rem + 0.7vw, 1.4rem);
  margin: 1.4rem 0;
  text-align: left;
  border-left: 4px solid var(--primary-color);
  position: relative;
  overflow: hidden;
}

.interpretation::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100px;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: rotate(30deg);
}

.interpretation h3 {
  color: var(--primary-color);
  margin-bottom: 0.7rem;
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.interpretation p {
  color: #555;
  font-size: clamp(0.9rem, 0.87rem + 0.2vw, 0.98rem);
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

.interpretation h3 i {
  color: var(--secondary-color);
}

/* ===== 页脚样式 ===== */
footer {
  text-align: center;
  margin-top: 1.6rem;
  padding: 1.1rem;
  color: var(--gray-medium);
  font-size: 0.85rem;
  line-height: 1.6;
  border-top: 1px solid rgba(0,0,0,0.05);
}

/* ================= 小屏幕手机适配 ================= */
@media (max-width: 768px) {
  body {
    padding: 12px 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .container {
    padding: 0;
  }

  header {
    padding: 1rem 0.85rem;
    margin-bottom: 0.9rem;
    border-radius: 10px;
  }

  h1 {
    font-size: 1.28rem;
    gap: 8px;
  }

  h1 i {
    font-size: 1.4rem;
  }

  .subtitle {
    font-size: 0.88rem;
  }

  .info-box {
    padding: 1rem;
    border-radius: 10px;
    border-left-width: 4px;
    margin-bottom: 0.9rem;
  }

  .info-box h2 {
    font-size: 1.08rem;
  }

  .info-box p {
    font-size: 0.92rem;
  }

  .auto-next-hint {
    padding: 0.7rem 0.8rem;
    gap: 8px;
    margin-top: 0.8rem;
  }

  .progress-container {
    padding: 0.8rem 0.85rem;
    border-radius: 10px;
    margin-bottom: 0.9rem;
    top: 6px;
  }

  .progress-header {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .progress-bar-bg {
    height: 8px;
  }

  .question-card {
    padding: 1.05rem;
    border-radius: 10px;
    margin-bottom: 0.9rem;
  }

  .question-title {
    font-size: 1.02rem;
    margin-bottom: 1rem;
  }

  .question-number {
    font-size: 1.6rem;
    top: 0.55rem;
    right: 0.9rem;
  }

  .options-container {
    gap: 0.6rem;
    margin-bottom: 1.1rem;
  }

  .option {
    padding: 0.72rem 0.85rem;
    border-radius: 9px;
    min-height: 48px;
  }

  .option-value {
    width: 29px;
    height: 29px;
    font-size: 0.92rem;
    margin-right: 10px;
  }

  .option-text {
    font-size: 0.94rem;
  }

  .button-group {
    flex-direction: column;
    gap: 0.6rem;
  }

  button {
    padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
    min-height: 48px;
    border-radius: 9px;
    width: 100%;
  }

  /* ===== 移动端结果卡片样式 ===== */
  .result-card {
    padding: 1.15rem 0.9rem;
    border-radius: 10px;
  }

  .result-card h2 {
    font-size: 1.3rem;
    margin-bottom: 0.9rem;
  }

  .total-score {
    font-size: 1.6rem;
    padding: 0.9rem;
    margin: 0.9rem 0 1.3rem;
    border-radius: 12px;
  }

  /* ===== 移动端双排显示结果 ===== */
  .result-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin: 1.1rem 0;
  }

  .result-item {
    padding: 0.85rem;
    border-radius: 10px;
  }

  .result-item-header {
    margin-bottom: 0.7rem;
  }

  .result-label {
    font-size: 0.9rem;
    gap: 5px;
  }

  .result-label::before {
    width: 8px;
    height: 8px;
  }

  .result-value {
    font-size: 0.95rem;
    padding: 0.2rem 0.5rem;
  }

  .result-bar-container {
    height: 8px;
  }

  .interpretation {
    padding: 1rem;
    border-radius: 10px;
    margin: 1.2rem 0;
    border-left-width: 4px;
  }

  .interpretation h3 {
    font-size: 1.05rem;
  }

  .interpretation p {
    font-size: 0.92rem;
  }

  footer {
    margin-top: 1.4rem;
    padding: 0.9rem;
    font-size: 0.8rem;
  }
}

/* ===== 超窄屏（如 iPhone SE 320~380px）：结果改为单列，避免拥挤 ===== */
@media (max-width: 380px) {
  .result-container {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.18rem;
  }

  .question-title {
    font-size: 0.98rem;
  }

  .option-text {
    font-size: 0.9rem;
  }
}

/* ===== 减少动效偏好 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
