:root {
  --duck: #ffd84d; --duck-deep: #f2b705; --beak: #ff9f43; --ink: #4a3b2f; --cream: #fff8e8;
  --card: #ffffff; --line: #f0dfb8; --mint: #9fe0c9; --pink: #ffb6c9; --danger: #ff6b6b;
  --shadow: 0 6px 18px rgba(120, 90, 30, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff6e0; 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(--duck); 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(--duck); }
.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, 248, 232, .96); border-radius: 26px 26px 0 0;
  box-shadow: 0 -6px 22px rgba(120, 90, 30, .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(--duck); }
.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(--duck); }
.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 { 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 { 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(--duck-deep); background: var(--duck); }
.done { background: var(--mint) !important; border-radius: 14px; padding: 10px 18px; font-size: 19px; }
body[data-mode="wall"] .wallbar, body[data-mode="walk"] .walkbar { display: block; }
body[data-mode="wall"] .drawer, body[data-mode="walk"] .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(420px, calc(100% - 28px)); 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(--duck-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: #fff6e0; 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; }
}
