/* =========================================================
 * 빌런 메이커 — style.css
 * 색감: 검정 / 보라 / 자주 / 금색 포인트
 * 모바일 우선 → 넓은 화면에서는 가운데 정렬 카드
 * ========================================================= */

/* ---------- 색·글꼴 토큰 (여기만 바꾸면 전체 톤이 바뀜) ---------- */
:root {
  --bg: #0b0712;
  --bg-2: #160c22;
  --panel: rgba(22, 13, 34, 0.88);
  --panel-2: rgba(38, 20, 56, 0.9);
  --line: rgba(196, 160, 255, 0.18);
  --line-strong: rgba(232, 195, 114, 0.55);

  --purple: #8b5cf6;
  --purple-deep: #4c1d95;
  --magenta: #d6339c;
  --gold: #e8c372;
  --gold-soft: #f5e2b0;

  --text: #f4eeff;
  --muted: #b8a8d4;
  --dim: #8a7aa6;

  --radius: 18px;
  --font-body: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --font-display: "Nanum Myeongjo", "Noto Serif KR", "AppleMyungjo", "Batang", serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- 배경 장식 ---------- */
/* 배경 그라데이션은 화면에 고정 (모바일에서 끊김 없이) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(139, 92, 246, 0.28), transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(214, 51, 156, 0.16), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
}

.bg-stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px at 78% 12%, rgba(255,255,255,.6), transparent),
    radial-gradient(1.5px 1.5px at 64% 42%, rgba(232,195,114,.7), transparent),
    radial-gradient(1px 1px at 28% 66%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.5px 1.5px at 88% 74%, rgba(214,51,156,.7), transparent),
    radial-gradient(1px 1px at 8% 88%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 46% 92%, rgba(232,195,114,.6), transparent),
    radial-gradient(1px 1px at 52% 8%, rgba(255,255,255,.5), transparent);
}

.bg-circle {
  position: fixed; z-index: 0; pointer-events: none;
  width: 760px; height: 760px;
  left: 50%; top: 260px; margin-left: -380px;
  fill: none; stroke: var(--gold); stroke-width: 1;
  opacity: 0.07;
  animation: spin 160s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 레이아웃 ---------- */
.wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 600px;
  margin: 0 auto;
  padding: 28px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- 타이틀 ---------- */
.hero { text-align: center; padding: 18px 0 22px; }
.eyebrow {
  margin: 0 0 10px; font-size: 13px; letter-spacing: 0.04em; color: var(--gold);
}
.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(42px, 12vw, 64px);
  font-weight: 800; line-height: 1.1; letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fff6dc 0%, var(--gold) 45%, #b9853a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 28px rgba(214, 51, 156, 0.35);
}
.title-sub {
  margin: 6px 0 0; font-size: 17px; font-weight: 700; color: #e9d5ff;
}
.lead { margin: 12px auto 0; max-width: 30em; font-size: 15px; color: var(--muted); }

/* ---------- 공통 패널 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.panel-title {
  margin: 0 0 14px; font-size: 19px; font-weight: 800;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.step-no {
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  padding: 4px 9px; border-radius: 999px;
  color: var(--bg); background: var(--gold);
}

.is-locked .mode-btn { opacity: 0.4; }
.lock-hint { margin: -6px 0 12px; font-size: 14px; color: var(--dim); }
.panel:not(.is-locked) .lock-hint { display: none; }

/* ---------- 선택 버튼 ---------- */
.choice-grid { display: grid; gap: 10px; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice-grid.two { grid-template-columns: 1fr; }

.choice, .mode-btn, .quiz-opt, .btn {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  transition: transform .12s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.choice:active, .mode-btn:active, .quiz-opt:active, .btn:active { transform: scale(0.97); }

.choice {
  min-height: 72px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 17px; font-weight: 800;
}
.choice-icon { font-size: 22px; color: var(--gold); line-height: 1; }
.choice[aria-pressed="true"] {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.45), rgba(214, 51, 156, 0.35));
  box-shadow: 0 0 0 1px var(--gold) inset, 0 0 22px rgba(214, 51, 156, 0.35);
}

.mode-btn {
  min-height: 76px; padding: 14px 18px; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  background: linear-gradient(150deg, rgba(76, 29, 149, 0.75), rgba(40, 18, 60, 0.9));
}
.mode-btn:disabled { cursor: not-allowed; }
.mode-btn:not(:disabled):hover { border-color: var(--line-strong); }
.mode-name { font-size: 18px; font-weight: 800; }
.mode-name::before { content: "✦ "; color: var(--gold); }
.mode-desc { font-size: 14px; color: var(--muted); }

/* ---------- 성향 테스트 ---------- */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quiz-count { font-size: 14px; font-weight: 800; color: var(--gold); letter-spacing: 0.06em; }
.text-btn {
  background: none; border: 0; padding: 8px 4px; min-height: 40px;
  color: var(--muted); font-size: 14px; cursor: pointer;
}
.progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--purple), var(--magenta), var(--gold));
  transition: width .25s ease;
}
.quiz-q { margin: 18px 0 14px; font-size: 20px; line-height: 1.45; font-weight: 800; }
.quiz-options { display: grid; gap: 10px; }
.quiz-opt {
  min-height: 58px; padding: 12px 16px; text-align: left;
  display: flex; align-items: center; gap: 12px;
  font-size: 16px; font-weight: 600;
}
.quiz-opt:hover { border-color: var(--line-strong); }
.opt-key {
  flex: 0 0 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: var(--bg); background: var(--gold);
}

/* ---------- 결과 카드 ---------- */
.result { padding: 14px; }

.villain-card {
  position: relative;
  border-radius: 16px;
  padding: 16px 16px 18px;
  background:
    linear-gradient(180deg, rgba(76, 29, 149, 0.35), rgba(15, 8, 24, 0.6) 55%),
    var(--bg);
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 4px rgba(232, 195, 114, 0.06), 0 0 40px rgba(139, 92, 246, 0.25);
}
/* 카드 모서리 크리스탈 장식 */
.villain-card::before, .villain-card::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  background: var(--gold); transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(232, 195, 114, 0.7);
}
.villain-card::before { top: -6px; left: 50%; margin-left: -6px; }
.villain-card::after { bottom: -6px; left: 50%; margin-left: -6px; }

.portrait {
  position: relative;
  width: 100%; max-width: 380px; margin: 0 auto;
  aspect-ratio: 1 / 1;   /* SD 아바타(정사각형 투명 PNG)에 맞춘 정사각형 */
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 50% 35%, rgba(139, 92, 246, 0.35), rgba(11, 7, 18, 0.95) 70%);
}
.portrait img {
  width: 100%; height: 100%; display: block;
  object-fit: contain;          /* 머리장식·무기·팔다리까지 잘리지 않게 전체 표시 */
  object-position: center;
  padding: 4%;                  /* 테두리에 그림이 딱 붙지 않게 살짝 여백 */
}
.portrait img[hidden] { display: none; }
.portrait-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--dim); font-size: 14px;
}
.portrait-placeholder svg { width: 38%; fill: rgba(196, 160, 255, 0.22); }
.portrait-placeholder[hidden] { display: none; }

.card-head { text-align: center; padding: 18px 4px 6px; }
.card-kicker {
  margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.3em; color: var(--gold);
}
.villain-name {
  margin: 8px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(26px, 7.4vw, 34px);
  font-weight: 800; line-height: 1.25;
  word-break: keep-all; overflow-wrap: anywhere;
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(214, 51, 156, 0.45);
}
.type-badge { margin: 0; }
.type-badge span {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 800;
  background: linear-gradient(90deg, var(--purple), var(--magenta));
}
.type-intro { margin: 10px 0 0; font-size: 15px; color: var(--muted); word-break: keep-all; }

.stats { margin: 14px 0 0; border-top: 1px solid var(--line); }
.stat {
  display: grid; grid-template-columns: 84px 1fr; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.stat dt { font-size: 14px; font-weight: 800; color: var(--gold); padding-top: 1px; }
.stat dd { margin: 0; font-size: 16px; font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; }

.secret {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; color: #ffd7ef;
  background: rgba(214, 51, 156, 0.14); border: 1px dashed rgba(214, 51, 156, 0.5);
  word-break: keep-all;
}
.secret b { color: var(--gold); }

.note {
  margin: 14px 4px 0; text-align: center; font-size: 14px; color: var(--muted); word-break: keep-all;
}

/* ---------- 결과 버튼 ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.btn {
  min-height: 56px; padding: 10px 12px;
  font-size: 16px; font-weight: 800;
}
.btn:hover { border-color: var(--line-strong); }
.btn-primary {
  grid-column: 1 / -1;
  min-height: 60px; font-size: 18px; color: #1a0f05;
  border-color: transparent;
  background: linear-gradient(180deg, #fbe8b6, var(--gold) 55%, #c9973f);
  box-shadow: 0 6px 20px rgba(232, 195, 114, 0.25);
}
.btn-ghost { grid-column: 1 / -1; background: transparent; color: var(--muted); min-height: 50px; }

.copy-fallback {
  margin: 14px 0 0; padding: 12px; border-radius: 10px;
  white-space: pre-wrap; font-family: var(--font-body); font-size: 14px;
  background: rgba(0,0,0,.4); border: 1px solid var(--line);
  user-select: text; -webkit-user-select: text;
}

.foot { margin-top: 26px; text-align: center; font-size: 12px; color: var(--dim); }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 22px; border-radius: 999px;
  font-size: 16px; font-weight: 800; color: #1a0f05;
  background: var(--gold); box-shadow: 0 8px 26px rgba(0,0,0,.45);
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 결과/문항 등장 애니메이션 */
.reveal { animation: reveal .35s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 태블릿·데스크탑 ---------- */
@media (min-width: 560px) {
  .wrap { padding-top: 44px; }
  .panel { padding: 24px 22px; }
  .result { padding: 18px; }
  .choice-grid.two { grid-template-columns: 1fr 1fr; }
  .villain-card { padding: 22px 24px 24px; }
  .stat { grid-template-columns: 96px 1fr; }
}

/* 움직임 줄이기 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  .bg-circle, .reveal { animation: none; }
  * { transition: none !important; }
}
