/* DESIGN.md 토큰 */
:root {
  --night900: #141A2E;
  --night700: #26304F;
  --night500: #3D4A73;
  --cookie: #C98A4B;
  --cookieDark: #8E5A2B;
  --icing: #FFF6EA;
  --glow: #FFC46B;
  --candy: #E2474B;
  --mint: #6CC7A8;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font-display: 'Jua', 'Pretendard', sans-serif;
  --font-body: 'Pretendard', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--night900); color: var(--icing); font-family: var(--font-body); -webkit-tap-highlight-color: transparent; }

#top-banner { position: fixed; inset: 0 0 auto 0; height: 50px; background: var(--night900); z-index: 10; }
#stage { position: fixed; top: 50px; left: 0; right: 0; bottom: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.ui { position: fixed; top: 50px; left: 0; right: 0; bottom: 0; pointer-events: none; display: none; }
.ui * { pointer-events: auto; }
body[data-view='landing'] .ui-landing { display: flex; }
body[data-view='building'] .ui-building { display: block; }
body[data-view='home'] .ui-home, body[data-view='inside'] .ui-home { display: block; }
body[data-view='plaza'] .ui-plaza { display: block; }

.ui-landing { flex-direction: column; align-items: center; justify-content: flex-end; gap: 24px; padding: 0 16px 56px;
  background: linear-gradient(to top, rgba(20, 26, 46, 0.75), rgba(20, 26, 46, 0) 45%); }

.logo { font-family: var(--font-display); font-weight: 400; text-align: center; line-height: 1.05; color: var(--icing);
  font-size: 22px; letter-spacing: 0.02em; text-shadow: 0 3px 0 var(--cookieDark), var(--shadow); }
.logo span { display: inline-block; font-size: 52px; color: var(--cookie);
  -webkit-text-stroke: 6px var(--icing); paint-order: stroke fill; text-shadow: 0 5px 0 var(--cookieDark), var(--shadow); }

.btn-primary { font: 700 16px var(--font-body); color: var(--night900); background: var(--glow); border: 0;
  border-radius: 999px; padding: 16px 56px; box-shadow: var(--shadow); cursor: pointer; }
.btn-ghost { font: 700 16px var(--font-body); color: var(--icing); background: rgba(20, 26, 46, 0.4);
  border: 1.5px solid var(--icing); border-radius: 999px; padding: 8px 16px; cursor: pointer; }

.address { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-family: var(--font-display);
  font-size: 22px; color: var(--night900); background: var(--glow); padding: 8px 24px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; }
.back { position: absolute; left: 16px; bottom: 24px; }
.elevator { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px;
  background: rgba(38, 48, 79, 0.7); border: 1.5px solid var(--night500); border-radius: 999px; padding: 8px; box-shadow: var(--shadow); }
.elevator button { width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--night700); color: var(--icing); font-size: 14px; cursor: pointer; }

.btn-primary.small { padding: 12px 28px; font-size: 15px; }
.btn-ghost.tiny { padding: 6px 14px; font-size: 13px; }
.to-home { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); }

.ui-home .address { top: 16px; }
.breath { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  background: rgba(38, 48, 79, 0.72); border: 1.5px solid var(--night500); border-radius: 999px; padding: 8px 14px; color: var(--icing); box-shadow: var(--shadow); }
.breath .bar { width: 150px; height: 8px; border-radius: 999px; background: var(--night900); overflow: hidden; }
.breath .bar i { display: block; height: 100%; width: 100%; border-radius: 999px; background: var(--icing); transition: width .15s; }
.breath-note { position: absolute; top: 118px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13px; color: var(--icing); text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.ui-home .back { bottom: 24px; left: 16px; }
.decor { position: absolute; right: 16px; bottom: 24px; }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--night700); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .25s ease; z-index: 5; }
.sheet.open { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-family: var(--font-display); font-size: 22px; font-weight: 400; }
.sheet-head span { display: flex; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.item { background: var(--night900); border: 2px solid transparent; border-radius: 16px; padding: 6px 4px 8px; color: var(--icing); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font: 400 12px var(--font-body); }
.item img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.item.sel { border-color: var(--glow); }

#fade { position: fixed; inset: 0; background: var(--night900); opacity: 0; pointer-events: none; transition: opacity .45s ease; z-index: 20; }
#fade.on { opacity: 1; pointer-events: auto; }

.tools { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; gap: 4px; padding: 4px;
  background: rgba(38, 48, 79, 0.85); border: 1.5px solid var(--night500); border-radius: 999px; box-shadow: var(--shadow); }
.tools button { font: 700 14px var(--font-body); color: var(--icing); background: transparent; border: 0; border-radius: 999px; padding: 9px 18px; cursor: pointer; }
.tools button.on { background: var(--glow); color: var(--night900); }

/* ---------- 로그인 · 입주 창 / 알림 ---------- */
.modal { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-height: 88vh; overflow-y: auto; background: var(--night700);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .25s ease; }
.modal.open { transform: none; }
.modal h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; margin-bottom: 8px; }
.modal .note { font-size: 13px; color: var(--icing); opacity: .8; margin-bottom: 16px; line-height: 1.5; }
.modal .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.btn-ghost.wide, .btn-primary.wide { width: 100%; text-align: center; }
.btn-primary:disabled { opacity: .4; cursor: default; }
.field { width: 100%; background: var(--night900); color: var(--icing); border: 1.5px solid var(--night500); border-radius: 14px;
  padding: 14px 16px; font: 400 16px var(--font-body); margin-top: 8px; }
.field:focus { outline: none; border-color: var(--glow); }
.label { font: 700 13px var(--font-body); margin: 16px 0 8px; color: var(--glow); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--night900); color: var(--icing); border: 1.5px solid var(--night500); border-radius: 999px; padding: 8px 14px;
  font: 400 14px var(--font-body); cursor: pointer; }
.chip.sel { background: var(--glow); color: var(--night900); border-color: var(--glow); font-weight: 700; }
.check { display: flex; gap: 10px; align-items: center; margin: 16px 0; font-size: 14px; }
.check input { width: 22px; height: 22px; accent-color: var(--glow); }
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; font-size: 12px; opacity: .6; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--night500); }
#toast { position: fixed; top: 62px; left: 50%; transform: translate(-50%, -20px); background: var(--night700); color: var(--icing);
  border: 1.5px solid var(--glow); border-radius: 999px; padding: 10px 18px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 집주인 전용 / 방문자 */
.owner-only { display: none; }
body[data-owner='1'] .owner-only { display: inline-block; }
body[data-owner='1'] .breath, body[data-owner='1'] .breath-note { display: none; }

/* ---------- 집 안 (대화 · 선물 · 사연) ---------- */
.inside { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); }
.room { position: absolute; left: 0; right: 0; bottom: 0; height: 78vh; display: flex; flex-direction: column; background: var(--night700);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); transform: translateY(105%); transition: transform .25s ease; z-index: 8; }
.room.open { transform: none; }
.room-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px; font-family: var(--font-display); font-size: 20px; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 0 16px 8px; background: var(--night900); border-radius: 999px; }
.seg button { flex: 1; font: 700 14px var(--font-body); color: var(--icing); background: transparent; border: 0; border-radius: 999px; padding: 9px 0; cursor: pointer; }
.seg button.on { background: var(--glow); color: var(--night900); }
.room-body { flex: 1; overflow-y: auto; padding: 4px 16px 12px; }
.room-compose { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--night500); }
.room-compose form.inline { display: flex; gap: 8px; align-items: center; }
.room-compose form.inline .field { margin-top: 0; flex: 1; }
.room-compose textarea.field { resize: none; }
.note.center { text-align: center; margin: 16px 0; font-size: 13px; opacity: .8; }
.msg { background: var(--night900); border-radius: 16px; padding: 10px 14px; margin: 8px 0; max-width: 90%; }
.msg.mine { margin-left: auto; background: var(--night500); }
.msg.dim { opacity: .45; }
.msg.now { outline: 2px solid var(--glow); }
.msg .who { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.msg .who b { color: var(--glow); }
.msg .who .when { opacity: .6; font-size: 11px; flex: 1; }
.msg .txt { margin-top: 4px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.mini { font: 400 11px var(--font-body); color: var(--icing); background: transparent; border: 1px solid var(--night500); border-radius: 999px; padding: 2px 8px; cursor: pointer; }
.gifts { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 12px 0 4px; }
.gifts img { width: 56px; height: 56px; object-fit: contain; }
.gift-count { text-align: center; font-weight: 700; margin: 4px 0; }
.btn-primary.small.wide { width: 100%; margin: 8px 0; }

/* 걷는 집 안 (DESIGN.md 13) */
.inside-ui { display: none; }
body[data-view='inside'] .inside-ui { display: block; }
body[data-view='inside'] .address, body[data-view='inside'] #home-back, body[data-view='inside'] #home-inside, body[data-view='inside'] #home-decor, body[data-view='inside'] .tools, body[data-view='inside'] #sheet { display: none; }
.inside-ui .exit { position: fixed; left: 12px; top: 62px; z-index: 5; }
.radio-chip { position: fixed; right: 12px; top: 62px; z-index: 5; display: none; align-items: center; gap: 8px; background: rgba(38,48,79,.9); color: var(--icing); border: 1px solid var(--night500); border-radius: 999px; padding: 6px 8px 6px 12px; font-size: 13px; }
.radio-chip.on { display: flex; }
.act { white-space: nowrap; position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translate(-50%, 24px); opacity: 0; pointer-events: none; z-index: 6; transition: .2s; }
.act.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.inside-ui .hint { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); color: var(--icing); opacity: .7; font-size: 13px; text-shadow: 0 1px 4px var(--night900); pointer-events: none; }

.inside-ui .story { position: fixed; left: 12px; top: 106px; z-index: 5; background: rgba(38,48,79,.9); }
.inside-ui .tosofa { position: fixed; left: 12px; top: 150px; z-index: 5; background: rgba(38,48,79,.9); opacity: 0; pointer-events: none; transition: .2s; }
.inside-ui .tosofa.on { opacity: 1; pointer-events: auto; }

.radio-chip { display: flex; gap: 6px; padding: 5px; border-radius: 999px; }
.radio-chip button { font: 700 12px var(--font-body); color: var(--icing); background: transparent; border: 1px solid var(--night500); border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.radio-chip .ch { display: flex; }
.radio-chip .ch button { border-radius: 0; margin-left: -1px; }
.radio-chip .ch button:first-child { border-radius: 999px 0 0 999px; margin: 0; }
.radio-chip .ch button:last-child { border-radius: 0 999px 999px 0; }
.radio-chip button.on { background: var(--glow); color: var(--night900); border-color: var(--glow); }
.radio-chip .tg:not(.on) { opacity: .55; text-decoration: line-through; }

.radio-btn { position: fixed; right: 12px; top: 62px; z-index: 6; display: flex; align-items: center; gap: 6px; font: 700 13px var(--font-body); color: var(--icing); background: rgba(38,48,79,.92); border: 1px solid var(--night500); border-radius: 999px; padding: 9px 14px; cursor: pointer; }
.radio-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--night500); }
.radio-btn.live .dot { background: var(--candy); box-shadow: 0 0 8px var(--candy); }
.snd-panel { position: fixed; right: 12px; top: 106px; z-index: 6; width: 232px; padding: 10px 12px; border-radius: 14px; background: rgba(38,48,79,.96); border: 1px solid var(--night500); display: none !important; flex-direction: column; gap: 10px; }
.snd-panel.open { display: flex !important; }
.snd-panel .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--icing); }
.snd-panel button { padding: 6px 12px; }
.snd-panel .tg:not(.on) { text-decoration: none; opacity: .7; }
.gift-info { position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5; min-width: 240px; text-align: center; padding: 10px 16px; border-radius: 14px; background: rgba(20,26,46,.88); border: 1px solid var(--night500); color: var(--icing); display: none; }
.gift-info.on { display: block; }
.gift-info b { display: block; font: 400 22px var(--font-display); color: var(--glow); }
.gift-info span { display: block; font-size: 13px; margin-top: 2px; }
.gift-info small { display: block; font-size: 12px; opacity: .8; margin-top: 4px; }
.gopen { position: fixed; inset: 0; z-index: 50; background: rgba(20,26,46,.94); display: none; align-items: center; justify-content: center; padding: 20px; }
.gopen.on { display: flex; }
.gopen-body { width: 100%; max-width: 360px; text-align: center; color: var(--icing); }
.gopen .gcard { background: var(--icing); color: var(--night900); border-radius: 16px; padding: 22px 18px; min-height: 160px; animation: gflip .5s ease; }
.gopen .gcard .from { font-size: 13px; color: var(--cookieDark); margin-bottom: 8px; }
.gopen .gcard .txt { font-size: 18px; line-height: 1.5; word-break: break-all; }
.gopen h3 { font: 400 26px var(--font-display); margin: 0 0 12px; color: var(--glow); }
.gopen p { font-size: 14px; margin: 0 0 14px; opacity: .9; }
.gopen img { width: 100%; border-radius: 14px; margin-bottom: 12px; }
.gopen .acts { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
@keyframes gflip { from { transform: rotateY(90deg) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.ui-home .share { position: absolute; right: 12px; top: 62px; background: rgba(38,48,79,.9); }
body[data-view='inside'] #share { display: none; }

.here { position: fixed; left: 50%; top: 66px; transform: translateX(-50%); z-index: 5; padding: 6px 14px; border-radius: 999px; background: rgba(38,48,79,.92); border: 1px solid var(--mint); color: var(--icing); font-size: 13px; display: none; pointer-events: none; }
.here.on { display: block; }
body:not([data-view='home']):not([data-view='inside']) .here { display: none; }

html, body { overscroll-behavior: none; }
body[data-view='inside'] #stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(20,10,5,0) 55%, rgba(20,10,5,.5) 100%); }
.boot { position: fixed; inset: 0; z-index: 100; background: var(--night900); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--icing); }
  .boot .star { width: 72px; height: 72px; animation: bootspin 1.6s ease-in-out infinite; }
.boot p { font-family: var(--font-display); font-size: 24px; }
.boot small { opacity: .6; font-size: 12px; letter-spacing: .12em; }
@keyframes bootspin { 0%, 100% { transform: scale(.9) rotate(-6deg); opacity: .7; } 50% { transform: scale(1.1) rotate(6deg); opacity: 1; } }
.fatal { position: fixed; inset: 0; z-index: 200; background: var(--night900); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px; color: var(--icing); }
.coach { position: fixed; left: 50%; top: 40%; transform: translate(-50%, 10px); z-index: 7; text-align: center; padding: 14px 20px; border-radius: 16px; background: rgba(20,26,46,.9); border: 1px solid var(--glow); opacity: 0; pointer-events: none; transition: .4s; }
.coach.on { opacity: 1; transform: translate(-50%, 0); }
.coach b { display: block; font-size: 17px; color: var(--glow); }
.coach span { font-size: 13px; opacity: .85; }

.coach img { width: 120px; height: 120px; object-fit: cover; border-radius: 16px; margin-bottom: 8px; }
.gift-info img.rib { height: 34px; margin: 2px auto 0; display: block; }
.gopen .stamp { width: 120px; margin: 0 auto 10px; display: block; animation: gflip .6s ease; }

.notice { position: fixed; top: 50px; left: 0; right: 0; z-index: 9; background: var(--glow); color: var(--night900); font: 700 13px var(--font-body); text-align: center; padding: 7px 12px; display: none; }
.notice.on { display: block; }
.snd-panel .ghost { border: 1px solid var(--night500); background: transparent; }
.fm-form textarea { width: 100%; font: 400 16px var(--font-body); background: var(--night900); color: var(--icing); border: 1px solid var(--night500); border-radius: 12px; padding: 10px 12px; margin: 8px 0; resize: none; }
.fm-form .count { text-align: right; font-size: 12px; opacity: .7; }

.row2 { display: flex; gap: 8px; }

/* 공지 띠가 켜져 있으면 화면 전체를 그만큼 아래로 내린다 (위쪽 버튼을 가리지 않게) */
.notice { height: 30px; line-height: 16px; }
body.notice-on #stage { top: 80px; }
body.notice-on .ui { top: 80px; }
body.notice-on .inside-ui .exit, body.notice-on .radio-btn, body.notice-on .snd-panel, body.notice-on .inside-ui .tosofa, body.notice-on .ui-home .share, body.notice-on .here { margin-top: 30px; }
.coach { width: min(300px, 86vw); } .coach b, .coach span { word-break: keep-all; display: block; }

.ui-home .hset { position: absolute; right: 12px; top: 106px; background: rgba(38,48,79,.9); }
.ui-home .nbtn { position: absolute; right: 12px; top: 106px; background: rgba(38,48,79,.9); }
.hset .dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--candy); margin-left: 6px; }
.hset.alert .dot { display: inline-block; }
body[data-owner='1'] .visitor-only, body[data-owner='0'] .owner-only { display: none; }
body[data-view='inside'] #home-settings, body[data-view='inside'] #neighbor-btn { display: none; }
body.notice-on .ui-home .hset, body.notice-on .ui-home .nbtn { margin-top: 30px; }
.seg2 { display: flex; gap: 6px; margin: 8px 0 14px; } .seg2 button { flex: 1; }
.seg2 .on { background: var(--glow); color: var(--night900); border-color: var(--glow); }
.nrow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--night500); font-size: 14px; }
.nrow .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nrow small { opacity: .7; display: block; font-size: 12px; }
.lockbox { text-align: center; padding: 8px 0 0; } .lockbox h3 { font: 400 22px var(--font-display); color: var(--glow); margin: 6px 0; }

.plaza-btn { position: absolute; right: 12px; top: 16px; background: rgba(38,48,79,.9); }
.ui-plaza .back { position: absolute; left: 16px; bottom: 24px; }
.plaza-radio { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); white-space: nowrap; }
.plaza-hint { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); font-size: 13px; opacity: .75; text-shadow: 0 1px 4px var(--night900); white-space: nowrap; }
body.notice-on .plaza-btn { margin-top: 0; }
.santa-row { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--night500); font-size: 14px; } .santa-row.now { color: var(--glow); font-weight: 700; } .santa-row.past { opacity: .5; } .santa-row .t { width: 64px; flex: none; }

.plaza-count { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); padding: 5px 14px; border-radius: 999px; background: rgba(38,48,79,.92); border: 1px solid var(--mint); font-size: 13px; display: none; white-space: nowrap; }
.plaza-count:not(:empty) { display: block; }
.landing-plaza { margin-top: 12px; }
