/* Talkster 기본 스타일 (모바일 우선) - 파스텔 하늘 + 동글동글 게임 UI */
:root {
  --sky-top: #a7aef3;
  --sky-mid: #cdb8f0;
  --sky-low: #f8c9e2;
  --card: #fffdf6;
  --ink: #3b2a1a;          /* 진한 갈색 외곽선·글자 */
  --sub: #7a6a8f;
  --main: #ff9f1c;         /* 주황 버튼 */
  --main-light: #ffd34d;
  --purple: #8b7cf6;
  --error: #e0345a;
  --font: "Jua", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --font-en: "Fredoka", "Jua", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  overflow-x: hidden;
}

/* ===== 배경 장식 ===== */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.cloud {
  position: absolute; width: 360px; height: 120px; border-radius: 999px;
  background: #fff6fb; opacity: 0.85;
  box-shadow: 0 6px 0 rgba(160, 130, 220, 0.25);
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 170px; height: 170px; left: 50px; top: -80px; }
.cloud::after { width: 130px; height: 130px; right: 50px; top: -55px; }
.cloud.c1 { left: -120px; bottom: 4%; background: #f6d9f2; }
.cloud.c2 { right: -140px; bottom: -2%; background: #cfe6fb; transform: scale(1.2); }
.cloud.c3 { right: 8%; top: 8%; transform: scale(0.45); background: #f3e6ff; }
.deco { position: absolute; font: 700 2.4rem var(--font-en); color: #ff8fa3; -webkit-text-stroke: 2px #fff; transform: rotate(-12deg); }
.deco.b { color: #7cc4ff; transform: rotate(10deg); }
.deco.c { color: #a3e06b; }
.star { position: absolute; font-size: 1.8rem; color: #ffe27a; text-shadow: 0 0 6px #fff; }
.twinkle { position: absolute; color: #fff; font-size: 1.2rem; animation: twinkle 2s ease-in-out infinite; }
.bubble {
  position: absolute; background: #fff; color: var(--purple); border-radius: 50%;
  width: 54px; height: 42px; display: grid; place-items: center; font-size: 1.4rem;
  box-shadow: 0 3px 0 rgba(120, 100, 200, 0.3);
}
@keyframes twinkle { 50% { opacity: 0.3; transform: scale(0.7); } }

/* ===== 로그인 ===== */
.login { position: relative; z-index: 1; width: 100%; max-width: 440px; margin: auto 0; padding: 12px 0; text-align: center; }

.logo {
  position: relative; z-index: 2;
  margin: 0 0 -28px;
  font: 700 clamp(3rem, 14vw, 4.6rem) var(--font-en);
  color: var(--main-light);
  background: linear-gradient(180deg, #ffe066 20%, #ff9f1c 85%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  /* 글자 테두리: 갈색 → 흰색 두 겹 (text-stroke는 글자끼리 겹치는 곳이 지저분해서 그림자로) */
  filter: drop-shadow(2px 0 0 var(--ink)) drop-shadow(-2px 0 0 var(--ink)) drop-shadow(0 2px 0 var(--ink)) drop-shadow(0 -2px 0 var(--ink))
          drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff)
          drop-shadow(0 6px 4px rgba(90, 50, 150, 0.35));
  letter-spacing: 1px;
}

.login-card {
  position: relative;
  padding: 44px 26px 22px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 246, 214, 0.95));
  border: 3px solid #fff;
  box-shadow: 0 12px 30px rgba(110, 80, 190, 0.25);
}
.sub { margin: 0 0 18px; font: 500 1.2rem var(--font-en); color: var(--ink); }

/* 카드 옆 몬스터 친구들 */
.buddy { position: absolute; pointer-events: none; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(80, 50, 140, 0.25)); }
.buddy.left { width: 120px; left: -70px; bottom: -30px; }
.buddy.right { width: 105px; right: -60px; bottom: -20px; animation-delay: -0.8s; }
.buddy.right-top { width: 95px; right: -55px; top: 40px; animation-delay: -1.6s; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@media (max-width: 560px) {
  .buddy.left { width: 84px; left: -14px; bottom: -48px; }
  .buddy.right { width: 76px; right: -12px; bottom: -44px; }
  .buddy.right-top { display: none; }
  .login-card { margin-bottom: 48px; }
}

.login form { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.pw-msg { margin: 0; font-size: 1.05rem; }
#pw-confirm-row { display: flex; flex-direction: column; }

.pill-input {
  font: 1.25rem var(--font);
  text-align: center;
  padding: 14px 18px;
  border-radius: 999px;
  border: 3px solid #cfc6ef;
  background: #fff;
  box-shadow: inset 0 3px 0 rgba(120, 100, 200, 0.12);
  outline: none;
}
.pill-input:focus { border-color: var(--purple); }
.pill-input::placeholder { color: #aaa1bf; }

/* 반짝이는 주황 큰 버튼 (START) */
.big-btn {
  position: relative;
  font: 700 1.9rem var(--font-en);
  letter-spacing: 1px;
  color: #fffbe8;
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink),
               1.5px 1.5px var(--ink), -1.5px -1.5px var(--ink), 1.5px -1.5px var(--ink), -1.5px 1.5px var(--ink);
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd54a 0%, #ffb02e 50%, #ff8c1a 100%);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.6), 0 5px 0 #c46a10, 0 8px 14px rgba(150, 80, 20, 0.3);
  cursor: pointer;
  transition: transform 0.08s;
}
.big-btn:active { transform: translateY(3px); box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.6), 0 2px 0 #c46a10; }
.big-btn:disabled { opacity: 0.6; cursor: wait; }

/* ===== 공통 (교사 화면·게임 임시 화면) ===== */
.card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px; margin-top: 6vh;
  background: var(--card);
  border: 3px solid #fff;
  border-radius: 28px;
  padding: 26px 22px;
  box-shadow: 0 12px 30px rgba(110, 80, 190, 0.25);
  text-align: center;
}
.card h1 { margin: 4px 0 16px; font: 700 2.2rem var(--font-en); color: var(--main); -webkit-text-stroke: 1.5px var(--ink); }
h2 { font-size: 1.2rem; }

.card form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
label { font-size: 1.05rem; }
.card input {
  font: 1.15rem var(--font);
  padding: 12px 16px;
  border: 3px solid #cfc6ef;
  border-radius: 16px;
  outline: none;
}
.card input:focus { border-color: var(--purple); }

button {
  font: 1.1rem var(--font);
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffd54a, #ff9f1c);
  color: var(--ink);
  box-shadow: 0 4px 0 #c46a10;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: wait; }
button.ghost { background: transparent; border: none; box-shadow: none; color: var(--sub); }
button.small { font-size: 0.95rem; padding: 6px 10px; }

.error { color: var(--error); min-height: 1.2em; margin: 12px 0 4px; }
.hint { color: var(--sub); font-size: 0.95rem; margin: 4px 0 0; }

.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  padding: 10px 16px;
  background: #fff3c4; color: #6b4e00;
  text-align: center; font-size: 0.95rem;
  border-bottom: 3px solid #ffd34d;
}

/* 상단 바 (2단계에서 XP·코인·기분 게이지가 들어갈 자리) */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 14px; margin: -8px -6px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffc1dc, #fff3a8 50%, #b9ecff);
  border: 3px solid #fff;
  font-size: 0.95rem;
}
#save-status { color: var(--sub); font-size: 0.85rem; }

/* ======================================================================
   2단계: 몬스터 고르기 · 부화 · 홈
   ====================================================================== */
.screen { position: relative; z-index: 1; width: 100%; max-width: 760px; padding-bottom: 140px; text-align: center; }
.screen-title { margin: 12px 0 4px; font-size: 1.6rem; color: #fff; text-shadow: 0 2px 0 rgba(80, 50, 140, 0.4); }
.screen-sub { margin: 0 0 14px; color: #fff; font-size: 1.05rem; text-shadow: 0 1px 0 rgba(80, 50, 140, 0.4); }

.species-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 700px) { .species-grid { grid-template-columns: repeat(6, 1fr); } }
.species-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border-radius: 20px; border: 3px solid #fff;
  background: linear-gradient(180deg, #fffdf6, #fff1c9); color: var(--ink); box-shadow: 0 5px 0 #d9c7f5;
}
.species-card img { width: 100%; max-width: 96px; aspect-ratio: 1; object-fit: contain; }
.species-card.picked { border-color: var(--main); box-shadow: 0 0 0 4px #ffd34d, 0 5px 0 #c46a10; transform: translateY(-3px); }
.sp-name { font: 600 0.95rem var(--font-en); }
.sp-ko { font-size: 0.8rem; color: var(--sub); }
.ph { display: inline-grid; place-items: center; font-size: 3rem; width: 100%; aspect-ratio: 1; }

.panel {
  margin-top: 14px; padding: 16px; border-radius: 24px; border: 3px solid #fff;
  background: rgba(255, 253, 246, 0.95); box-shadow: 0 10px 24px rgba(110, 80, 190, 0.2);
}
.detail-head { display: flex; gap: 14px; align-items: center; text-align: left; }
.detail-head img { width: 120px; height: 120px; object-fit: contain; }
.detail-head h3 { margin: 0 0 4px; font: 600 1.25rem var(--font-en); }
.detail-head p { margin: 0 0 8px; color: var(--sub); }
.mini-title { margin: 14px 0 6px; color: var(--sub); }
.preview-row { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.silhouette { width: 56px; height: 56px; object-fit: contain; filter: brightness(0) opacity(0.55); }
.secret { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #ece6ff; font-size: 1.6rem; }

.chip {
  font-size: 1rem; padding: 8px 14px; border-radius: 999px; border: 2px solid #cfc6ef;
  background: #fff; color: var(--ink); box-shadow: 0 3px 0 #d9c7f5;
}
.big-btn.small-big { font-size: 1.3rem; padding: 10px 26px; }
.row-btns { display: flex; justify-content: center; gap: 10px; align-items: center; }

/* 부화 */
.hatch-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4vh; }
.hatch-img { width: min(60vw, 260px); height: min(60vw, 260px); object-fit: contain; filter: drop-shadow(0 10px 10px rgba(80, 50, 140, 0.3)); }
.hatch-img.egg { animation: wobble 2.4s ease-in-out infinite; }
.hatch-img.crack { animation: shake 0.15s linear infinite; filter: brightness(1.4) drop-shadow(0 0 30px #fff7b0); }
.hatch-img.born { animation: born 0.8s ease-out; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes shake { 25% { transform: translateX(-6px) rotate(-4deg); } 75% { transform: translateX(6px) rotate(4deg); } }
@keyframes born { from { transform: scale(0.2); opacity: 0; filter: brightness(3); } }
.subtitle { color: #fff; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(60, 30, 120, 0.6); max-width: 420px; }

.bubble-box {
  position: relative; max-width: 420px; padding: 12px 18px; border-radius: 20px;
  background: #fff; border: 3px solid var(--ink); font: 600 1.15rem var(--font-en); color: var(--ink);
  box-shadow: 0 4px 0 rgba(60, 40, 20, 0.2);
}
.bubble-box:empty { visibility: hidden; }
.bubble-box::after {
  content: ""; position: absolute; left: 50%; bottom: -12px; width: 18px; height: 18px; background: #fff;
  border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: translateX(-50%) rotate(45deg);
}

/* 홈 */
.home { position: relative; z-index: 1; width: 100%; max-width: 980px; padding-bottom: 130px; }
body:has(#home:not([hidden])) { background: #f6e3c8; padding: 8px; }

.hud {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 22px; border: 3px solid #fff;
  background: linear-gradient(90deg, #ffc1dc, #fff3a8 50%, #b9ecff);
  box-shadow: 0 5px 14px rgba(150, 100, 60, 0.2);
}
.hud-logo { display: none; }
@media (min-width: 720px) {
  .hud { grid-template-columns: auto 1fr auto 1fr auto; }
  .hud-logo {
    display: block; font: 700 2rem var(--font-en); color: #ff8fb1;
    filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff);
  }
}
.hud-avatar {
  width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.3rem;
  background: #fff; border: 3px solid #8fa6d8; box-shadow: none;
}
.hud-gauge { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hud-star { display: grid; place-items: center; width: 34px; height: 34px; flex: none; font: 700 0.8rem var(--font-en);
  background: #ffd34d; color: var(--ink); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.bar { position: relative; flex: 1; min-width: 70px; height: 20px; border-radius: 999px; background: #fff; border: 2px solid #e0d2f5; overflow: hidden; }
.bar-label { position: absolute; inset: 0; display: grid; place-items: center; font: 600 0.72rem var(--font-en); color: var(--ink); white-space: nowrap; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s; }
.bar-fill.xp { background: linear-gradient(90deg, #ffd34d, #ff5d8f); }
.hud-label { font-size: 0.8rem; white-space: nowrap; }
.hud-coin { font-size: 1.4rem; }
.hud-num { font: 700 1.1rem var(--font-en); }
@media (max-width: 719px) { .wide-only { display: none; } }

.mission { margin: 8px auto 0; padding: 6px 12px; max-width: 600px; border-radius: 999px; background: #fff7d6; border: 2px solid #ffd34d; font-size: 0.95rem; text-align: center; }

/* 정면에서 본 몬스터 방: 옆벽(배경) + 뒷벽 + 창문 + 바닥 */
.room {
  position: relative; margin-top: 8px; width: 100%; aspect-ratio: 16 / 9; max-height: 66vh;
  overflow: hidden; border-radius: 24px; border: 3px solid #fff;
  background: linear-gradient(90deg, #e9c497, #f6dcb9 15%, #f6dcb9 85%, #e9c497);
  box-shadow: 0 8px 20px rgba(150, 100, 60, 0.2);
}
.backwall {
  position: absolute; left: 15%; right: 15%; top: 0; bottom: 42%;
  background: linear-gradient(180deg, #fdf0dc, #f9e4c6);
  border-left: 3px solid #e2bd8f; border-right: 3px solid #e2bd8f; border-bottom: 3px solid #d9a774;
}
.window {
  position: absolute; left: 50%; top: 10%; width: 30%; height: 62%; transform: translateX(-50%);
  border: 6px solid #f3d8a8; border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 47%, #f3d8a8 47% 53%, transparent 53%),
    linear-gradient(180deg, transparent 47%, #f3d8a8 47% 53%, transparent 53%),
    linear-gradient(180deg, #fffbe9, #fff1c2);
  box-shadow: 0 0 40px 10px rgba(255, 240, 180, 0.7);
}
.poster {
  position: absolute; right: 8%; top: 12%; width: 15%; aspect-ratio: 3 / 4; padding: 4%;
  background: #fffdf6; border: 2px solid #e2cfb0; transform: rotate(3deg); box-shadow: 0 3px 6px rgba(120, 80, 40, 0.2);
}
.poster img { width: 100%; height: 100%; object-fit: contain; }
.poster .ph { font-size: 1.6rem; }
.floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 42%;
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
  background:
    repeating-linear-gradient(90deg, transparent 0 11%, rgba(170, 110, 60, 0.12) 11% 11.4%),
    linear-gradient(180deg, #f1c995, #e6b47c);
}
.sunlight {
  position: absolute; left: 35%; right: 35%; top: 34%; bottom: 0; pointer-events: none;
  clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(255, 246, 200, 0.55), rgba(255, 246, 200, 0));
}

/* 가구 자리 (PC: 가로 방) */
.furn { position: absolute; z-index: 1; object-fit: contain; filter: drop-shadow(0 6px 4px rgba(110, 70, 30, 0.25)); }
.f-bookshelf { left: 1%; bottom: 10%; width: 20%; }
.f-bed { left: 20%; bottom: 33%; width: 22%; }
.f-plant { right: 25%; bottom: 36%; width: 10%; }
.f-sofa { right: 6%; bottom: 17%; width: 23%; }
.f-lamp { right: 0; bottom: 2%; width: 12%; }
.f-rug { left: 50%; bottom: 4%; width: 38%; transform: translateX(-50%); z-index: 0; filter: none; }
.you-said {
  position: absolute; right: 2%; bottom: 4%; z-index: 3; max-width: 46%; padding: 6px 12px; border-radius: 14px;
  background: rgba(123, 92, 255, 0.92); color: #fff; font: 500 0.95rem var(--font-en);
}
.monster { position: absolute; left: 50%; bottom: 9%; width: 25%; max-width: 280px; transform: translateX(-50%); z-index: 2; }
.monster .mon-body { transform-origin: 50% 100%; }
.monster .mon-base { filter: drop-shadow(0 12px 8px rgba(90, 60, 30, 0.3)); }
.monster .ph { font-size: 6rem; }
/* 표정 대신 움직임 */
.monster.idle .mon-body { animation: breathe 3s ease-in-out infinite; }
.monster.happy .mon-body { animation: hop 0.6s ease-in-out 3; }
.monster.excited .mon-body { animation: wiggle 0.25s linear 6; }
.monster.curious .mon-body { animation: tilt 1.6s ease-in-out infinite; }
.monster.sleepy .mon-body { animation: droop 3s ease-in-out infinite; }
.monster.surprised .mon-body { animation: pop 0.4s ease-out; }
.monster.sad .mon-body { transform: translateY(6px) scaleY(0.94); filter: saturate(0.7); }
.monster.caring .mon-body { animation: nod 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.02, 0.98); } }
@keyframes hop { 50% { transform: translateY(-14%); } }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes tilt { 50% { transform: rotate(-8deg); } }
@keyframes droop { 50% { transform: scale(1.04, 0.9); } }
@keyframes pop { 50% { transform: scale(1.15); } }
@keyframes nod { 50% { transform: translateY(4%) rotate(2deg); } }

.popups { position: absolute; left: 50%; top: 35%; z-index: 4; pointer-events: none; }
.popup {
  position: absolute; left: -60px; width: 120px; text-align: center; font: 700 1.3rem var(--font-en); color: #ff7a00;
  text-shadow: 2px 0 #fff, -2px 0 #fff, 0 2px #fff, 0 -2px #fff; animation: rise 1.8s ease-out forwards;
}
.popup:nth-child(2) { margin-left: 70px; } .popup:nth-child(3) { margin-left: -70px; } .popup:nth-child(4) { margin-left: 120px; }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-90px); opacity: 0; } }
.save-status { margin: 4px 0 0; text-align: center; color: #9a8466; font-size: 0.8rem; }

/* 아래쪽 말하기 도구 */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;   /* 팝업 창(따라 말하기) 위에서도 마이크를 누를 수 있게 */
  display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; gap: 14px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.mic-btn {
  width: 92px; height: 92px; border-radius: 50%; font-size: 2.6rem; padding: 0;
  border: 4px solid var(--ink); background: radial-gradient(circle at 35% 30%, #ffe27a, #ffb02e 55%, #ff8c1a);
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.6), 0 6px 0 #c46a10, 0 0 0 8px rgba(255, 255, 255, 0.6);
}
.mic-btn.listening { animation: listening 0.9s ease-in-out infinite; }
@keyframes listening {
  0%, 100% { box-shadow: inset 0 5px 0 rgba(255,255,255,0.6), 0 6px 0 #c46a10, 0 0 0 8px rgba(255, 93, 143, 0.5); }
  50% { box-shadow: inset 0 5px 0 rgba(255,255,255,0.6), 0 6px 0 #c46a10, 0 0 0 22px rgba(255, 93, 143, 0.15); }
}
.side-btn {
  display: flex; align-items: center; gap: 6px; height: 58px; padding: 0 16px; border-radius: 18px;
  font-size: 1.05rem; background: linear-gradient(180deg, #7fdcff, #3fb4ec); color: #fff;
  border: 3px solid #1f5c86; box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.5), 0 5px 0 #1f5c86;
  text-shadow: 0 1px 0 #1f5c86;
}
.side-btn span { white-space: nowrap; }
@media (max-width: 420px) { .side-btn { flex-direction: column; justify-content: center; gap: 0; height: 64px; padding: 0 10px; font-size: 0.85rem; } }
.type-toggle { position: absolute; right: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 44px; height: 44px; padding: 0; border-radius: 50%; background: #fff; border: 2px solid #cfc6ef; box-shadow: none; }
.type-toggle.nudge { animation: pop 0.6s ease-in-out 3; border-color: var(--main); }
.type-form { flex-basis: 100%; display: flex; gap: 8px; max-width: 520px; margin: 0 auto; flex-direction: row; }
.type-form input { flex: 1; font: 1.05rem var(--font); padding: 10px 14px; border-radius: 999px; border: 3px solid #cfc6ef; }
.type-form button { border-radius: 999px; padding: 8px 16px; }

/* 팝업 창 */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px 16px 130px; background: rgba(40, 20, 80, 0.45); }
.modal-box { position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 160px); overflow: auto; padding: 20px; border-radius: 24px; background: var(--card); border: 3px solid #fff; text-align: center; }
.modal-close { position: absolute; z-index: 5; right: 10px; top: 10px; width: 40px; height: 40px; padding: 0; border-radius: 12px; background: #ff8f8f; color: #fff; border: 2px solid #b54848; box-shadow: 0 3px 0 #b54848; }
.modal-box h3 { margin: 4px 0 12px; font-size: 1.3rem; }
.modal-box small { color: var(--sub); font-size: 0.85rem; }
.stat-list { list-style: none; padding: 0; margin: 0 0 10px; text-align: left; }
.stat-list li { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 12px; }
.stat-list li:nth-child(odd) { background: #fff4dc; }
.follow-line { font: 600 1.5rem var(--font-en); margin: 8px 0 12px; }
.follow-result { min-height: 1.4em; font-size: 1.1rem; }
.settings-list { display: flex; flex-direction: column; gap: 10px; }

/* 진화 연출 */
.evolve { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; background: radial-gradient(circle, #3a2a7a, #120a30); overflow: hidden; }
.evolve-rays { position: absolute; width: 220vmax; height: 220vmax; background: repeating-conic-gradient(rgba(255, 240, 160, 0.25) 0 8deg, transparent 8deg 20deg); animation: spin 8s linear infinite; }
.evolve-img { position: relative; width: min(60vw, 280px); height: min(60vw, 280px); object-fit: contain; }
.evolve.charging .evolve-img { animation: evo-spin 2.6s ease-in forwards; }
.evolve.flash .evolve-img { animation: born 0.9s ease-out; filter: drop-shadow(0 0 24px #fff3a0); }
.evolve.flash::after { content: ""; position: absolute; inset: 0; background: #fff; animation: flash 0.8s ease-out forwards; pointer-events: none; }
.evolve-text { position: relative; color: #fff; font-size: 1.2rem; text-align: center; line-height: 1.6; }
.evolve .big-btn { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes evo-spin { to { transform: rotate(1080deg) scale(0.6); filter: brightness(10); } }
@keyframes flash { to { opacity: 0; } }

.toast {
  position: fixed; left: 50%; top: 14px; z-index: 40; transform: translateX(-50%); max-width: 92vw;
  padding: 10px 16px; border-radius: 16px; background: rgba(43, 35, 80, 0.92); color: #fff; font-size: 1rem; text-align: center;
}

@media (max-width: 719px) {
  /* 휴대폰: 세로로 긴 방, 가구는 양옆으로 */
  .room { aspect-ratio: 4 / 5; max-height: calc(100vh - 250px); }
  .backwall { bottom: 46%; }
  .window { width: 40%; height: 54%; }
  .poster { right: 5%; width: 20%; }
  .floor { height: 46%; }
  .sunlight { top: 30%; }
  .f-bookshelf { left: -3%; bottom: 30%; width: 30%; }
  .f-bed { left: 16%; bottom: 47%; width: 34%; }
  .f-plant { right: 18%; bottom: 50%; width: 15%; }
  .f-sofa { right: -5%; bottom: 25%; width: 36%; }
  .f-lamp { right: -2%; bottom: 2%; width: 19%; }
  .f-rug { bottom: 6%; width: 74%; }
  .monster { width: 52%; bottom: 8%; }
}

/* ======================================================================
   3단계: 대화 (말풍선 묶음, 차원 상태, 글리치, 위험 카드)
   ====================================================================== */
.bubble-wrap { position: absolute; left: 50%; top: 3%; transform: translateX(-50%); z-index: 3; width: max-content; max-width: 86%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bubble-wrap .bubble-box { text-align: center; }
.bubble-box.receiving::after { animation: pop 0.6s ease-in-out infinite; }
.bubble-box.receiving { color: var(--purple); }
.room-sub { max-width: 100%; padding: 2px 10px; border-radius: 10px; background: rgba(43, 35, 80, 0.75); color: #fff; font-size: 0.9rem; text-align: center; }
.room-sub:empty { display: none; }
.chip.tiny { font-size: 0.85rem; padding: 4px 10px; }
.dim-status { position: absolute; left: 10px; top: 10px; z-index: 3; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.85); font-size: 1.3rem; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1); }
.share-btn { position: absolute; left: 10px; bottom: 10px; z-index: 3; font: 600 0.85rem var(--font-en); padding: 6px 12px; border-radius: 999px; border: 2px solid #f3a6c3; background: #fff0f6; color: #b23a6b; box-shadow: 0 3px 0 #f3a6c3; }
.you-said { bottom: 12%; }

/* 차원 흔들림 */
.room.glitch { animation: glitch 0.12s steps(2) 10; }
.room.glitch .monster img { filter: blur(2px) opacity(0.6) hue-rotate(90deg); }
@keyframes glitch {
  0% { transform: translate(0); filter: none; }
  50% { transform: translate(-4px, 2px) skewX(3deg); filter: hue-rotate(60deg) contrast(1.4); }
  100% { transform: translate(3px, -2px); }
}
.room.sparkle::after { content: "✨ ✨ ✨"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; letter-spacing: 1em; z-index: 4; animation: rise 1.6s ease-out forwards; pointer-events: none; }

/* 위험 신호 상담 카드: 눈에 잘 띄게 */
.risk-card { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(40, 20, 80, 0.55); }
.risk-box { width: 100%; max-width: 440px; padding: 22px; border-radius: 24px; background: #fffaf0; border: 4px solid #ffb4c8; text-align: center; }
.risk-box h3 { margin: 0 0 10px; font-size: 1.3rem; }
.risk-box p { font-size: 1.05rem; line-height: 1.6; }
.risk-lines { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.risk-call { display: block; padding: 12px; border-radius: 16px; background: #e8f6ff; border: 3px solid #5ab4e6; color: #12476b; font-size: 1.2rem; text-decoration: none; }
.risk-call.urgent { background: #fff0f0; border-color: #ff8f8f; color: #8a1f1f; }
#set-end { z-index: 22; }

/* ======================================================================
   4단계: 꾸미기 아이템, 상점, 방 꾸미기, 친구 방
   ====================================================================== */
.mon-box { position: relative; width: 100%; aspect-ratio: 1; }
.mon-box .mon-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mon-box .layer { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.mon-box .layer-effect { position: absolute; inset: -8%; width: 116%; height: 116%; object-fit: contain; animation: spin 20s linear infinite; opacity: 0.9; }
.mon-box .title-badge { position: absolute; left: 50%; bottom: -4%; transform: translateX(-50%); white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: #ffd34d; border: 2px solid var(--ink); font: 600 0.8rem var(--font-en); }
.mon-box .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 5rem; }

.room.custom-wall .backwall { background: var(--wall); }
.room.custom-floor .floor { background: repeating-linear-gradient(90deg, transparent 0 11%, rgba(0, 0, 0, 0.06) 11% 11.4%), var(--floor); }
.corner-btn { position: absolute; right: 10px; bottom: 10px; z-index: 3; font-size: 0.9rem; padding: 6px 12px; border-radius: 999px; border: 2px solid #9fc9e8; background: #eef8ff; color: #1f5c86; box-shadow: 0 3px 0 #9fc9e8; }

.modal-box.wide { max-width: 760px; }
.shop { display: grid; gap: 10px; }
.shop-preview { position: relative; display: flex; justify-content: center; }
.shop-preview .mon-box { width: 170px; }
.shop-coins { position: absolute; left: 0; top: 0; padding: 4px 12px; border-radius: 999px; background: #fff3c4; border: 2px solid #ffd34d; font: 600 1.1rem var(--font-en); }
.shop-tabs { display: flex; gap: 6px; justify-content: center; }
.shop-tabs button { flex: 1; padding: 8px 4px; border-radius: 14px; font: 600 0.95rem var(--font-en); background: #bfe9f7; border: 3px solid #1f5c86; box-shadow: 0 3px 0 #1f5c86; color: #12476b; }
.shop-tabs button.on { background: linear-gradient(180deg, #ffd54a, #ff9f1c); border-color: var(--ink); box-shadow: 0 3px 0 #c46a10; color: var(--ink); }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 36vh; overflow: auto; padding: 4px; }
.item-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 16px; background: #fff7e6; border: 3px solid #f0dcb8; box-shadow: none; color: var(--ink); }
.item-card img, .item-card .swatch { width: 56px; height: 56px; object-fit: contain; }
.item-card .swatch { display: grid; place-items: center; border-radius: 12px; border: 2px solid #e0d2f5; font-size: 1.6rem; }
.item-card.on { border-color: var(--main); background: #fff0c9; box-shadow: 0 0 0 3px #ffd34d; }
.item-card.locked { opacity: 0.55; }
.item-name { font: 500 0.75rem var(--font-en); line-height: 1.1; }
.item-badge { font-size: 0.75rem; color: var(--sub); }
.filter-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.chip.on { background: #ffd34d; border-color: #c46a10; }
.clerk { display: flex; align-items: center; gap: 10px; justify-content: center; }
.clerk-face { font-size: 3rem; }
.clerk .bubble-box { font-size: 1rem; margin: 0; }
.clerk .bubble-box::after { display: none; }
.mini-room { margin: 0 auto 8px; max-width: 520px; aspect-ratio: 16 / 9 !important; max-height: none !important; }
.mini-room .mini-mon { position: absolute; left: 50%; bottom: 6%; width: 26%; transform: translateX(-50%); z-index: 2; }
.friend-list { display: flex; flex-direction: column; gap: 8px; }
.gb-write { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.gb-write select, .gb-write input { font: 1rem var(--font); padding: 8px 10px; border-radius: 12px; border: 2px solid #cfc6ef; }
.gb-list { list-style: none; padding: 0; text-align: left; max-height: 24vh; overflow: auto; }
.gb-list li { padding: 6px 10px; border-radius: 10px; background: #fff4dc; margin-bottom: 4px; font-family: var(--font-en); }

/* 아이템 위치 맞추기 */
.fit-panel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border-radius: 16px; background: #f4f0ff; }
.fit-panel:empty { display: none; }
.fit-row { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 320px; font-size: 0.95rem; }
.fit-row input { flex: 1; }
.mon-box.draggable { cursor: grab; touch-action: none; }

/* ======================================================================
   6단계: 2.5D (Three.js 캔버스). 3D가 켜지면 2D 장식은 숨김
   ====================================================================== */
.stage3d { position: absolute; inset: 0; width: 100% !important; height: 100% !important; z-index: 1; display: block; touch-action: pan-y; }
.room.is3d > .backwall, .room.is3d > .floor, .room.is3d > .sunlight, .room.is3d > .furniture, .room.is3d > .monster { display: none; }
.room.is3d .bubble-wrap, .room.is3d .you-said, .room.is3d .dim-status, .room.is3d .share-btn, .room.is3d .corner-btn, .room.is3d .popups { z-index: 4; }
.room.is3d { background: #f6dcb9; }
.evolve-3d { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.evolve.is3d .evolve-img, .evolve.is3d .evolve-rays { display: none; }
.evolve-text, .evolve .big-btn { z-index: 2; }
.evolve.is3d .evolve-text { margin-top: 62vh; }

/* 모습 고르기 */
.look-panel { padding: 8px; border-radius: 16px; background: #fff4dc; }
.look-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.look-card { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 6px; border-radius: 14px; border: 3px solid #f0dcb8; background: #fff; box-shadow: none; color: var(--ink); font-size: 0.75rem; }
.look-card img { width: 60px; height: 60px; object-fit: contain; }
.look-card.on { border-color: var(--main); box-shadow: 0 0 0 3px #ffd34d; }
.look-card.locked img { filter: brightness(0) opacity(0.35); }
.look-card.locked { opacity: 0.8; }
