:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #0b1020;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #142033;
}

.park {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.park-hud {
  position: absolute;
  z-index: 20;
  left: 10px;
  right: 10px;
  top: calc(8px + var(--safe-top));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.park-hud > * { pointer-events: auto; }

.park-hud__back {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
  color: #333;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.park-brand {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  max-width: 260px;
  margin: 0 auto;
}
.park-brand__name {
  font-size: 0.95rem;
  font-weight: 900;
  color: #16324a;
}
.park-brand__sub {
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(22, 50, 74, 0.7);
}

.park-hud__spacer { width: 44px; flex-shrink: 0; }

/* 整张游乐场图可滚动/可缩放感：完整底图 */
.park-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #6ec6ff;
}

.park-canvas {
  position: relative;
  width: 100%;
  line-height: 0;
  /* 与底图同一框，避免 SVG 被父级拉高导致区块错位 */
  aspect-ratio: 3 / 4;
}

.park-canvas__img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* SVG 分区：与底图同框叠放 */
.park-zones {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  overflow: visible;
  display: block;
}

.zone-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zone-link:focus {
  outline: none;
}
.zone-link:focus-visible .zone-poly {
  stroke-width: 4;
  stroke: #ffffff;
}

.zone-poly {
  fill-opacity: 0.22;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linejoin: round;
  transition: fill-opacity 0.15s ease, stroke-width 0.15s ease;
  vector-effect: non-scaling-stroke;
}
.zone-link:hover .zone-poly,
.zone-link:active .zone-poly {
  fill-opacity: 0.34;
  stroke-width: 3.5;
  stroke: #ffffff;
}

.zone-poly--learn { fill: #e25a2e; }
.zone-poly--split { fill: #2f9e52; }
.zone-poly--code  { fill: #2f6fd0; }
.zone-poly--roots { fill: #e89410; }
.zone-poly--words { fill: #1498a6; }
.zone-poly--short { fill: #8a45d8; }
.zone-poly--type  { fill: #d64538; }
.zone-poly--blind { fill: #3d4f78; }

.zone-text {
  fill: #fff;
  font-size: 13px;
  font-weight: 900;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(0, 0, 0, 0.45);
  stroke-width: 3px;
  letter-spacing: 0.04em;
}

/* 点进大区后的设施层 */
.sheet-mask {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(10, 16, 32, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sheet-mask.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: min(72dvh, 520px);
  background: #fffef8;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22);
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open { transform: translateY(0); }

.sheet__grab {
  width: 42px;
  height: 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.12);
  margin: 10px auto 6px;
}
.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 16px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.sheet__swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
}
.sheet__title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 900;
  color: #1a2433;
}
.sheet__close {
  border: none;
  background: rgba(0, 0, 0, 0.06);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #445;
  cursor: pointer;
}
.sheet__body {
  flex: 1;
  overflow: auto;
  padding: 14px 14px 20px;
}
.sheet__note {
  font-size: 0.8rem;
  color: #667788;
  margin-bottom: 12px;
  line-height: 1.45;
}

.facility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}

.facility {
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  background: #fff;
  min-height: 72px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
}
.facility--wide {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
}
.facility__badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}
.facility__label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #243044;
  text-align: center;
  line-height: 1.2;
}
.facility--wide .facility__label {
  font-size: 0.86rem;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
}
.sheet.is-open .sheet__body {
  max-height: min(58dvh, 420px);
}
.facility__sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8899aa;
  margin-top: 2px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  background: rgba(20, 28, 44, 0.92);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— 嵌在站点首页：高度跟地图走，底下不留大块空白 —— */
html.is-park-home,
body.is-park-home {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

#app.is-park-home {
  height: auto;
  max-height: none;
  overflow: visible;
  background: transparent;
}

#app.is-park-home .park {
  position: relative;
  inset: auto;
}

#app.is-park-home .park-hud__back,
#app.is-park-home .park-hud__spacer {
  visibility: hidden;
  pointer-events: none;
}

#app.is-park-home .park-stage {
  flex: none;
  overflow: visible;
  background: #6ec6ff;
}

#app.is-park-home .sheet-mask,
#app.is-park-home .sheet,
#app.is-park-home .toast {
  position: fixed;
  left: 50%;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
}
#app.is-park-home .sheet-mask {
  inset: 0;
  left: 0;
  width: 100%;
  max-width: none;
  transform: none;
}
#app.is-park-home .sheet {
  left: 50%;
  right: auto;
  bottom: 0;
  transform: translateX(-50%) translateY(105%);
}
#app.is-park-home .sheet.is-open {
  transform: translateX(-50%) translateY(0);
}
#app.is-park-home .toast {
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
}
#app.is-park-home .toast.is-show {
  transform: translateX(-50%) translateY(0);
}
