:root {
  --cream: #FFF6EC;
  --card: #FFFFFF;
  --flame: #FF5A36;
  --yellow: #FFC93C;
  --ink: #3A2A22;
}

* { box-sizing: border-box; }

/* .btn 의 display:block 이 UA 의 [hidden] 을 덮어써서 필요 */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 24px 0 48px;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
               "Apple SD Gothic Neo", Roboto, sans-serif;
  line-height: 1.6;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px 20px;
  margin-bottom: 16px;
  text-align: center;
}

h1 { font-size: 26px; margin: 4px 0 12px; }
h2 { font-size: 22px; margin: 8px 0; }
h3 { font-size: 14px; margin: 0 0 8px; color: #7A6258; font-weight: 600; }

img { max-width: 100%; height: auto; }
.hero { width: 220px; }

.sub { color: #7A6258; margin: 8px 0 20px; }
.count { color: #7A6258; font-size: 14px; margin: 12px 0 0; }
/* 화면 전환 후 스크린리더 위치를 옮기려 프로그램적으로 focus() 하는 제목들.
   상호작용 요소가 아니라 UA 기본 focus ring 은 지운다(버튼의 :focus-visible 은 그대로). */
.question, #result-name { outline: none; }
.question { font-size: 20px; margin: 12px 0 24px; }
.tagline { color: var(--ink); font-weight: 700; margin: 0 0 16px; }
.desc { text-align: left; margin: 0; }

/* 버튼 */
.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 2px solid var(--flame);
  background: var(--card);
  color: var(--ink);
}
.btn:last-child { margin-bottom: 0; }
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.primary { background: var(--flame); color: #FFFFFF; font-size: 19px; }
/* .choice는 17px이라 flame(#FF5A36) 배경에 흰 글씨면 AA 미달(4.49:1) -> 더 진한 빨강 사용.
   .primary는 19px bold라 AA Large(3:1) 기준으로 flame 그대로 통과. */
@media (hover: hover) {
  .choice:hover { background: #D23A1B; color: #FFFFFF; }
}
.choice:active {
  background: #D23A1B;
  color: #FFFFFF;
}
.primary:hover, .primary:active {
  background: var(--flame);
  color: #FFFFFF;
}
.outline:hover, .outline:active { background: #FFEDE7; }

/* 진행 바 */
.progress {
  height: 8px;
  border-radius: 4px;
  background: #F0E4D8;
  overflow: hidden;
}
.bar {
  height: 100%;
  width: 0;
  background: var(--flame);
  transition: width .25s ease;
}

/* 결과 궁합 */
.mates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}
.mate img { width: 88px; }
.mate p { margin: 4px 0 0; font-weight: 700; font-size: 15px; }

/* 로딩 흔들림 */
.shake { animation: shake 1s ease-in-out infinite; }
@keyframes shake {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
  .bar { transition: none; }
}

/* 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 15px;
  margin: 0;
}

/* ===== 문항 장면 (CSS만, 이미지 파일 추가 없음) ===== */
.scene {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  margin: 14px 0 4px;
  background: #E9DCCB;
}
.scene-face {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translateX(-50%);
  height: 70%;
  width: auto;
  max-width: none;
  z-index: 2;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .35));
}

/* 밤하늘 + 별 + 달 */
.scene.night {
  background:
    radial-gradient(circle 13px at 80% 20%, #FFF6D0 99%, transparent),
    radial-gradient(1.6px 1.6px at 12% 18%, #FFFFFF 99%, transparent),
    radial-gradient(1.6px 1.6px at 26% 34%, #FFFFFF 99%, transparent),
    radial-gradient(1.2px 1.2px at 38% 12%, #FFF0C0 99%, transparent),
    radial-gradient(1.8px 1.8px at 52% 26%, #FFFFFF 99%, transparent),
    radial-gradient(1.2px 1.2px at 63% 8%, #FFFFFF 99%, transparent),
    radial-gradient(1.6px 1.6px at 92% 38%, #FFF0C0 99%, transparent),
    radial-gradient(1.2px 1.2px at 70% 44%, #FFFFFF 99%, transparent),
    radial-gradient(1.6px 1.6px at 18% 52%, #FFFFFF 99%, transparent),
    linear-gradient(#0C1533 0%, #24306B 60%, #4A3C66 100%);
}
.scene.night::after {
  content: "";
  position: absolute;
  inset: 74% 0 0;
  background: #101B33;
}

/* 숲: 하늘 + 나무 실루엣 */
.scene.forest { background: linear-gradient(#FBD79A 0%, #A8CBA6 55%, #5E8B63 100%); }
.scene.forest::before {
  content: "";
  position: absolute;
  inset: 26% 0 0;
  background: #24402C;
  clip-path: polygon(0 100%, 0 62%, 7% 14%, 14% 62%, 21% 30%, 28% 68%, 36% 8%, 44% 66%, 52% 28%,
                     60% 70%, 68% 16%, 76% 62%, 84% 32%, 92% 66%, 100% 38%, 100% 100%);
}
.scene.forest::after {
  content: "";
  position: absolute;
  inset: 78% 0 0;
  background: #3D6142;
}

/* 텐트 */
.scene.tent { background: linear-gradient(#1E2C55 0%, #6C79A8 62%, #6C79A8 70%, #4B5C39 70%); }
.scene.tent::before {
  content: "";
  position: absolute;
  left: 6%;
  bottom: 8%;
  width: 44%;
  height: 58%;
  background: linear-gradient(90deg, #E4653F 0 50%, #B94526 50%);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.scene.tent::after {
  content: "";
  position: absolute;
  left: 24%;
  bottom: 8%;
  width: 8%;
  height: 34%;
  background: #4A1E12;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* 강/계곡: 물결 */
.scene.river { background: linear-gradient(#CFEBF5 0%, #8FC7A0 44%, #6E9E78 100%); }
.scene.river::before {
  content: "";
  position: absolute;
  inset: 44% 0 0;
  background:
    repeating-linear-gradient(-8deg, rgba(255, 255, 255, .26) 0 2px, transparent 2px 24px),
    linear-gradient(#3B84A8, #12405C);
}

/* 비 */
.scene.rain { background: linear-gradient(#5D6C7C 0%, #8E9EAC 70%, #59614A 70%); }
.scene.rain::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(102deg, rgba(255, 255, 255, .55) 0 1.5px, transparent 1.5px 13px);
}
.scene.rain::after {
  content: "";
  position: absolute;
  left: 10%;
  top: 10%;
  width: 32%;
  height: 15%;
  /* 바닥선에 걸친 반타원 세 개를 겹쳐 구름 실루엣을 만든다 */
  background:
    radial-gradient(ellipse 32% 62% at 20% 100%, #46525F 99%, transparent),
    radial-gradient(ellipse 30% 100% at 50% 100%, #46525F 99%, transparent),
    radial-gradient(ellipse 30% 72% at 80% 100%, #46525F 99%, transparent);
}

/* 아침: 해 + 구름 */
.scene.morning { background: linear-gradient(#FFE3AC 0%, #FFF6EC 62%, #BFD9A0 62%); }
.scene.morning::before {
  content: "";
  position: absolute;
  right: 10%;
  top: 12%;
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #FFC93C;
  box-shadow: 0 0 22px 10px rgba(255, 201, 60, .45);
}
.scene.morning::after {
  content: "";
  position: absolute;
  left: 8%;
  top: 20%;
  width: 30%;
  height: 15%;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 26px 6px 0 -3px #FFFFFF, -14px 8px 0 -5px #FFFFFF;
}

/* ===== 결과: 스펙 목록 ===== */
.spec {
  margin: 20px 0 4px;
  text-align: left;
}
.spec-row {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: baseline;
  padding: 9px 2px;
  border-bottom: 1px solid #F0E4D8;
}
.spec-row:last-child { border-bottom: none; }
.spec dt {
  margin: 0;
  font-size: 13px;
  color: #7A6258;
  white-space: nowrap;
}
.spec dd {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}
.spec-stars {
  color: #D23A1B; /* flame(#FF5A36)은 흰 배경 텍스트로 쓰면 대비 3.1:1 이라 AA 미달 -> 진한 주색 사용 */
  letter-spacing: 1px;
}

/* ===== 결과: 4축 막대그래프 ===== */
.bars { margin-top: 20px; }
.bar-row { margin-bottom: 14px; }
.bar-name {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.bar-track {
  position: relative;
  height: 14px;
  border-radius: 7px;
  background: #F0E4D8;
  overflow: hidden;
}
.bar-mid {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  margin-left: -1px;
  background: #D8C6B4;
}
.bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 2px;
  background: var(--flame);
}
.bar-ends {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 0;
  font-size: 12px;
  color: #7A6258;
}

/* ===== 결과: 성격 불릿 ===== */
.bullets { margin-top: 22px; text-align: left; }
.bullet-sec { margin-bottom: 14px; }
.bullet-sec h3 { color: var(--ink); font-size: 15px; margin: 0 0 6px; }
.bullet-sec ul { margin: 0; padding-left: 20px; }
.bullet-sec li { margin-bottom: 4px; }

/* 궁합 카드의 "유형 보기" */
.btn.tiny {
  min-height: 36px;
  font-size: 14px;
  border-radius: 10px;
  margin: 8px 0 0;
  padding: 0 8px;
}
@media (hover: hover) {
  .btn.tiny:hover { background: #FFEDE7; }
}
.btn.tiny:active { background: #FFEDE7; }

/* 결과 카드 맨 위 "내 모닥이로 돌아가기" (궁합 유형 열람 중에만 노출) */
#back-to-mine { margin: 0 0 14px; }

#quiz.card,
#loading.card,
#result-card.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--warm-line);
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 201, 60, .18), transparent 25%),
    linear-gradient(180deg, var(--paper), var(--cream));
  box-shadow: 0 6px 0 var(--deep-forest), 0 18px 32px rgba(58, 42, 34, .14);
}

#quiz.card {
  padding: 20px;
}

#quiz.card::before,
#result-card.card::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 44% -20% -24%;
  transform: perspective(520px) rotateX(58deg);
  transform-origin: center bottom;
  background:
    radial-gradient(circle at 22% 26%, rgba(255, 201, 60, .72) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, .85) 0 2px, transparent 3px),
    linear-gradient(rgba(36, 64, 44, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 64, 44, .09) 1px, transparent 1px);
  background-size: auto, auto, 30px 25px, 30px 25px;
  opacity: .62;
  pointer-events: none;
}

#quiz.card > *,
#result-card.card > * { position: relative; z-index: 1; }

#quiz .scene-face { animation: scene-face-float 5.2s ease-in-out infinite; }
#result-card .hero { animation: result-hero-float 6.2s ease-in-out infinite; }
#result-card .mate img { animation: mate-float 5.8s ease-in-out .3s infinite; }

@keyframes scene-face-float {
  0%, 100% { transform: translateX(-50%) translateY(0); filter: drop-shadow(0 8px 7px rgba(86, 42, 23, .22)); }
  50% { transform: translateX(-50%) translateY(-3px); filter: drop-shadow(0 11px 9px rgba(86, 42, 23, .3)); }
}
@keyframes result-hero-float {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 10px 8px rgba(86, 42, 23, .2)); }
  50% { transform: translateY(-5px); filter: drop-shadow(0 13px 10px rgba(86, 42, 23, .26)); }
}
@keyframes mate-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

#quiz .progress {
  height: 12px;
  border: 2px solid var(--forest);
  border-radius: 999px;
  background: rgba(36, 64, 44, .16);
  box-shadow: inset 0 2px 4px rgba(24, 54, 44, .18);
}

#quiz .bar {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--flame));
}

#quiz .count {
  display: inline-block;
  margin: 12px 0 0;
  padding: 3px 11px;
  border: 1px solid var(--warm-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--orange-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

#quiz .scene {
  margin: 16px 0 18px;
  border: 4px solid rgba(255, 255, 255, .9);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--forest), 0 14px 24px rgba(58, 42, 34, .16);
}

#quiz .scene-face {
  filter: drop-shadow(0 8px 7px rgba(86, 42, 23, .22));
}

#quiz .question {
  margin: 26px auto 22px;
  max-width: 360px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  line-height: 1.4;
  letter-spacing: -.025em;
  text-wrap: balance;
  word-break: keep-all;
}

#quiz .choice {
  min-height: 60px;
  margin-bottom: 14px;
  padding: 10px 16px;
  border-color: var(--warm-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 4px 0 var(--forest), 0 9px 16px rgba(58, 42, 34, .1);
  color: var(--ink);
  line-height: 1.45;
  word-break: keep-all;
  transition: transform 150ms ease-out, background-color 150ms ease-out, filter 150ms ease-out;
}

@media (hover: hover) {
  #quiz .choice:hover {
    background: var(--peach);
    color: var(--ink);
    filter: brightness(1.02);
    transform: translateY(-2px);
  }
}

#quiz .choice:active {
  background: var(--peach);
  color: var(--ink);
  transform: translateY(3px);
}

#result {
  padding-bottom: 6px;
}

#result-card.card {
  padding: 28px 20px 24px;
}

#result-card::before {
  content: "";
  position: absolute;
  top: -118px;
  left: 50%;
  width: 330px;
  height: 260px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 201, 60, .54), rgba(255, 201, 60, .12) 58%, transparent 72%);
  pointer-events: none;
}

#result-card > * {
  position: relative;
}

#result-card .hero {
  width: 228px;
  margin: 0 auto -2px;
  filter: drop-shadow(0 10px 8px rgba(86, 42, 23, .2));
}

#result-name {
  margin: 4px 0 6px;
  color: var(--flame);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: -.04em;
  text-shadow: 0 3px 0 var(--yellow);
  text-wrap: balance;
  word-break: keep-all;
}

#result-card .tagline {
  display: inline-block;
  margin: 6px 0 18px;
  padding: 5px 12px;
  border: 1px solid var(--warm-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .76);
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
}

#result-card .desc {
  padding: 16px;
  border-left: 4px solid var(--yellow);
  border-radius: 4px 14px 14px 4px;
  background: rgba(255, 255, 255, .68);
  line-height: 1.75;
  text-wrap: pretty;
  word-break: keep-all;
}

#result-card .spec {
  margin-top: 20px;
  padding: 7px 14px;
  border: 1px solid var(--warm-line);
  border-radius: 16px;
  background: rgba(255, 249, 234, .88);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
}

#result-card .spec-row {
  padding: 10px 0;
  border-color: rgba(232, 203, 167, .72);
}

#result-card .bars {
  padding: 16px;
  border: 1px solid var(--warm-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .68);
}

#result-card .bar-track {
  border: 1px solid rgba(36, 64, 44, .28);
  background: rgba(36, 64, 44, .13);
}

#result-card .bar-fill {
  background: linear-gradient(90deg, var(--yellow), var(--flame));
}

#result-card .bullets {
  display: grid;
  gap: 10px;
}

#result-card .bullet-sec {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--warm-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 4px 10px rgba(58, 42, 34, .06);
}

#result-card .bullet-sec h3 {
  color: var(--orange-ink);
  font-size: 16px;
  font-weight: 900;
}

#result-card .bullet-sec li {
  line-height: 1.6;
  text-wrap: pretty;
  word-break: keep-all;
}

#result-card .mates {
  gap: 10px;
}

#result-card .mate {
  min-width: 0;
  padding: 14px 10px 12px;
  border: 1px solid var(--warm-line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .82), var(--peach));
  box-shadow: 0 5px 12px rgba(58, 42, 34, .08);
}

#result-card .mate h3,
#result-card .mate p {
  word-break: keep-all;
}

#result-card .mate img {
  filter: drop-shadow(0 6px 5px rgba(86, 42, 23, .18));
}

#result .btn.primary,
#result .btn.outline {
  border-color: var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--deep-forest), 0 11px 20px rgba(58, 42, 34, .13);
  transition: transform 150ms ease-out, filter 150ms ease-out;
}

#result .btn.outline {
  background: var(--paper);
}

@media (hover: hover) {
  #result .btn.primary:hover,
  #result .btn.outline:hover {
    filter: brightness(1.03);
    transform: translateY(-2px);
  }
}

#result .btn.primary:active,
#result .btn.outline:active {
  transform: translateY(3px);
}

@media (max-width: 380px) {
  #quiz.card,
  #result-card.card {
    padding-inline: 16px;
  }

  #quiz .question {
    font-size: 21px;
  }

  #result-name {
    font-size: 28px;
  }

  #result-card .mate {
    padding-inline: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #quiz .choice,
  #result .btn.primary,
  #result .btn.outline,
  #quiz .scene-face,
  #result-card .hero,
  #result-card .mate img {
    transition: none;
    animation: none;
  }
}
