:root {
  --blue: #2b65f5;
  --blue-press: #1f51d6;
  --blue-soft: #ebf1ff;
  --ink: #191f28;
  --sub: #6b7684;
  --faint: #8b95a1;
  --field: #f2f4f6;
  --line: #e5e8eb;
  --error: #e5484d;
  --heading: 'IBM Plex Sans KR', 'Pretendard', sans-serif;
  --body: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  --pad: 24px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #fff; }
body { font-family: var(--body); color: var(--ink); font-size: 16px; line-height: 1.55; }
button { font: inherit; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 2; background: #fff; height: 56px; display: flex; align-items: center; padding: 0 12px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; color: var(--ink); border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: var(--field); }
.step { margin: 0 0 0 auto; padding-right: 12px; font-size: 14px; color: var(--faint); font-variant-numeric: tabular-nums; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--field); }
#bar-fill { height: 100%; width: 0; background: var(--blue); transition: width .35s ease; }

/* 본문 */
main { flex: 1; padding: 20px var(--pad) 140px; }
.enter { animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .enter { animation: none; } #bar-fill { transition: none; } }

h1 { font-family: var(--heading); font-size: 28px; line-height: 1.4; font-weight: 700; margin: 24px 0 12px; letter-spacing: -0.02em; }
h2 { font-family: var(--heading); font-size: 22px; line-height: 1.45; font-weight: 700; margin: 4px 0 8px; letter-spacing: -0.02em; word-break: keep-all; }
.lead { font-size: 17px; color: var(--sub); margin: 0; word-break: keep-all; }
.section { font-size: 15px; font-weight: 600; color: var(--blue); margin: 8px 0 0; }
.help { font-size: 15px; color: var(--sub); margin: 0; word-break: keep-all; }
.optional { color: var(--faint); font-weight: 600; }
.note { background: var(--field); border-radius: 14px; padding: 14px 16px; font-size: 14px; color: var(--sub); margin: 20px 0 0; word-break: keep-all; }

/* 시작 화면 정보 */
.facts { list-style: none; padding: 0; margin: 40px 0 0; display: grid; gap: 20px; }
.facts li { display: flex; align-items: center; gap: 14px; font-size: 16px; }
.facts .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex: none; }
.facts b { display: block; font-weight: 600; }
.facts span { color: var(--sub); font-size: 14px; }

/* 선택지 */
.options { margin-top: 28px; display: grid; gap: 10px; }
.opt { width: 100%; min-height: 58px; text-align: left; border: 0; border-radius: 14px; background: var(--field); color: var(--ink); padding: 15px 16px; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background .12s ease, color .12s ease, transform .08s ease; word-break: keep-all; }
.opt:active { transform: scale(.985); }
.opt .mark { margin-left: auto; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid #d1d6db; display: grid; place-items: center; }
.opt.multi .mark { border-radius: 6px; }
.opt[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.opt[aria-pressed="true"] .mark { background: var(--blue); border-color: var(--blue); }
.opt .mark svg { opacity: 0; }
.opt[aria-pressed="true"] .mark svg { opacity: 1; }

.field { width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: var(--field); border: 2px solid transparent; border-radius: 14px; padding: 15px 16px; margin-top: 10px; }
.field:focus { outline: none; border-color: var(--blue); background: #fff; }
textarea.field { min-height: 132px; resize: none; margin-top: 28px; line-height: 1.55; }
.error { color: var(--error); font-size: 14px; margin: 10px 2px 0; }

/* 하단 고정 버튼 */
.cta-area { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom)); background: #fff; }
.cta { display: block; width: 100%; max-width: 432px; margin: 0 auto; height: 56px; border: 0; border-radius: 16px; background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; cursor: pointer; transition: background .12s ease, transform .08s ease; }
.cta:active { background: var(--blue-press); transform: scale(.99); }
.cta:disabled { background: #d1d6db; color: #fff; cursor: default; transform: none; }
.cta.ghost { background: var(--field); color: var(--ink); }

/* 완료 화면 */
.done { text-align: center; padding-top: 72px; }
.done .check { width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; animation: pop .4s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.done .check.fail { background: var(--error); }

@media (min-width: 640px) {
  main { padding-top: 40px; }
  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
}
.result { padding-top: 32px; }
.result .facts { margin-top: 28px; }
.hero { display: block; width: 72%; max-width: 280px; height: auto; margin: 8px auto 0; }
.type-img { display: block; width: 60%; max-width: 240px; height: auto; margin: 0 auto 4px; }
.spinner { display: block; width: 48px; height: 48px; margin: 0 auto 20px; border-radius: 50%; border: 4px solid var(--blue-soft); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* 시작 화면 등장 효과 */
.pop { animation: pop-in .55s cubic-bezier(.2,1.4,.4,1) both, bob 3.2s ease-in-out .7s infinite; }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.rise { animation: rise .45s ease calc(var(--n) * 90ms) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pop, .rise { animation: none; } }

/* 결과: 동물 별명 아래 유형 이름 */
.result h1 { word-break: keep-all; margin-bottom: 4px; }
.type-name { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--blue); }

/* 넓은 화면: 회색 배경 위 휴대폰 크기 패널 */
@media (min-width: 640px) {
  html, body { background: var(--field); }
  .app { background: #fff; box-shadow: 0 8px 32px rgba(25, 31, 40, .08); }
  .cta-area { left: 50%; right: auto; width: 100%; max-width: 480px; transform: translateX(-50%); }
}
