/* 增删卜易 - 古风占卜样式 */
:root {
  --paper: #f4e9dc;
  --paper-dark: #e8dcc8;
  --ink: #2c1810;
  --ink-light: #4a3728;
  --vermilion: #8B2500;
  --vermilion-light: #a63d2e;
  --bamboo: #5d7c4a;
  --bamboo-dark: #3d5c2e;
  --gold: #8b6914;
  --border: #c4a882;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Noto Serif SC', 'Ma Shan Zheng', 'KaiTi', '楷体', 'STKaiti', serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.7;
  background-color: #c9b896;
  background-image:
    linear-gradient(135deg, rgba(244,233,220,0.85) 0%, rgba(248,240,228,0.8) 40%, rgba(232,218,195,0.85) 100%),
    url("https://images.unsplash.com/photo-1684871430772-569936b1a0ae?auto=format&fit=crop&w=1920&q=80");
  background-size: auto, cover;
  background-position: center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed;
}

.page-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* 顶部 */
.header {
  text-align: center;
  padding: 2rem 0 1.5rem;
  border-bottom: 2px solid var(--border);
}

.site-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.4em;
}

.site-subtitle {
  font-size: 0.95rem;
  color: var(--ink-light);
  margin-top: 0.4rem;
  letter-spacing: 0.2em;
}

/* 纸卡 */
.paper-card {
  background: linear-gradient(180deg, #fdfbf7 0%, #f8f0e4 100%);
  border: 1px solid var(--border);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(44,24,16,0.08);
  position: relative;
}

.paper-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--vermilion), transparent);
  opacity: 0.6;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.3rem;
  letter-spacing: 0.15em;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: 1.5rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(253,251,247,0.6);
}

/* 所问之事 */
.question-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.question-btn {
  padding: 0.75rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: linear-gradient(180deg, #faf5ed 0%, #ebe0d0 100%);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.25s ease;
  transform-origin: center;
  box-shadow: 0 1px 3px rgba(44,24,16,0.08);
}

.question-btn:hover {
  border-color: var(--vermilion);
  color: var(--vermilion);
  background: linear-gradient(180deg, #fff9f0 0%, #f5e6d8 100%);
  box-shadow: 0 2px 8px rgba(139, 37, 0, 0.15);
}

.question-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 2px rgba(139, 37, 0, 0.2);
  transition-duration: 0.1s;
}

.question-btn.selected {
  background: linear-gradient(180deg, var(--vermilion-light) 0%, var(--vermilion) 100%);
  color: #fff;
  border-color: #6b1a00;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 2px 6px rgba(139, 37, 0, 0.35);
}

.question-btn.selected:hover {
  background: linear-gradient(180deg, var(--vermilion) 0%, #6b1a00 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 3px 8px rgba(139, 37, 0, 0.4);
}

.selected-hint {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--ink-light);
}

/* 简介与功能介绍 */
.intro-section {
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem 1.8rem !important;
  box-shadow: inset 0 0 0 1px rgba(244,233,220,0.5);
}

.intro-section .section-title {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.intro-text {
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.9;
  margin-bottom: 1.2rem;
  text-align: justify;
  padding: 1rem 1.2rem !important;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: rgba(253,251,247,0.5);
}

.feature-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.8rem;
  letter-spacing: 0.1em;
}

.feature-list {
  list-style: none;
  font-size: 0.95rem;
  color: var(--ink-light);
  line-height: 2;
  padding: 0.6rem 0;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 1rem 1.2rem 0.8rem !important;
  background: rgba(253,251,247,0.4);
}

.feature-list li {
  padding-left: 2em;
  position: relative;
}

.feature-num {
  position: absolute;
  left: 0;
  color: var(--vermilion);
  font-weight: 600;
}

/* 未选所问之事时，摇卦区域禁用 */
#step2:not(.unlocked) .bamboo-area {
  opacity: 0.5;
  pointer-events: none;
}

#step2:not(.unlocked) .bamboo-tube {
  cursor: not-allowed;
}

/* 竹筒 */
.bamboo-area {
  text-align: center;
  padding: 1.5rem 0;
}

.bamboo-tube {
  display: inline-block;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#step2.unlocked .bamboo-tube:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 4px 12px rgba(61, 92, 46, 0.4));
}

#step2.unlocked .bamboo-tube:active {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

/* 摇卦动画：竹筒倾倒晃动 + 铜钱弹跳 */
.bamboo-area {
  perspective: 400px;
}

.bamboo-tube.shaking {
  animation: tubeShake 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.bamboo-tube.shaking .coins-slot {
  animation: slotRumble 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.bamboo-tube.shaking .coin:nth-child(1) {
  animation: coinBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s;
}

.bamboo-tube.shaking .coin:nth-child(2) {
  animation: coinBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s;
}

.bamboo-tube.shaking .coin:nth-child(3) {
  animation: coinBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s;
}

@keyframes tubeShake {
  0%   { transform: rotate(0deg); }
  12%  { transform: rotate(-20deg); }
  25%  { transform: rotate(18deg); }
  38%  { transform: rotate(-14deg); }
  50%  { transform: rotate(12deg); }
  62%  { transform: rotate(-6deg); }
  75%  { transform: rotate(4deg); }
  88%  { transform: rotate(-2deg); }
  100% { transform: rotate(0deg); }
}

@keyframes slotRumble {
  0%, 100% { transform: translateX(0) translateY(0); }
  15% { transform: translateX(-3px) translateY(-4px); }
  30% { transform: translateX(4px) translateY(2px); }
  45% { transform: translateX(-3px) translateY(-2px); }
  60% { transform: translateX(2px) translateY(1px); }
  80% { transform: translateX(-1px) translateY(0); }
}

@keyframes coinBounce {
  0%, 100% { transform: translateY(0) scale(1); opacity: 1; }
  25% { transform: translateY(-18px) scale(1.15); opacity: 0.9; }
  50% { transform: translateY(-6px) scale(1.05); opacity: 1; }
  75% { transform: translateY(-2px) scale(1.02); opacity: 1; }
}

.bamboo-body {
  width: 80px;
  height: 140px;
  background: linear-gradient(90deg, var(--bamboo-dark) 0%, var(--bamboo) 20%, #6d8c5a 50%, var(--bamboo) 80%, var(--bamboo-dark) 100%);
  border-radius: 4px;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

.bamboo-node {
  height: 12px;
  background: var(--bamboo-dark);
  border-radius: 2px;
}

.coins-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  min-height: 60px;
}

.coin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a227 0%, #8b6914 50%, #6b5010 100%);
  border: 1px solid #6b5010;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  display: inline-block;
  transition: transform 0.3s;
}

.coin[data-face="1"] { transform: rotateY(0deg) translateY(0); }
.coin[data-face="2"] { transform: rotateY(180deg) translateY(0); }

.shake-btn {
  margin-top: 1.5rem;
  padding: 0.9rem 2.8rem;
  font-family: inherit;
  font-size: 1.1rem;
  background: linear-gradient(180deg, var(--vermilion-light) 0%, var(--vermilion) 100%);
  color: #fff;
  border: 2px solid #6b1a00;
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: 0.35em;
  transition: all 0.25s ease;
  transform-origin: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 4px 12px rgba(139, 37, 0, 0.3);
}

.shake-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--vermilion) 0%, #6b1a00 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 6px 18px rgba(139, 37, 0, 0.4);
  border-color: #4a1200;
}

.shake-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 2px 6px rgba(139, 37, 0, 0.25);
  transition-duration: 0.1s;
}

.shake-btn:disabled {
  background: linear-gradient(180deg, #9a8b7a 0%, #7a6b5a 100%);
  cursor: not-allowed;
  opacity: 0.75;
  border-color: #5a4b3a;
  box-shadow: none;
}

#step2:not(.unlocked) .shake-btn {
  pointer-events: none;
}

/* 进度 */
.progress-area {
  margin-top: 1.5rem;
}

#progressText {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 6px;
  background: var(--paper-dark);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--vermilion);
  width: 0%;
  transition: width 0.3s;
}

/* 卦象展示 */
.hexagram-display {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 1.8rem;
  letter-spacing: 0.5em;
  line-height: 2;
}

.hexagram-display .yang { color: var(--ink); }
.hexagram-display .yin { color: var(--ink-light); }
.hexagram-display .moving { text-decoration: underline; }

.gua-preview {
  text-align: center;
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

/* 支付 */
.pay-area {
  text-align: center;
  padding: 1rem 0;
  border-top: 1px dashed var(--border);
}

.pay-desc {
  font-size: 0.95rem;
  color: var(--ink-light);
  margin-bottom: 1rem;
}

.pay-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2.2rem;
  font-family: inherit;
  font-size: 1rem;
  background: linear-gradient(180deg, #4096ff 0%, #1677ff 100%);
  color: #fff;
  border: 2px solid #0958d9;
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.25s ease;
  transform-origin: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 4px 14px rgba(22, 119, 255, 0.4);
}

.pay-btn:hover {
  background: linear-gradient(180deg, #69b1ff 0%, #4096ff 100%);
  border-color: #1677ff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 6px 20px rgba(22, 119, 255, 0.5);
}

.pay-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 2px 8px rgba(22, 119, 255, 0.3);
  transition-duration: 0.1s;
}

.pay-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

/* 支付成功页 */
.result-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: inherit;
}

.site-header {
  text-align: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-header .logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.2em;
}

.result-main {
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.success-badge {
  text-align: center;
  margin-bottom: 1.5rem;
}

.success-icon {
  display: inline-block;
  width: 48px;
  height: 48px;
  line-height: 48px;
  border-radius: 50%;
  background: var(--vermilion);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.success-msg {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-top: 0.3rem;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: var(--ink-light);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--vermilion);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-state {
  text-align: center;
  padding: 2rem;
  color: var(--ink-light);
}

.error-state a {
  display: inline-block;
  margin-top: 1rem;
  color: var(--vermilion);
}

.result-actions {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  font-family: inherit;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-outline {
  border: 2px solid var(--vermilion);
  border-radius: 10px;
  color: var(--vermilion);
  background: transparent;
  transition: all 0.25s ease;
}

.btn-outline:hover {
  background: var(--vermilion);
  color: #fff;
  box-shadow: 0 3px 12px rgba(139, 37, 0, 0.25);
}

.btn-outline:active {
  transform: translateY(1px);
  transition-duration: 0.1s;
}

.gua-display {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.gua-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.gua-label {
  font-size: 0.9rem;
  color: var(--ink-light);
}

.gua-name {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
}

.hexagram-lines {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
}

.hexagram-lines .line {
  line-height: 1.8;
}

.hexagram-lines .line.yang { color: var(--ink); }
.hexagram-lines .line.yin { color: var(--ink-light); }
.hexagram-lines .line.moving { text-decoration: underline; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--ink-light);
  border-top: 1px solid var(--border);
}

.result-card {
  padding: 2rem;
  background: linear-gradient(180deg, #fdfbf7 0%, #f8f0e4 100%);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(44,24,16,0.08);
}

.result-card .section-title {
  margin-bottom: 1rem;
}

.interpretation-text {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink);
  margin-bottom: 1.5rem;
  text-align: justify;
}

.interpretation-text .gua-ci {
  padding: 0.8rem 1rem;
  background: rgba(196,168,130,0.15);
  border-left: 3px solid var(--vermilion);
  margin: 1rem 0;
  font-style: italic;
}

.interpretation-text .baihua-section,
.interpretation-text .question-specific,
.interpretation-text .final-advice {
  margin: 1.2rem 0;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--border);
}

.interpretation-text .baihua-section:last-of-type,
.interpretation-text .question-specific:last-of-type,
.interpretation-text .final-advice {
  border-bottom: none;
}

.interpretation-text .baihua-detail,
.interpretation-text .question-text {
  margin-top: 0.5rem;
  color: var(--ink);
  line-height: 1.9;
  text-align: justify;
}

.interpretation-text .question-specific strong {
  color: var(--vermilion);
}

/* 页脚 */
.footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.85rem;
  color: var(--ink-light);
}

@media (max-width: 480px) {
  .question-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .site-title {
    font-size: 1.8rem;
    letter-spacing: 0.2em;
  }
}
