:root {
  --cream: #F7F1E3;
  --ink: #2E3A32;
  --ink-soft: #5F665B;
  --muted: #8A8776;
  --moss: #3C4C3E;
  --cinnabar: #B04A3C;
  --gold: #C9A45C;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --kai: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
button { font-family: inherit; }

.landscape {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: clamp(140px, 27vh, 300px);
  object-fit: cover;
  object-position: bottom;
  z-index: 0;
  pointer-events: none;
}

.page { position: relative; z-index: 1; }

.cta {
  display: block;
  border: 0;
  border-radius: 999px;
  padding: 15px 44px;
  background: var(--moss);
  color: #FBF6E8;
  font-size: 15px;
  letter-spacing: .14em;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(60, 76, 62, .22);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.cta:hover:not(:disabled) {
  background: #334434;
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(60, 76, 62, .26);
}

.cta:disabled {
  opacity: .75;
  cursor: wait;
  transform: none;
}

.cta:focus-visible {
  outline: 2px solid rgba(176, 74, 60, .55);
  outline-offset: 3px;
}

.cta .arrow {
  display: inline-block;
  margin-left: 10px;
  letter-spacing: 0;
}

.cta.loading .arrow { display: none; }

.cta.loading .label {
  animation: labelPulse 1.4s ease-in-out infinite;
}

@keyframes labelPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* ---------- 首页 ---------- */

.home {
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 24px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  display: block;
  width: min(640px, 100%);
  height: auto;
  border-radius: 16px;
  box-shadow: 0 24px 54px rgba(92, 82, 60, .14);
}

.pet-slot {
  width: 190px;
  height: 216px;
  margin-top: 12px;
}

.pet-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.pet-wrap.dragging { cursor: grabbing; }

.pet-wrap:focus-visible .pet-img {
  filter: drop-shadow(0 0 8px rgba(176, 74, 60, .5));
}

.pet-img {
  display: block;
  width: 100%;
  height: 100%;
  animation: petFloat 5.2s ease-in-out infinite;
  transform-origin: 50% 90%;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

@keyframes petFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-.6deg); }
}

.pet-wrap.happy .pet-img { animation: petHappy .62s ease; }

@keyframes petHappy {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-11px) scale(1.04); }
  62% { transform: translateY(0) scale(.985); }
  100% { transform: translateY(0) scale(1); }
}

.pet-wrap.sleeping .pet-img {
  animation-play-state: paused;
  filter: saturate(.75) brightness(.96);
  transform: translateY(3px);
}

.pet-bubble {
  position: absolute;
  left: -138px;
  top: 18px;
  padding: 8px 13px;
  border-radius: 14px;
  background: #FFFDF8;
  color: #7A5847;
  font-size: 11.5px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(180, 120, 90, .14);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.pet-bubble.show { opacity: 1; transform: translateY(0); }

.pet-bubble::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #FFFDF8;
  transform: translateY(-50%) rotate(45deg);
  border-radius: 1px;
}

.pet-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.heart {
  position: absolute;
  animation: heartUp 1.2s ease-out forwards;
}

@keyframes heartUp {
  0% { opacity: 0; transform: translateY(4px) scale(.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-42px) scale(1.1); }
}

.pet-zzz {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 42px;
  height: 52px;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  color: #A5826D;
  font-family: Georgia, serif;
}

.pet-zzz span {
  position: absolute;
  right: 0;
  bottom: 0;
  animation: zFloat 2.6s ease-in-out infinite;
}

.pet-zzz span:nth-child(1) { font-size: 11px; right: 14px; bottom: 0; }
.pet-zzz span:nth-child(2) { font-size: 15px; right: 8px; bottom: 13px; animation-delay: .4s; }
.pet-zzz span:nth-child(3) { font-size: 20px; right: 0; bottom: 28px; animation-delay: .8s; }

.pet-wrap.sleeping .pet-zzz { opacity: 1; }

@keyframes zFloat {
  0% { opacity: 0; transform: translateY(5px); }
  30% { opacity: .85; }
  100% { opacity: 0; transform: translateY(-12px); }
}

.story {
  width: min(600px, 100%);
  margin: 24px auto 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 2.02;
  letter-spacing: .01em;
  color: #4B4B3F;
}

.story .block { display: block; margin-top: 13px; }

.story .block:first-child {
  margin-top: 0;
  font-size: 19px;
  line-height: 1.95;
  color: #354036;
}

.story strong { font-weight: 700; color: var(--ink); }

.home .cta { margin-top: 30px; }

/* ---------- 写信页 ---------- */

.write-page { width: 100%; }

.write-hero {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.write-hero img {
  display: block;
  width: 100%;
  height: clamp(320px, 52vw, 520px);
  object-fit: cover;
  object-position: center 42%;
}

.write-form {
  width: min(560px, calc(100% - 36px));
  margin: 0 auto;
  padding: 46px 0 90px;
}

.q { display: block; margin: 0 0 26px; }

.q p {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin: 0 0 5px;
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.6;
  letter-spacing: .02em;
  color: #3A4438;
}

.q .num {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--cinnabar);
}

.q input {
  display: block;
  width: 100%;
  padding: 10px 2px 11px;
  border: 0;
  border-bottom: 1px solid rgba(74, 85, 68, .22);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  outline: none;
  transition: border-color .2s ease;
}

.q input:focus { border-color: var(--cinnabar); }

.q input::placeholder {
  color: #A8A08D;
  font-size: 14px;
}

.write-form .cta { margin: 48px auto 0; }

.form-msg {
  min-height: 22px;
  margin: 14px 0 0;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

.form-msg.error { color: #A94438; }

/* ---------- 信件页 ---------- */

.letter-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 16px 110px;
}

.letter-card {
  position: relative;
  width: min(700px, 100%);
  margin: 0 auto;
  padding: 78px 88px 76px;
  border: 1px solid #CBB88F;
  border-radius: 6px;
  background:
    radial-gradient(rgba(120, 100, 70, .03) 1px, transparent 1px),
    linear-gradient(180deg, #FDF9EF 0%, #F9F2E1 100%);
  background-size: 5px 5px, 100% 100%;
  box-shadow: 0 30px 70px rgba(92, 82, 60, .12);
}

.letter-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid #E0D4BA;
  border-radius: 4px;
  pointer-events: none;
}

.letter-inner {
  position: relative;
  z-index: 2;
}

.letter-head { text-align: center; }

.letter-head .eyebrow {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 8.5px;
  letter-spacing: .34em;
  color: #A69D89;
}

.letter-head .title {
  display: block;
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .3em;
  color: #7C846F;
}

.letter-text {
  margin-top: 26px;
  font-family: var(--kai);
  font-size: 17px;
  line-height: 2;
  letter-spacing: .01em;
  color: #3B3B31;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.letter-text.reveal { animation: inkIn .8s ease both; }

@keyframes inkIn {
  from { opacity: 0; filter: blur(5px); transform: translateY(6px); }
  to { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.corner {
  position: absolute;
  width: 96px;
  height: 96px;
  z-index: 1;
  opacity: .9;
  pointer-events: none;
}

.corner.tl { top: 0; left: 0; }
.corner.tr { top: 0; right: 0; transform: scaleX(-1); }
.corner.bl { bottom: 0; left: 0; transform: scaleY(-1); }
.corner.br { bottom: 0; right: 0; transform: scale(-1, -1); }

.vine {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 48px;
  right: 48px;
  height: 34px;
  background: url("vine-tile.svg") repeat-x center;
  opacity: .85;
  pointer-events: none;
}

.grass {
  position: absolute;
  z-index: 1;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 58px;
  background: url("grass-tile.svg") repeat-x bottom;
  opacity: .9;
  pointer-events: none;
}

.bfly {
  position: absolute;
  z-index: 3;
  width: 52px;
  height: auto;
  pointer-events: none;
  animation: bflyFloat 4.6s ease-in-out infinite;
}

.bfly.teal { top: 4px; right: 44px; }
.bfly.pink { bottom: 8px; left: 44px; animation-delay: -2.3s; }

@keyframes bflyFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(3deg); }
}

.seal {
  position: absolute;
  z-index: 4;
  right: 74px;
  bottom: 74px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--cinnabar);
  color: #FFF7E8;
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: .18em;
  writing-mode: vertical-rl;
  transform: rotate(-3deg);
  opacity: .9;
  box-shadow: inset 0 0 0 1px rgba(255, 247, 232, .3);
}

.letter-fallback {
  text-align: center;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2;
  color: var(--ink-soft);
}

.letter-fallback a {
  color: var(--cinnabar);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 手机端 ---------- */

@media (max-width: 720px) {
  .home { padding: 32px 18px 70px; }
  .hero { width: 100%; border-radius: 12px; }

  .pet-slot { width: 150px; height: 171px; }

  .pet-bubble {
    left: 50%;
    top: auto;
    bottom: calc(100% + 2px);
    transform: translateX(-50%) translateY(4px);
  }

  .pet-bubble.show { transform: translateX(-50%) translateY(0); }

  .pet-bubble::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -4px;
    transform: translateX(-50%) rotate(45deg);
  }

  .story {
    width: 100%;
    margin-top: 20px;
    font-size: 15.5px;
    line-height: 1.95;
  }

  .story .block:first-child { font-size: 17.5px; }
  .home .cta { margin-top: 26px; padding: 14px 36px; }

  .write-hero img { height: 320px; }
  .write-form { width: calc(100% - 32px); padding-top: 32px; }
  .q p { font-size: 16.5px; }
  .write-form .cta { margin-top: 38px; }

  .letter-page { padding: 28px 12px 80px; }
  .letter-card { padding: 62px 30px 64px; }
  .corner { width: 58px; height: 58px; }
  .vine { top: 6px; left: 24px; right: 24px; height: 26px; background-size: auto 26px; }
  .grass { height: 42px; bottom: 3px; background-size: auto 42px; }
  .bfly { width: 38px; }
  .bfly.teal { top: 2px; right: 24px; }
  .bfly.pink { bottom: 4px; left: 24px; }
  .letter-text { font-size: 16.5px; line-height: 1.95; margin-top: 22px; }
  .seal { right: 30px; bottom: 46px; width: 36px; height: 36px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .pet-img, .bfly, .letter-text.reveal { animation: none; }
  .cta.loading .label { animation: none; }
}
