/* ===== 기본 초기화 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #C4845A;
  --primary-light: #EDD5C0;
  --primary-dark: #A06840;
  --secondary: #9EC4AA;
  --bg: #FAF7F4;
  --surface: #FFFFFF;
  --surface-warm: #FDF0E8;
  --text: #2D2016;
  --text-mid: #7A6247;
  --text-light: #B89E86;
  --border: #EAD9C8;
  --radius: 16px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  color: var(--text);
  overflow: hidden;
}

/* ===== 앱 래퍼 ===== */
.app {
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ===== 태블릿 반응형 (768px+) ===== */
@media (min-width: 768px) {
  body {
    background: #E8DDD3;
  }

  .app {
    max-width: 600px;
    box-shadow: 0 0 80px rgba(90, 60, 30, 0.18);
  }

  /* 버튼 크기 확대 */
  .btn-primary, .btn-start {
    padding: 20px;
    font-size: 18px;
    border-radius: 18px;
  }

  .btn-secondary {
    padding: 20px;
    font-size: 17px;
    border-radius: 18px;
  }

  /* 성별 카드 */
  .gender-card img {
    max-width: 160px;
    height: 200px;
  }

  /* 옵션 카드 */
  .option-card {
    padding: 20px 22px;
  }

  .option-label { font-size: 17px; }
  .option-desc  { font-size: 14px; }

  /* 입력창 */
  .input-wrap input {
    font-size: 22px;
    padding: 18px 0;
  }

  /* 텍스트 */
  .title    { font-size: 30px; }
  .subtitle { font-size: 15px; }

  /* 스텝 화면 */
  .step { padding: 0 32px 48px; }
}

/* ===== 스텝 화면 ===== */
.step {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 0 24px 40px;
  animation: fadeSlideIn 0.28s ease;
}

.step.active {
  display: flex;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== 진행 도트 ===== */
.progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding-top: 20px;
  padding-bottom: 8px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.progress-dot.active {
  background: var(--primary);
}

/* ===== 뒤로가기 ===== */
.back-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-mid);
  cursor: pointer;
  padding: 8px 0;
  align-self: flex-start;
  line-height: 1;
}

/* ===== 텍스트 ===== */
.title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.title .highlight {
  color: var(--primary);
}

.subtitle {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 32px;
}

/* ===== 캐릭터 ===== */
.character-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex: 1;
  min-height: 0;
  margin-bottom: 24px;
}

.character-wrap img {
  max-height: 240px;
  width: auto;
  object-fit: contain;
}

/* ===== Step 1: 성별 카드 ===== */
.gender-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.gender-card {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.gender-card img {
  width: 100%;
  max-width: 130px;
  height: 160px;
  object-fit: contain;
  margin-bottom: 10px;
}

.gender-card span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-mid);
}

.gender-card.selected {
  border-color: var(--primary);
  background: var(--surface-warm);
}

.gender-card.selected span {
  color: var(--primary);
}

.neutral-btn {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
  margin-bottom: 24px;
  transition: border-color 0.2s, background 0.2s;
}

.neutral-btn.selected {
  border-color: var(--primary);
  background: var(--surface-warm);
  color: var(--primary);
}

/* ===== Step 2: 이름 입력 ===== */
.input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--primary);
}

.input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  padding: 16px 0;
  background: transparent;
  font-family: inherit;
}

.input-wrap input::placeholder {
  color: var(--text-light);
  font-weight: 400;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.input-hint {
  font-size: 12px;
  color: var(--text-light);
  padding-left: 4px;
  margin-bottom: auto;
}

/* ===== 생일 입력 ===== */
.birthday-section {
  margin-top: 20px;
  margin-bottom: 12px;
}

.birthday-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.birthday-selects {
  display: flex;
  gap: 8px;
}

.birthday-selects select {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
  transition: border-color 0.2s;
}

.birthday-selects select:focus {
  border-color: var(--primary);
}

.birthday-selects select:disabled {
  color: var(--text-light);
  background: var(--bg);
  cursor: default;
}

/* ===== Step 2: 연령대 옵션 ===== */
.age-card {
  gap: 16px;
}

.age-emoji {
  font-size: 26px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

/* ===== Step 3: 관계 옵션 ===== */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.option-card {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.option-card.selected {
  border-color: var(--primary);
  background: var(--surface-warm);
}

.option-text {
  flex: 1;
}

.option-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.option-card.selected .option-label {
  color: var(--primary);
}

.option-desc {
  font-size: 13px;
  color: var(--text-light);
}

.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.option-card.selected .radio {
  border-color: var(--primary);
}

.radio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: none;
}

.option-card.selected .radio-dot {
  display: block;
}

.custom-input {
  width: 100%;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  resize: none;
  outline: none;
  min-height: 80px;
  margin-bottom: 12px;
  display: none;
}

.custom-input.visible {
  display: block;
}

/* ===== Step 4: 컨텍스트 ===== */
.character-speech-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}

.character-speech-row img {
  width: 110px;
  object-fit: contain;
}

.speech-bubble {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
  position: relative;
}

.context-input {
  width: 100%;
  flex: 1;
  min-height: 120px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  resize: none;
  outline: none;
  line-height: 1.6;
  margin-bottom: 6px;
  transition: border-color 0.2s;
}

.context-input:focus {
  border-color: var(--primary);
}

.char-count {
  font-size: 12px;
  color: var(--text-light);
  text-align: right;
  margin-bottom: 20px;
}

/* ===== 버튼 ===== */
.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  font-family: inherit;
  letter-spacing: -0.3px;
}

.btn-primary:disabled {
  background: var(--primary-light);
  cursor: default;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  flex: 1;
  background: var(--surface);
  color: var(--text-mid);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-start {
  flex: 2;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.3px;
}
