:root {
  color-scheme: dark;
  --wash: #6d3144;
  --ink: #fff8f6;
  --muted: rgba(255, 248, 246, 0.76);
  --line: rgba(255, 248, 246, 0.42);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }
body { touch-action: manipulation; user-select: none; }

body {
  min-height: 100dvh;
  color: var(--ink);
  background: var(--wash);
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  transition: background-color 0.8s ease, color 0.8s ease;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 236, 240, 0.46), transparent 34%),
    radial-gradient(circle at 50% 120%, rgba(0, 0, 0, 0.28), transparent 46%);
}

body[data-mood="welcome"] { --wash: #4c2233; }
body[data-mood="0"] { --wash: #6d3144; }
body[data-mood="1"] { --wash: #8a4b52; }
body[data-mood="2"] { --wash: #2a1438; }
body[data-mood="3"] { --wash: #1b2744; }
body[data-mood="4"] {
  --wash: #f3e2d4;
  --ink: #5a2e36;
  --muted: rgba(90, 46, 54, 0.76);
  --line: rgba(90, 46, 54, 0.38);
  color-scheme: light;
}
body[data-mood="5"] { --wash: #3d4d78; }
body[data-mood="6"] { --wash: #1d3b34; }
body[data-mood="7"] { --wash: #4c3946; }
body[data-mood="8"] { --wash: #6d4e3c; }
body[data-mood="9"] { --wash: #7a2436; }

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

main {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.42em;
  font-size: 13px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "楷体", serif;
  font-size: clamp(76px, 18vw, 128px);
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.line {
  min-height: 1.6em;
  margin: 18px 0 28px;
  font-size: clamp(18px, 4.6vw, 24px);
  color: var(--muted);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.line.swap {
  opacity: 0;
  transform: translateY(8px);
}

.heart {
  width: 118px;
  height: 118px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background:
    radial-gradient(circle at 34% 30%, #fff 0%, #ffe3ea 26%, #f07290 68%, #c6365c 100%);
  box-shadow:
    0 18px 50px rgba(110, 20, 40, 0.32),
    inset 0 0 0 7px rgba(255, 255, 255, 0.2);
  transition: transform 0.25s ease;
}

.heart svg {
  width: 58px;
  height: 52px;
  fill: currentColor;
  filter: drop-shadow(0 6px 8px rgba(120, 20, 40, 0.2));
  transform-origin: center;
  animation: beat 1.35s ease-in-out infinite;
}

.heart:active { transform: scale(0.94); }

.heart.m1 svg { animation-name: sway; }
.heart.m2 svg { animation-name: pop; }
.heart.m3 svg { animation-name: spin; }
.heart.m4 svg { animation-name: beat; }
.heart.m5 svg { animation-name: sway; }
.heart.m6 svg { animation-name: glow; }
.heart.m7 svg { animation-name: pop; }
.heart.m8 svg { animation-name: sway; }
.heart.m9 svg { animation-name: beat; }

.dots {
  display: flex;
  gap: 7px;
  margin-top: 26px;
}

.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  display: block;
}

.dots i.on {
  background: var(--ink);
  transform: scale(1.35);
}

.hint {
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--muted);
  transition: opacity 0.6s ease;
}

.hint.gone { opacity: 0; }

.letter {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(48, 22, 28, 0.18);
}

.letter[hidden] { display: none; }

.paper {
  width: min(420px, 100%);
  padding: 32px 28px 28px;
  border-radius: 18px;
  color: #5c3138;
  background:
    linear-gradient(180deg, rgba(255, 252, 248, 0.2), transparent 28%),
    #fff8f2;
  box-shadow: 0 24px 70px rgba(60, 20, 30, 0.28);
  animation: rise 0.55s ease;
}

.paper-kicker {
  margin: 0;
  letter-spacing: 0.32em;
  font-size: 13px;
}

.paper h2 {
  margin: 8px 0 16px;
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "楷体", serif;
  font-size: 42px;
  font-weight: 400;
}

.paper p { margin: 0 0 12px; line-height: 1.85; font-size: 17px; }

.sound {
  position: fixed;
  z-index: 5;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 7px 12px;
  letter-spacing: 0.08em;
  font: inherit;
  font-size: 13px;
  opacity: 0.8;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  18% { transform: scale(1.08); }
  32% { transform: scale(0.98); }
  48% { transform: scale(1.05); }
}

@keyframes sway {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.04); }
}

@keyframes pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.16); }
}

@keyframes spin {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 236, 170, 0)); }
  50% { filter: drop-shadow(0 0 12px rgba(255, 228, 160, 0.95)); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (max-height: 720px) {
  h1 { font-size: 68px; }
  .line { margin: 10px 0 16px; }
  .heart { width: 92px; height: 92px; }
  .heart svg { width: 46px; height: 42px; }
  .dots { margin-top: 16px; }
}

.loc-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  max-width: min(92vw, 340px);
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  color: #5a2e36;
  background: rgba(255, 246, 240, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.loc-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .heart svg, .line, .paper { animation: none; transition: none; }
  .loc-toast { transition: none; }
}
