:root {
  --sky-top: #abcce0;
  --sky-bottom: #d8e9f2;
  --logo-blue: #1a5296;
}

/* ベース */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Hiragino Mincho ProN', serif;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
}
#stage.is-open {
  overflow: auto;
}

/* 王国（Enter後） */
#kingdom-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
}

.is-open #kingdom-container {
  display: flex;
  position: relative;
  height: 100vh;
  align-items: center;
  width: fit-content;
  min-width: 100%;
  justify-content: center;
}

/* Enter後：マップ画像を横スクロール可能にする */
.is-open #stage {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.map-image {
  display: block;
  height: 100vh;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* 建物コンテナ */
.buildings-container {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
  width: 100%;
  height: 100vh;
}

.buildings-container .building {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  z-index: 10;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

/* Rujie */
.buildings-container .building[data-building-id="rujie"] {
  left: 51.67%;
  top: 41.25%;
}

.buildings-container .building[data-building-id="rujie"] img {
  width: 25vh;
  height: auto;
}

/* House2 (SNS) */
.buildings-container .building[data-building-id="house2"] {
  left: calc(50% - 55vh);
  top: 28%;
}

.buildings-container .building[data-building-id="house2"] img {
  width: 21vh;
  height: auto;
}

/* House3 (Store) */
.buildings-container .building[data-building-id="house3"] {
  left: calc(50% - 31vh);
  top: 60%;
}

.buildings-container .building[data-building-id="house3"] img {
  width: 20vh;
  height: auto;
}

/* House4 (Music) */
.buildings-container .building[data-building-id="house4"] {
  left: calc(50% - 7vh);
  top: 72.5%;
}

.buildings-container .building[data-building-id="house4"] img {
  width: 27vh;
  height: auto;
}

/* Company */
.buildings-container .building[data-building-id="company"] {
  left: calc(50% + 60vh);
  top: 19.5%;
}

.buildings-container .building[data-building-id="company"] img {
  width: 22vh;
  height: auto;
}

.buildings-container .building img {
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  display: block;
}

/* 雲 */
#cloudSea,
.cloud-element {
  pointer-events: none;
}

.cloud-container {
  position: absolute;
  inset: -30%;
  width: 160%;
  height: 160%;
  z-index: 10;
  pointer-events: none;
  transition: transform 2s cubic-bezier(0.7,0,0.3,1), opacity 2s ease;
}

.cloud-element {
  position: absolute;
  background: white;
  border-radius: 40% 60% 70% 30% / 40% 40% 60% 60%;
  filter: url(#organic-structure) blur(30px);
  opacity: 0.95;
}

@keyframes drift {
  from { transform: translate(-20px, -10px); }
  to   { transform: translate(20px, 10px); }
}

/* UI */
.ui-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 1.2s ease;
}

.logo-symbol {
  width: 140px;
}

.logo-symbol img {
  width: 100%;
}

.logo-text {
  margin-top: 20px;
  color: var(--logo-blue);
  letter-spacing: 0.3em;
  font-weight: bold;
}

.enter-btn {
  margin-top: 60px;
  padding: 12px 50px;
  background: white;
  border: 2px solid var(--logo-blue);
  color: var(--logo-blue);
  font-weight: bold;
  letter-spacing: 0.5em;
  cursor: pointer;
  transition: 0.3s;
}

.enter-btn:hover {
  background: var(--logo-blue);
  color: white;
}

/* Enter後 */
.is-open .ui-wrapper {
  opacity: 0;
  pointer-events: none;
}

.is-open .cloud-container {
  transform: scale(6);
  opacity: 0;
}

/* フラッシュ */
.flash-overlay {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 500;
}

.is-open .flash-overlay {
  animation: flash 1.5s forwards;
}

@keyframes flash {
  0% { opacity: 1; }
  40% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* モバイル */
@media (max-width: 768px) {
  .logo-symbol { width: 100px; }
  .enter-btn {
    padding: 10px 30px;
    letter-spacing: 0.3em;
  }
}


#stage {
  position: relative;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
}

.info-bubble {
  position: absolute;
  pointer-events: auto;
}


/* 説明用パネル */
.info-bubble {
  background: rgba(255,255,255,0.95);
  padding: 14px 18px 25px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 9999;
  visibility: hidden;
}

.info-bubble.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Rujie - 上に出す */
#info-bubble-rujie {
  left: 51.67%;
  top: calc(41.25% - 90px);
  transform: translate(-50%, -100%);
}

#info-bubble-rujie::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: rgba(255,255,255,0.95);
}

/* House2 (SNS) - 右に出す */
#info-bubble-house2 {
  left: calc(18.33% + 110px);
  top: 30%;
  transform: translateY(-50%);
}

#info-bubble-house2::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -12px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right-color: rgba(255,255,255,0.95);
}

/* House3 (Store) - 上に出す */
#info-bubble-house3 {
  left: 31.67%;
  top: calc(60% - 90px);
  transform: translate(-50%, -100%);
}

#info-bubble-house3::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: rgba(255,255,255,0.95);
}

/* House4 (Music) - 上に出す */
#info-bubble-house4 {
  left: 44.17%;
  top: calc(72.5% - 90px);
  transform: translate(-50%, -100%);
}

#info-bubble-house4::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: rgba(255,255,255,0.95);
}

/* Company - 左に出す */
#info-bubble-company {
  left: calc(87.5% - 140px);
  top: 21.5%;
  transform: translate(-100%, -50%);
}

#info-bubble-company::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-left-color: rgba(255,255,255,0.95);
}


@media (max-width: 500px) {
  /* Rujie - 上に出す */
  #info-bubble-rujie {
    left: 51.67%;
    top: calc(41.25% - 90px);
    transform: translate(-50%, -100%);
  }

  #info-bubble-rujie::after {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: rgba(255,255,255,0.95);
  }

  /* House2 (SNS) - 右に出す */
  #info-bubble-house2 {
    left: calc(0.33% + 110px);
    top: 62%;
    transform: translateY(-50%);
  }

  #info-bubble-house2::after {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-bottom-color: rgba(255,255,255,0.95);
  }

  /* House3 (Store) - 上に出す */
  #info-bubble-house3 {
    left: 28.67%;
    top: calc(60% - 90px);
    transform: translate(-50%, -100%);
  }

  #info-bubble-house3::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: rgba(255,255,255,0.95);
  }

  /* House4 (Music) - 上に出す */
  #info-bubble-house4 {
    left: 44.17%;
    top: calc(72.5% - 90px);
    transform: translate(-50%, -100%);
  }

  #info-bubble-house4::after {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: rgba(255,255,255,0.95);
  }

  /* Company - 左に出す */
  #info-bubble-company {
    left: calc(98.5% - 140px);
    top: 49.5%;
    transform: translate(-100%, -50%);
  }

  #info-bubble-company::after {
    content: '';
    position: absolute;
    top: -16px;
    right: 20%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-bottom-color: rgba(255,255,255,0.95);
  }


  /* Rujie */
  .buildings-container .building[data-building-id="rujie"] {
    left: 51.67%;
    top: 41.25%;
  }

  .buildings-container .building[data-building-id="rujie"] img {
    width: calc(220 / 430 * 100vw);
  }

  /* House2 (SNS) */
  .buildings-container .building[data-building-id="house2"] {
    left: 17.33%;
    top: 27%;
  }

  .buildings-container .building[data-building-id="house2"] img {
    width: calc(160 / 430 * 100vw);
  }

  /* House3 (Store) */
  .buildings-container .building[data-building-id="house3"] {
    left: 32.67%;
    top: 58%;
  }

  .buildings-container .building[data-building-id="house3"] img {
    width: calc(160 / 430 * 100vw);
  }

  /* House4 (Music) */
  .buildings-container .building[data-building-id="house4"] {
    left: 45.17%;
    top: 72.5%;
  }

  .buildings-container .building[data-building-id="house4"] img {
    width: calc(210 / 430 * 100vw);
  }

  /* Company */
  .buildings-container .building[data-building-id="company"] {
    left: 87.5%;
    top: 20.5%;
  }

  .buildings-container .building[data-building-id="company"] img {
    width: calc(200 / 430 * 100vw);
  }

  /* Rujie - 上に出す（スマホ用） */
  #info-bubble-rujie {
    transform: translate(-50%, -110%);
    min-width: 205px;
    max-width: 300px;
  }

  /* House3 - 上に出す（スマホ用） */
  #info-bubble-house3 {
    transform: translate(-50%, -110%);
    min-width: 205px;
    max-width: 300px;
  }

  /* House4 - 上に出す（スマホ用） */
  #info-bubble-house4 {
    transform: translate(-50%, -110%);
    min-width: 205px;
    max-width: 300px;
  }

  /* Company - 左表示（スマホ用） */
  #info-bubble-company {
    transform: translate(-80%, -50%);
    min-width: 235px;
    max-width: 300px;
  }
}
