/**
 * 豆格人格工坊 - 像素风CSS
 * 主色 #FF69B4(粉红) + 辅色 #4ECDC4(薄荷绿) + 强调色 #FFD166(芒果黄)
 */

/* ==================== 基础重置 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
}

body {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #FFFFFF;
  color: #333;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==================== 像素字体引入 ==================== */
@font-face {
  font-family: 'PixelFont';
  src: local('Press Start 2P'), local('VT323');
  /* 备用：如果用户没有像素字体，使用系统字体 */
}

/* ==================== 页面容器 ==================== */
.page {
  display: none;
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* ==================== 启动页 ==================== */
#page-loading {
  background: linear-gradient(180deg, #FFF0F5 0%, #FFFFFF 50%, #F0FFFE 100%);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.loading-logo {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: 40px;
}

.loading-bean {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  opacity: 0;
  animation: beanDrop 0.5s ease-out forwards;
}

@keyframes beanDrop {
  0% {
    opacity: 0;
    transform: translateY(-60px) scale(0.5);
  }
  60% {
    opacity: 1;
    transform: translateY(5px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.loading-title {
  font-size: 28px;
  font-weight: 900;
  color: #FF69B4;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-shadow: 2px 2px 0px #FFD166;
}

.loading-subtitle {
  font-size: 14px;
  color: #4ECDC4;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 40px;
}

.loading-progress-bar {
  width: 200px;
  height: 16px;
  background: #F0F0F0;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 2px solid #FFD166;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF69B4, #4ECDC4);
  border-radius: 6px;
  width: 0%;
  transition: width 0.3s ease;
}

.loading-skip {
  position: absolute;
  bottom: 40px;
  right: 20px;
  font-size: 12px;
  color: #999;
}

.loading-start-btn {
  margin-top: 24px;
  padding: 14px 48px;
  border: none;
  border-radius: 28px;
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 105, 180, 0.4);
  transition: all 0.3s ease;
  letter-spacing: 2px;
  animation: btnBounceIn 0.5s ease-out;
}

.loading-start-btn:active {
  transform: scale(0.95);
}

@keyframes btnBounceIn {
  0% { opacity: 0; transform: scale(0.5) translateY(10px); }
  60% { transform: scale(1.08) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==================== 测试页 ==================== */
#page-quiz {
  background: #FFFFFF;
}

.quiz-header {
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  background: #FFFFFF;
  z-index: 10;
  border-bottom: 2px solid #FFF0F5;
}

.quiz-progress-text {
  font-size: 14px;
  color: #666;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 600;
}

.quiz-progress-bar {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 0 10px;
  flex-wrap: wrap;
}

.quiz-progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #E8E8E8;
  transition: all 0.3s ease;
  border: 1px solid #D0D0D0;
}

.quiz-progress-dot.filled {
  background: #FF69B4;
  border-color: #FF69B4;
  transform: scale(1.1);
  box-shadow: 0 0 6px rgba(255, 105, 180, 0.4);
}

.quiz-progress-dot.current {
  background: #FFD166;
  border-color: #FFD166;
  animation: dotPulse 1s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.quiz-group-tag {
  display: inline-block;
  padding: 4px 12px;
  background: #4ECDC4;
  color: #FFFFFF;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin: 16px 20px 8px;
}

.quiz-question {
  padding: 12px 20px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.quiz-question-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.6;
  color: #333;
  margin-bottom: 24px;
  padding: 16px;
  background: #FFF0F5;
  border-radius: 16px;
  border: 2px solid #FFE4EC;
  position: relative;
}

.quiz-question-text::before {
  content: '💬';
  position: absolute;
  top: -12px;
  left: 16px;
  font-size: 20px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.quiz-option {
  padding: 16px 18px;
  border: 2px solid #E8E8E8;
  border-radius: 16px;
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: 15px;
  line-height: 1.5;
  color: #555;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option .option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: #F5F5F5;
  font-weight: 800;
  font-size: 14px;
  color: #999;
  transition: all 0.25s ease;
}

.quiz-option.selected {
  border-color: #FF69B4;
  background: linear-gradient(135deg, #FFF0F5, #FFFFFF);
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(255, 105, 180, 0.2);
}

.quiz-option.selected .option-key {
  background: #FF69B4;
  color: #FFFFFF;
}

.quiz-option.selected::after {
  content: '✓';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #FF69B4;
  font-weight: 800;
}

/* 选项颜色变体 */
.quiz-option[data-index="0"].selected { border-color: #FF69B4; }
.quiz-option[data-index="0"].selected .option-key { background: #FF69B4; }
.quiz-option[data-index="1"].selected { border-color: #4ECDC4; }
.quiz-option[data-index="1"].selected .option-key { background: #4ECDC4; }
.quiz-option[data-index="2"].selected { border-color: #FFD166; }
.quiz-option[data-index="2"].selected .option-key { background: #FFD166; }
.quiz-option[data-index="3"].selected { border-color: #A78BFA; }
.quiz-option[data-index="3"].selected .option-key { background: #A78BFA; }

.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: #FFFFFF;
  border-top: 1px solid #F0F0F0;
}

.quiz-nav-btn {
  padding: 12px 28px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.quiz-nav-btn.prev {
  background: #F0F0F0;
  color: #666;
}

.quiz-nav-btn.prev:active {
  background: #E0E0E0;
}

.quiz-nav-btn.next {
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.3);
}

.quiz-nav-btn.next:active {
  transform: scale(0.96);
}

.quiz-nav-btn.next:disabled {
  background: #E0E0E0;
  color: #BDBDBD;
  box-shadow: none;
  cursor: not-allowed;
}

.quiz-nav-btn.finish {
  background: linear-gradient(135deg, #FFD166, #FFE08A);
  color: #795548;
  box-shadow: 0 4px 12px rgba(255, 209, 102, 0.4);
  font-size: 16px;
  padding: 14px 32px;
}

/* ==================== 结果页 ==================== */
#page-result {
  background: linear-gradient(180deg, #FFF0F5 0%, #FFFFFF 40%);
}

.result-container {
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.result-badge {
  display: inline-block;
  padding: 6px 16px;
  background: #4ECDC4;
  color: #FFFFFF;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  margin-top: 20px;
}

.result-personality-name {
  font-size: 32px;
  font-weight: 900;
  color: #FF69B4;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.result-emoji {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.result-tagline {
  font-size: 14px;
  color: #999;
  text-align: center;
  margin-bottom: 16px;
  font-style: italic;
}

.result-image {
  width: 180px;
  height: 180px;
  border-radius: 20px;
  border: 3px solid #FFE4EC;
  margin-bottom: 20px;
  object-fit: cover;
  background: #FFF0F5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.result-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-description {
  font-size: 15px;
  line-height: 1.8;
  color: #555;
  background: #FAFAFA;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid #F0F0F0;
  width: 100%;
}

/* DPT 属性展示 */
.result-attrs {
  width: 100%;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid #F0F0F0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.result-attrs-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  margin-bottom: 16px;
  text-align: center;
}

.result-attr-item {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.result-attr-item:last-child {
  margin-bottom: 0;
}

.result-attr-label {
  font-size: 13px;
  font-weight: 700;
  color: #666;
  width: 80px;
  min-width: 80px;
}

.result-attr-bar {
  flex: 1;
  height: 20px;
  background: #F5F5F5;
  border-radius: 10px;
  overflow: hidden;
  margin: 0 10px;
  position: relative;
}

.result-attr-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease-out;
  position: relative;
}

.result-attr-fill.d-fill {
  background: linear-gradient(90deg, #FF69B4, #FF8DC7);
}

.result-attr-fill.p-fill {
  background: linear-gradient(90deg, #4ECDC4, #7EDDD6);
}

.result-attr-fill.t-fill {
  background: linear-gradient(90deg, #FFD166, #FFE08A);
}

.result-attr-score {
  font-size: 13px;
  font-weight: 800;
  color: #333;
  width: 50px;
  text-align: right;
}

.result-attr-level {
  font-size: 11px;
  color: #999;
  width: 24px;
  text-align: right;
}

/* 结果页按钮 */
.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.result-btn {
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.result-btn:active {
  transform: scale(0.97);
}

.result-btn.primary {
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(255, 105, 180, 0.3);
}

.result-btn.secondary {
  background: linear-gradient(135deg, #4ECDC4, #7EDDD6);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.result-btn.outline {
  background: #FFFFFF;
  color: #999;
  border: 2px solid #E8E8E8;
}

.result-rarity {
  font-size: 12px;
  color: #BDBDBD;
  text-align: center;
  margin-top: 8px;
}

/* ==================== 图纸页 ==================== */
#page-pattern {
  background: #FFFFFF;
}

.pattern-container {
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.pattern-header {
  width: 100%;
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-top: 10px;
}

.pattern-back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #F5F5F5;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pattern-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-right: 36px;
}

.pattern-canvas-wrap {
  background: #FAFAFA;
  border-radius: 16px;
  padding: 16px;
  border: 2px solid #F0F0F0;
  margin-bottom: 20px;
  overflow: auto;
  max-width: 100%;
}

#pattern-canvas {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

.pattern-color-table {
  width: 100%;
  background: #FAFAFA;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid #F0F0F0;
}

.pattern-color-table h3 {
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin-bottom: 12px;
}

.pattern-color-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.pattern-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #E0E0E0;
  margin-right: 10px;
}

.pattern-color-name {
  flex: 1;
  font-size: 14px;
  color: #555;
}

.pattern-color-count {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

.pattern-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pattern-btn {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.pattern-btn:active {
  transform: scale(0.97);
}

.pattern-btn.save {
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.3);
}

.pattern-btn.buy {
  background: linear-gradient(135deg, #FFD166, #FFE08A);
  color: #795548;
  box-shadow: 0 4px 12px rgba(255, 209, 102, 0.3);
}

.pattern-btn.print {
  background: #FFFFFF;
  color: #666;
  border: 2px solid #E8E8E8;
}

/* ==================== 分享模态窗 ==================== */
.share-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.share-overlay.active {
  display: flex;
}

.share-modal {
  background: #FFFFFF;
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.share-preview {
  width: 100%;
  border-radius: 16px;
  border: 2px solid #F0F0F0;
  margin-bottom: 16px;
  overflow: hidden;
  background: #FAFAFA;
}

.share-preview-content {
  padding: 24px 16px;
  background: linear-gradient(180deg, #FFF0F5, #FFFFFF);
}

.share-preview-heading {
  font-size: 14px;
  color: #999;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.share-preview-name {
  font-size: 24px;
  font-weight: 900;
  color: #FF69B4;
  margin-bottom: 4px;
}

.share-preview-emoji {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  border: 3px solid #FFE4EC;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.share-preview-emoji img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.share-preview-tagline {
  font-size: 13px;
  color: #999;
  margin-bottom: 10px;
  font-style: italic;
}

.share-preview-description {
  font-size: 13px;
  color: #666;
  line-height: 1.7;
  text-align: left;
  margin-bottom: 14px;
  padding: 0 4px;
}

.share-preview-qr {
  width: 100px;
  height: 100px;
  margin: 0 auto 8px;
  background: #F5F5F5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #BDBDBD;
}

.share-preview-hint {
  font-size: 11px;
  color: #BDBDBD;
}

.share-actions {
  display: flex;
  gap: 12px;
}

.share-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.share-btn:active {
  transform: scale(0.96);
}

.share-btn.save {
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
}

.share-btn.close {
  background: #F5F5F5;
  color: #666;
}

/* ==================== 通用动画 ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fadeIn {
  animation: fadeIn 0.5s ease-out forwards;
}

.animate-slideInRight {
  animation: slideInRight 0.4s ease-out forwards;
}

.animate-slideInLeft {
  animation: slideInLeft 0.4s ease-out forwards;
}

.animate-bounceIn {
  animation: bounceIn 0.6s ease-out forwards;
}

/* ==================== 豆子装饰元素 ==================== */
.bean-deco {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.3;
  pointer-events: none;
}

/* ==================== 响应式 ==================== */
@media screen and (min-width: 500px) {
  body {
    display: flex;
    justify-content: center;
    background: #F5F5F5;
  }
  
  .page {
    max-width: 420px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.08);
    background: #FFFFFF;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #E0E0E0;
  border-radius: 2px;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #FFFFFF;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* 恢复测试提示 */
.resume-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.resume-modal.active {
  display: flex;
}

.resume-modal-content {
  background: #FFFFFF;
  border-radius: 24px;
  padding: 28px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.resume-modal-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 12px;
}

.resume-modal-content p {
  font-size: 14px;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.resume-modal-btns {
  display: flex;
  gap: 12px;
}

.resume-modal-btns button {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.resume-modal-btns .btn-continue {
  background: linear-gradient(135deg, #FF69B4, #FF8DC7);
  color: #FFFFFF;
}

.resume-modal-btns .btn-restart {
  background: #F5F5F5;
  color: #666;
}
