/* ===================== 기본 리셋 & 테마 ===================== */
:root {
  --boy: #4aa8ff;
  --boy-dark: #2b7fd6;
  --girl: #ff7eb6;
  --girl-dark: #e85a97;
  --bg-a: #fff3fb;
  --bg-b: #eef6ff;
  --ink: #4a3f4d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Jua', 'Gaegu', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-a), var(--bg-b));
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ===================== 화면 전환 ===================== */
.screen {
  display: none;
  width: 100%;
  max-width: 460px;
  text-align: center;
  animation: fadeIn 0.5s ease;
}
.screen.is-active { display: block; }

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

/* ===================== 공통 버튼 ===================== */
.btn-primary {
  border: none;
  border-radius: 22px;
  padding: 16px 36px;
  font-family: inherit;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #ff9ec7, #6fbcff);
  box-shadow: 0 12px 24px rgba(150,120,200,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover  { transform: translateY(-3px); }
.btn-primary:active { transform: scale(0.96); }

/* ===================== 화면 0: 시작 ===================== */
.start-card {
  background: rgba(255,255,255,0.72);
  border-radius: 30px;
  padding: 44px 26px 32px;
  box-shadow: 0 18px 40px rgba(180,150,190,0.25);
  backdrop-filter: blur(4px);
}
.start-emoji {
  font-size: 60px;
  animation: floaty 2.6s ease-in-out infinite;
}
.start-title {
  font-size: 34px;
  line-height: 1.3;
  margin: 12px 0 14px;
}
.start-sub {
  font-family: 'Gaegu', sans-serif;
  font-size: 19px;
  color: #8a7f92;
  line-height: 1.5;
  margin-bottom: 30px;
}
.start-foot {
  font-family: 'Gaegu', sans-serif;
  font-size: 15px;
  color: #b3a8bd;
  margin-top: 22px;
}
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-10px); }
}

/* ===================== 화면 1: 초음파 + 선택 ===================== */
.guess-title {
  font-size: 26px;
  line-height: 1.35;
  margin-bottom: 18px;
}
.photo-frame {
  position: relative;
  display: inline-block;
  background: #fff;
  padding: 12px 12px 40px;
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(120,100,140,0.28);
  transform: rotate(-2deg);
  margin-bottom: 22px;
}
.photo {
  display: block;
  width: 100%;
  max-width: 300px;
  border-radius: 4px;
  background: #eee;
}
.photo-tape {
  position: absolute;
  top: -10px;
  width: 64px;
  height: 26px;
  background: rgba(255,214,110,0.6);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.photo-tape--l { left: 16px; transform: rotate(-8deg); }
.photo-tape--r { right: 16px; transform: rotate(7deg); }

.guess-sub {
  font-family: 'Gaegu', sans-serif;
  font-size: 18px;
  color: #8a7f92;
  margin-bottom: 16px;
}
.choice-row { display: flex; gap: 14px; }
.choice {
  flex: 1;
  border: none;
  border-radius: 22px;
  padding: 20px 10px;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s ease;
}
.choice__emoji { font-size: 42px; }
.choice__label { font-size: 20px; }
.choice--boy  { background: linear-gradient(160deg, #6fbcff, var(--boy-dark)); box-shadow: 0 10px 20px rgba(43,127,214,0.35); }
.choice--girl { background: linear-gradient(160deg, #ff9ec7, var(--girl-dark)); box-shadow: 0 10px 20px rgba(232,90,151,0.35); }
.choice:hover  { transform: translateY(-4px); }
.choice:active { transform: scale(0.96); }

/* ===================== 화면 2: 카드 뒤집기 게임 ===================== */
.game-top { margin-bottom: 6px; }
.game-guess {
  font-family: 'Gaegu', sans-serif;
  font-size: 16px;
  color: #8a7f92;
  margin-bottom: 4px;
}
.game-title { font-size: 26px; }
.game-desc {
  font-family: 'Gaegu', sans-serif;
  font-size: 17px;
  color: #7d7288;
  margin: 8px 0 14px;
}

/* 3x3 카드 그리드 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 340px;
  margin: 0 auto 6px;
}

.card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  perspective: 700px;
}
.card:disabled { cursor: default; }

.card__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.1, 0.3, 1.2);
}
.card.is-flipped .card__inner { transform: rotateY(180deg); }

.card__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(120,100,140,0.22);
}

/* 카드 뒷면(물음표) */
.card__back {
  background: linear-gradient(150deg, #b79cff, #8f6fff);
  color: rgba(255,255,255,0.9);
  font-size: 34px;
  font-family: 'Jua', sans-serif;
}
.card__back::after {
  content: "?";
}
.card:not(:disabled):hover .card__inner { transform: translateY(-4px); }
.card:not(:disabled):hover.is-flipped .card__inner { transform: rotateY(180deg); }

/* 카드 앞면(성별) */
.card__front {
  transform: rotateY(180deg);
  font-size: 44px;
  background: #fff;
}
.card__front--boy  { background: linear-gradient(150deg, #cfe9ff, #9fd0ff); }
.card__front--girl { background: linear-gradient(150deg, #ffd6ec, #ffb0d6); }

/* 정답 라인 강조 */
.card.is-win .card__front {
  animation: winPulse 0.7s ease-in-out infinite alternate;
  box-shadow: 0 0 0 4px #ffd36e, 0 8px 18px rgba(0,0,0,0.2);
}
@keyframes winPulse {
  from { transform: rotateY(180deg) scale(1); }
  to   { transform: rotateY(180deg) scale(1.06); }
}

.game-hint {
  font-family: 'Gaegu', sans-serif;
  font-size: 18px;
  color: #9a8fa6;
  margin-top: 10px;
  min-height: 24px;
}

/* ===================== 오뚝이 인형 (결과용) ===================== */
.doll {
  width: 140px;
  height: 168px;
  margin: 0 auto 8px;
  position: relative;
  animation: wobble 2.4s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.doll__body {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 128px; height: 150px;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  background: linear-gradient(160deg, #d9d9e5, #b9b9cc);
  box-shadow: inset -8px -12px 18px rgba(0,0,0,0.12), 0 10px 18px rgba(0,0,0,0.12);
}
.doll__face {
  position: absolute;
  top: 46px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  align-items: center;
}
.doll__eye {
  width: 12px; height: 16px;
  background: #43384a;
  border-radius: 50%;
}
.doll__mouth {
  position: absolute;
  bottom: -22px; left: 50%;
  transform: translateX(-50%);
  width: 30px; height: 16px;
  border-bottom: 4px solid #43384a;
  border-radius: 0 0 20px 20px;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}
.doll--boy .doll__body  { background: linear-gradient(160deg, #8fccff, var(--boy)); }
.doll--girl .doll__body { background: linear-gradient(160deg, #ffb2d6, var(--girl)); }

/* ===================== 화면 3: 결과 ===================== */
.reveal-card {
  background: rgba(255,255,255,0.78);
  border-radius: 28px;
  padding: 32px 22px 30px;
  box-shadow: 0 18px 40px rgba(180,150,190,0.28);
}
.reveal-eyebrow {
  font-family: 'Gaegu', sans-serif;
  font-size: 18px;
  color: #8a7f92;
  margin-bottom: 12px;
}
.reveal-title {
  font-size: 34px;
  margin: 14px 0 8px;
}
.reveal-title.is-boy  { color: var(--boy-dark); }
.reveal-title.is-girl { color: var(--girl-dark); }
.reveal-message {
  font-family: 'Gaegu', sans-serif;
  font-size: 19px;
  color: #6f6479;
  line-height: 1.5;
  margin-bottom: 22px;
}

/* ===================== 색종이 & 폭발 ===================== */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(-20px) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

.pop-flash {
  position: absolute;
  width: 160px; height: 160px;
  margin: -80px 0 0 -80px;
  border-radius: 50%;
  z-index: 40;
  animation: popFlash 0.6s ease-out forwards;
}
@keyframes popFlash {
  0%   { transform: scale(0.2); opacity: 0.9; }
  60%  { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}
.burst-piece {
  position: absolute;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  z-index: 45;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  animation: burstFly 1.1s cubic-bezier(0.18, 0.7, 0.3, 1) forwards;
}
@keyframes burstFly {
  0%   { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 160px)) scale(0.6) rotate(540deg); opacity: 0; }
}

@media (max-width: 380px) {
  .start-title { font-size: 30px; }
  .guess-title { font-size: 23px; }
  .doll { width: 120px; height: 150px; }
  .doll__body { width: 112px; height: 132px; }
}
