@font-face {
  font-family: "Ma Shan Zheng";
  src: url("assets/fonts/MaShanZheng-subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #1c1c1c;
  --quiet: #5e5e5e;
  --paper: #FAE5D7;
  --vh: 1vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Ma Shan Zheng", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: calc(var(--vh) * 100);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 4px;
}

#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #FAE5D7;
}

#stage, #reveal {
  position: fixed;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(420px, 100%);
  transform: translateX(-50%);
}

#stage.is-done { visibility: hidden; }

.word {
  margin: 0 0 36px;
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.04em;
  color: var(--quiet);
}

.bar {
  display: block;
  width: 0;
  height: 1.5px;
  margin: 8px auto 0;
  background: var(--ink);
}

#mover {
  position: absolute;
  left: 50%;
  top: 43%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  transition: transform 0.32s cubic-bezier(0.2, 0.75, 0.2, 1);
}

#key {
  position: relative;
  width: min(68vw, 230px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#key.is-down .cap {
  transform: translateY(8px) scale(0.98, 0.95);
  transform-origin: center bottom;
}

.cap {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.12s ease;
}

#cat {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -18px;
  width: 168px;
  margin-left: -84px;
  pointer-events: none;
}

#cat img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 62% 78%;
  animation: cat-idle 1.7s ease-in-out infinite;
}

#cat.is-shoving img { animation: cat-shove 0.22s ease-in-out infinite; }
#cat.is-going img { animation: cat-hop 0.28s ease-in-out infinite; }
#cat.is-busy img { animation: cat-nibble 0.4s ease-in-out infinite; }
#cat.is-buzzed img { animation: cat-buzz 0.34s ease-in-out infinite; }
#cat.on-photo img { animation: cat-cheer 0.9s ease-in-out infinite; }

@keyframes cat-idle {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}

@keyframes cat-shove {
  0%, 100% { transform: translate(0, 0) rotate(-2deg); }
  45% { transform: translate(-14px, 10px) rotate(-14deg) scale(1.05, 0.92); }
  75% { transform: translate(6px, -4px) rotate(8deg); }
}

@keyframes cat-hop {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-12px) rotate(6deg); }
}

@keyframes cat-nibble {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(8deg) scale(1.07, 0.93); }
}

@keyframes cat-buzz {
  0%, 100% { transform: translateY(0) rotate(-12deg); }
  45% { transform: translateY(-22px) rotate(14deg) scale(1.05, 0.94); }
}

@keyframes cat-cheer {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-8px); }
}

.lure {
  position: absolute;
  z-index: 3;
  width: 74px;
  padding: 6px;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.lure img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.lure.is-held {
  z-index: 6;
  cursor: grabbing;
}

#food {
  left: 10%;
  bottom: calc(7% + env(safe-area-inset-bottom));
  transform: rotate(-8deg);
}

#toy {
  right: 12%;
  bottom: calc(9% + env(safe-area-inset-bottom));
  transform: rotate(7deg);
}

#hint {
  position: absolute;
  left: 50%;
  z-index: 1;
  pointer-events: none;
  bottom: calc(22% + env(safe-area-inset-bottom));
  width: min(16em, 80vw);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-size: 15px;
  line-height: 1.55;
  color: var(--quiet);
}

#hint[hidden] { display: none !important; }

#reveal {
  overflow-y: auto;
  touch-action: pan-y;
}

#reveal[hidden] { display: none !important; }

.letter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 100%;
  padding: calc(20px + env(safe-area-inset-top)) 28px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}

#reveal h1 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

#reveal .note {
  max-width: 23em;
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--quiet);
}

#reveal figure {
  position: relative;
  width: min(62vw, 240px);
  margin: 0;
}

#reveal img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: 50% 58%;
  background: #eceae8;
  border: 1.5px solid var(--ink);
  border-radius: 2px 6px 3px 5px;
}

#reveal figcaption {
  width: min(84vw, 348px);
  margin: 16px 0 0;
  margin-left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 15px;
  line-height: 1.7;
}

#cat.on-photo {
  position: absolute;
  top: 6px;
  right: -6px;
  left: auto;
  width: 88px;
  margin-left: 0;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  #mover, #cat, .cap { transition: none; }
  #cat img { animation: none; }
}
