:root {
  --bg: #0b0d13;
  --ink: #e8eaf0;
  --muted: #878da0;
  --hairline: rgba(255, 255, 255, 0.08);
  --amber: #f0b35e;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header { grid-area: title; text-align: center; }

h1 {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 650;
  letter-spacing: -0.01em;
}
h1 .accent { color: var(--ink); }
h1 .dot { color: var(--amber); }

/* モバイル(既定): 1カラムの縦並び。grid-template-areas で順序を定義 */
main {
  width: min(1040px, 94vw);
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* 1fr(=minmax(auto,1fr))だと幅広の子要素で横に膨らむため最小0 */
  grid-template-areas:
    "title"
    "map"
    "send"
    "phrase";
  gap: 18px;
  padding: 40px 0;
}

.map-wrap {
  grid-area: map;
  position: relative;
  width: min(640px, 100%);
  margin: 0 auto;
}

#map {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
  touch-action: pan-y; /* 横スワイプは回転、縦はページスクロール */
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #14171f;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  transform: translate(-50%, -115%);
  z-index: 5;
}
.tooltip .tt-phrase { color: var(--amber); font-size: 13px; }
.tooltip .tt-muted { color: var(--muted); }
.tooltip .tt-city { font-weight: 600; }

.send-btn {
  grid-area: send;
  justify-self: center;
  margin-top: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #c2c7d4;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 12px 26px;
  cursor: pointer;
  touch-action: manipulation; /* 連打時のダブルタップズームを抑止(ピンチズームは生きる) */
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.send-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.send-btn:active { transform: translateY(1px); }

/* フレーズ表示枠: 送信前はイントロ文、送信後はフレーズカードに置き換わる。
   min-height をカードと揃えて、入れ替え時のレイアウトシフトを防ぐ */
.phrase-slot {
  grid-area: phrase;
  min-height: 122px;
  text-align: center;
}

.phrase-intro {
  color: var(--muted);
  font-size: 13px;
  line-height: 2.1;
  letter-spacing: 0.04em;
  padding-top: 14px;
}

.phrase-card {
  padding-top: 4px;
  animation: rise 0.5s ease-out;
}
.phrase-main {
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.phrase-lang { color: var(--muted); font-size: 13px; margin-top: 10px; }
.phrase-city { font-size: 15px; font-weight: 600; margin-top: 6px; }
.phrase-time { color: var(--muted); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PC(2カラム): 左に地球儀、右にタイトル→フレーズ→送信ボタン。
   上下の空白行(1fr/1.3fr)で右カラムを地球儀の中心よりやや上に置く */
@media (min-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    grid-template-rows: 1fr auto auto auto 1.3fr;
    grid-template-areas:
      "map gap-top"
      "map title"
      "map phrase"
      "map send"
      "map gap-bottom";
    column-gap: 48px;
    row-gap: 16px;
    align-items: start;
    padding: 52px 0 56px;
  }

  .map-wrap { align-self: center; width: 100%; }
  header { text-align: left; }
  header h1 { font-size: clamp(26px, 2.4vw, 34px); }
  .phrase-slot { text-align: left; }
  .phrase-intro { padding-top: 6px; }
  .phrase-card { padding-top: 0; }
  .send-btn { justify-self: start; } /* 右カラム内では左寄せ */
}

/* 言語トグル(右上固定) */
.lang-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  z-index: 20;
}
.lang-switch button {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 6px 9px;
  cursor: pointer;
  touch-action: manipulation; /* ダブルタップズームを抑止 */
  transition: color 0.15s;
}
.lang-switch button + button { border-left: 1px solid var(--hairline); }
.lang-switch button:hover { color: var(--ink); }
.lang-switch button.active { color: var(--ink); }

/* モバイル: 送信ボタンを画面下部に固定 */
@media (max-width: 899px) {
  main { padding-bottom: 88px; } /* 固定ボタンと内容が重ならないよう下に余白を確保 */
  /* 縦が短い画面では地球儀を縮めて、イントロ文が固定ボタンに重ならないようにする。
     340px = タイトル・行間・フレーズ枠・ボタン余白ぶんの固定オーバーヘッド。
     svh(URLバー表示時の最小高さ)基準なのでスクロール中にサイズが揺れない。
     240px は下限(極端に低い画面では重なりよりサイズを優先) */
  .map-wrap { width: min(640px, 100%, max(calc(100svh - 340px), 240px)); }
  .send-btn {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    margin-top: 0;
    white-space: nowrap; /* fixed+left:50% だと利用幅が右半分に制限され折り返すため */
    z-index: 10;
  }
  .send-btn:active { transform: translateX(-50%) translateY(1px); } /* 固定時は中央寄せを保ったまま沈める */
}
