:root {
  --ink: #5B4636;
  --sky: #CFE3F2;
  --snow: #F7FBFF;
  --wood: #B9794A;
  --lamp: #FFD58A;
  --pink: #FF9EAF;
  --paper: #fffdf8;
  font-family: "Yuanti SC", "PingFang SC", "Hiragino Maru Gothic ProN", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); touch-action: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#sky {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 12% 18%, #fff 0 18px, transparent 20px),
    radial-gradient(circle at 88% 30%, #fff 0 10px, transparent 12px),
    linear-gradient(#d7ebf6, #c5dfef 42%, #f7fbff 43%, #e7f3ea 100%);
}
#sky::after {
  content: "";
  position: absolute; left: -10%; right: -10%; bottom: 0; height: 28%;
  background: radial-gradient(80% 100% at 50% 100%, #fff, transparent 70%);
}

#stage {
  position: fixed; left: 50%; top: 50%;
  width: 1024px; height: 768px;
  transform-origin: center center;
  overflow: hidden;
  background: var(--sky);
  border-radius: 8px;
}
#world { position: absolute; inset: 0; }
#snow { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
#snow i {
  position: absolute; top: -40px;
  background: url("/assets/fx/snowflake.svg") center / contain no-repeat;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 0 1px rgba(91, 70, 54, .45));
}
body[data-weather="heavy"] #world::after,
body[data-weather="sunny"] #world::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
body[data-weather="heavy"] #world::after { background: rgba(70, 110, 150, .16); }
body[data-weather="sunny"] #world::after {
  background: radial-gradient(circle at 82% 8%, rgba(255, 214, 120, .55), transparent 28%);
}

.bg { width: 1024px; height: 768px; pointer-events: none; }
.hot, .tree, .spark, .room-hot, .icon-btn, .bird-btn, .text-btn, .food, .slot, .shower {
  min-width: 64px; min-height: 64px;
}
.hot {
  position: absolute; z-index: 2; border: 0; background: transparent; border-radius: 28px; padding: 0;
}
.hot.hint { animation: glow 1.5s ease-in-out infinite; }
.tree {
  position: absolute; border: 0; background: transparent; padding: 0; z-index: 1;
}
.tree.felled {
  background: radial-gradient(ellipse at 50% 82%, #F7FBFF 0 42%, rgba(247, 251, 255, .9) 58%, transparent 72%);
}
.stump {
  position: absolute; left: 50%; bottom: 8%; width: 42%; height: 16px;
  transform: translateX(-50%); border-radius: 8px;
  background: #8A5A3B; box-shadow: 0 0 0 4px var(--ink);
}
.hits {
  position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--lamp); border: 3px solid var(--ink); font-size: 24px; line-height: 30px;
}
.spark {
  position: absolute; z-index: 3; width: 72px; height: 72px; border: 0; background: transparent; padding: 0;
  animation: twinkle 1.2s ease-in-out infinite;
}
.spark img { width: 72px; height: 72px; }

.room-hot {
  position: absolute; border: 0; background: transparent; border-radius: 18px; padding: 8px;
}
.room-hot span {
  display: inline-block; min-height: 40px; padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 253, 248, .92); border: 3px solid var(--ink); font-size: 24px;
}
.mini { position: absolute; width: 42px; height: 42px; pointer-events: none; }
.mini.flipped { transform: scaleX(-1); }
.mini svg, .mini img { width: 42px; height: 42px; }

.back, .text-btn {
  min-height: 64px; padding: 0 22px; border-radius: 999px;
  border: 4px solid var(--ink); background: var(--paper); font-size: 28px;
}
.back { position: absolute; left: 20px; top: 108px; z-index: 8; }
.text-btn.primary { background: var(--lamp); }
.text-btn:active, .icon-btn:active, .hot:active, .food:active { transform: scale(.96); }

.room { position: absolute; inset: 0; }
.wall { position: absolute; left: 0; right: 0; top: 0; height: 48%; }
.floor { position: absolute; left: 0; right: 0; top: 46%; bottom: 0; }
.kitchen .floor { background-image: repeating-linear-gradient(90deg, transparent 0 42px, rgba(91,70,54,.08) 42px 46px); }
.bath .wall { background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px) !important; background-size: 48px 48px !important; background-color: #E3F4FB !important; }
.window {
  position: absolute; right: 70px; top: 130px; width: 180px; height: 140px;
  background: #d7ebf6; border: 6px solid var(--ink); border-radius: 16px; overflow: hidden;
}
.window i { position: absolute; width: 10px; height: 10px; background: #fff; border-radius: 50%; animation: fall 4s linear infinite; }
.window i:nth-child(1) { left: 20px; }
.window i:nth-child(2) { left: 80px; animation-delay: -1s; }
.window i:nth-child(3) { left: 130px; animation-delay: -2s; }
.prop { position: absolute; border: 0; background: transparent; padding: 0; }
.fridge { left: 70px; top: 210px; width: 180px; }
.stove { left: 280px; top: 250px; width: 210px; }
.pot { left: 250px; top: 250px; width: 280px; }
.tub { left: 150px; top: 280px; width: 320px; }
.bed { left: 180px; top: 250px; width: 390px; z-index: 2; }
.lamp { left: 620px; top: 150px; width: 160px; }
.shower { position: absolute; left: 700px; top: 160px; width: 120px; border: 0; background: transparent; padding: 0; z-index: 6; touch-action: none; }
.quilt { position: absolute; left: 250px; top: 500px; width: 280px; z-index: 7; touch-action: none; }
.quilt.covered { left: 190px; top: 330px; width: 380px; }
.recipes { position: absolute; right: 36px; bottom: 120px; }
.hint-line { position: absolute; left: 180px; bottom: 78px; margin: 0; font-size: 24px; background: rgba(255,253,248,.9); border: 3px solid var(--ink); border-radius: 999px; padding: 8px 16px; z-index: 5; }
.room.dim::after { content: ""; position: absolute; inset: 0; background: rgba(28, 48, 84, .28); pointer-events: none; }
.bubble {
  position: absolute; width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--ink);
  background: radial-gradient(circle at 35% 35%, #fff, #d7f4ff 60%, #9ed8f2);
}
.b0 { left: 220px; top: 240px; } .b1 { left: 300px; top: 200px; } .b2 { left: 380px; top: 230px; }
.b3 { left: 260px; top: 320px; } .b4 { left: 420px; top: 300px; }

#place { position: absolute; left: 36px; right: 36px; top: 120px; bottom: 24px; z-index: 3; pointer-events: none; }
.decorating #place { bottom: 210px; }
.piece { position: absolute; pointer-events: auto; touch-action: none; }
.piece img, .piece svg { width: 100%; height: 100%; pointer-events: none; }
.piece.flipped { transform: scaleX(-1); }
.piece.is-selected { filter: drop-shadow(0 0 0 #FFD84D) drop-shadow(0 0 8px #FFD84D); }
.piece.frame .painting { position: absolute; left: 24%; top: 21%; width: 52%; height: 56%; object-fit: cover; border-radius: 4px; }
.decorating .actor { pointer-events: none; }
.decorating .actor .chat { pointer-events: auto; }

#tray {
  position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 9;
  background: rgba(255, 253, 248, .96); border: 4px solid var(--ink); border-radius: 28px;
  padding: 10px 16px 14px; min-height: 180px;
}
#tray p { margin: 0 0 8px; font-size: 24px; }
.tray-row { display: flex; gap: 12px; overflow-x: auto; align-items: flex-end; min-height: 120px; }
.tray-item { width: 120px; flex: none; text-align: center; touch-action: none; }
.tray-item .piece { position: relative; left: auto; top: auto; margin: 0 auto; }
.tray-item span { display: block; font-size: 24px; }
.ghost { position: absolute; z-index: 25; pointer-events: none; }
.ghost .piece { position: relative; }

.actor { position: absolute; width: 132px; height: 132px; z-index: 6; }
.actor.peeking { animation: peek .8s ease-out both; }
.chat { position: absolute; left: 30px; top: -68px; width: 72px; height: 72px; }
.plate {
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  background: rgba(255,253,248,.94); border: 3px solid var(--ink); border-radius: 999px;
  padding: 4px 10px; pointer-events: auto;
}
.plate.on { box-shadow: 0 0 0 4px var(--lamp); }
.plate b, .hrow span, .day, .res b, .help li, .sheet, .sheet p, .sheet h2, .sheet h3, input, .math {
  font-size: 24px;
}
.plate b { display: block; text-align: center; font-weight: 400; }
.hrow { display: flex; align-items: center; gap: 1px; }
.hrow svg { width: 22px; height: 22px; }
.status-bar {
  position: absolute; left: 12px; right: 108px; bottom: 10px; z-index: 8;
  display: flex; gap: 8px; pointer-events: none;
}
body[data-decorate="1"] .status-bar { visibility: hidden; }
.bird-btn { width: 132px; height: 132px; border: 0; background: transparent; padding: 0; border-radius: 50%; }
.bird-btn svg { width: 132px; height: 132px; animation: breathe 2.8s ease-in-out infinite; transform-origin: 50% 70%; }
.actor.selected .bird-btn { box-shadow: 0 0 0 6px var(--lamp); }
.actor.dirty .bird-btn { filter: saturate(.65) contrast(.95); }
.mood-idle .eyes, .mood-hungry .eyes, .mood-surprised .eyes, .mood-talk .eyes,
.wing-l, .wing-r { transform-box: fill-box; transform-origin: center; }
.mood-idle .eyes, .mood-hungry .eyes, .mood-surprised .eyes, .mood-talk .eyes { animation: blink 4.8s infinite; }
.actor .wing-l { animation: flap 5.4s ease-in-out infinite; }
.actor[data-bird="xueqiu"] .eyes { animation-delay: 1.1s; }

#hud { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
#hud button, #hud .res, #hud .day { pointer-events: auto; }
.res, .day, .tools { position: absolute; top: 14px; display: flex; align-items: center; }
.res {
  left: 14px; gap: 6px; background: var(--paper); border: 4px solid var(--ink);
  border-radius: 999px; padding: 4px 10px; max-width: 470px;
}
.res-item { display: flex; align-items: center; gap: 2px; }
.res img { width: 36px; height: 36px; }
.res b { font-weight: 400; min-width: 1.2em; }
.day {
  left: 50%; transform: translateX(-50%); background: rgba(255,253,248,.94);
  border: 4px solid var(--ink); border-radius: 999px; padding: 10px 16px; white-space: nowrap;
}
.tools { right: 110px; gap: 8px; }
.icon-btn { width: 72px; height: 72px; border: 0; background: transparent; padding: 0; position: relative; }
.icon-btn img, .decorate img { width: 100%; height: 100%; }
.icon-btn.muted::after {
  content: ""; position: absolute; left: 18px; right: 18px; top: 34px; height: 6px;
  background: var(--ink); transform: rotate(-35deg); border-radius: 4px;
}
.gear.holding::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 6px solid transparent; border-top-color: var(--lamp); animation: spin 3s linear;
}
.decorate { position: absolute; right: 16px; bottom: 16px; width: 84px; height: 84px; border: 0; background: transparent; padding: 0; pointer-events: auto; }
.decorate i {
  position: absolute; right: -4px; top: -4px; min-width: 32px; height: 32px; border-radius: 999px;
  background: var(--pink); border: 3px solid var(--ink); font-style: normal; font-size: 24px; line-height: 28px;
}

#modal { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; background: rgba(91, 70, 54, .18); padding: 188px 24px 84px; }
#modal.open { display: flex; }
.sheet {
  width: min(920px, 100%); max-height: 680px; overflow: auto;
  background: var(--paper); border: 5px solid var(--ink); border-radius: 32px; padding: 20px 22px 24px;
}
.sheet h2, .sheet h3 { margin: 0; font-weight: 400; font-size: 36px; }
.sheet header, .row-btns, .composer, .ai-row, .name-row { display: flex; align-items: center; gap: 12px; }
.sheet header { justify-content: space-between; margin-bottom: 12px; }
.logo { width: 120px; margin: 0 auto 8px; }
.name-row { margin: 10px 0; }
.name-row img { width: 84px; height: 84px; }
.name-row input, .composer input, #ai-prompt, #paint-input {
  flex: 1; min-height: 64px; border-radius: 18px; border: 4px solid var(--ink); padding: 0 14px; background: #fff;
}
.shop { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.shop-card {
  flex: none; width: 180px; border: 4px solid var(--ink); border-radius: 22px; padding: 8px; background: #fff; position: relative;
}
.shop-card img { width: 140px; height: 120px; margin: 0 auto; object-fit: contain; }
.shop-card h3 { font-size: 24px; }
.ribbon { position: absolute; left: 8px; top: 8px; background: var(--pink); border: 3px solid var(--ink); border-radius: 999px; padding: 2px 8px; font-style: normal; font-size: 24px; }
.where, .left { color: #7b6556; }
.preview { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.preview-art { width: 160px; flex: none; }
.log { min-height: 180px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.me, .bird-line { margin: 0; padding: 10px 14px; border-radius: 18px; border: 3px solid var(--ink); font-size: 24px; }
.me { align-self: flex-end; background: #fff4c8; }
.bird-line { align-self: flex-start; background: #e7f6ff; }
.speak { min-width: 64px; min-height: 64px; border-radius: 18px; border: 4px solid var(--ink); background: #e7f6ff; font-size: 24px; }
.cook-grid { display: flex; gap: 16px; align-items: center; }
.fridge-grid { display: grid; grid-template-columns: repeat(3, 120px); gap: 8px; }
.food, .slot { border: 4px solid var(--ink); border-radius: 18px; background: #fff; padding: 4px; }
.food { width: 120px; height: 120px; }
.food img, .slot img { width: 64px; height: 64px; margin: 0 auto; }
.food span, .food b { display: block; font-size: 24px; font-weight: 400; }
.slots { display: flex; gap: 8px; justify-content: center; }
.slot { width: 84px; height: 84px; }
.pot-side img { width: 220px; margin: 0 auto; }
.mini-bird { width: 112px; margin: 0 auto; }
.mini-bird img { width: 112px; height: 112px; }
.fish-sheet { text-align: center; }
.fish-sheet .left { text-align: center; }
.hole { display: block; width: 200px; min-height: 140px; height: auto; margin: 8px auto; border: 0; background: transparent; position: relative; }
.hole img { width: 200px; height: auto; }
.bobber {
  position: absolute; left: 50%; top: 46%; width: 28px; height: 36px; margin-left: -14px;
  border-radius: 50%; background: linear-gradient(#ff6f6f 50%, #fff 50%); border: 4px solid var(--ink);
}
.bite .bobber { animation: bite .25s linear infinite; }
.catch { width: 180px; margin: 8px auto; }
.help { margin: 0; padding-left: 28px; }
.help li { margin: 8px 0; }
.math { font-size: 40px; }
.math b { display: inline-block; min-width: 72px; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; }
.keys button { width: 84px; height: 64px; border-radius: 16px; border: 4px solid var(--ink); background: #fff; font-size: 28px; }
.switch, .slider { display: block; font-size: 24px; margin: 12px 0; }
.slider input, .switch input { width: 100%; min-height: 48px; }
.row-btns { flex-wrap: wrap; margin-top: 8px; }
#import-file { display: none; }
.hello p { font-size: 32px; }
.shake { animation: shake .35s linear; }

#toast {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 8px; max-width: 620px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; padding: 8px 12px 8px 18px;
}
#toast[hidden] { display: none; }
#toast p { margin: 0; font-size: 28px; }

#night {
  position: fixed; inset: 0; z-index: 80; background: #1c2c4a; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 1s ease;
}
#night.on { opacity: 1; }
#night p { font-size: 64px; margin: 12px 0 0; }
.moon { width: 120px; height: 120px; border-radius: 50%; background: #ffe7a3; box-shadow: 0 0 40px #ffe7a3; }

#rotate {
  display: none; position: fixed; inset: 0; z-index: 100; background: var(--sky);
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
#rotate img { width: 220px; animation: tilt 2s ease-in-out infinite; }
#rotate p { font-size: 40px; margin: 8px 16px; }
@media (orientation: portrait) { #rotate { display: flex; } }

.boot-error { position: fixed; left: 20px; right: 20px; bottom: 20px; font-size: 24px; }

@keyframes fall { to { transform: translateY(860px) rotate(180deg); } }
@keyframes breathe { 50% { transform: translateY(-6px) scale(1.03, .97); } }
@keyframes blink { 0%, 42%, 48%, 100% { transform: scaleY(1); } 45% { transform: scaleY(.12); } }
@keyframes flap { 0%, 72%, 100% { transform: rotate(0); } 82% { transform: rotate(-16deg); } 90% { transform: rotate(8deg); } }
@keyframes glow { 50% { box-shadow: inset 0 0 0 6px rgba(255, 196, 70, .9); } }
@keyframes twinkle { 50% { transform: scale(1.12) rotate(12deg); } }
@keyframes bite { 50% { transform: translateY(-10px) rotate(-8deg); } }
@keyframes peek { from { transform: translateY(70px); } to { transform: none; } }
@keyframes tilt { 50% { transform: rotate(-8deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
