:root {
  color-scheme: light;
  --paper: #f6f3e9;
  --ink: #25372c;
  --muted: #526051;
  --accent: #ab5a36;
  --line: #dddfd2;
  --soft-green: #e9ede1;
  --green: #345744;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

body { margin: 0; }
button { color: inherit; font: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.site-shell {
  width: min(100%, 1272px);
  margin: 0 auto;
  padding-inline: max(48px, env(safe-area-inset-left)) max(48px, env(safe-area-inset-right));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 81px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
}

.wordmark, .brand-icon, .sound-button, .scene-badge { display: inline-flex; align-items: center; }
.wordmark { gap: 11px; font-weight: 650; letter-spacing: .08em; }
.scene-controls { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; margin-bottom: 5px; }
.scene-controls .sound-button { min-width: 0; white-space: nowrap; }
.brand-icon {
  width: 36px;
  height: 36px;
  justify-content: center;
  border-radius: 50%;
  background: #304939;
  color: #f5e9cc;
}

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-button {
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 120px;
  padding: 0 14px;
  border: 1px solid #d4d9cb;
  border-radius: 99px;
  background: #faf8ef;
  font-size: .875rem;
  cursor: pointer;
}
.sound-button[aria-pressed="true"] { background: var(--soft-green); border-color: #aebfae; }
.sound-button .when-audible, .sound-button[aria-pressed="true"] .when-muted { display: none; }
.sound-button[aria-pressed="true"] .when-audible { display: block; }

.content {
  display: grid;
  grid-template-columns: minmax(276px, .7fr) minmax(0, 1.4fr);
  grid-template-rows: 1fr 1fr;
  grid-template-areas: "intro play" "actions play";
  column-gap: clamp(30px, 6vw, 92px);
  row-gap: 37px;
  align-items: start;
  padding-block: clamp(32px, 5vh, 64px) 27px;
}

.intro { grid-area: intro; align-self: end; }
h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  font-size: clamp(4.3rem, 7.4vw, 7.1rem);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.07em;
}
h1 > span { display: block; padding-top: .13em; }
.title-dot { color: var(--accent); font-size: .77em; }
.intro .cat-breed {
  margin-top: 18px;
  color: var(--accent);
  font-size: .9375rem;
  letter-spacing: .06em;
}
.intro .cat-breed + p { margin-top: 10px; }
.intro p {
  margin: 27px 0 0;
  max-width: 17em;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.125rem);
  line-height: 1.8;
  letter-spacing: .025em;
}
.room-link {
  display: inline-flex;
  align-items: center;
  gap: .6em;
  min-height: 44px;
  margin-top: .6rem;
  color: var(--green);
  font-size: .9rem;
  text-underline-offset: .28em;
}

.play { grid-area: play; min-width: 0; }
.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  isolation: isolate;
  background: #8b9275;
  box-shadow: 0 15px 32px #26372225;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
.scene[data-active="true"] { cursor: grabbing; }
.scene[data-hand-visible="true"] { cursor: none; }
.room, .scene-shade, #cat-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
/* Decoders for the motion clips; the canvas draws them. */
.motion-source {
  position: absolute;
  width: 2px;
  height: 2px;
  opacity: .001;
  pointer-events: none;
}
.room { object-fit: cover; }
.scene-shade { background: radial-gradient(ellipse at 47% 43%, transparent 35%, #2135263b 100%); }
.cat-poster {
  position: absolute;
  top: 53.5%;
  left: 51.5%;
  width: 86%;
  height: 86%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.scene[data-photographic="true"] .cat-poster {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
}
#cat-canvas { opacity: 0; }
.scene.is-ready #cat-canvas { opacity: 1; }
.scene.is-ready .cat-poster { opacity: 0; }
.scene-badge {
  position: absolute;
  top: 18px;
  left: 18px;
  gap: 7px;
  max-width: calc(100% - 36px);
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid #fffae74d;
  border-radius: 99px;
  background: #23382be3;
  color: #fff8e7;
  font-size: .875rem;
  pointer-events: none;
}
.scene-badge .icon { width: 15px; height: 15px; color: #f2cc82; }
.touch-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 36px;
  height: 36px;
  margin: -18px;
  border: 1.5px solid #fff6d8;
  border-radius: 50%;
  box-shadow: 0 0 0 3px #fff1d72e, 0 0 7px #22372275;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.touch-marker::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid #fff5dc9c;
  border-radius: 50%;
}
.pet-hand {
  position: absolute;
  top: 0;
  left: 0;
  width: clamp(94px, 32%, 196px);
  aspect-ratio: 3 / 4;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 105ms ease-out;
}
.scene[data-hand-visible="true"] .pet-hand { opacity: 1; }
.pet-hand[data-hidden-immediately] { transition: none; }
.pet-hand-pose,
.pet-hand img {
  position: absolute;
  inset: 0;
}
.pet-hand-pose {
  transform: translate(-32%, -23%);
  filter: drop-shadow(1px 3px 3px #34281845);
}
.pet-hand img {
  display: block;
  width: 100%;
  height: 100%;
}
.pet-hand-front { clip-path: inset(0 0 42% 0); }
.pet-hand-sleeve {
  clip-path: inset(57.7% 0 0 0);
  mask-image: linear-gradient(#000 94%, transparent);
  transform-origin: 0 58%;
  transform: matrix(1, 0, var(--sleeve-skew, 0), var(--sleeve-stretch, 1), 0, 0);
}
.pet-hand[data-pose="tail"] .pet-hand-stroke,
.pet-hand[data-pose="stroke"] .pet-hand-tail { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .pet-hand { transition: none; }
}
@media (max-width: 540px) {
  .site-header .wordmark { white-space: nowrap; gap: 6px; }
  .scene-controls { gap: 5px; }
  .scene-controls .sound-button { gap: 4px; padding: 0 9px; font-size: .78rem; }
  .scene-controls .icon { width: 16px; height: 16px; }
}
.feedback {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  margin-top: 7px;
  padding-inline: 3px;
  font-size: .875rem;
  color: var(--muted);
}
.cat-meters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 24px);
  padding: 13px 3px 1px;
}
.cat-meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  color: var(--muted);
  font-size: .875rem;
}
.cat-meters + .feedback { min-height: 32px; margin-top: 3px; }
.trust-track {
  grid-column: 1 / -1;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 5px;
  background: #dbdfd2;
}
.trust-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #a65a35;
  transition: width .16s ease-out;
}
#trust-value { min-width: 4ch; font-variant-numeric: tabular-nums; }
.meter-value { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
.cat-meter-patience .trust-track span { background: #727e56; }
#pressure-source { margin-left: auto; text-align: right; }
.meter { display: flex; gap: 3px; }
.meter span {
  width: clamp(5px, 1.1vw, 13px);
  height: 5px;
  border-radius: 4px;
  background: #dbdfd2;
}
.meter span.is-lit { background: #54765a; }

.actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 350px;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 71px;
  padding: 8px 4px;
  border: 1px solid #d8decf;
  border-radius: 13px;
  background: #faf9f1;
  color: #344e3c;
  font-size: .875rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease;
}
.action .icon { width: 23px; height: 23px; }
.action[data-active="true"], .action:active {
  background: var(--soft-green);
  border-color: #99ae99;
}
@media (hover: hover) {
  .action:hover, .sound-button:hover { background: var(--soft-green); }
}

.site-footer {
  padding: 13px 0 max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.6;
}
.site-footer summary { display: list-item; width: fit-content; padding: 5px 8px 5px 0; cursor: pointer; }
.site-footer p { margin: 7px 0 0; }
.site-footer a { color: #365740; text-underline-offset: .18em; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 800px) {
  .site-shell {
    max-width: 635px;
    padding-inline: max(17px, env(safe-area-inset-left)) max(17px, env(safe-area-inset-right));
  }
  .site-header { min-height: 64px; }
  .brand-icon { width: 32px; height: 32px; }
  .wordmark { font-size: .9375rem; }
  .content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "intro" "play" "actions";
    row-gap: 14px;
    padding-block: 25px 22px;
  }
  h1 { font-size: clamp(2.75rem, 12vw, 5.1rem); line-height: 1.08; }
  h1 > span { display: inline; padding-top: 0; }
  .intro p { margin-top: 6px; max-width: none; font-size: 1rem; line-height: 1.55; }
  .intro .cat-breed { margin-top: 4px; font-size: .875rem; }
  .intro .cat-breed + p { margin-top: 4px; }
  .scene { border-radius: 18px; }
  .scene-badge { top: 12px; left: 12px; min-height: 32px; }
  .feedback { min-height: 33px; margin-top: 7px; }
  .meter span { width: clamp(6px, 2vw, 12px); }
  .actions { max-width: none; }
  .action { min-height: 56px; flex-direction: row; gap: 5px; }
  .action .icon { width: 18px; height: 18px; }
}

@media (max-width: 350px) {
  .site-shell { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .scene { border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .action, .trust-track span { transition: none; }
}
