/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1220;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.stage {
  position: absolute;
  /* 略大于视口，为视差留出余量 */
  inset: -3vmax;
  width: calc(100% + 6vmax);
  height: calc(100% + 6vmax);
  will-change: transform;
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== 天空基底：白天绿林 / 夜晚蓝空，交叉淡入淡出 ===== */
.sky {
  position: absolute;
  inset: 0;
  transition: opacity 3.4s ease;
  will-change: opacity;
}

/* 白天：春芽 → 森林渐变 + 顶部一团暖光（komorebi） */
.sky-day {
  opacity: 1;
  background:
    radial-gradient(ellipse 78% 52% at 54% 12%, rgba(238,249,190,0.98) 0%, rgba(205,236,135,0.55) 30%, rgba(150,205,90,0) 62%),
    linear-gradient(to bottom,
      #d6ec84 0%,
      #aed95c 20%,
      #7cc24a 42%,
      #4e9c45 64%,
      #2f7a3c 84%,
      #1c5730 100%);
  animation: dayBreath 46s ease-in-out infinite;
}
@keyframes dayBreath {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.03) saturate(1.03); }
}

/* 夜晚：暮蓝/蓝调时刻，不太深，往地平线更浅更亮 */
.sky-night {
  opacity: 0;
  background: linear-gradient(
    to bottom,
    #1b3358 0%,
    #244472 32%,
    #315a8c 58%,
    #4472a1 80%,
    #5d8bb3 100%
  );
}
body.world-night .sky-day { opacity: 0; }
body.world-night .sky-night { opacity: 1; }

/* ===== 白天漏光光束（夜晚淡出） ===== */
.rays {
  position: absolute; inset: 0;
  overflow: hidden;
  mix-blend-mode: screen;
  transition: opacity 3.4s ease;
}
.ray {
  position: absolute; top: -30%; left: var(--x);
  width: var(--w, 16vmax); height: 150%;
  background: linear-gradient(to bottom, rgba(255,253,215,0.5), rgba(240,248,180,0.06) 68%, transparent);
  transform: rotate(15deg); transform-origin: top center;
  filter: blur(13px);
  animation: rayPulse var(--d, 16s) ease-in-out infinite;
  animation-delay: var(--dl, 0s);
}
@keyframes rayPulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.5; } }
body.world-night .rays { opacity: 0; }

/* ===== 夜晚星空层（星星+月亮，夜晚淡入；位于树后） ===== */
.night-sky {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 3.4s ease;
}
body.world-night .night-sky { opacity: 1; }

/* ===== 夜晚月亮：夜晚主角，较大、柔和 ===== */
.moon {
  position: absolute;
  top: 15%;
  left: 26%;
  width: 16vmax;
  height: 16vmax;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #fdf6dc 0%, #f6ecc2 52%, #ecdca0 100%);
  box-shadow: 0 0 6vmax 1.2vmax rgba(246,236,190,0.28);
}

.moon-glow {
  position: absolute;
  top: 15%;
  left: 26%;
  width: 16vmax;
  height: 16vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246,235,185,0.28) 0%, rgba(246,235,185,0) 68%);
  transform: translate(-16vmax, -16vmax) scale(3);
  transform-origin: center;
  pointer-events: none;
}

/* 手机竖屏：月亮占据更大篇幅 */
@media (orientation: portrait) {
  .moon      { width: 46vw; height: 46vw; top: 12%; left: 50%; margin-left: -23vw; }
  .moon-glow { width: 46vw; height: 46vw; top: 12%; left: 50%; margin-left: -23vw;
               transform: translate(-23vw, -23vw) scale(3); }
}

/* ===== 夜晚静态星星（少量、极淡呼吸） ===== */
.stars-static { position: absolute; inset: 0; }
.stars-static .star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fdfdf5;
  opacity: 0.7;
  animation: starTwinkle var(--dur, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.85; }
}

/* ===== 夜晚雾气：柔和蓝调雾带，缓慢横向漂移 ===== */
.night-fog { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fog {
  position: absolute;
  left: -30%;
  width: 160%;
  border-radius: 50%;
  background: radial-gradient(ellipse 60% 70% at 50% 50%, rgba(150,185,220,0.5) 0%, rgba(150,185,220,0) 72%);
  filter: blur(6px);
  will-change: transform;
}
/* 雾气集中在中下部，营造地平线附近的空气层次 */
.fog-1 { bottom: 6%;  height: 30vmax; opacity: 0.55; animation: fogDrift1 90s linear infinite; }
.fog-2 { bottom: 22%; height: 24vmax; opacity: 0.4;  animation: fogDrift2 120s linear infinite; }
.fog-3 { bottom: -4%; height: 26vmax; opacity: 0.6;  animation: fogDrift1 150s linear infinite; }

@keyframes fogDrift1 {
  from { transform: translateX(-8%); }
  to   { transform: translateX(8%); }
}
@keyframes fogDrift2 {
  from { transform: translateX(7%); }
  to   { transform: translateX(-7%); }
}

/* ===== 森林：简化树形，分远近两层，深色近树呼吸更明显 ===== */
.forest {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  /* 白天有树 / 夜晚淡出（夜晚以月亮星空为主，没有树） */
  transition: opacity 3.4s ease;
}
.forest-far { filter: blur(2px); }
body.world-night .forest { opacity: 0; }

.tree {
  position: absolute;
  bottom: var(--b, 0%);
  left: var(--x, 50%);
  width: var(--w, 20vmax);
  transform: translateX(-50%);
  transform-origin: bottom center;
  will-change: transform;
  animation: sway var(--d, 10s) ease-in-out infinite;
  animation-delay: var(--dl, 0s);
}
.tree svg { width: 100%; height: auto; display: block; }
@keyframes sway {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(0deg); }
  50%      { transform: translateX(-50%) scale(var(--s, 1.03)) rotate(var(--r, 0.6deg)); }
}

/* ===== 流萤画布（白天互动） ===== */
.fireflies {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* ===== 漏光斑（白天，夜晚淡出） ===== */
.glints {
  position: absolute; inset: 0;
  mix-blend-mode: screen;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 3.4s ease;
}
.glint {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(250,252,205,0.95) 0%, rgba(220,240,150,0.4) 45%, transparent 72%);
  filter: blur(2px);
  animation: glintPulse var(--gd, 9s) ease-in-out infinite;
  animation-delay: var(--gdl, 0s);
}
@keyframes glintPulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 0.9; transform: scale(1.1); } }
body.world-night .glints { opacity: 0; }

/* ===== 动态元素层（互动星） ===== */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* 互动星：点击夜空缓慢亮起、停留、消退（暖白、发光更明显） */
.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffdf2 0%, #fdf4d6 60%, rgba(253,244,214,0) 100%);
  box-shadow: 0 0 14px 3px rgba(255,248,220,0.9), 0 0 28px 6px rgba(255,244,200,0.4);
  opacity: 0;
  transform: scale(0.4);
  will-change: opacity, transform;
}

/* 点击夜空的一圈柔和涟漪，缓慢扩散消失 */
.ripple {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 1px solid rgba(230,240,255,0.5);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

/* ===== 极淡噪点纹理 ===== */
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== 首次进入的轻提示 ===== */
.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12%;
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  letter-spacing: 0.15em;
  font-weight: 300;
  opacity: 0;
  transition: opacity 1.6s ease;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0,0,0,0.25);
}
.hint.show { opacity: 1; }
body.world-day .hint { color: rgba(30, 62, 34, 0.8); text-shadow: 0 1px 8px rgba(230,246,180,0.4); }

/* ===== 角落声音开关 ===== */
.sound-toggle {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  right: max(18px, env(safe-area-inset-t));
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  z-index: 10;
  transition: color 0.4s ease, background 0.4s ease, opacity 0.6s ease;
  opacity: 0.55;
}
.sound-toggle:hover { opacity: 0.9; }
body.world-day .sound-toggle { color: rgba(28, 60, 34, 0.65); background: rgba(255,255,255,0.22); }

.sound-toggle .icon-sound { display: none; }
.sound-toggle.on .icon-sound { display: block; }
.sound-toggle.on .icon-muted { display: none; }

