/* 全螢幕場景背景 + 疊加元件定位（PC ≥ 768px）。Mobile 版改寫於 css/mobile.css（Phase 6）。 */

.scene,
#star-field {
  position: fixed;
  inset: 0;
  opacity: 0.15;
  transition: opacity 0.6s;
}

.scene {
  background: var(--bg);
}

/* 真的在播放時背景圖／星空才完全不透明，未播放（含暫停）一律降為 15%；
   #star-field 跟 .scene 共用同一份規則，行為維持一致 */
body.is-playing .scene,
body.is-playing #star-field {
  opacity: 1;
}

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

/* 限制在畫面上半部；故意放在 .site-title-fade／.bottom-fade 之後（DOM 順序）疊在
   黑色漸層上方，星星才不會被漸層蓋住變暗——只有星星本身浮出漸層，背景圖仍然在
   漸層下方，不影響漸層原本「讓標題不被背景吃掉」的效果 */
#star-field {
  height: 50%;
  overflow: hidden;
  pointer-events: none;
}

.star-field-star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 4px 1px var(--text);
  opacity: 0;
  animation: star-twinkle 4s ease-in-out infinite;
}

@keyframes star-twinkle {
  0%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 0.9;
  }
}

/* 第一層預設可見，城市資料載入前維持深色底（fallback 紋理） */
#bg-layer-a {
  opacity: 1;
}

/* 由上往下的黑色漸層，蓋住背景插畫最花的頂部區域，讓標題不會被吃掉，
   又不會像純色色塊一樣切出一條明顯的 UI 硬邊 */
.site-title-fade {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  pointer-events: none;
}

/* 同樣的處理放底部，蓋住背景插畫貼著 player-bar 那一段，讓浮動播放列跟背景的交界更柔和 */
.bottom-fade {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.site-title {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 56px;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
  opacity: 0.5;
  transition: opacity 0.6s;
}

/* 真的在播放時標題才完全不透明，未播放（含暫停）降為 50% */
body.is-playing .site-title {
  opacity: 1;
}

/* 右上角容器：credits icon 與 Steam 連結並排，桌面版在此定位 */
.top-right-controls {
  position: fixed;
  top: 16px;
  right: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  z-index: 6;
}

.steam-link {
  background: rgba(14, 13, 15, 0.68);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  display: none;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}

.steam-link svg {
  vertical-align: middle;
}

/* :hover 限定在真的有滑鼠的裝置才套用，避免觸控裝置點擊後 hover 樣式卡住不放 */
@media (hover: hover) and (pointer: fine) {
  .steam-link:hover {
    color: var(--accent);
    border-color: var(--accent);
  }
}

/* 版權宣告／icon credits：右上角容器內的純圖示按鈕，預設隱藏（Admin 沒填 credits 就不顯示） */
.credits-trigger {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  opacity: 0.75;
  cursor: pointer;
  transition: color 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

/* :hover 限定在真的有滑鼠的裝置才套用，避免觸控裝置點擊後 hover 樣式卡住不放 */
@media (hover: hover) and (pointer: fine) {
  .credits-trigger:hover {
    color: var(--accent);
    opacity: 1;
  }
}

.credits-panel {
  position: fixed;
  top: 50px;
  right: 20px;
  max-width: calc(100vw - 40px);
  background: rgba(14, 13, 15, 0.68);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  color: var(--text2);
  white-space: pre-line;
  overflow-wrap: anywhere;
  /* mobile 版開合面板要蓋在 .player-bar（z-index: 5）之上才看得到 */
  z-index: 6;
}

.credits-panel[hidden] {
  display: none;
}

.credits-panel a {
  color: var(--accent);
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .credits-panel a:hover {
    text-decoration: underline;
  }
}

/* Loading overlay — 三點 loading，資料就緒後淡出 */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-overlay.is-done {
  opacity: 0;
}

.loading-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  opacity: 0.5;
  animation: loading-bounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-7px); opacity: 1; }
}

.network-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(14, 13, 15, 0.68);
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  padding: 8px 20px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 0.06em;
  white-space: nowrap;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.network-toast.network-toast-visible {
  opacity: 1;
}

.paused-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  align-items: center;
  justify-content: center;
  background: rgba(14, 13, 15, 0.92);
  backdrop-filter: blur(8px);
}

.paused-message {
  font-family: var(--serif);
  font-size: 20px;
  font-style: italic;
  font-weight: 300;
  color: var(--text2);
  letter-spacing: 0.02em;
}
