/* Luna — 별빛 타로 · 스타일시트
   팔레트: 밤하늘 근흑색 · 달빛 본색 · 앤티크 금색 (방향 name-as-monument, seed 1368802888)
   색은 주제(달·밤하늘)에서 취함(슬롭 보라/인디고 배제). 타입: General Sans + Fraunces 2종.
   하우스 규칙 준수: 그라데이션·정지 상태 그림자/글로우·분리용 얇은 선·이모지 없음. */

:root {
  --bg: #0b0c14;
  --bg-deep: #07080e;
  --surface: #14151f;
  --surface-2: #1c1d29;
  --ink: #ece7d8;
  --ink-dim: #c9c3b4;
  --muted: #8f8778;
  --accent: #c9a24a;
  --accent-soft: #e3c87c;
  --field: #171221;        /* 한 개의 큰 색면(절제된 자정빛) */
  --line: rgba(236, 231, 216, .12);
  --line-strong: rgba(236, 231, 216, .22);
  --gold-line: rgba(201, 162, 74, .42);

  --disp: "General Sans", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;

  --step-small: 0.8125rem;
  --step-body: 1.0625rem;
  --step-lead: clamp(1.2rem, 1.05rem + 0.7vw, 1.55rem);
  --step-head: clamp(1.9rem, 1.3rem + 2.6vw, 2.9rem);
  --monument: clamp(4.6rem, 17vw, 8.5rem);

  --app-w: 30rem;
  --gut: 22px;
  --radius: 16px;
  --tap: 52px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--disp);
  font-size: var(--step-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: var(--bg-deep); }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: 4px; }

#stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ── 앱 컬럼(바깥은 더 어두운 밤하늘로 톤 분리) ── */
.app {
  position: relative;
  width: min(100%, var(--app-w));
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: clip;
}
.screen { display: none; flex: 1; flex-direction: column; animation: viewIn .5s var(--ease) both; }
.screen.active { display: flex; }
.pad { padding: 0 var(--gut); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 28px; }

@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.head { font-size: var(--step-head); }
.lead { font-size: var(--step-lead); line-height: 1.35; color: var(--ink); }
.serif { font-family: var(--serif); font-optical-sizing: auto; }
.muted { color: var(--muted); }
.dim { color: var(--ink-dim); }
.center { text-align: center; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 26px; width: 100%;
  background: var(--accent); color: var(--bg-deep);
  font-weight: 600; letter-spacing: -0.01em; border-radius: 999px;
  transition: transform .2s var(--ease), filter .2s var(--ease);
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.975); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line-strong); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-soft); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.link { color: var(--accent-soft); text-decoration: underline; text-underline-offset: 4px; background: none; }

/* ── 상단 바 ── */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 10px var(--gut) 0; }
.brandmark { font-weight: 700; letter-spacing: .14em; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 999px; color: var(--ink-dim); transition: color .2s, background .2s; }
.icon-btn:hover { color: var(--accent-soft); background: var(--surface-2); }
.icon-star { width: 16px; height: 16px; flex: none; }

/* ═══ 온보딩 ═══ */
#onboard .scroll { display: flex; flex-direction: column; position: relative; }
.ob-sky { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .14; filter: grayscale(.4) sepia(.5) saturate(1.2) brightness(.9) hue-rotate(-6deg); pointer-events: none; }
.ob-step { display: none; position: relative; flex: 1; flex-direction: column; justify-content: center; padding: 8vh var(--gut) 5vh; min-height: 100dvh; animation: viewIn .5s var(--ease) both; }
.ob-step.active { display: flex; }

/* 기념비: LUNA + 달 */
.monument { display: flex; align-items: center; justify-content: center; gap: .04em; line-height: .82; font-weight: 700; }
.monument .word { font-family: var(--disp); font-weight: 700; font-size: var(--monument); letter-spacing: -0.05em; display: inline-block; }
.monument .moon-glyph { width: .8em; height: .8em; color: var(--accent); }
.intro-sub { margin-top: 30px; font-size: 1.14rem; color: var(--ink-dim); max-width: 24ch; line-height: 1.5; }
.intro-actions { margin-top: 42px; max-width: 360px; }

/* 질문 단계 */
.ob-q { font-size: var(--step-head); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 28px; }
.field { width: 100%; min-height: var(--tap); background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 0 18px; color: var(--ink); font-size: 1.15rem; transition: border-color .2s; }
.field:focus { border-color: var(--accent); outline: none; }
.field::placeholder { color: var(--muted); }
.choices { display: grid; gap: 14px; }
.choice { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 0 20px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; font-size: 1.1rem; text-align: left; transition: border-color .2s, background .2s, color .2s; }
.choice:hover { border-color: var(--line-strong); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); color: var(--accent-soft); }
.choice .dotmark { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--muted); flex: none; position: relative; }
.choice[aria-pressed="true"] .dotmark { border-color: var(--accent); }
.choice[aria-pressed="true"] .dotmark::after { content: ""; position: absolute; inset: 3px; border-radius: 999px; background: var(--accent); }
.date-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.gender-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gender-3 .choice { min-height: 52px; justify-content: center; padding: 0 6px; font-size: 1.02rem; }
.err { color: #e08a7a; font-size: var(--step-small); margin-top: 12px; min-height: 1em; }
.ob-nav { display: flex; gap: 12px; margin-top: 34px; }
.ob-progress { display: flex; gap: 7px; justify-content: center; margin: 26px 0 8vh; position: relative; }
.ob-progress i { width: 7px; height: 7px; border-radius: 999px; background: var(--line-strong); transition: background .3s, width .3s; }
.ob-progress i.on { background: var(--accent); width: 22px; }

/* ═══ 홈 ═══ */
.home-hero { padding: 6px var(--gut) 10px; text-align: center; }
.greet { font-size: var(--step-lead); font-weight: 600; letter-spacing: -0.02em; }
.greet b { color: var(--accent-soft); font-weight: 700; }
.moon-monument { margin: 14px auto 6px; width: min(62vw, 220px); aspect-ratio: 1; color: var(--ink); }
.moon-meta { font-size: var(--step-small); }
.moon-meta .ph { color: var(--accent-soft); font-weight: 600; letter-spacing: .02em; }
.moon-line { font-family: var(--serif); font-size: 1.1rem; color: var(--ink-dim); margin-top: 8px; max-width: 30ch; margin-inline: auto; font-style: italic; }

/* 오늘의 카드 배너 */
.daily { display: block; width: calc(100% - 2 * var(--gut)); margin: 24px var(--gut) 0; position: relative; border-radius: var(--radius); overflow: hidden; background: var(--field); text-align: left; }
.daily-bg { position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%; opacity: .2; filter: grayscale(.3) sepia(.45) saturate(1.3) hue-rotate(-8deg); }
.daily-inner { position: relative; display: flex; gap: 18px; align-items: center; padding: 20px; }
.daily h3 { font-size: 1.35rem; }
.daily p { color: var(--ink-dim); font-size: var(--step-small); margin-top: 4px; }
.daily .mini-card { flex: none; width: 60px; }

/* 모듈 입구 — 채워진 면으로 분리(선 없음) */
.section-intro { padding: 32px var(--gut) 14px; }
.section-intro h2 { font-size: 1.5rem; }
.section-intro p { color: var(--muted); font-size: var(--step-small); margin-top: 4px; }
.modules { display: grid; gap: 12px; padding: 0 var(--gut); }
.module { display: flex; align-items: center; gap: 16px; padding: 18px 20px; background: var(--surface); border-radius: var(--radius); text-align: left; transition: transform .25s var(--ease), background .25s; }
.module:hover { background: var(--surface-2); transform: translateY(-2px); }
.module .emblem { width: 44px; height: 44px; color: var(--accent); flex: none; }
.module .m-body { flex: 1; }
.module .m-body h3 { font-size: 1.22rem; }
.module .m-body p { color: var(--muted); font-size: var(--step-small); margin-top: 2px; }
.module .chev { color: var(--muted); }

/* 프리미엄 유혹 띠 */
.promo { margin: 28px var(--gut) 8px; padding: 24px 22px; border-radius: var(--radius); background: var(--field); text-align: center; }
.promo h3 { font-size: 1.3rem; }
.promo p { color: var(--ink-dim); font-size: var(--step-small); margin: 8px 0 16px; }

/* ═══ 하단 내비 — 톤 분리 ── */
.tabbar { display: flex; background: var(--bg-deep); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0 14px; color: var(--muted); font-size: 11px; letter-spacing: .02em; transition: color .2s; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent-soft); }

/* ═══ 공통 내부 화면 헤더 ═══ */
.sub-head { padding: 6px var(--gut) 16px; }
.sub-head .back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--step-small); margin-bottom: 14px; }
.sub-head h1 { font-size: var(--step-head); }
.sub-head .sh-sub { color: var(--ink-dim); margin-top: 8px; font-family: var(--serif); font-style: italic; }

/* ═══ 타로 ═══ */
.spread-pick { display: grid; gap: 12px; padding: 4px var(--gut) 0; }
.spread-opt { padding: 20px; background: var(--surface); border-radius: var(--radius); text-align: left; transition: background .25s; }
.spread-opt:hover { background: var(--surface-2); }
.spread-opt h3 { font-size: 1.25rem; }
.spread-opt p { color: var(--muted); font-size: var(--step-small); margin-top: 4px; }

/* 카드 비주얼 — 카드는 테두리를 가진 '물체'(허용) */
.card { aspect-ratio: 2 / 3.3; border-radius: 12px; position: relative; background: #141019; border: 1px solid var(--gold-line); overflow: hidden; }
.card .frame { position: absolute; inset: 7px; border: 1px solid var(--gold-line); border-radius: 7px; pointer-events: none; }
.card .num { position: absolute; top: 9px; left: 0; right: 0; text-align: center; font-size: 11px; letter-spacing: .14em; color: var(--accent); }
.card .emblem { position: absolute; inset: 0; margin: auto; width: 56%; color: var(--accent-soft); }
.card .nm { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-family: var(--serif); font-size: 13px; color: var(--ink-dim); }
.card.back { background: #0e0b16; }
.card.back .bk { position: absolute; inset: 0; margin: auto; width: 46%; color: var(--gold-line); }
.card.rev .emblem { transform: rotate(180deg); }
.card.rev .num::after { content: " ↓"; }

/* 뽑기 테이블 */
.draw-stage { position: relative; min-height: 46vh; display: grid; place-items: center; padding: 10px var(--gut); }
.deck-fan { position: relative; width: 100%; max-width: 320px; height: 220px; }
.fan-card { position: absolute; left: 50%; top: 20px; width: 92px; transform-origin: 50% 150%; transition: transform .5s var(--ease), filter .3s; cursor: pointer; }
.fan-card:hover { filter: brightness(1.25); }
.fan-card.chosen { filter: brightness(1.3); }
.shake-hint { text-align: center; color: var(--muted); font-size: var(--step-small); margin-top: 8px; }
.reveal-row { display: flex; gap: 8px; justify-content: center; padding: 0 var(--gut); }
.reveal-slot { flex: 1; max-width: 108px; }
.reveal-slot .slot-name { text-align: center; font-size: var(--step-small); color: var(--accent); margin-bottom: 8px; letter-spacing: .02em; }
.flip { perspective: 1000px; cursor: pointer; }
.flip .inner { position: relative; transition: transform .7s var(--ease); transform-style: preserve-3d; aspect-ratio: 2 / 3.3; }
.flip.up .inner { transform: rotateY(180deg); }
.flip .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip .face.front { transform: rotateY(180deg); }

/* 해석 */
.reading { padding: 26px var(--gut) 0; }
.reading .r-card { padding: 22px 20px; background: var(--surface); border-radius: var(--radius); margin-bottom: 12px; }
.reading .r-slot { font-size: var(--step-small); color: var(--accent); letter-spacing: .02em; }
.reading .r-name { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; margin: 4px 0 2px; }
.reading .r-kw { color: var(--muted); font-size: var(--step-small); }
.reading .r-text { font-family: var(--serif); font-size: 1.1rem; line-height: 1.62; color: var(--ink-dim); margin-top: 14px; }
.reading .r-pos { display: inline-block; font-size: 11px; letter-spacing: .1em; padding: 4px 11px; border-radius: 999px; background: var(--surface-2); color: var(--accent-soft); margin-top: 14px; }

/* ═══ 별자리 운세 ═══ */
.sign-head { text-align: center; padding: 10px var(--gut) 0; }
.sign-glyph { font-size: 72px; color: var(--accent); line-height: 1; }
.sign-name { font-size: 1.7rem; font-weight: 700; margin-top: 6px; }
.sign-range { color: var(--muted); font-size: var(--step-small); margin-top: 2px; }
.sign-date { color: var(--accent-soft); font-size: var(--step-small); margin-top: 14px; letter-spacing: .02em; }
.horo-list { display: grid; gap: 12px; padding: 22px var(--gut) 0; }
.horo-item { padding: 18px 20px; background: var(--surface); border-radius: var(--radius); }
.horo-item .hi-top { display: flex; align-items: center; justify-content: space-between; }
.horo-item h3 { font-size: 1.15rem; }
.stars-rate { display: inline-flex; gap: 2px; color: var(--accent); flex: none; }
.stars-rate .icon-star.off { color: var(--line-strong); }
.horo-item p { font-family: var(--serif); color: var(--ink-dim); margin-top: 10px; line-height: 1.55; }
.lock-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: var(--step-small); }
.lock-row svg { width: 16px; height: 16px; flex: none; }
.sign-switch { display: flex; flex-wrap: wrap; gap: 8px; padding: 24px var(--gut) 0; }
.sign-chip { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; font-size: 20px; color: var(--muted); background: var(--surface); transition: color .2s, background .2s; }
.sign-chip[aria-pressed="true"] { color: var(--bg-deep); background: var(--accent); }

/* ═══ 예언(오라클) ═══ */
.oracle-wrap { padding: 10px var(--gut) 0; display: flex; flex-direction: column; min-height: 60vh; }
.orb { width: min(54vw, 180px); aspect-ratio: 1; margin: 10px auto 20px; border-radius: 999px; position: relative; background: #171222; border: 1px solid var(--gold-line); display: grid; place-items: center; overflow: hidden; transition: transform 1.6s var(--ease), border-color 1.6s; }
.orb .hl { position: absolute; width: 30%; height: 30%; top: 16%; left: 18%; border-radius: 999px; background: rgba(236,231,216,.28); filter: blur(7px); }
.orb svg { width: 50%; color: var(--accent-soft); opacity: .9; position: relative; }
.orb.thinking { animation: orbPulse 1.7s var(--ease) infinite; }
@keyframes orbPulse { 0%,100% { transform: scale(1); border-color: var(--gold-line); } 50% { transform: scale(1.05); border-color: var(--accent-soft); } }
.q-field { width: 100%; min-height: 92px; resize: none; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px; font-size: 1.08rem; line-height: 1.5; transition: border-color .2s; }
.q-field:focus { border-color: var(--accent); outline: none; }
.q-counter { text-align: center; color: var(--muted); font-size: var(--step-small); margin: 14px 0; }
.q-counter b { color: var(--accent-soft); }
.prophecy { font-family: var(--serif); font-size: 1.14rem; line-height: 1.62; text-align: center; color: var(--ink); padding: 8px 16px; font-style: italic; word-break: keep-all; }
.prophecy .mark { display: block; margin: 12px auto; color: var(--accent); }

/* ═══ 프로필 ═══ */
.profile-top { text-align: center; padding: 12px var(--gut) 0; }
.avatar-moon { width: 96px; height: 96px; margin: 0 auto 14px; color: var(--ink); }
.pf-name { font-size: 1.7rem; font-weight: 700; }
.pf-sign { color: var(--accent-soft); font-size: var(--step-body); margin-top: 4px; }
.form-list { display: grid; gap: 18px; padding: 26px var(--gut) 0; }
.form-row label { display: block; font-size: var(--step-small); color: var(--muted); margin-bottom: 7px; letter-spacing: .02em; }

/* ═══ 프리미엄 ═══ */
.prem-hero { text-align: center; padding: 18px var(--gut) 0; }
.prem-hero .mk { font-weight: 700; letter-spacing: .2em; color: var(--accent); font-size: 13px; }
.prem-hero h1 { font-size: var(--step-head); margin-top: 12px; }
.prem-hero p { color: var(--ink-dim); margin-top: 14px; font-family: var(--serif); font-style: italic; }
.perks { padding: 28px var(--gut) 0; }
.perk { display: flex; gap: 16px; align-items: flex-start; padding: 18px; border-radius: 14px; margin-bottom: 8px; background: var(--surface); }
.perk .pk-ic { color: var(--accent); flex: none; margin-top: 2px; }
.perk h3 { font-size: 1.1rem; }
.perk p { color: var(--muted); font-size: var(--step-small); margin-top: 3px; }
.price-block { text-align: center; padding: 28px var(--gut) 0; }
.price-block .amt { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.03em; }
.price-block .per { color: var(--muted); }
.mock-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.5; padding-inline: 10px; }

/* ── 토스트(오버레이) ── */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--surface-2); color: var(--ink); padding: 12px 20px; border-radius: 999px; border: 1px solid var(--gold-line); font-size: var(--step-small); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease), transform .35s var(--ease); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 진입 모션 (스크립트 실패 시에도 내용은 보이게: 기본 표시) ── */
.rise { opacity: 1; }
.js .rise:not(.in) { opacity: 0; transform: translateY(22px); }
.rise.in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); }
@keyframes moonDrift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.moon-float { animation: moonDrift 7s var(--ease) infinite; }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: .9; } }
.spark { animation: twinkle 3.5s ease-in-out infinite; }

/* ── 모션 최소화 ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .rise { opacity: 1 !important; transform: none !important; }
}

/* 출처 표기 */
.credits { margin-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: center; }
.credits a { color: var(--ink-dim); text-decoration: underline; text-underline-offset: 2px; }

/* 그리드/셀렉트 넘침 방지 (기본 min-width:auto 해제) */
.scroll { overflow-x: hidden; }
.field, .choice { min-width: 0; }
.date-row > *, .gender-3 > * { min-width: 0; }

/* 그리드 열이 넓은 자식 때문에 늘어나는 것 방지 */
.form-list, .modules, .horo-list, .spread-pick, .choices { grid-template-columns: minmax(0, 1fr); }
.gender-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.date-row { grid-template-columns: 1.4fr minmax(0,1fr) minmax(0,1fr); }
.credits { overflow-wrap: anywhere; }

/* 셀렉트 기본 외형 제거(기본 최소 너비가 그리드를 늘리는 문제 해결) + 전역 가로 넘침 차단 */
html, body { overflow-x: hidden; max-width: 100%; }
select.field { appearance: none; -webkit-appearance: none; -moz-appearance: none; background-image: none; }
.date-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row, .scroll > * { min-width: 0; max-width: 100%; }

/* 날짜·성별 선택을 flex로(확실한 수축) */
.date-row { display: flex; gap: 10px; }
.date-row > * { flex: 1 1 0; min-width: 0; }
.gender-3 { display: flex; gap: 8px; }
.gender-3 > * { flex: 1 1 0; min-width: 0; padding: 0 4px; }
