:root {
  --ink: #0b0e14;
  --ink-2: #131722;
  --line: #2a3142;
  --ivory: #f3ede0;
  --muted: #a9a39a;
  --gold: #d8b04a;
  --gold-soft: #e3bd5e;
  --red: #a91d2a;
  --green: #2f6b4f;
  --paper: #f5efe0;
  --crimson: #a63b2e;
  --warmgray: #c9c2b4;
  --radius: 8px;
  --font-display: "NotoSerifSC", "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "STSong", "SimSun", serif;
  --font-script: "KaiTi", "STKaiti", "Kaiti", serif;
  --font-body: "NotoSansSC", "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@font-face {
  font-family: "NotoSerifSC";
  src: url("/assets/fonts/noto-serif-sc-cn-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "NotoSansSC";
  src: url("/assets/fonts/noto-sans-sc-cn-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

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

body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("/assets/grain.png");
  background-size: 160px 160px;
  mix-blend-mode: screen;
  z-index: 20;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 28px 20px 32px;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(11, 14, 20, 0.82), rgba(11, 14, 20, 0.94)),
    url("/assets/fortune-bg.jpg") center / cover no-repeat;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 50% 18%, rgba(212, 175, 55, 0.1), transparent 44%),
    linear-gradient(180deg, rgba(11, 14, 20, 0.72), rgba(11, 14, 20, 0.95));
}

.screen-home {
  background: transparent;
}

.screen-home::before {
  content: none;
}

.screen-home::after {
  content: none;
}

.hero-bg {
  position: absolute;
  inset: -8% -4%;
  z-index: -3;
  background: url("/assets/main-keyart.jpg") left center / cover no-repeat;
  animation: heroPan 12s ease-in-out infinite alternate;
  will-change: transform;
}

.hero-veil {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 52% 37%, rgba(212, 175, 55, 0.14), transparent 24%),
    linear-gradient(180deg, rgba(11, 14, 20, 0.06) 0%, rgba(11, 14, 20, 0.02) 26%, rgba(11, 14, 20, 0.42) 52%, rgba(11, 14, 20, 0.86) 78%, #0b0e14 100%);
}

.hero-veil::after {
  content: "";
  position: absolute;
  top: 9%;
  right: -8%;
  width: 58%;
  height: 58%;
  opacity: 0.13;
  pointer-events: none;
  background: url("/assets/hu-zi-light.png") center / contain no-repeat;
  filter: drop-shadow(0 0 22px rgba(212, 175, 55, 0.35));
}

.screen-star,
.screen-sign {
  background:
    linear-gradient(180deg, rgba(11, 14, 20, 0.4) 0%, rgba(11, 14, 20, 0.22) 28%, rgba(11, 14, 20, 0.88) 78%, #0b0e14 100%),
    url("/assets/main-keyart.jpg") center 34% / cover no-repeat;
}

@keyframes heroPan {
  from { background-position: 25% center; }
  to { background-position: 75% center; }
}

.screen-star::after,
.screen-sign::after {
  content: "";
  position: absolute;
  top: 16%;
  right: -6%;
  width: 54%;
  height: 54%;
  z-index: -1;
  opacity: 0.09;
  pointer-events: none;
  background: url("/assets/hu-zi-light.png") center / contain no-repeat;
}

.fortune-theme {
  margin: 0 0 18px;
  color: rgba(227, 189, 94, .82);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 6px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.fortune-theme::before,
.fortune-theme::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: 26px;
  height: 1px;
  margin: 0 10px;
}

.fortune-theme::before { background: linear-gradient(90deg, transparent, rgba(227, 189, 94, .72)); }
.fortune-theme::after { background: linear-gradient(90deg, rgba(227, 189, 94, .72), transparent); }

.screen.is-active {
  display: flex;
  animation: screenIn .48s cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeDown .8s .05s ease-out both;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(212, 175, 55, .72);
  border-radius: var(--radius);
  color: var(--crimson);
  display: grid;
  place-items: center;
  font-family: var(--font-script);
  font-weight: 700;
  font-size: 20px;
  box-shadow: inset 0 0 18px rgba(212, 175, 55, .08);
}

.brand-show {
  color: rgba(243, 237, 224, .76);
  margin: 0;
  font-size: 13px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .8);
}

.home-core {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 48px 0;
}

.home-core h1 {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 1.12;
  margin: 0;
  color: var(--paper);
  letter-spacing: 5px;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .55),
    0 3px 10px rgba(0, 0, 0, .9),
    0 8px 26px rgba(0, 0, 0, .78);
  animation: fadeUp .9s .1s ease-out both;
}

.slogan {
  color: var(--gold-soft);
  font-size: 18px;
  margin: 0;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .5),
    0 2px 8px rgba(0, 0, 0, .92),
    0 5px 18px rgba(0, 0, 0, .72);
  animation: fadeUp .9s .52s ease-out both;
}

.slogan::before {
  content: "";
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft));
}

.slogan::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-soft), transparent);
}

.today-line {
  color: var(--warmgray);
  margin: 0;
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, .8),
    0 3px 12px rgba(0, 0, 0, .9);
  animation: fadeUp .9s .94s ease-out both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Buttons */
.btn-primary,
.btn-secondary {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 18px;
  transition: transform .18s ease, box-shadow .2s ease, opacity .2s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #dcba53, #b48c2a);
  color: #191307;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
}

.btn-primary:active,
.btn-secondary:active { transform: scale(.985); }

.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-secondary {
  background: rgba(19, 23, 34, .72);
  color: var(--ivory);
  border: 1px solid rgba(212, 175, 55, .24);
  backdrop-filter: blur(8px);
}

.btn-primary svg,
.btn-secondary svg,
.icon-btn svg { width: 20px; height: 20px; }

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--ivory);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--ivory);
  font-weight: 600;
  position: relative;
  z-index: 2;
}

/* Photo */
.photo-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(212, 175, 55, .2);
  border-radius: var(--radius);
  background: rgba(11, 14, 20, .48);
  overflow: hidden;
  margin-bottom: 20px;
  min-height: 320px;
  backdrop-filter: blur(8px);
}

.guide-tiger {
  position: absolute;
  inset: 8% 15%;
  width: 70%;
  height: 84%;
  object-fit: contain;
  opacity: .16;
  pointer-events: none;
  filter: drop-shadow(0 0 18px rgba(212, 175, 55, .18));
}

.photo-pick {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 24px;
  text-align: center;
}

.photo-pick svg { width: 42px; height: 42px; color: var(--gold-soft); }

#photoPreview {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bigdipper { width: 180px; height: auto; }

.dipper-line {
  fill: none;
  stroke: #465068;
  stroke-width: 2;
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
}

.bigdipper.is-live .dipper-line { animation: drawLine 1.1s ease-out forwards; }

.star { fill: #303548; stroke: #4a5062; stroke-width: 1; transform-box: fill-box; transform-origin: center; }

.star.lit {
  fill: var(--gold-soft);
  stroke: #fff0bf;
  filter: drop-shadow(0 0 7px rgba(212, 175, 55, .72));
  animation: starPop .7s cubic-bezier(.2, .75, .3, 1.25) both, starGlow 2.8s .7s ease-in-out infinite;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

@keyframes starGlow {
  0%, 100% { opacity: .82; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.16); }
}

@keyframes starPop {
  0% { transform: scale(.4); opacity: .3; }
  70% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.fortune-star {
  color: var(--gold-soft);
  margin: 0;
  font-size: 16px;
  letter-spacing: 4px;
  font-family: var(--font-display);
}

.brand-show,
.today-line {
  font-family: var(--font-body);
}

.fortune-label {
  color: var(--crimson);
  border: 1px solid rgba(166, 59, 46, .55);
  border-radius: 4px;
  padding: 4px 14px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 4px;
}

.star-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.star-stage .bigdipper { width: 230px; }

.star-theme {
  color: var(--muted);
  margin: 0;
  font-size: 13px;
  letter-spacing: 2px;
}

.star-progress {
  margin: 18px 0 0;
  color: rgba(227, 189, 94, .82);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  text-align: center;
}

.star-progress.is-complete {
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(212, 176, 74, .45);
}

.land-note-tag {
  color: rgba(166, 59, 46, .85);
  letter-spacing: 1px;
}

.sign-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  position: relative;
}

.sign-stage[hidden] { display: none; }

.sign-stage::before {
  content: "";
  position: absolute;
  inset: -24px -24px;
  z-index: -1;
  background: radial-gradient(circle at 50% 42%, rgba(212, 176, 74, .17), transparent 62%);
  opacity: 0;
  transition: opacity .45s ease;
  pointer-events: none;
}

.sign-stage.is-shaking::before {
  opacity: 1;
}

.sign-tube {
  position: relative;
  width: 158px;
  height: 228px;
  cursor: pointer;
  transform-origin: 50% 72%;
  transition: transform .35s cubic-bezier(.2, .75, .3, 1.1), opacity .45s ease;
  filter: drop-shadow(0 20px 28px rgba(0, 0, 0, .5));
}

.tube-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.stick {
  position: absolute;
  top: 40px;
  left: 50%;
  width: 7px;
  height: 76px;
  margin-left: -3.5px;
  border-radius: 3px;
  background: linear-gradient(180deg, #e2c184, #b78a3d);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
}

.sign-stage.is-ready .sign-tube { animation: tubeIdle 2.8s ease-in-out infinite; }
.sign-stage.is-shaking .sign-tube { animation: tubeShakeBig .7s ease-in-out forwards; }
.sign-stage.is-shaking .stick { animation: stickFly .7s ease-out forwards; }
.sign-stage.is-revealed .sign-tube {
  opacity: 0;
  transform: scale(.72) translateY(34px);
}

.draw-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  transition: opacity .3s ease;
}

@keyframes tubeIdle {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-1.2deg); }
}

@keyframes tubeShakeBig {
  0% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.9) rotate(-5deg); }
  50% { transform: scale(1.95) rotate(4deg); }
  75% { transform: scale(1.9) rotate(-3deg); }
  100% { transform: scale(1.9) rotate(0); }
}

@keyframes stickFly {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  18% { opacity: 1; }
  68% { transform: translateY(-92px) rotate(-7deg); opacity: 1; }
  100% { transform: translateY(-128px) rotate(-13deg); opacity: 0; }
}

.sign-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  margin-bottom: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .55s cubic-bezier(.2, .75, .25, 1), transform .55s cubic-bezier(.2, .75, .25, 1);
}

.sign-result[hidden] { display: none; }
.sign-result.is-shown { opacity: 1; transform: translateY(0); }

.sign-text {
  font-family: var(--font-script);
  font-size: 31px;
  line-height: 1.5;
  margin: 0;
  letter-spacing: 1px;
}

.sign-interp {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  margin: 0;
}

.sign-land {
  margin: 0 0 26px;
  color: rgba(201, 194, 180, .78);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .5s ease .15s, transform .5s ease .15s;
}

.sign-land[hidden] { display: none; }
.sign-land.is-shown { opacity: 1; transform: translateY(0); }

.star-read {
  margin: 0 0 30px;
  color: rgba(243, 237, 224, .9);
  font-family: var(--font-script);
  font-size: 17px;
  line-height: 1.9;
  text-align: center;
  padding: 0 12px;
  max-width: 100%;
}

.poster-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.poster-actions .btn-secondary { grid-column: 1 / -1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(19, 23, 34, .94);
  color: var(--ivory);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(212, 175, 55, .28);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
  max-width: 80vw;
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Poster */
.poster-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

#posterImg {
  display: block;
  width: 100%;
  max-width: 300px;
  max-height: 68vh;
  border-radius: var(--radius);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .48);
  background: var(--ink-2);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: default;
  object-fit: contain;
}

/* 微信内长按保存提示：改为文字提示，不再用虚线框压住海报 */
.poster-tip {
  margin: -6px auto 18px;
  text-align: center;
  font-size: 13px;
  letter-spacing: .4px;
  color: var(--gold-soft);
  opacity: .82;
}
.poster-tip .tip-arrow {
  display: inline-block;
  margin-right: 6px;
  animation: tip-bob 1.6s ease-in-out infinite;
}
@keyframes tip-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

#posterCanvas {
  width: 100%;
  height: auto;
  max-width: 300px;
  max-height: 68vh;
  border-radius: var(--radius);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .48);
  background: var(--ink-2);
}

@media (min-width: 520px) {
  body { padding: 20px 0; }
}
