/* 浮気ラインMAP 共通スタイル（SPEC 11章／モックのデザインベース） */

:root {
  --ground: #FBF6F3;
  --card: #FFFFFF;
  --ink: #4A4545;
  --sub: #7A7272;
  --sub-dark: #5E5757;
  --pink: #F0AEC1;
  --pink-tint: #FBE6EC;
  --line: 2px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  /* 点の配色：自分＝ピンクの塗り＋白フチ＋チャコールの外枠／相手・友達＝白にピンクの太枠／住人＝白にチャコールの枠 */
  --dot-partner-border: 4px solid var(--pink);
  --r-card: 20px;
  --r-btn: 16px;
  --font: 'M PLUS Rounded 1c', sans-serif;
  --num: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
}

p, h1, h2 { margin: 0; }

a { color: var(--ink); text-underline-offset: 4px; }
a:hover { color: #2E2A2A; }

button, input { font-family: inherit; color: var(--ink); }

button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

[hidden] { display: none !important; }

.num { font-family: var(--num); }

/* ---- 画面の枠 ---- */

.app {
  max-width: 430px;
  margin: 0 auto;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 24px 28px;
  display: flex;
  flex-direction: column;
}

.spacer { flex-grow: 1; }

/* ---- 文字 ---- */

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--sub);
  letter-spacing: 0.04em;
}

.title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.4;
}

.lead {
  font-size: 15px;
  line-height: 1.7;
  color: var(--sub);
}

.label {
  font-size: 13px;
  font-weight: 700;
}

.small-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--sub);
}

/* ---- ボタン ---- */

.btn {
  min-height: 56px;
  border: var(--line);
  border-radius: var(--r-btn);
  background: var(--card);
  font-size: 16px;
  font-weight: 700;
  padding: 0 16px;
}

.btn-primary {
  min-height: 58px;
  background: var(--pink);
  font-size: 17px;
  box-shadow: var(--shadow);
}

.btn-primary:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn-primary:disabled {
  cursor: not-allowed;
  background: var(--pink-tint);
  box-shadow: none;
  opacity: 0.6;
}

/* 選択肢：通常は白、選択中は淡ピンク＋影 */
.opt[aria-pressed="true"] {
  background: var(--pink-tint);
  box-shadow: var(--shadow);
}

.opt-row {
  min-height: 58px;
  font-size: 17px;
  text-align: left;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.opt-row .check { display: none; flex-shrink: 0; }
.opt-row[aria-pressed="true"] .check { display: block; }

/* a 要素のボタン（Xの投稿画面、相性へのリンクなど） */
.btn-link,
.btn-x {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.link-btn {
  min-height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--sub);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.small-link { align-self: center; font-size: 13px; }
.start-self { align-self: flex-start; }

.link-strong {
  min-height: 44px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* 象限の淡い色（区画・入力欄・カードの地の色） */
.q-strict-body { background: #F8E3DE; }
.q-strict-mind { background: #ECE6F6; }
.q-loose-body { background: #F8F0DB; }
.q-loose-mind { background: #DDF0ED; }

/* ---- S0 トップ ---- */

.s0 { gap: 26px; }

.friend-banner {
  background: var(--pink-tint);
  border: var(--line);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
}

.s0-head { display: flex; flex-direction: column; gap: 12px; }

.title-xl {
  margin: 0;
  font-size: 44px;
  font-weight: 700;
  line-height: 1.2;
}

.s0-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.s0-map p {
  min-height: 78px;
  padding: 12px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.s0-meta {
  font-size: 15px;
  font-weight: 700;
  color: var(--sub-dark);
  text-align: center;
}
.s0-meta .num { font-size: 20px; }

.s0-honke {
  font-size: 13px;
  line-height: 1.8;
  color: var(--sub);
  text-align: center;
}
.s0-honke a { font-weight: 700; }

/* ---- S1 本家結果の入力 ---- */

.s1 { gap: 30px; }

.s1-head { display: flex; flex-direction: column; gap: 12px; }

.s1-nums { gap: 12px; }

.num-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.num-field { display: flex; flex-direction: column; gap: 8px; }

.num-field input {
  width: 100%;
  height: 68px;
  border: var(--line);
  border-radius: var(--r-btn);
  font-family: var(--num);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.num-field input::-webkit-outer-spin-button,
.num-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.sum {
  font-size: 13px;
  font-weight: 700;
  color: var(--sub-dark);
  min-height: 1.5em;
}

.sum.is-error { color: #A24F4F; }

.fieldset {
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
}

.fieldset legend { padding: 0; margin-bottom: 10px; }

/* 「どっちに変わる？」は文字が長いので、1行に収まる大きさにする */
.yaru-dir .btn { font-size: 14px; padding: 0 6px; white-space: nowrap; }

/* ---- S2・S3 設問 ---- */

.quiz,
.quiz .q-body { gap: 22px; }
.quiz.is-choice,
.quiz.is-choice .q-body { gap: 28px; }
.q-body { display: flex; flex-direction: column; }

.progress { display: flex; flex-direction: column; gap: 10px; }

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.progress-top .label { color: var(--sub); }

.progress-count { font-family: var(--num); font-size: 15px; font-weight: 700; flex-shrink: 0; }

.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--card);
  border: var(--line);
  overflow: hidden;
}

.bar > div {
  height: 100%;
  background: var(--pink);
  transition: width 0.2s;
}

.compare { display: flex; flex-direction: column; gap: 10px; }

.compare-card {
  border: var(--line);
  border-radius: var(--r-card);
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.compare-card .text { font-size: 19px; font-weight: 700; line-height: 1.5; }

.badge {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--num);
  font-size: 18px;
  font-weight: 700;
}

.compare-and {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--sub);
}

.compare-opts { gap: 10px; }
.compare-opts .btn { font-size: 15px; padding: 0 8px; }

.q-card {
  border: var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.q-card .q-no { font-family: var(--num); font-size: 15px; font-weight: 700; color: var(--sub-dark); }
.q-card .q-text { font-size: 24px; font-weight: 700; line-height: 1.55; }

.opt-list { display: flex; flex-direction: column; gap: 12px; }

/* ---- S4 結果 ---- */

.s4 { padding-top: 24px; gap: 18px; }

.result-head {
  border: var(--line);
  border-radius: 24px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}

.result-head .you { font-size: 13px; font-weight: 700; }
.result-head h1 { font-size: 30px; font-weight: 700; line-height: 1.3; }
.result-head .subtitle { margin-top: 6px; font-size: 13px; font-weight: 700; }
.result-head .comment { margin-top: 8px; font-size: 14px; line-height: 1.7; }

.minimap {
  position: relative;
  height: 230px;
  border: var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.minimap .axis {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
}

.minimap .axis-top { top: 8px; left: 0; right: 0; text-align: center; }
.minimap .axis-bottom { bottom: 8px; left: 0; right: 0; text-align: center; }
.minimap .axis-left { top: 50%; left: 10px; margin-top: -9px; }
.minimap .axis-right { top: 50%; right: 10px; margin-top: -9px; }

.map-wrap { position: relative; }

/* 住人の点：押しやすいよう 44px の透明なボタンの中に小さな丸 */
.residents { position: absolute; inset: 0; }

.resident {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.resident-face {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--ink);
  overflow: hidden;
}
.resident-face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.resident[aria-expanded="true"] .resident-face { box-shadow: 0 0 0 3px var(--pink); }

/* 友達リンクの相手：白の塗りにピンクの太枠 */
.resident.is-friend { z-index: 1; }
.resident.is-friend .resident-face { width: 30px; height: 30px; background: #FFFFFF; border: var(--dot-partner-border); }

.map-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #A24F4F;
}

.map-hint {
  margin-top: -8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--sub);
  text-align: center;
}

/* 吹き出し：名前・X／YouTube・相性を見る */
.balloon {
  position: absolute;
  z-index: 10;
  min-width: 190px;
  max-width: min(280px, 100%);
  background: var(--card);
  border: var(--line);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow);
  padding: 10px 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.balloon::after {
  content: '';
  position: absolute;
  left: var(--tail-x, 50%);
  bottom: -8px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: var(--card);
  border-right: var(--line);
  border-bottom: var(--line);
  transform: rotate(45deg);
}
.balloon.is-below::after { bottom: auto; top: -8px; transform: rotate(225deg); }

.balloon-name {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.balloon-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

.btn-small {
  min-height: 44px;
  border: var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 13px;
  font-weight: 700;
}

.balloon-go {
  margin-left: auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  text-decoration: none;
  background: var(--pink);
  white-space: nowrap;
}

/* 住人の X・YouTube（タップ領域 44px） */
.person-links { display: flex; align-items: center; }
.person-link {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border-radius: 12px;
}
.person-link:hover { background: var(--pink-tint); }

.dot-me {
  z-index: 2;
  pointer-events: none; /* 下にいる住人を押せるように */
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: var(--pink);
  border: 3px solid #FFFFFF;
  box-shadow: 0 0 0 2px var(--ink);
}

.trait-grid { gap: 10px; }

.trait {
  background: var(--card);
  border: var(--line);
  border-radius: var(--r-btn);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trait .value { font-size: 16px; font-weight: 700; }

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

.icon-pick {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px dashed var(--ink);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.icon-pick img { width: 100%; height: 100%; object-fit: cover; }

.identity-field { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; }

.text-input {
  width: 100%;
  height: 44px;
  border: var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 0 14px;
  font-size: 16px;
}

.actions { display: flex; flex-direction: column; gap: 12px; }

.share-url { font-size: 13px; }

.status {
  font-size: 13px;
  font-weight: 700;
  color: var(--sub-dark);
  text-align: center;
  min-height: 1.5em;
}

/* 配信運用用（小さく） */
.ops {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px dashed #D9CFCB;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ops-row { display: flex; gap: 8px; }

.ops-input {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  border-radius: 12px;
}

.ops-row .btn-small.ops-open { flex: 0 0 auto; padding: 0 14px; }

.ops-row .btn-small { flex: 1; }

/* ---- S5 相性 ---- */

.s5 { padding-top: 20px; gap: 18px; }

.back-link {
  align-self: flex-start;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
}

.s5-main, .s5-empty, #result { display: flex; flex-direction: column; gap: 18px; }
.s5-main[hidden], .s5-empty[hidden], #result[hidden] { display: none; }

.chips-wrap { display: flex; flex-direction: column; gap: 8px; }

/* 人数が増えたら横にスクロール */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px 6px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--card);
  border: var(--line);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip.is-friend { background: var(--pink-tint); }
.chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; margin-left: -8px; }
.chip[aria-pressed="true"] { background: var(--pink); }

/* 相性カードは白（ピンク寄りだと、相手の丸のピンクの枠が見えにくい。SPEC 11章 点の色） */
.match-head {
  background: var(--card);
  border: var(--line);
  border-radius: 24px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.pair { display: flex; align-items: center; }

.pair-me, .pair-you {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
}
.pair-me { background: var(--pink); border: 3px solid #FFFFFF; box-shadow: 0 0 0 2px var(--ink); position: relative; z-index: 1; }
.pair-you { background: #FFFFFF; border: var(--dot-partner-border); margin-left: -12px; }
.pair img { display: block; width: 100%; height: 100%; object-fit: cover; }

.match-who { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; column-gap: 2px; }
.match-who .person-links { margin: -8px 0; }

.map-note-inline { font-size: 13px; font-weight: 700; color: #A24F4F; }

.match-caption { font-size: 13px; font-weight: 700; color: var(--sub-dark); }
.match-score { font-size: 84px; font-weight: 700; line-height: 1; }
.match-label { font-size: 18px; font-weight: 700; }

.breakdown {
  background: var(--card);
  border: var(--line);
  border-radius: var(--r-card);
  padding: 2px 18px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  font-size: 14px;
}
.breakdown-row + .breakdown-row { border-top: 1px solid #E8DEDA; }
.breakdown-row .num { font-weight: 700; flex-shrink: 0; }

.match-comment { font-size: 15px; line-height: 1.7; color: var(--sub-dark); }

/* ---- フッター（出典表記） ---- */

.credit {
  padding: 16px 24px 28px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--sub);
  text-align: center;
}

/* ---- 配信用マップ（obs.html、1920×1080固定） ---- */

.obs-body {
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  background: transparent;
}

.obs {
  position: relative;
  width: 1920px;
  height: 1080px;
  padding: 48px 56px;
  background: linear-gradient(150deg, #FDF3EC 0%, #F6D9DE 100%);
  display: flex;
  gap: 48px;
  transform-origin: 0 0;
}

.obs-side { display: flex; flex-direction: column; gap: 16px; }
.obs-left { width: 420px; flex-shrink: 0; }
.obs-right { flex-grow: 1; }

.obs-tag { font-size: 22px; font-weight: 700; color: var(--sub); }
.obs-title { margin: 0; font-size: 64px; font-weight: 700; line-height: 1.15; }

/* 立ち絵エリア：配信では何も描かない。?guide=1 のときだけ点線で示す */
.obs-stand {
  flex-grow: 1;
  border: 3px dashed transparent;
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--sub);
}
.obs-left .obs-stand { margin-top: 16px; }
.obs-stand span { visibility: hidden; }
.obs.is-guide .obs-stand { border-color: var(--ink); }
.obs.is-guide .obs-stand span { visibility: visible; }

.obs-map {
  position: relative;
  width: 984px;
  flex-shrink: 0;
  border: 4px solid var(--ink);
  border-radius: 40px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  box-shadow: 10px 10px 0 var(--ink);
}

.obs-axis { position: absolute; font-size: 26px; font-weight: 700; }
.obs-axis-top { top: 20px; left: 0; right: 0; text-align: center; }
.obs-axis-bottom { bottom: 20px; left: 0; right: 0; text-align: center; }
.obs-axis-left { top: 50%; left: 24px; margin-top: -20px; }
.obs-axis-right { top: 50%; right: 24px; margin-top: -20px; }

.obs-pill {
  position: absolute;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 16px;
}

/* 四隅の象限名（色は scoring.js の QUADRANTS と同じ） */
.pill-tl { top: 20px; left: 24px; background: #E8A79A; }
.pill-tr { top: 20px; right: 24px; background: #B9A8DC; }
.pill-bl { bottom: 20px; left: 24px; background: #E8CD8A; }
.pill-br { bottom: 20px; right: 24px; background: #8FCBC4; }

/* 点の置き場。格子の1マスを取らないよう、マップ全体に重ねる */
#obs-dots { position: absolute; inset: 0; }

/* 点：中心が (left, top) に来るように置く */
.obs-marker {
  position: absolute;
  width: 0;
  height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.obs-face {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  margin-top: -38px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 4px solid var(--ink);
  overflow: hidden;
}

.obs-face img { display: block; width: 100%; height: 100%; object-fit: cover; }

.obs-name {
  margin-top: 6px;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 700;
  background: #FFFFFF;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
}

/* 名前もアイコンもない人は小さい白丸だけ */
.obs-marker.is-plain .obs-face { width: 26px; height: 26px; margin-top: -13px; border-width: 3px; }

/* 今回の人（NEW）：大きく、自分の点の配色（ピンクの塗り＋白フチ＋チャコールの外枠） */
.obs-marker.is-new { z-index: 2; }
.obs-marker.is-new .obs-face {
  width: 108px;
  height: 108px;
  margin-top: -54px;
  background: var(--pink);
  border: 6px solid #FFFFFF;
  box-shadow: 0 0 0 4px var(--ink);
}
.obs-marker.is-new .obs-name {
  margin-top: 10px;
  font-size: 22px;
  background: var(--pink);
  padding: 4px 14px;
}

.obs-count {
  background: #FFFFFF;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.obs-count-label { font-size: 18px; font-weight: 700; color: var(--sub); }
.obs-count-num { font-family: var(--num); font-size: 52px; font-weight: 700; line-height: 1; }

.obs-error {
  position: absolute;
  left: 56px;
  bottom: 16px;
  font-size: 18px;
  font-weight: 700;
  color: #A24F4F;
}
