:root {
  --warm: #ff8a5b;
  --warm-glow: rgba(255, 138, 91, 0.35);
  --cold: #4a90d9;
  --bg-room: #2a2438;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  background: #14121c;
  color: #f5f3ff;
  overscroll-behavior: none;
}

#app { height: 100vh; width: 100%; }

/* ===== 공통 버튼 ===== */
.btn {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, #ff8a5b, #ff6b9d);
  color: white;
  box-shadow: 0 6px 18px rgba(255,107,157,.35);
}
.btn-ghost {
  background: rgba(255,255,255,.08);
  color: #f5f3ff;
  border: 1px solid rgba(255,255,255,.15);
}

/* ===== 설정 화면 ===== */
.setup-wrap {
  min-height: 100vh;
  overflow-y: auto;
  padding: 24px 16px 48px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255,138,91,.18), transparent),
    linear-gradient(180deg, #1c1830, #14121c);
}
.card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  backdrop-filter: blur(8px);
}
.param-select {
  background: rgba(20,18,28,.7);
  border: 1px solid rgba(255,255,255,.14);
  color: #f5f3ff;
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  font-size: 14px;
}
.param-select:focus { outline: 2px solid var(--warm); }
.mode-tab {
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.05);
}
.mode-tab.active {
  background: linear-gradient(135deg,#ff8a5b,#ff6b9d);
  border-color: transparent;
}
.diff-btn {
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  transition: transform .1s, background .2s, border-color .2s;
}
.diff-btn:hover { background: rgba(255,255,255,.1); }
.diff-btn:active { transform: scale(.96); }
.diff-btn.active {
  background: linear-gradient(135deg, rgba(255,77,109,.35), rgba(255,138,91,.25));
  border-color: #ff6b9d;
  box-shadow: 0 0 0 1px #ff6b9d55;
}

/* ===== 상담 화면 ===== */
.stage {
  position: relative;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 50% 0%, #3a3350, #211d33 70%);
  display: flex;
  flex-direction: column;
}
.stage-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  opacity: .82;
  transition: filter .5s, background .5s;
}
/* 배경 위 가독성용 상하 그라데이션 */
.stage-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(20,17,30,.28) 0%, rgba(20,17,30,0) 30%, rgba(20,17,30,0) 55%, rgba(20,17,30,.55) 100%);
}
/* 온도에 따른 배경 오버레이 톤 */
.stage.warm-tone .stage-bg { filter: saturate(1.15) brightness(1.05); }
.stage.cold-tone .stage-bg { filter: saturate(.6) brightness(.75); }

/* 캐릭터 스탠딩 영역 */
.char-area {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2;
}
.char-sprite {
  max-height: 68vh;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.5));
  transition: opacity .4s ease;
}
/* 캐릭터 이미지 레이어 (표정 크로스페이드) */
.char-avatar {
  position: relative;
  width: min(46vh, 82vw);
  height: 78vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform .3s;
  user-select: none;
}
.char-img {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-height: 78vh;
  max-width: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .4s ease;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,.45));
  pointer-events: none;
}
.char-img.is-on { opacity: 1; }
.stage.warm-tone .char-img { filter: drop-shadow(0 12px 30px rgba(255,150,90,.35)); }
.stage.cold-tone .char-img { filter: drop-shadow(0 12px 30px rgba(0,0,0,.55)) saturate(.85) brightness(.92); }
/* 이모지 폴백 */
.char-emoji {
  font-size: clamp(90px, 24vw, 190px);
  line-height: 1;
  transition: opacity .3s;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.4));
}

/* 속마음 말풍선 */
.inner-thought {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 78%;
  background: rgba(255,255,255,.14);
  border: 1px dashed rgba(255,255,255,.4);
  color: #eee;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 14px;
  backdrop-filter: blur(4px);
  z-index: 5;
  font-style: italic;
}

/* 온도계 (데스크탑: 우측 세로) */
.thermo {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 260px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.thermo-tube {
  position: relative;
  flex: 1;
  width: 20px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.2);
}
.thermo-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 999px;
  transition: height .7s cubic-bezier(.22,1,.36,1), background .7s;
}
.thermo-val { font-weight: 900; font-size: 15px; margin-bottom: 6px; }
.thermo-label { font-size: 10px; opacity: .6; margin-top: 4px; }

/* 온도 변화 팝업 */
.delta-pop {
  position: absolute;
  right: 70px;
  top: 50%;
  font-weight: 900;
  font-size: 22px;
  z-index: 7;
  pointer-events: none;
  animation: deltaFloat 1.4s ease forwards;
}
@keyframes deltaFloat {
  0% { opacity: 0; transform: translateY(10px) scale(.8); }
  20% { opacity: 1; transform: translateY(-6px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}
.delta-up { color: #ffb27a; text-shadow: 0 0 12px var(--warm-glow); }
.delta-down { color: #8ec5ff; }

/* 따뜻/차가움 이펙트 */
.fx-warm {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(600px 400px at 50% 60%, var(--warm-glow), transparent);
  opacity: 0; animation: warmPulse 1.2s ease;
}
@keyframes warmPulse { 0%{opacity:0} 30%{opacity:1} 100%{opacity:0} }
.stage.shake { animation: coldShake .4s; }
@keyframes coldShake {
  0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)}
}

/* 대사창 */
.dialogue {
  position: relative;
  z-index: 4;
  margin: 0 12px 12px;
  background: rgba(16,14,24,.92);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 14px 18px 16px;
  box-shadow: 0 -6px 30px rgba(0,0,0,.4);
}
.name-tag {
  display: inline-block;
  background: linear-gradient(135deg,#ff8a5b,#ff6b9d);
  color: white;
  font-weight: 800;
  font-size: 13px;
  padding: 3px 14px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.dialogue-text {
  font-family: 'Gowun Dodum', 'Noto Sans KR', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  min-height: 52px;
  white-space: pre-wrap;
}
.typing-caret::after {
  content: '▋';
  animation: blink .8s steps(2) infinite;
  color: var(--warm);
}
@keyframes blink { 50% { opacity: 0; } }

/* 입력 영역 */
.input-bar {
  z-index: 4;
  margin: 0 12px 14px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.chat-input {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  color: white;
  padding: 12px 14px;
  font-size: 15px;
  resize: none;
}
.chat-input:focus { outline: 2px solid var(--warm); }
.mic-btn.recording { background: #ff4d6d; animation: micPulse 1s infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 8px rgba(255,77,109,.3); } }

/* 선택지 */
.choice-btn {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  padding: 12px 16px;
  color: #f5f3ff;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.choice-btn:hover { background: rgba(255,138,91,.18); }
.choice-btn:active { transform: scale(.99); }

/* ===== 디브리핑 ===== */
.debrief-wrap {
  min-height: 100vh; overflow-y: auto; padding: 28px 16px 60px;
  background: linear-gradient(180deg,#1c1830,#14121c);
}
.score-track {
  height: 12px; background: rgba(255,255,255,.1);
  border-radius: 999px; overflow: hidden;
}
.score-fill { height: 100%; border-radius: 999px; transition: width 1s cubic-bezier(.22,1,.36,1); }
.grade-badge {
  font-size: 64px; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg,#ffd76b,#ff8a5b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* 로딩 스피너 */
.spinner {
  width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--warm); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 모바일: 온도계 상단 가로 게이지 ===== */
@media (max-width: 640px) {
  .thermo {
    position: absolute; top: 10px; left: 12px; right: 12px;
    width: auto; height: 34px; transform: none;
    flex-direction: row; align-items: center; gap: 10px;
  }
  .thermo-tube { width: auto; height: 14px; flex: 1; }
  .thermo-fill {
    top: 0; bottom: 0; left: 0; height: 100% !important;
    width: var(--fill-w, 0%);
    transition: width .7s cubic-bezier(.22,1,.36,1), background .7s;
  }
  .thermo-val { margin: 0; }
  .thermo-label { display: none; }
  .delta-pop { right: auto; left: 50%; top: 46px; transform: translateX(-50%); }
  .inner-thought { top: 54px; font-size: 12px; }
  .char-avatar { width: min(70vh, 92vw); height: 62vh; }
  .char-img { max-height: 62vh; }
  .char-emoji { font-size: clamp(80px, 30vw, 140px); }
}

/* ===== 게이미피케이션: 배지 ===== */
.badge-pill {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  font-size: 13px; font-weight: 600;
}
.badge-pill.badge-new {
  background: linear-gradient(135deg, #ffd76b33, #ff9f6b33);
  border-color: #ffd76b88;
  animation: badgePop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badgePop { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 480px) { .badge-grid { grid-template-columns: repeat(4, 1fr); } }
.badge-tile {
  text-align: center;
  padding: 14px 6px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  transition: transform .2s;
}
.badge-tile.earned {
  background: linear-gradient(135deg, #2f2a44, #3a3020);
  border-color: #ffd76b55;
}
.badge-tile.earned:hover { transform: translateY(-3px); }
.badge-tile.locked { opacity: .45; filter: grayscale(.7); }
.badge-tile-icon { font-size: 34px; line-height: 1; }
.badge-tile-name { font-size: 11px; margin-top: 6px; color: rgba(255,255,255,.75); font-weight: 600; }
