@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background: #fce7f3;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #FDFCFB;
  color: #1A1A1A;
  overflow-x: hidden; /* 가로 스크롤 방지 */
}

img {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent; /* 모바일 터치 시 깜빡임 제거 */
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 12px 16px; /* 모바일 여백 축소 */
  display: flex;
  justify-content: center; /* 모바일에서는 중앙 정렬 */
  align-items: center;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
}

.progress-bar {
  height: 6px; /* 모바일에서 약간 더 두껍게 */
  width: 120px;
  background: rgba(0,0,0,0.05);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #ec4899;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ===== Main ===== */
.main {
  padding: 72px 16px 24px; /* 모바일 여백 최적화 */
  max-width: 72rem;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== Start Screen ===== */
.start-screen {
  text-align: center;
  animation: fadeInUp 0.6s ease;
  width: 100%;
}

.start-screen .title {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.start-screen .title .highlight {
  color: #ec4899;
}

.start-screen .subtitle {
  font-size: 1rem;
  opacity: 0.6;
  max-width: 28rem;
  margin: 0 auto 32px;
  line-height: 1.5;
  word-break: keep-all;
}

.start-btn {
  position: relative;
  padding: 16px 36px;
  background: #1A1A1A;
  color: white;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 1.125rem;
  overflow: hidden;
  transition: transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 300px; /* 모바일에서 너무 넓어지지 않게 */
}

.start-btn:active {
  transform: scale(0.95);
}

.start-btn .btn-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.start-btn .btn-bg {
  position: absolute;
  inset: 0;
  background: #ec4899;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.start-btn:hover .btn-bg {
  transform: translateY(0);
}

.start-btn .chevron {
  transition: transform 0.2s ease;
}

.start-btn:hover .chevron {
  transform: translateX(4px);
}

/* ===== Playing Screen (Mobile First: 상하 배치) ===== */
.match-grid {
  width: 100%;
  display: flex;
  flex-direction: column; /* 모바일은 위아래 스택 */
  gap: 12px;
  position: relative;
  animation: fadeIn 0.4s ease;
  height: calc(100vh - 120px); /* 화면에 꽉 차게 하여 스크롤 방지 */
  min-height: 480px;
}

.vs-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 50%;
  border: 3px solid #FDFCFB;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

.vs-text {
  font-weight: 900;
  font-style: italic;
  font-size: 0.875rem;
  color: #ec4899;
}

/* ===== Candidate Card ===== */
.card {
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease;
  flex: 1; /* 상하 공간 균등 분할 */
  min-height: 0; /* Flexbox 버그 방지 */
}

.card-inner {
  height: 100%; /* 부모(card) 높이 100% 사용 */
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.05);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease;
}

.card:hover .card-img {
  transform: scale(1.05);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 40%, transparent 100%);
  opacity: 0.85;
  transition: opacity 0.3s;
}

.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 16px; /* 텍스트 공간 확보 */
  color: white;
}

.card-alias {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: #ec4899;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.card-name {
  font-size: 1.5rem; /* 모바일 가독성 향상 */
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.card-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
}

.card-trait {
  font-size: 0.7rem; /* 너무 작았던 글씨 확대 */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 10px;
  border-radius: 9999px;
  color: white;
  background: rgba(255,255,255,0.1);
}

.info-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  z-index: 10;
}

.info-btn svg {
  width: 18px;
  height: 18px;
  color: white;
}

/* Info Overlay */
.info-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  z-index: 5;
  animation: fadeIn 0.2s ease;
}

.info-overlay h4 {
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  text-transform: uppercase;
  font-style: italic;
  margin-bottom: 8px;
}

.info-overlay p {
  color: rgba(255,255,255,0.9);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 20px;
  word-break: keep-all;
}

.info-close-btn {
  color: #1A1A1A;
  background: white;
  padding: 8px 16px;
  border-radius: 9999px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

/* ===== Finished Screen ===== */
.finished-screen {
  text-align: center;
  animation: scaleIn 0.6s ease;
  width: 100%;
}

.finished-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fdf2f8;
  color: #ec4899;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
}

.winner-card {
  position: relative;
  width: 100%;
  max-width: 24rem; /* 모바일 사이즈에 맞게 살짝 축소 */
  margin: 0 auto 40px;
}

.winner-card-inner {
  aspect-ratio: 3 / 4;
  border-radius: 2rem;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15);
  border: 6px solid white;
  position: relative;
}

.winner-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.winner-card .gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.2) 60%, transparent);
}

.winner-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 20px;
  color: white;
  text-align: left;
}

.winner-alias {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #f472b6;
  margin-bottom: 6px;
}

.winner-name {
  font-size: 2.25rem;
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.winner-desc {
  margin-top: 12px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: keep-all;
}

.winner-heart {
  position: absolute;
  top: -12px;
  right: -8px; /* 모바일에서 화면 밖으로 튀어나가지 않게 조정 */
  width: 72px;
  height: 72px;
  background: #ec4899;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  transform: rotate(12deg);
  animation: heartPulse 2s ease-in-out infinite;
}

.winner-heart svg {
  width: 32px;
  height: 32px;
  color: white;
  fill: white;
}

.play-again-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
  background: #1A1A1A;
  color: white;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.15s ease;
  width: 100%;
  max-width: 300px;
  justify-content: center;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes heartPulse {
  0%, 100% { transform: rotate(12deg) scale(1); }
  50%      { transform: rotate(12deg) scale(1.1); }
}

/* ===== Responsive (PC 최적화: 768px 이상) ===== */
@media (min-width: 768px) {
  .header {
    padding: 16px 24px;
    justify-content: space-between;
  }
  
  .main {
    padding: 96px 16px 48px;
  }

  .start-btn {
    width: auto;
    padding: 20px 48px;
    font-size: 1.25rem;
  }

  /* PC에서는 다시 양옆(Side-by-Side) 배치 */
  .match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    height: auto; /* 고정 높이 해제 */
    min-height: auto;
  }

  .card:hover {
    transform: translateY(-5px) scale(1.02);
  }

  .card:first-child { animation-name: slideInLeft; }
  .card:last-child { animation-name: slideInRight; }

  .card-inner {
    aspect-ratio: 3 / 4; /* PC용 예쁜 비율 복원 */
    border-radius: 24px;
    height: auto;
  }

  .vs-badge {
    width: 64px;
    height: 64px;
    border-width: 4px;
  }

  .vs-text {
    font-size: 1.25rem;
  }

  .card-content {
    padding: 32px;
  }

  .card-name {
    font-size: 2.25rem;
  }

  .card-alias {
    font-size: 0.75rem;
  }

  .card-trait {
    font-size: 0.75rem;
  }

  .info-btn {
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
  }

  .info-btn svg { width: 20px; height: 20px; }

  .info-overlay h4 { font-size: 1.5rem; }
  .info-overlay p { font-size: 1.125rem; }

  .winner-card {
    max-width: 28rem;
  }
  
  .winner-card-inner {
    border: 8px solid white;
    border-radius: 3rem;
  }

  .winner-name { font-size: 3rem; }
  .winner-info { padding: 40px; }
  .winner-desc { font-size: 1rem; }

  .winner-heart {
    top: -16px;
    right: -16px;
    width: 96px;
    height: 96px;
  }

  .winner-heart svg {
    width: 48px;
    height: 48px;
  }

  .play-again-btn { width: auto; }
}