@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=Pretendard:wght@300;400;600;700&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #0f1026 0%, #1a1635 50%, #2c1b4d 100%);
  --surface: rgba(30, 26, 56, 0.85);
  --surface-border: rgba(255, 255, 255, 0.15);
  --accent: #ff61d8;
  --accent-secondary: #a881ff;
  --text-primary: #ffffff;
  --text-secondary: #c2b9d8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Pretendard', 'Outfit', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  overflow-x: hidden;
}

/* 데스크탑 넉넉한 레이아웃 */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* 공통 텍스트 정렬 및 줄바꿈 */
h1, h2, h3, h4, p, .desc {
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: balance;
  text-align: center;
}

header {
  margin-bottom: 30px;
}

.badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

h1 {
  font-size: clamp(26px, 5vw, 42px);
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(to right, #ffffff, #ffb6ed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.desc {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

/* 화면 전환 규칙 */
.screen {
  display: none;
  width: 100%;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s ease forwards;
}

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

/* 글래스 카드 */
.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  margin-bottom: 24px;
}

/* 업로드 영역 */
.upload-zone {
  border: 2px dashed var(--accent-secondary);
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.03);
}

.upload-zone:hover {
  background: rgba(168, 129, 255, 0.1);
  border-color: var(--accent);
}

.upload-preview {
  max-width: 200px;
  max-height: 200px;
  border-radius: 12px;
  margin: 15px auto;
  display: none;
  object-fit: cover;
  border: 2px solid var(--accent);
}

/* 화풍 그리드 */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 20px 0 30px;
}

.style-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.style-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent-secondary);
}

.style-item.selected {
  background: linear-gradient(135deg, rgba(255, 97, 216, 0.2), rgba(168, 129, 255, 0.2));
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(255, 97, 216, 0.4);
}

.style-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.style-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  color: #fff;
  box-shadow: 0 8px 20px rgba(255, 97, 216, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(255, 97, 216, 0.5);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 12px;
}

/* 로딩 스피너 및 광고 */
.loading-card {
  text-align: center;
  padding: 50px 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ads-block {
  margin: 24px 0;
  width: 100%;
  min-height: 200px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 결과 이미지 및 텍스트 */
.result-image-box {
  text-align: center;
  margin: 20px 0;
}

.result-image {
  max-width: 100%;
  width: 380px;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
  border: 2px solid var(--accent-secondary);
}

.text-section {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  text-align: left;
}

.text-section h3 {
  color: var(--accent);
  margin-bottom: 10px;
  text-align: left;
}

.text-section p {
  text-align: left;
  line-height: 1.6;
  color: #fff;
  margin-bottom: 12px;
}

/* 캐릭터 시트 (2단계) */
.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 20px 0;
}

.sheet-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sheet-image {
  width: 100%;
  border-radius: 12px;
  margin-top: 10px;
}

/* 모바일 여백 이원화 최적화 🚨 */
@media (max-width: 600px) {
  body {
    padding: 12px 10px;
  }
  .container {
    max-width: 100%;
  }
  .card {
    padding: 20px 16px;
    border-radius: 18px;
  }
  .style-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .sheet-grid {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 24px;
  }
}

/* PDF 인쇄 모드 */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0;
  }
  .card {
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 20px !important;
  }
  .text-section, .sheet-box {
    background: #f8f9fa !important;
    border: 1px solid #ddd !important;
    color: #000 !important;
  }
  .text-section h3, .text-section p, h1, h2, h3, p {
    color: #000 !important;
    text-shadow: none !important;
  }
  .btn, .ads-block, header {
    display: none !important;
  }
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.03); opacity: 1; text-shadow: 0 0 10px rgba(255,154,158,0.8); }
  100% { transform: scale(1); opacity: 0.9; }
}
