/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0f1e; /* 深夜蓝黑,作为 Canvas 渲染前的兜底 */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #fff;
  user-select: none;
}

/* 电脑端隐藏默认光标 */
@media (hover: hover) and (pointer: fine) {
  html, body {
    cursor: none;
  }
}

/* ========== Canvas 画布 ========== */
#stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ========== UI 层通用 ========== */
.ui-layer {
  position: fixed;
  inset: 0;
  pointer-events: none; /* UI 层默认不拦截点击,让 Canvas 接收 */
  z-index: 10;
  transition: opacity 1.5s ease;
}

.ui-layer.hidden {
  opacity: 0;
  pointer-events: none !important;
}

.ui-layer.fade-out {
  opacity: 0;
}

/* ========== 场景 1:进度条 ========== */
.progress-wrap {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 70vw);
  text-align: center;
}

.progress-label {
  font-size: 13px;
  letter-spacing: 4px;
  color: rgba(220, 230, 255, 0.75);
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(180, 200, 255, 0.4);
}

.progress-track {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: visible;
}

.progress-fill {
  position: absolute;
  top: -0.5px;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(
    90deg,
    rgba(180, 210, 255, 0.8),
    rgba(255, 240, 220, 0.95)
  );
  box-shadow:
    0 0 8px rgba(200, 220, 255, 0.7),
    0 0 20px rgba(255, 230, 200, 0.4);
  transition: width 0.4s ease-out;
  border-radius: 2px;
}

/* ========== 场景 2:信纸 ========== */
.letter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) perspective(800px) rotateY(-8deg) rotateX(4deg) scale(0.6);
  opacity: 0;
  padding: 40px 60px;
  min-width: 260px;

  /* 液态玻璃质感 */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 240, 220, 0.12) 100%
  );
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.35),
    0 0 80px rgba(255, 200, 150, 0.25);

  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.letter.show {
  opacity: 1;
  transform: translate(-50%, -50%) perspective(800px) rotateY(-8deg) rotateX(4deg) scale(1);
}

.letter-inner {
  text-align: center;
  font-family: "Ma Shan Zheng", "KaiTi", "STKaiti", serif;
  color: #fff8e8;
  text-shadow:
    0 0 20px rgba(255, 200, 140, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.4);
}

.letter-title {
  font-size: clamp(32px, 6vw, 56px);
  margin-bottom: 14px;
  letter-spacing: 4px;
}

.letter-date {
  font-size: clamp(18px, 3vw, 26px);
  letter-spacing: 2px;
  opacity: 0.9;
}

/* ========== 返回按钮 ========== */
.back-btn {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  border: none;
  color: rgba(255, 230, 200, 0.6);
  font-size: 13px;
  letter-spacing: 3px;
  cursor: pointer;
  padding: 10px 20px;
  pointer-events: auto;
  transition: color 0.3s, text-shadow 0.3s;
  font-family: inherit;
}

.back-btn:hover {
  color: rgba(255, 240, 210, 1);
  text-shadow: 0 0 12px rgba(255, 200, 150, 0.8);
}

/* 电脑端移除按钮默认光标 */
@media (hover: hover) and (pointer: fine) {
  .back-btn {
    cursor: none;
  }
}

/* ========== 自定义光标 ========== */
.custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
  transition: width 0.2s, height 0.2s;
  display: none; /* 默认隐藏,JS 在电脑端才显示 */
}

.custom-cursor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(200, 220, 255, 0.5) 40%,
    transparent 70%
  );
  border-radius: 50%;
}

.custom-cursor.hover {
  width: 50px;
  height: 50px;
}

@media (hover: hover) and (pointer: fine) {
  .custom-cursor {
    display: block;
  }
}

/* ========== 场景 1 UI 的淡入淡出 ========== */
#scene1-ui {
  transition: opacity 1s ease;
}

#scene1-ui.fade-out {
  opacity: 0;
}
