:root {
  color-scheme: light;
  font-family: "KaiTi", "STKaiti", "楷体", "Comic Sans MS", cursive;
  color: #242524;
  background: #83d0f7;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px dashed currentColor; outline-offset: 6px; }
[hidden] { display: none !important; }

.pasture { position: relative; height: 100vh; height: 100svh; overflow: hidden; isolation: isolate; }
.scene { position: absolute; inset: 0; overflow: clip; transform-origin: var(--zoom-x, 50%) var(--zoom-y, 50%); transition: transform 720ms cubic-bezier(.2, .8, .2, 1), filter 720ms ease; }
.scene[data-camera="zoomed"] { transform: scale(var(--zoom-scale, 5.5)); filter: saturate(.75) brightness(.82); }
.layer { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; object-fit: fill; }
.layer-sky { z-index: 0; }
.layer-night { z-index: 1; opacity: var(--night-opacity, 0); transition: opacity var(--clock-transition, 0s) linear; }
.layer-grass { z-index: 5; filter: brightness(var(--grass-brightness, 1)) saturate(var(--grass-saturation, 1)) hue-rotate(var(--grass-hue, 0deg)); transition: filter var(--clock-transition, 0s) linear; }
/* Sun and moon sit above the clouds (a cloud parked on the moon reads as a smudge)
   but still below the grass, so they keep setting behind the horizon. */
.sun, .moon { position: absolute; z-index: 4; top: 0; left: 0; width: clamp(80px, min(15vw, 24svh), 245px); aspect-ratio: 1; will-change: transform; pointer-events: none; visibility: hidden; }
.sun canvas, .moon canvas { transform-origin: 50% 56%; }
.sun canvas, .moon canvas, .cloud canvas, #cow-canvas { display: block; width: 100%; height: 100%; }
/* Clouds live in the top quarter of the sky. Tops are a share of the scene height and
   the height cap is the same unit, so top + height can never exceed 25% of the scene
   (2+11=13, 15+7=22, 8+8=16). The vw term only stops the art from getting too wide on
   narrow screens, it never makes a cloud taller than its share of the scene. */
.cloud { position: absolute; z-index: 3; left: 0; aspect-ratio: 5 / 3; pointer-events: none; will-change: transform; filter: brightness(var(--cloud-brightness, 1)); transition: filter var(--clock-transition, 0s) linear; }
.cloud-one { top: 2%; height: min(11%, 22vw); }
.cloud-two { top: 15%; height: min(7%, 15vw); }
.cloud-three { top: 8%; height: min(8%, 17vw); }
.cow { position: absolute; z-index: 6; left: 0; bottom: 11%; width: clamp(185px, min(35.8vw, 53svh), 543px); aspect-ratio: 1000 / 780; padding: 0; background: none; border: 0; transform-origin: 50% 100%; touch-action: manipulation; will-change: transform; color: var(--scene-ink, #242524); pointer-events: none; }
.cow-hit-area { position: absolute; inset: 0; pointer-events: auto; clip-path: polygon(11% 33%, 66% 33%, 89% 50%, 92% 79%, 87% 100%, 10% 100%, 10% 58%); }
.cow[data-action="walk"] .cow-hit-area { clip-path: polygon(12% 8%, 42% 8%, 48% 22%, 86% 22%, 100% 38%, 100% 81%, 87% 93%, 13% 93%, 0 58%, 0 25%); }
#cow-canvas { transform-origin: 50% 100%; filter: brightness(var(--cow-brightness, 1)) saturate(var(--cow-saturation, 1)); transition: filter var(--clock-transition, 0s) linear; }
.cow[data-action="rest"] #cow-canvas { animation: rest-breathe 3.8s ease-in-out infinite; }
.pasture[data-motion="paused"] #cow-canvas { animation-play-state: paused; }
@keyframes rest-breathe {
  0%, 100% { scale: 1 1; }
  50% { scale: 1.006 1.012; }
}
.cow:focus-visible { border-radius: 49% 47% 29% 32%; }
.cow:active #cow-canvas { scale: .975; }

.building { position: absolute; z-index: 5; display: block; padding: 0; border: 0; background: transparent; color: #25251e; filter: drop-shadow(2px 4px 0 rgb(35 48 24 / 23%)); transition: transform 160ms ease, filter 160ms ease; touch-action: manipulation; }
.building-house { left: calc(var(--house-x, 10.1) * 1%); top: calc(var(--house-y, 33.6) * 1%); width: clamp(92px, calc(var(--house-width, 18.8) * 1vw), 520px); height: auto; aspect-ratio: 1.1; scale: var(--house-scale, 1); transform-origin: center; rotate: -1deg; }
.building-lab { left: calc(var(--lab-x, 69.5) * 1%); top: calc(var(--lab-y, 49) * 1%); width: clamp(76px, calc(var(--lab-width, 10.6) * 1vw), 280px); height: auto; aspect-ratio: 1.1; scale: var(--lab-scale, 1); transform-origin: center; rotate: 2deg; }
.building > img:first-child { position: absolute; left: 50%; top: 50%; display: block; height: auto; object-fit: contain; transform: translate(-50%, -50%); }
.building-house > img:first-child { width: 230%; }
.building-lab > img:first-child { width: 175%; }
.scene-sign { position: absolute; z-index: 5; display: block; width: clamp(84px, 9vw, 184px); aspect-ratio: 1233 / 1276; padding: 0; border: 0; background: transparent; transform-origin: center; transition: filter 160ms ease; touch-action: manipulation; }
.scene-sign-warehouse { left: calc(var(--warehouse-sign-x, 6.5) * 1%); top: calc(var(--warehouse-sign-y, 63) * 1%); scale: var(--warehouse-sign-scale, 1); rotate: -2deg; }
.scene-sign-experiment { left: calc(var(--experiment-sign-x, 71.2) * 1%); top: calc(var(--experiment-sign-y, 67.5) * 1%); scale: var(--experiment-sign-scale, 1); rotate: 2deg; }
.scene-sign img { display: block; width: 100%; height: 100%; object-fit: contain; }
.scene-sign:hover, .scene-sign:focus-visible { filter: drop-shadow(2px 4px 0 rgb(35 48 24 / 25%)); }
.building:hover, .building:focus-visible { transform: translateY(-5px); filter: drop-shadow(2px 7px 0 rgb(35 48 24 / 26%)); }
.building:active { transform: translateY(1px) scale(.98); }
.building:focus-visible { outline-offset: 0; }

.tools { position: absolute; z-index: 10; left: max(22px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; font-size: 17px; }
.tools { color: var(--scene-ink, #242524); transition: color var(--clock-transition, 0s) linear; }
.pasture[data-gallery-open="true"] .tools { opacity: 0; pointer-events: none; }
.quiet-button { padding: 12px 2px; min-height: 44px; border: 0; background: none; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.quiet-button:hover { rotate: -3deg; }
.asset-status, .no-script { position: absolute; z-index: 12; bottom: 64px; left: 24px; right: 24px; width: fit-content; max-width: calc(100% - 48px); margin: 0; background: #fffbea; padding: 10px 14px; border: 1px solid #363a29; font-family: system-ui, sans-serif; font-size: 14px; }

.paper { width: min(420px, calc(100vw - 40px)); max-height: calc(100svh - 40px); padding: 33px 30px 30px; border: 2px solid #31322e; border-radius: 4% 2% 3% 2% / 2% 4% 2% 3%; background: #fffcee; color: #242524; box-shadow: 5px 6px 0 #31322e; overflow: auto; }
.paper::backdrop { background: rgb(47 67 50 / 20%); }
.paper h2 { margin: 0 30px 18px 0; font-size: 27px; font-weight: 700; line-height: 1.4; }
.paper p { font-size: 20px; line-height: 1.7; margin: 10px 0 12px; }
.close-button { position: absolute; right: 12px; top: 8px; width: 44px; height: 44px; border: 0; background: transparent; font: 32px/1 system-ui, sans-serif; }
.paper .small-copy { font-size: 16px; line-height: 1.6; }
.paper-flower { display: block; margin: 25px 0 0; color: #ee9158; font: 48px/1 system-ui, sans-serif; rotate: -10deg; width: fit-content; }
.action-buttons, .time-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.action-buttons button, .time-buttons button { border: 2px solid #30342b; background: transparent; min-height: 44px; padding: 8px 16px; border-radius: 43% 48% 42% 46% / 15% 20% 15% 20%; font-size: 19px; }
.action-buttons button[aria-pressed="true"], .time-buttons button[aria-pressed="true"] { background: #ffe171; rotate: -3deg; }
.action-buttons button:disabled { opacity: .45; cursor: default; }
.time-controls { border-top: 1px dashed #a3a58f; margin-top: 24px; padding-top: 18px; }
.time-controls h3 { margin: 0; font-size: 21px; }
.time-buttons { margin: 14px 0; }
.time-slider-label { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 22px 0 8px; font-size: 18px; }
.time-slider { display: block; width: 100%; min-height: 36px; accent-color: #cf9735; cursor: pointer; }
.auto-label { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: 18px; cursor: pointer; }
.auto-label input { width: 18px; height: 18px; accent-color: #45883e; }
.reduced-copy { padding-top: 12px; border-top: 1px dashed #aaa; }
.assets-dialog { width: min(680px, calc(100vw - 40px)); }
.asset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 18px; margin: 22px 0; }
.asset-grid a { display: grid; gap: 8px; text-align: center; color: inherit; font-size: 19px; text-decoration: none; }
.asset-image { display: block; aspect-ratio: 4 / 3; border: 1px dashed #8e917f; background-color: #e5e6df; background-image: linear-gradient(45deg, #f9f8f1 25%, transparent 25%), linear-gradient(-45deg, #f9f8f1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f9f8f1 75%), linear-gradient(-45deg, transparent 75%, #f9f8f1 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.asset-image img { width: 100%; height: 100%; object-fit: contain; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.gallery-screen { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; background: transparent; color: #251f18; }
.gallery-screen::backdrop { background: transparent; }
.gallery-room { position: absolute; inset: 0; overflow: hidden; background: #594331; opacity: 0; transition: opacity 190ms ease; }
.gallery-screen[data-active="true"] .gallery-room { opacity: 1; }
.gallery-room-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; user-select: none; }
.gallery-header { position: absolute; z-index: 5; inset: 0; pointer-events: none; }
.gallery-back { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); display: grid; place-items: center; width: 72px; height: 72px; padding: 0; border: 0; background: transparent; color: #30291f; pointer-events: auto; }
.gallery-back-icon { position: relative; display: block; width: 54px; height: 34px; }
.gallery-back-icon::before { position: absolute; top: 13px; right: 3px; left: 6px; height: 8px; border-radius: 55% 45% 58% 42%; background: currentColor; box-shadow: 2px 2px 0 #d38b35, -1px -1px 0 #67904b; content: ""; rotate: -2deg; }
.gallery-back-icon::after { position: absolute; top: 4px; left: 5px; width: 19px; height: 19px; border-bottom: 8px solid currentColor; border-left: 8px solid currentColor; border-radius: 3px 2px 4px 2px; box-shadow: -1px 2px 0 #d38b35; content: ""; rotate: 45deg; }
.gallery-back:hover { rotate: -5deg; scale: 1.08; }
.shelf-stack { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.shelf-row { position: absolute; left: 7%; right: 7%; display: flex; height: 264px; align-items: flex-end; justify-content: center; gap: clamp(8px, 4vw, 58px); overflow: visible; pointer-events: none; }
.shelf-row[data-shelf="top"] { top: calc(28% - 264px); }
.shelf-row[data-shelf="middle"] { top: calc(52% - 264px); }
.shelf-row[data-shelf="bottom"] { top: calc(76% - 264px); }
.project-item { display: flex; flex: 0 0 264px; width: 264px; height: 264px; min-width: 0; flex-direction: column; align-items: center; justify-content: flex-end; padding: 0; overflow: visible; border: 0; background: transparent; color: #24221b; pointer-events: auto; transition: transform 180ms ease; }
.project-item:hover, .project-item:focus-visible { transform: translateY(-9px) scale(1.04); }
.project-icon { position: relative; display: block; flex: 0 0 264px; width: 264px; height: 264px; min-height: 264px; aspect-ratio: 1; overflow: visible; background-repeat: no-repeat; background-position: 0 0; }
.project-icon[data-atlas="finished"], .project-detail-art[data-atlas="finished"] { background-image: url("./assets/optimized/v0.10.2/project-objects-finished.de3dae0504b8.webp"); background-size: 300% 300%; }
.project-detail { position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); overflow: auto; background: rgb(37 32 24 / 42%); pointer-events: auto; }
.project-detail[hidden] { display: none; }
.project-detail-card { position: relative; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); grid-template-rows: minmax(0, 1fr); align-items: center; gap: 28px; width: min(960px, 100%); max-height: 100%; padding: 52px 32px 28px; overflow: hidden; border: 2px solid #453d2c; border-radius: 2% 3% 2% 4% / 3% 2% 4% 2%; background: #fff9e8; color: #30291f; box-shadow: 5px 6px 0 rgb(48 41 31 / 65%); }
.project-detail-art { display: block; width: 100%; aspect-ratio: 1; background-repeat: no-repeat; }
.project-detail-video { display: block; width: 100%; min-width: 0; max-height: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #171813; object-fit: contain; }
.project-detail-copy { min-width: 0; min-height: 0; max-height: 100%; padding: 0 6px 5px 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #90836b transparent; }
.project-detail-copy h2 { margin: 0 0 16px; font-size: clamp(28px, 4vw, 36px); line-height: 1.2; }
.project-detail-copy p { margin: 0 0 16px; font-size: 19px; line-height: 1.65; }
.project-detail-enter { display: inline-flex; align-items: center; justify-content: center; gap: 28px; min-width: 136px; min-height: 48px; margin-top: 8px; padding: 10px 22px; border: 2px solid #3e5331; border-radius: 8px 11px 7px 10px; background: #dce9bc; color: #263b23; box-shadow: 2px 3px 0 #546b40; font-size: 22px; font-weight: 700; text-decoration: none; }
.project-detail-enter:hover { background: #cedda8; }
.project-detail-enter:active { transform: translateY(2px); box-shadow: 1px 1px 0 #546b40; }
.project-detail-close { position: absolute; z-index: 1; top: 8px; right: 8px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: #30291f; }
.project-detail-close-icon { position: relative; display: block; width: 22px; height: 22px; }
.project-detail-close-icon::before, .project-detail-close-icon::after { position: absolute; top: 8px; left: 0; width: 22px; height: 5px; border-radius: 60% 42% 50% 38%; background: currentColor; box-shadow: 1px 1px 0 #cf6f43; content: ""; }
.project-detail-close-icon::before { rotate: 45deg; }
.project-detail-close-icon::after { rotate: -45deg; }
.layout-dialog { width: min(540px, calc(100vw - 32px)); }
.layout-object { display: grid; gap: 7px; margin: 15px 0; padding: 8px 13px 12px; border: 1px dashed #77735d; }
.layout-object legend { padding: 0 7px; font-size: 20px; font-weight: 700; }
.layout-control { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 12px; min-height: 47px; font-size: 16px; }
.layout-control output { min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.layout-control input { grid-column: 1 / -1; width: 100%; min-height: 22px; margin: 0; accent-color: #49844a; cursor: ew-resize; }
.layout-reset { min-height: 44px; padding: 7px 12px; border: 1px dashed #514b3a; background: #f6e7ae; color: #28251d; font-size: 16px; }
.layout-reset:hover { rotate: -1deg; }

@media (min-width: 641px) {
  .gallery-room[data-gallery-kind="finished"] .shelf-row[data-shelf="middle"] { transform: translateX(clamp(48px, 7vw, 144px)); }
  .gallery-room[data-gallery-kind="lab"] .shelf-row[data-shelf="middle"] { transform: translateX(clamp(110px, 20vw, 300px)); }
}

@media (max-width: 640px) {
  .sun, .moon { width: min(29%, 24svh); }
  .cow { width: min(79%, 53svh); bottom: 12%; }
  .scene-sign { width: clamp(80px, 30vw, 125px); }
  .tools { left: 18px; font-size: 16px; }
  .paper { padding: 30px 22px 24px; }
  .asset-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-back { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 64px; height: 64px; }
  .gallery-back-icon { scale: .9; }
  .shelf-row { left: 0; right: 0; height: 168px; justify-content: flex-start; gap: 0; overflow-x: auto; overflow-y: visible; padding-left: max(12px, calc((100vw - 336px) / 2)); padding-right: max(12px, calc((100vw - 336px) / 2)); scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x; }
  .shelf-row::-webkit-scrollbar { display: none; }
  .shelf-row[data-shelf="top"] { top: calc(25% - 168px); }
  .shelf-row[data-shelf="middle"] { top: calc(47% - 168px); }
  .shelf-row[data-shelf="bottom"] { top: calc(69% - 168px); }
  .project-item { flex-basis: 168px; width: 168px; height: 168px; }
  .project-icon { flex-basis: 168px; width: 168px; height: 168px; min-height: 168px; }
  .project-detail-card { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 16px; width: min(420px, 100%); padding: 52px 22px 24px; }
  .project-detail-art { width: min(160px, 24svh); justify-self: center; }
  .project-detail-copy h2 { margin-bottom: 12px; font-size: 28px; }
  .project-detail-copy p { margin-bottom: 12px; font-size: 18px; line-height: 1.6; }
  .project-detail-enter { width: 100%; }
  .layout-dialog { padding: 28px 18px 18px; }
  .layout-object { gap: 3px; margin: 7px 0; padding: 4px 10px 5px; }
  .layout-object legend { font-size: 18px; }
  .layout-control { min-height: 36px; gap: 2px 10px; font-size: 14px; }
  .layout-control input { min-height: 18px; }
}

@media (min-width: 641px) and (max-height: 480px) {
  .project-detail-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; width: min(960px, 100%); padding: 48px 24px 20px; }
  .project-detail-art { width: min(170px, 100%); justify-self: center; }
  .project-detail-copy h2 { margin-bottom: 8px; font-size: 28px; }
  .project-detail-copy p { margin-bottom: 10px; font-size: 17px; line-height: 1.5; }
  .project-detail-enter { min-height: 44px; margin-top: 0; padding-block: 8px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
  .cow[data-action="rest"] #cow-canvas { animation: none; }
  .scene, .gallery-room { transition-duration: 0s; }
}
