/* 퍼널 공용 스타일. 상품별 색은 product.json 의 theme 에서 CSS 변수로 주입한다. */

:root {
  --accent: #D4AF37;
  --accent-soft: #F9E27A;
  --ink: #FFF7D6;
  --bg: #0f0a14;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #0a0a0a;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  word-break: keep-all;
}

body.locked { overflow: hidden; }

#root { min-height: 100dvh; }

.boot {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  color: #666; font-size: 13px;
}

/* ── 퍼널 무대 ─────────────────────────────── */
.stage {
  position: relative; width: 100%; max-width: 430px; height: 100dvh;
  margin: 0 auto; background: var(--bg); overflow: hidden; touch-action: pan-y;
}

.slot {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
}
.slot.active { opacity: 1; pointer-events: auto; transform: none; z-index: 3; }

.scene-bg { position: absolute; inset: 0; z-index: 0; }

.scene-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 1; opacity: 0; transition: opacity .6s ease;
}
.scene-video.ready { opacity: 1; }

.scrim {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.68) 0%, rgba(0,0,0,.12) 40%, rgba(0,0,0,.88) 100%);
}

.content {
  position: relative; z-index: 3; width: 86%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  text-align: center; pointer-events: none;
}
.content > * { pointer-events: auto; }

.bubble {
  display: inline-block; padding: 11px 20px; border-radius: 999px;
  font-size: 17px; font-weight: 700; line-height: 1.5;
  border: 1px solid rgba(212,175,55,.5); background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px); color: var(--ink);
}
.sub { font-size: 13px; color: rgba(255,255,255,.68); }

.btn {
  margin-top: 22px; width: 100%; max-width: 320px; min-height: 52px;
  border-radius: 999px; border: none; cursor: pointer;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #1a1200; font-weight: 800; font-size: 15px;
  transition: transform .12s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ── 선택지 ─────────────────────────────── */
.choices { display: flex; flex-direction: column; gap: 9px; width: 100%; max-width: 320px; margin-top: 14px; }
.choice {
  min-height: 48px; padding: 12px 18px; border-radius: 14px; cursor: pointer;
  border: 1px solid rgba(212,175,55,.35); background: rgba(0,0,0,.55);
  color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.4;
  transition: background .18s ease, border-color .18s ease;
}
.choice:active, .choice:hover { background: rgba(212,175,55,.18); border-color: var(--accent); }
.choice:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── 입력 폼 ─────────────────────────────── */
.form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.label { font-size: 11px; color: rgba(212,175,55,.9); letter-spacing: .04em; font-weight: 600; }

.inp, .sel {
  min-height: 46px; border-radius: 12px; padding: 0 14px;
  border: 1px solid rgba(212,175,55,.28); background: rgba(0,0,0,.62);
  color: var(--ink); font-size: 15px; outline: none; width: 100%;
  font-family: inherit;
}
.inp:focus, .sel:focus { border-color: var(--accent); }
.sel {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(212,175,55,.8) 50%), linear-gradient(135deg, rgba(212,175,55,.8) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.row { display: grid; gap: 7px; }
.row.d3 { grid-template-columns: 1.25fr 1fr 1fr; }
.row.d2 { grid-template-columns: 1fr 1fr; }
.row.g2 { grid-template-columns: 1fr 1fr; }

.toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: rgba(255,255,255,.75); padding: 4px 0;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.seg button {
  min-height: 46px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(212,175,55,.28); background: rgba(0,0,0,.62); color: rgba(255,255,255,.7);
  font-family: inherit;
}
.seg button[aria-pressed="true"] { background: rgba(212,175,55,.22); border-color: var(--accent); color: var(--ink); }

.divider {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 0;
  font-size: 11px; color: rgba(255,255,255,.45);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.14); }

.err {
  font-size: 12.5px; color: #FF9A8B; line-height: 1.5; text-align: left;
  background: rgba(255,80,60,.1); border: 1px solid rgba(255,120,100,.3);
  border-radius: 10px; padding: 9px 12px;
}

.notice { font-size: 11px; color: rgba(255,255,255,.5); line-height: 1.6; text-align: left; }
.notice a { color: rgba(212,175,55,.9); }

/* ── 진행 표시 / 스와이프 ─────────────────── */
.progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: rgba(255,255,255,.1); z-index: 20; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); transition: width .35s ease; }

.hint {
  position: absolute; left: 14px; top: 12px; z-index: 20; font-size: 11px;
  color: rgba(255,255,255,.6); border: 1px solid rgba(212,175,55,.3);
  padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,.45);
  pointer-events: none; opacity: 0; transition: opacity .3s ease;
}
.edge {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0; z-index: 30; pointer-events: none;
  transition: opacity .2s ease;
}

/* ── 결과 화면 ─────────────────────────────── */
.report {
  min-height: 100dvh; background: #0b0910; color: #EDE8DA;
  padding: 28px 20px calc(56px + var(--safe-b));
}
.report-inner { max-width: 620px; margin: 0 auto; }

.report h1 {
  font-size: 20px; font-weight: 800; color: var(--ink); margin: 0 0 4px;
  letter-spacing: -.01em;
}
.report .who { font-size: 13px; color: rgba(255,255,255,.5); margin: 0 0 22px; }

/* 명식판 — 생성 대기 중 연출을 겸한다 */
.chart {
  border: 1px solid rgba(212,175,55,.25); border-radius: 14px;
  background: rgba(212,175,55,.05); padding: 16px; margin-bottom: 20px;
}
.chart-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.pil { display: flex; flex-direction: column; gap: 5px; }
.pil .cap { font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .06em; }
.pil .gz {
  font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.25;
  font-family: "Apple SD Gothic Neo", serif;
  opacity: 0; transform: translateY(4px);
  transition: opacity .5s ease, transform .5s ease;
}
.pil .gz.in { opacity: 1; transform: none; }
.pil .gz.none { font-size: 12px; color: rgba(255,255,255,.35); font-weight: 400; }
.pil .ko { font-size: 10.5px; color: rgba(255,255,255,.4); }

.chart-meta {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; color: rgba(255,255,255,.55); line-height: 1.6;
}
.chart-meta b { color: rgba(212,175,55,.9); font-weight: 600; }

.oheng { display: flex; gap: 5px; flex-wrap: wrap; }
.oheng span {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.7);
}
.oheng span.zero { opacity: .38; text-decoration: line-through; }
.oheng span.top { border-color: rgba(212,175,55,.6); color: var(--ink); }

/* 섹션 */
.sec { margin: 0 0 26px; opacity: 0; transform: translateY(8px); animation: rise .5s ease forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.sec h2 {
  font-size: 15px; font-weight: 700; color: var(--accent-soft); margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.sec h2::before {
  content: ""; width: 14px; height: 1px; background: var(--accent); flex: none;
}
.sec p { font-size: 15px; line-height: 1.85; margin: 0; white-space: pre-wrap; }

.loading {
  display: flex; align-items: center; gap: 9px; padding: 14px 0;
  font-size: 13px; color: rgba(212,175,55,.85);
}
.spin {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid rgba(212,175,55,.25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.report-foot {
  margin-top: 32px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 11px; color: rgba(255,255,255,.42); line-height: 1.7;
}
.report-actions { display: flex; gap: 9px; margin-top: 18px; flex-wrap: wrap; }
.report-actions button {
  flex: 1; min-width: 130px; min-height: 46px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(212,175,55,.35); background: transparent; color: var(--ink);
  font-size: 14px; font-weight: 600; font-family: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *, .sec { animation: none !important; transition: none !important; opacity: 1 !important; transform: none !important; }
}
