/* 몽글시티 공용 모양 v0.1.5 — "말랑이": 크림 바탕, 둥근 모서리 20px, 굵은 선 대신 부드러운 그림자, 누르면 살짝 납작.
   부품 이름과 변수는 styles/README.md 에 적어 두었습니다. 단추는 손가락 기준 48px 넘게. */
:root {
  /* 말랑이 변수(새 이름 — 오퍼스A의 꾸미기 화면도 이것을 씀) */
  --m-bg: #fbefe6;           /* 화면 바탕 크림 */
  --m-bg-2: #f6e4d4;         /* 바탕 아래쪽 */
  --m-card: #fffaf5;         /* 카드·창 */
  --m-card-2: #f7ede2;       /* 카드 안 오목한 칸 */
  --m-ink: #5b3a2e;          /* 글씨 */
  --m-sub: #a08578;          /* 흐린 글씨 */
  --m-hair: rgba(122, 59, 74, .10);   /* 아주 옅은 테 */
  --m-accent: #f58fa6;       /* 고른 것·강조(분홍) */
  --m-accent-2: #f08a7a;     /* 산호 */
  --m-go: #6fbf73;           /* 하기 단추 */
  --m-go-2: #8fd48a;
  --m-teal: #2f6b62;         /* 청록(지붕·차양) */
  --m-sage: #7fa987;
  --m-butter: #f6d766;
  --m-navy: #4a5f9a;
  --m-sky: #bfe3ee;
  --m-radius: 20px;
  --m-radius-s: 14px;
  --m-shadow: 0 8px 22px rgba(122, 59, 74, .14), 0 2px 5px rgba(122, 59, 74, .08);
  --m-shadow-s: 0 4px 10px rgba(122, 59, 74, .12), 0 1px 2px rgba(122, 59, 74, .08);
  --m-shadow-in: inset 0 2px 0 rgba(255, 255, 255, .75), inset 0 -3px 0 rgba(122, 59, 74, .10);
  --m-press: scale(1.02, .96);

  /* 옛 이름(패널들이 씀) — 새 색에 맞춰 둠 */
  --cream: var(--m-bg); --paper: var(--m-card); --sand: #f3e6d0; --ink: var(--m-ink); --line: #6b4a3a; --muted: var(--m-sub);
  --green: var(--m-go); --green-d: #4f9a55; --pink: var(--m-accent); --pink-l: #fbd3dc; --yellow: var(--m-butter); --yellow-l: #fff1c4;
  --sky: #7fc9e8; --sky-l: #dcf1f8; --red: #e2685c; --lilac: #c9a0e8;
  --r: var(--m-radius); --shadow: var(--m-shadow-s);
  --font: 'Noto Sans CJK KR', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--m-bg); color: var(--m-ink); font-family: var(--font);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
input, textarea { user-select: text; -webkit-user-select: text; font-family: var(--font); }
button { font-family: var(--font); }
.muted { color: var(--m-sub); }
.hidden { display: none !important; }

/* ───── 겹 ───── */
#game { position: fixed; inset: 0; background: #cfe3c0; }
#game canvas { display: block; }
#screens { position: fixed; inset: 0; z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#screens:empty { display: none; }
#hud, #bottombar, #noticebar { z-index: 30; }
#panels { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#panels > * { pointer-events: auto; }
#modals { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#modals > * { pointer-events: auto; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(76px + var(--safe-t)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
/* 버전 표시: 오른쪽 아래, 늘 보임 */
#version { position: fixed; right: 8px; bottom: calc(5px + var(--safe-b)); z-index: 90; font-size: 12px; font-weight: 900; color: var(--m-ink);
  background: rgba(255, 250, 245, .9); border-radius: 999px; padding: 2px 10px; pointer-events: none; letter-spacing: .5px; box-shadow: var(--m-shadow-s); }

/* ───── 단추(말랑이) ───── */
.btn { min-height: 52px; min-width: 52px; padding: 8px 18px; border-radius: 18px; border: none; color: var(--m-ink); font-size: 18px; font-weight: 800; cursor: pointer;
  background: linear-gradient(#ffffff, #f7eee6); box-shadow: var(--m-shadow-in), var(--m-shadow-s);
  transition: transform .09s ease, box-shadow .09s, filter .09s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.2; }
.btn:active:not(:disabled) { transform: var(--m-press); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), inset 0 -1px 0 rgba(122, 59, 74, .1), 0 1px 3px rgba(122, 59, 74, .12); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible { outline: 3px solid rgba(245, 143, 166, .6); outline-offset: 2px; }
.btn-go { background: linear-gradient(#8fd48a, #63b768); color: #fff; text-shadow: 0 1px 1px rgba(40, 90, 40, .45); }
.btn-warn { background: linear-gradient(#f39a8c, #e2685c); color: #fff; text-shadow: 0 1px 1px rgba(120, 40, 30, .35); }
.btn-money { background: linear-gradient(#fbe68a, #f2cf4f); }
.btn-plain { background: linear-gradient(#ffffff, #f7eee6); }
.btn-pink { background: linear-gradient(#f9a9bb, #f07f9a); color: #fff; text-shadow: 0 1px 1px rgba(140, 50, 70, .35); }
.btn-sky { background: linear-gradient(#9ad7ee, #6bbbe0); color: #fff; text-shadow: 0 1px 1px rgba(40, 80, 110, .4); }
.btn-teal { background: linear-gradient(#4c8f84, #2f6b62); color: #fff; }
.btn-wide { width: 100%; }
.btn-big { min-height: 64px; font-size: 22px; border-radius: 22px; }
.btn .ic { flex: none; }

/* ───── 화면 공통 ───── */
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: calc(18px + var(--safe-t)) 16px calc(44px + var(--safe-b));
  background: radial-gradient(circle at 18% 8%, rgba(255, 236, 190, .9) 0, transparent 38%), radial-gradient(circle at 88% 92%, rgba(255, 210, 222, .8) 0, transparent 42%), linear-gradient(var(--m-bg), var(--m-bg-2)); }
/* 첫 화면들: 말랑이 도시 그림을 뒤에 깔고 크림 안개를 덮음 */
.screen.scene-bg { background: linear-gradient(rgba(251, 239, 230, .08) 0, rgba(251, 239, 230, .28) 42vh, rgba(251, 239, 230, .78) 72vh, var(--m-bg) 100vh), url('/assets/ui/title.webp') center top / max(100vw, 179vh) auto no-repeat, var(--m-bg); background-attachment: local; }
.card { width: min(100%, 460px); background: var(--m-card); border: none; border-radius: 26px; box-shadow: var(--m-shadow); padding: 20px; margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 800; font-size: 16px; }
.field input { min-height: 54px; border-radius: 16px; border: 2px solid transparent; padding: 0 14px; font-size: 20px; background: var(--m-card-2); color: var(--m-ink); outline: none;
  box-shadow: inset 0 2px 4px rgba(122, 59, 74, .08); transition: border-color .15s, box-shadow .15s, background .15s; }
.field input:focus { border-color: #9fd59a; background: #fff; box-shadow: 0 0 0 4px rgba(111, 191, 115, .18); }
.field .hint { font-weight: 600; font-size: 13px; color: var(--m-sub); }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.check input { width: 28px; height: 28px; accent-color: var(--m-go); }
.row { display: flex; gap: 10px; align-items: center; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.err-text { color: #d2584c; font-weight: 800; min-height: 22px; margin: 4px 0 8px; }

/* 제목 글자: 찹쌀떡처럼 통통한 분홍 글자 */
.logo { display: flex; flex-direction: column; align-items: center; margin-top: 8px; padding-bottom: 8px; }
.logo-title { font-size: clamp(54px, 15vw, 84px); font-weight: 900; letter-spacing: 6px; margin: 0; line-height: 1.1;
  color: #fff; -webkit-text-stroke: 0; paint-order: stroke fill;
  text-shadow: 0 2px 0 #f7a3b6, 0 4px 0 #f08aa2, 0 6px 0 #e57592, 0 12px 18px rgba(180, 70, 100, .35); }
.logo-sub { font-weight: 800; font-size: 17px; margin: 8px 0 0; color: var(--m-ink); background: rgba(255, 250, 245, .8); padding: 4px 14px; border-radius: 999px; box-shadow: var(--m-shadow-s); }
.logo-stage { position: relative; width: min(92vw, 420px); height: 210px; margin-top: 8px; }
.logo-stage::after { content: ''; position: absolute; left: 12%; right: 12%; bottom: 2px; height: 22px; border-radius: 50%; background: radial-gradient(ellipse, rgba(122, 59, 74, .22), transparent 70%); }
.logo-stage canvas { position: absolute; bottom: 0; z-index: 1; }

/* "누구예요?" */
.who { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: min(100%, 420px); margin-top: 12px; }
.who-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px; min-height: 150px; border-radius: 24px; border: none;
  background: var(--m-card); box-shadow: var(--m-shadow-in), var(--m-shadow); font-size: 18px; font-weight: 800; color: var(--m-ink); cursor: pointer; transition: transform .09s; }
.who-btn:active { transform: var(--m-press); }
.who-btn canvas { width: 96px; height: 96px; border-radius: 50%; background: #fff3e6; }

/* 로비 */
.ch-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: none; border-radius: 20px; background: #fff; margin-bottom: 12px; box-shadow: var(--m-shadow-s); }
.ch-card > .ic { background: linear-gradient(#e6f4ea, #cfe9dc); border-radius: 16px; padding: 4px; }
.ch-card .ch-name { font-size: 20px; font-weight: 900; }
.ch-card .ch-meta { font-size: 14px; color: var(--m-sub); font-weight: 700; }
.ch-card .grow { flex: 1; min-width: 0; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 16px; }
.numpad .btn { font-size: 26px; min-height: 60px; }
.code-boxes { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.code-box { width: 44px; height: 56px; border: none; border-radius: 14px; background: var(--m-card-2); box-shadow: inset 0 2px 4px rgba(122, 59, 74, .1); font-size: 30px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.code-box.on { background: #fff; box-shadow: 0 0 0 3px rgba(111, 191, 115, .45); }

/* ───── 캐릭터 만들기(오퍼스A가 덮어 쓸 수 있음) ───── */
.creator { width: min(100%, 980px); display: flex; flex-direction: column; gap: 12px; }
.cr-stage { position: relative; background: radial-gradient(ellipse at 50% 86%, #d4ecc2 0 36%, transparent 37%), linear-gradient(#e4f3fb, #fff4e8);
  border: none; border-radius: 28px; box-shadow: var(--m-shadow); display: flex; align-items: center; justify-content: center; height: 300px; overflow: hidden; }
.cr-stage canvas { width: 200px; height: 300px; }
.cr-stage .cr-tools { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 10px; }
.cr-stage .cr-tools-l { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 10px; }
.cr-tools .btn, .cr-tools-l .btn { padding: 6px; width: 58px; height: 58px; }
.cr-side { display: flex; flex-direction: column; gap: 10px; }
.cr-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.part-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 112px; padding: 4px 2px 6px; border-radius: 20px;
  border: none; background: #fff; box-shadow: var(--m-shadow-s); font-size: 13px; font-weight: 800; color: var(--m-ink); cursor: pointer; transition: transform .09s; }
.part-btn:active { transform: var(--m-press); }
.part-btn canvas { width: 64px; height: 80px; }
.part-btn.on { background: #fff4f6; box-shadow: 0 0 0 3px var(--m-accent), var(--m-shadow-s); }
.part-btn.locked { opacity: .55; }
.part-btn .price { position: absolute; top: 4px; right: 4px; background: var(--m-butter); border-radius: 10px; font-size: 11px; padding: 0 6px; box-shadow: var(--m-shadow-s); }
.cr-label { font-weight: 900; font-size: 16px; margin: 6px 0 2px; }
.cr-name { display: flex; gap: 10px; align-items: flex-end; }
.cr-name .field { flex: 1; margin: 0; }
@media (min-width: 820px) and (orientation: landscape) {
  .creator { flex-direction: row; align-items: flex-start; }
  .cr-stage { width: 360px; height: calc(100vh - 80px); max-height: 640px; position: sticky; top: 0; flex: none; }
  .cr-stage canvas { width: 280px; height: 420px; }
  .cr-side { flex: 1; min-width: 0; }
}

/* ───── 탭(작은 탭 .tabs/.tab · 큰 갈래 탭 .tabs.tabs-big) ───── */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 48px; padding: 0 16px; border-radius: 999px; border: none; background: rgba(255, 255, 255, .7); box-shadow: var(--m-shadow-s);
  font-weight: 800; font-size: 17px; color: var(--m-sub); cursor: pointer; transition: transform .09s, background .15s, color .15s; }
.tab:active { transform: var(--m-press); }
.tab.on { background: linear-gradient(#ffd3dd, #f9b4c4); color: var(--m-ink); box-shadow: var(--m-shadow-in), var(--m-shadow-s); }
.tabs.tabs-big { background: var(--m-card-2); border-radius: 22px; padding: 5px; gap: 4px; box-shadow: inset 0 2px 5px rgba(122, 59, 74, .08); }
.tabs.tabs-big .tab { flex: 1; min-height: 52px; border-radius: 18px; background: transparent; box-shadow: none; font-size: 18px; }
.tabs.tabs-big .tab.on { background: #fff; color: var(--m-ink); box-shadow: var(--m-shadow-s); }

/* ───── 견본 격자 .m-grid / .m-tile ───── */
.m-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 72px), 1fr)); gap: 10px; }
.m-tile { position: relative; aspect-ratio: 1 / 1; min-height: 64px; border-radius: 18px; border: none; background: #fff; box-shadow: var(--m-shadow-s); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; color: var(--m-ink); font-weight: 800; font-size: 12px; transition: transform .09s; overflow: hidden; }
.m-tile:active { transform: var(--m-press); }
.m-tile canvas, .m-tile img { max-width: 92%; max-height: 78%; }
.m-tile.on { background: #fff4f6; box-shadow: 0 0 0 3px var(--m-accent), var(--m-shadow-s); }
.m-tile.locked > canvas, .m-tile.locked > img { opacity: .5; }
.m-tile .m-lock { position: absolute; left: 4px; top: 4px; font-size: 13px; }
.m-tile .m-price { position: absolute; right: 4px; top: 4px; background: var(--m-butter); border-radius: 999px; font-size: 11px; font-weight: 900; padding: 0 6px; }
.m-tile .m-tile-label { font-size: 12px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ───── 색 동그라미 .swatches / .swatch ───── */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 48px; height: 48px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .08), inset 0 3px 0 rgba(255, 255, 255, .35), var(--m-shadow-s); transition: transform .09s; }
.swatch:active { transform: scale(.92); }
.swatch.on { box-shadow: 0 0 0 3px var(--m-accent), inset 0 -5px 0 rgba(0, 0, 0, .08), var(--m-shadow-s); transform: scale(1.06); }

/* ───── 미닫이 .m-slider ───── */
.m-slider { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.m-slider-label { font-weight: 900; font-size: 16px; min-width: 64px; }
.m-slider input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 14px; border-radius: 999px; background: var(--m-card-2);
  box-shadow: inset 0 2px 4px rgba(122, 59, 74, .12); outline: none; margin: 0; }
.m-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, #ffc2cf 19%, #f58fa6 80%); box-shadow: 0 3px 8px rgba(180, 70, 100, .35); }
.m-slider input[type=range]::-moz-range-thumb { width: 36px; height: 36px; border-radius: 50%; border: none; background: #f58fa6; box-shadow: 0 3px 8px rgba(180, 70, 100, .35); }
.m-slider-value { min-width: 46px; text-align: right; font-weight: 900; font-size: 16px; color: var(--m-sub); }

/* ───── 카드·칩 ───── */
.m-card { background: var(--m-card); border-radius: var(--m-radius); box-shadow: var(--m-shadow); padding: 16px; }
.m-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--m-card); border-radius: 999px; padding: 4px 12px; font-weight: 800; box-shadow: var(--m-shadow-s); }
.m-press { transition: transform .09s; cursor: pointer; }
.m-press:active { transform: var(--m-press); }

/* ───── 위쪽 띠(HUD) ───── */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(8px + var(--safe-t)) 8px 6px; display: flex; gap: 6px; align-items: flex-start; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-chip { display: flex; align-items: center; gap: 6px; background: rgba(255, 250, 245, .94); border: none; border-radius: 22px; padding: 4px 12px 4px 4px;
  box-shadow: var(--m-shadow-in), var(--m-shadow); font-weight: 900; font-size: 16px; min-height: 48px; color: var(--m-ink); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
button.hud-chip { cursor: pointer; transition: transform .09s; font-family: var(--font); }
button.hud-chip:active { transform: var(--m-press); }
.hud-me { flex: 0 1 auto; min-width: 0; }
.hud-me canvas { width: 40px; height: 40px; border-radius: 50%; flex: none; background: #fff3e6; box-shadow: 0 0 0 2px #fff, 0 2px 4px rgba(122, 59, 74, .2); }
.hud-me .hud-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.hud-lv { display: flex; flex-direction: column; gap: 3px; min-width: 62px; text-align: left; }
.hud-lv b { font-size: 12px; color: var(--m-sub); }
.xpbar { height: 8px; border-radius: 999px; background: #efe2d4; overflow: hidden; box-shadow: inset 0 1px 2px rgba(122, 59, 74, .15); }
.xpbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #8fd48a, #c8ec9c); width: 0; transition: width .4s; }
.hud-money { color: var(--m-ink); }
.hud-money .ic { margin-left: 2px; }
.hud-clock { margin-left: auto; font-size: 14px; flex-direction: row; white-space: nowrap; padding-left: 8px; }
.hud-clock .hud-paused { display: none; background: #b996e0; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.hud-clock.paused .hud-paused { display: inline-block; }
.hud-clock.paused .hud-time { opacity: .6; }
.hud-net { display: none; background: linear-gradient(#f39a8c, #e2685c); color: #fff; padding-left: 12px; }
.hud-net.on { display: flex; }
@media (max-width: 520px) {
  #hud { flex-wrap: wrap; }
  .hud-clock { margin-left: 0; order: 5; }
  .hud-me .hud-name { max-width: 64px; }
}

/* 공지 띠 */
#noticebar { position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translate(-50%, -30px); opacity: 0; visibility: hidden; transition: transform .35s ease, opacity .35s, visibility .35s; width: min(94vw, 560px);
  background: linear-gradient(#fff6d6, #ffeeb8); border: none; border-radius: 20px; box-shadow: var(--m-shadow); padding: 10px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
#noticebar.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
@media (max-width: 520px) { #noticebar { top: calc(132px + var(--safe-t)); } body[data-screen=town] #toasts { top: calc(136px + var(--safe-t)); } }
#noticebar .nb-title { font-weight: 900; font-size: 16px; }
#noticebar .nb-body { font-size: 13px; color: var(--m-sub); font-weight: 700; }

/* 아래 단추줄: 떠 있는 말랑 받침 */
#bottombar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); display: flex; gap: 6px; padding: 6px; background: rgba(255, 250, 245, .92);
  border: none; border-radius: 28px; box-shadow: var(--m-shadow-in), var(--m-shadow); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.bb-btn { position: relative; width: 64px; min-height: 64px; border-radius: 20px; border: none; background: linear-gradient(#ffffff, #f8efe6); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; font-size: 12px; font-weight: 900; color: var(--m-ink); cursor: pointer; padding: 2px; box-shadow: var(--m-shadow-in), 0 2px 5px rgba(122, 59, 74, .1); transition: transform .09s; }
.bb-btn:active { transform: var(--m-press); }
.bb-btn .badge, .app-btn .badge { position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; border-radius: 12px; background: #e2685c; color: #fff; font-size: 13px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; padding: 0 5px; box-shadow: var(--m-shadow-s); }
@media (max-width: 400px) { .bb-btn { width: 58px; } #bottombar { gap: 5px; padding: 5px; } }

/* 화면 위 말(탭한 곳 알림) */
.tap-hint { position: fixed; z-index: 35; pointer-events: none; }

/* ───── 패널 창 ───── */
.panel-shade { position: absolute; inset: 0; background: rgba(91, 58, 46, .22); display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s; }
.panel-shade.panel-under { display: none; }
.panel-win { width: min(100%, 600px); max-height: calc(100% - 70px - var(--safe-t)); background: var(--m-card); border: none; border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 30px rgba(122, 59, 74, .18); display: flex; flex-direction: column; animation: slideup .24s cubic-bezier(.2, 1.2, .4, 1); }
@media (min-width: 700px) {
  .panel-shade { align-items: center; }
  .panel-win { border-radius: 28px; box-shadow: var(--m-shadow), 0 20px 50px rgba(122, 59, 74, .2); max-height: calc(100% - 48px); }
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 18px; border-bottom: none; background: linear-gradient(#fff3ea, rgba(255, 250, 245, 0)); border-radius: 28px 28px 0 0; }
.panel-title { flex: 1; margin: 0; font-size: 21px; font-weight: 900; }
.panel-x { width: 52px; height: 52px; border-radius: 18px; border: none; background: linear-gradient(#ffffff, #f7eee6); box-shadow: var(--m-shadow-in), var(--m-shadow-s); display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; transition: transform .09s; }
.panel-x:active { transform: var(--m-press); }
.panel-back { order: -1; }
.panel-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px calc(20px + var(--safe-b)); flex: 1; }
.panel-locked { text-align: center; padding: 20px; font-weight: 800; font-size: 18px; }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* 작은 상자(묻기) */
.modal-shade { position: absolute; inset: 0; background: rgba(91, 58, 46, .3); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein .15s; }
.modal-card { width: min(100%, 400px); background: var(--m-card); border: none; border-radius: 28px; box-shadow: var(--m-shadow), 0 20px 50px rgba(122, 59, 74, .2); padding: 20px; text-align: center; animation: pop .25s ease; }
.modal-title { margin: 0 0 8px; font-size: 22px; }
.modal-text { font-size: 17px; font-weight: 700; margin: 6px 0 14px; }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-btns .btn { flex: 1; min-width: 120px; }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.03); } 100% { transform: none; opacity: 1; } }

/* 알림 */
.toast { background: var(--m-card); border: none; border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 16px; box-shadow: var(--m-shadow); animation: pop .2s; transition: opacity .4s; text-align: center; }
.toast-good { background: #e6f6dc; }
.toast-bad { background: #ffe3de; }
.toast-out { opacity: 0; }

/* 공용 부품 */
.money { font-weight: 900; }
.item-icon { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: none; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1); font-weight: 900; color: #fff; flex: none; }
.item-icon-drawn { border: none; border-radius: 0; background: none; box-shadow: none; }
.ic { display: inline-flex; flex: none; }
.ic svg { display: block; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .btn { padding: 0; width: 52px; font-size: 24px; }
.stepper-value { min-width: 40px; text-align: center; font-weight: 900; font-size: 22px; }
.receipt { border: 2px dashed #e4d2c0; border-radius: 16px; padding: 10px 14px; background: #fffdf6; font-size: 16px; }
.receipt-row { display: flex; justify-content: space-between; padding: 3px 0; }
.receipt-tax { color: #b0623a; }
.receipt-sum { border-top: 2px solid #efe0cf; margin-top: 4px; padding-top: 6px; font-size: 18px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; border-radius: 20px; background: #fff; box-shadow: var(--m-shadow-s); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row canvas { width: 56px; height: 56px; border-radius: 50%; flex: none; background: #fff3e6; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; border: none; font-size: 13px; font-weight: 800; background: var(--m-card-2); }
.pill-on { background: #d9f2c9; }
.pill-off { background: #eee6dc; color: var(--m-sub); }

/* 폰 */
.phone-frame { background: linear-gradient(160deg, #dff1f8, #fff4e8 60%, #ffe6ec); border: none; border-radius: 28px; padding: 18px 12px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .8), inset 0 -4px 10px rgba(122, 59, 74, .06); }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 16px 8px; }
.app-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; font-weight: 800; font-size: 14px; color: var(--m-ink); cursor: pointer; min-height: 96px; transition: transform .09s; }
.app-btn:active { transform: var(--m-press); }
.app-btn .app-ic { width: 66px; height: 66px; border-radius: 22px; border: none; background: linear-gradient(#ffffff, #f6ede4); display: flex; align-items: center; justify-content: center; box-shadow: var(--m-shadow-in), var(--m-shadow-s); }

/* 친구 부르기 */
.invite-big { text-align: center; }
.invite-code { font-size: clamp(44px, 13vw, 64px); font-weight: 900; letter-spacing: 8px; color: var(--m-ink); background: linear-gradient(#fff6d6, #ffeeb8); border: none; border-radius: 22px; padding: 6px 10px; margin: 6px 0 14px; box-shadow: var(--m-shadow-in), var(--m-shadow-s); }
.invite-pw { font-size: clamp(30px, 9vw, 44px); font-weight: 900; letter-spacing: 3px; background: linear-gradient(#e6f5fb, #d3ecf6); border: none; border-radius: 22px; padding: 6px 10px; margin: 6px 0 14px; word-break: break-all; box-shadow: var(--m-shadow-in), var(--m-shadow-s); }
.invite-label { font-weight: 900; font-size: 17px; color: var(--m-sub); }
.seats { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.seat { width: 60px; height: 60px; border-radius: 50%; border: 3px dashed #e0cdbd; display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--m-sub); background: #fff; }
.seat canvas { width: 54px; height: 54px; border-radius: 50%; }
.seat.full { border: none; box-shadow: var(--m-shadow-s); }

/* 소환 물음 */
.summon-card canvas { width: 96px; height: 96px; border-radius: 50%; background: #fff3e6; }
.summon-left { font-weight: 800; color: var(--m-sub); margin-bottom: 10px; }

/* 채팅 */
.chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 38vh; overflow-y: auto; padding: 4px 2px 8px; }
.chat-line { display: flex; gap: 8px; align-items: flex-end; }
.chat-line.mine { flex-direction: row-reverse; }
.chat-bubble { background: #fff; border: none; border-radius: 18px; padding: 7px 13px; font-size: 16px; font-weight: 700; max-width: 75%; word-break: break-all; box-shadow: var(--m-shadow-s); }
.chat-line.mine .chat-bubble { background: #fff0c8; }
.chat-name { font-size: 12px; font-weight: 800; color: var(--m-sub); }
.chat-sys .chat-bubble { background: var(--sky-l); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.quick .btn { font-size: 16px; padding: 4px 6px; }
.stickers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 8px 0; }
.sticker-btn { min-height: 54px; border-radius: 16px; border: none; background: #fff; box-shadow: var(--m-shadow-s); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .09s; }
.sticker-btn:active { transform: var(--m-press); }
.chat-input { display: flex; gap: 8px; margin-top: 6px; }
.chat-input input { flex: 1; min-width: 0; min-height: 54px; border-radius: 16px; border: 2px solid transparent; padding: 0 12px; font-size: 18px; background: var(--m-card-2); box-shadow: inset 0 2px 4px rgba(122, 59, 74, .08); outline: none; }
.chat-input input:focus { border-color: #9fd59a; background: #fff; }

/* 지도 */
.map-wrap { position: relative; display: flex; justify-content: center; }
.map-wrap canvas { width: 100%; max-width: 560px; height: auto; border: none; border-radius: 20px; background: #f6efe2; touch-action: none; box-shadow: var(--m-shadow-s); }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 14px; font-weight: 800; }
.map-tip { font-size: 14px; color: var(--m-sub); font-weight: 700; margin-top: 8px; text-align: center; }

/* 오늘의 장부 */
.day-ledger { text-align: left; font-size: 17px; font-weight: 800; }
.day-ledger div { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 2px dashed #efe0cf; }

/* 연결 상태 */
.overlay-msg { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(251, 239, 230, .7); font-weight: 900; font-size: 20px; }
.loading-dots::after { content: '…'; animation: dots 1.2s infinite steps(4); }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
/* 불러오는 중: 말랑이 점 셋 */
.m-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; font-weight: 900; font-size: 20px; }
.m-loading-dots { display: flex; gap: 10px; }
.m-loading-dots i { width: 18px; height: 18px; border-radius: 50%; background: var(--m-accent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1), inset 0 3px 0 rgba(255, 255, 255, .5); animation: mhop .9s infinite ease-in-out; }
.m-loading-dots i:nth-child(2) { background: var(--m-butter); animation-delay: .15s; }
.m-loading-dots i:nth-child(3) { background: var(--m-go); animation-delay: .3s; }
@keyframes mhop { 0%, 100% { transform: translateY(0) scale(1.08, .92); } 45% { transform: translateY(-14px) scale(.94, 1.06); } }

/* 움직임 줄이기(설정·기기) */
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }

/* ───── 배치 손질 ───── */
/* 폰: 버전 표시가 아래 단추줄('이야기')과 창 맨 아래 단추를 가리지 않게 자리를 비움 */
@media (max-width: 720px) {
  body[data-screen=town] #bottombar { bottom: calc(30px + var(--safe-b)); }
  .panel-body { padding-bottom: calc(40px + var(--safe-b)); }
}
/* 캐릭터 만들기: '완성!'이 두 줄로 꺾이지 않게, 탭은 넘치면 다음 줄로 */
.cr-name .btn { white-space: nowrap; flex: none; padding-left: 14px; padding-right: 14px; }
.cr-name .field { min-width: 0; }
.cr-name input { width: 100%; min-width: 0; box-sizing: border-box; }
.cr-side .tabs { flex-wrap: wrap; overflow-x: visible; }

/* 첫 안내 카드(v0.1.5) */
.welcome-steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; text-align: left; }
.welcome-step { display: flex; align-items: center; gap: 12px; background: var(--m-bg, #fff6ec); border-radius: 18px; padding: 10px 14px; font-size: 16px; font-weight: 800; line-height: 1.35; }
.welcome-step .ic { flex: 0 0 auto; }

/* 한글 줄바꿈: 낱말 가운데에서 끊지 않기(v0.1.5 통합) */
.screen, .panel-win, .modal-card, .toast { word-break: keep-all; overflow-wrap: break-word; }
