/* ==========================================================================
   말랑귀! 무슨 일이야, 친구야? — 아이용 웹 클라이언트 (폰 세로 화면 우선)
   방향: 따뜻한 그림책 마을. 파스텔 크림 종이 위에 일러스트 캐릭터, 큼직한 터치 타겟.
   레이아웃: 모든 주요 화면은 100dvh 안에 들어가고(세로 스크롤 없음), 목록/설정은 바텀시트.
   ========================================================================== */

:root {
  --cream: #fff4dd;
  --paper: #fffdf7;
  --ink: #4a3628;
  --ink-soft: #6b5741;   /* 보조 안내 문구 — 크림 배경 위 대비 4.5:1 이상 (예전 #8a7259 는 미달) */
  --peach: #ffe1c2;
  --peach-deep: #ffbf8d;
  --sky: #dbeeff;
  --sky-deep: #5aa9f0;
  --grass: #d6efc4;
  --sun: #ffcf4a;
  --sun-deep: #e2ad1f;
  --coral: #ff8a5c;
  --coral-deep: #d96a40;
  --line: #f0e3cb;
  --line-strong: #e6d3ad;
  --shadow: rgba(92, 64, 30, 0.14);
  --shadow-strong: rgba(92, 64, 30, 0.28);

  --hint-bg: #eaf3ff;
  --hint-border: #bcd8ff;
  --note-bg: #fff6dc;
  --note-border: #f6dc8f;
  --log-bg: rgba(255, 253, 247, 0.78);

  --c-kongi: #f6b26b;
  --c-moka: #a78bfa;
  --c-bobo: #8b5e3c;
  --c-toto: #f9a8d4;
  --c-pip: #60a5fa;
  --c-keeper: #9ca3af;

  --radius-lg: 28px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --touch: 56px;
  --gutter: 14px;

  /* 초등 저학년용 무료 폰트(OFL, fonts/fonts.css 자체 호스팅): 제목 주아 · 본문 고운돋움 · 손글씨 개구 */
  --font-display: "Jua", "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  --font-hand: "Gaegu", "Gowun Dodum", "Apple SD Gothic Neo", sans-serif;

  color-scheme: light;
}

/* 말랑귀는 라이트 팔레트 고정 — 폰 다크모드에서 글자만 밝아져 배경과 겹치는 문제 방지 */

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  /* 벽지: 크림 종이 위에 한 톤 진한 낙서 무늬(발자국·별·구름·하트·잎) + 위쪽이 살짝 밝은 빛 */
  background-color: var(--cream);
  background-image: url("assets/wallpaper_day.webp");
  background-size: 700px 700px;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;          /* 저학년 읽기: 본문 17px 이상, 줄간격 1.55 */
  line-height: 1.55;
  letter-spacing: .005em;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
/* 넓은 화면: 가운데 폰 크기 기둥 + 은은한 종이 패턴 */
@media (min-width: 560px) {
  body {
    background-color: var(--cream);
    background-image: radial-gradient(rgba(255, 255, 255, .55) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
  }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

#app {
  position: relative;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  overflow-x: clip;
  background: var(--cream) url("assets/wallpaper_day.webp") center top / 700px 700px;   /* 벽지 (body 와 같은 타일) */
}
@media (min-width: 560px) {
  #app { box-shadow: 0 0 0 1px var(--line-strong), 0 24px 60px var(--shadow); }
}

button { font-family: inherit; cursor: pointer; color: inherit; touch-action: manipulation; }
input, select, textarea { font-family: inherit; font-size: max(16px, 1rem); }
img { max-width: 100%; }
.avatar-img, .meadow-actor img, .title-char, .home-card-emoji img, .brand-emoji img, .intro-char, .ending-emoji img,
.ns-emoji, .gear-btn img, .home-hint-avatar img, .stage-prompt-avatar img, .reflection-avatar img, .meadow-cloud, .meadow-sun {
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none; pointer-events: none;
}
.avatar-img { display: block; object-fit: contain; }
.avatar-emoji { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
/* v0.4 그림이 아직 없는 캐릭터(도도·뭉치·쫑이·솜이)의 자리표시: 캐릭터 색 동그라미 + 이모지 + 이름. 깨진 그림 대신 */
.avatar-ph {
  --ph-color: #cbb89a;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 86%; aspect-ratio: 1 / 1; max-width: 100%; max-height: 100%;
  border-radius: 50%; line-height: 1; text-align: center; overflow: hidden;
  background: #fff8ea;
  background: radial-gradient(circle at 50% 38%, #fffdf8 0%, color-mix(in srgb, var(--ph-color) 38%, #fff) 72%);
  border: 3px solid var(--ph-color);
  box-shadow: 0 3px 8px rgba(60, 40, 20, .18);
  -webkit-user-select: none; user-select: none; pointer-events: none;
}
.avatar-ph-emoji { font-size: 1.5em; }
.avatar-ph-name { display: none; font-size: .34em; font-weight: 800; color: #4a3628; max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 무대 칩: .char-chip-avatar .char-chip-img(그림용, 100%·각진 모서리) 보다 구체적으로 */
.char-chip-avatar .avatar-ph.char-chip-img { width: 84px; height: 84px; margin: 0 0 8px; border-radius: 50%; font-size: 2.2rem; }
.char-chip-avatar .avatar-ph-name, .ep-art .avatar-ph-name, .friend-emoji .avatar-ph-name, .rel-avatar .avatar-ph-name,
.reco-art .avatar-ph-name { display: block; }
.ep-art .avatar-ph.ep-art-img, .ep-art .avatar-ph { width: 84px; height: 84px; margin-bottom: 16px; font-size: 2.1rem; position: relative; z-index: 1; }
.bubble-avatar .avatar-ph, .speech-avatar .avatar-ph { width: 100%; font-size: 1rem; border-width: 2px; }
.rel-avatar .avatar-ph { width: 58px; height: 58px; font-size: 1.4rem; }
.friend-emoji .avatar-ph { font-size: 1.6rem; }

/* ---------------------------------------------------------------- screens */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  animation: screen-in .35s ease both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

.screen-center { align-items: center; justify-content: center; }

.screen-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.55rem;
  text-align: center;
  margin: 4px 0 16px;
  letter-spacing: -.01em;
}

/* ------------------------------------------------------------------ card */
.card {
  background: var(--paper) url("assets/paper_tile.webp") center / 384px 384px;
  border-radius: var(--radius-lg);
  box-shadow: 0 5px 0 var(--line-strong), 0 12px 24px var(--shadow);   /* 두툼한 종이 카드 */
  padding: 26px 20px;
  width: 100%;
  max-width: 420px;
  border: 3px solid var(--line-strong);
}

.brand { text-align: center; margin-bottom: 18px; }
.brand-emoji { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin-bottom: 8px; }
.brand-emoji img { height: 58px; width: auto; }
.brand-emoji img:nth-child(2) { height: 72px; }
.brand h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; margin: 4px 0 0; }
.brand-sub { color: var(--ink-soft); margin: 2px 0 0; font-size: .95rem; }

.stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .95rem; font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="range"] {
  min-height: var(--touch);
  border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  padding: 0 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: max(16px, 1.05rem);
  font-weight: 500;
  width: 100%;
}
.field input:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }
.field input[type="range"] { padding: 0 8px; }
.field legend { font-weight: 700; margin-bottom: 4px; }

.hint { color: var(--ink-soft); font-size: .88rem; text-align: center; margin: 0; }
.error-text { color: #d9534f; font-size: .9rem; text-align: center; margin: 0; }
.save-msg { color: #4c9a5f; font-size: .9rem; text-align: center; margin: 4px 0 0; }

/* -------------------------------------------------------------- buttons */
.btn {
  min-height: var(--touch);
  border-radius: 999px;
  border: none;
  padding: 0 22px;
  font-weight: 700;
  font-size: 1.05rem;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible, .icon-btn:focus-visible, .home-card:focus-visible, .episode-card:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 3px; }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 6px 0 var(--coral-deep); font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; letter-spacing: .01em; }
.btn-primary:active { box-shadow: 0 2px 0 var(--coral-deep); transform: translateY(4px) scale(.99); }
.btn-big { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink-soft); text-decoration: underline; min-height: 48px; font-size: .95rem; }

.icon-btn {
  min-width: 52px; min-height: 52px;
  width: 52px; height: 52px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  font-size: 1.3rem;
  box-shadow: 0 4px 10px var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 40px; height: 40px; min-width: 40px; min-height: 40px; font-size: .95rem; }

/* ◀ 뒤로 가기 — 모든 화면 공통 (방 화면 ◀ 는 gamify.js 가 같은 클래스로 만든다) */
.back-btn {
  min-width: 52px; min-height: 52px;
  width: 52px; height: 52px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 4px 10px var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.back-btn:active { transform: scale(.92); }
/* 카드가 가운데 놓이는 화면에서는 카드 위가 아니라 화면 왼쪽 위에 띄운다 */
.screen-center { position: relative; }
.screen-center > .back-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: var(--gutter);
  z-index: 5;
}
/* 작은 폰에서는 조금 줄인다 (홈 상단바 ◀ 는 옆 아이콘과 맞춰 gamify.css 에서 46px) */
@media (max-width: 380px) {
  .back-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 1.1rem; }
  .chat-topbar { grid-template-columns: 44px 1fr 44px; }
}

/* 보호자 계정 만들기: 카드 우측 상단 X (버튼은 gamify.js 가 단다) */
.auth-card { position: relative; }
.card-close {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  padding: 0; border-radius: 50%; border: none;
  background: var(--paper); color: var(--ink);
  font-size: .95rem; line-height: 1;
  box-shadow: 0 4px 10px var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
}
.card-close:active { transform: scale(.92); }
/* 회원가입 폼이 열려 있는 동안에는 화면 왼쪽 위 뒤로가기를 숨긴다 (X 와 겹쳐 헷갈리지 않게) */
#screen-guardian-login.is-registering > .back-btn { display: none; }

/* ------------------------------------------------------------- children */
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 14px; margin-bottom: 18px; }
.child-card {
  background: var(--peach);
  border-radius: var(--radius-md);
  border: none;
  padding: 18px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  min-height: 112px;
  box-shadow: 0 6px 0 var(--peach-deep);
}
.child-card:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--peach-deep); }
.child-emoji { font-size: 2.2rem; }

/* ================================================================== HOME */
.screen-home {
  height: 100dvh;
  overflow: hidden;
  gap: 10px;
}
.home-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.neighborhood-status {
  background: var(--hint-bg);
  border: 2px solid var(--hint-border);
  border-radius: 999px;
  padding: 8px 16px 8px 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
}
.ns-emoji { width: 30px; height: 30px; object-fit: contain; }
.gear-btn { width: 56px; height: 56px; min-width: 56px; min-height: 56px; }
.gear-btn img { width: 32px; height: 32px; object-fit: contain; }

.home-hint {
  flex: none;
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 34px 12px 12px;
  border-radius: 20px;
  background: var(--hint-bg);
  border: 2px solid var(--hint-border);
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.45;
}
.home-hint-avatar { position: relative; flex: none; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.home-hint-avatar img { width: 52px; height: 52px; object-fit: contain; animation: chick-bob 2.6s ease-in-out infinite; }
.home-hint-spark { position: absolute; color: var(--sun); font-style: normal; font-size: .9rem; top: -4px; right: -6px; animation: spark-twinkle 1.8s ease-in-out infinite; }
.home-hint-spark-r { top: auto; right: 12px; bottom: 10px; font-size: 1.1rem; animation-delay: .6s; }
.home-hint-text { flex: 1; min-width: 0; }
@keyframes chick-bob { 0%,100% { transform: translateY(0) rotate(-3deg);} 50% { transform: translateY(-4px) rotate(3deg);} }
@keyframes spark-twinkle { 0%,100% { opacity: .35; transform: scale(.8);} 50% { opacity: 1; transform: scale(1.15);} }

/* ---- 초원 (하늘 그라데이션 + 구름/해 png + 인라인 SVG 언덕) */
.home-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 3px solid var(--line);
  background: #bfe4fb;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 10px 24px var(--shadow);
}
.meadow-sky {
  position: absolute; inset: 0;
  background: #bfe4fb url("assets/bg_v2/home.jpg") center 55% / cover no-repeat;
}
/* 마을 소품: 표지판·동물 (배경 그림 위 고정 위치, %) */
/* 표지판: 글씨는 그림에 새겨 넣었다(assets/signpost_town.png, signpost_play.png) */
.meadow-sign { position: absolute; height: auto; pointer-events: none; }
.meadow-sign-town { left: 3%; top: 5%; width: 31%; }
.meadow-sign-play { left: 1%; bottom: 3%; width: 28%; }
.meadow-bird { position: absolute; left: 12%; top: 1%; width: 12%; height: auto; animation: meadow-bob 2.6s ease-in-out infinite; }
.meadow-duck { position: absolute; left: 3%; top: 39%; width: 13%; height: auto; animation: duck-drift 7s ease-in-out infinite alternate; }
.meadow-butterfly { position: absolute; right: 8%; top: 40%; width: 10%; height: auto; animation: butterfly-flit 4.5s ease-in-out infinite; }
@keyframes duck-drift { from { transform: translateX(0); } to { transform: translateX(28%); } }
@keyframes butterfly-flit { 0%,100% { transform: translate(0,0) rotate(-6deg); } 50% { transform: translate(-14px,-10px) rotate(8deg); } }
/* 우체통 = 새 메시지 입구 */
.meadow-mailbox {
  position: absolute; right: 9%; bottom: 17%; width: 22%; padding: 0; border: none; background: none; box-shadow: none;
  pointer-events: auto; cursor: pointer;
}
.meadow-mailbox img { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 4px rgba(60,40,20,.25)); }
.meadow-mailbox:active { transform: scale(.95); }
.meadow-mailbox .mail-badge {
  position: absolute; top: -8%; right: -6%; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  background: #ff5a4e; color: #fff; font-weight: 800; font-size: .85rem; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.meadow-mailbox .mail-bubble {
  position: absolute; right: -2%; top: -34px; white-space: nowrap;
  background: #fff; border: 2px solid #ffb3a7; border-radius: 999px; padding: 4px 10px; font-size: .78rem; font-weight: 800; color: #d84b3a;
  animation: bubble-pop .35s ease both;
}
.meadow-mailbox .mail-bubble::after { content: ""; position: absolute; left: 70%; bottom: -7px; width: 10px; height: 10px; background: #fff; border-right: 2px solid #ffb3a7; border-bottom: 2px solid #ffb3a7; transform: translateX(-50%) rotate(45deg); }
.meadow-mailbox[hidden] { display: none; }
.meadow-mailbox.is-quiet .mail-badge, .meadow-mailbox.is-quiet .mail-bubble { display: none; }
.meadow-mailbox.is-quiet img { filter: drop-shadow(0 4px 4px rgba(60,40,20,.2)) saturate(.6); }
.meadow-chars { position: absolute; inset: 0; pointer-events: none; }
.meadow-actor { position: absolute; bottom: 9%; left: 30%; width: 34%; }
.meadow-actor img { position: relative; width: 100%; height: auto; display: block; transform-origin: 50% 100%; animation: meadow-bob 3.4s ease-in-out infinite; }
.meadow-shadow {
  position: absolute; left: 10%; right: 10%; bottom: -2%; height: 9%;
  background: radial-gradient(ellipse at center, rgba(60,95,40,.30) 0%, rgba(60,95,40,0) 70%);
}
.meadow-chick { left: 6%; bottom: 8%; width: 17%; }
.meadow-chick img { animation: meadow-hop 2.8s ease-in-out infinite; }
@keyframes meadow-bob { 0%,100% { transform: translateY(0) scaleY(1);} 50% { transform: translateY(-5px) scaleY(1.02);} }
@keyframes meadow-hop { 0%,100% { transform: translateY(0) rotate(-2deg);} 40% { transform: translateY(-9px) rotate(3deg);} 60% { transform: translateY(-6px) rotate(3deg);} }

/* ---- 하단 액션 카드 */
.home-actions { flex: none; display: flex; flex-direction: column; gap: 6px; }
.home-card-row { display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.home-card {
  position: relative;
  background: var(--paper) url("assets/paper_tile.webp") center / 384px 384px;
  border: 3px solid var(--line-strong);
  box-shadow: 0 4px 0 var(--line-strong);
  border-radius: var(--radius-md);
  min-height: 86px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.12rem;
  line-height: 1.15;
  letter-spacing: -.01em;
  box-shadow: 0 6px 0 var(--line-strong);
  text-align: left;
}
.home-card:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--line-strong); }
.home-card-primary { background: var(--sun); border-color: var(--sun-deep); box-shadow: 0 6px 0 var(--sun-deep); color: #4a3628; }
.home-card-primary:active { box-shadow: 0 3px 0 var(--sun-deep); }
.home-card-emoji { flex: none; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; }
.home-card-emoji img { max-width: 42px; max-height: 42px; width: auto; height: auto; object-fit: contain; }
.home-card-primary .home-card-emoji img { max-width: 44px; }
.home-card-label { white-space: nowrap; }
/* 폰 폭(≤ 460px)에서는 보조 카드 두 개를 아이콘 위 / 글자 아래로 쌓아 세 카드가 한 줄에 들어가게 한다 */
@media (max-width: 460px) {
  .home-card-row { gap: 8px; grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr) minmax(0, 1fr); }
  .home-card { font-size: 1.02rem; padding: 6px 4px; }
  .home-card-primary { gap: 4px; padding: 6px 2px; }
  .home-card:not(.home-card-primary) { flex-direction: column; gap: 3px; text-align: center; }
  .home-card:not(.home-card-primary) .home-card-emoji { width: 36px; height: 36px; }
  .home-card:not(.home-card-primary) .home-card-emoji img { max-width: 36px; max-height: 36px; }
  .home-card-primary .home-card-emoji { width: 38px; height: 38px; }
  .home-card-primary .home-card-emoji img { max-width: 38px; max-height: 38px; }
}
.badge {
  position: absolute; top: -10px; right: -8px;
  background: #ff7a45; color: #fff;
  border-radius: 999px; min-width: 32px; height: 32px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.05rem;
  border: 3px solid var(--cream);
  box-shadow: 0 3px 8px rgba(0,0,0,.18);
  animation: badge-pop .5s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes badge-pop { from { transform: scale(0);} to { transform: scale(1);} }
.home-intro-link {
  align-self: center;
  background: transparent; border: none;
  color: var(--ink-soft); font-size: .9rem; font-weight: 700;
  min-height: 40px; padding: 0 12px; border-radius: 999px;
}
.home-intro-link:active { background: var(--paper); }

/* ================================================================== CHAT */
.screen-chat { height: 100dvh; overflow: hidden; padding-bottom: 0; }
/* 단톡방 상단바: 뒤로가기가 있어도 제목이 정확히 가운데 오도록 3단 그리드로 */
.chat-topbar { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 10px; margin-bottom: 10px; flex: none; }
.chat-topbar .chat-title { grid-column: 2; justify-self: center; }
.chat-title { 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; display: inline-block; }
.chat-lines { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 20px; }
.chat-cta-wrap { flex: none; padding: 12px 0 max(16px, env(safe-area-inset-bottom)); }

.bubble-row { display: flex; gap: 8px; align-items: flex-end; animation: bubble-pop .3s ease both; max-width: 92%; }
@keyframes bubble-pop { from { opacity: 0; transform: translateY(10px) scale(.95);} to { opacity: 1; transform: none;} }
.bubble-row.is-partner, .bubble-row.is-player { align-self: flex-end; flex-direction: row-reverse; }
.bubble-avatar {
  width: 48px; height: 48px; min-width: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #fff;
  background: radial-gradient(circle at 50% 30%, #fff 0%, color-mix(in srgb, var(--chip-color, #eadfce) 22%, #fff) 100%);
  border: 2.5px solid var(--chip-color, var(--line));
}
.bubble-avatar .avatar-img { width: 86%; height: 86%; margin-top: 2px; }
.bubble-avatar .avatar-emoji { font-size: 1.55rem; }
.bubble-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bubble-name { font-size: .8rem; font-weight: 700; color: var(--ink-soft); padding: 0 8px; }
.bubble-row.is-partner .bubble-name, .bubble-row.is-player .bubble-name { text-align: right; }
.bubble {
  background: var(--paper);
  border-radius: 20px;
  border: 2px solid var(--line);
  padding: 10px 14px;
  font-size: 1.1rem;
  line-height: 1.55;
  position: relative;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px var(--shadow);
}
.bubble-row:not(.is-partner):not(.is-player) .bubble { border-bottom-left-radius: 6px; }
.bubble-row.is-partner .bubble, .bubble-row.is-player .bubble { border-color: var(--sky-deep); background: var(--hint-bg); border-bottom-right-radius: 6px; }
.bubble-emote { font-size: 1rem; }
.bubble-emote:empty { display: none; }
.bubble-replay { border: none; background: transparent; font-size: 1.1rem; padding: 4px; min-height: auto; min-width: 32px; border-radius: 8px; }
.bubble-replay:active { transform: scale(.85); }
.bubble-caption { align-self: center; color: var(--ink-soft); font-size: .88rem; font-style: italic; margin: 4px 0; text-align: center; padding: 0 12px; }

/* ================================================================= STAGE */
.screen-stage {
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
  gap: 6px;
}
.stage-topbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; }
.stage-location { font-family: var(--font-display); font-size: 1.2rem; flex: 1; text-align: center; }
.stage-deco { font-size: 1.5rem; width: 52px; text-align: center; }

.stage-hint {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  background: var(--note-bg); border: 2px solid var(--note-border); border-radius: 16px;
  padding: 8px 8px 8px 12px; font-size: .95rem; line-height: 1.4;
}
.stage-hint span { flex: 1; min-width: 0; cursor: pointer; }
.stage-hint.is-collapsed span {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;
}

.stage-floor {
  position: relative;
  flex: 1 1 auto;
  min-height: 30dvh;
  border-radius: var(--radius-lg);
  border: 3px solid var(--line);
  overflow: hidden;
  background: linear-gradient(180deg, #b9e2fa 0%, #e5f5ff 45%, #d6efc4 46%, #b9df9d 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.5);
}
.stage-floor::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.6) 1.4px, transparent 1.4px);
  background-size: 20px 20px;
  opacity: .35;
  pointer-events: none;
}
.stage-floor[data-loc="chat"] { background: #f9efe6 url("assets/bg_chat.jpg") center / cover no-repeat; }
.stage-floor[data-loc="playground"] { background: #cfe9c0 url("assets/bg_v2/playground.jpg") center 70% / cover no-repeat; }
.stage-floor[data-loc="lobby"] { background: #f2d9b6 url("assets/bg_v2/lobby.jpg") center 70% / cover no-repeat; }
.stage-floor[data-loc="rooftop"] { background: #2b2f63 url("assets/bg_v2/rooftop.jpg") center 70% / cover no-repeat; color: #fff; }
.stage-floor[data-loc="playground"]::before, .stage-floor[data-loc="lobby"]::before, .stage-floor[data-loc="rooftop"]::before, .stage-floor[data-loc="chat"]::before { display: none; }

.stage-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stage-fx .speech-float, .stage-fx .stage-timer, .stage-fx .stage-battery { pointer-events: auto; }

.char-chip {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  touch-action: none;
  cursor: grab;
  user-select: none; -webkit-user-select: none;
  transition: left .35s ease, top .35s ease;
  z-index: 2;
  translate: -50% -50%;
}
.char-chip.is-dragging { transition: none; cursor: grabbing; z-index: 20; }
.char-chip-avatar {
  /* 동그라미 없이 캐릭터 그림 그대로(투명 배경), 크게. 바닥 그림자로 서 있는 느낌 */
  position: relative;
  width: 112px; height: 112px;
  overflow: visible;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 2.6rem;
  animation: gentle-float 4.5s ease-in-out infinite;
}
.char-chip-avatar::before {
  content: ""; position: absolute; left: 50%; bottom: -4px; width: 62%; height: 14px; border-radius: 50%;
  background: rgba(60, 40, 20, .22); filter: blur(3px); transform: translateX(-50%);
}
.char-chip-avatar .char-chip-img {
  position: relative; width: 100%; height: 100%; object-fit: contain; object-position: center bottom;
  border-radius: 0; margin: 0;
  filter: drop-shadow(0 4px 6px rgba(60, 40, 20, .28));
}
.char-chip-avatar .avatar-emoji { font-size: 2rem; }
@keyframes gentle-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.char-chip.is-dragging .char-chip-avatar { animation: none; transform: scale(1.06); }
.char-chip-name { font-size: .8rem; font-weight: 800; background: var(--paper); padding: 2px 9px; border-radius: 999px; box-shadow: 0 2px 6px var(--shadow); white-space: nowrap; }
.char-chip-emote { position: absolute; top: -8px; right: -6px; font-size: 1.15rem; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.char-chip-emote:empty { display: none; }
.char-chip.emote-pulse .char-chip-avatar { animation: emote-pulse .5s ease; }
@keyframes emote-pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.22);} }

.speech-float {
  position: absolute;
  /* 칩(.char-chip)이 중심 기준으로 놓이므로, 말풍선은 칩 중심에서 아바타 반지름 + 여백만큼 위에 띄운다.
     (bubble-pop 애니메이션이 transform 을 덮어쓰므로 독립 속성인 translate 를 쓴다) */
  translate: -50% calc(-100% - 70px);
  background: #fffef9;
  border: 2px solid var(--sky-deep);
  border-radius: 18px;
  padding: 8px 10px;
  font-size: .95rem;
  line-height: 1.4;
  max-width: min(250px, 74vw);
  width: max-content;
  box-shadow: 0 6px 14px var(--shadow);
  z-index: 10;
  animation: bubble-pop .25s ease both;
  display: flex; gap: 8px; align-items: flex-start;
}
.speech-float::after {
  content: ""; position: absolute; left: clamp(14px, calc(50% + var(--tail-dx, 0px)), calc(100% - 14px)); bottom: -9px; width: 14px; height: 14px;
  background: #fffef9; border-right: 2px solid var(--sky-deep); border-bottom: 2px solid var(--sky-deep);
  transform: translateX(-50%) rotate(45deg);
}
.speech-float.is-below { translate: -50% 48px; }
.speech-float.is-below::after { bottom: auto; top: -9px; border-right: none; border-bottom: none; border-left: 2px solid var(--sky-deep); border-top: 2px solid var(--sky-deep); }
.speech-avatar { flex: none; width: 40px; height: 40px; overflow: visible; display: flex; align-items: flex-end; justify-content: center; }
.speech-avatar .avatar-img { width: 100%; height: 100%; object-fit: contain; }
.speech-avatar .avatar-emoji { font-size: 1.1rem; }
.speech-body { flex: 1; min-width: 0; }
.speech-float.thinking-bubble { display: inline-flex; align-items: center; translate: -50% -100%; }
.thinking-dots { display: inline-flex; gap: 3px; margin-left: 4px; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft);
  animation: dot-bounce 1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce { 0%,80%,100% { transform: translateY(0); opacity:.5; } 40% { transform: translateY(-5px); opacity:1; } }

.stage-timer, .stage-battery {
  position: absolute; top: 10px; right: 10px;
  background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 800;
  box-shadow: 0 4px 8px var(--shadow); z-index: 5;
}
.stage-battery-bar { width: 80px; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.stage-battery-fill { height: 100%; background: #4c9a5f; }

/* 별비(SHOW_STARFALL)는 아래 "장면 배경 그림·영상 + 밤하늘" 의 .shoot 별똥별로 바뀌었다 (2026-10-11) */

.stage-objects {
  flex: none;
  display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px;
  scrollbar-width: none;
}
.stage-objects::-webkit-scrollbar { display: none; }
.stage-objects:empty { display: none; }
.object-chip {
  min-height: 60px; min-width: 72px;
  background: var(--paper); border: 2px solid var(--line-strong); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: .8rem; font-weight: 800; padding: 4px 10px; flex-shrink: 0;
  box-shadow: 0 3px 0 var(--line-strong);
}
.object-chip .oc-emoji { font-size: 1.5rem; }
.object-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }

.safety-panel {
  position: fixed; inset: 0; background: rgba(60,45,30,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; z-index: 100; text-align: center;
}
.safety-msg { background: var(--paper); padding: 16px 20px; border-radius: var(--radius-md); font-weight: 700; max-width: 320px; font-size: 1.05rem; }

.stage-footer { flex: none; padding: 4px 0 max(10px, env(safe-area-inset-bottom)); }
.stt-fallback-notice { text-align: center; background: var(--hint-bg); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 8px; font-size: .88rem; }
.text-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.text-input-row input { flex: 1; min-width: 0; min-height: var(--touch); border-radius: var(--radius-sm); border: 2px solid var(--line-strong); padding: 0 14px; background: var(--paper); color: var(--ink); }
.text-input-row .btn { padding: 0 16px; font-size: 1rem; }

.mic-row { display: flex; align-items: center; justify-content: center; gap: 14px; position: relative; }
.mic-live-text { position: absolute; bottom: 100%; margin-bottom: 6px; font-size: .88rem; color: var(--ink-soft); max-width: 80%; text-align: center; background: var(--paper); border-radius: 999px; padding: 2px 10px; }
.mic-live-text:empty { display: none; }
.mic-btn {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--coral); border: none; color: #fff;
  box-shadow: 0 8px 0 var(--coral-deep), 0 10px 18px var(--shadow);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.mic-btn .mic-icon { font-size: 2rem; }
.mic-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 var(--coral-deep); }
.mic-btn[aria-pressed="true"] { background: #e35d57; animation: mic-pulse 1.2s infinite; }
@keyframes mic-pulse { 0% { box-shadow: 0 8px 0 #b33330, 0 0 0 0 rgba(217,83,79,.5);} 70% { box-shadow: 0 8px 0 #b33330, 0 0 0 18px rgba(217,83,79,0);} 100% { box-shadow: 0 8px 0 #b33330, 0 0 0 0 rgba(217,83,79,0);} }
.mic-btn:disabled { opacity: .5; }

/* ---- 상황 설명 / 이야기 기록 / 프롬프트 바 (아이가 "지금 무슨 상황인지, 뭘 하면 되는지" 항상 볼 수 있게) */
.stage-caption {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: 90%;
  background: rgba(60,45,30,.86); color: #fff; border-radius: 12px; padding: 8px 14px; font-size: .95rem; line-height: 1.4;
  z-index: 3; animation: bubble-pop .3s ease both;
}
.stage-log {
  flex: 0 1 auto; min-height: 0;
  max-height: 16dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 10px; border-radius: 14px;
  background: var(--log-bg); border: 1.5px solid var(--line); font-size: .9rem; line-height: 1.5;
  display: flex; flex-direction: column; gap: 4px;
}
.stage-log:empty { display: none; }
.log-line { display: flex; gap: 6px; align-items: baseline; }
.log-line .log-who { font-weight: 800; white-space: nowrap; }
.log-line.is-narrator { color: var(--ink-soft); font-style: italic; }
.log-line.is-child { justify-content: flex-end; }
.log-line.is-child .log-text { background: var(--hint-bg); border-radius: 12px 12px 2px 12px; padding: 4px 10px; }
.log-line.is-partner .log-who { color: #2563eb; }
.stage-prompt {
  flex: none;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 18px;
  background: var(--hint-bg); border: 2px solid var(--hint-border); font-size: 1.02rem; font-weight: 700; line-height: 1.4;
}
.stage-prompt span:nth-child(2) { flex: 1; min-width: 0; }
.stage-prompt-avatar { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.stage-prompt-avatar img { width: 44px; height: 44px; object-fit: contain; }
.char-chip.is-player .char-chip-avatar::before { background: rgba(37, 99, 235, .45); width: 76%; height: 18px; }
.char-chip.is-player .char-chip-img { filter: drop-shadow(0 0 6px rgba(96,165,250,.9)) drop-shadow(0 4px 6px rgba(60,40,20,.28)); }
.char-chip.is-player .char-chip-name { color: #1d4ed8; }
.char-chip .char-chip-me {
  position: absolute; top: -10px; left: -6px; background: #2563eb; color: #fff; font-size: .72rem; font-weight: 800;
  border-radius: 999px; padding: 2px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.2); line-height: 1.3;
}

/* 어두운 장소(옥상 등)에서도 이름표/말풍선 글자는 항상 진한 색 (말풍선은 늘 밝은 종이색이므로 글자색을 고정) */
.char-chip-name { color: var(--ink, #2b2118) !important; }
.speech-float, .speech-float strong, .speech-float .speech-body { color: #2b2118 !important; }
.speech-float { background: #fffef9; }

/* ================================================================ ENDING */
.ending-card { background: #fff8ea url("assets/book_page.webp") center / cover no-repeat; text-align: center; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; padding: 18px 14px; }
.ending-emoji { position: relative; display: inline-block; animation: gentle-float 3s ease-in-out infinite; }
.ending-emoji img { height: 92px; width: auto; display: block; }
.ending-star { position: absolute; top: -6px; right: -18px; font-size: 1.8rem; animation: spark-twinkle 1.6s ease-in-out infinite; }
.reflection-box { display: flex; align-items: center; gap: 10px; background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: var(--radius-sm); padding: 10px 10px 10px 12px; margin: 12px 0; text-align: left; }
.reflection-avatar { flex: none; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; }
.reflection-avatar img { width: 42px; height: 42px; object-fit: contain; }
.reflection-box p { margin: 0; flex: 1; font-size: 1rem; line-height: 1.45; }
.ending-rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.reward-card {
  background: var(--sun); border-radius: var(--radius-sm); padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 78px;
  animation: reward-bounce .6s cubic-bezier(.34,1.56,.64,1) both;
  box-shadow: 0 4px 0 var(--sun-deep);
  color: #4a3628;
}
@keyframes reward-bounce { from { opacity: 0; transform: scale(.3) rotate(-8deg);} to { opacity: 1; transform: none;} }
.reward-emoji { font-size: 1.8rem; }
.reward-label { font-size: .74rem; font-weight: 800; text-align: center; }
.ending-relationships { display: flex; flex-wrap: wrap; gap: 10px 12px; justify-content: center; margin-bottom: 16px; }
.rel-chip { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .82rem; font-weight: 800; }
.rel-avatar { position: relative; width: 64px; height: 64px; display: flex; align-items: flex-end; justify-content: center; overflow: visible; }
.rel-avatar .avatar-img { width: 84%; height: 84%; margin-top: 2px; }
.rel-avatar .avatar-emoji { font-size: 1.7rem; }
.rel-avatar .rel-emoji { position: absolute; right: -8px; bottom: -6px; font-size: 1.15rem; background: var(--paper); border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px var(--shadow); }
.rel-up { animation: rel-pop .5s ease; }
.rel-up .rel-emoji { color: #4c9a5f; }
@keyframes rel-pop { 0% { transform: scale(1);} 50% { transform: scale(1.25);} 100% { transform: scale(1);} }

/* ============================================================ OVERLAYS (바텀시트) */
.overlay {
  position: fixed; inset: 0; background: rgba(60,45,30,.45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200; padding: 0;
  animation: overlay-in .2s ease both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.overlay-panel {
  position: relative;
  background: var(--paper) url("assets/paper_tile.webp") center / 384px 384px; width: 100%; max-width: 520px;
  border-radius: 28px 28px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  animation: sheet-up .34s cubic-bezier(.2,.8,.2,1) both;
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0;} to { transform: none; opacity: 1;} }
.sheet-handle { display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--line-strong); margin: 4px auto 6px; }
.overlay-header {
  position: sticky; top: -8px; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 10px; padding: 8px 0 8px;
  background: var(--paper);
}
.overlay-header h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; margin: 0; line-height: 1.1; }
.overlay-header .title-spark { font-style: normal; color: var(--sun); font-size: 1rem; vertical-align: super; margin-left: 2px; }
.overlay-panel-small, .overlay-panel-wide { max-width: 520px; }
@media (min-width: 560px) {
  .overlay { align-items: center; padding: 20px; }
  .overlay-panel { border-radius: var(--radius-lg); max-width: 480px; padding-top: 16px; }
  .overlay-panel-small { max-width: 360px; }
  .overlay-panel-wide { max-width: 520px; }
  .sheet-handle { display: none; }
}

.episode-list, .rewards-grid, .friends-grid, .history-list { display: flex; flex-direction: column; gap: 12px; }

/* ---- 에피소드 카드: 왼쪽 글, 오른쪽 파스텔 일러스트 박스 */
.episode-card {
  width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; align-items: center;
  text-align: left;
  background: #fff8ea; border: 2px solid #f0e2c6; border-radius: var(--radius-md);
  padding: 12px 10px 12px 14px; min-height: var(--touch);
  color: var(--ink);
  box-shadow: 0 4px 0 #efe1c4;
  transition: transform .12s ease, box-shadow .12s ease;
}
.episode-card:active { transform: translateY(2px); box-shadow: 0 2px 0 #efe1c4; }
.ep-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.episode-card .ep-tag { align-self: flex-start; font-size: .76rem; background: var(--sun); color: #4a3628; border-radius: 999px; padding: 4px 11px; font-weight: 800; }
.episode-card .ep-tag-again { background: var(--hint-border); }
.episode-card .ep-title { font-family: var(--font-display); font-weight: 400; font-size: 1.22rem; line-height: 1.2; letter-spacing: -.01em; }
.episode-card .ep-summary { color: var(--ink-soft); font-size: .86rem; line-height: 1.45; }
.episode-card .ep-hook { color: var(--ink); }
.ep-art {
  position: relative; width: 110px; height: 122px; border-radius: 18px; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
}
.ep-art .ep-art-img { width: 86%; height: 88%; object-fit: contain; object-position: center bottom; margin-bottom: 4px; position: relative; z-index: 1; }
.ep-art .avatar-emoji { font-size: 3rem; margin-bottom: 18px; }
.ep-art-sun { background: radial-gradient(circle at 50% 28%, #fffbe6 0%, #ffefb8 100%); }
.ep-art-pink { background: radial-gradient(circle at 50% 30%, #ffedf2 0%, #ffd3de 100%); }
.ep-art-night { background: radial-gradient(circle at 50% 38%, #3b4ea6 0%, #1f2a63 100%); }
.ep-art-cream { background: radial-gradient(circle at 50% 30%, #fff7ea 0%, #f3e6cf 100%); }
.ep-art::before { /* 캐릭터 발밑 풀/바닥 */
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 6px; height: 14px; border-radius: 50%;
  background: rgba(124,185,96,.55);
}
.ep-art-night::before { background: rgba(140,200,120,.55); }
.ep-mark { position: absolute; top: 6px; left: 10px; font-style: normal; font-weight: 900; font-size: 1.35rem; line-height: 1; transform: rotate(14deg); z-index: 2; letter-spacing: -.05em; }
.ep-mark-blue { color: #3b82f6; transform: rotate(-12deg); }
.ep-mark-red { color: #ef4444; left: auto; right: 12px; }
.ep-blocks { position: absolute; right: 7px; bottom: 9px; z-index: 2; display: grid; grid-template-columns: repeat(3, 12px); gap: 2px; }
.ep-blocks b { display: block; width: 12px; height: 12px; border-radius: 3px; background: #60a5fa; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.ep-blocks b:nth-child(2) { background: #f97316; } .ep-blocks b:nth-child(3) { background: #22c55e; }
.ep-blocks b:nth-child(4) { background: #facc15; } .ep-blocks b:nth-child(5) { background: #ef4444; }
.ep-star { position: absolute; font-style: normal; color: #ffe066; line-height: 1; animation: spark-twinkle 2.2s ease-in-out infinite; z-index: 0; }
.ep-star-a { top: 8px; left: 12px; font-size: 1.1rem; }
.ep-star-b { top: 18px; right: 14px; font-size: .8rem; animation-delay: .5s; }
.ep-star-c { top: 38px; left: 40%; font-size: .7rem; animation-delay: 1s; }
.ep-star-d { top: 46px; right: 8px; font-size: .95rem; animation-delay: 1.5s; }
.ep-scope { position: absolute; left: 6px; bottom: 6px; font-style: normal; font-size: 1.6rem; z-index: 2; line-height: 1; }

.rewards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px,1fr)); gap: 12px; }

.friends-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.friend-card { background: #fff8ea; border: 2px solid #f0e2c6; border-radius: var(--radius-md); padding: 14px 10px; text-align: center; color: var(--ink); }
.friend-card .friend-emoji {
  width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; overflow: hidden;
  background: #fff;
  background: radial-gradient(circle at 50% 30%, #fff 0%, color-mix(in srgb, var(--chip-color, #eadfce) 24%, #fff) 100%);
  border: 3px solid var(--chip-color, var(--line-strong));
  display: flex; align-items: center; justify-content: center;
}
.friend-card .friend-emoji .avatar-img { width: 86%; height: 86%; margin-top: 3px; }
.friend-card .friend-emoji .avatar-emoji { font-size: 2.2rem; }
.friend-card .friend-name { font-family: var(--font-display); font-size: 1.15rem; margin: 8px 0 4px; }
.friend-hearts { font-size: .9rem; color: var(--ink-soft); }

.history-card { background: #fff8ea; border: 2px solid #f0e2c6; border-radius: var(--radius-md); padding: 12px 14px; color: var(--ink); }
.history-card .h-title { font-weight: 800; }
.history-card .h-meta { color: var(--ink-soft); font-size: .84rem; margin: 2px 0 6px; }
.history-card .h-strats { display: flex; flex-wrap: wrap; gap: 6px; }
.h-strat-tag { background: var(--hint-bg); border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 700; }

.tab-row { display: flex; gap: 6px; margin-bottom: 14px; }
.tab-btn { flex: 1; min-height: 46px; border: none; border-radius: 999px; background: var(--cream); font-weight: 700; font-size: .9rem; }
.tab-btn.is-active { background: var(--sky-deep); color: #fff; }
.tab-panel { display: flex; flex-direction: column; gap: 14px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .98rem; min-height: 48px; }
.switch-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--coral); flex: none; }
.radio-row { display: flex; align-items: center; gap: 8px; font-size: .95rem; min-height: 44px; font-weight: 500; }
.radio-row input { width: 24px; height: 24px; accent-color: var(--coral); }
.pin-input { min-height: var(--touch); border-radius: var(--radius-sm); border: 2px solid var(--line-strong); padding: 0 14px; text-align: center; letter-spacing: 8px; font-size: 1.3rem; background: var(--paper); color: var(--ink); width: 100%; }

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 999px;
  font-size: .95rem; font-weight: 600; z-index: 300; box-shadow: 0 6px 16px var(--shadow-strong);
  max-width: 86%; text-align: center;
}

.loading-veil {
  position: fixed; inset: 0; background: rgba(255,244,221,.6);
  display: flex; align-items: center; justify-content: center; z-index: 400;
}
.loading-spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 6px solid var(--peach); border-top-color: var(--coral);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ TITLE / INTRO */
.screen-title-bg { background: linear-gradient(180deg, #d9edff 0%, #fff6dd 55%, #dff5d6 100%); }
.title-wrap { text-align: center; max-width: 520px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-chars { display: flex; gap: 6px; align-items: flex-end; justify-content: center; }
.title-char { height: 72px; width: auto; animation: gentle-float 3s ease-in-out infinite; }
.title-char.big { height: 92px; margin: 0 4px; }
.title-char-emoji { display: inline-flex; align-items: center; justify-content: center; width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 3px solid var(--c-kongi); font-size: 2rem; margin-bottom: 6px; }
.title-chars > :nth-child(2) { animation-delay: .4s; } .title-chars > :nth-child(3) { animation-delay: .8s; }
.title-chars > :nth-child(4) { animation-delay: 1.2s; } .title-chars > :nth-child(5) { animation-delay: 1.6s; }
.title-logo { font-family: var(--font-display); font-weight: 400; font-size: 3rem; line-height: 1.02; margin: 0; color: #c2410c; letter-spacing: -.02em; text-shadow: 0 3px 0 #fff; }
.title-logo span { display: block; font-size: 1.7rem; color: var(--ink); margin-top: 6px; text-shadow: none; }
.title-tagline { font-size: 1.05rem; line-height: 1.55; color: var(--ink); margin: 0; }
.title-points { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.title-points span { background: #fff; border: 2px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .95rem; }

.intro-card { max-width: 520px; width: 100%; background: var(--paper); border: 3px solid var(--line); border-radius: var(--radius-lg); padding: 26px 20px; text-align: center; box-shadow: 0 12px 30px var(--shadow); display: flex; flex-direction: column; gap: 18px; align-items: center; }
.intro-visual { font-size: 3rem; min-height: 132px; display: flex; gap: 10px; align-items: flex-end; justify-content: center; animation: bubble-pop .35s ease both; flex-wrap: wrap; }
.intro-char { height: 128px; width: auto; }
.intro-emoji { font-size: 2.6rem; line-height: 1; padding-bottom: 12px; }
.intro-visual .who { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.intro-visual .who .avatar-img { width: 66px; height: 66px; }
.intro-visual .who .avatar-emoji { width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 3px solid var(--c-kongi); font-size: 2rem; }
.intro-visual .who small { font-size: .82rem; font-weight: 800; color: var(--ink); letter-spacing: 0; }
.intro-text { font-size: 1.22rem; line-height: 1.6; font-weight: 700; margin: 0; min-height: 3.2em; }
.intro-dots { display: flex; gap: 6px; }
.intro-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); transition: background .2s, transform .2s; }
.intro-dots i.on { background: #f97316; transform: scale(1.25); }
.intro-actions { display: flex; gap: 10px; width: 100%; justify-content: center; }
.intro-actions .btn { white-space: nowrap; }
.intro-actions .btn-big { flex: 1; }

/* ------------------------------------------------------------ small phone */
@media (max-width: 380px) {
  :root { --gutter: 12px; }
  .home-card { font-size: 1.02rem; min-height: 80px; gap: 6px; }
  .home-card-emoji { width: 36px; height: 36px; }
  .home-card-emoji img, .home-card-primary .home-card-emoji img { max-width: 36px; max-height: 36px; }
  .home-hint { font-size: .96rem; padding-right: 26px; }
  .episode-card { grid-template-columns: minmax(0, 1fr) 96px; padding-left: 12px; }
  .ep-art { width: 96px; height: 110px; }
  .mic-btn { width: 68px; height: 68px; }
  .stage-floor { min-height: 28dvh; }
}
/* 세로가 짧은 폰(≤ 700px): 무대/기록 높이를 조금 줄인다 */
@media (max-height: 800px) {
  .stage-hint span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .stage-log { max-height: 14dvh; }
  .stage-prompt { font-size: .98rem; padding: 6px 6px 6px 8px; }
  .stage-prompt-avatar, .stage-prompt-avatar img { width: 38px; height: 38px; }
}
@media (max-height: 700px) {
  .stage-floor { min-height: 26dvh; }
  .stage-log { max-height: 14dvh; }
  .stage-hint { font-size: .9rem; }
  .mic-btn { width: 64px; height: 64px; }
  .mic-btn .mic-icon { font-size: 1.7rem; }
  .home-card { min-height: 76px; }
}

/* ---------------------------------------------------------- tablet/desktop */
@media (min-width: 768px) {
  .home-card { font-size: 1.18rem; }
  .title-char { height: 84px; }
  .title-char.big { height: 108px; }
}

/* --------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* hidden 속성은 클래스의 display 값보다 항상 우선한다 (화면/오버레이 전환은 el.hidden 으로 제어) */
[hidden] { display: none !important; }

.chat-cta-wrap { padding-bottom: max(14px, env(safe-area-inset-bottom)); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; line-height: 1.4; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.field select { font-size: 16px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; }


/* ---- v0.2 모범 시연 / 교육 포인트 / 회고 / 리포트 */
.demo-banner { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; background: #e8f1ff; border: 2px solid #bfdbfe; border-radius: 14px; padding: 8px 12px; font-weight: 800; }
.demo-banner img { width: 36px; height: 36px; object-fit: contain; }
.demo-banner span { flex: 1; }
.demo-controls { display: flex; gap: 6px; align-items: center; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.stage-floor.demo-mode .char-chip { transition: left .7s ease, top .7s ease; }
.stage-floor.demo-mode .char-chip.is-player .char-chip-avatar { box-shadow: 0 0 0 4px #fbbf24, 0 6px 14px rgba(245,158,11,.35); }
.stage-floor.demo-mode .char-chip .char-chip-me { display: none; }
.stage-skills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.stage-skills span { background: #fff7e0; border: 2px solid #f3d98b; border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-weight: 800; }
.teaching-panel { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.teaching-kicker { margin: 0; font-weight: 800; color: #2563eb; }
.teaching-card { width: 100%; background: #fff7e0; border: 2px solid #f3d98b; border-radius: 20px; padding: 22px 16px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; animation: bubble-pop .3s ease both; }
.teaching-emoji { font-size: 3rem; }
.teaching-card h2 { margin: 0; font-size: 1.5rem; }
.teaching-card p { margin: 0; font-size: 1.1rem; line-height: 1.5; }
.ending-learned { width: 100%; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px 14px; }
.ending-learned h3 { margin: 6px 0; font-size: 1rem; color: #2563eb; }
.learned-points { display: flex; flex-direction: column; gap: 6px; }
.learned-point { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: #f8fafc; border: 1.5px solid var(--line); }
.learned-point.applied { background: #ecfdf5; border-color: #86efac; }
.learned-point .lp-mark { font-weight: 900; width: 22px; text-align: center; }
.learned-point .lp-title { font-weight: 800; }
.learned-text { margin: 6px 0 0; font-size: 1rem; line-height: 1.5; }
.learned-text.next { background: #e8f1ff; border-radius: 12px; padding: 8px 10px; }
.reward-card.skill { background: #ecfdf5; border-color: #86efac; }
.notify-box { background: #e8f1ff; border: 2px solid #bfdbfe; border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.notify-title { font-weight: 800; margin-bottom: 6px; }
.notify-options { display: flex; flex-direction: column; gap: 6px; }
.notify-options label { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.notify-options input { width: 20px; height: 20px; }
.report-body { max-height: 70dvh; overflow: auto; background: #fff; border-radius: 12px; padding: 4px 8px; }
.h-actions { margin-top: 6px; display: flex; gap: 6px; }

.forgot-methods { display: flex; flex-direction: column; gap: 6px; }
.forgot-methods label { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.forgot-methods input { width: 20px; height: 20px; }
.tab-btn { white-space: nowrap; }

/* 서버 연결 실패 안내 (시작 화면) */
.server-down { margin-top: 12px; padding: 14px; border-radius: 16px; background: #fff3f0; border: 2px solid #f2b3a6; color: var(--ink); text-align: center; word-break: keep-all; }
.server-down p { margin: 0 0 10px; line-height: 1.5; }
.server-down-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* 장면 물건(단서): 그림이 있으면 이모지 대신 그림 */
.object-chip .oc-img { width: 44px; height: 44px; object-fit: contain; display: block; filter: drop-shadow(0 2px 2px rgba(60,40,20,.25)); }

/* 그림 아이콘 버튼·보상 그림 */
.icon-img-btn img { width: 78%; height: 78%; object-fit: contain; display: block; margin: auto; }
.reward-emoji.has-art img { width: 58px; height: 58px; object-fit: contain; display: block; }
.title-hero { width: 100%; max-width: 380px; max-height: 44vh; object-fit: cover; object-position: center 30%; border-radius: 22px; border: 3px solid #fff; box-shadow: 0 8px 20px rgba(0,0,0,.12); margin: 0 auto 6px; display: block; }
.intro-image { width: 100%; max-width: 300px; max-height: 40vh; object-fit: cover; object-position: center 20%; border-radius: 20px; border: 3px solid #fff; box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.server-waking { margin-top: 12px; text-align: center; color: var(--ink-soft); font-weight: 700; animation: bubble-pop .3s ease both; }

/* ── 무대 배경 3레이어(하늘·중경·전경) + 패럴랙스 + 파티클 ── */
.stage-backdrop { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; --px: 0; --py: 0; }
/* 배경 3레이어(3:2 가로 그림)를 세로로 긴 무대에 맞추는 법:
   하늘은 무대 전체를 덮고(cover), 중경·전경은 폭에 맞춰 원래 비율로 바닥에 붙인다(잘리거나 흐려지지 않게).
   중경 위쪽은 하늘로 스르르 섞이도록 마스크. z: 하늘 0 → 중경 1 → 전경 2 */
.stage-backdrop img.bd-sky {
  position: absolute; left: -6%; top: -6%; width: 112%; max-width: none; height: 112%; object-fit: cover; object-position: center top; display: block; z-index: 0;
  transform: translate(calc(var(--px) * -3px), calc(var(--py) * -2px)); transition: transform .25s ease-out;
}
.stage-backdrop img.bd-mid, .stage-backdrop img.bd-front {
  position: absolute; left: -6%; bottom: -3%; width: 112%; max-width: none; height: auto; display: block;
  transition: transform .25s ease-out;
}
.stage-backdrop img.bd-mid {
  z-index: 1; transform: translate(calc(var(--px) * -8px), calc(var(--py) * -4px));
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 30%); mask-image: linear-gradient(to bottom, transparent 0%, #000 30%);
}
.stage-backdrop img.bd-front { z-index: 2; transform: translate(calc(var(--px) * -16px), calc(var(--py) * -8px)); }
.stage-backdrop .bd-particles { z-index: 3; }
.stage-backdrop[data-tod="evening"]::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(255,150,90,.18), rgba(255,200,120,.06)); }
.stage-backdrop[data-tod="night"]::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(30,30,80,.28), rgba(30,30,80,.08)); }
.stage-floor > :not(.stage-backdrop):not(.char-chip) { position: relative; z-index: 1; }  /* 칩은 absolute 유지 */
.stage-floor[data-loc] .stage-backdrop + * { z-index: 1; }
.bd-particles { position: absolute; inset: 0; }
.bd-particle { position: absolute; top: -12%; width: 34px; height: 34px; opacity: .85; transform: scale(var(--s, .7));
  animation: bd-fall var(--d, 8s) linear var(--delay, 0s) infinite; }
.bd-particle.bd-firefly { animation: bd-float var(--d, 8s) ease-in-out var(--delay, 0s) infinite; top: auto; bottom: 10%; }
@keyframes bd-fall { 0% { transform: translate(0, 0) rotate(0) scale(var(--s, .7)); } 50% { transform: translate(24px, 60vh) rotate(180deg) scale(var(--s, .7)); } 100% { transform: translate(-10px, 120vh) rotate(360deg) scale(var(--s, .7)); opacity: .2; } }
@keyframes bd-float { 0%,100% { transform: translate(0, 0) scale(var(--s, .7)); opacity: .3; } 50% { transform: translate(18px, -60px) scale(var(--s, .7)); opacity: .95; } }
/* 표정 배지 그림 */
.char-chip-emote img { width: 28px; height: 28px; display: block; }
/* 장면 전환 아이리스: 가운데 투명한 원이 커지며 크림색 막이 걷힌다 (box-shadow 로 바깥을 덮는다) */
#iris-veil { position: fixed; left: 50%; top: 50%; width: 0; height: 0; border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 200vmax #fff7e6, inset 0 0 40px 20px #fff7e6; z-index: 999; pointer-events: none; opacity: 0; }
#iris-veil.open { animation: iris-open .85s cubic-bezier(.4,0,.2,1) both; }
@keyframes iris-open { 0% { width: 0; height: 0; opacity: 1; } 80% { opacity: 1; } 100% { width: 320vmax; height: 320vmax; opacity: 0; } }
/* 새 배경 한 장(bg_v2): 무대를 꽉 채우고(cover) 바닥이 보이게 아래쪽을 남긴다. 하늘·전경 레이어·마스크는 끈다 */
.stage-backdrop.bd-v2 img.bd-sky, .stage-backdrop.bd-v2 img.bd-front { display: none; }
.stage-backdrop.bd-v2 img.bd-mid {
  left: -2%; top: -2%; bottom: auto; width: 104%; height: 104%; object-fit: cover; object-position: center 70%;
  -webkit-mask-image: none; mask-image: none; transform: translate(calc(var(--px) * -6px), calc(var(--py) * -3px));
}
.stage-backdrop.bd-v2[data-loc="rooftop"]::after { content: none; }   /* 옥상 그림은 이미 밤 — 밤 색조를 또 얹지 않는다 */
@media (prefers-reduced-motion: reduce) { .bd-particle, #iris-veil.open { animation: none; display: none; } .stage-backdrop img { transition: none; } }


/* ── 폰트 고도화 ── */
html.big-text { font-size: 112%; }               /* 보호자 설정 "글자 크게 보기" */
.sticker-name, .speech-float, .home-intro-link, .coach p, .growth-next, .card-memo { font-family: var(--font-hand); }
.speech-float { font-size: 1.15rem; }
strong, b { font-weight: 700; }
.btn { font-size: 1.05rem; }
.stt-fallback-notice, .mic-live-text { font-family: var(--font-body); }

/* ── 인앱 브라우저 안내 (inapp.js) — 보호자에게 Chrome/Safari 로 열어 달라고 부탁한다 ── */
.inapp-guide {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--cream) url("assets/paper_tile.webp") center / 384px 384px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  color: var(--ink); font-family: var(--font-body);
}
.inapp-card {
  width: 100%; max-width: 440px; margin: auto 0;
  background: var(--paper); border-radius: var(--radius-lg); border: 3px solid var(--line-strong);
  box-shadow: 0 5px 0 var(--line-strong), 0 12px 24px var(--shadow);
  padding: 22px 18px 16px; display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.inapp-pip { width: 72px; height: 72px; object-fit: contain; align-self: center; }
.inapp-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; line-height: 1.3; word-break: keep-all; }
.inapp-lead { margin: 0; font-size: 1rem; line-height: 1.55; word-break: keep-all; }
.inapp-steps {
  margin: 0; padding: 12px 14px 12px 34px; text-align: left;
  background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: 16px;
  font-size: .98rem; line-height: 1.5; word-break: keep-all;
  display: flex; flex-direction: column; gap: 6px;
}
.inapp-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px;
  background: var(--paper); border: 2px solid var(--line-strong); font-size: 1.1rem; line-height: 1;
}
.inapp-url {
  padding: 10px 12px; border-radius: 12px; border: 2px dashed var(--line-strong); background: #fff;
  font-size: .85rem; color: var(--ink-soft); word-break: break-all; text-align: left;
  -webkit-user-select: all; user-select: all;
}
.inapp-actions { display: flex; flex-direction: column; gap: 10px; }
.inapp-reopen {
  width: 100%; background: var(--paper); color: var(--ink);
  border: 3px solid var(--line-strong); box-shadow: 0 4px 0 var(--line-strong);
}
.inapp-msg { margin: 0; min-height: 1.4em; font-size: .92rem; font-weight: 700; color: var(--ink); }
.inapp-msg:empty { display: none; }
.inapp-skip {
  align-self: center; min-height: 44px; padding: 0 14px;
  background: transparent; border: none; color: var(--ink-soft);
  font-size: .9rem; text-decoration: underline;
}

/* ======================================================= v0.3 단계 연습 · 새 상황 (guided_practice) */
/* 연습 중에는 연습 카드가 아래쪽 시트로 열리고 무대(장면·친구 표정)는 위에 그대로 보인다 (제안서 01 §1-2).
   마이크 줄과 확인 시트(stage-footer)는 그대로. 아래 phase 1b 블록이 시트 배치를 맡는다 */
.screen-stage.is-practicing .stage-objects,
.screen-stage.is-practicing .stage-log,
.screen-stage.is-practicing .stage-prompt,
.screen-stage.is-practicing .stage-hint,
.screen-stage.is-practicing .stage-examples,
.screen-stage.is-practicing .stage-skills { display: none; }   /* 위쪽 단계 칩도: 패널 안에 같은 칩이 있다 */
.practice-panel {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--paper); border: 3px solid var(--line); border-radius: var(--radius-lg);
  padding: 12px 12px 14px; box-shadow: 0 6px 18px var(--shadow);
  animation: bubble-pop .25s ease both;
}
.practice-top { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.practice-step-chip {
  font-family: var(--font-display); font-size: 1.05rem; color: var(--ink);
  background: #fff7e0; border: 2px solid #f3d98b; border-radius: 999px; padding: 4px 14px;
}
.practice-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.practice-steps li {
  font-size: .8rem; font-weight: 800; color: var(--ink-soft);
  border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 10px;
}
.practice-steps li.done { background: #ecfdf5; border-color: #86efac; color: #166534; }
.practice-steps li.on { background: var(--sun); border-color: var(--sun-deep); color: var(--ink); }
.practice-body { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
.practice-card {
  background: #fff7e0; border: 2px solid #f3d98b; border-radius: 20px; padding: 18px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.practice-card h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; }
.practice-card p { margin: 0; font-size: 1.15rem; line-height: 1.5; word-break: keep-all; }
.practice-kicker { margin: 0; font-weight: 800; color: #2563eb; text-align: center; }
.practice-bubble {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: 20px;
  padding: 10px 12px; font-size: 1.15rem; line-height: 1.45; word-break: keep-all;
}
.practice-bubble .pb-text { flex: 1; min-width: 0; font-weight: 700; }
.practice-bubble .pb-avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.practice-bubble .pb-avatar .avatar-img { width: 40px; height: 40px; object-fit: contain; }
.practice-bubble .pb-who { flex: none; font-size: .8rem; font-weight: 800; color: var(--ink-soft); background: #fff; border-radius: 999px; padding: 2px 8px; }
.practice-bubble .pb-replay { font-size: 1.3rem; flex: none; }
.practice-bubble.is-lead { font-size: 1.35rem; border-color: var(--sky-deep); }
.practice-bubble.is-child { background: #fff; border-color: var(--line-strong); align-self: flex-end; }
.practice-bubble.is-praise { background: #ecfdf5; border-color: #86efac; font-size: 1.3rem; }
/* 말풍선 버튼: 손가락 하나로 누르기 쉽게 (--touch 56px 이상) */
.practice-lead, .practice-choice {
  display: block; width: 100%; min-height: var(--touch); padding: 0; border: none; background: transparent;
  border-radius: 20px; cursor: pointer; color: inherit; font: inherit;
}
.practice-lead:active, .practice-choice:active { transform: scale(.98); }
.practice-choices { display: flex; flex-direction: column; gap: 10px; }
.practice-choice .practice-bubble { background: #fff; border-color: var(--line-strong); min-height: 60px; padding: 6px 12px; }
.practice-choice[aria-pressed="true"] .practice-bubble { background: #fff7e0; border-color: var(--sun-deep); box-shadow: 0 0 0 3px var(--sun); }
.practice-lead:focus-visible, .practice-choice:focus-visible, .stage-chip:focus-visible, .example-bubble:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 3px; }
.practice-praise { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.practice-go { margin: 0; text-align: center; font-family: var(--font-display); font-size: 1.2rem; }
.practice-guide { margin: 0; text-align: center; font-weight: 800; color: var(--ink); min-height: 1.2em; }
.practice-guide:empty { display: none; }
.practice-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.practice-next { min-width: 60%; }
.practice-skip {
  background: var(--paper); color: var(--ink-soft);
  border: 2px solid var(--line-strong); box-shadow: 0 3px 0 var(--line-strong); font-size: .95rem;
}
/* 무대 위 단계 칩 (누르면 연습한 말 다시 듣기) */
.stage-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 2px 14px;
  background: #fff7e0; border: 2px solid #f3d98b; border-radius: 999px;
  font-family: var(--font-display); font-size: 1rem; color: var(--ink); cursor: pointer;
}
.stage-chip:active { transform: scale(.96); }
.stage-skills:has(.stage-chip) { margin: 0; }   /* 무대 높이를 예전 기술 줄(26px+8px)과 비슷하게 */
.stage-skills .stage-chip span { background: none; border: 0; padding: 0; font-size: inherit; font-weight: inherit; }
/* 연습한 말 다시 보기: 한 줄(가로 스크롤)로 작게 */
.stage-examples {
  flex: none; display: flex; align-items: center; gap: 6px;
  background: var(--paper); border: 2px solid #f3d98b; border-radius: 18px; padding: 4px 4px 4px 10px;
  animation: bubble-pop .25s ease both;
}
.stage-examples-head { display: contents; }
.stage-examples-title { order: 0; flex: none; width: 3.2em; font-weight: 800; font-size: .78rem; line-height: 1.2; color: var(--ink-soft); }
.stage-examples-row { order: 1; flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.stage-examples .icon-btn { order: 2; flex: none; }
/* 예시 줄이 떠 있는 동안에는 이야기 기록을 잠깐 접어 마이크가 화면 밖으로 밀리지 않게 한다 */
.screen-stage.has-examples .stage-log,
.screen-stage.has-examples .stage-hint { display: none; }
.example-bubble {
  flex: none; min-height: 48px; padding: 6px 12px; max-width: 78vw;
  background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: 16px;
  font-size: 1rem; font-weight: 700; color: var(--ink); white-space: nowrap; cursor: pointer;
}
.example-bubble:active { transform: scale(.96); }
.transfer-bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #ecfdf5; border: 2px solid #86efac; border-radius: 16px; padding: 4px 6px 4px 12px;
}
.transfer-bar-title { font-family: var(--font-display); font-size: 1.05rem; }
.transfer-bar .practice-skip { min-height: 44px; }
@media (max-width: 380px) {
  .practice-card h2 { font-size: 1.35rem; }
  .practice-bubble, .practice-card p { font-size: 1.05rem; }
  .practice-bubble.is-lead { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .practice-panel, .stage-examples { animation: none; }
}

/* ---- v0.4 다음 친구 만나기 (자동 추천, 잠금 없음) */
.next-friend-card {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 28px; align-items: center; gap: 10px;
  width: calc(100% - 32px); max-width: 520px; margin: 8px auto 0; padding: 10px 12px;
  text-align: left; color: var(--ink);
  background: linear-gradient(135deg, #fff6d6 0%, #ffe9f0 100%);
  border: 2px solid #f4c95d; border-radius: var(--radius-md);
  box-shadow: 0 4px 0 #efd08a; position: relative; z-index: 3;
  transition: transform .12s ease, box-shadow .12s ease;
}
.next-friend-card:active { transform: translateY(2px); box-shadow: 0 2px 0 #efd08a; }
.next-friend-card[hidden] { display: none; }
.reco-art { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.reco-art .avatar-img { width: 100%; height: 100%; object-fit: contain; }
.reco-art .avatar-ph { width: 60px; height: 60px; font-size: 1.35rem; }
.reco-art .avatar-emoji { font-size: 2.2rem; }
.reco-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.reco-tag { align-self: flex-start; font-size: .74rem; font-weight: 800; background: #f4c95d; color: #4a3628; border-radius: 999px; padding: 3px 10px; }
.reco-title { font-family: var(--font-display); font-size: 1.12rem; line-height: 1.2; }
.reco-line { font-size: .84rem; color: var(--ink-soft); line-height: 1.35; }
.reco-go { font-size: 1.1rem; color: #c58a12; text-align: center; }
.episode-card.is-next { border-color: #f4c95d; background: #fff6d6; box-shadow: 0 4px 0 #efd08a; }
.episode-card .ep-tag-next { background: #f4c95d; }
.guardian-reco-box .reco-reason { margin: 6px 0 2px; line-height: 1.5; }
.brand h1 small { display: block; font-family: inherit; font-size: .62em; font-weight: 600; opacity: .75; margin-top: 2px; }

/* ===================================================================================
   제안서 01 (phase 1b) — UI/UX · 보호자 보안
   =================================================================================== */
/* ---- 1-1 처음 안내: 카드 높이 고정 · 점과 '다음'은 아래 같은 자리 · 건너뛰기는 오른쪽 위 (다시 보기에서만) */
#screen-intro .intro-card {
  height: min(620px, calc(100dvh - 120px)); min-height: 440px;
  justify-content: flex-start; gap: 14px; padding: 22px 18px 18px;
}
#screen-intro .intro-visual { flex: 1 1 auto; min-height: 0; height: auto; align-items: center; overflow: hidden; width: 100%; }
#screen-intro .intro-image { max-height: 100%; height: 100%; max-width: 100%; }
#screen-intro .intro-text { flex: none; height: 6.4em; min-height: 0; overflow: hidden; word-break: keep-all;
  display: flex; align-items: center; justify-content: center; }
.intro-foot { flex: none; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: auto; }
.intro-foot .intro-actions .btn-big { flex: 1; max-width: 360px; }
.intro-skip {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: var(--gutter); z-index: 5;
  min-height: 44px; padding: 0 16px; background: var(--paper); box-shadow: 0 4px 10px var(--shadow);
}
.intro-skip[hidden] { display: none; }
@media (max-height: 700px) {
  #screen-intro .intro-card { height: calc(100dvh - 90px); min-height: 380px; }
  #screen-intro .intro-text { font-size: 1.08rem; }
}

/* ---- 1-2 연습 카드: 아래쪽 시트 — 장면은 위, 방금 나온 친구 대사는 장면 아래, 카드는 그 아래 */
.screen-stage.is-practicing .stage-floor { flex: 0 1 auto; height: 26dvh; min-height: 120px; }
.screen-stage.is-practicing .practice-panel { flex: 1 0 210px; min-height: 210px; }
.screen-stage.is-practicing .practice-panel.is-folded { flex: 0 0 auto; min-height: 0; }
/* 연습 중 마이크가 쉬면: 연습 카드의 문장 말풍선을 누르면 입력 칸에 들어가므로 추천 줄·어른 버튼은 접는다 */
.screen-stage.is-practicing .mic-rest-suggest { display: none; }
.screen-stage.is-practicing .mic-rest { padding: 4px 6px 4px 10px; }
.screen-stage.is-practicing .mic-btn { width: 64px; height: 64px; }
.screen-stage.is-practicing.practice-folded .stage-floor { flex: 1 1 auto; height: auto; }
.screen-stage.is-practicing .practice-panel { order: 5; }
.screen-stage.is-practicing .stage-footer { order: 6; }
.screen-stage.is-practicing .stage-lastline { order: 4; }
.stage-lastline {
  flex: none; margin: 0; padding: 6px 12px; border-radius: 14px;
  background: var(--log-bg); border: 1.5px solid var(--line); font-size: .95rem; line-height: 1.4; word-break: keep-all;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.stage-lastline b { font-weight: 800; margin-right: 4px; }
.stage-lastline[hidden] { display: none; }
.screen-stage.is-practicing .practice-panel {
  border-radius: 26px 26px 18px 18px; border-width: 3px; padding-top: 8px;
  box-shadow: 0 -6px 18px var(--shadow); animation: sheet-up .28s ease both;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.practice-top { flex-direction: row; justify-content: space-between; align-items: center; gap: 6px; }
.practice-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; padding: 2px 0; color: inherit; cursor: pointer;
}
.practice-fold { flex: none; min-height: 40px; }
.practice-sheet-body { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.practice-panel { overflow: hidden; }
.practice-panel.is-folded { flex: 0 0 auto; }
.practice-panel.is-folded .practice-sheet-body,
.practice-panel.is-folded .practice-fold { display: none; }
.practice-panel.is-folded .practice-open::after {
  content: "눌러서 다시 펼치기 ▴"; font-size: .82rem; font-weight: 800; color: var(--ink-soft);
}
.practice-open:focus-visible, .practice-fold:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }
@media (max-height: 760px) {
  .screen-stage.is-practicing .stage-floor { height: 22dvh; min-height: 120px; }
  .screen-stage.is-practicing .practice-card { padding: 10px 12px; }
  .screen-stage.is-practicing .practice-card .teaching-emoji { display: none; }
}

/* ---- 1-3 대화 기록(최근 3줄 + 전체 보기) · 단서 큰 말풍선 */
.stage-log:not(.is-expanded) .log-line:not(:nth-last-child(-n+3)) { display: none; }
.stage-log { max-height: none; overflow-y: hidden; }
.stage-log.is-expanded { max-height: 42dvh; overflow-y: auto; }
.screen-stage.log-expanded .stage-floor { min-height: 18dvh; }
.log-line .log-text { word-break: keep-all; }
.log-all-btn {
  flex: none; align-self: flex-end; margin-top: -4px; min-height: 36px; padding: 0 12px;
  border: 1.5px solid var(--line-strong); background: var(--paper); color: var(--ink-soft);
  border-radius: 999px; font-size: .82rem; font-weight: 800; cursor: pointer;
}
.log-all-btn[hidden] { display: none; }
.screen-stage.is-practicing .log-all-btn, .screen-stage.has-examples .log-all-btn { display: none; }
.clue-bubble {
  position: absolute; left: 5%; right: 5%; top: 8%; z-index: 6;
  display: flex; gap: 12px; align-items: flex-start;
  background: #fffdf7; color: var(--ink); border: 3px solid var(--sun-deep); border-radius: 24px;
  padding: 14px 44px 14px 14px; box-shadow: 0 10px 24px rgba(0,0,0,.25);
  animation: bubble-pop .25s ease both;
}
.clue-bubble::after {
  content: ""; position: absolute; left: 42px; bottom: -14px; width: 24px; height: 24px; background: #fffdf7;
  border-right: 3px solid var(--sun-deep); border-bottom: 3px solid var(--sun-deep); transform: rotate(45deg);
}
.clue-art { flex: none; width: 64px; height: 64px; display: grid; place-items: center; font-size: 2.6rem; }
.clue-art img { width: 64px; height: 64px; object-fit: contain; }
.clue-body { flex: 1; min-width: 0; }
.clue-kicker { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.05rem; color: #b7791f; }
.clue-line { margin: 0 0 4px; font-size: 1.12rem; line-height: 1.45; font-weight: 700; word-break: keep-all; }
.clue-line b { color: #2563eb; }
.clue-close { position: absolute; top: 6px; right: 6px; }

/* ---- 1-8 감각 설정: 움직임 줄이기 (보호자) — 애니메이션·전환을 즉시 끝낸다 */
html.sens-calm *, html.sens-calm *::before, html.sens-calm *::after {
  animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}
html.sens-nofx .confetti { display: none !important; }
.sensory-box { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px 2px; margin: 4px 0; }
.sensory-box legend { font-weight: 800; padding: 0 4px; }
.sensory-box .switch-row span { word-break: keep-all; }
/* 보상 카드 이름이 단어 가운데서 끊기지 않게 */
.reward-label, .reward-card, .growth-reward, .codex-card b, .friend-hearts, .ep-title, .quest span, .detail-text, .coach-text { word-break: keep-all; overflow-wrap: break-word; }
/* '+5'가 게이지로 날아간다 */
.xp-fly {
  position: fixed; z-index: 400; pointer-events: none;
  font-family: var(--font-display); font-size: 1.5rem; color: #f97316;
  text-shadow: 0 2px 0 #fff, 0 0 8px #fff;
}
.xp-fly.is-still { transform: translate(-50%, -100%); animation: xp-still 1.3s ease both; }
@keyframes xp-still { 0% { opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.xp-pulse { animation: xp-pulse .5s ease; }
@keyframes xp-pulse { 0% { transform: scale(1); } 40% { transform: scale(1.06); filter: brightness(1.15); } 100% { transform: scale(1); } }

/* ---- 1-4 마이크가 쉬고 있을 때: 아이용 한 줄 + 추천 문장 + 어른에게 부탁하기 */
.mic-rest { text-align: left; background: #fff7e0; border: 2px solid #f3d98b; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.mic-rest[hidden] { display: none; }
.mic-rest-text { margin: 0; font-weight: 800; font-size: .98rem; word-break: keep-all; }
.mic-rest-suggest { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.mic-rest-chip {
  flex: none; min-height: 44px; padding: 4px 12px; max-width: 80vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--hint-bg); border: 2px solid var(--hint-border); border-radius: 14px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.mic-rest-chip:active { transform: scale(.96); }
.mic-ask-adult {
  align-self: flex-start; min-height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--paper); color: var(--ink-soft); font-size: .84rem; font-weight: 800; cursor: pointer;
}
.mic-help-steps { text-align: left; margin: 6px 0; padding-left: 1.3em; line-height: 1.6; word-break: keep-all; }

/* ---- 1-8 말할 친구를 누르면: 친구가 통통 뛰고 짧은 말풍선 (예전: 꼬미를 끌어다 놓으면) */
.char-chip.is-noticing .char-chip-img { animation: notice-hop .6s ease; }
.char-chip.is-noticing.face-left .char-chip-img { transform: scaleX(-1); }
@keyframes notice-hop { 0% { translate: 0 0; } 30% { translate: 0 -14px; } 60% { translate: 0 0; } 80% { translate: 0 -5px; } 100% { translate: 0 0; } }
.guide-react {
  position: absolute; left: 50%; top: 0; translate: -50% 0; z-index: 4;   /* 무대 위쪽에서 잘리지 않게 머리 위에 겹쳐 띄운다 */
  background: #fff; color: var(--ink); border: 2px solid var(--sun-deep); border-radius: 14px;
  padding: 4px 10px; font-size: .95rem; font-weight: 800; white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,.18); animation: bubble-pop .25s ease both;
}

/* ---- 1-7 홈의 오늘의 목표 카드 (한 줄: 제목 + 목표 3칸) */
.home-goal-card {
  display: grid; grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 1fr)); gap: 6px; align-items: stretch;
  width: 100%; max-width: 520px; margin: 6px auto 0; padding: 6px 8px; text-align: left; color: var(--ink); cursor: pointer;
  background: var(--paper); border: 2px solid var(--line-strong); border-radius: 18px; box-shadow: 0 3px 0 var(--line-strong);
}
.home-goal-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }
.home-goal-card.is-all { background: #ecfdf5; border-color: #86efac; box-shadow: 0 3px 0 #86efac; }
.goal-head { display: flex; flex-direction: column; justify-content: center; gap: 0; padding-left: 2px; }
.goal-head b { font-family: var(--font-display); font-weight: 400; font-size: 1rem; line-height: 1.2; word-break: keep-all; }
.goal-head i { font-style: normal; font-weight: 800; color: var(--ink-soft); font-size: .85rem; }
.goal-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 3px 2px; border-radius: 12px; background: #fff7e0; text-align: center; }
.goal-top { display: flex; align-items: center; gap: 3px; }
.goal-item i { font-style: normal; font-size: 1rem; }
.goal-item b { font-size: .82rem; }
.goal-item .goal-label { font-size: .7rem; line-height: 1.15; word-break: keep-all; color: var(--ink-soft); font-weight: 700; }
.goal-item.is-done { background: #ecfdf5; color: #166534; }
/* ---- 1-5 결말 하이라이트: 무대는 그대로, 아래에 한 문장 요약과 '결과 보러 가기' */
.screen-stage.is-highlight .stage-objects, .screen-stage.is-highlight .stage-log, .screen-stage.is-highlight .log-all-btn,
.screen-stage.is-highlight .stage-prompt, .screen-stage.is-highlight .stage-hint, .screen-stage.is-highlight .stage-skills,
.screen-stage.is-highlight .stage-examples, .screen-stage.is-highlight .stage-footer, .screen-stage.is-highlight .stage-lastline,
.screen-stage.is-highlight .demo-banner { display: none !important; }
.screen-stage.is-highlight .stage-floor { flex: 1 1 auto; }
.highlight-panel {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: var(--paper); border: 3px solid #f3d98b; border-radius: 24px; padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  margin-bottom: 8px; box-shadow: 0 -4px 16px var(--shadow); animation: sheet-up .3s ease both;
}
.hl-kicker { margin: 0; font-weight: 800; color: #b7791f; font-size: .9rem; }
.hl-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; word-break: keep-all; }
.hl-summary { margin: 0; font-size: 1.15rem; font-weight: 700; line-height: 1.45; word-break: keep-all; }
.hl-photo { margin: 0; font-weight: 800; color: #2563eb; }
.hl-photo[hidden], .hl-next[hidden] { display: none; }
.hl-next { width: 100%; max-width: 360px; margin-top: 4px; }
/* 결말 별비: 떨어지는 별똥별을 눌러 사진 찍기 (2026-10-11 별빛망원경 시연 모양).
   버튼(누르는 자리 56px)은 머리 자리에 있고, 꼬리는 오른쪽 위로 길게. 날아가는 길은 translate, 기울기는 rotate */
.hl-star {
  position: absolute; z-index: 5; pointer-events: auto;
  width: 56px; height: 56px; margin: -28px 0 0 -28px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.hl-star:focus-visible { outline: 3px solid #ffe28a; outline-offset: 2px; }
.hl-star-head {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: radial-gradient(circle, #fffef4 0 35%, #fff2b8 60%, rgba(255,236,160,0) 72%);
  box-shadow: 0 0 16px 7px rgba(255, 236, 160, .85), 0 0 34px 12px rgba(255, 214, 120, .35);
}
.hl-star-tail {
  position: absolute; left: 50%; top: 50%; width: var(--len, 130px); height: 4px; margin-top: -2px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 250, 220, .95), rgba(255, 240, 180, .45) 45%, rgba(255, 255, 255, 0));
  filter: drop-shadow(0 0 6px rgba(255, 246, 176, .9)); transform-origin: left center;
}
.hl-star.is-shooting { rotate: -28deg; animation: shoot var(--dur, 3s) linear forwards; }
.hl-star.is-still { rotate: -28deg; }
.hl-star.is-still .hl-star-tail { width: calc(var(--len, 60px) * .5); opacity: .55; }
.hl-star.is-still .hl-star-head { animation: hl-twinkle 1.6s ease-in-out infinite; }
.hl-star.is-caught { pointer-events: none; animation: hl-caught .5s ease-out forwards; }
.hl-star.is-caught .hl-star-tail { opacity: 0; transition: opacity .15s; }
@keyframes hl-twinkle { 0%,100% { opacity: .7; scale: .9; } 50% { opacity: 1; scale: 1.15; } }
@keyframes hl-caught { 0% { scale: 1; opacity: 1; } 40% { scale: 2.2; opacity: 1; } 100% { scale: 3; opacity: 0; } }
/* 사진 섬광: 누른 별 자리에서 하얗게 번지고, 사진기 네모 틀이 '찰칵' 하고 맞춰진다 */
.hl-flash {
  position: absolute; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 40%), #fff 0, rgba(255,255,255,.96) 30%, rgba(255,250,228,.85) 100%);
  animation: hl-flash .65s ease-out forwards;
}
.hl-flash.is-soft { background: rgba(255, 250, 230, .9); animation: hl-flash-soft .9s ease-in-out forwards; }
@keyframes hl-flash { 0% { opacity: .95; } 100% { opacity: 0; } }
@keyframes hl-flash-soft { 0% { opacity: 0; } 35% { opacity: .32; } 100% { opacity: 0; } }
.hl-snap { position: absolute; inset: 9%; animation: hl-snap .8s cubic-bezier(.2,.9,.3,1) forwards; }
.hl-snap i { position: absolute; width: 13%; height: 22%; border: 0 solid #fff; filter: drop-shadow(0 0 3px rgba(60,40,10,.35)); }
.hl-snap i:nth-child(1) { left: 0; top: 0; border-width: 5px 0 0 5px; border-top-left-radius: 14px; }
.hl-snap i:nth-child(2) { right: 0; top: 0; border-width: 5px 5px 0 0; border-top-right-radius: 14px; }
.hl-snap i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 5px 5px; border-bottom-left-radius: 14px; }
.hl-snap i:nth-child(4) { right: 0; bottom: 0; border-width: 0 5px 5px 0; border-bottom-right-radius: 14px; }
@keyframes hl-snap { 0% { scale: 1.12; opacity: 0; } 25% { scale: 1; opacity: 1; } 70% { opacity: 1; } 100% { scale: 1; opacity: 0; } }
.char-chip.hl-turn .char-chip-img { animation: notice-hop .7s ease 2; }

/* ---- 1-6 보상 순서: 보상 → (다음) 경험치 게이지 → (다음) 레벨업(오른 판에만) */
.ending-xp {
  margin: 4px auto 14px; max-width: 360px; padding: 10px 14px; border-radius: 18px;
  background: rgba(255,253,247,.92); border: 2px solid #f3d98b; animation: bubble-pop .3s ease both;
}
.ending-xp[hidden], .ending-next[hidden], #btn-ending-home[hidden] { display: none; }
.ending-xp-head { margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; word-break: keep-all; }
.ending-xp-head b { font-size: .95rem; }
.ending-xp-gain { font-style: normal; font-family: var(--font-display); font-size: 1.3rem; color: #f97316; }
.ending-xp .xp-track { display: block; height: 14px; border-radius: 999px; background: #f3e6c8; overflow: hidden; }
.ending-xp .xp-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffcf4a, #ff8a5c); border-radius: inherit; transition: width 1.1s ease; }
.ending-xp-level { margin: 6px 0 0; font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
.ending-next { width: 100%; max-width: 360px; }
.levelup .lv-later { margin-top: 6px; width: 100%; }

/* ---- 2-1 첫 화면: 만 14세 미만 보호자 동의 안내 */
.consent-notice {
  margin: 10px auto 0; max-width: 340px; padding: 8px 12px; border-radius: 14px;
  background: rgba(255,253,247,.9); border: 1.5px solid var(--line-strong);
  font-size: .82rem; line-height: 1.5; color: var(--ink); text-align: left; word-break: keep-all;
}
/* ---- 2-2 🔒 보호자 버튼 (아이 고르기 화면 오른쪽 위) · 홈 톱니에 자물쇠 */
.guardian-lock-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: var(--gutter); z-index: 5;
  min-height: 44px; padding: 0 14px; background: var(--paper); box-shadow: 0 4px 10px var(--shadow); font-weight: 800;
}
.gear-btn { position: relative; }
.lock-badge {
  position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 2px 4px var(--shadow); font-size: .72rem; line-height: 22px; text-align: center;
}
.guardian-menu .btn { justify-content: flex-start; text-align: left; }
#form-pin .btn-ghost.small, #form-pin-forgot .btn-ghost.small { align-self: center; }
.pin-input:disabled, #btn-pin-submit:disabled { opacity: .5; }

.mic-rest { gap: 4px; padding: 4px 6px 4px 10px; margin-bottom: 6px; }
.mic-rest-head { display: flex; align-items: center; gap: 6px; }
.mic-rest-text { flex: 1; min-width: 0; font-size: .86rem; line-height: 1.3; }
.mic-rest .mic-ask-adult { flex: 0 1 44%; align-self: center; min-height: 40px; padding: 2px 8px; font-size: .74rem; line-height: 1.2; border-radius: 14px; word-break: keep-all; text-align: center; }
.mic-rest-chip { min-height: 44px; padding: 2px 12px; }
/* 마이크가 쉬는 동안: 큰 🎤 줄을 접고(글자 입력이 주인공) 무대·기록이 밀려나지 않게 */
html.mic-resting .mic-row { display: none; }
html.mic-resting .screen-stage .stage-floor { min-height: 20dvh; }
html.mic-resting .screen-stage .text-input-row { margin-bottom: 2px; }
/* 무대 바로 아래 자식은 원래 position:relative 로 바뀐다(style.css .stage-floor > :not(...)) — 새 층은 id 로 절대 위치를 되찾는다 */
#stage-floor > .clue-bubble { position: absolute; z-index: 8; }
#stage-floor > .hl-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
#stage-floor > .hl-flash { position: absolute; inset: 0; z-index: 9; }
.stage-log { flex: none; }
.log-all-btn { min-height: 30px; margin-top: -2px; }

/* 연습 시트: 말할 차례가 아닐 때(배우기·해보기)는 마이크 줄을 접어 시트를 넓힌다. 버튼은 시트 아래에 붙어 있다 */
.screen-stage.is-practicing.guided-mic-off .mic-row { display: none; }
.screen-stage.is-practicing .practice-actions { position: sticky; bottom: 0; background: var(--paper); padding: 6px 0 2px; margin-top: auto; }
.screen-stage.is-practicing .practice-card { padding: 10px 12px; gap: 4px; }
.screen-stage.is-practicing .practice-card .teaching-emoji { font-size: 2rem; line-height: 1; }
.screen-stage.is-practicing .practice-card h2 { font-size: 1.35rem; }
/* 마이크가 쉬는 동안 이야기 장면: 조작 안내(끌기·🎤)는 접는다 — 상황 설명은 대화 기록 '지금 상황'에 남아 있다 */
html.mic-resting .screen-stage:not(.is-practicing) .stage-hint { display: none; }

/* ── 장면 배경 그림·영상 + 밤하늘 (2026-10-11, 별빛망원경 시연에서 옮김) ──────────────
   층: 그림(0) → 영상(1, 재생되면 스르르) → 밤 그늘(2) → 반짝이는 별·별똥별(3) → (그 위에 친구 칩·자막)
   16:9 그림을 장면 칸에 cover 로 맞추고 --focus(콘텐츠 focus) 자리를 남긴다 */
:root {
  --sky-star: #fffbe6;
  --sky-star-glow: rgba(255, 244, 190, .75);
  --shoot-head: #fffbe0;
  --shoot-glow: rgba(255, 240, 170, .8);
  --shoot-tail: rgba(255, 247, 200, .95);
}
#stage-floor > .stage-scenebg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: #0d1533; }
#stage-floor.has-scenebg { background: #0d1533; }
#stage-floor.has-scenebg > .stage-backdrop { display: none; }
.stage-scenebg .sbg-img, .stage-scenebg .sbg-video {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block;
  object-fit: cover; object-position: var(--focus, 50% 60%);
}
.stage-scenebg .sbg-video { z-index: 1; opacity: 0; transition: opacity .9s ease; background: transparent; }
.stage-scenebg.video-on .sbg-video { opacity: 1; }
.stage-scenebg::after {   /* 가장자리를 살짝 어둡게: 자막·칩이 밤하늘 위에서도 또렷하게 */
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 22%, transparent 42%, rgba(0, 0, 30, .32));
}
.stage-scenebg .sky-fx, .stage-scenebg .sky-twinkles, .stage-scenebg .sky-shoots { position: absolute; inset: 0; }
.stage-scenebg .sky-fx { z-index: 3; }
.sky-twinkle {
  position: absolute; width: var(--ts, 2px); height: var(--ts, 2px); border-radius: 50%;
  background: var(--sky-star); box-shadow: 0 0 6px 2px var(--sky-star-glow);
  animation: sky-tw var(--tw, 3s) ease-in-out var(--tdelay, 0s) infinite;
}
.sky-twinkle.is-cross::before, .sky-twinkle.is-cross::after {   /* 큰 별은 십자로 반짝 */
  content: ""; position: absolute; left: 50%; top: 50%; width: 15px; height: 1.5px; translate: -50% -50%;
  background: linear-gradient(90deg, transparent, var(--sky-star), transparent); border-radius: 2px;
}
.sky-twinkle.is-cross::after { rotate: 90deg; }
@keyframes sky-tw { 0%, 100% { opacity: .28; scale: .7; } 50% { opacity: 1; scale: 1.15; } }
.stage-scenebg.sky-glow .sky-twinkle { opacity: 1; scale: 1.3; box-shadow: 0 0 10px 4px var(--sky-star-glow); transition: scale .6s, opacity .6s; }

/* 별똥별 (시연 .shoot): 밝은 머리가 왼쪽 아래로 앞서고, 꼬리가 오른쪽 위로 */
.shoot {
  position: absolute; width: var(--len, 150px); height: 3px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--shoot-tail), rgba(255, 247, 200, .35) 50%, rgba(255, 255, 255, 0));
  rotate: -28deg; transform-origin: left center; filter: drop-shadow(0 0 6px #fff6b0);
  animation: shoot var(--dur, 2s) linear forwards;
}
.shoot::after {
  content: ""; position: absolute; left: -5px; top: -4px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--shoot-head); box-shadow: 0 0 14px 6px var(--shoot-glow);
}
.shoot.is-big { height: 4px; }
.shoot.is-big::after { width: 13px; height: 13px; top: -4.5px; }
@keyframes shoot {
  from { translate: 0 0; opacity: 0; }
  10% { opacity: 1; }
  80% { opacity: .9; }
  to { translate: calc(var(--travel, 520px) * -1) calc(var(--travel, 520px) * .54); opacity: 0; }
}
#stage-floor > .sky-burst { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }

/* 움직임 줄이기(기기 설정 · 보호자 '움직임 줄이기'): 영상·별똥별 없이, 별은 제자리에서 은은하게 */
@media (prefers-reduced-motion: reduce) {
  .sky-twinkle { animation: none; opacity: .75; }
  .shoot, .hl-star.is-shooting { display: none; }
  .stage-scenebg .sbg-video { display: none; }
}
html.sens-calm .sky-twinkle { animation: none !important; opacity: .75; scale: 1; }
html.sens-calm .shoot, html.sens-calm .stage-scenebg .sbg-video { display: none !important; }
html.sens-nofx .shoot { display: none !important; }

/* ==========================================================================
   꼬미 = 나레이터 (2026-10-11 결정: "꼬미는 없어 나오지 않게해 나레이터일 뿐이야")
   꼬미는 장면·화면에 캐릭터(그림·🐶)로 나오지 않는다. 꼬미의 말은 해설로, 작은 "꼬미" 이름표만 붙인다.
   ========================================================================== */
.narr-tag {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 9px; border-radius: 999px;
  background: #fff3d1; color: #8a5a12; border: 1.5px solid #f2c96b;
  font-family: var(--font-display, inherit); font-style: normal; font-weight: 400; font-size: .78em; line-height: 1.5;
  letter-spacing: .02em; white-space: nowrap; vertical-align: middle;
}
/* 홈 안내 · 프롬프트 바 · 회고 · 연습 말풍선: 그림 자리에 이름표 */
.home-hint-tag, .stage-prompt-tag, .reflection-tag, .practice-bubble .pb-guide { margin-right: 2px; }
/* 단톡방: 꼬미 해설은 프로필 그림 없이, 이름표가 달린 말풍선 */
.bubble-row.is-guide .bubble { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
.bubble-row.is-guide .bubble-text { min-width: 0; }
.bubble-row.is-guide .bubble-col { flex: 0 1 auto; }
/* 첫 인사·출석 인사 딤드: 꼬미 그림 대신 말풍선 안 이름표 (꼬리 없음) */
.pip-greet-bubble.is-narration::before { display: none; }
.pip-greet-bubble.is-narration .narr-tag { display: flex; width: max-content; margin: 0 auto 6px; font-size: .82rem; }
/* 장면: 말할 친구로 고른 친구 — 노란 고리 + 이름표 강조 (키보드 포커스도 같은 모양) */
.char-chip.is-selected .char-chip-avatar::before { background: rgba(245, 180, 40, .55); width: 82%; height: 20px; filter: blur(2px); }
.char-chip.is-selected .char-chip-img { filter: drop-shadow(0 0 7px rgba(255, 205, 70, .95)) drop-shadow(0 0 2px #fff) drop-shadow(0 4px 6px rgba(60, 40, 20, .28)); }
.char-chip.is-selected .char-chip-name { background: var(--sun, #ffd36b); color: #4a3112; box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(0, 0, 0, .25); }
.char-chip.is-selected .char-chip-name::before { content: "👆 "; }
.char-chip:focus-visible { outline: none; }
.char-chip:focus-visible .char-chip-name { outline: 3px solid #2563eb; outline-offset: 2px; }
/* 코치: 친구 누르기 시연 (꼬미 끌기 시연을 대신한다) */
.coach-track-pick { width: 200px; height: 104px; }
.coach-track-pick .coach-friend { bottom: 10px; }
.coach-track-pick .coach-friend-a { left: 6px; right: auto; opacity: .75; }
.coach-track-pick .coach-friend-b { right: 18px; }
.coach-track-pick .coach-friend-b img { position: relative; z-index: 1; }
.coach-pick-ring {
  position: absolute; left: 50%; bottom: -6px; width: 92%; height: 20px; translate: -50% 0; border-radius: 50%;
  background: rgba(245, 180, 40, .7); filter: blur(2px); z-index: 0; animation: coach-pick 1.6s ease-in-out infinite;
}
.coach-hand-pick {
  position: absolute; right: -10px; bottom: -16px; z-index: 2; font-size: 2rem; 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));
  animation: coach-pick-tap 1.6s cubic-bezier(.34,1.56,.64,1) infinite;
}
@keyframes coach-pick { 0%, 25% { opacity: 0; } 40%, 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes coach-pick-tap { 0%, 55%, 100% { transform: translate(0, 0) rotate(-10deg); } 20% { transform: translate(-4px, -18px) rotate(0deg) scale(1.08); } 34% { transform: translate(-2px, -4px) rotate(-8deg); } }
@media (prefers-reduced-motion: reduce) { .coach-pick-ring { animation: none; opacity: 1; } .coach-hand-pick { animation: none; } }
