/* ===================================================
   🎭 深度角色问卷 · 极简质朴白风格
   Clean, Minimalist, Paper-like Aesthetic
   =================================================== */

:root {
  /* 基础配色：纸白极简体系 */
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f4f6;
  --bg-subtle: #f3f4f6;
  
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --border-dark: #d1d5db;
  
  --text: #1f2937;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  
  --accent: #111827; /* 沉稳黑 */
  --accent-hover: #374151;
  --primary: #2563eb;
  
  --radius: 12px;
  --radius-sm: 8px;
  --radius-round: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* 全局重置与平滑渲染 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  padding-bottom: max(36px, env(safe-area-inset-bottom, 36px));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 容器居中与自适应 */
.app-container {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

/* 页面切换 */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* 头部设计 */
.header {
  text-align: center;
  margin-bottom: 20px;
  padding: 8px 0;
}

.title {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* 引导说明区域 */
.intro-section {
  margin-bottom: 20px;
}

.intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.intro-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 14px;
}

/* 作者注 - 诚恳温和的浅色便签 */
.author-note {
  background: #fdfaf6;
  border: 1px solid #f2e9dc;
  border-left: 3px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #78350f;
  margin: 0;
  line-height: 1.55;
}

/* 随机全部按钮（置于分类之前） */
.random-all-btn {
  display: block;
  width: 100%;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  margin-bottom: 28px;
  touch-action: manipulation;
}

.random-all-btn:hover {
  background: var(--text-primary);
  color: #ffffff;
  border-color: var(--text-primary);
}

.random-all-btn:active {
  transform: scale(0.99);
}

/* 分类选择区域 */
.categories-section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  text-align: center;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  color: inherit;
  width: 100%;
  display: block;
  user-select: none;
  touch-action: manipulation;
}

.category-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-dark);
  transform: translateY(-1px);
}

.category-card:active {
  transform: scale(0.98);
  background: #eef0f3;
}

.category-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.category-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 最后一个格子：完整问卷特色样式 */
.category-card.full-card {
  border: 1.5px dashed var(--border-dark);
  background: #fafafa;
}

.category-card.full-card:hover {
  background: #f4f4f5;
  border-color: var(--text-primary);
}

/* ===================================================
   📖 完整问卷独立页面 (#full-page)
   =================================================== */
#full-page .all-questions-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-bottom: 28px;
}

.copy-all-top-btn {
  background: var(--text-primary);
  color: #ffffff;
  border: 1px solid var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  touch-action: manipulation;
  font-family: inherit;
}

.copy-all-top-btn:hover {
  background: var(--accent-hover);
}

.copy-all-top-btn:active {
  transform: scale(0.96);
}

.all-cat-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.all-cat-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
  align-self: flex-start;
}

.all-q-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 4px;
}

.all-q-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.92rem;
  line-height: 1.55;
}

.all-q-question {
  color: var(--text-primary);
  font-weight: 600;
}

.all-q-hint {
  color: var(--text-muted);
  font-size: 0.84rem;
  padding-left: 18px;
  line-height: 1.5;
}

/* ===================================================
   抽卡页面
   =================================================== */
.draw-header {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
}

.back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  font-family: inherit;
}

.back-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.back-btn:active {
  transform: scale(0.96);
}

.category-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

/* 卡片抽卡区域 */
.draw-area {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 420px;
  margin-bottom: 28px;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

.card-container {
  width: min(330px, calc(100vw - 32px));
  height: 430px;
  max-height: calc(100dvh - 220px);
  min-height: 380px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.card.drawing {
  animation: cardDraw 0.45s ease;
}

@keyframes cardDraw {
  0% { transform: scale(0.96); opacity: 0.8; }
  50% { transform: scale(1.01); }
  100% { transform: scale(1); opacity: 1; }
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow-card);
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

/* 卡片正面 - 质朴素白 */
.card-front {
  justify-content: center;
  align-items: center;
  padding: 32px 20px;
  border: 1.5px dashed var(--border-dark);
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);
}

.card-emoji {
  font-size: 3.5rem;
  margin-bottom: 14px;
}

.card-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* 卡片背面 - 纯白直观 */
.card-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  padding: 24px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  justify-content: space-between;
  align-items: stretch;
  gap: 14px;
  border: 1px solid var(--border-dark);
}

/* 问题主体容器 */
.card-question-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 0;
}

.question-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

/* 提示盒子 */
.question-hint-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
}

.hint-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.hint-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

/* 卡片来源小注 */
.card-source {
  font-size: 0.78rem;
  color: var(--text-light);
  text-align: center;
  min-height: 16px;
}

/* 操作按钮 */
.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.action-btn {
  padding: 12px 24px;
  min-height: 48px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  touch-action: manipulation;
}

.redraw-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-dark);
}

.redraw-btn:hover {
  background: var(--bg-subtle);
}

.redraw-btn:active {
  transform: scale(0.98);
}

.answer-btn {
  background: var(--text-primary);
  color: #ffffff;
  border: 1px solid var(--text-primary);
}

.answer-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.answer-btn:active {
  transform: scale(0.98);
}

/* Toast 提示 */
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: var(--radius-round);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 极简滚动条 */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ===================================================
   📱 移动端适配优化
   =================================================== */
@media (max-width: 480px) {
  body {
    padding: 16px 12px;
    padding-bottom: max(28px, env(safe-area-inset-bottom, 28px));
  }

  .title {
    font-size: 1.5rem;
  }

  .intro-card {
    padding: 16px 14px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .category-card {
    padding: 16px 10px;
  }

  .category-emoji {
    font-size: 1.75rem;
  }

  .category-name {
    font-size: 0.9rem;
  }

  #full-page .all-questions-content {
    padding: 18px 14px;
  }

  .draw-area {
    min-height: 380px;
    margin-bottom: 20px;
  }

  .card-container {
    width: min(315px, calc(100vw - 24px));
    height: 410px;
  }

  .card-back {
    padding: 20px 16px;
    gap: 12px;
  }

  .question-title {
    font-size: 1.05rem;
    line-height: 1.55;
  }

  .action-buttons {
    flex-direction: column;
    padding: 0 8px;
    gap: 10px;
  }

  .action-btn {
    width: 100%;
    min-height: 48px;
  }
}

/* 短屏手机适配 */
@media (max-height: 680px) {
  .draw-area {
    min-height: 340px;
    margin-bottom: 16px;
  }

  .card-container {
    height: 360px;
    min-height: 330px;
  }

  .card-front {
    padding: 20px 16px;
  }

  .card-emoji {
    font-size: 2.8rem;
    margin-bottom: 8px;
  }

  .card-back {
    padding: 16px 14px;
    gap: 10px;
  }

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

  .hint-text {
    font-size: 0.82rem;
  }
}
