:root {
  --sky: #4aa7ff;
  --sky-deep: #2e7fd6;
  --cloud: #f3f8ff;
  --orange: #ff8a2b;
  --orange-deep: #f06d10;
  --ink: #1d2a44;
  --panel: rgba(255, 255, 255, 0.92);
  --shadow: 0 12px 32px rgba(18, 56, 110, 0.22);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1220;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
}

/* 首页允许纵向滚动 */
.home-screen,
.home-screen * {
  touch-action: pan-y;
}
.home-cta,
.home-enter-hint,
.home-map-overlay,
.music-btn {
  touch-action: manipulation;
}

/* 背景音乐开关：右上角 logo 下方 */
.music-btn {
  position: fixed;
  top: calc(52px + var(--safe-top));
  right: 14px;
  left: auto;
  bottom: auto;
  z-index: 90;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.35);
  color: #1d4f8c;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(30, 90, 160, 0.2);
  cursor: pointer;
}

.music-btn .icon-on { display: none; }
.music-btn .icon-off { display: block; }
.music-btn.is-on .icon-on { display: block; }
.music-btn.is-on .icon-off { display: none; }
.music-btn.is-on {
  color: #fff;
  background: rgba(255, 138, 43, 0.88);
}

.music-btn:active {
  transform: scale(0.94);
}

.map-screen .music-btn {
  top: calc(58px + var(--safe-top));
  right: 14px;
  left: auto;
  bottom: auto;
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  background: none;
  color: inherit;
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* ========== Loading ========== */
.loading-screen {
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 0%, #7ec4ff 0%, transparent 55%),
    linear-gradient(180deg, #3b97ef 0%, #8ec8ff 45%, #eaf4ff 100%);
}

.loading-inner {
  text-align: center;
  color: #fff;
  padding: 24px;
}

.loading-orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff 0%, #ffe0a8 28%, #ff8a2b 62%, #ff5a1f 100%);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.18), 0 16px 40px rgba(255, 110, 30, 0.35);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.loading-text {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 10px rgba(20, 70, 140, 0.35);
}

.loading-sub {
  margin: 8px 0 22px;
  font-size: 13px;
  opacity: 0.9;
}

.loading-bar {
  width: min(220px, 60vw);
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.loading-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff6c8, #ff8a2b);
  transition: width 0.2s ease;
}

/* ========== Home ========== */
.home-screen {
  z-index: 10;
  background: #5eb6ff;
  touch-action: pan-y;
  overflow: hidden;
}

.home-layout {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
}

/* 切片拼合首页：天空为画布 */
.home-hero {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 1134 / 2004;
  min-height: 100%;
  overflow: hidden;
  background: #5eb6ff;
}

.home-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
  z-index: 0;
}

.home-logos {
  position: absolute;
  top: calc(2.2% + var(--safe-top) * 0.3);
  left: 3.5%;
  right: 3.5%;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.home-logo-bank {
  width: min(20%, 148px);
  height: auto;
  display: block;
}

.home-logo-suxin {
  width: min(36%, 156px);
  height: auto;
  display: block;
}

.home-copy {
  position: absolute;
  left: 50%;
  top: -3%;
  transform: translateX(-50%);
  width: min(100%, 380px);
  height: auto;
  z-index: 4; /* 保证标题文案在地图之上 */
  pointer-events: none;
}

.home-city {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: fill;
  object-position: bottom center;
  z-index: 1;
  pointer-events: none;
  display: block;
}

.home-cta {
  position: absolute;
  left: 50%;
  top: 21%;
  transform: translate(-50%, -50%);
  width: min(62vw, 280px);
  height: clamp(40px, 5.5vh, 52px);
  border-radius: 999px;
  background: transparent;
  color: transparent;
  font-size: 0;
  box-shadow: none;
  animation: none;
  z-index: 5;
}

.home-cta::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
}

.home-cta:active {
  transform: translate(-50%, -50%) scale(0.98);
}

/* 原引导按钮隐藏 */
.home-enter-hint {
  display: none !important;
}

/* 透明底地图：顶边由 JS 对齐到文案下方 */
.home-map-overlay {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, 0);
  width: min(122%, 680px);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  z-index: 3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.home-map-overlay:active {
  transform: translate(-50%, 0) scale(0.985);
}

.home-map-preview {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  background: transparent;
  filter: drop-shadow(0 8px 20px rgba(30, 90, 160, 0.2));
}

/* 手指引导：简洁白描点击手势 */
.map-finger {
  position: absolute;
  right: 12%;
  bottom: 16%;
  width: 58px;
  height: 58px;
  pointer-events: none;
  z-index: 2;
  animation: fingerTap 1.15s cubic-bezier(.34, 1.4, .64, 1) infinite;
  transform-origin: 35% 85%;
}

.map-finger-hand {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
}

.map-finger-dot {
  display: none;
}

.map-finger-ripple {
  position: absolute;
  left: 10%;
  top: 4%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 138, 43, 0.7);
  background: rgba(255, 138, 43, 0.2);
  z-index: 1;
  animation: fingerRipple 1.15s ease-out infinite;
}

@keyframes fingerTap {
  0%, 100% { transform: translate(0, 0) rotate(-16deg) scale(1); }
  35% { transform: translate(-5px, 11px) rotate(-16deg) scale(0.9); }
  50% { transform: translate(-2px, 5px) rotate(-16deg) scale(0.95); }
  65% { transform: translate(0, 0) rotate(-16deg) scale(1); }
}

@keyframes fingerRipple {
  0%, 28% { transform: scale(0.4); opacity: 0; }
  40% { transform: scale(0.85); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ========== Map ========== */
.map-screen {
  z-index: 20;
  /* 与封面一致的天蓝底 */
  background:
    radial-gradient(ellipse 90% 55% at 12% 18%, rgba(255, 255, 255, 0.55) 0%, transparent 52%),
    radial-gradient(ellipse 70% 45% at 88% 12%, rgba(255, 255, 255, 0.48) 0%, transparent 50%),
    radial-gradient(ellipse 80% 50% at 70% 78%, rgba(255, 255, 255, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 20% 88%, rgba(255, 255, 255, 0.28) 0%, transparent 50%),
    linear-gradient(180deg, #5eb6ff 0%, #7ec4ff 38%, #a8d8ff 72%, #cfe9ff 100%);
  display: flex;
  flex-direction: column;
}

.map-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 42% 18% at 28% 22%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.25) 40%, transparent 70%),
    radial-gradient(ellipse 36% 16% at 62% 16%, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.2) 42%, transparent 72%),
    radial-gradient(ellipse 48% 20% at 78% 58%, rgba(255, 255, 255, 0.45) 0%, transparent 68%),
    radial-gradient(ellipse 40% 18% at 18% 68%, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  opacity: 0.95;
}

.map-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(46, 127, 214, 0.55), rgba(46, 127, 214, 0.12));
  color: #fff;
  z-index: 5;
  text-shadow: 0 1px 4px rgba(20, 70, 140, 0.35);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(30, 90, 160, 0.18);
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.42);
}

.map-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-title strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.map-title span {
  font-size: 11px;
  opacity: 0.88;
}

.map-tips {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: #1d4f8c;
  font-size: 12px;
  pointer-events: none;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(30, 90, 160, 0.15);
}

.map-tips.hide {
  opacity: 0;
}

.map-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  z-index: 1;
  background: transparent;
}

.map-viewport.grabbing {
  cursor: grabbing;
}

/* 进入地图时先套默认缩放再显示，避免露出 1 倍再放大 */
.map-screen.map-preparing {
  visibility: hidden;
}

.map-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
  transition: none;
}

.map-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.hotspots {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.hotspot {
  position: absolute;
  /* 锚点在脉冲点；热区主体向上覆盖插画/站牌 */
  transform: translate(-50%, -70%);
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transition: transform 0.18s ease, background 0.18s ease;
  z-index: 2;
  pointer-events: none; /* 点击由几何命中处理，避免与拖动手势抢事件 */
}

/* 城市：脉冲点在橙色标题下方，不压字 */
.hotspot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 88%;
  bottom: auto;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: rgba(255, 138, 43, 0.92);
  box-shadow: 0 0 0 0 rgba(255, 138, 43, 0.55);
  animation: ping 2s ease-out infinite;
  pointer-events: none;
}

/* 能量站：脉冲点在黄按钮下方，不挡「能量站」文字 */
.hotspot.station::after {
  background: rgba(255, 210, 74, 0.95);
  box-shadow: 0 0 0 0 rgba(255, 210, 74, 0.55);
  border-radius: 3px;
  width: 8px;
  height: 5px;
  margin-left: -4px;
  margin-top: -2.5px;
  top: 96%;
}

@keyframes ping {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(255, 138, 43, 0.5); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(255, 138, 43, 0); }
  100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(255, 138, 43, 0); }
}

.hotspot .pin,
.hotspot .label {
  display: none !important;
}

.hotspot:active {
  transform: translate(-50%, -70%) scale(1.04);
  background: rgba(255, 255, 255, 0.12);
}

/* 调试模式：?debug=1 只显示热区范围，不显示文字 */
body.debug .hotspot {
  background: rgba(255, 80, 40, 0.28);
  outline: 1px dashed rgba(255, 255, 255, 0.7);
}

body.debug .hotspot.station {
  background: rgba(255, 200, 40, 0.32);
}

.map-legend {
  position: absolute;
  left: 12px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: #1d4f8c;
  font-size: 11px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(30, 90, 160, 0.16);
}

.map-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 4px;
}

.map-legend .dot.city {
  background: #ff8a2b;
}

.map-legend .dot.station {
  background: #ffd24a;
  border-radius: 2px;
}

.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom-controls button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(30, 90, 160, 0.2);
}

.zoom-controls button:active {
  transform: scale(0.95);
}

/* ========== Detail ========== */
.detail-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* 打开瞬间先吃掉穿透点击 */
  touch-action: manipulation;
}

.detail-screen.hidden {
  display: none !important;
}

.detail-mask {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 24, 0.62);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.detail-screen.open .detail-mask {
  opacity: 1;
}

.detail-panel {
  position: relative;
  z-index: 2;
  width: min(100%, 480px);
  height: min(92vh, 920px);
  margin: 0 auto;
  border-radius: 22px 22px 0 0;
  overflow: hidden;
  background: #e8f4ff;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
  transform: translateY(110%);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
}

.detail-screen.open .detail-panel {
  transform: translateY(0);
}

.detail-close {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #d9ecff;
}

.detail-figure {
  position: relative;
  width: 100%;
}

.detail-scroll img {
  width: 100%;
  height: auto;
}

/* 覆盖设计稿底部领取按钮区域，避免重复按钮 */
.detail-cta {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 3.2%;
  height: 7.5%;
  min-height: 44px;
  border-radius: 999px;
  background: transparent;
  color: transparent;
  font-size: 0;
  z-index: 2;
}

.detail-cta:active {
  background: rgba(255, 138, 43, 0.18);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Desktop preview */
@media (min-width: 768px) {
  body {
    background: #d7ecff;
  }

  .home-screen,
  .map-screen,
  .loading-screen {
    left: 50%;
    width: min(430px, 100%);
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.45);
  }

  .detail-screen {
    left: 50%;
    width: min(430px, 100%);
    transform: translateX(-50%);
  }

  .detail-panel {
    border-radius: 22px;
    margin-bottom: 12px;
    height: min(88vh, 860px);
  }
}
