* { box-sizing: border-box; }

html, body { min-width: 320px; min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  overflow: hidden;
  background: #143c2c;
  font-family: "Microsoft YaHei", sans-serif;
}

.farm {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #58aa39;
}

.farm-scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.farmer, .flower {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
}

.farmer {
  left: 60.9%;
  top: 85.7%;
  width: 3.34%;
  height: 11.43%;
  transform: translate(-50%, -100%);
  transition: opacity 120ms linear;
  z-index: 3;
}

.farmer.is-walking { animation: farmer-step 360ms steps(2, end) infinite; }
.farmer.is-inside { opacity: 0; }

.flower {
  width: 0.84%;
  height: 1.43%;
  z-index: 2;
  animation: flower-breeze 1.9s ease-in-out infinite alternate;
  will-change: transform;
}
.flower-one { left: 42.08%; top: 69.3%; }
.flower-two { left: 42.5%; top: 72.1%; animation-delay: -0.7s; }
.flower-three { left: 20.8%; top: 82.5%; animation-delay: -1.3s; }


.house-entry {
  position: absolute;
  left: 61.4%;
  top: 39.5%;
  width: 3.8%;
  height: 12%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.house-entry:focus-visible { outline: 3px solid #ffe59d; outline-offset: -3px; }

.mailbox-entry {
  position: absolute;
  z-index: 4;
  top: 48%;
  left: 76.2%;
  width: 4.5%;
  height: 13%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.mailbox-entry:focus-visible { outline: 3px solid #ffe59d; outline-offset: -3px; }

.entry-note {
  position: absolute;
  left: 50%;
  top: 65%;
  margin: 0;
  padding: 5px 9px;
  transform: translateX(-50%);
  border: 2px solid #65361c;
  background: #ffe2a0;
  color: #743d24;
  font-size: clamp(12px, 1.5vw, 18px);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

.entry-note.is-visible { opacity: 1; }

.mail-note {
  position: absolute;
  z-index: 7;
  top: 43%;
  left: 76.5%;
  margin: 0;
  padding: 5px 9px;
  border: 3px solid #7c3b1e;
  background: #ffe0a0;
  color: #6c321c;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.mail-note.is-visible { opacity: 1; transform: translate(-50%, 0); }

.mailbox-panel {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(3 16 34 / .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.mailbox-panel.is-open { opacity: 1; pointer-events: auto; }
.mailbox-paper {
  position: relative;
  width: min(88vw, 395px);
  max-height: min(70vh, 480px);
  padding: 26px 25px 22px;
  border: 6px solid #70351b;
  outline: 3px solid #eaa04d;
  background: #ffe3a4;
  color: #6d331c;
  box-shadow: 0 12px 0 rgb(45 18 8 / .45);
  transform: translateY(12px) scale(.96);
  transition: transform 180ms ease;
}

.mailbox-panel.is-open .mailbox-paper { transform: translateY(0) scale(1); }
.mailbox-paper h2 { margin: 0 0 14px; color: #74381f; font-size: 20px; text-align: center; }
.mailbox-close { position: absolute; top: 8px; right: 9px; display: grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 2px solid #71351d; background: #bd582d; color: #fff1b7; font: 900 17px/1 sans-serif; cursor: pointer; }
.mailbox-memos { display: grid; gap: 9px; max-height: min(51vh, 350px); overflow-y: auto; padding-right: 4px; }
.mailbox-memo { padding: 9px 10px; border: 2px solid #aa6335; background: #fff0be; }
.mailbox-memo strong { display: block; font-size: 15px; }
.mailbox-memo p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.mailbox-memo.is-done { opacity: .62; }
.mailbox-empty { margin: 18px 0; color: #93603b; font-size: 14px; line-height: 1.6; text-align: center; }

@keyframes flower-breeze {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

@keyframes farmer-step {
  50% { transform: translate(-50%, calc(-100% - 2px)); }
}

@media (prefers-reduced-motion: reduce) {
  .flower { animation: none; }
  .farmer { transition: none; animation: none; }
}

.home-link {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid #63381e;
  background: #f5c66f;
  color: #63381e;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}
