/* ============================================================
   WAKEUP · 全局样式
   双阶段：糖果(答题) → 黑暗(梦境/收尾)
   ============================================================ */

:root {
  --pink:   #ffb7d5;
  --purple: #c8b7ff;
  --yellow: #ffe08a;
  --cyan:   #aee8ff;
  --ink-1:  #1a1a1a;
  --ink-2:  #444;
  --ink-3:  #888;
  --red:    #d32f2f;
  --red-h:  #ff3a3a;
  --paper:  #fff7fb;
  --line:   rgba(0,0,0,.08);
  --mono:   'IBM Plex Mono', 'JetBrains Mono', 'Courier New', monospace;
  --serif:  'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --candy:  'Nunito', 'ZCOOL KuaiLe', 'PingFang SC', sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  overflow-x: hidden;
  font-family: var(--candy);
}
body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #fff4fa 0%, #f6e8ff 50%, #e8f3ff 100%);
  color: var(--ink-1);
  transition: background .6s ease;
}
body[data-phase="dark"] { background: #050505; color: #fff; }
body[data-phase="dream"] { background: #000; color: #fff; overflow: hidden; }
body[data-phase="outro"] { background: #0a0a0a; color: #fff; }

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ============================================================
   屏切换
   ============================================================ */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}
.screen.active { display: block; }

.screen--quiz {
  position: relative;
  padding: 56px 22px 80px;
  max-width: 540px;
  margin: 0 auto;
  z-index: 5;
}
.screen--dream {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 8;
}
.screen--outro {
  position: relative;
  padding: 50px 24px 80px;
  max-width: 600px;
  margin: 0 auto;
  z-index: 5;
}

/* ============================================================
   糖果背景装饰 (浮点 + 星)
   ============================================================ */
.candy-decor {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  transition: opacity .8s ease, filter .8s ease;
}
body[data-phase="dark"] .candy-decor,
body[data-phase="dream"] .candy-decor,
body[data-phase="outro"] .candy-decor {
  opacity: 0; filter: blur(12px) grayscale(1);
}
.candy-dot { position:absolute; border-radius:50%; filter:blur(28px); opacity:.55; animation: float 9s ease-in-out infinite; }
.candy-dot.d1 { width: 240px; height: 240px; background: var(--pink);   top: -40px;  left: -60px; }
.candy-dot.d2 { width: 200px; height: 200px; background: var(--purple); top: 28%;   right: -50px; animation-delay: -2s; }
.candy-dot.d3 { width: 180px; height: 180px; background: var(--yellow); bottom: 18%; left: -40px; animation-delay: -4s; }
.candy-dot.d4 { width: 160px; height: 160px; background: var(--cyan);   top: 60%;   left: 30%;  animation-delay: -1s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(18px,-12px) scale(1.08); }
}
.candy-star { position: absolute; font-size: 22px; color: #ffc6dd; animation: twinkle 2.4s ease-in-out infinite; text-shadow: 0 0 14px rgba(255,182,213,.7); }
.candy-star.s2 { top: 22%; right: 18%; animation-delay: -0.8s; color: var(--purple); }
.candy-star.s3 { bottom: 24%; left: 16%; animation-delay: -1.2s; color: var(--yellow); }
.candy-star:not(.s2):not(.s3) { top: 14%; left: 12%; }
@keyframes twinkle {
  0%,100% { opacity: .3; transform: scale(.8) rotate(0deg); }
  50%     { opacity: 1;  transform: scale(1.2) rotate(20deg); }
}

/* ============================================================
   答题 · INTRO 屏
   ============================================================ */
.quiz-intro { position: relative; z-index: 4; }
.intro-badge {
  display: inline-flex; gap: 8px; align-items: center;
  padding: 8px 18px;
  background: #fff;
  border: 2px solid var(--pink);
  border-radius: 999px;
  color: #d84098;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 24px;
  box-shadow: 0 4px 14px rgba(255,183,213,.35);
}
.intro-title {
  margin: 0 0 24px;
  font-family: var(--candy);
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.intro-title-row { display: block; color: #2a1a2a; }
.intro-title-row--accent {
  background: linear-gradient(95deg, #ffb7d5 0%, #ffc870 50%, #c8b7ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.intro-card {
  background: rgba(255,255,255,.78);
  border: 1.5px solid rgba(216,64,152,.18);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 24px 0;
  box-shadow: 0 10px 30px rgba(216,64,152,.08);
}
.intro-line {
  margin: 0 0 8px;
  font-size: 15px;
  color: #4a3848;
  line-height: 1.7;
}
.intro-line strong { color: #d84098; font-weight: 700; }
.intro-line--sub { margin: 0; font-size: 13.5px; color: #7a6a7a; }
.intro-tags {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 18px 0 26px;
}
.tag {
  padding: 5px 12px;
  background: rgba(255,255,255,.85);
  border-radius: 999px;
  font-size: 12.5px;
  color: #b04886;
  border: 1px solid rgba(255,183,213,.45);
}
.tag:nth-child(2) { color: #b88820; border-color: rgba(255,200,80,.5); }
.tag:nth-child(3) { color: #6850b0; border-color: rgba(200,183,255,.5); }
.tag:nth-child(4) { color: #2080a0; border-color: rgba(174,232,255,.5); }

.cta-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 18px 26px;
  border: none;
  border-radius: 16px;
  font-family: var(--candy);
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(95deg, #ff8eb8 0%, #d84098 50%, #b04886 100%);
  box-shadow: 0 12px 28px rgba(216,64,152,.36), inset 0 -3px 0 rgba(0,0,0,.08);
  letter-spacing: .04em;
  transition: transform .12s ease, box-shadow .12s ease;
}
.cta-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(216,64,152,.42), inset 0 -3px 0 rgba(0,0,0,.08); }
.cta-primary:active { transform: translateY(1px); }

/* ============================================================
   答题 · 进度条 + 题目
   ============================================================ */
.progress-wrap {
  position: relative; z-index: 4;
  margin: 0 0 18px;
  opacity: 0;
  transition: opacity .4s ease;
}
.progress-wrap.visible { opacity: 1; }
.progress-bar { height: 6px; background: rgba(255,183,213,.3); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ffb7d5 0%, #d84098 100%);
  transition: width .35s cubic-bezier(.4,0,.2,1);
}
.progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #b06090;
  letter-spacing: .1em;
}

.quiz-body { position: relative; z-index: 4; }
.q-label {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11.5px;
  color: #b06090; letter-spacing: .14em; text-transform: uppercase;
  margin-bottom: 14px;
}
.q-label .cat {
  padding: 2px 9px;
  background: rgba(255,183,213,.25);
  border-radius: 99px;
  color: #b04080;
}
.q-text {
  font-size: 22px; font-weight: 700;
  color: #2a1a2a;
  margin: 6px 0 10px;
  line-height: 1.4;
}
.q-sub { font-size: 13px; color: #7a6a7a; margin: 0 0 22px; }
.q-options { display: flex; flex-direction: column; gap: 12px; }
.q-option {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid rgba(216,64,152,.16);
  border-radius: 14px;
  font-family: inherit;
  font-size: 15.5px;
  color: #2a1a2a;
  text-align: left;
  transition: all .15s ease;
  font-weight: 600;
  letter-spacing: .01em;
}
.q-option .marker {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2px solid rgba(216,64,152,.45);
  border-radius: 50%;
  flex-shrink: 0;
}
.q-option:hover { border-color: #d84098; transform: translateX(3px); }
.q-option.selected {
  background: linear-gradient(95deg, #fff0f8 0%, #f0e8ff 100%);
  border-color: #d84098;
}
.q-option.selected .marker { background: #d84098; box-shadow: inset 0 0 0 4px #fff; }

/* ============================================================
   崩塌转场
   ============================================================ */
.crash-overlay {
  position: fixed; inset: 0;
  background: #000;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s linear;
}
.crash-overlay.active { opacity: 1; pointer-events: auto; }
#crashCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.crash-text {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: clamp(14px, 4vw, 22px);
  color: #ff3a3a;
  letter-spacing: .2em;
  text-shadow: 0 0 20px rgba(255,58,58,.6);
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .5s ease;
  z-index: 2;
  white-space: pre-line;
}
.crash-overlay.active .crash-text { opacity: 1; }

/* ============================================================
   梦境屏
   ============================================================ */
#dreamCanvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: #000;
  cursor: grab;
  touch-action: none;
}
#dreamCanvas:active { cursor: grabbing; }

/* 新手引导 (进梦境时短暂提示) */
.dream-tutorial {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 14;
  padding: 16px 26px;
  background: rgba(0,0,0,.7);
  border: 1px solid rgba(255,58,58,.5);
  backdrop-filter: blur(6px);
  font-family: var(--mono);
  color: #ffe0e0;
  font-size: 13px;
  letter-spacing: .14em;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
  text-transform: uppercase;
}
.dream-tutorial.visible { opacity: 1; }
.dream-tutorial .dt-line1 { font-size: 11px; color: #ff7575; margin-bottom: 6px; letter-spacing: .22em; }
.dream-tutorial .dt-line2 { font-size: 14px; }
.dream-tutorial .dt-line3 { font-size: 11px; color: #888; margin-top: 6px; letter-spacing: .18em; }

/* 场景加载 loading */
.dream-loading {
  position: fixed; inset: 0;
  background: #050505;
  z-index: 15;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  transition: opacity .8s ease;
}
.dream-loading.hidden { opacity: 0; pointer-events: none; }
.dl-spin {
  width: 38px; height: 38px;
  border: 3px solid rgba(211,47,47,0.2);
  border-top-color: #d32f2f;
  border-radius: 50%;
  animation: dlSpin 1.1s linear infinite;
}
@keyframes dlSpin { to { transform: rotate(360deg); } }
.dl-text {
  font-family: var(--serif);
  color: #c0c0c4;
  font-size: 16px;
  letter-spacing: .04em;
}
.dl-sub {
  font-family: var(--mono);
  color: #6a4040;
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
}

/* 点击式 hotspots (旧 DOM layer 隐藏 · 现在用 3D 发光球) */
.dream-hotspots {
  display: none !important;
}
.dream-hotspots-old {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9;
}
.hotspot {
  position: absolute;
  pointer-events: auto;
  width: 56px; height: 56px;
  border: 2px solid rgba(255,255,255,.42);
  border-radius: 50%;
  background: rgba(255,58,58,.18);
  cursor: pointer;
  transform: translate(-50%, -50%);
  animation: hsPulse 2.4s ease-in-out infinite;
  backdrop-filter: blur(2px);
}
.hotspot::after {
  content: '+';
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  color: rgba(255,255,255,.85);
  font-size: 26px;
  font-family: var(--mono);
  font-weight: 300;
}
.hotspot.read { background: rgba(0,0,0,.4); border-color: rgba(255,255,255,.18); animation: none; }
.hotspot.read::after { content: '✓'; font-size: 18px; }
@keyframes hsPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,58,58,.55), 0 0 26px rgba(255,58,58,.4); }
  50%     { box-shadow: 0 0 0 12px rgba(255,58,58,0),  0 0 14px rgba(255,58,58,.2); }
}

/* HUD */
.dream-hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
  font-family: var(--mono);
  color: #ff7575;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255,58,58,.4);
}
.hud-cell {
  position: absolute;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(211,47,47,.4);
  padding: 6px 12px 5px;
  backdrop-filter: blur(4px);
  display: flex; flex-direction: column;
  gap: 2px;
}
.hud-cell .k { font-size: 9.5px; opacity: .65; }
.hud-cell .v { font-size: 13px; font-weight: 700; color: #ff3a3a; }
.hud-cell--left   { top: 16px; left: 16px; }
.hud-cell--right  { top: 16px; right: 16px; text-align: right; }
.hud-cell--code   { bottom: 16px; left: 16px; }
.hud-cell--signal { bottom: 16px; right: 16px; text-align: right; }
.signal-bars { letter-spacing: .1em; }

/* 旁白浮层 */
.dream-narration {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  max-width: min(92vw, 580px);
  padding: 14px 22px;
  background: rgba(0,0,0,.7);
  border-left: 3px solid #d32f2f;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.7;
  color: #f0d0d0;
  text-align: center;
  opacity: 0;
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
  z-index: 11;
  white-space: pre-line;
  backdrop-filter: blur(6px);
}
.dream-narration.visible {
  opacity: 1; transform: translateX(-50%) translateY(-6px);
}

/* trigger warning */
.trigger-warning {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.trigger-warning[hidden] { display: none !important; }
.tw-card {
  max-width: 460px;
  background: #0c0c0c;
  border: 1px solid rgba(211,47,47,.4);
  border-top: 3px solid #d32f2f;
  padding: 28px 24px 22px;
  color: #ddd;
}
.tw-label { font-family: var(--mono); font-size: 11px; color: #d32f2f; letter-spacing: .25em; margin-bottom: 12px; }
.tw-title { font-family: var(--serif); font-size: 22px; margin: 0 0 14px; color: #fff; }
.tw-body  { font-family: var(--serif); font-size: 14.5px; line-height: 1.8; color: #c0b8b8; margin: 0 0 14px; }
.tw-source { font-family: var(--mono); font-size: 10.5px; color: #888; letter-spacing: .12em; margin: 0 0 22px; }
.tw-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.tw-btn {
  flex: 1; min-width: 140px;
  padding: 12px 18px;
  font-family: var(--mono); font-size: 13.5px; letter-spacing: .1em;
  border: 1px solid rgba(211,47,47,.5);
  background: transparent;
  color: #fff;
  transition: background .15s ease;
}
.tw-btn-go { background: #d32f2f; border-color: #d32f2f; }
.tw-btn-go:hover { background: #ff3a3a; }
.tw-btn-skip:hover { background: rgba(211,47,47,.18); }

/* 模式切换/音量按钮 */
.mode-toggle, .audio-toggle, .global-audio {
  position: fixed;
  z-index: 25;
  padding: 8px 12px;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.18);
  color: #eee;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .12em;
  border-radius: 4px;
  backdrop-filter: blur(6px);
  transition: background .15s ease;
}
.mode-toggle { right: 16px; top: 60px; }
.audio-toggle, .global-audio {
  bottom: 16px; right: 16px;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.global-audio { z-index: 200; }
@media (max-width: 640px) {
  .mode-toggle { display: none; }
}

/* ============================================================
   收尾屏
   ============================================================ */
.outro-wrap { text-align: center; padding-top: 60px; }
.outro-line {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 7vw, 40px);
  margin: 0 0 18px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s ease;
  letter-spacing: .04em;
}
.outro-line.visible { opacity: 1; transform: translateY(0); }
.outro-line-1 { color: #c0c0c4; }
.outro-line-2 { color: #fff; }
.outro-line-3 {
  color: #ff3a3a;
  text-shadow: 0 0 16px rgba(255,58,58,.4);
  animation: outroShake 4s ease-in-out infinite;
  animation-delay: 1.5s;
}
@keyframes outroShake {
  0%,100% { transform: translateX(0); }
  50%     { transform: translateX(.5px); }
}

.outro-stats {
  margin: 38px auto 28px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.95;
  color: #aaa;
  opacity: 0;
  transition: opacity 1s ease;
}
.outro-stats.visible { opacity: 1; }
.outro-stats strong {
  font-family: var(--mono);
  color: #ff3a3a;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}

.outro-card-wrap {
  margin: 30px auto;
  max-width: 320px;
  border: 1px solid #2a1010;
  padding: 8px;
  background: #0a0a0a;
  opacity: 0;
  transition: opacity 1s ease;
}
.outro-card-wrap.visible { opacity: 1; }
#posterCanvas {
  width: 100%; height: auto; display: block;
  background: #050505;
}

.outro-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center;
  margin: 20px 0 30px;
  opacity: 0;
  transition: opacity 1s ease;
}
.outro-actions.visible { opacity: 1; }
.outro-btn {
  min-width: 130px;
  padding: 12px 18px;
  font-family: var(--mono); font-size: 13px; letter-spacing: .12em;
  border: 1px solid rgba(255,255,255,.3);
  background: transparent; color: #fff;
  transition: background .15s ease;
}
.outro-btn-primary { background: #d32f2f; border-color: #d32f2f; }
.outro-btn-primary:hover { background: #ff3a3a; }
.outro-btn:hover { background: rgba(255,255,255,.06); }

.outro-divider {
  width: 60%;
  height: 1px;
  background: rgba(255,255,255,.15);
  margin: 30px auto;
}
.outro-footer {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #666;
  letter-spacing: .12em;
  line-height: 1.95;
}
.outro-link { color: #ff7575; text-decoration: none; font-weight: 600; display: block; margin: 4px 0; }
.outro-meta { margin: 6px 0; }

/* ============================================================
   reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .candy-dot, .candy-star, .hotspot, .outro-line-3 { animation: none; }
}
