/* 《如果老物件会说话》H5 样式 */
:root {
  --red: #8B0000;
  --black: #1A1A1A;
  --paper: #F5F0E8;
  --gold: #C9A96E;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--black);
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
  color: var(--paper);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%; height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.4s ease;
  transform: scale(0.98);
  overflow: hidden;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  z-index: 10;
}

.scene-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: transform;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(26,26,26,0.35) 0%,
    rgba(26,26,26,0.05) 30%,
    rgba(26,26,26,0.1) 70%,
    rgba(26,26,26,0.55) 100%);
  pointer-events: none;
}

.scene-overlay.dark {
  background: rgba(26,26,26,0.45);
}

.scene-overlay.cover-overlay {
  background: linear-gradient(180deg,
    rgba(26,26,26,0.5) 0%,
    rgba(26,26,26,0.15) 40%,
    rgba(26,26,26,0.6) 100%);
}

.scene-content {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(48px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
}

/* 加载 */
#loader {
  z-index: 100;
  background: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-inner { text-align: center; width: 70%; }

.loader-title {
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--paper);
  margin-bottom: 24px;
}

.loader-bar {
  height: 3px;
  background: rgba(245,240,232,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.loader-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.3s;
}

.loader-tip {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(245,240,232,0.5);
  letter-spacing: 2px;
}

/* 封面 */
#screen-cover .scene-content {
  align-items: center;
  justify-content: space-between;
}

.title-main {
  font-size: 28px;
  font-weight: normal;
  letter-spacing: 6px;
  text-align: center;
  color: var(--paper);
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  margin-top: 8vh;
}

.title-sub {
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--gold);
  text-align: center;
  margin-top: 12px;
}

.btn-start, .btn-action {
  position: relative;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 10vh;
  animation: breathe 3s ease-in-out infinite;
}

.btn-start .btn-bg, .btn-action .btn-bg {
  display: block;
  width: 200px;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(201, 169, 110, 0.8)) drop-shadow(0 0 4px #C9A96E);
}

.btn-start span, .btn-action span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--paper);
  font-family: inherit;
}

.btn-action span {
  color: var(--black);
}

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

/* 旁白 */
.narration {
  font-size: 15px;
  line-height: 2;
  letter-spacing: 1px;
  color: var(--paper);
  text-shadow: 0 1px 8px rgba(0,0,0,0.8);
  min-height: 3em;
  margin-top: auto;
  padding: 16px;
  background: rgba(26,26,26,0.35);
  border-left: 2px solid var(--gold);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.chapter-tag {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.tap-hint, .wipe-hint, .collect-hint {
  text-align: center;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 2px;
  animation: pulse 2s ease-in-out infinite;
  margin: 12px 0;
}

.hidden { display: none !important; }

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* 序章视差 */
.parallax-zoom {
  animation: pushIn 10s ease-out forwards;
}

@keyframes pushIn {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

/* 擦除 */
.wipe-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  touch-action: none;
}

.ch1-ui { pointer-events: none; }
.ch1-ui .narration, .chapter-tag, .wipe-hint, .wipe-progress { pointer-events: none; }

.wipe-progress {
  height: 3px;
  background: rgba(245,240,232,0.15);
  border-radius: 2px;
  margin-top: 8px;
}

.wipe-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.2s;
}

.btn-continue {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border: 2px solid var(--gold);
  background: rgba(139, 0, 0, 0.75);
  color: var(--paper);
  font-size: 14px;
  letter-spacing: 2px;
  font-family: inherit;
  cursor: pointer;
  animation: pulse 2s ease-in-out infinite;
  pointer-events: auto;
  box-shadow: 0 0 10px rgba(201, 169, 110, 0.4), inset 0 0 6px rgba(201, 169, 110, 0.15);
}

.ch1-ui .btn-continue { pointer-events: auto; }

/* 蒙太奇 */
.montage-bg {
  transition: background-image 1s ease;
}

/* 雨 */
.rain-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.5;
  background-image: repeating-linear-gradient(
    105deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.06) 2px,
    rgba(255,255,255,0.06) 3px
  );
  animation: rainFall 0.6s linear infinite;
}

.rain-layer.clearing {
  animation: rainClear 2s ease forwards;
}

@keyframes rainFall {
  from { background-position: 0 0; }
  to { background-position: -20px 40px; }
}

@keyframes rainClear {
  to { opacity: 0; }
}

/* 修补光点 */
.repair-spots {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.repair-spot {
  position: absolute;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  cursor: pointer;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,169,110,0.9) 0%, rgba(201,169,110,0) 70%);
  animation: spotPulse 1s ease-in-out infinite;
  border: none;
  padding: 0;
}

.repair-spot::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold);
}

.repair-spot.repaired {
  animation: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

.repair-particle {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: particleBurst 0.6s ease forwards;
}

@keyframes spotPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

@keyframes particleBurst {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* 远景房屋金色呼吸光斑引导 */
.glimmer-guide {
  position: absolute;
  left: 42%;
  top: 16%;
  width: 100px;
  height: 70px;
  z-index: 4;
  pointer-events: none;
}

.glimmer-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(201, 169, 110, 0.6), 0 0 12px rgba(201, 169, 110, 0.2);
  animation: glimmer 3.6s ease-in-out infinite;
}

.glimmer-dot:nth-child(1) { top: 25%; left: 35%; animation-delay: 0s; }
.glimmer-dot:nth-child(2) { top: 55%; left: 65%; animation-delay: 0.7s; }
.glimmer-dot:nth-child(3) { top: 35%; left: 50%; animation-delay: 1.4s; }
.glimmer-dot:nth-child(4) { top: 65%; left: 30%; animation-delay: 2.1s; }
.glimmer-dot:nth-child(5) { top: 20%; left: 60%; animation-delay: 2.8s; }

@keyframes glimmer {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 0.65; transform: scale(1.15); }
}

.ch2-ui { pointer-events: none; }

/* 收集 */
.petals-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
}

.petal-item {
  position: absolute;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: none;
  filter: drop-shadow(0 0 6px rgba(201,169,110,0.5));
}

.petal-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.memory-bottle {
  position: absolute;
  right: 16px;
  bottom: calc(100px + var(--safe-bottom));
  width: 60px;
  z-index: 4;
  transition: filter 0.5s;
}

.memory-bottle.glow {
  filter: drop-shadow(0 0 20px var(--gold));
}

.collect-progress {
  margin-top: auto;
  text-align: center;
}

.progress-deco {
  width: 100%;
  max-width: 280px;
  opacity: 0.7;
  margin-bottom: 8px;
}

.collect-bar {
  height: 4px;
  background: rgba(245,240,232,0.15);
  border-radius: 2px;
  max-width: 280px;
  margin: 0 auto;
}

.collect-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  border-radius: 2px;
  transition: width 0.3s;
}

.collect-count {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
}

.ch3-ui { pointer-events: none; }
.ch3-ui .collect-hint { pointer-events: none; }
.petals-layer, .petal-item { pointer-events: auto; }

/* 记忆爆发 */
.burst-zoom {
  animation: burstIn 3s ease forwards;
}

@keyframes burstIn {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.15); opacity: 1; }
}

/* 第四章 */
.ch4-bg {
  transition: background-image 1.2s ease, filter 1.2s ease;
}

.ending-quote {
  font-size: 22px;
  line-height: 1.8;
  text-align: center;
  letter-spacing: 3px;
  color: var(--paper);
  text-shadow: 0 2px 16px rgba(0,0,0,0.8);
  margin: auto 0;
  padding: 24px;
  animation: fadeUp 1.5s ease;
}

.ending-sign {
  text-align: center;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 40px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.gold-particles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.gold-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.6;
  animation: goldFall linear infinite;
}

@keyframes goldFall {
  from { transform: translateY(-10px); opacity: 0; }
  10% { opacity: 0.6; }
  to { transform: translateY(100vh); opacity: 0; }
}

/* 海报 */
#screen-poster .poster-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
  background: var(--black);
}

.poster-card {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 9/16;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.poster-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.poster-umbrella {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  border-radius: 50%;
  object-fit: cover;
}

.poster-quote {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  text-align: center;
  font-size: 16px;
  line-height: 2;
  color: var(--black);
  letter-spacing: 1px;
}

.poster-rank {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--red);
  letter-spacing: 2px;
  white-space: nowrap;
}

.poster-actions {
  display: flex;
  gap: 16px;
  margin-top: 20px;
}

.btn-action .btn-bg { width: 140px; }
.btn-action span { font-size: 15px; letter-spacing: 2px; }

.btn-replay {
  margin-top: 16px;
  background: none;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 8px 24px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 8px rgba(201, 169, 110, 0.3);
}

/* 全局进度 */
.global-progress {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 16px;
  z-index: 50;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 1px;
  background: rgba(26,26,26,0.5);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

/* 音乐开关 */
.music-toggle {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 16px;
  z-index: 80;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(201, 169, 110, 0.4);
  border-radius: 50%;
  background: rgba(26,26,26,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--gold);
  transition: all 0.3s;
}

.music-toggle:active {
  transform: scale(0.9);
}

.music-icon {
  display: block;
  line-height: 1;
}

.music-toggle.muted .music-icon {
  opacity: 0.35;
}

/* 转场 */
.transition-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--black);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.transition-mask.show {
  opacity: 1;
  pointer-events: auto;
}

.transition-mask.flash {
  background: var(--paper);
  transition: opacity 0.2s ease;
}
