:root {
  color-scheme: light;
  --paper: #f6efe6;
  --panel: #fffaf2;
  --ink: #3d2a33;
  --muted: #705c64;
  --accent: #773b53;
  --accent-dark: #58283b;
  --border: #e0d2cc;
  --focus: #733b64;
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; background: var(--paper); color: var(--ink); }
button, input, textarea { font: inherit; }
button, a.primary { min-height: 44px; border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, p { margin: 0; }
.primary, .outline, .text-button, .icon-button {
  padding: .62rem .95rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .28rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.primary { background: var(--accent); color: #fff7f1; }
.primary:hover { background: var(--accent-dark); }
.outline { border-color: var(--border); background: var(--panel); color: var(--ink); }
.outline:hover, .text-button:hover, .icon-button:hover { background: #ede1de; }
.text-button, .icon-button { background: transparent; color: var(--muted); }
.icon-button { min-width: 44px; padding: 0; font-size: 1.55rem; }
.welcome {
  min-height: calc(100svh - 2.5rem);
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 2rem 1.25rem;
  background: #272034 radial-gradient(ellipse at 50% 26%, #503749 0, transparent 52%);
  color: #ffefd8;
}
.site-filing { padding: .75rem 1rem; color: var(--muted); font-size: .75rem; line-height: 1rem; text-align: center; }
.site-filing a { color: inherit; }
.welcome-window {
  position: relative;
  width: 8.4rem;
  height: 9.9rem;
  border: .42rem solid #bb8164;
  border-radius: 4rem 4rem .36rem .36rem;
  box-shadow: 0 0 0 3px #6d4c57, inset 0 0 0 2px #d2a281, 0 1rem 3rem #1b1729;
  background: #3d3153 linear-gradient(#40315b, #80546e);
  margin-bottom: 1.6rem;
  overflow: hidden;
}
.welcome-window::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg,transparent 48%,#bb8164 48% 52%,transparent 52%), linear-gradient(transparent 58%,#bb8164 58% 62%,transparent 62%); }
.welcome-window span { position: absolute; color: #f9db9a; }
.welcome-window span:nth-child(1) { top: 31%; left: 22%; }
.welcome-window span:nth-child(2) { top: 69%; left: 64%; }
.welcome-window span:nth-child(3) { top: 13%; left: 58%; font-size: 2.15rem; }
.welcome-content { width: min(100%, 23rem); text-align: center; }
.welcome h1 { font-size: clamp(1.65rem, 5vw, 2.2rem); letter-spacing: .075em; }
.welcome p { margin-top: .5rem; color: #decad9; }
.welcome form { margin-top: 1.65rem; display: grid; gap: .6rem; text-align: left; }
.welcome form label { color: #f1dccc; font-size: .9rem; }
.welcome .primary { background: #f1c6a6; color: #382537; }
.welcome .primary:hover { background: #ffe0bc; }
.welcome :focus-visible { outline-color: #f4bb95; }
input:not([type="hidden"]), textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  border-radius: .5rem;
  border: 1px solid var(--border);
  background: #fffdfa;
  color: var(--ink);
  padding: .7rem .8rem;
  font-size: 1rem;
}
textarea { resize: vertical; }
.form-error { color: #933346; font-size: .9rem; line-height: 1.5; }
.welcome .form-error { min-height: 1.3rem; margin-top: 0; color: #ffb7bd; }
.home {
  position: relative;
  width: min(928px, 100% - 52px);
  margin: 0 auto;
  padding: 1.45rem 0 max(1.2rem, env(safe-area-inset-bottom));
}
.home-header, .wordmark, .header-actions { display: flex; align-items: center; }
.home-header { justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.wordmark { gap: .7rem; }
.wordmark h1 { font-size: clamp(1.1rem, 3.25vw, 1.55rem); letter-spacing: .055em; }
.brand-light { color: #a06443; border: 1px solid #dbc4ad; background: #f4e3cd; border-radius: .55rem; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; font-size: 1.15rem; }
.header-actions { gap: .45rem; }
.presence { font-size: .81rem; color: #624e58; white-space: nowrap; }
.presence::before { content: ""; display: inline-block; width: .42rem; height: .42rem; margin-right: .36rem; border-radius: 50%; background: #ac8067; vertical-align: .09em; }
.room-shell { overflow: hidden; border-radius: 1rem; border: 1px solid #b89c8d; background: var(--panel); box-shadow: 0 12px 34px #4c28331d; }
.room { position: relative; aspect-ratio: 3 / 2; isolation: isolate; background: #9b685d url("/art/room.webp") center / cover; cursor: crosshair; touch-action: manipulation; outline-offset: -4px; }
.room-shade { position: absolute; inset: 0; background: #211734; opacity: 0; pointer-events: none; z-index: 3; transition: opacity .45s; mix-blend-mode: multiply; }
.room.is-dark .room-shade { opacity: .52; }
.scene-layer { position: absolute; inset: 0; pointer-events: none; }
.scene-layer > * { pointer-events: auto; }
.hotspot {
  position: absolute; z-index: 2; width: 44px; height: 44px; transform: translate(-50%,-50%);
  display: grid; place-items: center; color: #fff4d0; background: transparent;
  padding: 0; border-radius: 50%;
}
.hotspot span { background: #39293a; border: 1px solid #ffe1a5; border-radius: 50%; width: 1.25rem; height: 1.25rem; font-size: .72rem; line-height: 1.12rem; box-shadow: 0 0 0 4px #64344838; }
.hotspot:hover span, .hotspot:focus-visible span { color: #614050; background: #ffdfa2; }
.hotspot-sofa { left: 49%; top: 49%; }
.hotspot-lamp { left: 87%; top: 34%; }
.avatar, .room-object, .place-indicator { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -100%); }
.avatar {
  z-index: 4; width: max(44px, 10%); height: 25%; padding: 0;
  background: transparent; border-radius: .4rem; transition: left .32s linear, top .32s linear;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.avatar::before { content: ""; position: absolute; width: 62%; height: 9%; bottom: 0; border-radius: 50%; background: #38233853; z-index: -1; }
.avatar-img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: bottom; image-rendering: pixelated; pointer-events: none; }
.avatar[data-facing="left"] .avatar-img { transform: scaleX(-1); }
.avatar-name {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); padding: .07rem .38rem;
  border-radius: .36rem; background: #3d2835; color: #fff1da; font-size: clamp(.65rem, 2.6vw, .78rem);
  line-height: 1.3; white-space: nowrap;
}
.avatar-reaction {
  position: absolute; left: 75%; top: 2%; padding: .2rem .4rem; min-width: 1.45rem; border-radius: .5rem;
  background: #fff3df; color: #9e3d62; font-weight: bold; font-size: clamp(.75rem, 3vw, 1.3rem); line-height: 1.1;
  box-shadow: 0 2px 0 #3e254e6e; pointer-events: none; animation: pop .25s ease-out both;
}
@keyframes pop { from { opacity: .3; transform: translateY(6px) scale(.75); } }
.room-object {
  z-index: 5; width: max(44px, 7%); height: max(44px, 10.5%);
  background: transparent; padding: 0; border-radius: .45rem;
  display: grid; justify-items: center; align-items: end; line-height: 1;
}
.object-icon { font-size: clamp(1.45rem, 5vw, 2.65rem); filter: drop-shadow(1px 3px 0 #37283765); }
.room-object[data-type="gift"] .object-icon { color: transparent; position: relative; width: 67%; aspect-ratio: 1.13; background: url("/art/gift.png") center / contain no-repeat; image-rendering: pixelated; }
.room-object:hover, .avatar:hover { filter: brightness(1.12); }
.place-indicator {
  z-index: 7; transform: translate(-50%, -50%); pointer-events: none; width: 25px; height: 17px;
  border: 2px dashed #fff3c7; border-radius: 50%; background: #fff3c746; box-shadow: 0 0 0 2px #4a2a3b;
}
.room.is-placing { cursor: cell; }
.room.is-placing .scene-layer, .room.is-placing .scene-layer > *, .room.is-placing .hotspot { pointer-events: none; }
.control-deck { padding: .72rem .78rem; display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.room-actions, .room-tools { display: flex; gap: .45rem; }
.room-actions button { display: flex; align-items: center; justify-content: center; gap: .26rem; white-space: nowrap; padding: .48rem .55rem; border-radius: .55rem; color: var(--ink); background: transparent; }
.room-actions button:hover { background: #f4e8da; }
.room-actions button span { font-size: 1.05rem; color: var(--accent); }
.room-status { padding: .8rem .3rem 0; min-height: 2.5rem; font-size: .86rem; color: var(--muted); line-height: 1.55; }
.room-drawer { position: absolute; z-index: 10; right: 1rem; top: 4.75rem; width: min(22rem, 100% - 2rem); max-height: min(550px, 73svh); overflow: auto; padding: .65rem 1rem 1rem; border-radius: .75rem; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 16px 45px #3020354d; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; gap: .7rem; margin-bottom: .35rem; }
.drawer-header h2, .dialog-body h2 { font-size: 1.2rem; }
.drawer-section { padding-top: .8rem; margin-top: .6rem; border-top: 1px solid var(--border); font-size: .9rem; }
.drawer-section h3 { margin: 0 0 .5rem; }
#drawer-content > p, .drawer-section p { line-height: 1.5; font-size: .9rem; color: var(--muted); }
.catalog-button, .asset-list button { display: inline-flex; align-items: center; gap: .4rem; background: #f4e9df; color: var(--ink); border-radius: .5rem; padding: .5rem .65rem; margin: .2rem; }
.catalog-button:hover, .asset-list button:hover { background: #eddad3; }
.activity-list, .asset-list { padding-left: 1.2rem; margin-block: .5rem; line-height: 1.55; }
.activity-list li + li { margin-top: .35rem; }
dialog { width: min(426px, 100% - 1.5rem); max-height: 90svh; border-radius: 1rem; border: 1px solid var(--border); background: var(--panel); color: var(--ink); padding: 0; box-shadow: 0 16px 60px #2e1c304a; }
dialog::backdrop { background: #312332a6; }
.dialog-body { padding: 1.25rem; }
.dialog-body h2 { margin-bottom: .95rem; }
#place-fields { display: grid; gap: .75rem; }
#place-fields label { display: grid; gap: .28rem; font-size: .88rem; color: var(--muted); }
#place-error:not(:empty) { margin-top: .7rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: 1.05rem; }
.gift-body { text-align: center; }
.gift-mark { color: #a26449; font-size: 1.45rem; margin-bottom: .3rem; }
.gift-caption { color: var(--muted); font-size: .85rem; }
.gift-note { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; margin-top: .7rem; }
#gift-image { width: 100%; max-height: 42svh; object-fit: contain; border-radius: .55rem; background: #f0e6dc; margin-top: .75rem; }
.gift-actions { justify-content: center; }
@media (max-width: 580px) {
  .home { width: calc(100% - 20px); padding-top: max(.65rem, env(safe-area-inset-top)); }
  .home-header { margin-bottom: .55rem; gap: .25rem; }
  .wordmark { gap: .38rem; }
  .brand-light { width: 1.75rem; height: 1.75rem; }
  .header-actions { gap: 0; }
  .header-actions .text-button { padding-inline: .45rem; font-size: .83rem; }
  .room-shell { border-radius: .72rem; }
  .control-deck { flex-wrap: wrap; padding: .4rem .48rem .5rem; justify-content: flex-end; }
  .room-actions { width: 100%; justify-content: space-around; gap: .12rem; border-bottom: 1px solid #efe5dc; }
  .room-actions button { padding-inline: .35rem; font-size: .83rem; }
  .room-tools { justify-content: flex-end; width: 100%; }
  .room-tools button { font-size: .87rem; }
  .room-drawer { position: fixed; inset: auto 10px max(10px, env(safe-area-inset-bottom)); width: auto; max-height: 64svh; }
  .hotspot span { scale: .83; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
.presence[data-state="together"]::before { background: #56906b; }
.presence[data-state="reconnecting"]::before { background: #bb875a; }
.room-object[data-type="gift"][data-opened="true"] .object-icon { background-image: url("/art/gift-open.png"); }
.avatar[data-reaction="sit"] .avatar-img { translate: 0 12%; scale: .92; }
.avatar[data-reaction="hug"] .avatar-img { scale: 1.04; }
.catalog-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.catalog-list .catalog-button { margin: 0; }
.avatar { transition-duration: var(--travel-ms, .32s); }
.activity-list time { display: block; font-size: .76rem; color: var(--muted); }
.catalog-button small { display: block; }
.room-object[data-type="gift"] .object-icon { font-size: 0; }
.room-object.is-new-gift .object-icon { filter: drop-shadow(0 0 5px #ffd085) drop-shadow(1px 3px 0 #37283765); }
.room-object.is-new-gift::after { content: "✦"; position: absolute; right: 3%; top: 11%; color: #fff1b8; font-size: .9rem; text-shadow: 0 1px #573349; }
@media (prefers-reduced-motion: reduce) {
  .avatar { transition-duration: .001s !important; }
}
