/* ==========================================================================
   v2 — 꼬미를 주인공으로
   ========================================================================== */

/* -------------------------------------------------- 초원: 꼬미가 주인공 */
/* 원본은 토리가 항상 크게(36%) 왼쪽에 서고 꼬미는 절반 확률로 구석에(17%) 나왔다.
   주인공이 뒤바뀐 상태라 역할을 맞바꾼다. */
/* 정원은 원본 그대로 토리만 선다. 위치·크기·바운스는 원본 .meadow-actor 규칙을 그대로 쓴다. */

/* -------------------------------------------------------- 꼬미의 집 */
.meadow-house {
  position: absolute; right: 3%; top: 4%; width: 36%;
  padding: 0; border: none; background: none; cursor: pointer;
  pointer-events: auto; z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(92, 64, 30, .28));
}
.meadow-house svg, .meadow-house img { width: 100%; height: auto; display: block; }
.meadow-house:active { transform: scale(.95); }
/* 집 이름표: 글씨가 새겨진 나무 팻말 그림 (집 앞 오른쪽에 꽂힘) */
.meadow-house .meadow-house-sign {
  position: absolute; right: -6%; bottom: -30%; width: 58% !important; height: auto;
  filter: drop-shadow(0 3px 4px rgba(92, 64, 30, .3));
}
.meadow-house-label.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------ 홈 첫 도착: 꼬미 인사 */
.pip-greet {
  position: fixed; inset: 0; z-index: 900;
  /* 앱은 #app 의 max-width:520px 칸으로 가운데 정렬된다. 딤드도 그 칸 안에만 씌워야
     넓은 화면에서 폰 화면처럼 보인다. (inset:0 + max-width + margin:auto = 가운데) */
  max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
  background: rgba(26, 18, 10, .66);
  animation: overlay-in .35s ease both;
}
.pip-greet-chick {
  width: 46vw; max-width: 170px; height: auto;
  /* 등장은 원본 말풍선과 같은 bubble-pop, 그다음엔 초원의 meadow-bob 으로 잔잔하게 */
  animation: bubble-pop .35s ease both, meadow-bob 3.4s ease-in-out infinite .35s;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .5));
}
.pip-greet-bubble {
  position: relative; max-width: 330px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--line-strong); border-radius: 20px;
  padding: 16px 18px;
  font-weight: 700; font-size: 1.05rem; line-height: 1.5;
  text-align: center; word-break: keep-all;
  animation: bubble-pop .35s ease both .25s;
}
/* 말풍선 꼬리 (위쪽 꼬미를 가리킨다) */
.pip-greet-bubble::before {
  content: ""; position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-bottom: 13px solid var(--line-strong);
}
/* .btn-big 이 width:100% 라 그냥 두면 칸 끝까지 늘어난다. 말풍선과 같은 폭으로 맞춘다. */
.pip-greet .btn { width: 100%; max-width: 330px; min-width: 190px; animation: bubble-pop .35s ease both .5s; }


/* ------------------------------------------------ 연속 출석 도장 */
.pip-greet.daily .pip-greet-chick { width: 38vw; max-width: 136px; }
.stamp-box {
  width: 100%; max-width: 330px;
  background: var(--paper); border: 3px solid var(--line-strong); border-radius: 18px;
  padding: 12px 12px 10px;
  animation: bubble-pop .35s ease both .4s;
}
.stamp-title { margin: 0 0 9px; text-align: center; font-size: .92rem; font-weight: 800; color: var(--ink); }
.stamp-title b { color: var(--coral-deep, #c0491c); font-size: 1.18rem; }
.stamp-row { display: flex; gap: 4px; justify-content: center; }
.stamp-day {
  position: relative; flex: 1 1 0; min-width: 0; aspect-ratio: 1 / 1; max-width: 40px;
  border-radius: 50%;
  background: var(--bg-soft, #f6f1e7); border: 2px solid var(--line-strong); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800;
}
.stamp-day em { font-style: normal; }
.stamp-day.is-on { background: var(--sun); border-color: var(--sun-deep); color: var(--ink); }
.stamp-day.is-today { background: var(--paper); border-color: var(--coral); }
.stamp-old { position: absolute; right: -1px; bottom: -1px; font-style: normal; font-size: .6rem; color: #3f7a24; }

/* 오늘 칸에 쿵 하고 찍히는 도장 */
.stamp-mark {
  position: absolute; inset: -5px;
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 1.35rem;
  border-radius: 50%;
  background: rgba(255, 138, 92, .2);
  border: 3px solid var(--coral);
  animation: stamp-hit .5s cubic-bezier(.2, 1.5, .4, 1) both .62s;
}
@keyframes stamp-hit {
  0%   { opacity: 0; transform: scale(2.4) rotate(-16deg); }
  60%  { opacity: 1; transform: scale(.93) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
.stamp-note {
  margin: 8px 0 0; text-align: center; font-size: .8rem; font-weight: 800; color: var(--ink-soft);
  animation: bubble-pop .3s ease both 1s;
}
@media (prefers-reduced-motion: reduce) {
  .stamp-mark, .stamp-box, .stamp-note { animation: none; }
}

/* ---------------------------------------- 인사말 창 글로우 + 깜빡임 */
/* 꼬미가 말을 건 직후, 다음에 볼 곳을 가리킨다. 새 메시지를 누르면 멈춘다. */
.home-hint.is-calling {
  border-color: var(--sky-deep);
  animation: hint-glow 1.5s ease-in-out infinite;
}
@keyframes hint-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(90, 169, 240, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(90, 169, 240, .26), 0 0 22px 4px rgba(90, 169, 240, .55); }
}

/* ------------------------------------------------- 누를 곳으로 이끄는 유도 */
/* 버튼 테두리에서 퍼져 나가는 물결 */
.tap-ring {
  position: absolute; inset: 0; z-index: 3;
  border-radius: inherit;
  border: 3px solid var(--coral);
  pointer-events: none;
  animation: tap-ring 1.6s ease-out infinite;
}
@keyframes tap-ring {
  0%       { transform: scale(1);    opacity: .95; }
  70%, 100% { transform: scale(1.16); opacity: 0; }
}

/* 버튼 오른쪽 아래에 걸쳐 서서 위를 가리키는 손가락 */
.tap-hand {
  position: absolute; right: -16px; bottom: -18px; z-index: 6;
  font-size: 2.6rem; line-height: 1;
  pointer-events: none;
  transform-origin: 50% 100%;
  /* 버튼이 살구색이라 손 색과 겹쳐 묻혔다. 흰 테두리를 둘러 어떤 색 위에서도 보이게 한다. */
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px #fff) drop-shadow(0 0 6px #fff)
          drop-shadow(0 5px 8px rgba(92, 64, 30, .55));
  animation: tap-hand 1.6s cubic-bezier(.34, 1.56, .64, 1) infinite;
}
/* 버튼을 톡 누르고 튕겨 나오는 느낌 */
@keyframes tap-hand {
  0%, 55%, 100% { transform: translate(0, 0) rotate(-14deg) scale(1); }
  20%           { transform: translate(-10px, -18px) rotate(-2deg) scale(1.08); }
  38%           { transform: translate(-3px, -4px) rotate(-10deg) scale(1); }
}

/* ------------------------------------------------------- 설명 팝업 */
.detail-veil {
  position: fixed; inset: 0; z-index: 950;
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(26, 18, 10, .66);
  animation: overlay-in .25s ease both;
}
.detail-card {
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--line-strong); border-radius: 22px;
  padding: 22px 18px;
  text-align: center;
  animation: bubble-pop .3s ease both;
}
.detail-emoji { font-size: 3rem; line-height: 1; }
.detail-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; }
.detail-text { margin: 0; font-size: 1rem; line-height: 1.55; word-break: keep-all; color: var(--ink-soft); }
.detail-card .btn { width: 100%; margin-top: 6px; }


/* 버튼이 넷(뒤로·소리·성장·설정)으로 늘어 날씨 문구가 두 줄로 접혔다.
   상단 줄 간격과 글자를 조금 줄여 한 줄을 되찾는다. */
.home-topbar { gap: 8px; }
@media (max-width: 380px) {
  .home-topbar { gap: 5px; }
  .home-topbar .icon-btn, .home-topbar .back-btn { width: 46px; height: 46px; min-width: 46px; min-height: 46px; }
  /* 작은 폰에서는 날씨 문구가 "오늘 …" 으로 잘려 뜻이 없다 — 날씨 그림만 남긴다 */
  .home-topbar .neighborhood-status { padding: 6px 10px; }
  .home-topbar .ns-text { display: none; }
}

/* ==================================================== 경험치 · 레벨 · 성장 앨범 */
.growth-btn { font-size: 1.35rem; }

/* 날씨 줄 바로 아래 놓이는 경험치 게이지 */
.xp-gauge {
  flex: none; display: flex; align-items: center; gap: 10px;
  width: 100%; margin-top: 8px; padding: 8px 12px;
  background: var(--paper); border: none; border-radius: 18px;
  box-shadow: 0 3px 0 var(--line-strong);
  text-align: left; color: var(--ink);
}
.xp-gauge:active { transform: scale(.99); }
.xp-badge {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: var(--sun); display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; box-shadow: 0 2px 0 var(--sun-deep);
}
.xp-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.xp-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.xp-name { font-family: var(--font-display); font-weight: 400; font-size: 1.02rem; }
.xp-num { font-style: normal; font-size: .8rem; color: var(--ink-soft); white-space: nowrap; }
.xp-track {
  display: block; height: 10px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.xp-track.big { height: 14px; width: 100%; margin: 6px 0 2px; }
.xp-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sun) 0%, var(--coral) 100%);
  transition: width .6s cubic-bezier(.34, 1.4, .64, 1);
}
.xp-streak { flex: none; text-align: center; line-height: 1.1; }
.xp-streak b { display: block; font-size: 1.15rem; color: var(--coral-deep); }
.xp-streak i { font-style: normal; font-size: .68rem; color: var(--ink-soft); white-space: nowrap; }

/* 경험치를 받았을 때 잠깐 뜨는 알림 */
.xp-toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%);
  z-index: 940; padding: 9px 18px; border-radius: 999px;
  background: var(--coral); color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .25); pointer-events: none;
  animation: xp-toast 1.8s ease both;
}
@keyframes xp-toast {
  0%   { opacity: 0; transform: translate(-50%, 10px) scale(.9); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -6px); }
  100% { opacity: 0; transform: translate(-50%, -16px); }
}

/* 레벨업 축하 */
.levelup .lv-burst { font-size: 4.6rem; line-height: 1; animation: lv-burst .7s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes lv-burst { from { transform: scale(.3) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.lv-gift {
  margin: 2px 0 0; padding: 7px 12px; border-radius: 999px;
  background: var(--note-bg); border: 2px solid var(--note-border);
  font-size: .88rem; font-weight: 700; text-align: center; word-break: keep-all;
}
.lv-sub { margin: -6px 0 0; font-size: .95rem; color: var(--ink-soft); text-align: center; word-break: keep-all; }

/* 성장 앨범 */
.growth-card { max-width: 340px; max-height: 86dvh; overflow-y: auto; gap: 8px; }
.growth-title { margin: 0 0 4px; font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; }
.growth-badge {
  width: 86px; height: 86px; border-radius: 50%;
  background: var(--sun); box-shadow: 0 4px 0 var(--sun-deep);
  display: flex; align-items: center; justify-content: center; font-size: 2.8rem;
}
.growth-level { margin: 2px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; }
.growth-next { margin: 0; font-size: .88rem; color: var(--ink-soft); }
.growth-h { margin: 12px 0 2px; font-size: .95rem; font-weight: 800; }

.quest-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.quest {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 14px;
  background: var(--note-bg); border: 2px solid var(--note-border);
  font-size: .92rem; font-weight: 700; text-align: left; word-break: keep-all;
}
.quest span { flex: 1 1 auto; min-width: 0; }
.quest b { flex: none; font-size: .82rem; color: var(--ink-soft); }
.quest-check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--note-border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: .8rem; color: #fff;
}
.quest.is-done { background: var(--grass); border-color: #a8d98a; }
.quest.is-done .quest-check { background: #5aa03c; border-color: #5aa03c; }

.streak-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.streak-day {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--line); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 800;
}
.streak-day.is-on { background: var(--sun); color: var(--ink); box-shadow: 0 2px 0 var(--sun-deep); }

.growth-rewards { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.growth-reward {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--sun); box-shadow: 0 2px 0 var(--sun-deep);
  font-size: .82rem; font-weight: 800; word-break: keep-all;
}
.growth-reward i { font-style: normal; font-size: 1.05rem; }

/* ------------------------------------------------------- 방 캔버스 (가구를 얹는 층) */
.room-canvas { position: absolute; inset: 0 auto 0 0; height: 100%; will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .lv-burst, .xp-toast { animation: none; }
}

/* 작은 폰에서 게이지가 눌리지 않게 */
@media (max-width: 380px) {
  .xp-gauge { gap: 8px; padding: 7px 10px; }
  .xp-badge { width: 34px; height: 34px; font-size: 1.15rem; }
  .xp-name { font-size: .95rem; }
  .xp-num { font-size: .74rem; }
}



/* ---- 성장 앨범 높이 ----
   재보니 내용이 692~754px 인데 82dvh 로 묶어두어 큰 폰에서도 아슬아슬하게 잘렸다.
   여유를 92dvh 로 늘리고 군살을 덜어, 390px 이상 폰에서는 스크롤이 안 생기게 한다.
   (360x640 같은 작은 폰은 내용이 애초에 화면보다 커서 스크롤이 남는다) */
.growth-veil { padding: 14px; }
.growth-card {
  max-height: 92dvh;
  gap: 6px;
  padding: 22px 14px 16px;
}
.growth-badge { width: 64px; height: 64px; font-size: 2.1rem; }
.growth-title { margin-bottom: 0; font-size: 1.25rem; }
.growth-level { font-size: 1.1rem; }
.growth-h { margin: 7px 0 0; font-size: .9rem; }
.growth-next { font-size: .84rem; }
.xp-track.big { margin: 3px 0 0; }
.quest { padding: 7px 10px; font-size: .88rem; }
.streak-day { width: 30px; height: 30px; font-size: .78rem; }
.growth-reward { padding: 5px 9px; font-size: .78rem; }
.growth-card .btn { margin-top: 6px; }

/* 목표 줄은 눌러서 설명을 볼 수 있다 */
.quest-list li { list-style: none; }
button.quest { width: 100%; cursor: pointer; font-family: inherit; color: inherit; }
.quest-more {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--line-strong); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: .72rem; font-weight: 800;
}
.quest.is-done .quest-more { background: #5aa03c; }
/* 앨범 위에 겹쳐 뜨는 설명 */
.detail-veil.on-top { z-index: 960; }


/* --------------------------------------------------------- 홈 상단 정리 */
/* 버튼이 넷이라 space-between 으로는 날씨 칸이 한쪽으로 쏠린다.
   날씨를 가운데 늘리고 버튼은 양 끝에 고정한다. */
.home-topbar { justify-content: flex-start; }
.home-topbar .neighborhood-status { flex: 1 1 auto; min-width: 0; justify-content: center; }
.home-topbar .ns-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------ 말하기가 주인공 */
/* 마이크는 크고 가운데, 키보드는 옆으로 물러난 보조 버튼으로 */
.mic-btn { width: 92px; height: 92px; }
.mic-btn .mic-icon { font-size: 2.5rem; }
.mic-hint {
  display: block; margin-top: 6px;
  font-size: .86rem; font-weight: 800; color: var(--ink-soft); text-align: center;
}
#btn-text-toggle {
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  font-size: .95rem; opacity: .55;
}
#btn-text-toggle:active { opacity: 1; }
@media (max-width: 380px) {
  .mic-btn { width: 82px; height: 82px; }
  .mic-btn .mic-icon { font-size: 2.2rem; }
}

/* ------------------------------------------------------------- 단서 */
.clue-row { position: relative; }
.object-chip.is-clue {
  position: relative;
  background: var(--note-bg);
  border: 2px dashed var(--note-border);
  box-shadow: 0 3px 0 rgba(92, 64, 30, .12);
}
/* 돋보기 표식 — 살펴볼 것이라는 신호 */
.object-chip.is-clue::before {
  content: "🔍";
  position: absolute; top: -9px; left: -9px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--note-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem;
}
/* 아직 안 살펴본 단서는 살짝 흔들려 눈에 띈다 */
.object-chip.is-clue.is-new { animation: clue-wiggle 2.4s ease-in-out infinite; }
@keyframes clue-wiggle {
  0%, 88%, 100% { transform: rotate(0deg); }
  91%  { transform: rotate(-4deg); }
  94%  { transform: rotate(4deg); }
  97%  { transform: rotate(-2deg); }
}
.object-chip.is-clue.is-seen { opacity: .72; border-style: solid; }
.object-chip.is-clue.is-seen::before { content: "✓"; color: #5aa03c; font-weight: 800; }
@media (prefers-reduced-motion: reduce) {
  .object-chip.is-clue.is-new { animation: none; }
}

/* ------------------------------------------------------- 팝업 모양 정리 */
/* 우측 상단 닫기 버튼 — 다른 팝업(overlay-close)과 같은 자리, 같은 모양 */
.detail-card { position: relative; padding-top: 26px; }
.popup-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  padding: 0; border: none; border-radius: 50%;
  background: var(--paper); color: var(--ink);
  font-size: .95rem; line-height: 1;
  box-shadow: 0 3px 8px var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.popup-close:active { transform: scale(.92); }

/* 브라우저 기본 스크롤바가 그대로 보여 거칠었다. 얇고 앱 색에 맞게 */
.growth-card {
  max-height: 82dvh;
  padding-right: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  overscroll-behavior: contain;
}
.growth-card::-webkit-scrollbar { width: 8px; }
.growth-card::-webkit-scrollbar-track { background: transparent; }
.growth-card::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }

/* 노란 바탕 위 글자는 테마를 따르면 다크 모드에서 묻힌다. 항상 진한 갈색으로. */
.growth-reward, .streak-day.is-on { color: #4a3628; }
.growth-badge, .xp-badge { color: #4a3628; }

/* 목표 줄: 동그라미가 너무 커 보여 조금 줄이고 간격을 좁힌다 */
.quest { padding: 8px 11px; gap: 8px; }
.quest-check { width: 19px; height: 19px; font-size: .72rem; }
.growth-h { margin: 10px 0 2px; }
.growth-card .btn { margin-top: 4px; }


/* 마이크 아래 문구 — 옆이 아니라 바로 아래 가운데에 놓는다 */
.mic-wrap { position: relative; padding-bottom: 26px; }
.mic-hint {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  margin: 0; white-space: nowrap;
  font-size: .86rem; font-weight: 800; color: var(--ink-soft);
}
/* 듣는 동안에는 눈에 띄게 */
.screen-stage.is-listening .mic-hint { color: #e35d57; }
/* 말하기 전용 시연본 — 글자 입력 자리는 아예 비운다 */
#text-input-row[hidden], #btn-text-toggle[hidden] { display: none !important; }


/* ------------------------------------------------- 이야기 중 경험치 게이지 */
/* 축하 화면은 엔딩 뒤로 미루고, 이야기 중엔 이 가느다란 막대만 보여준다 */
.stage-xp {
  flex: none; display: flex; align-items: center; gap: 8px;
  margin: 6px 0 2px; padding: 5px 10px;
  background: var(--paper); border-radius: 999px;
  box-shadow: 0 2px 0 var(--line-strong);
}
.stage-xp-badge { flex: none; font-size: 1.05rem; line-height: 1; }
.stage-xp-track {
  flex: 1 1 auto; height: 8px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.stage-xp-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sun) 0%, var(--coral) 100%);
  transition: width .6s cubic-bezier(.34, 1.4, .64, 1);
}
.stage-xp-num { flex: none; font-size: .72rem; font-weight: 800; color: var(--ink-soft); }


/* ------------------------------------------------------------- 폭죽 */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; left: 50%; top: 42%;
  width: 10px; height: 14px; border-radius: 2px;
  opacity: 0;
  animation: confetti-fly 1.5s cubic-bezier(.15, .7, .35, 1) var(--delay, 0s) both;
}
@keyframes confetti-fly {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(0deg); }
  12%  { opacity: 1; }
  60%  { opacity: 1; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 70px)) scale(.9) rotate(var(--rot)); }
}
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* ---------------------------------------------------------- 듣는 중 표시 */
/* 원본은 마이크 버튼 색만 바뀌어 녹음 중인지 알기 어려웠다.
   버튼 위에 빨간 표찰을 띄우고, 고리를 더 크게 울린다. */
.mic-wrap { position: relative; }
.rec-badge {
  position: absolute; left: 50%; bottom: calc(100% + 12px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  background: #e35d57; color: #fff;
  padding: 8px 15px; border-radius: 999px;
  font-weight: 800; font-size: .95rem; white-space: nowrap;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .3);
  pointer-events: none; z-index: 8;
  animation: rec-pop .22s ease both;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: rec-blink 1s steps(1) infinite; }
@keyframes rec-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .2; } }
@keyframes rec-pop { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 듣는 동안 마이크 고리를 더 넓게 울린다 */
.mic-btn[aria-pressed="true"] { animation: mic-listen 1.1s ease-out infinite; }
@keyframes mic-listen {
  0%        { box-shadow: 0 8px 0 #b33330, 0 0 0 0 rgba(227, 93, 87, .55); }
  70%, 100% { box-shadow: 0 8px 0 #b33330, 0 0 0 26px rgba(227, 93, 87, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .rec-dot, .mic-btn[aria-pressed="true"] { animation: none; }
}

/* ------------------------------------------------------ 장소 유도 화면 */
.coach {
  position: fixed; inset: 0; z-index: 900;
  max-width: 520px; margin: 0 auto;           /* #app 칸 안에만 */
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(26, 18, 10, .66);
  animation: overlay-in .3s ease both;
}
.coach-card {
  width: 100%; max-width: 330px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--line-strong); border-radius: 22px;
  padding: 22px 18px;
  animation: bubble-pop .35s ease both;
}
.coach-text { margin: 0; font-size: 1.08rem; font-weight: 700; line-height: 1.5; text-align: center; word-break: keep-all; }
.coach-text b { color: var(--coral-deep); }
.coach .btn { width: 100%; }

/* 끌어다 놓기 시연: 꼬미가 친구 쪽으로 갔다가 돌아온다 */
.coach-track { position: relative; width: 220px; height: 92px; }
.coach-track img { width: 100%; height: 100%; object-fit: contain; display: block; }
.coach-friend { position: absolute; right: 0; bottom: 0; width: 74px; height: 74px; }
.coach-mover { position: absolute; left: 0; bottom: 0; width: 74px; height: 74px; animation: coach-drag 2.6s ease-in-out infinite; }
.coach-pip { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 0 4px #60a5fa; background: var(--paper); }
.coach-mover .coach-hand {
  position: absolute; right: -6px; bottom: -14px; font-size: 1.9rem; line-height: 1;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px #fff) drop-shadow(0 4px 6px rgba(92,64,30,.5));
}
@keyframes coach-drag {
  0%, 12%   { transform: translateX(0) scale(1); }
  50%, 66%  { transform: translateX(140px) scale(1.06); }
  88%, 100% { transform: translateX(0) scale(1); }
}

/* 마이크 누르기 시연 */
.coach-track-mic { width: 130px; height: 120px; }
.coach-mic {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--coral); box-shadow: 0 6px 0 #b33330;
  display: flex; align-items: center; justify-content: center; font-size: 2.2rem;
}
.coach-mic-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--coral); animation: tap-ring 1.6s ease-out infinite;
}
.coach-hand-tap {
  position: absolute; left: 50%; bottom: -2px;
  font-size: 2.2rem; line-height: 1;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px #fff) drop-shadow(0 0 6px #fff)
          drop-shadow(0 4px 7px rgba(92,64,30,.55));
  animation: coach-tap 1.6s cubic-bezier(.34,1.56,.64,1) infinite;
}
@keyframes coach-tap {
  0%, 55%, 100% { transform: translate(-50%, 0) rotate(-10deg); }
  20%           { transform: translate(-50%, -22px) rotate(0deg) scale(1.08); }
  38%           { transform: translate(-50%, -6px) rotate(-8deg); }
}
@media (prefers-reduced-motion: reduce) {
  .coach-mover, .coach-hand-tap, .coach-mic-ring { animation: none; }
}

/* ------------------------------------------------------------- 단톡방 */
/* 이름표를 말풍선 위가 아니라 프로필 사진 아래에 붙인다 */
.bubble-who { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none; }
.bubble-who .bubble-name {
  padding: 0; font-size: .72rem; line-height: 1.15;
  max-width: 62px; text-align: center; word-break: keep-all;
}
.bubble-row.is-partner .bubble-who .bubble-name,
.bubble-row.is-player .bubble-who .bubble-name { text-align: center; }

/* 말하는 동안 프로필에 글로우 펄스. 고리 색은 캐릭터 색(--chip-color)을 따른다. */
.bubble-avatar { position: relative; }
.bubble-avatar.is-speaking { animation: avatar-breathe 1.1s ease-in-out infinite; }
.bubble-avatar.is-speaking::before {
  content: ""; position: absolute; inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--chip-color, #5aa9f0);
  pointer-events: none;
  animation: avatar-ring 1.1s ease-out infinite;
}
@keyframes avatar-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}
@keyframes avatar-ring {
  0%        { transform: scale(.94); opacity: .9; }
  70%, 100% { transform: scale(1.26); opacity: 0; }
}

/* 타이핑 중 깜빡이는 커서 */
.bubble-text.is-typing::after,
.bubble-caption.is-typing::after {
  content: ""; display: inline-block;
  width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: currentColor; opacity: .7;
  animation: type-caret .7s steps(1) infinite;
}
@keyframes type-caret { 0%, 49% { opacity: .7; } 50%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .bubble-avatar.is-speaking, .bubble-avatar.is-speaking::before { animation: none; }
}

/* ---------------------------------------------------------- 스티커북 간격 */
/* 칸은 minmax(88px,1fr) 로 늘어나는데 카드가 width:78px 로 고정이라 사이가 휑했다.
   카드가 칸을 꽉 채우게 해 간격을 좁힌다. 엔딩의 보상 줄은 건드리지 않는다. */
.rewards-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.rewards-grid .reward-card { width: auto; padding: 12px 8px; }
.rewards-grid .reward-label { word-break: keep-all; }
/* 새 메시지 버튼 바로 위로 내려온 인사말은 살짝 띄운다 (.home-actions 기본 gap 이 6px) */
.home-actions > .home-hint { margin-bottom: 4px; }
@media (prefers-reduced-motion: reduce) {
  .home-hint.is-calling { animation: none; box-shadow: 0 0 0 4px rgba(90, 169, 240, .3); }
  .pip-greet-chick, .tap-hand { animation: none; }
}

/* ----------------------------------------------------- 꼬미의 방 화면 */
.screen-room { height: 100dvh; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 24px; }
.room-topbar {
  flex: none; display: grid; grid-template-columns: 52px 1fr 52px;
  align-items: center; gap: 10px; min-height: 52px;
}
.room-title {
  grid-column: 2; justify-self: center;
  font-family: var(--font-display); font-size: 1.15rem;
  background: var(--hint-bg); border: 2px solid var(--hint-border);
  padding: 8px 20px; border-radius: 999px;
}
.room-floor {
  position: relative; flex: 1 1 auto; min-height: 0; margin-top: 10px;
  border-radius: var(--radius-lg); overflow: hidden;
  border: 3px solid var(--line-strong);
  background:
    linear-gradient(180deg, #ffe9c9 0%, #ffe0b6 58%, #e8b783 58%, #dda86f 100%);
}
/* 벽지 무늬 + 바닥 경계 */
.room-floor::before {
  content: ""; position: absolute; inset: 0 0 42% 0;
  background-image: radial-gradient(rgba(255, 255, 255, .5) 1.5px, transparent 1.6px);
  background-size: 18px 18px;
}
.room-window {
  position: absolute; top: 9%; left: 8%; width: 30%; height: 26%;
  border-radius: 10px; border: 3px solid #d8a86e;
  background: linear-gradient(180deg, #bfe4fb 0%, #e6f5ff 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6);
}
.room-window::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to right, transparent calc(50% - 1.5px), #d8a86e calc(50% - 1.5px), #d8a86e calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    linear-gradient(to bottom, transparent calc(50% - 1.5px), #d8a86e calc(50% - 1.5px), #d8a86e calc(50% + 1.5px), transparent calc(50% + 1.5px));
}
.room-pip {
  position: absolute; right: 7%; bottom: 6%; width: 22%;
  pointer-events: none;
}
.room-pip img {
  width: 100%; height: auto; display: block;
  animation: bubble-pop .35s ease both, meadow-bob 3.4s ease-in-out infinite .35s;
}

/* 방 아이템은 버튼이 아니라 방에 놓인 가구처럼 보여야 한다.
   카드 배경·테두리를 걷어내고 그림만 크게, 바닥 그림자로 놓인 느낌을 준다. */
.room-item {
  position: absolute; width: 118px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: none; background: none; box-shadow: none;
  touch-action: none; cursor: grab;
  color: var(--ink);
  /* 두 손가락으로 바꾼 크기. 바닥을 기준으로 위로 자라야 놓인 느낌이 유지된다. */
  transform: scale(var(--item-scale, 1));
  transform-origin: 50% 100%;
  transition: transform .08s ease-out;
}
.room-item.is-pinching { z-index: 20; transition: none; }
.room-item:active { cursor: grabbing; }
.room-item-emoji {
  font-size: 5.7rem; line-height: 1;
  filter: drop-shadow(0 4px 5px rgba(92, 64, 30, .35));
  transition: transform .12s ease;
}
/* 바닥에 놓인 느낌을 주는 타원 그림자 */
.room-item::after {
  content: ""; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  width: 82px; height: 17px; border-radius: 50%;
  background: rgba(92, 64, 30, .2);
  filter: blur(2.5px);
}
.room-item.is-dragging { z-index: 20; }
.room-item.is-dragging .room-item-emoji { transform: scale(1.15) translateY(-4px); }
.room-item.is-dragging::after { opacity: .45; }

.room-hint {
  flex: none; margin-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  font-size: .9rem; color: var(--ink-soft); text-align: center; word-break: keep-all;
}
.room-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; font-weight: 700; color: var(--ink-soft); word-break: keep-all;
}


.room-item-emoji.has-art img { width: 110px; height: 110px; object-fit: contain; display: block; filter: drop-shadow(0 5px 6px rgba(92,64,30,.3)); }
.xp-fire { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; margin-right: 2px; }
.growth-reward i img { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }

/* 방 3개를 세로로 쌓기 (침실 → 거실 → 마당). 물건을 다른 방 위에 놓으면 그 방으로 옮겨간다 */
.room-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.room-block { display: flex; flex-direction: column; gap: 6px; }
.room-name { margin: 0 4px; font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; color: #4a3628; }
.room-block .room-floor { margin-top: 0; }
.room-floor.has-art .room-empty { background: rgba(255,255,255,.9); border-radius: 14px; padding: 8px 12px; color: #4a3628; box-shadow: 0 3px 8px rgba(60,40,20,.15); inset: auto 8% 6% 8%; font-size: .9rem; }
.room-floor[data-room="yard"] .room-item { /* 마당엔 벽이 없어 어디든 */ }
/* 다른 방으로 끌고 갈 때: 손가락을 따라가는 고스트 + 놓을 방 강조 */
.room-ghost { position: fixed !important; z-index: 1000; pointer-events: none; opacity: .92; width: 96px; transform: scale(var(--item-scale, 1)); }
.room-ghost .room-item-emoji.has-art img { width: 96px; height: auto; }
.room-floor.is-drop-target { outline: 4px solid #60a5fa; outline-offset: -4px; box-shadow: 0 0 0 6px rgba(96,165,250,.35); }

/* ------------------------------------------- 직접 끝내기 ✋ · 들은 말 확인 시트 */
/* "다 말했어 ✋" — 듣는 동안 마이크 오른쪽에 크게. 마이크는 가운데 그대로 둔다 */
.mic-done-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  left: calc(50% + 58px); right: 0; max-width: 150px;   /* left 는 JS(placeMicDone)가 마이크 실제 위치로 다시 잡는다 */
  min-height: 64px; padding: 8px 10px;
  border: none; border-radius: 22px;
  background: var(--sun); color: var(--ink);
  box-shadow: 0 5px 0 var(--sun-deep), 0 8px 14px var(--shadow);
  font-family: var(--font-display); font-size: 1.05rem; line-height: 1.15;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  word-break: keep-all; z-index: 9;
  animation: mic-done-pop .22s ease backwards;   /* backwards — 끝난 뒤엔 :active 눌림이 먹게 */
}
@keyframes mic-done-pop { from { opacity: 0; transform: translateY(calc(-50% + 8px)); } to { opacity: 1; transform: translateY(-50%); } }
.mic-done-btn:active { transform: translateY(calc(-50% + 3px)); box-shadow: 0 2px 0 var(--sun-deep); }
.mic-done-count { font-family: var(--font-body); font-size: .78rem; font-weight: 800; color: #b3412f; }
@media (max-width: 380px) {
  .mic-done-btn { left: calc(50% + 50px); font-size: .98rem; min-height: 58px; padding: 6px 8px; }
}

/* 확인 시트 — 발밑(마이크 줄)을 덮고 위로 올라온다 */
.stage-footer { position: relative; }
.mic-confirm {
  position: absolute; left: 0; right: 0; bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 30;
  background: var(--paper); border: 3px solid var(--line-strong); border-radius: 22px;
  box-shadow: 0 -6px 22px var(--shadow-strong);
  padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  animation: mic-sheet-up .24s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes mic-sheet-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.mic-confirm-title {
  margin: 0; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 1.05rem; color: var(--ink-soft);
}
.mic-confirm-avatar img { width: 34px; height: 34px; object-fit: contain; display: block; }
.mic-confirm-text {
  margin: 0; padding: 10px 14px;
  background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: 16px;
  font-size: 1.2rem; font-weight: 700; line-height: 1.4; word-break: keep-all;
  max-height: 30dvh; overflow-y: auto;
}
.mic-confirm-text::before { content: "“"; }
.mic-confirm-text::after { content: "”"; }
.mic-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mic-confirm-actions .btn { min-height: 60px; font-size: 1.05rem; padding: 0 8px; white-space: nowrap; }
.mic-confirm-retry {
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--line-strong); box-shadow: 0 4px 0 var(--line-strong);
}
.mic-confirm-retry:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line-strong); }
@media (max-width: 340px) {
  .mic-confirm-actions .btn { font-size: .95rem; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .mic-done-btn, .mic-confirm { animation: none; }
}
