:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #191919;
  --muted: #8b8b8b;
  --line: #ececec;
  --soft: #f6f6f6;
  --tint: #eef0ff;
  --primary: #5b5bd6;
  --primary-ink: #ffffff;
  --kakao: #fee500;
  --kakao-ink: #191600;
  --radius: 20px;
  --col: 440px;
  --side-ad: 160px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Gowun Dodum', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 70px; /* 모바일 하단 광고 자리 */
}
button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; }
.topbar { display: flex; justify-content: space-between; align-items: center; height: 44px; font-size: 13px; color: var(--muted); }
.topbar a { text-decoration: none; }

.layout {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding-block: 12px 24px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.app { width: 100%; max-width: var(--col); }

/* ---------- 광고 ---------- */
.ad { display: flex; align-items: center; justify-content: center; }
.ad-side {
  display: none;
  width: var(--side-ad);
  min-height: 600px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
}
.ad-bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .95);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.ad-placeholder {
  border: 2px dashed #cfc6ef;
  color: #a79fc4;
  font-size: 12px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .ad-side { display: flex; }
  .ad-bottom { display: none; }
}

/* ---------- 공통 ---------- */
.card { padding: 28px 0; border-bottom: 1px solid var(--line); }
.card:last-of-type { border-bottom: 0; }
.center { text-align: center; }
h1 { font-size: 26px; line-height: 1.3; margin: 8px 0 10px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.btn {
  display: block; width: 100%;
  padding: 16px;
  border: 0; border-radius: 12px;
  background: var(--primary); color: var(--primary-ink);
  font-size: 17px;
  margin-top: 10px;
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--soft); color: var(--text); }
.btn.kakao { background: var(--kakao); color: var(--kakao-ink); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; font-size: 15px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.ic { display: inline-block; user-select: none; -webkit-user-select: none; }
.hero { position: relative; height: 220px; margin-top: 4px; border-radius: 20px; background: var(--tint); overflow: hidden; }
.hero .ic { position: absolute; }
.hero .h0 { width: 128px; height: 128px; font-size: 100px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.hero .h1, .hero .h2, .hero .h3, .hero .h4 { width: 56px; height: 56px; font-size: 44px; }
.hero .h1 { left: 9%; top: 14%; transform: rotate(-12deg); }
.hero .h2 { right: 9%; top: 12%; transform: rotate(10deg); }
.hero .h3 { left: 13%; bottom: 12%; transform: rotate(8deg); }
.hero .h4 { right: 12%; bottom: 14%; transform: rotate(-8deg); }
.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit; font-size: 16px;
  margin-top: 18px;
  outline: none;
}
.input:focus { border-color: var(--text); }

.invite {
  background: var(--tint);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 15px;
}
.invite .em { width: 44px; height: 44px; font-size: 34px; flex: none; }

/* ---------- 퀴즈 ---------- */
.progress { height: 3px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s ease; }
.q-meta { display: flex; justify-content: space-between; margin: 10px 0 26px; font-size: 13px; color: var(--muted); }
.q-text { font-size: 23px; text-align: center; min-height: 96px; display: flex; align-items: center; justify-content: center; margin: 0 0 24px; word-break: keep-all; }
.scale { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.scale button {
  border-radius: 50%;
  border: 3px solid;
  background: transparent;
  padding: 0;
  transition: transform .1s, background .15s;
}
.scale button:active { transform: scale(.92); }
.scale .s2 { width: 54px; height: 54px; }
.scale .s1 { width: 44px; height: 44px; }
.scale .s0 { width: 34px; height: 34px; }
.scale .agree { border-color: #5b5bd6; }
.scale .agree:hover, .scale .agree.on { background: #5b5bd6; }
.scale .neutral { border-color: #c4c4c4; }
.scale .neutral:hover, .scale .neutral.on { background: #c4c4c4; }
.scale .disagree { border-color: #ff8a65; }
.scale .disagree:hover, .scale .disagree.on { background: #ff8a65; }
.scale-labels { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-top: 10px; }
.scale-labels span:first-child { color: #5b5bd6; }
.scale-labels span:last-child { color: #ff8a65; }

/* ---------- 결과 ---------- */
.char-badge {
  width: 150px; height: 150px;
  margin: 8px auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 82px;
}
.char-badge { width: 180px; height: 180px; }
.char-badge .ic { width: 116px; height: 116px; font-size: 92px; line-height: 116px; animation: pop .4s ease; }
.char-badge.small-badge { width: 120px; height: 120px; }
.char-badge.small-badge .ic { width: 76px; height: 76px; font-size: 60px; line-height: 76px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.type-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 14px;
  color: #fff;
}
.hidden-pill { background: #191919; }
.char-name { font-size: 32px; margin: 10px 0 2px; }
.char-tag { color: var(--muted); margin: 0 0 14px; }
.keys { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.keys span { background: var(--soft); color: #555; padding: 4px 10px; border-radius: 8px; font-size: 13px; }
.desc { word-break: keep-all; }

.bars { margin-top: 6px; }
.bar { margin: 14px 0; }
.bar-labels { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.bar-labels .dim { color: var(--muted); font-weight: 500; }
.bar-track { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; border-radius: 99px; }

.compat-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 4px; }
.compat-head .who { text-align: center; width: 110px; font-size: 13px; }
.compat-head .who .em { width: 64px; height: 64px; font-size: 52px; display: block; margin: 0 auto 4px; }
.compat-head .heart .ic { width: 32px; height: 32px; font-size: 26px; }
.score { font-size: 48px; color: var(--primary); margin: 4px 0 0; }
.score-label { font-size: 18px; margin-bottom: 14px; }
.compat-list { list-style: none; padding: 0; margin: 0; text-align: left; }
.compat-list li { padding: 10px 0; border-top: 1px solid var(--line); word-break: keep-all; font-size: 15px; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match { background: var(--soft); border-radius: 16px; padding: 12px; text-align: center; font-size: 13px; }
.match .em { width: 48px; height: 48px; font-size: 38px; display: block; margin: 0 auto 4px; }
.match b { display: block; font-size: 14px; }

/* ---------- 도감 ---------- */
.dex { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dex-item {
  background: var(--soft);
  border: 0;
  border-radius: 14px;
  padding: 10px 4px;
  text-align: center;
  font-size: 12px;
  color: var(--text);
}
.dex-item .em { width: 38px; height: 38px; font-size: 30px; display: block; margin: 0 auto 2px; }
.dex-item small { color: var(--muted); display: block; font-size: 10px; }
.dex-item.mine { outline: 2.5px solid var(--primary); }

.toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: #191919; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.fade-in { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 동료 유형 직접 고르기 ---------- */
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 10px; }
.type-btn, .seg button, .chip {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 12px; padding: 10px 0; font-size: 14px; font-weight: 700; cursor: pointer;
}
.type-btn.on, .seg button.on { border-color: var(--primary); background: var(--tint); color: var(--primary); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { font-weight: 600; font-size: 13px; }
.small { font-size: 12px; margin: 6px 0 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.history { margin-top: 16px; text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 12px; border-radius: 99px; font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.chip .em { width: 18px; height: 18px; font-size: 15px; }
.chip b { color: var(--primary); }

/* ---------- 다른 콘텐츠 ---------- */
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.more-card, .more-wide { background: var(--soft); border-radius: 16px; text-decoration: none; color: var(--text); }
.more-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 8px 16px; text-align: center; }
.more-card .em { width: 52px; height: 52px; font-size: 42px; margin-bottom: 6px; }
.more-card b { font-size: 15px; }
.more-card small, .more-wide small { color: var(--muted); font-size: 12px; word-break: keep-all; }
.more-wide { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-top: 8px; text-align: left; }
.more-wide .em { width: 40px; height: 40px; font-size: 32px; flex: none; }
.more-wide b { display: block; font-size: 15px; }
.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 8px 0 20px; }

/* ---------- 글씨: 제목, 버튼, 이름은 둥근 Jua (굵기 하나라 400) ---------- */
h1, h2, h3, .btn, .q-text, .char-name, .score, .score-label, .type-btn, .more-card b, .more-wide b, .compat-head b, .match b, .type-pill {
  font-family: 'Jua', 'Gowun Dodum', sans-serif; font-weight: 400; letter-spacing: 0;
}
.btn.ghost { font-family: inherit; }
h1 { font-size: 30px; }
h3 { font-size: 17px; }
