/* 入口場景:神秘占卜街 (直式地圖, 手機友善上下捲動). 純 CSS, 角色造型/名字後補. */

#sceneView {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 64px);
  padding-bottom: 120px;   /* 留位給底部對白框 */
}

/* 夜空背景層 — 固定當視窗背景, 內容在上面捲動 */
.scene-sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.scene-moon {
  position: absolute; top: 8%; right: 14%; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff 0%, #e8e2ff 45%, #b9aee6 70%, transparent 72%);
  box-shadow: 0 0 70px 24px rgba(210,200,255,.25);
  animation: moonGlow 6s ease-in-out infinite;
}
@keyframes moonGlow { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.15); } }

/* 飄動的雲 (柔霧狀, 多層不同速度飄過夜空) */
.scene-cloud {
  position: absolute; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(160,150,210,.22), rgba(160,150,210,.10) 60%, transparent 75%);
  filter: blur(6px); opacity: 0; will-change: transform;
}
.scene-cloud::after {
  content: ""; position: absolute; left: 26%; top: 14%; width: 64%; height: 78%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(150,140,205,.20), transparent 72%);
}
.scene-cloud.k1 { width: 240px; height: 70px; top: 14%; animation: cloudDrift 46s linear infinite; }
.scene-cloud.k2 { width: 320px; height: 92px; top: 26%; animation: cloudDrift 64s linear infinite; animation-delay: -22s; opacity: .8; }
.scene-cloud.k3 { width: 180px; height: 56px; top: 9%; animation: cloudDrift 38s linear infinite; animation-delay: -30s; }
.scene-cloud.k4 { width: 280px; height: 80px; top: 20%; animation: cloudDrift 56s linear infinite; animation-delay: -48s; opacity: .7; }
@keyframes cloudDrift {
  0% { transform: translateX(-360px); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { transform: translateX(calc(100vw + 120px)); opacity: 0; }
}
.scene-fog {
  position: absolute; bottom: 22%; left: -10%; right: -10%; height: 240px;
  background: radial-gradient(ellipse at 30% 50%, rgba(141,123,200,.18), transparent 60%),
              radial-gradient(ellipse at 75% 40%, rgba(212,175,106,.12), transparent 60%);
  filter: blur(8px); animation: fogDrift 22s ease-in-out infinite alternate;
}
@keyframes fogDrift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
.scene-hills {
  position: absolute; bottom: 0; left: 0; right: 0; height: 32%;
  background:
    radial-gradient(120% 90% at 20% 100%, #1a1535 60%, transparent 61%),
    radial-gradient(120% 80% at 65% 100%, #15112c 60%, transparent 61%),
    linear-gradient(transparent, #100d22 80%);
}

/* 標題 */
.scene-hero { position: relative; z-index: 2; text-align: center; padding: 34px 20px 14px; }
.scene-hero h1 {
  font-family: var(--display);
  font-size: 44px; font-weight: 700; letter-spacing: 7px;
  background: linear-gradient(120deg, var(--gold-soft), var(--gold), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 16px rgba(141,123,200,.35));
}
.scene-hero p { color: var(--text-dim); font-size: 15px; margin-top: 12px; max-width: 540px; margin-inline: auto; }

/* 橫向卷軸 */
.scene-rail-wrap { position: relative; z-index: 2; }
.scene-rail { position: relative; max-width: 560px; margin: 0 auto; padding: 16px 16px 30px; }
/* 中央占卜街小徑(虛線發光) */
.scene-rail::before {
  content: ""; position: absolute; left: 50%; top: 10px; bottom: 30px; width: 2px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(141,123,200,.55) 0 7px, transparent 7px 17px);
}

/* 攤位:左右交錯排在小徑兩側 */
.stall {
  position: relative; width: 52%; margin-bottom: 30px; padding: 0;
  border: none; background: none; cursor: pointer; font-family: inherit; color: var(--text);
  display: flex; flex-direction: column; align-items: center;
  transition: transform .2s ease;
}
.stall.side-l { margin-right: 48%; }
.stall.side-r { margin-left: 48%; }
.stall:hover, .stall:focus-visible { transform: translateY(-3px); outline: none; }
/* 小徑上的發光珠(連到節點) */
.stall::after {
  content: ""; position: absolute; top: 62px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--c1); box-shadow: 0 0 14px 2px var(--glow); z-index: 3;
}
.stall.side-l::after { right: -8%; }
.stall.side-r::after { left: -8%; }

/* 圓形節點(內含一直在動的占卜動畫) */
.stall-node {
  position: relative; width: 138px; height: 138px; border-radius: 50%;
  background: radial-gradient(circle at 50% 65%, color-mix(in srgb, var(--c1) 20%, #1a1535), #100d22 70%);
  border: 1px solid var(--c1);
  box-shadow: 0 0 26px -4px var(--glow), inset 0 0 24px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stall:hover .stall-node { box-shadow: 0 0 42px -2px var(--glow), inset 0 0 24px rgba(0,0,0,.4); }
.stall-anim { transform: scale(.9); pointer-events: none; }
.stall-art { position: absolute; inset: 0; background-size: cover; background-position: top center; }
.stall-lantern {
  position: absolute; top: 8px; z-index: 4; width: 13px; height: 18px; border-radius: 7px 7px 5px 5px;
  background: radial-gradient(circle at 50% 40%, #ffd98a, #d4882f); box-shadow: 0 0 14px 3px rgba(255,180,90,.55);
  animation: lantern 2.4s ease-in-out infinite;
}
.stall-lantern.l1 { left: 12px; } .stall-lantern.l2 { right: 12px; animation-delay: .8s; }
@keyframes lantern { 0%,100% { opacity: .65; transform: translateY(0) scale(1); } 50% { opacity: 1; transform: translateY(2px) scale(1.08); } }

.stall-label { margin-top: 12px; text-align: center; }
.stall-shop { font-size: 16px; font-weight: 800; color: var(--gold-soft); letter-spacing: 1px; }
.stall-shop .stall-ic { display: inline-flex; vertical-align: -4px; margin-right: 5px; color: var(--c1); }
.stall-shop .stall-ic svg { width: 18px; height: 18px; }
.stall-name { font-size: 12px; color: var(--text-dim); margin-top: 3px; letter-spacing: 1px; }

/* 底部對白框(點攤位 → 占卜師說話) */
.scene-dialogue {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: flex-start; gap: 14px;
  max-width: 640px; margin: 0 auto; padding: 18px 20px 22px;
  background: linear-gradient(180deg, rgba(20,16,40,.97), rgba(12,10,26,.99));
  border-top: 1px solid var(--c1, var(--gold)); border-radius: 20px 20px 0 0;
  box-shadow: 0 -16px 44px rgba(0,0,0,.55), 0 0 30px -10px var(--glow, rgba(212,175,106,.4));
  transform: translateY(115%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.scene-dialogue.show { transform: translateY(0); }
.sd-portrait {
  flex: 0 0 76px; width: 76px; height: 92px; border-radius: 12px; position: relative; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #2c245a, #15112a); border: 1px solid var(--c1, var(--gold));
  background-size: cover; background-position: top center;
}
.sd-portrait svg { width: 100%; height: 100%; }
.sd-portrait .sd-glyph { position: absolute; left: 50%; top: 54%; transform: translate(-50%, -50%); width: 30px; height: 30px; color: var(--c1, var(--gold)); }
.sd-portrait .sd-glyph svg { width: 100%; height: 100%; filter: drop-shadow(0 0 6px var(--glow)); }
.sd-body { flex: 1; min-width: 0; }
.sd-name { font-size: 14px; color: var(--gold-soft); font-weight: 700; font-family: var(--serif); letter-spacing: 1px; }
.sd-line { font-size: 16px; color: var(--text); line-height: 1.7; margin: 8px 0 14px; min-height: 46px; }
.sd-line::after { content: "▌"; color: var(--c1, var(--gold)); animation: sdBlink 1s steps(2) infinite; }
@keyframes sdBlink { 50% { opacity: 0; } }
.sd-enter {
  background: linear-gradient(120deg, var(--gold), #c79a4f); border: none; color: #1a1430;
  padding: 9px 24px; border-radius: 999px; font-weight: 800; letter-spacing: 2px; cursor: pointer; font-family: inherit; font-size: 14px;
}
.sd-enter:hover { filter: brightness(1.08); }
.sd-close { position: absolute; top: 8px; right: 14px; background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; }
.sd-close:hover { color: var(--gold); }

.scene-hint { position: relative; z-index: 2; text-align: center; color: var(--text-dim); font-size: 13px; padding: 6px 0 22px; letter-spacing: 1px; }

/* 主控台返回鈕 + 老師橫幅 */
.back-btn {
  background: transparent; border: 1px solid var(--purple); color: var(--text-dim);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-family: inherit; margin-bottom: 16px;
  transition: all .18s;
}
.back-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.master-banner {
  display: none; align-items: center; gap: 14px; margin-bottom: 18px; padding: 12px 16px;
  border-radius: 14px; background: linear-gradient(160deg, rgba(212,175,106,.1), rgba(0,0,0,.2));
  border: 1px solid rgba(212,175,106,.3);
}
.master-banner.show { display: flex; }
.master-banner .mb-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px; color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, #2c245a, #15112a); border: 1px solid var(--gold);
  background-image: var(--art, none); background-size: cover; background-position: center;
}
.master-banner .mb-avatar svg { width: 26px; height: 26px; }
.master-banner .mb-title { font-size: 16px; font-weight: 800; color: var(--gold-soft); }
.master-banner .mb-teaser { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

@media (max-width: 560px) {
  .scene-hero h1 { font-size: 32px; letter-spacing: 4px; }
  .scene-hero { padding: 24px 18px 10px; }
  .stall { width: 56%; }
  .stall.side-l { margin-right: 44%; }
  .stall.side-r { margin-left: 44%; }
  .stall-node { width: 120px; height: 120px; }
  .stall-shop { font-size: 14px; }
  .scene-dialogue { gap: 11px; padding: 16px 16px 20px; border-radius: 16px 16px 0 0; }
  .sd-portrait { flex: 0 0 60px; width: 60px; height: 76px; }
  .sd-line { font-size: 15px; min-height: 40px; }
}
