﻿/* ========== 基础重置 & CSS 变量 ========== */
:root {
  --bg:     #f7f8fa;
  --panel:  #ffffff;
  --ink:    #111111;
  --text:   #333333;
  --muted:  #888888;
  --line:   #eaeaea;
  --accent: #4a7cf7;
  --gold:   #c9a55a;
  --red:    #c0392b;
  --pink:   #e87d8e;
  --radius: 12px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after { margin:0; padding:0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-overflow-scrolling: touch;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  margin: 0;
}

button, a, [onclick] {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  cursor: pointer;
}

input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
  -webkit-text-fill-color: var(--ink) !important;
}

/* ========== 卡片通用 ========== */
.card {
  background: var(--panel);
  border:1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

/* ========== 首页：签种选择（原始悬挂卡片设计） ========== */
.lot-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 52px));
  gap: 28px;
  justify-content: center;
  margin: 0 auto;
  margin-top: -12.5vh;
}

.lot-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 4px 18px;
  min-height: 160px;
  background: linear-gradient(180deg, #f5e6d3 0%, #e8d5b8 15%, #dfc9a5 50%, #e8d5b8 85%, #f5e6d3 100%);
  border: 2px solid #c4a67a;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transform-origin: 50% -350px;
  animation: banner-sway 6s ease-in-out infinite;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.3);
  text-decoration: none;
  color: inherit;
  display: flex;
}

/* 顶部红绳挂孔 */
.lot-type-card::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  width: 8px;
  height: 14px;
  background: #c0392b;
  border-radius: 4px 4px 0 0;
  margin-left: -4px;
  pointer-events: none;
}

/* 红绳 — 延伸至顶部 */
.lot-type-card::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 2px;
  height: 200vh;
  background: linear-gradient(to bottom, transparent 0%, #c0392b 1%);
  margin-left: -1px;
  pointer-events: none;
  z-index: -1;
}

.lot-type-card:nth-child(1) { animation-delay: -0.8s; }
.lot-type-card:nth-child(2) { animation-delay: -2.4s; }
.lot-type-card:nth-child(3) { animation-delay: -4.0s; }

@keyframes banner-sway {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(3deg); }
  50%  { transform: rotate(-2.5deg); }
  75%  { transform: rotate(2deg); }
  100% { transform: rotate(0deg); }
}

.lot-type-card:active {
  animation: banner-sway 6s ease-in-out infinite;
}

.lot-type-body {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lot-type-body h3 {
  font-size: 17px;
  font-weight: 800;
  color: #5c3d1a;
  margin: 0;
  line-height: 1.6;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.25em;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  text-align: center;
  align-self: center;
}

.lot-type-body p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.lot-type-arrow {
  display: none;
}

/* ========== 首页：灵签说明 ========== */
.lot-instructions {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: max(280px, 80vw);
  max-width: 340px;
  padding: 14px 18px;
  background: rgba(0,0,0,0.5);
  border-radius: 10px;
  border: 1px solid rgba(255,215,0,0.2);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.lot-instructions h4 {
  color: #f5e6d3;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px 0;
  text-align: center;
  letter-spacing: 0.1em;
}

.lot-instructions ol {
  margin: 0;
  padding-left: 20px;
  list-style: none;
  counter-reset: step;
}

.lot-instructions li {
  color: #f5e6d3;
  font-size: 13px;
  line-height: 1.8;
  margin-bottom: 4px;
  position: relative;
  padding-left: 8px;
}

.lot-instructions li:last-child {
  margin-bottom: 0;
}

.lot-instructions li::before {
  content: counter(step) ".";
  counter-increment: step;
  color: #daa520;
  font-weight: 700;
  margin-right: 6px;
}

/* ========== 抽签页面 ========== */
.draw-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom:1px solid var(--line);
}

.back-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  font-size: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
  display: grid;
}

.draw-page-header h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.draw-stage {
  max-width: 440px;
  margin: 0 auto;
  text-align: center;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding-top: 60vh;
  padding-bottom: 40px;
  position: relative;
}

/* 开始抽签按钮 — 呼吸动画 */
.draw-btn {
  display: inline-block;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #f56a45, #F05324, #d44118);
  border: 2px solid #b83510;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 0.35em;
  box-shadow: 0 4px 16px rgba(240, 83, 36, 0.4);
  animation: btn-breathe 2s ease-in-out infinite;
  flex-shrink: 0;
  margin-top: auto;
  text-decoration: none;
}

@keyframes btn-breathe {
  0%, 100% { box-shadow: 0 4px 16px rgba(200, 126, 40, 0.35); transform: scale(1); }
  50%      { box-shadow: 0 4px 32px rgba(200, 126, 40, 0.6); transform: scale(1.05); }
}

/* ========== 签摆动特效（原始设计） ========== */
.pendulum-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.pendulum-wrap.visible {
  opacity: 1;
}
.pendulum {
  position: relative;
  padding-bottom: 60px;
  transform-origin: 50% 100%;
}
.pendulum.swinging {
  animation: pendulumSwing 1.2s ease-in-out infinite alternate;
}
@keyframes pendulumSwing {
  0%   { transform: rotate(-30deg); }
  100% { transform: rotate(30deg); }
}
.stick-swing {
  display: block;
  width: auto;
  height: 180px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

/* ========== 抽签页背景 ========== */
body.draw-page {
  min-height: 100vh;
  min-height: 100dvh;
}

/* 背景装饰图 */
.deity-bg {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 72px;
  animation: deityFloat 3s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}

.deity-bg.guanyin-bg { background: linear-gradient(135deg, #fce4ec, #f8bbd0); }
.deity-bg.yuelao-bg  { background: linear-gradient(135deg, #fff3e0, #ffe0b2); }
.deity-bg.caishen-bg { background: linear-gradient(135deg, #fff8e1, #ffecb3); }

@keyframes deityFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.draw-hint {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 12px;
}

.draw-sub-hint {
  font-size: 13px;
  color: #bbb;
  margin-bottom: 28px;
}

/* ========== 抽签结果提示 ========== */
.draw-result-hint {
  margin-top: 20px;
}
.explain-btn {
  display: inline-block;
  padding: 12px 36px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #E5623D, #D45530);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 16px rgba(229, 98, 61, 0.4);
  text-decoration: none;
}

/* ========== 月老结果页 ========== */
body.result-page-yuelao {
  background: #F5E6CC;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

body.result-page-yuelao::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 0;
  pointer-events: none;
}

body.result-page-yuelao > * {
  position: relative;
  z-index: 1;
}

/* ========== 财神结果页 ========== */
body.result-page-caishen {
  background: url('11.webp') center/cover no-repeat fixed;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

body.result-page-caishen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 0;
  pointer-events: none;
}

body.result-page-caishen > * {
  position: relative;
  z-index: 1;
}

/* ========== 结果页（原始设计） ========== */
body.result-page {
  background: #F5E6CC;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

/* 半透明遮罩 */
body.result-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 0;
  pointer-events: none;
}

body.result-page > * {
  position: relative;
  z-index: 1;
}

/* 返回按钮 */
.result-back {
  position: absolute;
  top: 16px;
  left: 16px;
  color: #fff;
  font-size: 15px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border: none;
  cursor: pointer;
  z-index: 10;
  text-decoration: none;
}
.result-back:active { opacity: 0.7; }

.result-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.result-meta .level {
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 10px;
}
.level-zhong    { background: #fff3e0; color: #e65100; }
.level-xia      { background: #fce4ec; color: #c62828; }
.level-xiaxia   { background: #fce4ec; color: #c62828; }

/* ========== 结果页：签文展示区 ========== */
.result-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  text-align: center;
}

.verse-bg-img {
  width: 80%;
  max-width: 280px;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.result-container > .verse-grid {
  position: relative;
  z-index: 2;
}

/* 签文：2x2网格竖排，从右到左 */
.verse-grid {
  display: grid;
  grid-template-areas:
    "left-top    right-top"
    "left-bottom right-bottom";
  gap: 20px 48px;
  justify-content: center;
  align-content: center;
  align-items: center;
  margin: 0 auto;
  width: 100%;
}

.verse-grid .v-cell {
  writing-mode: vertical-rl;
  text-orientation: upright;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #ffffff;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.35em;
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  text-align: center;
}

.verse-grid .v-cell span {
  display: block;
}

/* 底部按钮 */
.result-actions {
  position: relative;
  z-index: 10;
  margin-top: 32px;
  padding: 0 0 40px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.explain-btn-main {
  width: 120px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 18px;
  background: transparent;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.explain-btn-main:hover {
  opacity: 0.78;
}

/* ========== 签文解释弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px;
  padding-left: max(24px, var(--safe-left));
  padding-right: max(24px, var(--safe-right, 24px));
  background: rgba(0,0,0,0.45);
  animation: fadeIn 0.25s ease;
  overflow-y: auto;
}

.modal-overlay.is-hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-panel {
  width: min(400px, 100%);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: left;
  position: relative;
  margin-bottom: var(--safe-bottom);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-panel h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
}

.modal-panel .modal-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom:1px solid var(--line);
}

.modal-panel .explain-section {
  margin-bottom: 16px;
}

.modal-panel .explain-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.modal-panel .explain-section p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  font-size: 18px;
  display: grid;
  place-items: center;
  z-index: 10;
}

/* ========== 爱心呼吸发光动画 ========== */
@keyframes heartGlow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(255,105,180,0.7)) drop-shadow(0 0 24px rgba(255,20,147,0.4)) drop-shadow(0 0 40px rgba(255,20,147,0.2)); }
  50%      { filter: drop-shadow(0 0 28px rgba(255,105,180,1))   drop-shadow(0 0 56px rgba(255,20,147,0.85)) drop-shadow(0 0 90px rgba(255,20,147,0.5)); }
}

/* ========== 金币呼吸发光动画 ========== */
@keyframes coinGlow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(255,193,7,0.7)) drop-shadow(0 0 24px rgba(255,152,0,0.4)) drop-shadow(0 0 40px rgba(255,152,0,0.2)); }
  50%      { filter: drop-shadow(0 0 28px rgba(255,193,7,1))   drop-shadow(0 0 56px rgba(255,152,0,0.85)) drop-shadow(0 0 90px rgba(255,152,0,0.5)); }
}

/* ========== 标题呼吸发光动画 ========== */
@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 6px rgba(195,39,43,0.5), 0 0 12px rgba(195,39,43,0.3), 0 1px 4px rgba(0,0,0,0.4); }
  50%      { text-shadow: 0 0 24px rgba(195,39,43,1), 0 0 48px rgba(195,39,43,0.7), 0 0 72px rgba(195,39,43,0.4), 0 1px 4px rgba(0,0,0,0.4); }
}

#verse-title {
  animation: titleGlow 2.5s ease-in-out infinite;
}
.fade-up {
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up:nth-child(2) { animation-delay: 0.06s; }
.fade-up:nth-child(3) { animation-delay: 0.12s; }
.fade-up:nth-child(4) { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  .fade-up { animation: none; }
  .deity-bg { animation: none; }
}

/* ========== 响应式 ========== */
@media (max-width: 600px) {
  .lot-type-grid { grid-template-columns: repeat(3, minmax(0, 45px)); gap: 12px; }
  .lot-type-card { padding: 16px 3px 14px; min-height: 130px; border-radius: 6px; }
  .result-container { max-width: 320px; padding: 20px 10px; }
  .verse-grid { gap: 10px 24px; }
  .verse-grid .v-cell { font-size: 22px; letter-spacing: 0.1em; line-height: 1.1; }
  .result-actions { margin-top: 16px; }
  #verse-title { font-size: 24px !important; }
  .explain-btn-main { width: 100px; height: 32px; font-size: 14px; font-weight: 700; border-radius: 16px; }
  .deity-bg { width: 140px; height: 140px; font-size: 56px; }
  .draw-btn {
    padding: 12px 36px;
    font-size: 16px;
  }
  #heart-icon { width: 158px !important; height: 158px !important; }
}

