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

/* ── 테마 변수 ────────────────────────────────────── */
:root {
  --bg:          #0a0118;
  --bg2:         #110228;
  --surface:     #1a0d35;
  --surface2:    #231248;
  --border:      rgba(255,255,255,0.1);
  --text:        #e8d5ff;
  --text-sub:    #a78bca;
  --text-muted:  #6b4e8a;
  --gold:        #f59e0b;
  --gold-light:  #fcd34d;
  --btn-bg:      linear-gradient(135deg, #7c3aed, #a855f7);
  --card-radius: 12px;
  --shadow:      0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 24px rgba(245,158,11,0.5);
}

[data-theme="light"] {
  --bg:         #f3eeff;
  --bg2:        #e9deff;
  --surface:    #ffffff;
  --surface2:   #f0e8ff;
  --border:     rgba(100,50,180,0.15);
  --text:       #1a0d35;
  --text-sub:   #5b21b6;
  --text-muted: #8b5cf6;
  --shadow:     0 8px 32px rgba(100,50,180,0.15);
}

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── 테마 토글 ───────────────────────────────────── */
.btn-theme {
  position: fixed; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 1.1rem;
  cursor: pointer; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, background 0.3s;
}
.btn-theme:hover { transform: scale(1.1); }

/* ── 화면 전환 ───────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── 버튼 공통 ───────────────────────────────────── */
.btn-cta {
  background: var(--btn-bg);
  color: white; border: none; border-radius: 14px;
  padding: 14px 32px; font-size: 1rem; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
}
.btn-cta:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(124,58,237,0.55); }
.btn-cta:active:not(:disabled) { transform: translateY(0); }
.btn-cta:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-nav {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-sub); border-radius: 10px;
  padding: 8px 16px; font-size: 0.85rem; cursor: pointer;
  transition: background 0.2s;
}
.btn-nav:hover { background: var(--surface); }

/* ─────────────────────────────────────────────────
   ① 웰컴 화면
───────────────────────────────────────────────── */
#screen-welcome {
  align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(124,58,237,0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(168,85,247,0.2) 0%, transparent 55%),
    var(--bg);
}

.welcome-wrap {
  text-align: center; padding: 40px 24px; max-width: 480px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}

.orb {
  font-size: 5rem;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(168,85,247,0.6));
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

#screen-welcome h1 {
  font-size: 2.2rem; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, #c084fc, #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sub   { font-size: 1.05rem; color: var(--text-sub); line-height: 1.7; }
.hint  { font-size: 0.92rem; color: var(--text-muted); line-height: 1.7; }
.hint strong { color: var(--gold); }

/* ─────────────────────────────────────────────────
   ② 카드 선택 화면
───────────────────────────────────────────────── */
#screen-select {
  background: var(--bg);
  overflow: hidden;
}

.select-top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.select-title { flex: 1; text-align: center; font-size: 0.92rem; color: var(--text-sub); }
.select-title strong { color: var(--gold); }

.sel-count {
  font-weight: 800; font-size: 1rem; color: var(--gold);
  min-width: 40px; text-align: right;
}

/* 필터 바 */
.filter-row {
  display: flex; gap: 8px; padding: 12px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.filter-row::-webkit-scrollbar { height: 0; }

.fil {
  padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text-sub); cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
}
.fil:hover  { border-color: var(--gold); color: var(--gold); }
.fil.active { background: var(--gold); border-color: var(--gold); color: #0a0118; }

/* 카드 그리드 — 가로 스크롤 */
.cards-grid {
  --card-w: 88px;
  --card-h: calc(var(--card-w) * 8 / 5); /* 140.8px */

  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  display: grid;
  grid-template-rows: repeat(3, var(--card-h));
  grid-auto-flow: column;
  grid-auto-columns: var(--card-w);
  gap: 10px;
  align-content: center;
  -webkit-overflow-scrolling: touch;
}

.cards-grid::-webkit-scrollbar { height: 4px; }
.cards-grid::-webkit-scrollbar-track { background: transparent; }
.cards-grid::-webkit-scrollbar-thumb { background: rgba(245,158,11,0.3); border-radius: 2px; }

/* 카드 컨테이너 */
.card-item {
  border-radius: var(--card-radius); cursor: pointer;
  aspect-ratio: 5/8;
  position: relative;
  user-select: none;
  perspective: 800px;
  transition: transform 0.15s;
}

.card-item:hover       { transform: translateY(-4px) scale(1.04); }
.card-item.selected    { box-shadow: var(--shadow-gold); }
.card-item.filtered-out{ display: none; }

/* ── 3D 플립 ─────────────────────────────────────── */
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--card-radius);
}

.card-item.flipped .card-inner { transform: rotateY(180deg); }

.card-back,
.card-front {
  position: absolute; inset: 0;
  border-radius: var(--card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px; overflow: hidden;
}

/* 뒷면 */
.card-back {
  background: linear-gradient(160deg, #0d0122 0%, #2a0e5e 50%, #0d0122 100%);
  border: 2px solid rgba(245,158,11,0.35);
}
.card-back::before {
  content: '✦';
  font-size: 2rem;
  color: rgba(245,158,11,0.65);
  text-shadow: 0 0 14px rgba(245,158,11,0.5);
}
.card-back::after {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid rgba(245,158,11,0.18);
  border-radius: 8px;
  pointer-events: none;
}

/* 앞면 */
.card-front {
  transform: rotateY(180deg);
  border: 2px solid rgba(255,255,255,0.08);
}
.card-item.selected .card-front { border-color: var(--gold); }
.card-item.selected .card-front::after {
  content: '✓';
  position: absolute; top: 4px; right: 6px;
  font-size: 0.75rem; font-weight: 900; color: var(--gold);
}

/* 수트별 그라디언트 (앞면 + 결과 카드 공용) */
.suit-major    { background: linear-gradient(160deg, #2d1b69 0%, #4c1d95 60%, #5b21b6 100%); }
.suit-wands    { background: linear-gradient(160deg, #7c2d12 0%, #c2410c 60%, #ea580c 100%); }
.suit-cups     { background: linear-gradient(160deg, #1e3a8a 0%, #1d4ed8 60%, #2563eb 100%); }
.suit-swords   { background: linear-gradient(160deg, #1e293b 0%, #334155 60%, #475569 100%); }
.suit-pentacles{ background: linear-gradient(160deg, #14532d 0%, #15803d 60%, #16a34a 100%); }

.card-emoji  { font-size: 1.5rem; line-height: 1; }
.card-name   { font-size: 0.62rem; font-weight: 700; color: rgba(255,255,255,0.95); text-align: center; line-height: 1.3; word-break: keep-all; }
.card-nameen { font-size: 0.48rem; color: rgba(255,255,255,0.55); text-align: center; line-height: 1.2; }

/* 하단 고정 바 */
.select-footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 14px 20px; flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
}

.preview-row { display: flex; gap: 8px; flex: 1; }

.preview-slot {
  width: 44px; height: 60px; border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: border-color 0.2s;
  flex-shrink: 0;
}

.preview-slot.filled { border-color: var(--gold); border-style: solid; }

.prev-empty { color: var(--text-muted); font-size: 1.1rem; }

.preview-slot .mini-card {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 2px;
}
.preview-slot .mini-emoji { font-size: 1rem; }
.preview-slot .mini-name  { font-size: 0.38rem; color: rgba(255,255,255,0.9); text-align: center; font-weight: 700; }

/* ─────────────────────────────────────────────────
   ③ 결과 화면
───────────────────────────────────────────────── */
#screen-result {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.2) 0%, transparent 60%),
    var(--bg);
  overflow-y: auto;
}

.result-wrap {
  max-width: 700px; margin: 0 auto;
  padding: 20px 20px 60px;
  display: flex; flex-direction: column; gap: 24px;
}

.result-top {
  display: flex; align-items: center; gap: 12px;
}
.result-top h2 {
  flex: 1; text-align: center; font-size: 1.4rem; font-weight: 800;
}

/* 결과 카드 3장 */
.result-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}

.result-card {
  border-radius: 14px; padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
}

.result-card-emoji { font-size: 2.2rem; }
.result-card-name  { font-size: 0.85rem; font-weight: 800; color: white; text-align: center; }
.result-card-nameen{ font-size: 0.68rem; color: rgba(255,255,255,0.6); text-align: center; }
.result-card-badge {
  padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 800;
  letter-spacing: 0.03em;
}
.badge-pos { background: rgba(34,197,94,0.25); color: #4ade80; border: 1px solid rgba(34,197,94,0.4); }
.badge-neg { background: rgba(239,68,68,0.25);  color: #f87171; border: 1px solid rgba(239,68,68,0.4); }

/* 확률 박스 */
.prob-box {
  background: var(--surface); border-radius: 20px;
  padding: 28px 28px 22px; text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.prob-title { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin-bottom: 16px; letter-spacing: 0.05em; text-transform: uppercase; }

.prob-track {
  height: 16px; border-radius: 8px;
  background: var(--surface2); overflow: hidden; margin-bottom: 16px;
  border: 1px solid var(--border);
}

.prob-bar {
  height: 100%; border-radius: 8px; width: 0;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.prob-pct {
  font-size: 3.5rem; font-weight: 900; line-height: 1;
  margin-bottom: 10px;
}

.prob-msg { font-size: 0.95rem; color: var(--text-sub); line-height: 1.6; }

/* 긍/부정 밸런스 */
.balance-row {
  background: var(--surface); border-radius: 14px;
  padding: 16px 20px; border: 1px solid var(--border);
  display: flex; gap: 16px; align-items: center; justify-content: center;
}

.balance-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; font-weight: 700;
}
.dot-pos { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; }
.dot-neg { width: 10px; height: 10px; border-radius: 50%; background: #f87171; }

/* 섹션 타이틀 */
.sec-title {
  font-size: 0.85rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* 카드별 해석 */
.card-readings { display: flex; flex-direction: column; gap: 12px; }

.reading-item {
  background: var(--surface); border-radius: 14px;
  padding: 16px; border: 1px solid var(--border);
  display: flex; gap: 14px; align-items: flex-start;
}

.reading-icon {
  width: 48px; height: 64px; border-radius: 8px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.reading-icon .r-emoji { font-size: 1.4rem; }
.reading-icon .r-mini  { font-size: 0.4rem; color: rgba(255,255,255,0.8); font-weight: 700; text-align: center; }

.reading-body { flex: 1; }
.reading-name { font-size: 0.95rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.reading-keyword {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 0.72rem; font-weight: 700; margin-bottom: 8px;
}
.kw-pos { background: rgba(34,197,94,0.2); color: #4ade80; }
.kw-neg { background: rgba(239,68,68,0.2);  color: #f87171; }

.reading-meaning { font-size: 0.86rem; color: var(--text-sub); line-height: 1.7; }

/* 종합 해석 */
.overall-box {
  background: var(--surface); border-radius: 14px;
  padding: 20px; border: 1px solid var(--border);
  font-size: 0.93rem; color: var(--text-sub); line-height: 1.8;
}

/* 카카오톡 공유 */
.share-wrap { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.btn-share {
  display: flex; align-items: center; gap: 10px;
  background: #FEE500; color: #191919;
  border: none; border-radius: 14px;
  padding: 14px 32px; font-size: 1rem; font-weight: 800;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(254,229,0,0.35);
}
.btn-share:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(254,229,0,0.5); }
.btn-share:active { transform: translateY(0); }

.share-msg {
  font-size: 0.85rem; color: var(--text-sub);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 18px;
}

.hidden { display: none !important; }

/* ── 정보 섹션 (웰컴 화면 하단) ─────────────────── */
.info-section {
  max-width: 800px; margin: 0 auto;
  padding: 48px 24px 40px;
  display: flex; flex-direction: column; gap: 40px;
}

.info-title {
  font-size: 1.3rem; font-weight: 800; color: var(--text);
  text-align: center;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

.info-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}

.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.info-icon { font-size: 2rem; }

.info-card h3 {
  font-size: 0.95rem; font-weight: 800; color: var(--text);
}

.info-card p {
  font-size: 0.82rem; color: var(--text-sub); line-height: 1.7;
}

.tarot-guide { display: flex; flex-direction: column; gap: 16px; }

.tarot-guide h2 {
  font-size: 1.1rem; font-weight: 800; color: var(--text);
}

.suit-grid {
  display: flex; flex-direction: column; gap: 8px;
}

.suit-item {
  border-radius: 12px; padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.suit-item strong {
  font-size: 0.85rem; font-weight: 800; color: white;
  white-space: nowrap; min-width: 120px;
}

.suit-item span {
  font-size: 0.8rem; color: rgba(255,255,255,0.75); line-height: 1.6;
}

/* ── FAQ ─────────────────────────────────────────── */
.faq-section { display: flex; flex-direction: column; gap: 12px; }

.faq-section h2 {
  font-size: 1.1rem; font-weight: 800; color: var(--text);
  margin-bottom: 4px;
}

.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}

.faq-item h3 {
  font-size: 0.88rem; font-weight: 800; color: var(--gold);
  margin-bottom: 6px;
}

.faq-item p {
  font-size: 0.82rem; color: var(--text-sub); line-height: 1.75;
}

.disclaimer {
  font-size: 0.75rem; color: var(--text-muted);
  text-align: center; line-height: 1.7;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

/* ── 사이트 푸터 ─────────────────────────────────── */
.site-footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 20px 24px;
}

.footer-inner {
  max-width: 800px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

.footer-brand {
  font-weight: 800; font-size: 0.95rem; color: var(--text-sub);
}

.footer-nav {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; justify-content: center;
  font-size: 0.78rem; color: var(--text-muted);
}

.footer-nav a {
  color: var(--text-sub); text-decoration: none;
}
.footer-nav a:hover { color: var(--gold); text-decoration: underline; }

.footer-sep { color: var(--border); }

/* ── 색상 유틸 ───────────────────────────────────── */
.color-red    { color: #f87171; }
.color-orange { color: #fb923c; }
.color-green  { color: #4ade80; }
.color-gold   { color: var(--gold); }

/* ── 모바일 ──────────────────────────────────────── */
@media (max-width: 480px) {
  #screen-welcome h1 { font-size: 1.6rem; }
  .orb { font-size: 4rem; }
  .cards-grid { --card-w: 72px; gap: 8px; padding: 12px; }
  .card-emoji { font-size: 1.2rem; }
  .card-name  { font-size: 0.55rem; }
  .result-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .result-card { padding: 12px 8px; }
  .result-card-emoji { font-size: 1.8rem; }
  .result-card-name  { font-size: 0.75rem; }
  .prob-pct { font-size: 2.8rem; }
  .select-footer { flex-direction: column; gap: 10px; }
  .preview-row { justify-content: center; }
  .info-grid { grid-template-columns: 1fr; }
  .suit-item { flex-direction: column; gap: 4px; }
  .suit-item strong { min-width: unset; }
  .info-section { padding: 32px 16px 32px; }
}
