/* ============================================================
 * 운세 편의점 — 스타일
 * 모바일 우선, 밤하늘 테마
 * ============================================================ */
:root {
  --bg: #12101f;
  --bg2: #1a1730;
  --card: #221e3d;
  --card2: #2a2550;
  --line: #3a3468;
  --text: #efeaff;
  --sub: #a99fd6;
  --gold: #f0c75e;
  --gold-dark: #b8923a;
  --accent: #8b6ff0;
  --accent2: #c39df5;
  --danger: #e0564b;
  --good: #4caf7d;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #2b2452 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }

.hidden { display: none !important; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: rgba(18, 16, 31, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.coin-badge {
  background: linear-gradient(135deg, #3a3162, #2a2550);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-weight: 700; font-size: 14px;
  padding: 6px 12px; border-radius: 20px; cursor: pointer;
}
.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }

/* ---------- 온보딩 ---------- */
.onboarding { padding: 24px 16px 48px; }
.onboard-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 22px;
}
.onboard-title { text-align: center; font-size: 30px; margin-bottom: 4px; }
.onboard-tagline {
  text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: var(--gold); margin-bottom: 14px;
}
.onboard-sub { text-align: center; color: var(--sub); font-size: 14px; margin-bottom: 24px; }
.onboard-note { text-align: center; color: var(--sub); font-size: 12px; margin-top: 14px; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--accent2); margin-bottom: 7px; }
.field small { color: var(--sub); font-weight: 400; }

input[type="text"], select {
  width: 100%; padding: 12px 14px;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; outline: none; appearance: none;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }

.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.check-line {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 13px; color: var(--sub); cursor: pointer;
}
.check-line input { width: 16px; height: 16px; accent-color: var(--accent); }

.cal-preview {
  font-size: 12.5px; color: var(--gold); margin-top: 8px; min-height: 1em;
}
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 10px; border-radius: 12px;
  background: var(--bg2); color: var(--sub);
  border: 1px solid var(--line); font-size: 14px; cursor: pointer;
}
.seg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }

/* ---------- 버튼 ---------- */
.btn-primary {
  display: block; width: 100%;
  background: linear-gradient(135deg, var(--accent), #6a4fd8);
  color: #fff; border: none; border-radius: 14px;
  padding: 14px; font-size: 16px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 111, 240, 0.35);
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-big { margin-top: 6px; }

.btn-gold {
  display: block; width: 100%;
  background: linear-gradient(135deg, var(--gold), #d9a63f);
  color: #3a2c07; border: none; border-radius: 14px;
  padding: 13px; font-size: 15px; font-weight: 800; cursor: pointer;
}
.btn-ghost {
  display: block; width: 100%;
  background: none; color: var(--sub);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; font-size: 14px; cursor: pointer;
}
.btn-ghost:disabled { opacity: 0.5; cursor: default; }
.btn-sm { width: auto; display: inline-block; padding: 8px 16px; font-size: 13px; }

/* ---------- 메인/탭 ---------- */
main { padding: 16px 16px 96px; }
.tab { display: none; animation: fadeIn 0.25s ease; }
.tab.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.card-title .spacer { flex: 1; }
.muted { color: var(--sub); font-size: 13px; }

.section-head { margin: 4px 2px 14px; }
.section-head h2 { font-size: 20px; font-weight: 800; }
.section-head p { color: var(--sub); font-size: 13px; }

/* ---------- 홈 ---------- */
.greeting { font-size: 18px; font-weight: 800; margin-bottom: 2px; }
.date-line { color: var(--sub); font-size: 13px; margin-bottom: 14px; }
.iljin-chip {
  display: inline-block; background: var(--card2); border: 1px solid var(--line);
  color: var(--accent2); border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: 700;
}

.score-hero { text-align: center; padding: 8px 0 4px; }
.score-num { font-size: 52px; font-weight: 900; color: var(--gold); line-height: 1.1; }
.score-num small { font-size: 18px; color: var(--sub); font-weight: 600; }
.headline { font-size: 16px; font-weight: 800; margin: 6px 0 10px; }
.fortune-text { font-size: 14.5px; color: #ddd6f7; }

.rel-comment {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(139, 111, 240, 0.12); border: 1px solid rgba(139, 111, 240, 0.35);
  font-size: 13px; color: var(--accent2);
}

.cat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cat-name { width: 92px; font-size: 13.5px; font-weight: 700; flex-shrink: 0; }
.cat-bar-wrap { flex: 1; height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.cat-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.cat-score { width: 34px; text-align: right; font-size: 13px; font-weight: 800; color: var(--gold); flex-shrink: 0; }
.cat-desc { font-size: 13px; color: var(--sub); margin: -6px 0 12px 102px; }

.lucky-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lucky-item { background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.lucky-item .k { font-size: 11.5px; color: var(--sub); }
.lucky-item .v { font-size: 14px; font-weight: 700; }

/* ---------- 잠금 카드 ---------- */
.lock-card { position: relative; overflow: hidden; }
.lock-blur { filter: blur(6px); pointer-events: none; user-select: none; }
.lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: rgba(18, 16, 31, 0.55); border-radius: var(--radius); padding: 16px;
  text-align: center;
}
.lock-overlay .lock-ico { font-size: 30px; }
.lock-overlay .lock-msg { font-size: 14px; font-weight: 700; }
.lock-overlay .lock-sub { font-size: 12px; color: var(--sub); }

/* ---------- 주간 운세 ---------- */
.week-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.week-row:last-child { border-bottom: none; }
.week-day { width: 74px; flex-shrink: 0; font-size: 13px; font-weight: 700; }
.week-day small { display: block; color: var(--sub); font-weight: 400; font-size: 11px; }
.week-score { width: 40px; text-align: right; font-weight: 800; color: var(--gold); font-size: 14px; flex-shrink: 0; }
.week-head { font-size: 12.5px; color: var(--sub); flex: 1; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; border-radius: 8px; padding: 1px 7px; margin-left: 5px; }
.badge.best { background: rgba(76, 175, 125, 0.2); color: var(--good); }
.badge.worst { background: rgba(224, 86, 75, 0.18); color: var(--danger); }

/* ---------- 사주 기둥 ---------- */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.pillar { background: var(--bg2); border-radius: 12px; padding: 10px 4px; border: 1px solid var(--line); }
.pillar .p-label { font-size: 11px; color: var(--sub); margin-bottom: 6px; }
.pillar .p-hanja { font-size: 26px; font-weight: 900; line-height: 1.25; }
.pillar .p-han { font-size: 12px; color: var(--sub); margin-top: 4px; }
.pillar .p-god { font-size: 10.5px; color: var(--accent2); margin-top: 5px; }
.elem-chip { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 6px; color: #fff; margin-top: 4px; }

/* 12운성 */
.pillar-hl { border-color: var(--gold); background: rgba(240, 199, 94, 0.08); }
.stage-emoji { font-size: 24px; line-height: 1.4; }
.stage-name { font-size: 15px; font-weight: 900; }

.dm-hero { text-align: center; padding: 6px 0 12px; }
.dm-symbol { font-size: 40px; }
.dm-name { font-size: 21px; font-weight: 900; margin-top: 4px; }
.dm-title { color: var(--gold); font-size: 14px; font-weight: 700; margin-top: 2px; }
.dm-core { color: var(--sub); font-size: 13px; margin-top: 2px; }

.info-line { display: flex; gap: 8px; margin: 8px 0; font-size: 14px; }
.info-line .ik { flex-shrink: 0; font-weight: 800; color: var(--accent2); width: 64px; }

.elem-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.elem-name { width: 56px; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.elem-track { flex: 1; height: 10px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.elem-fill { height: 100%; border-radius: 5px; }
.elem-cnt { width: 22px; text-align: right; font-size: 13px; font-weight: 700; flex-shrink: 0; }

/* ---------- 타로 ---------- */
.tarot-stage { text-align: center; padding: 10px 0; }
.tarot-card-face {
  width: 180px; min-height: 240px; margin: 0 auto 14px;
  background: linear-gradient(160deg, #322a5e, #221e3d);
  border: 2px solid var(--gold-dark); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 14px; gap: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.tarot-back {
  cursor: pointer;
  background:
    radial-gradient(circle at 50% 35%, rgba(240, 199, 94, 0.15), transparent 60%),
    repeating-linear-gradient(45deg, #2a2550 0 12px, #251f46 12px 24px);
}
.tarot-emoji { font-size: 56px; }
.tarot-name { font-size: 19px; font-weight: 900; }
.tarot-en { font-size: 11.5px; color: var(--sub); letter-spacing: 1px; }
.tarot-rev-tag { font-size: 11px; color: var(--danger); font-weight: 800; }
.tarot-keywords { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.kw { background: var(--card2); border: 1px solid var(--line); color: var(--accent2); font-size: 12px; padding: 3px 10px; border-radius: 12px; }
.tarot-meaning { font-size: 14.5px; text-align: left; }
.tarot-advice {
  margin-top: 12px; padding: 10px 12px; text-align: left;
  background: rgba(240, 199, 94, 0.1); border: 1px solid rgba(240, 199, 94, 0.3);
  border-radius: 12px; font-size: 13.5px; color: var(--gold);
}

/* ---------- MBTI ---------- */
.mbti-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mbti-btn {
  padding: 10px 0; border-radius: 12px; font-size: 13.5px; font-weight: 800;
  background: var(--bg2); color: var(--sub); border: 1px solid var(--line); cursor: pointer;
}
.mbti-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.score-ring { text-align: center; margin: 6px 0 10px; }
.score-ring .big { font-size: 40px; font-weight: 900; color: var(--gold); }

/* ---------- 상점 ---------- */
.shop-balance {
  text-align: center; padding: 12px 0;
  font-size: 15px; color: var(--sub);
}
.shop-balance b { color: var(--gold); font-size: 26px; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.shop-item:last-child { border-bottom: none; }
.shop-ico { font-size: 24px; flex-shrink: 0; }
.shop-info { flex: 1; }
.shop-name { font-size: 14.5px; font-weight: 800; }
.shop-desc { font-size: 12px; color: var(--sub); }
.shop-price { font-size: 13px; font-weight: 800; color: var(--gold); flex-shrink: 0; }

/* ---------- 모달 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 22px;
  max-height: 82vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 900; margin-bottom: 10px; }
.modal-body { font-size: 14px; color: #ddd6f7; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions > * { flex: 1; }

/* 광고 모달 */
.ad-card { text-align: center; }
.ad-screen {
  background: #000; border-radius: 14px; padding: 34px 16px;
  margin-bottom: 14px; position: relative;
}
.ad-label {
  position: absolute; top: 8px; left: 10px;
  background: var(--gold); color: #000; font-size: 10px; font-weight: 900;
  padding: 1px 6px; border-radius: 4px;
}
.ad-text { color: #999; font-size: 14px; }
.ad-count {
  margin-top: 14px; font-size: 30px; font-weight: 900; color: var(--gold);
}

/* ---------- 하단 내비 ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 30;
  display: flex;
  background: rgba(18, 16, 31, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; min-width: 0;
  background: none; border: none; cursor: pointer;
  color: var(--sub); font-size: 10.5px; font-weight: 700;
  padding: 8px 0 9px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  white-space: nowrap;
}
.nav-btn.active { color: var(--gold); }
.nav-ico { font-size: 19px; }

/* ---------- 궁합 ---------- */
#tab-match .cat-name { width: 112px; }
.match-head {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 4px 0 10px;
}
.match-person { flex: 1; text-align: center; min-width: 0; }
.mp-emoji { font-size: 30px; }
.mp-name {
  font-size: 14.5px; font-weight: 800; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mp-sub { font-size: 11.5px; color: var(--sub); }
.match-heart { font-size: 26px; flex-shrink: 0; padding: 0 2px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: #362f63; color: #fff; border: 1px solid var(--accent);
  padding: 10px 20px; border-radius: 24px; font-size: 14px; font-weight: 700;
  z-index: 60; white-space: nowrap;
  animation: toastUp 0.25s ease;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
@keyframes toastUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 영수증 ---------- */
.receipt-wrap {
  background: repeating-linear-gradient(45deg, #1a1730 0 10px, #191630 10px 20px);
  border-radius: 12px; padding: 14px;
  max-height: 52vh; overflow-y: auto;
}

/* ---------- 용어 사전 ---------- */
.term {
  background: none; border: none; padding: 0;
  font: inherit; color: inherit; cursor: pointer;
  border-bottom: 1px dashed var(--accent2);
  line-height: 1.3;
}
.term:active { color: var(--accent2); }
.term-q {
  font-size: 9px; font-weight: 900; color: var(--accent2);
  vertical-align: super; margin-left: 1px;
}
.term-read { font-size: 13px; color: var(--sub); font-weight: 500; }
.term-plain {
  background: rgba(139, 111, 240, 0.14);
  border: 1px solid rgba(139, 111, 240, 0.38);
  border-radius: 12px; padding: 10px 12px;
  font-size: 14px; font-weight: 700; color: var(--accent2);
}
.glossary-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.term-chip {
  background: var(--bg2); border: 1px solid var(--line); color: var(--accent2);
  border-radius: 14px; padding: 5px 12px; font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.term-chip:active { background: var(--accent); color: #fff; }

.term-hint {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border-radius: 10px;
  padding: 8px 11px; margin-bottom: 12px;
  font-size: 12px; color: var(--sub);
}

/* ---------- 기타 ---------- */
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.notice-box {
  background: var(--bg2); border-radius: 12px; padding: 12px 14px;
  font-size: 12px; color: var(--sub);
}
