:root {
  --bg: #0a0a0d;
  --bg-grad: radial-gradient(circle at 20% 0%, #14141c 0%, #0a0a0d 55%);
  --panel-bg: #131318;
  --panel-bg-2: #1a1a21;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f2f5;
  --muted: #8a8a97;
  --muted-2: #5f5f6b;
  --accent: #ffffff;
  --accent-text: #0a0a0d;
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 30px rgba(0, 0, 0, 0.45);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, "SF Pro JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg-grad);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.title-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 10px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.badge-pill {
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--panel-bg-2);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.dcp-pill {
  border-color: rgba(255, 148, 82, 0.35);
  color: #ff9452;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.dcp-pill:hover {
  border-color: rgba(255, 148, 82, 0.7);
  background: rgba(255, 148, 82, 0.08);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 0.85fr 1.15fr;
  gap: 14px;
  padding: 10px 28px 28px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  position: relative;
}

.panel {
  background: var(--panel-bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 操作エリア(観光地/アクション選択) = 凸(浮き出た)ニューモーフィズム。「触るところ」 */
.spot-panel,
.action-panel {
  box-shadow: -8px -8px 18px rgba(255, 255, 255, 0.035), 8px 8px 22px rgba(0, 0, 0, 0.55);
}

/* 閲覧エリア(地図/結果) = 凹(沈んだ)ニューモーフィズム。「見るところ」 */
.map-panel,
.result-panel {
  background: #101014;
  box-shadow: inset -8px -8px 18px rgba(255, 255, 255, 0.025), inset 8px 8px 22px rgba(0, 0, 0, 0.65);
}

/* 選ぶ順を示す矢印コネクタ(凸のニューモーフィズム丸ボタン) */
.flow-arrow {
  position: absolute;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #18181f, #101014);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 148, 82, 0.9);
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: -5px -5px 10px rgba(255, 255, 255, 0.04), 5px 5px 16px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.flow-arrow-1 {
  /* 行の中央ではなく、パネル見出し(①②)の高さに固定で合わせる */
  left: 50%;
  top: 39px;
  transform: translate(-50%, -50%);
}

/* 地図(標高)と結果(運動量)を「同じ量の2つの見え方」として大きな枠で囲む。
   ラベルで説明しなくても伝わるよう、枠と=バッジだけで対応関係を示す。
   ＝は3Dルートと動画の間の継ぎ目にちょうど来るよう、固定座標ではなく
   グリッドの3列目として自動的に配置する(列比率が変わっても位置がズレない) */
.equivalence-frame {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr auto 1fr;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  border-radius: calc(var(--radius-lg) + 10px);
  border: 1px solid rgba(255, 148, 82, 0.22);
  background: rgba(255, 148, 82, 0.025);
}

.equals-badge {
  position: static;
  align-self: center;
  justify-self: center;
  width: 46px;
  height: 46px;
  font-size: 1.5rem;
  color: #ff9452;
  box-shadow: -5px -5px 10px rgba(255, 255, 255, 0.04), 5px 5px 16px rgba(0, 0, 0, 0.6), 0 0 18px rgba(255, 148, 82, 0.35);
}

@media (max-width: 720px) {
  .flow-arrow-1 {
    display: none;
  }
  .equivalence-frame {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  flex: none;
}

.panel-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.8rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--panel-bg-2);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, transform 0.1s;
}

.share-button:hover {
  border-color: rgba(255, 148, 82, 0.5);
  color: #ff9452;
  transform: translateY(-1px);
}

.share-button.hidden {
  display: none;
}

.step-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted-2);
}

/* 共通スクロールバー */
.spot-list::-webkit-scrollbar,
.action-grid::-webkit-scrollbar { width: 6px; }
.spot-list::-webkit-scrollbar-thumb,
.action-grid::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

/* --- 観光地: 縦積みのリスト表示 --- */
.spot-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.spot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  box-shadow: -4px -4px 8px rgba(255, 255, 255, 0.03), 4px 4px 10px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.15s, transform 0.1s, color 0.15s;
}

.spot-item:hover {
  transform: translateY(-1px);
  box-shadow: -5px -5px 10px rgba(255, 255, 255, 0.04), 5px 5px 12px rgba(0, 0, 0, 0.5);
}

.spot-item-icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 0.85rem;
}

.spot-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.spot-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-item-pref {
  font-size: 0.68rem;
  color: var(--muted-2);
}

.spot-item.selected {
  background: var(--panel-bg);
  color: #ff9452;
  font-weight: 600;
  box-shadow: inset -4px -4px 8px rgba(255, 255, 255, 0.03), inset 4px 4px 12px rgba(0, 0, 0, 0.6);
}

.spot-item.selected .spot-item-pref {
  color: rgba(255, 148, 82, 0.6);
}

.spot-item.selected .spot-item-icon {
  background: rgba(255, 148, 82, 0.15);
}

/* --- アクション: アイコンタイルのグリッド表示 --- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  align-content: flex-start;
}

.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  cursor: pointer;
  color: var(--text);
  text-align: center;
  box-shadow: -5px -5px 10px rgba(255, 255, 255, 0.03), 5px 5px 14px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.15s, transform 0.1s;
}

.action-tile:hover {
  transform: translateY(-2px);
}

.action-tile-icon {
  font-size: 1.3rem;
}

.action-tile-name {
  font-size: 0.66rem;
  line-height: 1.25;
  color: var(--muted);
}

.action-tile.selected {
  background: var(--panel-bg);
  box-shadow: inset -5px -5px 10px rgba(255, 255, 255, 0.03), inset 5px 5px 14px rgba(0, 0, 0, 0.6);
}

.action-tile.selected .action-tile-name {
  color: #ff9452;
  font-weight: 700;
}

.map-panel {
  padding: 0;
  position: relative;
}

/* 全国MAPと詳細3Dを横並びで常時同時表示する */
.map-split {
  display: flex;
  flex: 1;
  min-height: 0;
}

.map-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.map-pane + .map-pane {
  border-left: 1px solid var(--border);
}

.map-pane-label {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 500;
  background: rgba(10, 10, 13, 0.7);
  backdrop-filter: blur(4px);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  pointer-events: none;
  width: fit-content;
  max-width: calc(100% - 20px);
}

.map-pane-label small {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--muted-2);
  margin-top: 2px;
  line-height: 1.3;
}

.map-pane-body {
  position: absolute;
  inset: 0;
}

.terrain3d-container {
  position: absolute;
  inset: 0;
}

.terrain3d-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.terrain3d-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
  background: rgba(10, 10, 13, 0.4);
  pointer-events: none;
}

.terrain3d-loading.hidden {
  display: none;
}

.map-overlay-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 500;
  max-width: calc(100% - 20px);
  background: rgba(10, 10, 13, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  line-height: 1.5;
  pointer-events: none;
}

.map-overlay-label.hidden {
  display: none;
}

.result-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  position: relative;
  overflow: hidden;
}

.result-video-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

.result-video-wrap.hidden {
  display: none;
}

.result-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-box {
  flex: none;
  max-height: 42%;
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 2px 6px;
  color: var(--muted);
  overflow-y: auto;
}

.result-box.hidden {
  display: none;
}

.result-box.filled {
  color: var(--text);
  font-weight: 500;
}

/* 動画に重ねる、一番伝えたい数値を「どーん」と見せるバッジ */
.highlight-chip {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  padding: 14px;
  background: radial-gradient(ellipse at center, rgba(10, 10, 13, 0.55) 0%, rgba(10, 10, 13, 0.15) 65%, transparent 100%);
  pointer-events: none;
}

.highlight-chip.hidden {
  display: none;
}

.highlight-chip .chip-spot {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.highlight-chip .chip-equals {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: #ff9452;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.highlight-chip .chip-value {
  display: block;
  font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  line-height: 1;
  color: #fff;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(255, 148, 82, 0.55), 0 4px 18px rgba(0, 0, 0, 0.85);
  animation: chip-value-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.highlight-chip .chip-value.landed {
  animation: chip-value-land 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes chip-value-land {
  0% {
    transform: scale(1);
    text-shadow: 0 0 30px rgba(255, 148, 82, 0.55), 0 4px 18px rgba(0, 0, 0, 0.85);
  }
  35% {
    transform: scale(1.16);
    text-shadow: 0 0 60px rgba(255, 148, 82, 1), 0 4px 18px rgba(0, 0, 0, 0.85);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 30px rgba(255, 148, 82, 0.55), 0 4px 18px rgba(0, 0, 0, 0.85);
  }
}

.highlight-chip .chip-value small {
  font-size: 0.34em;
  font-weight: 700;
  margin-left: 0.15em;
  color: #ffd8b8;
}

@keyframes chip-value-pop {
  0% {
    opacity: 0;
    transform: scale(0.55);
  }
  70% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- MapLibre GL dark theme overrides --- */
.maplibregl-popup-content {
  background: var(--panel-bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--glow);
  font-size: 0.82rem;
  padding: 10px 12px;
}

.maplibregl-popup-tip {
  border-top-color: var(--panel-bg-2) !important;
  border-bottom-color: var(--panel-bg-2) !important;
}

.maplibregl-popup-close-button {
  color: var(--muted);
}

.maplibregl-ctrl-group {
  background: var(--panel-bg-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
}

.maplibregl-ctrl-group button:hover {
  background: var(--border-strong) !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(19, 19, 24, 0.75) !important;
  color: var(--muted-2) !important;
  border-radius: var(--radius-md) 0 0 0 !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--muted) !important;
}

.map-marker {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
  cursor: pointer;
}

.map-marker-small {
  font-size: 1.15rem;
}

@media (max-width: 720px) {
  html, body {
    overflow-x: hidden;
    /* デスクトップは「1画面に収めて内部だけスクロール」の設計だが、
       モバイルでは要素を縦積みにするため、bodyの高さをビューポートに
       固定したままだと.gridがflex:1で圧縮され、中身がコンテナ外に
       はみ出す(グリッド行は縮まずコンテナだけ縮む)。ページ全体を
       自然にスクロールさせるため固定高さをやめる */
    height: auto;
    min-height: 100%;
  }
  html {
    /* bodyの背景(グラデーション)はbody自身の高さぶんにしか広がらないため、
       iOS Safariのラバーバンドスクロールで下端を超えたときにhtml要素の
       (未指定=白)背景が見えてしまっていた。htmlにも同系色の背景を敷いておく */
    background: var(--bg);
  }
  .title-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 16px 8px;
  }
  .header-badges {
    flex-wrap: wrap;
    width: 100%;
  }
  .dcp-pill {
    white-space: normal;
  }
  .grid {
    flex: none;
    grid-template-columns: 1fr;
    /* equivalence-frameが base CSSで grid-row:2 に固定されているため、
       1列レイアウトでは3行目に明示的に逃がさないとaction-panelと重なる */
    grid-template-rows: auto auto auto;
    padding: 10px 14px 20px;
  }
  .equivalence-frame {
    grid-row: 3;
  }
  /* .gridがflex:noneで自然高さになったぶん、リストが無制限に伸びて
     ページが極端に長くならないよう、パネル単位では従来どおり内部スクロールにする */
  .spot-panel,
  .action-panel {
    max-height: 300px;
  }
  /* 一番見せたいのは映像+どーん演出(.result-panel)。地図と3Dは「参考情報」の
     位置づけでよいので横並びのまま小さくまとめ、動画までの距離を縮めて
     ほぼ1画面で「地図/3D(小)+映像(主役)」が見えるようにする */
  .map-panel { min-height: 160px; }
  .map-pane-label {
    font-size: 0.62rem;
  }
  .map-pane-label small {
    display: none;
  }
  /* 地図パネルが小さくなり、下部に重ねていたラベルが2ペインにまたがって
     邪魔になるため非表示に(同じ内容は下の結果パネルに大きく出ている) */
  .map-overlay-label {
    display: none;
  }
  /* パネル見出しが「…」で省略されて読めなくなるのを防ぎ、折り返して全文読めるようにする */
  .panel-head {
    align-items: flex-start;
  }
  .panel-head h2 {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.3;
  }
  /* 一番の見せ場(動画+どーん演出)が動画の縦横比なりの高さしかなく小さく見えて
     しまっていたのを、地図パネルと同じ高さを確保して主役として見せる */
  .result-panel {
    min-height: 420px;
  }
}

/* --- 初回訪問時に出す「これは何のサイトか」の説明モーダル --- */
.intro-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 5, 7, 0.72);
  backdrop-filter: blur(6px);
}

.intro-modal.hidden {
  display: none;
}

.intro-modal-card {
  max-width: 480px;
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.intro-modal-icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.intro-modal-card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.intro-modal-card p {
  margin: 0 0 14px;
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--muted);
}

.intro-modal-card p strong {
  color: #ff9452;
}

.intro-modal-note {
  font-size: 0.85rem !important;
}

.intro-modal-note a {
  color: #ff9452;
}

.intro-modal-close {
  margin-top: 6px;
  border: none;
  background: linear-gradient(145deg, #ff9452, #e57a38);
  color: #1a0d05;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}

.intro-modal-close:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 148, 82, 0.35);
}
