/* ── Design Tokens ── */
:root {
  --cream: #FAF4E4;
  --yellow: #FFD23E;
  --green: #46C35F;
  --blue: #4FA3F0;
  --pink: #FF93C4;
  --coral: #FF8A5B;
  --rose: #FF6B81;
  --ink: #1F1B16;
  --muted: #7A746B;
  --divider: #E7E0CF;
  --belly: #ECFDD2;
  --mascot-circle-start: #BDE8CE;
  --mascot-circle-main: #FFE9A8;
  --font-ko: 'Jua', sans-serif;
  --font-en: 'Baloo 2', cursive, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: #FFCE36;
  font-family: var(--font-ko);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px;
  position: relative;
  overflow: hidden;
}

/* 카드 밖 노란 배경의 구름 도들 */
.sky-doodles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.sky-cloud { position: absolute; background: #FFE08A; }
.sky-cloud-1 {
  left: -60px; top: 40px; width: 280px; height: 160px;
  border-radius: 50% 50% 48% 52%/60% 60% 40% 40%;
  opacity: .6;
}
.sky-cloud-2 {
  right: -40px; bottom: 30px; width: 240px; height: 150px;
  border-radius: 50%; opacity: .5;
}
.sky-cloud-3 {
  right: 120px; top: -30px; width: 170px; height: 110px;
  background: #FFDD6E; border-radius: 50%; opacity: .55;
}

#app { position: relative; z-index: 1; }

/* 가운데 정렬된 카드 틀 (원본 디자인) */
#app {
  position: relative;
  flex: none;
  width: min(1180px, 100vw - 68px);
  height: min(880px, 100vh - 68px);
  background: var(--cream);
  border: 6px solid var(--ink);
  border-radius: 46px;
  box-shadow: 16px 18px 0 var(--ink);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Text input fallback (음성 미지원/테스트용) ── */
.type-form { display: flex; gap: 6px; margin: 12px auto 0; width: 100%; max-width: 360px; }
.type-input {
  flex: 1; min-width: 0;
  border: 2.5px solid var(--ink); border-radius: 14px;
  padding: 9px 13px; font-family: inherit; font-size: 15px; outline: none;
}
.type-input:focus { box-shadow: 0 0 0 3px rgba(255,206,54,0.5); }
.type-send {
  border: 2.5px solid var(--ink); border-radius: 14px;
  background: #FFCE36; color: var(--ink); font-weight: 800;
  padding: 0 16px; cursor: pointer; font-size: 15px;
}
.type-send:active { transform: translateY(1px); }

/* ── Doodle decorations ── */
.doodles { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.doodle { position: absolute; border: 5px solid var(--ink); }
.doodle-green {
  left: -34px; top: -30px; width: 130px; height: 120px;
  background: var(--green);
  border-radius: 54% 46% 57% 43%/52% 58% 42% 48%;
  transform: rotate(-8deg);
}
.doodle-circle {
  right: 46px; top: 120px; width: 54px; height: 54px;
  background: transparent; border-color: var(--blue);
  border-radius: 50%;
}
.doodle-pink {
  left: 40px; bottom: -26px; width: 120px; height: 104px;
  background: var(--pink);
  border-radius: 48% 52% 44% 56%/56% 44% 60% 40%;
  transform: rotate(7deg);
}
.doodle-blue {
  right: -26px; bottom: 90px; width: 96px; height: 90px;
  background: var(--blue);
  border-radius: 52% 48% 60% 40%/46% 56% 44% 54%;
  transform: rotate(-6deg);
}

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
}
.screen.active { display: flex; }

/* ── START SCREEN (이름 입력 → 맵으로) ── */
.start-layout {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 46px 64px;
}
.start-mascot {
  flex: 0 0 46%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px 0;
}
#slot-start {
  width: 100%; height: 100%;
  max-width: 440px; max-height: 500px;
}
.start-content {
  flex: 1;
  padding-left: 30px;
}
.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 8px 16px;
  transform: rotate(-2deg);
  box-shadow: 4px 5px 0 var(--ink);
}
.badge-text {
  font-size: 26px;
  color: var(--ink);
  letter-spacing: 1px;
}
.start-title {
  font-family: var(--font-ko);
  font-size: 52px;
  line-height: 1.2;
  color: var(--ink);
  margin: 22px 0 0;
  text-wrap: balance;
}
.start-title .green { color: var(--green); }
.start-sub {
  font-size: 22px;
  color: var(--muted);
  margin: 16px 0 0;
}
.btn-start {
  display: block;
  margin-top: 26px;
  border: 5px solid var(--ink);
  cursor: pointer;
  width: 290px; height: 88px;
  border-radius: 22px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-ko);
  font-size: 32px;
  letter-spacing: 1px;
  box-shadow: 0 9px 0 var(--ink);
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  transition: transform .1s, box-shadow .1s;
}
.btn-start:active {
  transform: translateY(4px);
  box-shadow: 0 5px 0 var(--ink);
}

/* ── DAY MAP SCREEN ── */
#screen-map.active {
  flex-direction: column;
  padding: 20px 26px;
}
.map-layout {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.map-top {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 10;
}
.lv-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 5px solid var(--ink);
  border-radius: 20px;
  padding: 7px 18px 7px 9px;
  box-shadow: 5px 6px 0 var(--ink);
}
.lv-avatar {
  flex: none;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--mascot-circle-main);
  border: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.lv-avatar img { width: 58px; height: 58px; object-fit: contain; }
.lv-num {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 14px;
  color: var(--coral);
  letter-spacing: 1px;
  line-height: 1;
}
.lv-name {
  font-size: 21px;
  color: var(--ink);
  line-height: 1.15;
  white-space: nowrap;
}
.map-top-right { display: flex; align-items: center; gap: 11px; }
.name-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 8px 15px;
  box-shadow: 4px 5px 0 var(--ink);
  font-size: 18px;
}
.prog-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green);
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 8px 16px;
  box-shadow: 4px 5px 0 var(--ink);
}
.prog-pill span:last-child {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  white-space: nowrap;
}
.map-area {
  position: relative;
  flex: 1;
  min-height: 0;
  z-index: 2;
}
#map-svg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#map-nodes { position: absolute; inset: 0; }
.map-sheet {
  flex: none;
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  background: #fff;
  border: 5px solid var(--ink);
  border-radius: 24px;
  padding: 12px 14px 12px 24px;
  box-shadow: 6px 7px 0 var(--ink);
  margin-top: 8px;
}
.sheet-item { display: flex; align-items: center; gap: 8px; flex: none; }
.sheet-item.topic { flex: 1; min-width: 0; overflow: hidden; }
.sheet-item .ic { font-size: 19px; }
.sheet-item .k { font-size: 18px; color: var(--muted); white-space: nowrap; }
.sheet-item .v {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 21px;
  color: var(--ink);
  white-space: nowrap;
}
.sheet-item .v.ko {
  font-family: var(--font-ko);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-div { flex: none; width: 4px; height: 32px; background: #EDE6D4; border-radius: 2px; }
.btn-talk {
  flex: none;
  border: 5px solid var(--ink);
  cursor: pointer;
  height: 60px;
  padding: 0 30px;
  border-radius: 18px;
  font-family: var(--font-ko);
  font-size: 22px;
  box-shadow: 0 7px 0 var(--ink);
  background: var(--yellow);
  color: var(--ink);
  white-space: nowrap;
  transition: transform .1s, box-shadow .1s;
}
.btn-talk:active { transform: translateY(3px); box-shadow: 0 4px 0 var(--ink); }

/* ── Mascot (image with SVG fallback) ── */
.mascot-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mascot-img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
  /* 확대된 마스코트가 상단 게이지/뒤로가기 버튼 위로 넘쳐 클릭을 가로채지 않게 */
  pointer-events: none;
}
.mascot-fb { display: none; width: 100%; height: 100%; }
.mascot-fb svg { width: 100%; height: 100%; display: block; }
/* 이미지 로드 실패 시 SVG 폴백으로 전환 */
.mascot-slot.broken .mascot-img { display: none; }
.mascot-slot.broken .mascot-fb { display: block; }
.floating { animation: float-soft 3.4s ease-in-out infinite; }

.name-input {
  margin-top: 24px;
  width: 330px; height: 66px;
  border: 5px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  font-family: var(--font-ko);
  font-size: 23px;
  color: var(--ink);
  text-align: center;
  outline: none;
  box-shadow: 4px 5px 0 var(--ink);
}
.name-input:focus {
  border-color: var(--green);
  box-shadow: 4px 5px 0 var(--green);
}

/* ── DAY COMPLETE DIALOG (Day 1~6) ── */
.day-dialog {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(31,27,22,.42);
}
.day-card {
  position: relative;
  width: min(440px, 100%);
  background: #fff;
  border: 6px solid var(--ink);
  border-radius: 32px;
  padding: 32px 30px 28px;
  box-shadow: 12px 14px 0 var(--ink);
  text-align: center;
  animation: pop-in .6s cubic-bezier(.34,1.5,.5,1);
}
.day-avatar-wrap { position: relative; width: 136px; height: 136px; margin: 0 auto; }
.day-avatar {
  width: 136px; height: 136px;
  border-radius: 50%;
  background: var(--mascot-circle-main);
  border: 5px solid var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.day-avatar img { width: 144px; height: 144px; object-fit: contain; display: block; }
.day-stamp {
  position: absolute;
  right: -16px; bottom: -8px;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--green);
  border: 5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: stamp-thunk .7s cubic-bezier(.3,1.4,.5,1) forwards;
}
.day-stars { font-size: 22px; letter-spacing: 5px; margin-top: 16px; }
.day-title {
  font-family: var(--font-ko);
  font-size: 36px;
  color: var(--green);
  margin: 6px 0 0;
  line-height: 1.12;
}
.day-sub {
  font-family: var(--font-ko);
  font-size: 20px;
  color: var(--ink);
  margin: 12px 0 0;
}
.day-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EAF7EE;
  border: 3px solid var(--green);
  border-radius: 12px;
  padding: 6px 15px;
  margin-top: 15px;
}
#day-badge-text {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 16px;
  color: #2E8B4E;
}
.btn-day-done {
  display: block;
  width: 100%;
  margin-top: 22px;
  height: 70px;
  border: 5px solid var(--ink);
  border-radius: 20px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-ko);
  font-size: 24px;
  box-shadow: 0 8px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.btn-day-done:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 var(--ink);
}

/* ── MAIN SCREEN ── */
#screen-main.active {
  flex-direction: column;
  padding: 18px 40px 22px;
}
/* 메인 화면을 세로 flex로: 게이지(고정)–마스코트(가변)–말풍선(고정) */
.main-layout {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Gauge row */
.gauge-row {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 2;   /* 마스코트 위로 올려 상단 버튼 클릭 보장 */
}
.btn-back {
  flex: none;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 4px 0 var(--ink);
  cursor: pointer;
  font-family: var(--font-ko);
  font-size: 24px;
  color: var(--ink);
  transition: transform .1s, box-shadow .1s;
}
.btn-back:active { transform: translateY(2px); box-shadow: 1px 2px 0 var(--ink); }
.day-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 3px 4px 0 var(--ink);
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 15px;
  color: var(--coral);
  white-space: nowrap;
}
.gauge-icon {
  flex: none;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--coral);
  border: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 4px 0 var(--ink);
}
.gauge-track {
  flex: 1;
  height: 36px;
  border-radius: 20px;
  background: #fff;
  border: 4px solid var(--ink);
  position: relative;
  overflow: hidden;
}
.gauge-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--green);
  border-radius: 16px;
  transition: width .8s cubic-bezier(.34,1.4,.5,1);
}
.gauge-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}
.score-badge {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 6px 14px;
  box-shadow: 3px 4px 0 var(--ink);
}
.score-star { font-size: 16px; }
.score-val {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 24px;
  color: var(--ink);
}
.star-pop {
  position: absolute;
  right: 50px; top: 50px;
  font-size: 34px;
  animation: star-float 1.4s ease-out forwards;
  pointer-events: none;
}

/* Mascot area */
.main-mascot-area {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  padding: 0;
}
/* 슬롯을 영역에 절대 고정 → 이미지가 형제(말풍선)를 밀어내지 못하게 */
#slot-main {
  position: absolute;
  inset: 0;
}
#slot-main .mascot-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  /* contain 여백 때문에 작아 보여서 살짝 확대 (바닥 기준으로 위로 커짐)
     + 말풍선에 가깝게 아래로 살짝 내림 */
  transform: scale(1.22) translateY(7%);
  transform-origin: center bottom;
}

/* Sentence wrapper */
.sentence-wrapper {
  position: relative;
  width: 100%;
  max-width: 820px;
  flex: none;
  align-self: center;
}
.speech-arrow {
  position: absolute;
  left: 50%; top: -13px;
  width: 26px; height: 26px;
  background: #fff;
  border-left: 5px solid var(--ink);
  border-top: 5px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
  z-index: 1;
}
.sentence-box {
  position: relative;
  background: #fff;
  border: 5px solid var(--ink);
  border-radius: 30px;
  box-shadow: 7px 8px 0 var(--ink);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 26px;
  min-height: 148px;
}
.sentence-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.dots {
  display: flex;
  gap: 14px;
  padding: 14px 0;
}
.dot {
  width: 17px; height: 17px;
  border-radius: 50%;
}
.dot-g { background: var(--green); animation: dotb 1.1s ease-in-out infinite; }
.dot-b { background: var(--blue); animation: dotb 1.1s ease-in-out infinite .18s; }
.dot-p { background: var(--pink); animation: dotb 1.1s ease-in-out infinite .36s; }

.bubble-en {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 40px;
  line-height: 1.12;
  color: var(--ink);
  text-wrap: balance;
}
.bubble-ko {
  font-family: var(--font-ko);
  font-size: 20px;
  color: var(--coral);
  margin-top: 8px;
}

.sentence-divider {
  flex: none;
  align-self: stretch;
  border-left: 3px dashed var(--divider);
  margin: 8px 0;
}

/* Mic area */
.mic-area {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 132px;
}
.mic-btn-wrap {
  position: relative;
  width: 104px; height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-ping {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--rose);
  animation: ping 1.3s ease-out infinite;
}
.mic-ping.ping2 { animation-delay: .5s; }
.btn-mic {
  position: relative;
  z-index: 2;
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 5px solid var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 7px 0 var(--ink);
  transition: transform .1s, box-shadow .1s, background .2s, color .2s;
}
.btn-mic:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 var(--ink);
}
.btn-mic.recording {
  background: var(--rose);
  color: #fff;
}
.btn-mic.sending {
  background: #BDE8CE;
  color: var(--ink);
  cursor: default;
}
.mic-helper {
  font-family: var(--font-ko);
  font-size: 16px;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
}

/* ── EVOLUTION OVERLAY ── */
.evo-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
.evo-flash {
  position: absolute;
  inset: 0;
  background: #FFE27A;
  animation: flash3 1.5s ease-in-out;
  pointer-events: none;
}
.evo-video-wrap {
  position: absolute;
  inset: 0;
  z-index: 35;
  background: #1F1B16;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: auto;
}
.evo-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.evo-progress-badge {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #1F1B16;
  border: 4px solid #C1F65E;
  border-radius: 16px;
  padding: 8px 20px;
  font-family: var(--font-ko);
  font-size: 24px;
  color: #C1F65E;
  letter-spacing: 1px;
  box-shadow: 4px 5px 0 rgba(0,0,0,.4);
}
.evo-card-bg {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31,27,22,.45);
  pointer-events: auto;
}
.particles { position: absolute; inset: 0; pointer-events: none; }
.particles span {
  position: absolute;
  left: 50%; top: 46%;
  pointer-events: none;
}
.evo-card {
  position: relative;
  width: min(440px, 100%);
  background: #fff;
  border: 6px solid var(--ink);
  border-radius: 32px;
  padding: 30px 26px 28px;
  box-shadow: 10px 12px 0 var(--ink);
  text-align: center;
  animation: pop-in .6s cubic-bezier(.34,1.5,.5,1);
}
.evo-avatar {
  width: 150px; height: 150px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--mascot-circle-main);
  border: 5px solid var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* 프레임째 흔들리게(이미지만 움직이면 귀가 프레임에 잘려 보임) */
  animation: float-soft 3s ease-in-out infinite;
}
.evo-avatar img {
  width: 158px; height: 158px;
  object-fit: contain;
  display: block;
}
.evo-emojis { font-size: 26px; letter-spacing: 6px; margin-top: 14px; }
.evo-title {
  font-family: var(--font-ko);
  font-size: 32px;
  color: var(--green);
  margin: 6px 0 0;
  line-height: 1.12;
  word-break: keep-all;   /* 한글 단어가 중간에서 끊기지 않도록 */
}
.evo-congrats {
  font-family: var(--font-ko);
  font-size: 19px;
  color: var(--ink);
  margin: 12px 0 0;
}
.evo-bye {
  font-family: var(--font-ko);
  font-size: 15px;
  color: var(--muted);
  margin: 6px 0 0;
}
.btn-restart {
  display: block;
  width: 100%;
  margin-top: 22px;
  border: 5px solid var(--ink);
  cursor: pointer;
  height: 70px;
  border-radius: 20px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-ko);
  font-size: 24px;
  box-shadow: 0 8px 0 var(--ink);
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  transition: transform .1s, box-shadow .1s;
}
.btn-restart:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 var(--ink);
}

/* ── Keyframe Animations ── */
@keyframes ping {
  0%   { transform: scale(1); opacity: .55; }
  80%, 100% { transform: scale(1.85); opacity: 0; }
}
@keyframes dotb {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
}
@keyframes pop-in {
  0%   { transform: scale(.6) rotate(-4deg); opacity: 0; }
  60%  { transform: scale(1.05) rotate(1deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes star-float {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translateY(-56px) scale(1.15); opacity: 0; }
}
@keyframes flash3 {
  0%, 100% { opacity: 0; }
  10%, 40%, 70% { opacity: .9; }
  25%, 55%, 85% { opacity: 0; }
}
@keyframes p-burst {
  0%   { transform: translate(-50%,-50%) scale(.2); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(40deg); opacity: 0; }
}
@keyframes float-soft {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-9px) rotate(1deg); }
}
@keyframes daybounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes glowring {
  0%, 100% { box-shadow: 0 8px 0 var(--ink), 0 0 0 6px rgba(255,210,62,0); }
  50%      { box-shadow: 0 8px 0 var(--ink), 0 0 0 12px rgba(255,210,62,.45); }
}
@keyframes stamp-thunk {
  0%   { transform: scale(2.4) rotate(-18deg); opacity: 0; }
  55%  { transform: scale(.85) rotate(-8deg); opacity: 1; }
  75%  { transform: scale(1.08) rotate(-6deg); }
  100% { transform: scale(1) rotate(-7deg); opacity: 1; }
}

/* Mascot SVG keyframes */
@keyframes m-bob   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes m-sway  { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes m-jump  { 0%,100% { transform: translateY(0) scaleY(1); } 30% { transform: translateY(-26px) scaleY(1.04); } 62% { transform: translateY(0) scaleY(0.93); } }
@keyframes m-lean  { 0%,100% { transform: translateY(0) rotate(-1.6deg); } 50% { transform: translateY(-3px) rotate(1.6deg); } }
@keyframes m-wave  { 0%,100% { transform: rotate(10deg); } 50% { transform: rotate(-44deg); } }
@keyframes m-point { 0%,100% { transform: rotate(-116deg); } 50% { transform: rotate(-130deg); } }
@keyframes m-earperk { 0% { transform: scaleY(1) rotate(0); } 100% { transform: scaleY(1.13) rotate(-3deg); } }
@keyframes m-eartwitch { 0%,88%,100% { transform: rotate(0); } 94% { transform: rotate(-7deg); } }
@keyframes m-eyewide { 0% { transform: scale(1); } 100% { transform: scale(1.22); } }
@keyframes m-cheekglow { 0% { transform: scale(1); } 100% { transform: scale(1.2); } }
@keyframes m-tailflick { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(7deg); } }
@keyframes m-spark { 0% { transform: scale(0.4) rotate(0); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(1.15) rotate(40deg); opacity: 0; } }

/* ── Responsive (portrait / smaller screens) ── */
@media (max-width: 700px), (max-aspect-ratio: 1/1) {
  body { padding: 0; }
  #app {
    width: 100vw; height: 100vh; height: 100dvh;
    border-width: 0; border-radius: 0; box-shadow: none;
  }
  .start-layout { flex-direction: column; padding: 30px 24px; }
  .start-mascot { flex: none; height: auto; width: 100%; max-height: 40vh; }
  #slot-start { max-width: 240px; max-height: 280px; }
  .start-content { padding-left: 0; text-align: center; }
  .start-title { font-size: 34px; }
  .start-sub { font-size: 18px; }
  .name-input { width: 100%; max-width: 300px; }
  .btn-start { width: 100%; max-width: 300px; font-size: 26px; height: 72px; margin-left: auto; margin-right: auto; }
  .map-sheet { flex-wrap: wrap; gap: 10px; }
  .sheet-div { display: none; }
  .btn-talk { width: 100%; }
  #screen-main.active { padding: 16px 20px 20px; }
  .sentence-box { flex-direction: column; gap: 12px; }
  .sentence-divider { align-self: auto; width: 80%; border-left: none; border-top: 3px dashed var(--divider); margin: 0; }
  .mic-area { flex-direction: row; width: auto; }
  .bubble-en { font-size: 28px; }
}

/* ── 홈 화면 비밀번호 필드 (배포 시에만 표시) ── */
.pin-home { margin-top: 14px; letter-spacing: 8px; }
.pin-error {
  margin-top: 10px;
  color: var(--rose); font-weight: 700; text-align: center;
  font-family: var(--font-ko); font-size: 16px;
  width: 330px;
}
