/* ═══════════ 若梦空间站 ═══════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #05070f;
  color: #e8ecf4;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#scene-container {
  position: fixed;
  inset: 0;
  touch-action: none;          /* 防止页面随滑动滚动，交给自定义手势 */
}

/* ── 标题 ────────────────────────── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: max(16px, env(safe-area-inset-top)) 20px 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
#header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #ffd98a, #ffb35c, #ffd98a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#header p {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(232,236,244,.55);
  letter-spacing: 1px;
  white-space: nowrap;   /* 微信等 WebView 字体度量差异易换行 */
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 44px;       /* 给左右留出，避免与音乐按钮/边缘重叠 */
}
#music-btn {
  position: absolute;
  right: 16px; top: max(16px, env(safe-area-inset-top));
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,217,138,.4);
  background: rgba(10,14,26,.55);
  color: #ffd98a;
  font-size: 16px;
  cursor: pointer;
  z-index: 12;
  pointer-events: auto;   /* 父级 #header 是 pointer-events:none，必须恢复可点击 */
}
#music-btn:active { transform: scale(.92); }

/* 首次交互提示 */
#sound-hint {
  position: fixed;
  top: 72px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(10,14,26,.8);
  border: 1px solid rgba(255,217,138,.45);
  color: #ffe9b8;
  font-size: 13px;
  white-space: nowrap;      /* 防止微信等 WebView 换行撑高 */
  width: max-content;
  max-width: calc(100vw - 24px);
  animation: ss-hint 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ss-hint {
  0%,100% { opacity: 1; }
  50% { opacity: .55; }
}

/* 配乐署名（CC BY 4.0） */
#credit {
  position: fixed;
  right: 12px; bottom: 8px;
  z-index: 5;
  font-size: 10px;
  color: rgba(232,236,244,.4);
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  pointer-events: none;
}

/* ── 底部空间站导航窗：简笔画包裹金色窗口 ── */
#station-frame {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  z-index: 10;
  width: 440px; height: 200px;
  /* 固定尺寸：八角形舱门恒为 ~150px，与选择卡等宽，面板可超出屏幕被裁切 */
}
#station-art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}
#station-art .st-panel rect {
  fill: rgba(255,217,138,.05);
  stroke: #ffd98a; stroke-width: 1.3; opacity: .5;
}
#station-art .st-panel line,
#station-art .st-arm,
#station-art .st-mast {
  stroke: #ffd98a; stroke-width: .8; opacity: .32;
}
#station-art .st-ring {
  fill: none; stroke: #ffd98a; stroke-width: 1.6;
  stroke-dasharray: 7 5; opacity: .6;
  stroke-linejoin: round;
}
#station-art .st-bolt {
  fill: #ffd98a; opacity: .5;
}
#station-art .st-beacon {
  fill: #ffd98a;
  animation: ss-blink 2.2s ease-in-out infinite;
}
@keyframes ss-blink { 0%,100% { opacity: 1; } 50% { opacity: .2; } }

/* 金色窗口（选择卡）：无外框透明，整体居中于八角形舱门 */
#info-card {
  position: absolute;
  left: 50%; top: 110px;   /* 110 = 八角形中心（frame 200px 高，xMidYMax 绘制） */
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 14px;
  max-width: calc(100vw - 24px);
  transition: opacity .3s, transform .3s;
}
#info-card.hidden { opacity: 0; transform: translate(-50%, -50%) translateY(12px) scale(.96); pointer-events: none; }

/* 选择框：文字居中 */
#selector { position: relative; }
#selector-current {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 30px 7px 12px;
  border-radius: 999px;
  background: rgba(10,14,26,.55);
  border: 1px solid rgba(255,217,138,.45);
  color: #ffe9b8;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
#selector-arrow {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px; opacity: .7;
  transition: transform .2s;
}
#selector.open #selector-arrow { transform: translateY(-50%) rotate(180deg); }

/* 下拉菜单：按最长项定宽，文字居中 */
#selector-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-height: 42vh;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(12,17,32,.96);
  border: 1px solid rgba(255,217,138,.35);
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  padding: 6px;
  z-index: 15;
}
#selector-menu.hidden { display: none !important; }
.sel-item {
  position: relative;
  padding: 9px 26px;
  border-radius: 8px;
  font-size: 14px;
  color: #dfe6f2;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.sel-item:active { background: rgba(255,255,255,.08); }
.sel-item.selected {
  color: #ffd98a;
  background: rgba(255,217,138,.12);
  font-weight: 700;
}
.sel-item.selected::after {
  content: '✓';
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  opacity: .85;
}

/* 动作区：去探索 / 探索中 */
#info-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#info-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0b0f1a;
  background: linear-gradient(135deg, #ffd98a, #ffb35c);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255,190,80,.35);
}
#info-link:active { transform: scale(.96); }
#info-pending { color: rgba(232,236,244,.45); font-size: 13px; }

/* ── Toast ───────────────────────── */
#toast {
  position: fixed;
  top: 22%; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(10,14,26,.85);
  border: 1px solid rgba(255,255,255,.15);
  font-size: 13px;
  transition: opacity .25s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.hidden { opacity: 0; }

/* ── 3D 标签（由 JS 逐帧定位）────── */
.ss-label {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -140%);
  z-index: 5;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #dfe6f2;
  background: rgba(8,12,24,.55);
  border: 1px solid rgba(255,255,255,.18);
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  pointer-events: none;
  white-space: nowrap;
  transition: font-size .3s, color .3s, border-color .3s, opacity .3s;
}
.ss-label.moon {
  color: #ffe9b8;
  border-color: rgba(255,217,138,.85);
  background: rgba(255,180,60,.16);
  font-size: 14px;
  box-shadow: 0 0 16px rgba(255,190,80,.35);
}
.ss-label.focused {
  color: #ffd98a;
  border-color: #ffd98a;
  font-size: 15px;
}

/* ── 无 WebGL 降级 ───────────────── */
#fallback {
  position: fixed; inset: 0;
  z-index: 30;
  overflow-y: auto;
  background: radial-gradient(1200px 800px at 50% -10%, #101a33 0%, #05070f 60%);
  padding: max(56px, env(safe-area-inset-top)) 24px 40px;
  text-align: center;
}
#fallback h2 {
  font-size: 24px;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #ffd98a, #ffb35c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#fallback .fb-sub { margin-top: 10px; font-size: 13px; color: rgba(232,236,244,.55); }
#fallback-list {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  margin-left: auto; margin-right: auto;
}
.fb-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  text-decoration: none;
  color: #e8ecf4;
  font-size: 15px;
  transition: background .2s, border-color .2s;
}
.fb-card:active { background: rgba(255,255,255,.12); }
.fb-card .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 12px;
  flex: none;
}
.fb-card.moon {
  border-color: rgba(255,217,138,.7);
  background: rgba(255,180,60,.10);
  font-weight: 700;
}
.fb-card.moon .dot { background: #ffd98a; box-shadow: 0 0 10px #ffd98a; }
.fb-card.pending { opacity: .55; }
.fb-card .tag { font-size: 12px; color: rgba(232,236,244,.45); }

/* ── 加载动画 ────────────────────── */
#loader {
  position: fixed; inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #05070f;
  transition: opacity .5s;
}
#loader.gone { opacity: 0; pointer-events: none; }
#loader p { font-size: 13px; color: rgba(232,236,244,.6); letter-spacing: 2px; }
.spin {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255,217,138,.15);
  border-top-color: #ffd98a;
  animation: ss-spin 1s linear infinite;
}
@keyframes ss-spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
