/*
 * ===== スクラッチモンスターへの誘導（親ページ。src/free/views/guideViews.js） =====
 *
 *   ② ③ホームの帯のコインの「?」とカード（.tg-coinq / .tg-help）
 *   ③-b 迷っている子のところへ創くんが飛んでくる（.tg-so）。画面はふさがない（後ろの幕は無い）
 * 「ミッション → CLEAR! → コイン」のループと歩くキュン（.sm-ml / .sm-kyun）の見た目は shared/lib/monsterGuide.js が差し込む。
 * モック（ユーザー承認済み）: CoinHover・SoArrive。明るい世界観。動きを減らす設定では止める。
 * ⚠️ ルビを flex の直下に置かない（マークアップ側で span に包んである）。
 */

.sm-guide { font-family: var(--tf-font, 'M PLUS Rounded 1c', sans-serif); }
.tg-loop { display: flex; justify-content: center; }

/* ---------- 黄色い大きなボタン（ミッションへ） ---------- */

.tg-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  min-height: 54px;
  margin: 0 auto 6px;
  padding: 4px 18px;
  box-sizing: border-box;
  border: 0;
  border-radius: 28px;
  background: linear-gradient(180deg, #fff08a, #ffcf1f 60%, #f5b800);
  box-shadow: 0 0 0 3px #123a7a, 0 4px 0 3px #123a7a;
  color: #123a7a;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}
.tg-go:hover { filter: brightness(1.04); }
.tg-go:active { transform: translateY(3px); box-shadow: 0 0 0 3px #123a7a, 0 1px 0 3px #123a7a; }
.tg-go:focus-visible { outline: 3px solid var(--tf-blue-l, #5db2ff); outline-offset: 4px; }
.tg-go__kyun { width: 42px; height: 42px; }
.tg-go__chev { flex: 0 0 auto; }
.tg-go__text { min-width: 0; }
.tg-go rt, .tg-help rt, .tg-so rt { font-size: .5em; }

/* ---------- ② ③ホームの帯のコイン ---------- */

.tg-coinpill { cursor: pointer; }
.tg-coinq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--tf-blue, #2f86ea);
  box-shadow: 0 0 0 2px #fff;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
/* タッチでも押しやすく（見た目は小さいまま、押せる面を広げる） */
.tg-coinq { position: relative; }
.tg-coinq::after { content: ""; position: absolute; inset: -12px; }
.tg-coinq:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.tg-coinq[aria-expanded="true"] { background: var(--tf-yellow, #ffcf1f); color: var(--tf-navy, #123a7a); }

.tg-help {
  position: fixed;
  z-index: 1200;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 0 0 4px var(--tf-silver, #c9d3df), 0 0 0 5px var(--tf-silver-d, #8f9cad), 0 14px 30px rgba(18, 58, 122, .3);
  color: var(--tf-ink, #22303f);
  animation: tgPop .35s ease-out both;
}
.tg-help::before {
  content: "";
  position: absolute;
  left: var(--tg-arrow, 50%);
  top: -12px;
  width: 20px;
  height: 20px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: -4px -4px 0 0 var(--tf-silver, #c9d3df);
}
@keyframes tgPop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.tg-help__title {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--tf-navy, #123a7a);
}
.tg-help__coin { width: 30px; height: 30px; }
.tg-help__text { margin: 0; font-size: 14px; font-weight: 800; line-height: 1.9; text-align: center; }

/* ---------- ③-b 創くんが来る ---------- */

.tg-so {
  position: absolute;
  top: 60px;
  right: 380px; /* JS が SO君パネル（畳んでいれば右端のタブ）の左に合わせ直す */
  z-index: 40;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.tg-so__bubble {
  position: relative;
  pointer-events: auto;
  flex: 0 1 640px;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
  padding: 18px 20px 20px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 0 0 4px var(--tf-silver, #c9d3df), 0 0 0 5px var(--tf-silver-d, #8f9cad), 0 16px 34px rgba(18, 58, 122, .28);
  animation: tgBubbleIn .5s ease-out .6s both;
}
.tg-so__bubble::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 64px;
  width: 26px;
  height: 26px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 4px -4px 0 0 var(--tf-silver, #c9d3df);
}
@keyframes tgBubbleIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.tg-so__title {
  align-self: center;
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  paint-order: stroke fill;
  -webkit-text-stroke: 5px var(--tf-navy, #123a7a);
  text-align: center;
}
.tg-so__title rt { -webkit-text-stroke-width: 2px; }
.tg-so__cards { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.tg-so__card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
}
.tg-so__card--mission {
  flex: 0 0 356px;
  max-width: 100%;
  padding: 14px 18px 16px;
  background: #fffbea;
  box-shadow: 0 0 0 3px var(--tf-yellow, #ffcf1f);
}
.tg-so__card--mission .tg-go { max-width: 316px; min-height: 52px; margin-bottom: 4px; }
.tg-so__card--free {
  flex: 1 1 180px;
  justify-content: space-between;
  padding: 14px;
  background: #f4f8fd;
  box-shadow: 0 0 0 2px var(--tf-line, #dde5ee);
}
.tg-so__label { margin: 0; font-size: 15px; font-weight: 900; color: var(--tf-navy, #123a7a); text-align: center; line-height: 1.8; }
.tg-so__art {
  position: relative;
  width: 190px;
  height: 190px;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--tf-line, #dde5ee);
}
.tg-so__art-stage { position: absolute; left: 12px; top: 12px; width: 166px; height: 110px; border-radius: 8px; background-size: cover; background-position: center; }
.tg-so__art-b { position: absolute; left: 20px; display: block; border-radius: 3px; }
.tg-so__art-b--1 { top: 132px; width: 110px; height: 18px; border-radius: 9px 9px 3px 3px; background: #ffbf00; }
.tg-so__art-b--2 { top: 152px; width: 130px; height: 14px; background: #4c97ff; }
.tg-so__art-b--3 { top: 168px; width: 90px; height: 14px; background: #9966ff; }
.tg-so__art-pen { position: absolute; right: 12px; bottom: 12px; }
.tg-stay {
  width: 190px;
  max-width: 100%;
  min-height: 48px;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 24px;
  background: #fff;
  color: var(--tf-navy, #123a7a);
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.tg-stay:hover { background: #f4f8fd; }
.tg-stay:focus-visible { outline: 3px solid var(--tf-blue-l, #5db2ff); outline-offset: 2px; }

/* 創くん（羽ばたき 2 コマ）。SO君パネルの側から横に飛んでくる */
.tg-so__char {
  flex: 0 0 170px;
  width: 170px;
  height: 170px;
  animation: tgSoIn 1s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes tgSoIn { from { transform: translateX(260px) rotate(8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.tg-so__bob { position: relative; width: 100%; height: 100%; animation: tgSoBob 1.8s ease-in-out infinite; }
@keyframes tgSoBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.tg-so__flap { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tg-so__flap--a { animation: tgFlapA .5s steps(1, end) infinite; }
.tg-so__flap--b { opacity: 0; animation: tgFlapB .5s steps(1, end) infinite; }
@keyframes tgFlapA { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes tgFlapB { 0% { opacity: 0; } 50% { opacity: 1; } }

/* 狭い画面（iPad 縦など）: 創くんを小さく、カードは縦に並ぶ */
@media (max-width: 1023px) {
  .tg-so { top: 52px; }
  .tg-so__char { flex-basis: 110px; width: 110px; height: 110px; }
  .tg-so__bubble { padding: 14px; }
  .tg-so__title { font-size: 20px; }
  .tg-so__card--mission { flex-basis: 100%; }
  .tg-so__card--free { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .tg-so__art { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tg-help, .tg-so__bubble, .tg-so__char, .tg-so__bob, .tg-so__flap--a, .tg-so__flap--b { animation: none; }
  .tg-so__flap--b { opacity: 0; }
}
