/* ---------- 本地字体子集（Google Fonts 外链已移除，全部走本地） ----------
   由 tools/make-font-subset.py 按项目全部用字子集化生成，家族名与原 Google 字体
   保持一致（'Ma Shan Zheng' / 'Noto Serif SC'），所以下面所有 font-family 声明
   一行都不用改。
   不提供本地 Noto Sans SC —— 它在字体栈里后面就是 system-ui / 苹方 / 微软雅黑，
   各平台系统无衬线字体质量都足够好，没必要多传 200KB。
   若改了文案、出现子集外的字导致回退成宋体，重新跑 make-font-subset.py
   并更新下面的 ?v= 版本号。 */
@font-face {
  font-family: 'Ma Shan Zheng';
  src: url('fonts/MaShanZheng-subset.woff2?v=20260915b') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Noto Serif SC';
  src: url('fonts/NotoSerifSC-subset.woff2?v=20260915b') format('woff2');
  font-display: swap;
}

:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: 'Noto Sans SC', system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(circle at 50% 0%, #232a6b 0%, #14163a 45%, #0c0d22 100%);
  color: #faf6f0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

.serif { font-family: 'Noto Serif SC', STSong, SimSun, serif; }
.cal { font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif; }

/* ---------- 禅意背景 ---------- */
.bg-fixed { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -10; }
.bg-grad { position: absolute; inset: 0; background: linear-gradient(180deg, #232a6b 0%, #14163a 55%, #0c0d22 100%); }
.bg-halo {
  position: absolute; top: -96px; left: 50%; transform: translateX(-50%);
  width: 120%; height: 288px; background: rgba(212,168,83,0.10);
  filter: blur(48px); border-radius: 9999px;
}
@keyframes particle-rise {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  10%  { opacity: 0.7; }
  100% { transform: translateY(-110vh) scale(0.4); opacity: 0; }
}
.particle {
  position: absolute; bottom: -10px; border-radius: 9999px;
  background: rgba(212,168,83,0.40); box-shadow: 0 0 8px rgba(212,168,83,0.6);
}

/* ---------- 容器 ---------- */
.wrap {
  width: 100%; max-width: min(430px, 100vw); margin: 0 auto;
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
  position: relative; z-index: 1;
}
.hidden { display: none !important; }

/* ---------- 首页层 ---------- */
.cover { width: 100%; max-width: 420px; margin: 0 auto; padding: 0; }
.cover-img {
  display: block; margin: 0 auto; max-width: 100%; max-height: 32vh; width: auto; height: auto;
  border-radius: 18px;
  box-shadow: 0 0 24px rgba(212,168,83,0.45); border: 1px solid rgba(212,168,83,0.40);
  user-select: none; -webkit-user-drag: none;
}
.home-title {
  margin: 14px auto 0; text-align: center; font-size: 28px; letter-spacing: 0.12em;
  color: #f5d98a; text-shadow: 0 0 18px rgba(212,168,83,0.45);
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif;
}
.home-subtitle {
  margin: 6px auto 0; text-align: center; font-size: 13px; letter-spacing: 0.06em;
  color: rgba(250,246,240,0.50);
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}

/* ---------- 表单 ---------- */
.form-section { width: 100%; max-width: 420px; margin: 14px auto 0; padding: 0; }
.form-card {
  margin-top: 8px; border-radius: 18px; background: rgba(255,255,255,0.05);
  backdrop-filter: blur(4px); border: 1px solid rgba(212,168,83,0.20); padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.field-label { font-size: 12px; letter-spacing: 0.18em; color: rgba(212,168,83,0.80); font-family: 'Noto Serif SC', STSong, SimSun, serif; }
.input, .select {
  margin-top: 6px; width: 100%; border-radius: 10px;
  background: rgba(26,35,126,0.40); border: 1px solid rgba(212,168,83,0.30);
  padding: 10px 12px; color: #faf6f0; font-size: 15px; outline: none;
  font-family: 'Noto Sans SC', system-ui, 'PingFang SC', sans-serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input::placeholder { color: rgba(250,246,240,0.30); }
.input:focus, .select:focus { border-color: rgba(212,168,83,0.70); box-shadow: 0 0 0 2px rgba(212,168,83,0.15); }
.select { appearance: none; -webkit-appearance: none;
  /* 自定义金色下拉箭头（适配主题），替代被隐藏的原生箭头 */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' fill='none' stroke='%23d4a853' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px; cursor: pointer;
}
/* ---------- 生肖自定义下拉（完全主题化：展开列表不再使用系统原生样式） ---------- */
.zodiac-wrap { position: relative; margin-top: 6px; width: 100%; }
.zodiac-display {
  width: 100%; border-radius: 10px; cursor: pointer; outline: none;
  background-color: rgba(26,35,126,0.40); border: 1px solid rgba(212,168,83,0.30);
  padding: 10px 34px 10px 12px; font-size: 15px; letter-spacing: 0.1em;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' fill='none' stroke='%23d4a853' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  font-family: 'Noto Sans SC', system-ui, 'PingFang SC', sans-serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.zodiac-display.is-placeholder { color: rgba(250,246,240,0.35); }
.zodiac-display:not(.is-placeholder) { color: #f5d98a; }
.zodiac-wrap.open .zodiac-display,
.zodiac-display:focus { border-color: rgba(212,168,83,0.70); box-shadow: 0 0 0 2px rgba(212,168,83,0.15); }
.zodiac-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40;
  background: linear-gradient(180deg, rgba(24,28,64,0.98) 0%, rgba(14,16,44,0.98) 100%);
  border: 1px solid rgba(212,168,83,0.45); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55), 0 0 20px rgba(212,168,83,0.12);
  padding: 6px; max-height: 240px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.zodiac-menu[hidden] { display: none; }
.zodiac-option {
  padding: 9px 12px; border-radius: 8px; text-align: center; cursor: pointer;
  font-size: 15px; letter-spacing: 0.15em; color: #f0e6cf;
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
  transition: background 0.15s ease;
}
.zodiac-option + .zodiac-option { margin-top: 2px; }
.zodiac-option:hover { background: rgba(212,168,83,0.12); }
.zodiac-option.active {
  background: linear-gradient(180deg, #f5d98a 0%, #d4a853 100%);
  color: #14163a; font-weight: 500;
}
.date-display {
  margin-top: 6px; width: 100%; border-radius: 10px;
  background: rgba(26,35,126,0.40); border: 1px solid rgba(212,168,83,0.30);
  padding: 10px 12px; color: #d4a853; font-size: 15px; letter-spacing: 0.05em;
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}

/* ---------- 祈愿按钮 ---------- */
.btn-section { width: 100%; max-width: 420px; margin: 18px auto 0; padding: 0; }
.draw-btn {
  position: relative; width: 100%; overflow: hidden; border: none; cursor: pointer;
  border-radius: 9999px; padding: 14px 0; font-size: 22px;
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif;
  letter-spacing: 0.35em; color: #14163a;
  background: linear-gradient(180deg, #f5d98a 0%, #d4a853 55%, #b07d2e 100%);
  box-shadow: 0 0 24px rgba(212,168,83,0.45); transition: transform 0.15s ease, opacity 0.2s ease;
}
.draw-btn:hover:not(:disabled) { transform: scale(1.02); }
.draw-btn:active:not(:disabled) { transform: scale(0.99); }
.draw-btn:disabled { opacity: 0.70; cursor: wait; }

/* ---------- 结果层 ---------- */
@keyframes result-flip-in {
  0%   { transform: perspective(900px) rotateY(90deg); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: perspective(900px) rotateY(0deg); opacity: 1; }
}
@keyframes float-up {
  0%   { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.result { animation: float-up 0.7s ease-out both; }
.result-title {
  text-align: center; font-size: 20px; letter-spacing: 0.25em; color: #d4a853;
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif;
  margin-bottom: 16px; text-shadow: 0 0 14px rgba(212,168,83,0.40);
}
.result-img {
  display: block; width: auto; height: auto; max-width: min(420px, 86vw); max-height: 58vh;
  margin: 0 auto; border-radius: 18px;
  box-shadow: 0 0 24px rgba(212,168,83,0.45); border: 1px solid rgba(212,168,83,0.50);
  animation: result-flip-in 0.9s cubic-bezier(0.22,1,0.36,1) both;
  user-select: none; -webkit-user-drag: none;
}
/* ---------- 签卡翻面（点击翻转看背面首图） ---------- */
.flip-card {
  perspective: 1200px; width: fit-content; margin: 0 auto;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.flip-card:focus-visible { outline: 2px solid rgba(212,168,83,0.6); outline-offset: 6px; border-radius: 18px; }
.flip-inner {
  position: relative; transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
/* 背面（首图）：绝对定位铺满正面盒子，预旋转 180° 与正面贴合 */
.flip-face.flip-back {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; transform: rotateY(180deg); animation: none; margin: 0;
}
.flip-hint {
  text-align: center; font-size: 12px; letter-spacing: 0.14em;
  color: rgba(250,246,240,0.45); margin-top: 10px;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  transition: opacity 0.3s;
}
@media (prefers-reduced-motion: reduce) {
  .flip-inner { transition: none; }
}
.info-bar { margin-top: 20px; width: 100%; border-radius: 14px; background: rgba(255,255,255,0.05); border: 1px solid rgba(212,168,83,0.20); font-size: 14px; overflow: hidden; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.info-row + .info-row { border-top: 1px solid rgba(212,168,83,0.10); }
.info-key { color: rgba(250,246,240,0.50); letter-spacing: 0.18em; font-family: 'Noto Serif SC', STSong, SimSun, serif; }
.info-val { color: #faf6f0; font-family: 'Noto Sans SC', system-ui, sans-serif; }
.info-val.gold { color: #d4a853; font-family: 'Noto Serif SC', STSong, SimSun, serif; letter-spacing: 0.03em; }

.redraw-btn {
  margin-top: 20px; width: 100%; border-radius: 9999px; padding: 12px 0; cursor: pointer;
  font-size: 16px; letter-spacing: 0.3em; color: #d4a853; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(212,168,83,0.50); transition: background 0.2s ease, transform 0.15s ease;
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}
.redraw-btn:hover { background: rgba(255,255,255,0.10); }
.redraw-btn:active { transform: scale(0.99); }
.share-hint { margin-top: 16px; text-align: center; font-size: 12px; line-height: 1.7; color: rgba(250,246,240,0.40); font-family: 'Noto Sans SC', system-ui, sans-serif; }

.back-link {
  display: block; margin: 24px auto 0; background: none; border: none; cursor: pointer;
  font-size: 12px; letter-spacing: 0.2em; color: rgba(250,246,240,0.40); transition: color 0.2s ease;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.back-link:hover { color: rgba(250,246,240,0.70); }

/* ---------- 过渡层（全屏遮罩动效） ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
  background: radial-gradient(circle at 50% 38%, rgba(20,22,58,0.96) 0%, rgba(12,13,34,0.99) 100%);
  backdrop-filter: blur(6px);
}
.word-cloud {
  display: block; width: min(86vw, 360px); height: min(86vw, 360px);
}
.transition-text {
  margin-top: 28px; text-align: center; font-size: 18px; letter-spacing: 0.3em; color: #d4a853;
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif;
  text-shadow: 0 0 16px rgba(212,168,83,0.45);
}

/* ---------- 头像 / 昵称（首页可选） ---------- */
.avatar-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.avatar-prev {
  width: 46px; height: 46px; border-radius: 9999px; flex: 0 0 auto; overflow: hidden;
  background: rgba(26,35,126,0.40); border: 1px solid rgba(212,168,83,0.45);
  display: flex; align-items: center; justify-content: center;
  color: #d4a853; font-family: 'Ma Shan Zheng', serif; font-size: 22px;
}
.avatar-btn {
  font-size: 13px; color: #d4a853; background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(212,168,83,0.45); border-radius: 9999px; padding: 7px 14px; cursor: pointer;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.avatar-btn input { display: none; }

/* ---------- 分享按钮 ---------- */
.share-btn {
  margin-top: 14px; width: 100%; border-radius: 9999px; padding: 12px 0; cursor: pointer;
  font-size: 16px; letter-spacing: 0.25em; color: #14163a;
  background: linear-gradient(180deg, #f5d98a 0%, #d4a853 60%, #b07d2e 100%);
  border: none; box-shadow: 0 0 20px rgba(212,168,83,0.40);
  font-family: 'Noto Serif SC', STSong, SimSun, serif; transition: transform 0.15s ease;
}
.share-btn:active { transform: scale(0.99); }
.invite-note { margin-top: 12px; text-align: center; font-size: 12px; line-height: 1.7; color: rgba(212,168,83,0.9); font-family: 'Noto Sans SC', system-ui, sans-serif; }

/* ---------- 分享海报全屏预览 ---------- */
.share-preview {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.share-preview.hidden { display: none; }
.share-preview-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 8, 24, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.share-preview-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  width: 92%; max-width: 540px;
}
.share-preview-close {
  position: absolute; top: -48px; right: 0;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid rgba(212,168,83,0.45); background: rgba(20,22,58,0.7);
  color: #d4a853; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s;
}
.share-preview-close:active { background: rgba(212,168,83,0.2); transform: scale(0.92); }
.share-preview-tip {
  color: #d4a853; font-size: 14px; text-align: center;
  margin-bottom: 16px; letter-spacing: 0.5px;
  opacity: 0.9;
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}
.share-preview-img {
  width: 100%; height: auto; border-radius: 12px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(212,168,83,0.18);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: default;
}

/* ---------- 香期/节日弹窗 ---------- */
.festival-popup {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
.festival-popup.hidden { display: none; }
.festival-popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 8, 24, 0.82);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.festival-popup-card {
  position: relative; z-index: 1;
  width: 86%; max-width: 400px;
  padding: 34px 28px 26px; text-align: center;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(20,22,58,0.97) 0%, rgba(10,12,34,0.97) 100%);
  border: 1px solid rgba(212,168,83,0.4);
  box-shadow: 0 16px 60px rgba(0,0,0,0.55), 0 0 30px rgba(212,168,83,0.15);
  animation: festival-in 0.35s ease;
}
@keyframes festival-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.festival-popup-tag {
  display: inline-block; margin-bottom: 14px;
  padding: 4px 12px 4px 16px; border-radius: 9999px;
  font-size: 12px; letter-spacing: 0.3em; color: #14163a;
  background: linear-gradient(180deg, #f5d98a 0%, #d4a853 100%);
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}
.festival-popup-name {
  margin: 0 0 8px; font-size: 24px; font-weight: 400;
  color: #f5d98a; letter-spacing: 0.08em;
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', STSong, SimSun, serif;
}
/* 多条并列：条目间以金色细线分隔；条目多时列表内部滚动，按钮始终可见 */
.festival-popup-list {
  width: 100%; max-height: 52vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.festival-popup-list::-webkit-scrollbar { width: 3px; }
.festival-popup-list::-webkit-scrollbar-thumb {
  background: rgba(212,168,83,0.35); border-radius: 3px;
}
.festival-popup-entry { width: 100%; }
.festival-popup-entry + .festival-popup-entry {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid rgba(212,168,83,0.22);
}
.festival-popup-entry .festival-popup-msg { margin-bottom: 0; }
.festival-popup-date {
  margin: 0 0 18px; font-size: 13px; letter-spacing: 0.05em;
  color: rgba(212,168,83,0.75);
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.festival-popup-msg {
  margin: 0 0 24px; font-size: 15px; line-height: 2;
  color: #e8dcc0;
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
}
.festival-popup-btn {
  width: 100%; border-radius: 9999px; padding: 11px 0; cursor: pointer;
  font-size: 15px; letter-spacing: 0.2em; color: #14163a;
  background: linear-gradient(180deg, #f5d98a 0%, #d4a853 60%, #b07d2e 100%);
  border: none; box-shadow: 0 0 16px rgba(212,168,83,0.35);
  font-family: 'Noto Serif SC', STSong, SimSun, serif;
  transition: transform 0.15s ease;
}
.festival-popup-btn:active { transform: scale(0.98); }
@media (prefers-reduced-motion: reduce) {
  .festival-popup-card { animation: none; }
}

/* 日期可点击：查看今日香期/节日弹窗 */
.date-display { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity 0.15s ease; }
.date-display:active { opacity: 0.7; }
