:root {
  --bg: #FFFFFF;
  --blue: #3F7FD6;
  --card: #FFFFFF;
  --ink: #3A3340;
  --ink-soft: #7A7080;
  --line: #DDE3EC;
  --peach: #FF9A80;
  --peach-soft: #FFE6DD;
  --mint: #7FD1B9;
  --mint-soft: #E2F6EF;
  --lav: #B9A6E8;
  --lav-soft: #EEE8FB;
  --el-목: #7CC99A;
  --el-화: #FF9483;
  --el-토: #E9BF6A;
  --el-금: #B8BDC9;
  --el-수: #7FAEE3;
  --radius: 18px;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--blue); color: var(--ink); }
body { padding: 4px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
#app { max-width: 480px; margin: 0 auto; background: var(--bg); min-height: calc(100vh - 8px); padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* 상단 */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; height: 34px; width: auto; }
.icon-btn { border: 0; background: transparent; padding: 8px; border-radius: 12px; font-size: 14px; color: var(--ink-soft); }
.back { display: inline-flex; align-items: center; gap: 4px; }

/* 캐릭터 말풍선 */
.miso { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 18px; }
.avatar { flex: 0 0 52px; height: 52px; border-radius: 50%; box-shadow: var(--shadow); }
.avatar svg { display: block; width: 100%; height: 100%; }
.bubble { background: var(--card); border-radius: 4px var(--radius) var(--radius) var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.bubble .who { font-size: 12px; color: var(--peach); font-weight: 700; margin-bottom: 2px; }

/* 카드·버튼 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); margin: 12px 0; }
.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 16px; font-weight: 700; text-align: center; margin: 10px 0; }
.btn-main { background: var(--peach); color: #fff; }
.btn-sub { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn-soft { background: var(--peach-soft); color: #C2553D; }
.btn:disabled { opacity: 0.5; }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.small { font-size: 13px; }

/* 상황 질문 메뉴 */
.menu { display: grid; gap: 10px; }
.q { display: flex; width: 100%; border: 0; text-align: left; justify-content: space-between; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.q:active, .banner:active { transform: scale(0.99); }
.q .qi { flex: none; width: 48px; height: 48px; margin: -4px 2px -4px -4px; }
.q .qt { flex: 1; }
.banner { display: block; width: 100%; border: 0; text-align: left; }

/* 안내 토스트 */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; max-width: 440px; width: calc(100% - 32px); background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 10; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 설정 목록 */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 12px 0; overflow: hidden; }
.list a, .list .row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); font-size: 15px; }
.list > :first-child { border-top: 0; }
.list .val { color: var(--ink-soft); font-size: 14px; }
.doc h2 { font-size: 16px; } .doc p, .doc li { font-size: 15px; } .doc .draft { background: var(--peach-soft); color: #C2553D; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.q .tag { font-size: 12px; background: var(--lav-soft); color: #6B57B0; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.section-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 16px 2px 6px; }

.banner { background: linear-gradient(120deg, #FFE3D8, #EEE8FB); border-radius: var(--radius); padding: 16px; margin: 18px 0; }
.banner b { display: block; font-size: 17px; }

/* 점수 */
.score-row { display: flex; align-items: center; gap: 14px; }
.score { flex: 0 0 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #fff; }
.lv-great { background: #FF8A6E; } .lv-good { background: #FFAA80; } .lv-normal { background: #A8C8E8; }
.lv-caution { background: #C9B6E8; } .lv-careful { background: #B5B0BA; }
.level { font-weight: 800; font-size: 18px; }
.reasons { margin: 12px 0 0; padding: 0; list-style: none; }
.reasons li { position: relative; padding: 6px 0 6px 22px; border-top: 1px solid var(--line); font-size: 15px; }
.reasons li::before { content: attr(data-sign); position: absolute; left: 0; top: 6px; font-weight: 800; }
.reasons li.plus::before { color: #E0715A; } .reasons li.minus::before { color: #7A86A8; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.tabs button { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }

/* 폼 */
form .field { margin: 14px 0; }
label.lbl { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
input[type=date], input[type=time], input[type=text], input[type=email] { width: 100%; padding: 13px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink); }
.seg { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg label { flex: 1; text-align: center; padding: 9px 4px; border-radius: 9px; font-size: 15px; cursor: pointer; }
.seg label { position: relative; }
.seg input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0); overflow: hidden; }
.seg label:focus-within { outline: 2px solid var(--peach); outline-offset: -2px; }
.seg label:has(input:checked) { background: var(--peach-soft); color: #C2553D; font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-top: 8px; }
.error { color: #C0392B; font-size: 14px; margin: 8px 0; }
.note { background: var(--mint-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #2F6B5A; }

/* 타로 */
/* 타로 뽑기 연출: 섞기 → 나눠 주기 → 고르기 → 뒤집기 (data-phase: shuffle | deal | pick | flip) */
.stage { position: relative; width: 100%; aspect-ratio: 1 / 0.62; margin: 18px 0 6px; }
.tc { position: absolute; left: 37%; top: 8%; width: 26%; aspect-ratio: 480 / 824; border: 0; padding: 0; background: none; perspective: 900px; cursor: default;
  transition: translate 0.2s, scale 0.3s, opacity 0.4s; -webkit-tap-highlight-color: transparent; }
.tc .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.85s cubic-bezier(0.3, 0.7, 0.2, 1); }
.tc .face { position: absolute; inset: 0; border-radius: 8px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 4px 14px rgba(90, 60, 120, 0.22); }
.tc .face svg, .tc .face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tc .front { transform: rotateY(180deg); background: #fff; }
.tc .front img.rev { transform: rotate(180deg); }
.tc.flipped .inner { transform: rotateY(180deg); }
.tc.pile { opacity: 1; }
.stage[data-phase="shuffle"] .tc { animation: riffle 1.5s ease-in-out var(--d, 0s) both; }
.stage[data-phase="deal"] .tc.pick { animation: deal 0.75s cubic-bezier(0.25, 0.8, 0.3, 1) calc(var(--i) * 0.22s) both; }
.stage[data-phase="deal"] .tc.pile, .stage[data-phase="pick"] .tc.pile, .stage[data-phase="flip"] .tc.pile { opacity: 0; transition: opacity 0.5s 0.2s; }
.stage[data-phase="pick"] .tc.pick, .stage[data-phase="flip"] .tc.pick { transform: translateX(var(--fx)); }
.stage[data-phase="pick"] .tc.pick { cursor: pointer; }
.stage[data-phase="pick"] .tc.pick:hover, .stage[data-phase="pick"] .tc.pick:focus-visible { translate: 0 -8px; outline: none; }
.stage[data-phase="pick"] .tc.pick:focus-visible .face { box-shadow: 0 0 0 3px var(--peach), 0 4px 14px rgba(90, 60, 120, 0.22); }
.stage[data-phase="flip"] .tc.pick:not(.chosen) { opacity: 0.28; scale: 0.94; }
.stage[data-phase="flip"] .tc.chosen { scale: 1.1; z-index: 3; }
@keyframes riffle {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(calc(var(--s, 1) * 62%)) rotate(calc(var(--s, 1) * 4deg)); }
  50% { transform: translateX(calc(var(--s, 1) * -14%)) rotate(0); }
  75% { transform: translateX(calc(var(--s, 1) * 44%)) rotate(calc(var(--s, 1) * -3deg)); }
}
@keyframes deal {
  0% { transform: translateX(0) translateY(0) rotate(0); }
  45% { transform: translateX(calc(var(--fx) * 0.6)) translateY(-16%) rotate(var(--fr)); }
  100% { transform: translateX(var(--fx)) translateY(0) rotate(0); }
}
.stage-msg { text-align: center; min-height: 22px; color: var(--ink-soft); font-size: 14px; margin: 4px 0 8px; }
.tarot-face { text-align: center; padding: 22px 16px; background: linear-gradient(180deg, #FFFFFF, #F7F2FF); border-radius: var(--radius); box-shadow: var(--shadow); animation: flip 0.5s ease-out; }
.card-art { width: 170px; margin: 0 auto 12px; border-radius: 8px; overflow: hidden; box-shadow: 0 8px 22px rgba(110, 80, 160, 0.28); background: #fff; }
.card-art svg, .card-art img { display: block; width: 100%; height: auto; }
.card-art img.rev { transform: rotate(180deg); }
.tarot-face .name { font-size: 24px; font-weight: 800; }
.tarot-face .en { color: var(--ink-soft); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.chip { background: var(--lav-soft); color: #5E4AA6; border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip.peach { background: var(--peach-soft); color: #C2553D; }
.chip.mint { background: var(--mint-soft); color: #2F6B5A; }
@media (prefers-reduced-motion: reduce) { .tarot-face { animation: none; } .tc, .tc .inner { transition: none !important; animation: none !important; } }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } to { transform: rotateY(0); opacity: 1; } }

/* 내 사주 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.pillar .head { font-size: 12px; color: var(--ink-soft); }
.pillar .god { font-size: 12px; color: var(--ink-soft); min-height: 18px; }
.glyph { border-radius: 12px; padding: 6px 0; margin: 3px 0; color: #fff; }
.glyph .h { font-size: 26px; font-weight: 700; line-height: 1.15; }
.glyph .k { font-size: 12px; opacity: 0.95; }
.pillar.empty .glyph { background: #EEE9E6; color: var(--ink-soft); }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 28px 1fr 18px; gap: 8px; align-items: center; font-size: 14px; }
.bar .track { background: #F3ECE8; border-radius: 999px; height: 10px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; }
.daeun { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.daeun div { text-align: center; background: #fff; border-radius: 12px; padding: 7px 0; box-shadow: var(--shadow); font-size: 12px; }
.daeun div.past { opacity: 0.55; }
.daeun div.now { outline: 2px solid var(--peach); }
.daeun b { display: block; font-size: 16px; }

.foot { margin-top: 28px; font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.5; }
.spacer { height: 8px; }

/* AI 풀이 화면 */
.reading { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.reading p { margin: 0 0 12px; }
.reading p:last-child { margin-bottom: 0; }
.reading .rd-h { font-size: 17px; margin: 20px 0 8px; color: #C2553D; }
.reading h2.rd-h:first-child, .reading h3.rd-h:first-child { margin-top: 0; }
.reading ul { margin: 0 0 12px; padding-left: 20px; }
.reading li { margin: 4px 0; }
.reading hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.loading { text-align: center; padding: 28px 8px; color: var(--ink-soft); }
.spin { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid var(--peach-soft); border-top-color: var(--peach); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
/* 타로 3장 뽑기 */
.t3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.t3label { font-size: 12px; text-align: center; color: var(--ink-soft); min-height: 32px; line-height: 1.3; display: grid; place-items: center; }
.tc3 { position: relative; width: 100%; aspect-ratio: 480 / 824; perspective: 900px; }
.tc3 .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.85s cubic-bezier(0.3, 0.7, 0.2, 1); }
.tc3 .face { position: absolute; inset: 0; border-radius: 8px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 4px 14px rgba(90, 60, 120, 0.22); }
.tc3 .face svg, .tc3 .face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tc3 .front { transform: rotateY(180deg); background: #fff; }
.tc3 .front img.rev { transform: rotate(180deg); }
.tc3.flipped .inner { transform: rotateY(180deg); }
.t3name { font-size: 13px; text-align: center; font-weight: 700; margin-top: 6px; min-height: 20px; }
@media (prefers-reduced-motion: reduce) { .tc3 .inner { transition: none; } }

/* 홈: 점수 카드 아이콘·행운 칩, 아이콘 3개 줄, 신년 배너 아이콘 */
.score-ico { flex: none; width: 52px; height: 52px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.chip { font-size: 13px; background: var(--peach-soft, #FFE9E1); color: #8a5a4c; border-radius: 999px; padding: 4px 10px; }
.chip.best { background: var(--peach); color: #fff; }
.best-line b { color: var(--ink); }
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.tri a { display: block; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 4px 10px; text-align: center; font-weight: 700; font-size: 14px; color: var(--ink); }
.tri a:active { transform: scale(0.98); }
.tri img { display: block; width: 56px; height: 56px; margin: 0 auto 4px; }
.banner-ico { align-items: center; gap: 12px; }
.banner-ico img { flex: none; width: 52px; height: 52px; }
.set-btn { display: inline-flex; align-items: center; gap: 4px; }
.set-btn img { width: 22px; height: 22px; }

/* 사주 공유 */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.share-row .btn { flex: 1 1 0; min-width: 0; margin: 0; padding: 12px 8px; text-align: center; }
.share-icons { display: flex; justify-content: space-around; gap: 6px; margin-top: 12px; }
.si { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; background: none; border: 0; padding: 4px 0; font: inherit; font-size: 12px; color: var(--ink); cursor: pointer; text-decoration: none; }
.si img { display: block; }

.dsel { display: flex; gap: 8px; }
.dsel select { flex: 1; min-width: 0; font: inherit; padding: 10px 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
