:root {
  --red-deep: #7d1a1a;
  --red: #a8232a;
  --red-bright: #c8402f;
  --gold: #c9a227;
  --gold-light: #e8c85a;
  --ink: #2b1d16;
  --ink-soft: #6b5a4e;
  --paper: #fdf6e8;
  --paper-2: #f7ecd6;
  --line: #e2d2b4;
  --shadow: 0 2px 10px rgba(80, 40, 20, .08);
  --shadow-lg: 0 12px 40px rgba(80, 40, 20, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -180px, rgba(201, 162, 39, .18), transparent 70%),
    linear-gradient(180deg, #fbf1dd 0%, var(--paper) 40%, #f8efdd 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ---------- 背景香烟 ---------- */
.incense-smoke {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.incense-smoke span {
  position: absolute;
  bottom: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .55), transparent 65%);
  filter: blur(18px);
  animation: rise 22s linear infinite;
}
.incense-smoke span:nth-child(1) { left: 12%; animation-delay: 0s; }
.incense-smoke span:nth-child(2) { left: 48%; animation-delay: 7s; }
.incense-smoke span:nth-child(3) { left: 78%; animation-delay: 14s; }

@keyframes rise {
  0%   { transform: translateY(0) scale(.7); opacity: 0; }
  15%  { opacity: .55; }
  70%  { opacity: .3; }
  100% { transform: translateY(-115vh) scale(1.5); opacity: 0; }
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(125, 26, 26, .96);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 16px rgba(80, 20, 10, .3);
  border-bottom: 2px solid var(--gold);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 0 8px rgba(232, 200, 90, .8)); }
.brand-text h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 4px;
  color: var(--gold-light);
  font-weight: 600;
}
.brand-text p {
  margin: 0;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(253, 246, 232, .7);
}

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.free-badge {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #5a3d00;
  background: linear-gradient(135deg, #ffe08a, #f5c542);
  box-shadow: 0 2px 8px rgba(201, 162, 39, .45);
  animation: badgePulse 2.4s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(232, 200, 90, .35);
}
.user-info { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { color: var(--gold-light); font-size: 14px; font-weight: 600; }
.user-meta { color: rgba(253, 246, 232, .62); font-size: 11px; }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; }

.btn-primary {
  background: linear-gradient(135deg, var(--red-bright), var(--red));
  color: #fff;
  box-shadow: 0 3px 12px rgba(168, 35, 42, .35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 5px 18px rgba(168, 35, 42, .5); }

.btn-ghost {
  background: transparent;
  color: currentColor;
  border: 1px solid currentColor;
  opacity: .8;
}
.btn-ghost:hover:not(:disabled) { opacity: 1; }

.topbar .btn-ghost { color: var(--gold-light); font-size: 13px; padding: 6px 14px; }

.btn-block { width: 100%; padding: 12px; font-size: 16px; letter-spacing: 2px; }

.btn-worship {
  width: 100%;
  margin-top: 20px;
  padding: 16px;
  font-size: 18px;
  letter-spacing: 6px;
  color: #fff;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--red-bright), var(--red-deep));
  box-shadow: 0 6px 22px rgba(125, 26, 26, .38);
}
.btn-worship:hover:not(:disabled) {
  box-shadow: 0 10px 32px rgba(125, 26, 26, .55);
  transform: translateY(-2px);
}

/* ---------- 布局 ---------- */
.container {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.step {
  margin-bottom: 44px;
  padding: 26px 24px 30px;
  border-radius: 16px;
  background: rgba(255, 253, 247, .82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.step-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #5a3d00;
  font-size: 15px;
  font-weight: 700;
  flex: none;
}
.step-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--red-deep);
  font-weight: 600;
}
.step-tip { margin: 0; font-size: 13px; color: var(--ink-soft); }

.loading, .placeholder {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- 神仙卡片 ---------- */
.deity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.deity-card {
  position: relative;
  padding: 20px 14px 16px;
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, #fffdf7, var(--paper-2));
  border: 2px solid var(--line);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.deity-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(232, 200, 90, .3), transparent 65%);
  opacity: 0;
  transition: opacity .25s;
}
.deity-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gold);
}
.deity-card:hover::after { opacity: 1; }

.deity-card.selected {
  border-color: var(--red-bright);
  background: linear-gradient(180deg, #fff6f0, #fde8dd);
  box-shadow: 0 8px 26px rgba(168, 35, 42, .25);
}
.deity-card.selected::before {
  content: "已请";
  position: absolute;
  top: 0;
  right: 0;
  padding: 3px 12px;
  font-size: 11px;
  color: #fff;
  background: var(--red-bright);
  border-radius: 0 12px 0 12px;
}

/* 神位形象区：统一 3:4 竖框，有画像的放画像，没画像的放 emoji。
   两张卡片在同一个网格行里高度一致，不会因为有没有画像就参差不齐。 */
.deity-avatar,
.deity-emoji {
  width: 100%;
  aspect-ratio: 3 / 4;
  margin-bottom: 10px;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 36%, #fffbf1, #f2e5ca 68%, #e8d8b8);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, .3);
}

.deity-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 画像多为立像/半身，顶端对齐才能保证脸在框里 */
  object-position: 50% 0;
  transition: transform .35s ease;
}
.deity-card:hover .deity-avatar img { transform: scale(1.04); }

.deity-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  line-height: 1;
}
.deity-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--red-deep);
  margin-bottom: 4px;
}
.deity-title {
  font-size: 11px;
  color: var(--ink-soft);
  min-height: 32px;
  overflow: hidden;
}

/* ---------- 商品 ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab {
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-family: inherit;
  transition: all .2s;
}
.tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 14px;
  background: #fffdf7;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gold);
}
.product-card.selected {
  border-color: var(--red-bright);
  background: #fff6f0;
  box-shadow: 0 8px 26px rgba(168, 35, 42, .22);
}

.product-top { display: flex; align-items: center; gap: 10px; }
.product-emoji { font-size: 28px; }
.product-name { font-size: 15px; font-weight: 600; color: var(--red-deep); }
.product-desc { font-size: 12px; color: var(--ink-soft); min-height: 34px; }

.product-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price-free {
  font-size: 17px;
  font-weight: 700;
  color: #1a8a4a;
}
.price-original {
  font-size: 12px;
  color: #a89988;
  text-decoration: line-through;
}
.price-normal {
  font-size: 17px;
  font-weight: 700;
  color: var(--red-bright);
}

/* ---------- 祭坛 ---------- */
.altar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 24px;
  margin-bottom: 22px;
  border-radius: 14px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(201, 162, 39, .22), transparent 70%),
    linear-gradient(180deg, #fff9ec, #f6e8cd);
  border: 2px dashed var(--line);
}

.altar-placeholder { color: var(--ink-soft); font-size: 14px; }
.altar-placeholder .altar-icon { font-size: 34px; opacity: .45; margin-bottom: 6px; }
.altar-placeholder p { margin: 0; }

.altar-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  flex-wrap: wrap;
}
.altar-node { text-align: center; }
.altar-node .node-icon { font-size: 46px; line-height: 1; }
.altar-node .node-name {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--red-deep);
}
.altar-node .node-sub { font-size: 11px; color: var(--ink-soft); }
.altar-operator {
  font-size: 26px;
  color: var(--gold);
  padding-bottom: 22px;
  animation: badgePulse 2s ease-in-out infinite;
}

/* ---------- 祈愿 ---------- */
.wish-box { position: relative; }
.wish-box label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--red-deep);
}
.optional { font-weight: 400; color: var(--ink-soft); font-size: 12px; }

.wish-box textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.wish-box textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .16);
}
.wish-counter {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

/* ---------- 动态列表 ---------- */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  font-size: 14px;
  border-bottom: 1px dashed var(--line);
}
.feed-list li:last-child { border-bottom: none; }
.feed-empty { color: var(--ink-soft); justify-content: center; }
.feed-emoji { font-size: 20px; }
.feed-text { flex: 1; color: var(--ink); }
.feed-text b { color: var(--red-deep); }
.feed-time { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(43, 29, 22, .55);
  backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px 26px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf7, var(--paper));
  border-top: 4px solid var(--gold);
  box-shadow: var(--shadow-lg);
  animation: popIn .25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes popIn {
  from { transform: translateY(16px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-wide { max-width: 620px; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.modal-close:hover { background: rgba(0, 0, 0, .06); }

.modal-title {
  margin: 0 0 18px;
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--red-deep);
}

.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 999px;
  background: var(--paper-2);
}
.modal-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .2s;
}
.modal-tab.active {
  background: #fff;
  color: var(--red-deep);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(80, 40, 20, .12);
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-deep);
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .16);
}

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #a8232a;
  background: #fdeceb;
  border-left: 3px solid var(--red-bright);
}
.result-lines { text-align: left; margin-bottom: 22px; }
.result-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 2px;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
}
.result-line span:first-child { color: var(--ink-soft); }
.result-line span:last-child { color: var(--ink); font-weight: 600; }
.result-actions { display: flex; gap: 10px; }
.result-actions .btn { flex: 1; }
.result-actions .btn-ghost { color: var(--ink-soft); }

/* ---------- 订单列表 ---------- */
.orders-body { min-height: 120px; }
.order-item {
  padding: 13px 2px;
  border-bottom: 1px dashed var(--line);
}
.order-item:last-child { border-bottom: none; }
.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.order-title { font-size: 14px; font-weight: 600; color: var(--red-deep); }
.order-tag {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-free { color: #1a8a4a; background: #e4f7ea; border: 1px solid #a8dfba; }
.tag-paid { color: #a8232a; background: #fdeceb; border: 1px solid #f3c0bd; }
/* 一单多明细：每条占一行，名称左对齐、数量与小计右对齐 */
.order-lines {
  margin: 2px 0 6px;
  padding-left: 2px;
}
.order-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.7;
}
.order-line span:last-child {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-sub { font-size: 12px; color: var(--ink-soft); }
.order-wish {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.pager .btn-ghost { color: var(--ink-soft); }
.pager-info { font-size: 13px; color: var(--ink-soft); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  z-index: 200;
  transform: translateX(-50%);
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 14px;
  color: #fff;
  background: rgba(43, 29, 22, .92);
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 88vw;
  text-align: center;
}
.toast.ok { background: linear-gradient(135deg, #1a8a4a, #14703c); }
.toast.error { background: linear-gradient(135deg, var(--red-bright), var(--red)); }
@keyframes toastIn {
  from { transform: translate(-50%, 16px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- 入殿区块 ---------- */

.enter-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 0 6px;
}
.enter-hint {
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}
.enter-hint b { color: var(--red-deep); }
.enter-box .btn-worship { max-width: 420px; margin-top: 0; }

/* ---------- 小屏适配 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .brand-text h1 { font-size: 17px; letter-spacing: 2px; }
  .container { padding: 20px 12px 60px; }
  .step { padding: 20px 16px 24px; border-radius: 12px; }
  .deity-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .deity-emoji { font-size: 32px; }
  .product-grid { grid-template-columns: 1fr; }
  .altar-content { gap: 18px; }
  .altar-node .node-icon { font-size: 36px; }
  .btn-worship { letter-spacing: 3px; font-size: 16px; }
}
