/* 화가 빌리지 UI — "밤의 크리스마스 마켓" 팔레트 (그림자·입체 버튼 없음)
   참고: 북유럽 겨울밤 마켓 — 깊은 남색 하늘 · 촛불빛 크림 · 천막과 같은 크랜베리 · 전나무 초록 · 낡은 놋쇠
   남색 유리판 위에 크림 글씨, 주 버튼은 노점 천막 빨강(크랜베리), 보조는 크림 테두리, 포인트는 은은한 놋쇠 */
:root {
  --night: #151a33;          /* 배경 밤하늘 */
  --panel: rgba(24, 28, 54, .84);   /* 남색 유리판 */
  --panel-2: rgba(246, 233, 215, .07);
  --line: rgba(246, 233, 215, .18); /* 촛불빛 얇은 테두리 */
  --snow: #f6e9d7;           /* 기본 글씨: 촛불빛 크림 */
  --snow-dim: rgba(246, 233, 215, .66);
  --lantern: #cfae7c;        /* 포인트: 은은한 놋쇠 (작은 글씨·표시) */
  --btn: #a8414f;            /* 주 버튼: 크랜베리 (노점 천막과 같은 톤) */
  --btn-ink: #fbefe2;        /* 주 버튼 글씨 */
  --lantern-ink: #fbefe2;
  --pine: #2f5d4e;           /* 보조 (전나무) */
  --berry: #c45563;          /* 포인트 (열매·리본) */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--snow); overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button, label.btn { touch-action: manipulation; }

/* 버튼: 평면, 눌렀을 때 살짝 작아짐 */
.btn { appearance: none; border: 0; border-radius: 14px; min-height: 48px; padding: 12px 18px; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .1s ease, opacity .1s; letter-spacing: -0.2px; }
.btn:active { transform: scale(.97); opacity: .9; }
.btn.primary { background: var(--btn); color: var(--btn-ink); }
.btn.green { background: var(--pine); color: var(--snow); }
.btn.ghost { background: transparent; color: var(--snow); border: 1px solid rgba(246, 233, 215, .34); }
.btn.text { background: none; color: var(--snow-dim); font-weight: 600; min-height: 40px; padding: 8px; }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: 14px; border-radius: 12px; }
.btn.big { min-height: 56px; padding: 15px 30px; font-size: 18px; border-radius: 16px; }
.btn.wide { width: 100%; }
/* 가는 선 아이콘 (이모지 대신) */
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; stroke-width: 1.8; }
.btn .i { margin-left: -2px; }
.ic { display: inline-flex; align-items: center; }
.ic img { width: 1.45em; height: 1.45em; object-fit: contain; margin: -0.2em 0; }
#startLogo img { width: 150px; height: auto; margin-bottom: 2px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--snow); font-size: 15px; cursor: pointer; flex: none; }
.round:active { transform: scale(.94); }

/* 시작 화면 */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(14,17,40,.9) 0%, rgba(26,30,70,.72) 55%, rgba(70,52,96,.6) 100%); color: var(--snow); text-align: center; transition: opacity .8s; }
.overlay.fade { opacity: 0; pointer-events: none; }
.start-inner { position: relative; padding: 24px; max-width: 420px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--lantern); }
.overlay h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -1.6px; font-weight: 700; }
.overlay .sub { font-size: 15px; line-height: 1.65; color: var(--snow-dim); margin: 0; }
.overlay .healing { margin: 10px 0 0; }
.overlay #enterBtn { margin-top: 34px; min-width: 220px; }
.overlay #loadMsg { margin-top: 26px; min-height: 1em; }
.privacy { font-size: 13px; line-height: 1.6; color: var(--snow-dim); margin: 20px 0 0; }
.privacy.dark { color: var(--snow-dim); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.hint { font-size: 13px; opacity: .7; margin: 8px 0 0; }
.healing { font-size: 15px; line-height: 1.6; margin: 14px 0 0; color: var(--lantern); }
.small { font-size: 12px; }
.start-snow { position: absolute; inset: -40vh -20vw; pointer-events: none;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%), radial-gradient(3px 3px at 70% 10%, #fff 50%, transparent 51%),
  radial-gradient(2px 2px at 40% 70%, #fff 50%, transparent 51%), radial-gradient(3px 3px at 85% 55%, #fff 50%, transparent 51%),
  radial-gradient(2px 2px at 10% 85%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 55% 45%, #fff 50%, transparent 51%);
  background-size: 300px 300px; animation: snowfall 12s linear infinite; opacity: .6; z-index: -1; }
@keyframes snowfall { from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; } to { background-position: 30px 300px, -20px 300px, 10px 300px, -30px 300px, 20px 300px, 0 300px; } }

/* 상단 */
#topbar { position: fixed; top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px); display: flex; gap: 6px; z-index: 20; pointer-events: none; }
#topbar .spacer { flex: 1; }
.chip { pointer-events: auto; background: var(--panel); color: var(--snow); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 12px; height: 38px; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chip.title { letter-spacing: -0.3px; }
.btnchip { cursor: pointer; font: inherit; font-weight: 700; font-size: 14px; }
.btnchip:active { transform: scale(.95); }
.chip.icon-only { width: 38px; padding: 0; justify-content: center; }
.icon-col { display: flex; flex-direction: column; gap: 6px; }
#topbar { align-items: flex-start; }
body.card-open .chip.title { visibility: hidden; } /* 가게 카드가 맨 위에 뜰 땐 이름표를 비켜 줌 */
.chip .i { width: 16px; height: 16px; }
@media (max-width: 370px) { .chip.title { display: none; } }
#debug { position: fixed; top: calc(var(--safe-t) + 54px); left: 10px; z-index: 20; font: 11px/1.4 ui-monospace, monospace; color: #cfe; background: rgba(0,0,0,.45); padding: 4px 8px; border-radius: 6px; pointer-events: none; white-space: pre; }

/* 말풍선 (눈처럼 하얀 평면) */
.bubble { position: fixed; left: 0; top: 0; z-index: 15; width: max-content; max-width: min(72vw, 320px); background: var(--snow); color: #2b2234;
  border-radius: 16px; padding: 10px 14px; font-size: 15px; line-height: 1.45; font-weight: 600;
  transform: translate(-50%, calc(-100% - 14px)); opacity: 0; transition: opacity .25s; pointer-events: none; word-break: keep-all; }
.bubble.show { opacity: 1; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); border: 10px solid transparent; border-bottom: 0; border-top-color: var(--snow); }

/* 하단 도크 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px); display: flex; justify-content: center; pointer-events: none; }
.card { pointer-events: auto; width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--snow); }
.card.row { display: flex; align-items: center; gap: 10px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; flex-wrap: wrap; justify-content: center; }
.row.gap .btn { flex: 1 1 auto; }
.pc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pc-info { flex: 1; min-width: 0; text-align: center; }
.pc-name { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.pc-avatar { width: 64px; height: 64px; object-fit: contain; margin: -40px auto 2px; display: block; }
.pc-style { margin-bottom: 3px; }
.pc-intro { font-size: 13px; color: var(--snow-dim); margin-top: 4px; line-height: 1.45; word-break: keep-all; }
.tag { display: inline-block; color: var(--lantern); font-size: 11px; font-weight: 600; letter-spacing: .12em; }
.done-title { text-align: center; font-size: 15px; font-weight: 600; letter-spacing: .3em; color: var(--lantern); margin-bottom: 12px; }
.eat-hot { width: 18px; height: 18px; color: var(--berry); }

/* 속도 세그먼트 + 진행바 */
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex: none; }
.seg button { border: 0; background: none; font: inherit; font-weight: 800; font-size: 14px; min-height: 36px; padding: 6px 13px; border-radius: 9px; color: var(--snow-dim); cursor: pointer; }
.seg button.on { background: var(--btn); color: var(--btn-ink); }
.progress { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#progFill { height: 100%; width: 0; background: var(--btn); border-radius: 999px; transition: width .3s linear; }

/* 바텀시트 */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0 auto; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: rgba(20, 24, 52, .97); border: 1px solid var(--line); border-bottom: 0; color: var(--snow);
  border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--safe-b) + 12px);
  transform: translateY(110%); transition: transform .36s cubic-bezier(.2,.9,.3,1); text-align: center; }
.sheet.open { transform: translateY(0); }
.sheet h2 { font-size: 18px; margin: 6px 0 14px; font-weight: 800; }
.sheet-handle { width: 40px; height: 4px; border-radius: 9px; background: var(--line); margin: 0 auto 6px; }
.sheet-btns { display: flex; flex-direction: column; gap: 10px; }
.sample-row { display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; color: var(--snow-dim); margin-top: 2px; }
.save-img { display: block; max-width: 100%; max-height: 46dvh; margin: 0 auto 14px; border-radius: 10px; border: 1px solid var(--line);
  -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; pointer-events: auto; }
.save-hint { font-size: 15px; line-height: 1.6; color: var(--snow); margin: 4px 0 6px; }
.save-hint b { color: var(--snow); }

/* 간식 */
.food-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.food-btns .btn { flex: 1 1 30%; padding: 10px 8px; font-size: 14px; min-width: 96px; }
.eat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.eat-label { font-weight: 800; font-size: 16px; white-space: nowrap; }
.heat { flex: 1; height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#heatFill { height: 100%; width: 100%; background: linear-gradient(90deg, #e9c4b4, #e08a7a, var(--berry)); border-radius: 999px; transition: width .25s; }

/* 캐리커처 */
.cari-desc { margin: -6px 0 12px; font-size: 14px; color: var(--snow-dim); line-height: 1.55; }
.cari-step { margin: -4px 0 12px; font-size: 14px; font-weight: 700; color: var(--lantern); }
.wide-seg { justify-content: center; margin: 0 auto 14px; width: max-content; }
.wide-seg button { padding: 8px 18px; }
.cam-overlay { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; align-items: center; justify-content: center; }
.cam-overlay video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-guide { position: absolute; width: min(64vw, 340px); aspect-ratio: 3 / 4; border: 2px dashed rgba(251,243,230,.7); border-radius: 50% / 42%; pointer-events: none; }
.cam-bar { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 24px); display: flex; align-items: center; justify-content: space-around; }
.cam-spacer { width: 84px; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid var(--snow); background: var(--berry); cursor: pointer; }
.shutter:active { transform: scale(.94); }

/* 조이스틱: 닿은 자리에 생김 */
.joy { position: fixed; z-index: 18; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  background: rgba(251,243,230,.08); border: 1.5px solid rgba(251,243,230,.4); pointer-events: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(251,243,230,.85); }

/* 엄지 조이스틱 자리 안내 (왼쪽 아래) */
.joy-hint { position: fixed; z-index: 17; left: calc(var(--safe-l) + 30px); bottom: calc(var(--safe-b) + 36px); width: 108px; height: 108px; border-radius: 50%;
  border: 1.5px dashed rgba(251,243,230,.3); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.joy-hint span { width: 42px; height: 42px; border-radius: 50%; background: rgba(251,243,230,.16); color: rgba(251,243,230,.8);
  font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
/* 가게 카드: 오른쪽 위에 작게 (왼쪽 아래 이동 조이스틱·화면 끌기를 가리지 않게) */
#painterCard { top: calc(var(--safe-t) + 10px); bottom: auto; left: 0; right: 0; padding: 0 56px; justify-content: center; }
#painterCard .card { width: min(100%, 270px); padding: 10px 11px 11px; border-radius: 16px; }
#painterCard .pc-row { gap: 4px; margin-bottom: 9px; align-items: flex-start; }
#painterCard .round { width: 28px; height: 28px; }
#painterCard .round .i { width: 14px; height: 14px; }
#painterCard .pc-name { font-size: 16px; }
#painterCard .pc-intro { font-size: 11.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#painterCard .btn { min-height: 40px; font-size: 14px; padding: 8px 10px; border-radius: 12px; }
#painterCard .food-btns { flex-direction: row; flex-wrap: nowrap; gap: 5px; }
#painterCard .food-btns .btn { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 6px 4px; font-size: 13.5px; border-radius: 10px; }

/* 걷기 안내 (위쪽, 잠시 뒤 사라짐) */
.walk-hint { position: fixed; left: 50%; top: calc(var(--safe-t) + 58px); transform: translateX(-50%); z-index: 19; pointer-events: none;
  background: var(--panel); color: var(--snow); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px;
  font-size: 13px; font-weight: 700; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .5s; }
.walk-hint.gone { opacity: 0; }

/* 알림 */
.pill { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%); z-index: 25; background: var(--panel); color: var(--snow);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; font-weight: 700; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 170px); transform: translate(-50%, 12px); z-index: 60; background: rgba(22,27,58,.94); color: var(--snow);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; line-height: 1.45; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; width: max-content; max-width: 88vw; text-align: center; word-break: keep-all; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .dock { justify-content: flex-start; padding-left: 20px; }
}
