/* ============================================================
   ちいかわMBTI診断 スタイル
   ============================================================ */
:root {
  --sky-1: #84c9f0;
  --sky-2: #d8f0ff;
  --ink: #574a40;
  --ink-soft: #8a7a6c;
  --line: #7b6a5e;
  --card: #fffdf7;
  --yellow: #f9d976;
  --yellow-deep: #f2c94c;
  --pink: #f7b6c2;
  --green: #a5d98e;
  --radius: 26px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'BIZ UDGothic', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 70%, #e8f7ff 100%);
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- 背景（雲・草原・きらきら） ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.cloud {
  position: absolute;
  width: 120px; height: 42px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
}
.cloud::before { width: 52px; height: 52px; left: 18px; top: -24px; }
.cloud::after { width: 38px; height: 38px; right: 22px; top: -16px; }
.cloud.c1 { top: 8%; left: -140px; animation-duration: 58s; }
.cloud.c2 { top: 22%; left: -220px; transform: scale(0.72); animation-duration: 74s; animation-delay: -30s; }
.cloud.c3 { top: 55%; left: -180px; transform: scale(0.55); opacity: 0.8; animation-duration: 90s; animation-delay: -55s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 320px)); }
}
.cloud.c2 { animation-name: drift2; }
.cloud.c3 { animation-name: drift3; }
@keyframes drift2 {
  from { transform: scale(0.72) translateX(0); }
  to { transform: scale(0.72) translateX(calc(140vw + 380px)); }
}
@keyframes drift3 {
  from { transform: scale(0.55) translateX(0); }
  to { transform: scale(0.55) translateX(calc(190vw + 420px)); }
}

.ground {
  position: fixed;
  left: 50%; bottom: -140px;
  width: 160vw; height: 220px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--green), #8cc978);
  border-radius: 50% 50% 0 0;
  z-index: 0;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  color: #fff;
  font-size: 18px;
  animation: twinkle 2.6s ease-in-out infinite;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}
.sparkle.s1 { top: 14%; right: 12%; animation-delay: 0.3s; }
.sparkle.s2 { top: 34%; left: 8%; animation-delay: 1.2s; font-size: 13px; }
.sparkle.s3 { top: 6%; left: 28%; animation-delay: 2s; font-size: 15px; }

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.15) rotate(20deg); }
}

/* ---------- レイアウト ---------- */
main {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}

.view { display: none; }
.view.active { display: block; animation: fadeUp 0.45s ease both; }

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(88, 130, 160, 0.18);
}

/* ---------- 共通アバター（SVGサイズはここで一括指定） ---------- */
.avatar-frame svg { width: 100%; height: 100%; display: block; }
.avatar-frame .chara-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* タイプに2キャラいる場合の横並び表示（最大2人） */
.avatar-frame .duo {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 2%;
}
.avatar-frame .duo .chara-img,
.avatar-frame .duo svg {
  width: 49%;
  height: 88%;
  object-fit: contain;
}

/* ---------- スタート画面 ---------- */
.logo {
  text-align: center;
  margin: 18px 0 6px;
  line-height: 1.25;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 3px 0 rgba(90, 140, 175, 0.45);
  letter-spacing: 0.04em;
}
.logo .logo-main { display: block; font-size: 42px; }
.logo .logo-sub { display: block; font-size: 20px; opacity: 0.95; }

.start-copy {
  text-align: center;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(90, 140, 175, 0.4);
  margin-bottom: 18px;
}

#start-avatars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 20px;
}
#start-avatars .bob { width: 108px; height: 108px; }

.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.start-card { text-align: center; }
.start-card p { margin-bottom: 16px; font-weight: 700; }
.start-note { color: var(--ink-soft); font-size: 13px; margin-top: 14px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(3px); }

.btn-primary {
  background: linear-gradient(180deg, var(--yellow), var(--yellow-deep));
  box-shadow: 0 5px 0 #d9ae2f;
  font-size: 18px;
  padding: 16px 38px;
}
.btn-primary:active { box-shadow: 0 2px 0 #d9ae2f; }

.btn-ghost {
  background: #fff;
  border: 2.5px solid #e8ddcf;
  box-shadow: 0 4px 0 #e8ddcf;
}
.btn-ghost:active { box-shadow: 0 1px 0 #e8ddcf; }

.btn-block { width: 100%; margin-top: 12px; }

/* ---------- 診断画面 ---------- */
.quiz-head { margin-bottom: 14px; }
#q-count {
  display: block;
  text-align: center;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(90, 140, 175, 0.4);
  margin-bottom: 8px;
  font-size: 18px;
}
.bar {
  height: 14px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(90, 140, 175, 0.25);
}
#bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--yellow), var(--pink));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.quiz-card { text-align: center; }
#q-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
#q-text {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 20px;
  min-height: 3.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice {
  display: block;
  width: 100%;
  background: #fff;
  border: 3px solid #e8ddcf;
  border-radius: 20px;
  padding: 16px 18px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  margin-bottom: 12px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.choice:hover { border-color: var(--pink); transform: translateY(-2px); }
.choice.picked {
  background: #fdeef1;
  border-color: var(--pink);
  transform: scale(0.985);
}

.quiz-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.quiz-links button {
  background: none;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  text-shadow: 0 1px 0 rgba(90, 140, 175, 0.4);
  text-decoration: underline;
}

/* ---------- 判定中 ---------- */
.loading-card {
  text-align: center;
  padding: 60px 22px;
}
.loading-emoji { font-size: 56px; animation: spinBob 1.2s ease-in-out infinite; display: inline-block; }
@keyframes spinBob {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-10px) rotate(8deg); }
}
.loading-text { font-weight: 800; font-size: 18px; margin-top: 14px; }
.dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '・'; }
  50% { content: '・・'; }
  75% { content: '・・・'; }
}

/* ---------- 結果画面 ---------- */
.result-card { text-align: center; }
.result-headline { font-size: 17px; font-weight: 800; color: var(--ink-soft); }

.result-avatar {
  width: 170px; height: 170px;
  margin: 14px auto;
  border-radius: 50%;
  border: 4px solid;
  padding: 14px;
}

.type-pill {
  display: inline-block;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 999px;
  padding: 6px 20px;
  letter-spacing: 0.05em;
}

.result-name { font-size: 30px; font-weight: 800; margin-top: 10px; line-height: 1.3; }
.result-name .result-title {
  display: block;
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 700;
}

.result-catch { font-weight: 800; margin: 12px 0 8px; font-size: 16.5px; }
.result-desc { text-align: left; font-size: 14.5px; color: #6d5f53; }

.chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip {
  background: #fdeef1;
  color: #a86a75;
  font-weight: 800;
  font-size: 13px;
  border-radius: 999px;
  padding: 6px 16px;
}

.sec-title { font-size: 15px; font-weight: 800; margin: 22px 0 10px; }

/* 回答バランス */
.axis-box {
  background: #f7f3ea;
  border-radius: 18px;
  padding: 4px 14px 14px;
  margin-top: 18px;
}
.axis-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.axis-label {
  width: 64px;
  font-size: 12px;
  font-weight: 800;
  color: #b3a493;
  text-align: right;
  line-height: 1.2;
}
.axis-label.r { text-align: left; }
.axis-label small { display: block; font-size: 10px; }
.axis-label.win { color: var(--ink); }
.axis-track {
  position: relative;
  flex: 1;
  height: 18px;
  background: #fff;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(120, 100, 80, 0.18);
}
.axis-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd76e, #ffb3c1);
  border-radius: 999px 0 0 999px;
}
.axis-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #7c6c5c;
}

/* 相性キャラ */
.friend-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f2f8fd;
  border: 2.5px solid #dcebf6;
  border-radius: 18px;
  padding: 10px 14px;
  margin-top: 20px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease;
}
.friend-box:hover { transform: translateY(-2px); }
.friend-avatar {
  width: 62px; height: 62px;
  border-radius: 50%;
  padding: 6px;
  flex-shrink: 0;
}
.friend-text small { display: block; color: var(--ink-soft); font-weight: 700; font-size: 11.5px; }
.friend-text strong { font-size: 15.5px; }
.friend-arrow { margin-left: auto; font-size: 26px; color: #b7c9d8; font-weight: 800; }

/* シェアボタン */
.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.share-grid .btn { font-size: 14px; padding: 13px 10px; }
.share-x { background: #1b1f23; color: #fff; box-shadow: 0 4px 0 #000; }
.share-line { background: #06c755; color: #fff; box-shadow: 0 4px 0 #05a648; }
.share-copy { background: #fff; border: 2.5px solid #e8ddcf; box-shadow: 0 4px 0 #e8ddcf; }
.share-img { background: #fdeef1; border: 2.5px solid #f5c9d3; box-shadow: 0 4px 0 #f5c9d3; color: #a86a75; }
.share-native { grid-column: 1 / -1; background: #eef4fa; border: 2.5px solid #d5e5f2; box-shadow: 0 4px 0 #d5e5f2; color: #55708a; }

.result-actions { margin-top: 22px; display: grid; gap: 10px; }

/* ---------- 図鑑 ---------- */
.zukan-head {
  text-align: center;
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  text-shadow: 0 2px 0 rgba(90, 140, 175, 0.45);
  margin: 10px 0 4px;
}
.zukan-sub {
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 0 rgba(90, 140, 175, 0.4);
  margin-bottom: 14px;
}
.group-label {
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  text-shadow: 0 2px 0 rgba(90, 140, 175, 0.4);
  margin: 18px 4px 10px;
}
.zukan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}
.zukan-card {
  background: var(--card);
  border: none;
  border-radius: 20px;
  padding: 14px 8px 12px;
  box-shadow: 0 6px 16px rgba(88, 130, 160, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: transform 0.12s ease;
}
.zukan-card:hover { transform: translateY(-4px); }
.zukan-avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  padding: 8px;
}
.zukan-code {
  color: #fff;
  font-weight: 800;
  font-size: 11.5px;
  border-radius: 999px;
  padding: 2px 12px;
  letter-spacing: 0.06em;
}
.zukan-name { font-weight: 800; font-size: 13px; line-height: 1.3; }

.zukan-actions { margin-top: 22px; display: grid; gap: 10px; }

/* ---------- トースト ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(80px);
  background: rgba(60, 50, 42, 0.92);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 999px;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- 画像モーダル ---------- */
#img-modal {
  position: fixed;
  inset: 0;
  background: rgba(50, 60, 70, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
#img-modal.show { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: 22px;
  padding: 18px;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}
.modal-box h3 { font-size: 16px; margin-bottom: 10px; }
#share-preview {
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.modal-actions { display: grid; gap: 8px; margin-top: 12px; }
.modal-note { font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }

/* ---------- フッター ---------- */
footer a { color: #3d6a86; font-weight: 700; }

footer {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 20px 96px;
  text-align: center;
  color: #5c7d92;
  opacity: 0.85;
  font-size: 10.5px;
  line-height: 1.6;
}
footer p { margin: 0 0 4px; text-wrap: balance; }
footer .nowrap { white-space: nowrap; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 420px) {
  .logo .logo-main { font-size: 34px; }
  .result-catch { font-size: 14px; }
  #start-avatars .bob { width: 88px; height: 88px; }
  #q-text { font-size: 17px; }
  .share-grid .btn { font-size: 13px; padding: 12px 6px; }
  .zukan-grid { grid-template-columns: repeat(2, 1fr); }
}
