/* ===== 基本設定 ===== */
html, body { height: 100%; margin: 0; }

#tour {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  border: 0; z-index: 0;
}

/* ===== スケール変数 ===== */
:root {
  --scale: 1;
  --scale-bubble: 1;
  --scale-narrator: 1;
}

/* 横幅に応じてスケール調整 */
@media (min-width: 1600px) {
  :root { --scale: 1.1; --scale-bubble: 1.1; --scale-narrator: 1; }
}
@media (min-width: 1920px) {
  :root { --scale: 1.15; --scale-bubble: 1.15; --scale-narrator: 1; }
}
@media (min-width: 2560px) {
  :root { --scale: 1.2; --scale-bubble: 1.2; --scale-narrator: 1; }
}

/* ===== ローディング ===== */
#loader {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  z-index: 9999;
  opacity: 1; transition: opacity .4s ease;
}
#loader img {
  width: calc(420px * var(--scale));
  height: auto;
  max-width: 90vw;
}
#loader.hide { opacity: 0; pointer-events: none; }

/* ===== ナレーター ===== */
#narrator {
  position: fixed;
  right: 16px; bottom: 0;
  width: calc(110px * var(--scale-narrator));
  max-height: 100vh;
  object-fit: contain;
  pointer-events: none;
  z-index: 12;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.35));
}

/* ===== セリフ帯 ===== */
#speech {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: calc(16px * var(--scale));
  text-align: center;
  pointer-events: none;
  z-index: 13;
}

/* ボタン類は操作可能に戻す */
#speech .inline-btn,
#speech .choice-btn {
  pointer-events: auto;
}

/* ===== 選択肢ボタン ===== */
.choice-group {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.choice-btn {
  padding: calc(8px * var(--scale-bubble)) calc(14px * var(--scale-bubble));
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 9999px;
  font-size: calc(15px * var(--scale-bubble));
  font-weight: 600;
  background: rgb(255,36,70);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  cursor: pointer;
}
.choice-btn:active { transform: translateY(1px); }

/* ===== 吹き出し ===== */
#bubble {
  display: inline-block;
  background: rgba(255,255,255,.92);
  color: #222;
  border-radius: 14px;
  padding: calc(14px * var(--scale-bubble)) calc(16px * var(--scale-bubble));
  font-size: calc(16px * var(--scale-bubble));
  line-height: 1.8;
  font-family: "Yu Gothic","Segoe UI",sans-serif;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);

  /* 幅を可変に */
  width: fit-content;
  max-width: 80vw;   /* ビューポート幅の80%まで */
  min-width: 300px;  /* 最小幅は確保 */
  margin: 0 auto;
  word-wrap: break-word;
}

#typed { white-space: pre-wrap; }

/* ===== インラインボタン ===== */
.inline-btn {
  display: inline-block;
  margin-left: .5em;
  padding: calc(8px * var(--scale-bubble)) calc(14px * var(--scale-bubble));
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 9999px;
  background: rgb(255,36,70);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  font-size: calc(15px * var(--scale-bubble));
  font-weight: 600;
  cursor: pointer;
}
.inline-btn:active { transform: translateY(1px); }

/* ===== スマホ（600px以下） ===== */
@media (max-width: 600px) {
  #speech { display: block; }

  #narrator {
    right: -30px !important;
    bottom: 0 !important;
    max-height: 10vh !important;
    position: fixed;
  }

  /* 吹き出しの横幅を広げる */
  #bubble {
    max-width: 90vw;   /* ビューポート幅の90%まで広げる */
    min-width: auto;    /* 最小幅は自動 */
    padding: 12px 14px; /* パディングも少し調整可能 */
  }
}

/* ===== PC（601px以上）：吹き出し + ナレーター横並び ===== */
@media (min-width: 601px) {
  #speech-inner {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: calc(5px * var(--scale));
    white-space: nowrap;
  }

  #bubble {
    max-width: 70vw; /* 大画面でも横幅を拡張 */
    margin: 0;
    white-space: normal;
  }

  #narrator {
    position: relative;
    right: 0; bottom: 0;
    width: calc(130px * var(--scale-narrator));
    max-height: 40vh;
    flex-shrink: 0;
  }
}
