:root {
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #263a32;
  background: #f4ebdd;
  font-synthesis: none;
  --green: #263a32;
  --paper: #fff9ee;
  --rust: #b9663e;
}
* {
  box-sizing: border-box;
}
body {
  font-size: 16px;
  margin: 0;
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  border: 1px solid #263a3250;
  background: transparent;
  border-radius: 9px;
  min-height: 44px;
  padding: 10px 17px;
  cursor: pointer;
}
button:hover {
  background: #e9dfcc;
}
button:disabled {
  opacity: 0.48;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #b9663e;
  outline-offset: 3px;
}
button.primary {
  color: #fff9ee;
  background: #263a32;
  border-color: #263a32;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px clamp(16px, 5vw, 70px);
  border-bottom: 1px solid #263a3225;
  min-height: 64px;
}
header span {
  letter-spacing: 0.15em;
  font-size: 16px;
}
header a {
  color: inherit;
  text-decoration: none;
  font-size: 16px;
  padding: 12px 0;
}
header button {
  font-size: 14px;
}
main {
  max-width: 1160px;
  margin: auto;
  padding: 24px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #796b56;
  margin: 0 0 10px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-family: 'Songti SC', serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 17px;
}
#title-screen {
  max-width: 660px;
  text-align: center;
  margin: 55px auto;
}
#title-screen h1 {
  font-size: clamp(38px, 7vw, 70px);
  margin: 22px 0;
}
.tagline {
  font-size: 20px;
  line-height: 1.8;
}
/* Shared original object layers compose a still-life, with no puzzle state. */
.title-table {
  position: relative;
  aspect-ratio: 960 / 500;
  margin: 24px 0;
  overflow: hidden;
  border-radius: 18px;
  background: #bfa689 url('assets/art/desk.webp') center / 100% 100%;
  box-shadow:
    inset 0 0 0 1px #795b4030,
    0 8px 16px #59462a1a;
}
.title-table img {
  display: block;
  width: 100%;
}
.title-mat {
  position: absolute;
  inset: 9% 7%;
  border: 1px dashed #bdc4a7;
  outline: 7px solid #748575;
  border-radius: 5px;
  background: #748575;
  box-shadow: 0 5px 8px #263a3240;
}
.title-flash {
  position: absolute;
  width: 44%;
  left: 11%;
  top: 19%;
  transform: rotate(-12deg);
}
.title-flash .title-cap {
  position: absolute;
  width: 13.5%;
  right: 2%;
  top: 13%;
}
.title-car {
  position: absolute;
  width: 34%;
  left: 14%;
  top: 52%;
  transform: rotate(9deg);
}
.title-car .title-cover {
  position: absolute;
  width: 96%;
  left: 2%;
  top: 9.5%;
}
.title-player {
  position: absolute;
  width: 30%;
  right: 11%;
  top: 18%;
  transform: rotate(8deg);
}
.title-player .title-tape {
  position: absolute;
  width: 73%;
  left: 13.5%;
  top: 13%;
}
.title-player .title-reel {
  position: absolute;
  width: 17.6%;
  top: 24%;
}
.title-reel-left {
  left: 23.2%;
}
.title-reel-right {
  right: 23.2%;
}
.title-paper {
  position: absolute;
  width: 19%;
  height: 20%;
  right: 17%;
  bottom: 16%;
  background: #f7edcf;
  transform: rotate(-8deg);
  padding: 2% 3%;
  box-shadow: 1px 3px 5px #263a3226;
}
.title-paper i {
  display: block;
  height: 1px;
  margin: 11% 0;
  background: #a99a77;
}
.title-table .title-brush {
  position: absolute;
  width: 18%;
  right: 8%;
  bottom: 13%;
  transform: rotate(-38deg);
}
.story {
  line-height: 1.9;
  color: #746956;
  font-size: 16px;
}
.footnote {
  font-size: 12px;
  color: #867965;
  margin: 20px;
}
.commission {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* Editable paper illustration; the letter remains selectable, readable HTML. */
.commission-letter {
  --paper: #fbf0d7;
  --ink: #67563e;
  position: relative;
  max-width: 660px;
  margin: 18px 0 14px;
  padding: 14px 20px 10px;
  color: var(--ink);
  background: linear-gradient(135deg, transparent 12px, var(--paper) 0);
  border-bottom: 1px solid #cbb996;
  box-shadow: 0 3px 4px #49351e12;
  font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
}
.commission-letter[data-level='car'] {
  --paper: #edf0dd;
  --ink: #465d4a;
}
.commission-letter[data-level='cassette'] {
  --paper: #f2e5d8;
  --ink: #705148;
}
.letter-tape {
  position: absolute;
  top: -7px;
  right: 28px;
  width: 42px;
  height: 15px;
  transform: rotate(5deg);
  background: #c8b98470;
  border-inline: 1px dashed #ad9e6b80;
}
.commission-letter blockquote {
  margin: 0;
}
.commission-letter p {
  margin: 0;
  font-size: 16px;
  line-height: 1.8;
  background: repeating-linear-gradient(transparent 0 27px, #97856226 28px 29px);
}
.commission-letter figcaption {
  margin-top: 4px;
  text-align: right;
  font-size: 16px;
  line-height: 1.5;
}
#save-status {
  font-size: 12px;
  color: #647265;
  min-height: 16px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(270px, 1fr);
  gap: 22px;
}
.scene {
  position: relative;
  background: #966b4d;
  border-radius: 18px;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}
.canvas-label {
  position: absolute;
  bottom: 18px;
  left: 22px;
  color: #fff9ee9c;
  letter-spacing: 0.12em;
  font-size: 12px;
}
#zoom {
  background: #fff9eedb;
  font-size: 14px;
}
aside {
  background: #fff9ee;
  border: 1px solid #d8ceba;
  border-radius: 14px;
  padding: 20px;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-heading span {
  font-size: 12px;
  color: #786b57;
}
.panel-heading h2 {
  margin: 0 0 14px;
}
.part-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.part-list button {
  font-size: 14px;
  text-align: left;
  padding: 10px;
  line-height: 1.6;
}
.part-list button[aria-pressed='true'] {
  background: #e4eadb;
  border-color: #263a32;
}
.selection {
  margin-top: 20px;
  border-top: 1px dashed #d3c6ac;
  padding-top: 18px;
}
.selection p {
  font-size: 16px;
  line-height: 1.7;
  color: #746956;
}
.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.actions button {
  font-size: 14px;
}
.feedback {
  padding: 18px 4px 4px;
  min-height: 65px;
  font-size: 16px;
  line-height: 1.65;
}
.feedback p {
  margin-bottom: 8px;
}
#hint {
  color: #59412f;
  font-size: 16px;
}
#hint article {
  border-left: 3px solid #b48a57;
  padding: 8px 12px;
  margin-block: 10px;
  background: #faf3e6;
  border-radius: 0 10px 10px 0;
}
#hint h3 {
  font-size: 16px;
  margin: 0 0 4px;
}
#hint p {
  margin: 0;
}
#hint figure {
  margin: 12px 0 0;
}
#hint svg {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
}
#hint figcaption {
  font-size: 16px;
}
.tools {
  display: flex;
  gap: 10px;
}
.tools .primary {
  margin-left: auto;
  min-width: 130px;
}
#success,
#delivered {
  margin-top: 22px;
  padding: 24px;
  background: #e4eadb;
  border-radius: 12px;
  line-height: 1.8;
}
dialog {
  border: 1px solid #c5a163;
  border-radius: 16px;
  background: #fff9ee;
  width: min(400px, 90%);
  padding: 30px;
}
dialog::backdrop {
  background: #263a3280;
}
dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
dialog p {
  font-size: 16px;
  color: #786b57;
}
[hidden] {
  display: none !important;
}
@media (max-width: 700px) {
  main {
    padding: 16px;
  }
  h1 {
    font-size: 24px;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .scene {
    max-height: 54svh;
    display: flex;
    justify-content: center;
  }
  canvas {
    width: auto;
    max-width: 100%;
    height: 54svh;
    object-fit: contain;
  }
  aside {
    padding: 14px;
  }
  .part-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .selection {
    margin-top: 12px;
    padding-top: 12px;
  }
  .panel-heading h2 {
    font-size: 16px;
  }
  .selection h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  .selection p {
    margin-bottom: 8px;
  }
  .commission-letter {
    padding: 12px 14px 8px;
    margin-bottom: 8px;
  }
  #save-status {
    margin-bottom: 8px;
  }
  .tools {
    /* Keep actions in document flow so scrolling cannot hide repair feedback. */
    flex-wrap: wrap;
    background: #f4ebdd;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  }
  #title-screen {
    margin-top: 32px;
  }
  header span {
    font-size: 16px;
  }
  header {
    padding: 8px 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
/* Keep the canvas element and its pixels at the same aspect ratio for hit testing. */
@media (max-width: 700px) {
  .scene {
    max-height: none;
    display: block;
  }
  canvas {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: fill;
  }
}
.hidden {
  display: none !important;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin: 24px 0 38px;
}
.commission-card {
  padding: 24px;
  background: #fff9ee;
  border: 1px solid #d5c9b2;
  border-radius: 14px;
}
.commission-card p {
  font-size: 16px;
  line-height: 1.8;
}
.commission-card button {
  margin-top: 10px;
}
#intro-screen,
#ending-screen {
  max-width: 660px;
  margin: 55px auto;
  line-height: 2;
}
#view-switch,
#clean-cancel {
  background: #fff9eedb;
  z-index: 1;
}
.ending-stage {
  background: #dfcfad;
  border-radius: 20px;
  padding: 70px 24px;
  text-align: center;
  font-family: serif;
  font-size: 24px;
  margin: 25px 0;
}
#restart {
  margin: 20px 0;
}
#stop {
  margin-left: auto;
}
.tools .primary {
  min-width: 100px;
}
#success button {
  margin-top: 8px;
}
#beam-controls {
  max-width: 420px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid #b9beaa;
  border-radius: 12px;
}
#beam-controls input {
  display: block;
  width: 100%;
  min-height: 44px;
}
/* Four controls must fit on the narrowest supported phone without vertical text. */
.tools button {
  white-space: nowrap;
  padding: 10px 12px;
  font-size: 14px;
}
.storage-notice {
  max-width: 1112px;
  margin: 12px auto;
  padding: 14px 20px;
  background: #efe0bb;
  border: 1px solid #c5a163;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.7;
}
.storage-notice p {
  margin: 0 0 8px;
}
#recover-save {
  margin: 0 24px 12px;
}
#loading-screen {
  max-width: 640px;
  margin: 65px auto;
  padding: 28px;
  line-height: 1.8;
}
.audio-notice {
  max-width: 1112px;
  margin: 8px auto;
  font-size: 16px;
  color: #815a3d;
}
.audio-notice:empty {
  display: none;
}
.commission-art {
  display: block;
  width: 100%;
  height: 105px;
  object-fit: contain;
  margin: 12px 0 24px;
  filter: drop-shadow(0 5px 4px #263a3220);
}
.silhouette {
  filter: brightness(0) opacity(0.13);
}
#ending-canvas {
  border-radius: 18px;
  margin: 24px 0;
}
.ending-stage {
  padding: 12px;
  background: transparent;
  margin: 0;
  font-size: 18px;
}

.tutorial {
  margin-top: 12px;
  border-left: 3px solid #c5a163;
  padding: 10px 12px;
  background: #efe4ce;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tutorial p {
  flex: 1 1 220px;
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}
.tutorial button {
  font-size: 14px;
}

.bench-navigation,
.scene-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bench-navigation {
  margin: 0 0 12px;
}
.bench-navigation button {
  font-size: 14px;
}
.bench-navigation [aria-pressed='true'] {
  background: #263a32;
  color: #fff9ee;
}
.scene-controls {
  padding: 8px 12px;
  background: #e7d8bd;
  justify-content: space-between;
}
#tray-pages {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
#hint svg text {
  fill: #59412f;
  stroke: none;
  text-anchor: middle;
  font-size: 16px;
  font-family: inherit;
}
#repair-notes {
  margin-top: 16px;
  border: 1px solid #d8c6aa;
  border-radius: 12px;
  padding: 12px 16px;
  background: #faf3e6;
  font-size: 16px;
  line-height: 1.65;
}
#repair-notes summary {
  cursor: pointer;
  min-height: 44px;
  padding-block: 8px;
}
#repair-notes ul {
  padding-left: 22px;
}
#repair-notes li {
  margin-block: 8px;
}
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.comparison-grid figure {
  margin: 0;
  padding: 12px;
  background: #faf3e6;
  border-radius: 12px;
}
.comparison-grid h4 {
  font-size: 16px;
  margin: 0 0 8px;
}
.comparison-grid canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.comparison-grid figcaption {
  font-size: 16px;
  line-height: 1.65;
  margin-top: 12px;
}
@media (max-width: 600px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}
#help-reminder {
  padding: 12px 16px;
  margin-block: 12px;
  border: 1px solid #b89965;
  border-radius: 12px;
  background: #faf3e6;
  font-size: 16px;
}
#help-reminder button {
  margin: 4px 8px 4px 0;
}
#help[data-emphasized='true'] {
  outline: 3px solid #b89965;
  outline-offset: 3px;
  background: #faedcf;
}
#side-tray {
  margin-bottom: 20px;
}
#tray-bench {
  border-radius: 12px;
  width: 100%;
  height: auto;
}
#desktop-drag {
  position: fixed;
  z-index: 20;
  width: 96px;
  height: 96px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 7px #263a3255);
}
@media (min-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 344px;
  }
}
#desktop-motion {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  pointer-events: none;
  z-index: 19;
}
