/* ===== 基础与纸张背景 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --ink: #2b2b2b;
  --paper: #fffdf7;
  --bg: #f3ead6;
  --grid: #d9cdb0;
  --accent: #e8743b;   /* 手绘橙 */
  --accent2: #4a8fb0;  /* 手绘蓝 */
  --accent3: #7ba05b;  /* 手绘绿 */
  --pink: #d98aa0;
  --shadow: rgba(43, 43, 43, 0.85);
}

html {
  -webkit-text-size-adjust: 100%;   /* 禁止移动端自动放大字号 */
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
}

body {
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  /* 方格纸纹理 */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: -1px -1px;
  min-height: 100vh;
  min-height: 100dvh;                /* 移动端动态视口高度 */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* 适配 iOS 刘海 / 底部安全区域 */
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(60px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;  /* 去掉移动端点击高亮 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 全屏手绘涂鸦层 */
.doodle-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
}

/* ===== 屏幕切换 ===== */
.screen {
  display: none;
  animation: pop 0.35s ease;
}
.screen.active {
  display: block;
}

@keyframes pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ===== 纸张卡片（手绘风）===== */
.paper-card {
  position: relative;
  background: var(--paper);
  border: 2.6px solid var(--ink);
  border-radius: 3px 18px 4px 14px / 14px 4px 18px 3px;
  box-shadow: 5px 6px 0 var(--shadow);
  padding: 30px 26px;
}

/* 胶带装饰 */
.tape {
  position: absolute;
  width: 96px;
  height: 26px;
  background: rgba(232, 116, 59, 0.35);
  border: 1px dashed rgba(43, 43, 43, 0.4);
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
}

/* ===== 欢迎页 ===== */
.welcome-card { text-align: center; padding-top: 42px; }

.welcome-head { margin-bottom: 4px; }

.title {
  font-family: "Zhi Mang Xing", "ZCOOL KuaiLe", cursive;
  font-size: 58px;
  line-height: 1.05;
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.title-hand {
  font-size: 46px;
  color: var(--accent);
}
.subtitle {
  font-size: 17px;
  margin: 14px 0 22px;
  color: #5a5043;
}

.intro { text-align: left; margin: 0 auto 26px; max-width: 360px; }
.intro-lead { font-size: 18px; margin-bottom: 12px; }
.dim-legend { list-style: none; display: grid; gap: 10px; }
.dim-legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px 4px 14px 4px / 4px 14px 4px 14px;
  padding: 8px 14px;
  box-shadow: 2px 3px 0 var(--shadow);
  transform: rotate(-0.6deg);
}
.dim-legend li:nth-child(even) { transform: rotate(0.6deg); }
.dim-legend b {
  font-family: "Patrick Hand", monospace;
  font-size: 20px;
  color: var(--accent2);
  min-width: 58px;
}
.dim-legend span { color: #5a5043; }

/* ===== 按钮 ===== */
.btn {
  font-family: "ZCOOL KuaiLe", sans-serif;
  cursor: pointer;
  border: 2.6px solid var(--ink);
  background: #fff;
  color: var(--ink);
  border-radius: 12px 3px 12px 3px / 3px 12px 3px 12px;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;       /* 移动端防双击缩放、去点击延迟 */
}
.btn:hover { transform: translate(-1px, -1px) rotate(-0.8deg); box-shadow: 6px 6px 0 var(--shadow); }
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--shadow); }

.btn-primary {
  font-size: 22px;
  padding: 14px 34px;
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  font-size: 16px;
  padding: 9px 18px;
  background: #fff;
}

/* 欢迎页底部提示 */
.hint {
  margin-top: 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #6b6052;
  text-align: center;
}

/* ===== 测试页 ===== */
.quiz-head { margin-bottom: 14px; }
.progress-text {
  font-family: "Patrick Hand", monospace;
  font-size: 19px;
  display: block;
  margin-bottom: 6px;
}
.progress-track {
  height: 16px;
  background: #fff;
  border: 2.4px solid var(--ink);
  border-radius: 10px 3px 10px 3px / 3px 10px 3px 10px;
  box-shadow: 2px 3px 0 var(--shadow);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    45deg,
    var(--accent3),
    var(--accent3) 8px,
    #8fb56e 8px,
    #8fb56e 16px
  );
  transition: width 0.3s ease;
}

.question-card { margin-bottom: 16px; }
.q-num {
  font-family: "Patrick Hand", monospace;
  color: var(--accent);
  font-size: 22px;
  margin-bottom: 4px;
}
.q-text {
  font-size: 23px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.options { display: grid; gap: 14px; }
.option {
  font-size: 19px;
  line-height: 1.45;
  padding: 16px 18px;
  text-align: left;
  background: #fff;
  min-height: 56px;                  /* 触摸目标足够大 */
}
.option.selected {
  background: var(--accent2);
  color: #fff;
  transform: rotate(-0.6deg);
}
.option.left { border-radius: 14px 4px 14px 4px / 4px 14px 4px 14px; }
.option.right { border-radius: 4px 14px 4px 14px / 14px 4px 14px 4px; }

.quiz-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-hint { font-size: 14px; color: #6b6052; }

/* ===== 结果页 ===== */
.result-card { text-align: center; margin-bottom: 32px; }
.result-emoji { font-size: 70px; line-height: 1; margin-bottom: 4px; }
.result-code {
  font-family: "Patrick Hand", monospace;
  font-size: 64px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 3px 3px 0 rgba(43, 43, 43, 0.18);
}
.result-name {
  font-family: "Zhi Mang Xing", cursive;
  font-size: 38px;
  margin: 2px 0 6px;
}
.result-tagline { font-size: 18px; color: var(--accent2); margin-bottom: 18px; }

.dim-bars {
  display: grid;
  gap: 10px;
  margin: 0 auto 20px;
  max-width: 420px;
  text-align: left;
}
.dim-row { display: flex; align-items: center; gap: 10px; }
.dim-side {
  font-family: "Patrick Hand", monospace;
  font-size: 17px;
  width: 22px;
  text-align: center;
  color: #9a9082;
}
.dim-side.strong { color: var(--ink); font-weight: bold; }
.dim-track {
  flex: 1;
  height: 14px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 8px 3px 8px 3px / 3px 8px 3px 8px;
  overflow: hidden;
  box-shadow: 1px 2px 0 var(--shadow);
}
.dim-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 0.6s ease;
}

.result-desc {
  font-size: 17px;
  line-height: 1.6;
  background: #fff;
  border: 2px dashed var(--ink);
  border-radius: 12px 4px 12px 4px / 4px 12px 4px 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: left;
}

/* 身份维度说明块 */
.identity-box {
  font-size: 16px;
  line-height: 1.6;
  background: #fff3e6;
  border: 2px solid var(--ink);
  border-radius: 4px 14px 4px 14px / 14px 4px 14px 4px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: left;
  box-shadow: 2px 3px 0 var(--shadow);
}
.identity-title {
  font-size: 17px;
  color: var(--accent);
  margin-bottom: 4px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.chip {
  font-size: 15px;
  background: #fff3e6;
  border: 2px solid var(--ink);
  border-radius: 20px 6px 20px 6px / 6px 20px 6px 20px;
  padding: 4px 13px;
  box-shadow: 2px 2px 0 var(--shadow);
  transform: rotate(-1deg);
}
.chip:nth-child(even) { transform: rotate(1deg); background: #e8f3f8; }

/* 相近人格分析块 */
.nearby-box {
  background: #fff;
  border: 2px dashed var(--ink);
  border-radius: 12px 4px 12px 4px / 4px 12px 4px 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: left;
}
.nearby-title { font-size: 17px; color: var(--accent); margin-bottom: 6px; }
.nearby-lead { font-size: 15px; line-height: 1.5; color: #4a4238; margin-bottom: 12px; }
.nearby-list { display: grid; gap: 12px; }
.nearby-item { display: flex; gap: 12px; align-items: flex-start; }
.nearby-emoji { font-size: 30px; line-height: 1; }
.nearby-body { flex: 1; }
.nearby-type {
  font-family: "Patrick Hand", monospace;
  font-size: 19px;
  color: var(--accent2);
}
.nearby-type span {
  font-family: "ZCOOL KuaiLe", sans-serif;
  font-size: 15px;
  color: #5a5043;
}
.nearby-diff { font-size: 14px; line-height: 1.5; color: #4a4238; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: left;
  margin-bottom: 22px;
}
.info-grid h3 {
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 4px;
}
.info-grid p { font-size: 15px; line-height: 1.5; color: #4a4238; }

#retryBtn { margin: 0 auto; display: block; }

/* 结果页分享操作区 */
.share-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 20px;
}

/* 分享图预览弹层（modal） */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(43, 43, 43, 0.55);
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 17px;
  color: var(--accent);
  margin-bottom: 14px;
}
.share-img {
  width: 100%;
  height: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--paper);
}
.modal-card .btn { width: 100%; margin-bottom: 10px; }

/* 轻提示 toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 14px 4px 14px 4px / 4px 14px 4px 14px;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  max-width: 80vw;
  text-align: center;
  animation: pop 0.25s ease;
}
.toast[hidden] { display: none; }

/* =========================================================
   跨平台响应式断点
   ========================================================= */

/* 普通手机竖屏（默认样式已适配） */

/* 平板 / 横屏手机：放宽卡片内边距 */
@media (min-width: 480px) and (max-width: 767px) {
  .paper-card { padding: 34px 30px; }
}

/* 桌面 / 大屏：字号与留白更舒展 */
@media (min-width: 768px) {
  .title { font-size: 66px; }
  .title-hand { font-size: 52px; }
  .subtitle { font-size: 19px; }
  .paper-card { padding: 40px 36px; box-shadow: 7px 8px 0 var(--shadow); }
  .q-text { font-size: 26px; }
  .option { font-size: 21px; padding: 18px 22px; }
  .result-code { font-size: 76px; }
  .result-name { font-size: 44px; }
  .result-emoji { font-size: 84px; }
  .intro-lead { font-size: 20px; }
  .dim-legend li { font-size: 19px; }
}

/* 超小屏手机（≤340px）：收紧尺寸避免拥挤 */
@media (max-width: 340px) {
  .title { font-size: 42px; }
  .title-hand { font-size: 34px; }
  .subtitle { font-size: 15px; }
  .q-text { font-size: 19px; }
  .option { font-size: 17px; padding: 14px 14px; min-height: 52px; }
  .result-code { font-size: 48px; }
  .result-name { font-size: 32px; }
  .paper-card { padding: 22px 14px; }
  .dim-legend li { font-size: 15px; }
}

/* 横屏矮高度设备：压缩纵向留白 */
@media (max-height: 480px) and (orientation: landscape) {
  body { padding-top: 12px; padding-bottom: 24px; }
  .welcome-card { padding-top: 20px; }
  .title { font-size: 40px; }
  .subtitle { margin: 8px 0 14px; }
}

/* 尊重「减少动态效果」的系统偏好（无障碍） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
