:root {
  --pig: #ffb3c6; --pig-deep: #ff6f99; --beak: #ff8fab; --ink: #4a3b2f; --cream: #fff3f5;
  --card: #ffffff; --line: #f6d3dc; --mint: #9fe0c9; --pink: #ffb6c9; --danger: #ff6b6b;
  --shadow: 0 6px 18px rgba(150, 60, 90, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff0f3; color: var(--ink);
  font-family: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 위 막대 */
.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; background: var(--pig); border-radius: 999px; padding: 6px 16px 6px 8px; box-shadow: var(--shadow); }
.logo { font-size: 30px; line-height: 1; }
#cafeName { font: inherit; font-size: 22px; border: 0; background: transparent; color: var(--ink); width: 9em; outline: none; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.tools button, .tools summary, .selbar button {
  background: var(--card); border-radius: 18px; padding: 8px 14px; font-size: 17px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; min-width: 64px; list-style: none; }
.tools button span, .selbar button span { font-size: 24px; line-height: 1.1; }
.tools button.on { background: var(--pig); }
.tools button:disabled { opacity: .4; }
.more { position: relative; }
.more summary { cursor: pointer; font-size: 26px; min-width: 52px; padding: 10px 12px; }
.more summary::-webkit-details-marker { display: none; }
.more .menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 6px; min-width: 170px; }
.more .menu button { display: block; width: 100%; text-align: left; padding: 12px; background: none; box-shadow: none; font-size: 18px; flex-direction: row; border-radius: 10px; }
.more .menu button:active { background: var(--cream); }

/* 서랍 */
.drawer { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255, 243, 246, .96); border-radius: 26px 26px 0 0;
  box-shadow: 0 -6px 22px rgba(150, 60, 90, .18); padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); z-index: 4;
  transition: transform .25s ease; }
.drawer.closed { transform: translateY(calc(100% - 70px)); }
.handle { display: block; margin: 0 auto 4px; width: 72px; height: 10px; border-radius: 9px; background: #e8d3a6; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.tab { flex: none; background: #fff; border-radius: 999px; padding: 8px 16px; font-size: 18px; display: flex; gap: 6px; align-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.tab span { font-size: 22px; }
.tab.on { background: var(--pig); }
.items { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.card { flex: none; width: 112px; background: #fff; border-radius: 18px; padding: 6px 6px 8px; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); scroll-snap-align: start; border: 3px solid transparent; transition: transform .1s; }
.card:active { transform: scale(.94); border-color: var(--pig); }
.card img { width: 96px; height: 96px; object-fit: contain; }
.card span { font-size: 16px; margin-top: 2px; white-space: nowrap; }
.card { position: relative; }
.card.ai::after { content: '✨'; position: absolute; top: 4px; right: 6px; font-size: 16px; }

/* 고른 소품 단추 */
.selbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 250px; display: flex; gap: 8px; z-index: 6;
  background: rgba(255,255,255,.7); padding: 8px; border-radius: 24px; backdrop-filter: blur(6px); }
.selbar[hidden] { display: none; }
.selbar .danger { background: #ffe1e1; }
.drawer.closed ~ .selbar, body:has(.drawer.closed) .selbar { bottom: 90px; }

/* 벽 세우기·둘러보기 막대 */
.wallbar, .walkbar, .yardbar { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 6; background: #fff;
  border-radius: 24px; padding: 12px 16px; box-shadow: var(--shadow); text-align: center; }
.wallbar p, .walkbar p, .yardbar p { margin: 0 0 8px; font-size: 18px; }
.brushes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.brushes button { background: var(--cream); border-radius: 14px; padding: 10px 16px; font-size: 19px; border: 3px solid transparent; }
.brushes button.on { border-color: var(--pig-deep); background: var(--pig); }
.done { background: var(--mint) !important; border-radius: 14px; padding: 10px 18px; font-size: 19px; }
body[data-mode="wall"] .wallbar, body[data-mode="walk"] .walkbar, body[data-mode="yard"] .yardbar { display: block; }
.wallbar, .yardbar { width: min(760px, calc(100% - 24px)); }
.brushes button { padding: 8px 12px; font-size: 17px; }
body[data-mode="wall"] .drawer, body[data-mode="walk"] .drawer, body[data-mode="yard"] .drawer { transform: translateY(110%); }
body[data-mode="walk"] .top .tools > :not([data-mode-btn="walk"]):not(#btnPhoto) { display: none; }

/* 바닥·벽지 고르기 */
.panel { position: fixed; right: 14px; top: 90px; width: min(460px, calc(100% - 28px)); max-height: calc(100vh - 110px); overflow-y: auto; background: #fff; border-radius: 24px; box-shadow: var(--shadow); padding: 14px 16px; z-index: 7; }
.panel[hidden] { display: none; }
.panel h2 { margin: 4px 0 8px; font-size: 20px; font-weight: normal; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 10px; }
.swatch { background: var(--cream); border-radius: 14px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 15px; border: 3px solid transparent; }
.swatch canvas { width: 64px; height: 64px; border-radius: 10px; }
.swatch.on { border-color: var(--pig-deep); }
.panel .done { width: 100%; }

.toast { position: fixed; left: 50%; top: 96px; transform: translate(-50%, -20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 18px; opacity: 0; transition: .25s; pointer-events: none; z-index: 9; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 8; }
.flash.go { animation: flash .5s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
.loading { position: fixed; inset: 0; background: #fff0f3; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; font-size: 22px; }
.loading[hidden] { display: none; }
.bob { font-size: 80px; animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-14px) rotate(-6deg); } }

@media (max-width: 760px) {
  .tools button span { font-size: 20px; }
  .tools button, .tools summary { font-size: 13px; min-width: 52px; padding: 6px 8px; }
  #cafeName { font-size: 18px; width: 6em; }
  .card { width: 92px; } .card img { width: 78px; height: 78px; }
  .selbar { bottom: 220px; }
}

/* 들어갈 때 핀 번호 */
#pinGate { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, #fff5f8, #ffc9d8); transition: opacity .35s; }
#pinGate.pin-open { opacity: 0; pointer-events: none; }
.pin-box { width: min(360px, 100%); text-align: center; }
.pin-pig { font-size: 64px; line-height: 1; }
.pin-box h1 { margin: 6px 0 4px; font-size: 34px; font-weight: normal; color: var(--ink); }
.pin-msg { margin: 0 0 18px; font-size: 19px; color: #8a6d3b; min-height: 1.4em; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 26px; }
.pin-dots i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--pig-deep); background: #fff; transition: background .15s; }
.pin-dots i.on { background: var(--pig-deep); }
.pin-shake { animation: pinShake .45s; }
@keyframes pinShake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pin-pad button { font: inherit; font-size: 32px; color: var(--ink); background: #fff; border: 0; border-radius: 22px;
  height: 76px; box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.pin-pad button:active { transform: scale(.94); background: var(--pig); }
.pin-pad .pin-sub { font-size: 20px; background: var(--cream); }
