/* ---- Base / 몽환적 배경 ---- */
:root {
  --bg-0: #0a0719;
  --bg-1: #1a0f3a;
  --bg-2: #2b1855;
  --ink: #ece7ff;
  --ink-dim: #b8aee0;
  --gold: #e9d3a1;
  --gold-soft: #c9b07a;
  --violet: #8a6bff;
  --plum: #5a2e8e;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Noto Serif KR", "Nanum Myeongjo", serif;
  color: var(--ink);
  background-color: #050310;
  overflow-x: hidden;
  letter-spacing: 0.01em;
  line-height: 1.7;
  min-height: 100vh;
}

/* 고정 배경 그라데이션 (스크롤해도 잘리지 않도록 fixed) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 60% 40% at 50% 45%, rgba(102, 56, 200, 0.42), transparent 70%),
    radial-gradient(ellipse 50% 35% at 20% 55%, rgba(80, 40, 160, 0.28), transparent 72%),
    radial-gradient(ellipse 55% 45% at 78% 70%, rgba(60, 30, 140, 0.32), transparent 72%);
  background-color: #0a0719;
  animation: drift-bg 28s ease-in-out infinite alternate;
}
/* body::before z-index를 -3으로 내려서 stars/moon이 그 위, 페이드 마스크가 최상단에 깔리도록 */
@keyframes drift-bg {
  0%   { background-position: 0% 0%, 0% 0%, 0% 0%; filter: hue-rotate(0deg); }
  50%  { background-position: 4% 3%, -3% 4%, 5% -3%; filter: hue-rotate(8deg); }
  100% { background-position: -3% 6%, 5% -2%, -4% 4%; filter: hue-rotate(-6deg); }
}

/* 상하단 페이드 마스크 — 사파리 theme-color(#0a0719)와 끊김 없이 연결 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom,
      #0a0719 0%,
      rgba(10, 7, 25, 0.85) 6%,
      rgba(10, 7, 25, 0.0) 18%,
      rgba(10, 7, 25, 0.0) 82%,
      rgba(10, 7, 25, 0.85) 94%,
      #0a0719 100%);
}

/* 별 반짝임 + 천천히 표류 */
.stars {
  position: fixed; inset: -10%; pointer-events: none; z-index: -2;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 67%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 43% 13%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 82%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 71% 38%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 83% 24%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 73%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 47%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 18% 91%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 5%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 58%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 95% 48%, #fff 50%, transparent 51%);
  background-size: 100% 100%;
  opacity: 0.35;
  animation: twinkle 6s ease-in-out infinite alternate, drift-stars 60s linear infinite;
}
@keyframes twinkle {
  0% { opacity: 0.2; }
  100% { opacity: 0.55; }
}
@keyframes drift-stars {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(-1.5%, -1%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.moon {
  position: fixed;
  top: -120px; right: -120px;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, #fff7d8 0%, #e6c970 30%, #b48a2c 60%, transparent 72%);
  filter: blur(2px);
  opacity: 0.18;
  z-index: -2;
  pointer-events: none;
  animation: moon-float 14s ease-in-out infinite alternate;
}
@keyframes moon-float {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.18; }
  100% { transform: translate(-20px, 18px) scale(1.04); opacity: 0.24; }
}

/* ---- Layout ---- */
main#stage {
  position: relative;
  z-index: 1;
}

.scene {
  width: 100%;
  display: flex;
  justify-content: center;
  animation: fadeIn 1.1s ease both;
}
.scene[hidden] { display: none !important; }

/* 풀페이지: viewport 안에 다 들어옴, 스크롤 없음 */
.scene.fullpage {
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  padding:
    calc(24px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
  overflow: hidden;
}

/* 스크롤 가능: 콘텐츠 길어지면 자연스럽게 스크롤 (reading/result만) */
.scene.scrollable {
  align-items: flex-start;
  padding:
    calc(48px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(48px + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
}

.inner { width: 100%; text-align: center; }
.narrow { max-width: 540px; }
.wide   { max-width: 1100px; }
.inner .btn { display: inline-block; }
.inner > .reading-text { text-align: left; }

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

/* ---- Typography ---- */
.title {
  font-size: 3.4rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  margin: 0 0 18px;
  text-align: center;
}
.title-sm {
  font-size: 1.7rem;
  font-weight: 500;
  text-align: center;
  margin: 0 0 18px;
  letter-spacing: 0.08em;
}
.subtitle {
  text-align: center;
  color: var(--ink-dim);
  font-size: 1rem;
  margin: 0 0 36px;
  letter-spacing: 0.05em;
}
.prose {
  text-align: center;
  color: var(--ink-dim);
  margin: 8px 0 0;
}
.hint { color: var(--gold-soft); font-size: 0.9rem; }
.mt-1 { margin-top: 12px; }

.shimmer {
  background: linear-gradient(90deg, #e9d3a1 0%, #fff7d8 30%, #e9d3a1 60%, #b48a2c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% auto;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.fade-in-late { animation: fadeIn 1.6s ease 0.5s both; }

.divider {
  width: 60%; height: 1px;
  margin: 28px auto;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  opacity: 0.5;
}

/* ---- Form ---- */
.form-card {
  margin: 32px auto 0;
  display: flex; flex-direction: column; gap: 18px;
  padding: 28px;
  background: rgba(30, 18, 64, 0.55);
  border: 1px solid rgba(201, 176, 122, 0.25);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  text-align: left;
}
.form-card .btn { align-self: center; margin-top: 4px; }
.form-error {
  display: none;
  margin: 0 0 4px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(120, 30, 40, 0.35);
  border: 1px solid rgba(220, 120, 140, 0.4);
  color: #ffd5dc;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-align: center;
}
.form-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--gold-soft); }
.form-card input, .form-card textarea {
  background: rgba(10, 7, 25, 0.5);
  color: var(--ink);
  border: 1px solid rgba(201, 176, 122, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s;
  resize: vertical;
}
.form-card input:focus, .form-card textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(233, 211, 161, 0.1);
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.08em;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.3s, background 0.3s;
}
.btn.primary {
  background: linear-gradient(135deg, #6a4ad9 0%, #b48a2c 100%);
  color: #fff7e6;
  border: none;
  box-shadow: 0 4px 16px rgba(106, 74, 217, 0.4);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(180, 138, 44, 0.5); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--gold-soft);
  color: var(--gold-soft);
}
.btn.ghost:hover { background: rgba(201, 176, 122, 0.1); }

/* ---- Preparing orb ---- */
.prep-orb, .waiting-orb {
  width: 120px; height: 120px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7d8 0%, #e6c970 25%, #6a4ad9 60%, #2b1855 100%);
  box-shadow: 0 0 60px rgba(180, 138, 44, 0.5), inset 0 0 40px rgba(255, 255, 255, 0.2);
  animation: pulse-orb 3s ease-in-out infinite alternate;
}
.waiting-orb { width: 90px; height: 90px; opacity: 0.7; }
@keyframes pulse-orb {
  0%   { transform: scale(0.95); box-shadow: 0 0 40px rgba(180, 138, 44, 0.4); }
  100% { transform: scale(1.05); box-shadow: 0 0 80px rgba(180, 138, 44, 0.7); }
}

/* ---- Deck ---- */
.picked-indicator {
  display: flex; gap: 12px;
  justify-content: center;
  margin: 16px 0 24px;
  font-size: 1.5rem;
  color: var(--gold-soft);
}
.picked-indicator span.filled {
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold);
}

/* ---- 호 형태 카드 덱 ---- */
.deck-inner {
  max-width: none !important;       /* .wide(1100px) 제한 해제: 카드 덱은 viewport 전체 폭 사용 */
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.deck-arc {
  position: relative;
  width: 100%;
  height: 460px;
  overflow-x: auto;
  overflow-y: hidden;             /* 세로 스크롤 차단 — 카드가 호 따라 위로 솟아도 영역 밖으로 안 나감 */
  white-space: nowrap;
  /* scroll-behavior는 마우스 드래그 + 관성과 충돌하므로 'auto' 유지 */
  padding-top: 150px;             /* 호의 위쪽 솟음 + 회전 여유 (안전 마진 충분히) */
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;          /* 스크롤바 숨김 (가로 스크롤 hint는 텍스트로 안내) */
  cursor: grab;
  user-select: none;              /* 드래그 시 텍스트 선택 방지 */
}
.deck-arc.dragging,
.deck-arc.dragging .card-back { cursor: grabbing; }

/* 카드덱 페이지는 viewport 전체 폭 사용 — PC/모바일 공통 */
.scene.fullpage[data-scene="deck"] {
  padding-left: 0;
  padding-right: 0;
}
.scene.fullpage[data-scene="deck"] .deck-inner > h2,
.scene.fullpage[data-scene="deck"] .deck-inner > p,
.scene.fullpage[data-scene="deck"] .deck-inner > .picked-indicator,
.scene.fullpage[data-scene="deck"] .deck-inner > #confirm-cards-btn {
  padding-left: 18px;
  padding-right: 18px;
  box-sizing: border-box;
}
.deck-arc::-webkit-scrollbar { display: none; }

.card-back {
  display: inline-block;
  vertical-align: bottom;          /* 카드 하단 정렬 (호 회전 기준점) */
  width: 130px;
  aspect-ratio: 2 / 3;
  margin-left: -56px;              /* 반쯤 겹침: width의 약 43% */
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, #2b1855 0px, #2b1855 4px, #1a0f3a 4px, #1a0f3a 8px),
    radial-gradient(circle, #5a2e8e 0%, #1a0f3a 80%);
  background-blend-mode: overlay;
  border: 1px solid rgba(201, 176, 122, 0.3);
  cursor: pointer;
  position: relative;
  transform-origin: 50% 100%;      /* 카드 하단 중앙: 부채꼴 회전 중심 */
  /* 평소: filter/shadow/border만 부드럽게. transform은 매 스크롤 프레임마다 JS가 갱신하므로 transition 없음 */
  transition: filter 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  will-change: transform;
}
/* 선택/취소 순간에만 transform도 함께 transition — 살짝 오버슈팅하는 spring 곡선 */
.card-back.transitioning {
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.4s ease,
    box-shadow 0.4s ease,
    border-color 0.4s ease;
}
/* 첫·마지막 카드도 viewport 중앙까지 스크롤 가능하도록 양 끝 여백 */
.card-back:first-child { margin-left: 50vw; }
.card-back:last-child  { margin-right: 50vw; }

.card-back::before {
  content: "✦";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-soft);
  font-size: 1.4rem;
  opacity: 0.5;
}

/* hover 효과는 마우스 가능 장치에서만 — 모바일 sticky hover 방지 */
@media (hover: hover) and (pointer: fine) {
  .card-back:hover {
    filter: brightness(1.2);
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(233, 211, 161, 0.4);
  }
}

.card-back.picked {
  filter: brightness(1.35);
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(233, 211, 161, 0.6), inset 0 0 14px rgba(255, 247, 216, 0.3);
}
/* 명시적으로 선택 안 된 상태(잔존 hover 등) 리셋 */
.card-back:not(.picked) {
  border-color: rgba(201, 176, 122, 0.3);
  box-shadow: none;
}
.card-back.picked::after {
  content: "✦";
  position: absolute;
  top: 50%; left: 50%;
  color: var(--gold);
  font-size: 2.2rem;
  text-shadow: 0 0 16px var(--gold), 0 0 32px rgba(233, 211, 161, 0.7);
  z-index: 1;
  /* transform은 JS에서 카드 호 회전과 합쳐서 처리하지 않고, 자체 중앙 정렬 */
  transform: translate(-50%, -50%);
}

.deck-hint {
  margin: 18px auto 0;
  color: var(--gold-soft);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-align: center;
  line-height: 1.8;
}

#confirm-cards-btn {
  margin-top: 18px;
  transition: opacity 0.4s, transform 0.3s, box-shadow 0.3s;
}
#confirm-cards-btn:disabled {
  opacity: 0.35;
}

/* ---- Reveal row ---- */
.reveal-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 32px 0;
}
.reveal-row.small .flip-card { width: 110px; }

.flip-card {
  width: 180px;
  aspect-ratio: 2 / 3;
  perspective: 1200px;
}
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 1.2s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
  border: 1px solid rgba(201, 176, 122, 0.4);
  overflow: hidden;
}
.flip-face.back {
  background:
    repeating-linear-gradient(45deg, #2b1855 0px, #2b1855 4px, #1a0f3a 4px, #1a0f3a 8px),
    radial-gradient(circle, #5a2e8e 0%, #1a0f3a 80%);
  background-blend-mode: overlay;
  display: flex; align-items: center; justify-content: center;
}
.flip-face.back::before {
  content: "✦"; color: var(--gold-soft); font-size: 2rem; opacity: 0.6;
}
.flip-face.front {
  transform: rotateY(180deg);
  background: #1a0f3a;
}
.flip-face.front img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.flip-face.front.reversed img { transform: rotate(180deg); }

.card-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--gold-soft);
  margin-top: 8px;
  letter-spacing: 0.05em;
}
.card-caption .pos { color: var(--ink-dim); display: block; font-size: 0.75rem; margin-bottom: 2px; }
.card-caption .ori { color: var(--ink); font-size: 0.8rem; }

.flip-wrap { display: flex; flex-direction: column; align-items: center; }

/* ---- Reading ---- */
.reading-text {
  max-width: 760px;
  margin: 24px auto 0;
  padding: 0 20px;
  font-size: 1.05rem;
  line-height: 2;
  color: var(--ink);
  white-space: normal;
  text-align: left;
  word-break: keep-all;
}
.reading-text h2 {
  color: var(--gold);
  font-weight: 500;
  margin: 28px 0 8px;
  font-size: 1.18rem;
  letter-spacing: 0.06em;
  border-left: 2px solid var(--gold-soft);
  padding-left: 12px;
}
.reading-text strong { color: var(--gold); font-weight: 500; }
.reading-text p { margin: 0.6em 0; }
.reading-tail {
  text-align: center;
  margin: 16px auto 0;
  color: var(--gold);
  max-width: 760px;
}

/* ---- 풀이 분석 중 — 카드 펄스/플로팅 + 글로우 ---- */
.reading-status {
  text-align: center;
  color: var(--gold-soft);
  letter-spacing: 0.18em;
  font-size: 0.95rem;
  margin: 28px auto;
  max-width: 540px;
  font-style: italic;
  animation: status-breathe 2.6s ease-in-out infinite alternate;
}
@keyframes status-breathe {
  from { opacity: 0.5; letter-spacing: 0.18em; }
  to   { opacity: 1;   letter-spacing: 0.22em; }
}
.reading-status.fading {
  animation: fade-out 0.8s ease forwards;
}
@keyframes fade-out {
  to { opacity: 0; height: 0; margin: 0; }
}

/* 분석 중: 캡션 숨김 + 카드 플로팅 + 펄스 글로우 */
.reveal-row.analyzing .card-caption {
  opacity: 0;
  transform: translateY(-6px);
}
.reveal-row.analyzing .flip-wrap {
  animation: card-float 3.2s ease-in-out infinite alternate;
}
.reveal-row.analyzing .flip-wrap:nth-child(2) { animation-delay: 0.45s; }
.reveal-row.analyzing .flip-wrap:nth-child(3) { animation-delay: 0.9s; }
@keyframes card-float {
  from {
    transform: translateY(0) rotate(-1deg);
    filter: drop-shadow(0 0 12px rgba(180, 138, 44, 0.4)) blur(0.2px);
  }
  to {
    transform: translateY(-14px) rotate(1.5deg);
    filter: drop-shadow(0 0 28px rgba(233, 211, 161, 0.85)) blur(0.4px);
  }
}

/* 캡션은 분석 종료 후 자연스럽게 페이드인 */
.reveal-row .card-caption {
  transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}
.reveal-row.revealed .card-caption {
  opacity: 1;
  transform: translateY(0);
}
.cursor { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---- Result (모바일 화면 비율, 약 9:19.5) ---- */
.result-card {
  /* 너비를 의도적으로 좁혀 캡처 비율이 세로로 너무 길어지지 않게 */
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 22px;
  background: linear-gradient(180deg, rgba(30, 18, 64, 0.92), rgba(10, 7, 25, 0.96));
  border: 1px solid rgba(201, 176, 122, 0.3);
  border-radius: 18px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  /* 캡처 시 폰트 렌더링 안정화 */
  font-size: 0.95rem;
}
.result-header { text-align: center; margin-bottom: 18px; }
.result-header h1 {
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 0;
  word-break: keep-all;
}
.result-meta { color: var(--ink-dim); font-size: 0.82rem; margin-top: 6px; letter-spacing: 0.08em; }
.result-question {
  text-align: center;
  margin: 14px 0 22px;
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-top: 1px solid rgba(201, 176, 122, 0.2);
  border-bottom: 1px solid rgba(201, 176, 122, 0.2);
  word-break: keep-all;
}
.result-footer {
  text-align: center; margin-top: 24px;
  color: var(--gold-soft);
  letter-spacing: 0.25em;
  font-size: 0.82rem;
}

/* 결과 카드 안의 카드 3장 — 모바일 비율 보존을 위해 작게 */
#result-cards.reveal-row { gap: 12px; margin: 16px 0; }
#result-cards .flip-card { width: 92px; }
#result-cards .card-caption { font-size: 0.75rem; margin-top: 6px; }
#result-cards .card-caption .pos { font-size: 0.7rem; }
#result-cards .card-caption .ori { font-size: 0.72rem; }

/* 결과 안의 풀이 텍스트도 컴팩트하게 */
#result-text {
  font-size: 0.92rem;
  line-height: 1.75;
  padding: 0 4px;
}
#result-text h2 {
  font-size: 1rem;
  margin: 18px 0 4px;
}
.result-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin: 40px auto 32px;
  max-width: 880px;
  padding: 0 16px;
}
.result-actions::before {
  content: "✦ ✦ ✦";
  color: var(--gold-soft);
  opacity: 0.45;
  font-size: 0.85rem;
  letter-spacing: 0.5em;
  margin-bottom: 4px;
}

/* 저장 버튼 - 황금빛 강조 */
.btn.save {
  background: linear-gradient(135deg, #b48a2c 0%, #e9d3a1 50%, #b48a2c 100%);
  background-size: 200% auto;
  color: #1a0f3a;
  font-weight: 500;
  letter-spacing: 0.15em;
  padding: 14px 36px;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(180, 138, 44, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.98rem;
  transition: transform 0.3s, box-shadow 0.3s, background-position 0.8s;
  position: relative;
}
.btn.save:hover {
  transform: translateY(-2px);
  background-position: 100% center;
  box-shadow: 0 10px 28px rgba(233, 211, 161, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.save::before {
  content: "❉ ";
  opacity: 0.7;
  margin-right: 4px;
}

/* 떠나기 버튼 - 조용한 텍스트 */
.btn.leave {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.18em;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.3s, letter-spacing 0.3s;
  border-bottom: 1px solid transparent;
}
.btn.leave:hover {
  color: var(--gold);
  letter-spacing: 0.22em;
  border-bottom-color: rgba(201, 176, 122, 0.4);
}

/* ---- Waiting ---- */
#queue-ahead { color: var(--gold); font-size: 1.4rem; font-family: inherit; }

#start-reading-btn, #goto-result-btn {
  margin: 28px auto 12px;
}

/* ---- Transitions between scenes ---- */
.scene.fade-out { animation: fadeOut 0.8s ease both; }
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---- Responsive ---- */
/* ---- 모바일 (≤600px) ---- */
@media (max-width: 600px) {
  /* 타이포 컴팩트화 */
  .title { font-size: 2rem; letter-spacing: 0.15em; margin-bottom: 12px; }
  .title-sm { font-size: 1.25rem; letter-spacing: 0.06em; margin-bottom: 12px; }
  .subtitle { font-size: 0.85rem; margin-bottom: 22px; letter-spacing: 0.03em; }
  .prose { font-size: 0.9rem; line-height: 1.65; word-break: keep-all; }
  .hint { font-size: 0.78rem; }
  .divider { margin: 20px auto; }

  /* fullpage padding 줄임 — 모바일 viewport 최대한 활용 */
  .scene.fullpage {
    padding:
      calc(16px + env(safe-area-inset-top))
      14px
      calc(16px + env(safe-area-inset-bottom))
      14px;
  }
  .scene.scrollable {
    padding:
      calc(28px + env(safe-area-inset-top))
      16px
      calc(28px + env(safe-area-inset-bottom))
      16px;
  }

  /* 폼 */
  .form-card { padding: 20px; gap: 14px; margin-top: 20px; }
  .form-card label { font-size: 0.8rem; }
  .form-card input,
  .form-card textarea { font-size: 0.95rem; padding: 10px 12px; }
  .form-error { font-size: 0.82rem; padding: 8px 10px; }

  /* 버튼 */
  .btn { font-size: 0.92rem; padding: 10px 24px; }
  .btn.save { font-size: 0.92rem; padding: 12px 28px; }

  /* 준비/대기 오브 */
  .prep-orb, .waiting-orb { width: 80px; height: 80px; margin-bottom: 16px; }

  /* 선택 인디케이터 */
  .picked-indicator { font-size: 1.15rem; gap: 10px; margin: 6px 0 12px; }

  /* 카드 덱 (호) — 모바일 컴팩트 */
  .deck-arc {
    height: 280px;
    padding-top: 80px;
    padding-bottom: 12px;
  }
  .card-back {
    width: 78px;
    margin-left: -33px;
    border-radius: 6px;
  }
  .card-back::before { font-size: 0.95rem; }
  .card-back.picked::after { font-size: 1.5rem; }

  .deck-inner { gap: 4px; }
  .deck-hint {
    font-size: 0.74rem;
    margin-top: 10px;
    line-height: 1.55;
    letter-spacing: 0.04em;
  }
  #confirm-cards-btn { margin-top: 10px; }

  /* reveal / reading 카드 */
  .reveal-row { gap: 14px; margin: 22px 0; }
  .flip-card { width: 110px; }
  .reveal-row.small .flip-card { width: 78px; }
  .card-caption { font-size: 0.78rem; margin-top: 6px; }
  .card-caption .pos { font-size: 0.7rem; }

  /* 풀이 텍스트 */
  .reading-text { font-size: 0.95rem; line-height: 1.85; padding: 0 6px; }
  .reading-text h2 { font-size: 1.05rem; margin: 22px 0 6px; }
  .reading-status { font-size: 0.85rem; margin: 22px auto; letter-spacing: 0.12em; }

  /* 결과 카드 — 더 컴팩트 */
  .result-card { padding: 22px 16px; max-width: 100%; border-radius: 14px; }
  .result-header h1 { font-size: 1.2rem; letter-spacing: 0.05em; }
  .result-meta { font-size: 0.76rem; }
  .result-question { font-size: 0.85rem; padding: 8px 10px; }
  #result-cards.reveal-row { gap: 8px; margin: 14px 0; }
  #result-cards .flip-card { width: 76px; }
  #result-text { font-size: 0.88rem; line-height: 1.7; }
  #result-text h2 { font-size: 0.95rem; margin: 14px 0 4px; }
  .result-actions { margin: 24px auto 16px; gap: 14px; }
}
