/* 《潜梦之境》序章试玩 */
:root {
  --bg: #100e0c;
  --elevated: #1c1814;
  --text: #f4efe6;
  --secondary: rgba(244, 239, 230, 0.74);
  --tertiary: rgba(244, 239, 230, 0.5);
  --accent: #e0c37a;
  --danger: #d06050;
  --primary: #e8d5a3;
  --on-primary: #1a140c;
  --border: rgba(255, 255, 255, 0.18);
  --radius: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; }
button { font-family: inherit; }
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.howto h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: 0.06em; margin: 0 0 8px; }
.howto p { margin: 0 0 8px; line-height: 1.7; color: var(--secondary); font-size: 0.92rem; }
.howto .note { font-size: 0.82rem; color: var(--tertiary); }
.stage {
  position: relative;
  margin-top: 14px;
  height: min(720px, calc(100dvh - 180px));
  min-height: 520px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0b0908;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  touch-action: manipulation;
}
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fade { transition: opacity 0.7s ease; }
.layer.ken { animation: qmKen 16s ease-in-out alternate infinite; transform-origin: 50% 45%; will-change: transform; }
.fade.out { opacity: 0; }
.scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.62) 0%, rgba(0,0,0,.14) 42%, rgba(0,0,0,.22) 100%);
}
.dream-fog, .fx-ripples, .fx-flash { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fog-a, .fog-b { position: absolute; border-radius: 50%; filter: blur(28px); }
.fog-a { left: -8%; bottom: -8%; width: 70%; height: 180px; background: rgba(255,220,150,.18); animation: qmFog 10s ease-in-out infinite; }
.fog-b { right: -10%; top: 10%; width: 50%; height: 160px; background: rgba(40,30,20,.28); filter: blur(32px); animation: qmFog 13s ease-in-out infinite reverse; }
.spark {
  position: absolute; width: 5px; height: 5px; border-radius: 99px;
  background: rgba(255,236,190,.85); animation: qmFloat 8s linear infinite;
}
.portrait {
  position: absolute; bottom: -8px; height: 96%; width: auto; max-width: 46%;
  object-fit: contain; object-position: bottom; pointer-events: none;
  animation: qmSpriteIn .55s ease;
  -webkit-mask-image: radial-gradient(ellipse at 50% 38%, black 46%, transparent 76%);
  mask-image: radial-gradient(ellipse at 50% 38%, black 46%, transparent 76%);
}
.portrait.left { left: 2%; }
.portrait.right { right: 2%; opacity: 0.72; filter: saturate(0.85) brightness(1.05); }
.hud {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 14px 0;
}
.badge {
  font-size: 12px; letter-spacing: 0.08em; color: #fff; padding: 4px 10px; border-radius: 99px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.2); white-space: nowrap;
}
.spirit { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #fff; }
.spirit-track { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; min-width: 64px; }
.spirit-fill { height: 100%; border-radius: 99px; background: var(--accent); }
.spirit-fill.low { background: var(--danger); }
.art { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.art-body { position: relative; z-index: 2; flex: 1; min-height: 0; }
.dialog {
  padding: 14px 18px 16px; background: var(--elevated); border-top: 1px solid var(--border);
  z-index: 3; min-height: 150px; cursor: pointer;
}
.dialog.locked { cursor: default; }
.speaker {
  display: inline-block; font-size: 13px; color: var(--accent); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px 10px; margin-bottom: 8px; background: var(--bg);
}
.narration { font-size: 12px; color: var(--tertiary); margin-bottom: 8px; }
.line { margin: 0; line-height: 1.75; font-size: 16px; min-height: 52px; }
.caret { opacity: 0.6; }
.hint { text-align: right; margin-top: 10px; font-size: 12px; color: var(--tertiary); }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice, .btn-glow {
  border: 1px solid var(--accent); background: var(--elevated); color: var(--text);
  border-radius: var(--radius); padding: 10px 12px; font-size: 14px; cursor: pointer;
  text-align: left; width: 100%; animation: qmGlow 2s ease-in-out infinite;
}
.choice .sub { font-size: 12px; color: var(--tertiary); margin-top: 2px; }
.btn-primary {
  border: none; background: var(--primary); color: var(--on-primary); border-radius: var(--radius);
  padding: 10px 22px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-quiet {
  border: 1px solid var(--border); background: var(--elevated); color: var(--text);
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; animation: none; }
.title { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; }
.title-copy { position: relative; z-index: 2; padding: 28px 24px 36px; text-align: center; }
.kicker { font-size: 13px; letter-spacing: 0.32em; color: var(--accent); }
.title-copy h2 { font-size: clamp(28px, 6vw, 38px); font-weight: 600; letter-spacing: 0.14em; color: #fff; margin: 8px 0 0; }
.sub { font-size: 16px; color: rgba(255,255,255,.8); margin-top: 6px; }
.blurb { max-width: 440px; margin: 12px auto 0; color: rgba(255,255,255,.78); line-height: 1.7; }
.title .btn-primary { margin-top: 18px; animation: qmGlow 2s ease-in-out infinite; color: var(--on-primary); }
.tiny { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 10px; }
.explore-panel, .challenge-panel { padding: 14px 18px 16px; background: var(--elevated); border-top: 1px solid var(--border); z-index: 3; }
.map { display: block; width: 100%; height: 100%; }
.map-hit { cursor: pointer; }
.challenge-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.challenge-wrap.shake { animation: qmShake .4s; }
.fx-flash { z-index: 12; }
.fx-flash.good { background: rgba(255,236,180,.7); animation: qmFlashGood .45s ease-out; }
.fx-flash.bad { background: rgba(120,20,20,.55); animation: qmFlashBad .45s ease-out; }
.meter-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 12px 24px 8px; gap: 12px; }
.meter-label { font-size: 13px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.meter {
  position: relative; width: 86%; max-width: 460px; height: 28px; border-radius: 99px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.3); overflow: hidden;
}
.zone { position: absolute; left: 36%; width: 28%; top: 0; bottom: 0; background: rgba(224,195,122,.55); }
.knob { position: absolute; top: 3px; bottom: 3px; width: 10px; border-radius: 99px; background: #fff; box-shadow: 0 0 10px #fff; }
.challenge-panel { text-align: center; }
.challenge-panel p { margin: 0 0 12px; color: var(--secondary); line-height: 1.7; }
.challenge-panel .btn-primary { animation: qmGlow 1.6s ease-in-out infinite; }
.end { flex: 1; position: relative; overflow: auto; }
.end-inner { position: relative; z-index: 2; padding: 28px; display: flex; flex-direction: column; gap: 14px; color: #fff; }
.end h2 { font-size: 26px; font-weight: 600; margin: 0; }
.end p { margin: 0; line-height: 1.8; color: rgba(255,255,255,.82); }
.summary {
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius); padding: 16px;
  background: rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.7;
}
.end .tiny { margin: 0; }
.ripple {
  position: absolute; left: 50%; top: 45%; width: 80px; height: 80px; margin: -40px;
  border-radius: 999px; pointer-events: none; z-index: 20; animation: qmRipple .95s ease-out forwards;
}
.ripple.late { animation: qmRipple 1.15s ease-out .12s forwards; opacity: 0.7; }
.ripple.dream { border: 3px solid var(--accent); }
.ripple.wake { border: 3px solid rgba(255,255,255,.55); }
@keyframes qmShake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-7px,3px); }
  40% { transform: translate(6px,-2px); }
  60% { transform: translate(-4px,-3px); }
  80% { transform: translate(5px,2px); }
}
@keyframes qmFlashGood { 0% { opacity: 0; } 25% { opacity: .55; } 100% { opacity: 0; } }
@keyframes qmFlashBad { 0% { opacity: 0; } 30% { opacity: .45; } 100% { opacity: 0; } }
@keyframes qmRipple { 0% { transform: scale(.15); opacity: .7; } 100% { transform: scale(22); opacity: 0; } }
@keyframes qmSpriteIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes qmFog { 0%,100% { transform: translateX(0); } 50% { transform: translateX(8%); } }
@keyframes qmFloat { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: .7; } 100% { transform: translateY(-220px); opacity: 0; } }
@keyframes qmKen {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1.6%, -1.1%); }
}
@keyframes qmGlow {
  0%,100% { box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(224,195,122,.35); }
  50% { box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(224,195,122,.7); }
}
@media (max-width: 640px) {
  .page { padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); }
  .stage { height: min(780px, calc(100dvh - 40px)); min-height: 480px; border-radius: 10px; }
  .howto { display: none; }
  .portrait { max-width: 58%; }
  .line { font-size: 15px; }
  .dialog, .explore-panel, .challenge-panel { padding: 12px 14px 14px; min-height: 132px; }
  .title-copy { padding: 20px 16px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .fade, .portrait, .fog-a, .fog-b, .spark, .choice, .btn-glow, .btn-primary, .ripple, .fx-flash, .challenge-wrap.shake, .layer.ken {
    animation: none !important; transition: none !important;
  }
}
