:root {
  --night-1: #150f38;
  --night-2: #2d1b69;
  --night-3: #5b2a86;
  --night-4: #8f3b8f;
  --pink-1: #ff8fab;
  --pink-2: #ff5d8f;
  --gold: #ffd77a;
  --text-dark: #6d3350;
  --card-bg: rgba(255, 255, 255, 0.88);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--night-2);
  color: #fff;
}

/* ---------- 两层通用 ---------- */
.layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.9s ease, transform 0.9s ease, visibility 0.9s;
}

/* ---------- 封面层 ---------- */
.cover {
  z-index: 2;
  background:
    radial-gradient(circle at 80% 12%, rgba(255, 213, 122, 0.18), transparent 26%),
    radial-gradient(circle at 15% 85%, rgba(255, 95, 143, 0.25), transparent 34%),
    linear-gradient(155deg, var(--night-1) 0%, var(--night-2) 42%, var(--night-3) 76%, var(--night-4) 100%);
  background-image: url("../assets/cover.jpg");
  background-size: cover;
  background-position: center 35%;
  cursor: pointer;
  user-select: none;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.30) 0%, rgba(255, 255, 255, 0.0) 28%, rgba(255, 255, 255, 0.0) 72%, rgba(255, 255, 255, 0.25) 100%);
  pointer-events: none;
}

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

.star {
  position: absolute;
  background: #f2a63d;
  box-shadow: 0 0 6px rgba(242, 166, 61, 0.9);
  border-radius: 50%;
  animation: twinkle var(--tw, 2.6s) ease-in-out infinite alternate;
  animation-delay: var(--td, 0s);
}

@keyframes twinkle {
  from { opacity: 0.15; transform: scale(0.7); }
  to   { opacity: 1;    transform: scale(1.15); }
}

.moon {
  position: absolute;
  top: 9%;
  right: 10%;
  width: clamp(56px, 12vw, 92px);
  height: clamp(56px, 12vw, 92px);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, #fff7d6 0%, #ffe9a8 55%, #f6c96b 100%);
  box-shadow:
    0 0 26px rgba(255, 233, 168, 0.75),
    0 0 80px rgba(255, 233, 168, 0.35);
  animation: moonGlow 4.5s ease-in-out infinite alternate;
}

.moon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 62% 58%, rgba(180, 140, 90, 0.28) 0 8%, transparent 9%),
    radial-gradient(circle at 38% 68%, rgba(180, 140, 90, 0.22) 0 6%, transparent 7%);
}

@keyframes moonGlow {
  from { box-shadow: 0 0 22px rgba(255, 233, 168, 0.6), 0 0 70px rgba(255, 233, 168, 0.28); }
  to   { box-shadow: 0 0 34px rgba(255, 233, 168, 0.9), 0 0 110px rgba(255, 233, 168, 0.45); }
}

.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floater {
  position: absolute;
  bottom: -10%;
  animation: floatUp var(--dur, 9s) linear infinite;
  animation-delay: var(--dl, 0s);
  opacity: 0.85;
}

@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  8%   { opacity: var(--op, 0.8); }
  50%  { transform: translateY(-55vh) translateX(var(--sway, 24px)) rotate(12deg); }
  100% { transform: translateY(-115vh) translateX(calc(var(--sway, 24px) * -1)) rotate(-14deg); opacity: 0; }
}

.cover-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px;
  animation: fadeDown 1s ease both;
}

.cover .cover-content {
  margin-top: 6vh;
}

.cover-music-btn {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 1.5px solid rgba(74, 58, 108, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: #7a4a8f;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(80, 50, 110, 0.18);
}

.cover-music-btn:active {
  transform: scale(0.92);
}

.cover-music-btn.needs-tap {
  animation: musicPulse 1.8s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 122, 168, 0.55); }
  50%      { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(255, 122, 168, 0); }
}

.cover-title {
  font-size: clamp(46px, 13vw, 78px);
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(120deg, #3b2f7a 0%, #c9417f 55%, #e05a3c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.9));
  animation: titleFloat 3.4s ease-in-out infinite;
}

.cover-divider {
  margin: 18px 0 12px;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #b8860b;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.cover-sub {
  font-size: clamp(13px, 3.6vw, 16px);
  color: rgba(74, 58, 108, 0.94);
  line-height: 1.8;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.9);
}

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

.cover-emoji {
  font-size: clamp(26px, 7vw, 40px);
  letter-spacing: 0.35em;
  margin-bottom: 14px;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.9);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

.cover-divider span {
  font-size: 0.62em;
  vertical-align: middle;
}

.open-btn {
  margin-top: 34px;
  padding: 14px 38px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  background: linear-gradient(120deg, var(--pink-2), #b84ad6);
  border: none;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(255, 93, 143, 0.45);
  cursor: pointer;
  animation: btnGlow 2.2s ease-in-out infinite;
}

.open-btn:active {
  transform: scale(0.95);
}

@keyframes btnGlow {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 93, 143, 0.4); }
  50%      { box-shadow: 0 8px 38px rgba(255, 93, 143, 0.75); }
}

.tap-hint {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: rgba(74, 58, 108, 0.62);
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* ---------- 内页层 ---------- */
.inner {
  z-index: 1;
  visibility: hidden;
  opacity: 0;
  transform: translateY(46px) scale(0.96);
  pointer-events: none;
  justify-content: flex-start;
  padding-top: calc(8vh + env(safe-area-inset-top, 0px));
  background: linear-gradient(160deg, #ffd9e8 0%, #ffc2d6 38%, #ffd7ec 72%, #ffe9d6 100%);
  background-image: none;
  background-size: cover;
  background-position: center;
}

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

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  animation: twinkle var(--tw, 2.4s) ease-in-out infinite alternate;
  animation-delay: var(--td, 0s);
}

.floaters-inner {
  opacity: 0.8;
}

.inner-card {
  position: relative;
  z-index: 1;
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 0 10px 18px;
  text-align: center;
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(18, 10, 48, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.65);
  text-shadow: 0 1px 6px rgba(18, 10, 48, 0.5);
}

.card-body {
  margin-top: 22px;
}

.greeting {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(18, 10, 48, 0.55);
}

.name {
  color: #ffd77a;
}

.message {
  font-size: 16px;
  line-height: 2.05;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 9px rgba(18, 10, 48, 0.6);
}

.sign {
  margin-top: 22px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 8px rgba(18, 10, 48, 0.6);
  text-align: right;
  padding-right: 6px;
}

.card-footer {
  margin-top: 26px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.round-btn {
  padding: 11px 22px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--pink-2), #a94ad6);
  box-shadow: 0 6px 16px rgba(255, 93, 143, 0.35);
  cursor: pointer;
}

.round-btn.ghost {
  color: var(--pink-2);
  background: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(255, 93, 143, 0.4);
}

.round-btn:active {
  transform: scale(0.95);
}

.footer-note {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 6px rgba(18, 10, 48, 0.5);
}

/* ---------- 打开状态 ---------- */
body.open .cover {
  opacity: 0;
  transform: scale(1.14);
  visibility: hidden;
  pointer-events: none;
}

body.open .inner {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  background-image: url("../assets/inner.jpg");
}

body.open .inner-card {
  animation: cardPop 0.85s cubic-bezier(0.22, 1.2, 0.36, 1) 0.25s both;
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(46px) scale(0.82); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

body.replay .cover {
  opacity: 1;
  transform: none;
  visibility: visible;
  pointer-events: auto;
}

body.replay .inner {
  opacity: 0;
  transform: translateY(46px) scale(0.96);
  visibility: hidden;
  pointer-events: none;
}

/* ---------- 彩带 ---------- */
.confetti-piece {
  position: fixed;
  top: -4vh;
  z-index: 9;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiFall var(--fd, 3s) ease-in var(--fdl, 0s) forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(118vh) rotate(var(--fr, 620deg)); opacity: 0.25; }
}
