@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&family=Gaegu:wght@400;700&display=swap');

:root {
  --pink: #FF6B9D;
  --pink-light: #FFB3CC;
  --purple: #C77DFF;
  --purple-light: #E0B0FF;
  --mint: #48CAE4;
  --mint-light: #ADE8F4;
  --yellow: #FFD166;
  --bg: #FFF5F7;
  --bg2: #FFF0F5;
  --white: #FFFFFF;
  --dark: #2D2D2D;
  --gray: #888;
  --card-shadow: 0 8px 32px rgba(255,107,157,0.15);
  --radius: 24px;
  --radius-sm: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 배경 버블 장식 */
body::before {
  content: '';
  position: fixed;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(199,125,255,0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -100px;
  left: -100px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,107,157,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 80px;
  position: relative;
  z-index: 1;
}

/* 헤더 */
.header {
  text-align: center;
  padding: 40px 0 20px;
}

.header-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
  animation: float 3s ease-in-out infinite;
}

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

.header h1 {
  font-family: 'Gaegu', cursive;
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 8px;
}

.header-sub {
  font-size: 14px;
  color: var(--gray);
  font-weight: 400;
}

/* 카드 */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
  border: 1.5px solid rgba(255,107,157,0.1);
}

/* 섹션 레이블 */
.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--pink);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 입력 필드 */
.input-group {
  margin-bottom: 20px;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.name-input {
  flex: 1;
  height: 52px;
  border: 2px solid rgba(255,107,157,0.2);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-size: 18px;
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 700;
  color: var(--dark);
  background: var(--bg);
  outline: none;
  transition: all 0.2s;
  letter-spacing: 2px;
}

.name-input:focus {
  border-color: var(--pink);
  background: white;
  box-shadow: 0 0 0 4px rgba(255,107,157,0.1);
}

.name-input::placeholder {
  color: #ccc;
  font-weight: 400;
  letter-spacing: 0;
  font-size: 14px;
}

/* 성별 선택 */
.gender-btns {
  display: flex;
  gap: 6px;
}

.gender-btn {
  width: 48px;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255,107,157,0.2);
  background: var(--bg);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gender-btn:active { transform: scale(0.95); }

.gender-btn.active-M {
  border-color: #48CAE4;
  background: rgba(72,202,228,0.1);
  box-shadow: 0 0 0 4px rgba(72,202,228,0.15);
}

.gender-btn.active-F {
  border-color: var(--pink);
  background: rgba(255,107,157,0.1);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.15);
}

/* 획수 미리보기 */
.strokes-preview {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  min-height: 28px;
  align-items: center;
  flex-wrap: wrap;
}

.stroke-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, rgba(255,107,157,0.1), rgba(199,125,255,0.1));
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 13px;
  color: var(--purple);
  font-weight: 700;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.stroke-chip .char { color: var(--dark); font-weight: 400; }

/* VS 구분선 */
.vs-divider {
  text-align: center;
  margin: 4px 0 20px;
  position: relative;
}

.vs-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,107,157,0.3), transparent);
}

.vs-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  font-size: 13px;
  font-weight: 900;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  line-height: 36px;
  position: relative;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,157,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,107,157,0); }
}

/* 궁합 타입 표시 */
.compat-type {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 20px;
  padding: 8px 16px;
  background: rgba(199,125,255,0.1);
  border-radius: 100px;
  display: inline-block;
  width: 100%;
  transition: all 0.3s;
}

/* 계산 버튼 */
.calc-btn {
  width: 100%;
  height: 60px;
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 900;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.calc-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.calc-btn:hover::before { left: 100%; }
.calc-btn:active { transform: scale(0.98); }

.calc-btn:disabled {
  background: #ddd;
  cursor: not-allowed;
}

/* ===== 애니메이션 섹션 ===== */
.animation-section {
  display: none;
}

.animation-section.show {
  display: block;
  animation: fadeInUp 0.4s ease;
}

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

/* 로딩 멘트 */
.loading-text {
  text-align: center;
  font-size: 15px;
  color: var(--gray);
  margin-bottom: 20px;
  min-height: 24px;
  font-weight: 500;
}

.loading-text span {
  display: inline-block;
  animation: fadeText 0.5s ease;
}

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

/* 획수 계산 과정 */
.calc-process {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  border: 1.5px solid rgba(255,107,157,0.1);
  margin-bottom: 16px;
  overflow-x: auto;
}

.calc-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.calc-row.visible {
  opacity: 1;
  transform: translateY(0);
}

.calc-num {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(255,107,157,0.15), rgba(199,125,255,0.15));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--dark);
  font-family: 'Gaegu', cursive;
  transition: all 0.3s;
}

.calc-num.highlight {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(255,107,157,0.4);
}

.calc-num.name1 {
  background: linear-gradient(135deg, rgba(72,202,228,0.2), rgba(72,202,228,0.1));
  color: #0077B6;
}

.calc-num.name2 {
  background: linear-gradient(135deg, rgba(255,107,157,0.2), rgba(255,107,157,0.1));
  color: var(--pink);
}

/* 브라켓 연결선 */
.bracket-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.bracket-row.visible { opacity: 1; }

.bracket-item {
  width: 40px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bracket-line {
  width: 44px;
  height: 12px;
  border: 2px solid rgba(255,107,157,0.4);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

/* 결과보기 버튼 */
.result-btn-wrap {
  text-align: center;
  display: none;
}

.result-btn-wrap.show {
  display: block;
  animation: fadeInUp 0.5s ease;
}

.result-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  color: white;
  border: none;
  border-radius: 100px;
  padding: 18px 40px;
  font-size: 18px;
  font-weight: 900;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  animation: heartbeat 1.5s ease-in-out infinite;
  box-shadow: 0 8px 24px rgba(255,107,157,0.4);
  text-decoration: none;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(255,107,157,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 12px 32px rgba(255,107,157,0.6); }
}

.result-btn:active { transform: scale(0.97) !important; }

/* 광고 영역 */
.ad-banner {
  background: rgba(255,255,255,0.6);
  border: 1px dashed rgba(255,107,157,0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  margin-bottom: 16px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 결과 페이지 ===== */
.result-section {
  display: none;
}

.result-section.show {
  display: block;
  animation: fadeInUp 0.5s ease;
}

.result-card {
  background: white;
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
  border: 1.5px solid rgba(255,107,157,0.15);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--mint));
}

.result-names {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 24px;
  color: var(--dark);
  letter-spacing: 1px;
}

.result-names .connector {
  color: var(--pink);
  margin: 0 8px;
}

/* 하트 게이지 */
.heart-gauge-wrap {
  margin: 0 auto 24px;
  width: 160px;
  position: relative;
}

.heart-svg {
  width: 160px;
  height: 144px;
}

.heart-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Gaegu', cursive;
  font-size: 36px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 결과 등급 */
.result-grade {
  font-family: 'Gaegu', cursive;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-emoji {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
  animation: bounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.result-type-badge {
  display: inline-block;
  background: rgba(199,125,255,0.1);
  color: var(--purple);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 16px;
}

.result-desc {
  font-size: 15px;
  color: var(--gray);
  line-height: 1.6;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
}

/* 액션 버튼들 */
.action-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 120px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn:active { transform: scale(0.97); }

.btn-kakao {
  background: #FEE500;
  color: #3A1D1D;
}

.btn-save {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
}

.btn-retry {
  background: var(--bg);
  color: var(--dark);
  border: 1.5px solid rgba(0,0,0,0.1);
  width: 100%;
  flex: unset;
  margin-top: 4px;
}

/* 파티클 */
.particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
}

.particle {
  position: absolute;
  font-size: 20px;
  animation: particleFall 2s ease-out forwards;
}

@keyframes particleFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* 인터스티셜 오버레이 */
.interstitial-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.interstitial-overlay.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.interstitial-inner {
  width: 90%;
  max-width: 400px;
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
}

.interstitial-timer {
  text-align: right;
  font-size: 13px;
  color: var(--gray);
  margin-bottom: 12px;
}

.interstitial-skip {
  display: none;
  width: 100%;
  margin-top: 12px;
  height: 44px;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  color: var(--dark);
}

.interstitial-skip.show { display: block; }

/* 반응형 */
@media (min-width: 768px) {
  .container {
    max-width: 520px;
    padding: 0 24px 80px;
  }

  .header h1 { font-size: 44px; }
  .calc-num { width: 48px; height: 48px; font-size: 20px; }
}

@media (max-width: 360px) {
  .calc-num { width: 34px; height: 34px; font-size: 15px; }
  .header h1 { font-size: 30px; }
}

/* 스크롤바 커스텀 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--pink-light); border-radius: 3px; }
