:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #e9ede5;
  color: #344940;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 15% 20%, #f5ebdf, transparent 52%), linear-gradient(150deg, #e7ebe3, #d8e3dc); }
button { cursor: pointer; font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid #597e69; outline-offset: 4px; }
[hidden] { display: none !important; }
.shell { width: min(1390px, calc(100% - 72px)); margin: auto; padding-bottom: 32px; }
.masthead { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; letter-spacing: .07em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #f7e7df; color: #ad5e66; font-size: 21px; }
nav { display: flex; gap: 10px; }
nav button, .quiet-button { border: 1px solid #c6d1c7; background: #f9fbf3b8; padding: 8px 15px; border-radius: 50px; font-size: 13px; white-space: nowrap; }
nav button:hover, .quiet-button:hover { background: #fffaf1; border-color: #9cae9e; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 361px; gap: 22px; }
.scene, .control-card { border-radius: 25px; box-shadow: 0 14px 38px #34494018; }
.scene { min-height: 598px; position: relative; isolation: isolate; overflow: hidden; background: #dae6e7 url("./assets/alley.webp") 16% center / cover no-repeat; }
.scene::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, #f6fafac0, transparent 31%, transparent 76%, #27372d4d); z-index: -1; }
.level-title { text-align: center; padding: 32px 16px; position: relative; z-index: 2; pointer-events: none; }
.level-title span, .stage-name { color: #5d7767; font-size: 13px; font-weight: 700; letter-spacing: .12em; }
h1 { margin: 5px 0 0; font: 800 clamp(38px, 5.4vw, 68px)/1.25 "KaiTi", "STKaiti", "Noto Serif SC", serif; color: #455448; text-shadow: 0 3px 15px #fff; letter-spacing: .09em; }
.umbrella { position: absolute; width: min(57%, 465px); aspect-ratio: 1; top: 18%; left: 52%; transform: translateX(-50%); transition: transform 850ms cubic-bezier(.18,.67,.27,1.25); }
.umbrella img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; pointer-events: none; }
.umbrella-ghost { opacity: .27; filter: saturate(.5); }
.umbrella-reveal { clip-path: inset(0 calc(100% - var(--reveal, 0%)) 0 0); transition: clip-path 480ms cubic-bezier(.2,.75,.2,1); filter: drop-shadow(0 10px 16px #72574228); }
.scene.finished .umbrella { transform: translateX(-57%) rotate(-7deg) scale(1.06); }
.weather { position: absolute; inset: 10% -7% 0; pointer-events: none; opacity: .39; background-image: repeating-linear-gradient(110deg, transparent 0 31px, #f9ffffa8 32px, transparent 34px 75px); background-size: 163px 143px; mask-image: linear-gradient(180deg, #000, transparent 92%); animation: rain 2.7s linear infinite; z-index: -1; }
@keyframes rain { from { background-position: 0 -143px; } to { background-position: -163px 143px; } }
.scene-progress { display: flex; align-items: center; gap: 14px; position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 10px 18px; background: #fff9e9ec; border-radius: 50px; font-size: 13px; font-weight: 700; white-space: nowrap; }
progress { width: clamp(100px, 19vw, 214px); height: 7px; appearance: none; border: 0; border-radius: 99px; background: #e1e2d0; overflow: hidden; }
progress::-webkit-progress-bar { background: #e1e2d0; border-radius: 99px; }
progress::-webkit-progress-value { background: #739681; border-radius: 99px; }
progress::-moz-progress-bar { background: #739681; border-radius: 99px; }
.completion { position: absolute; top: 15px; right: 15px; color: #954950; background: #fff6e7; border: 1px solid #d49897; border-radius: 50%; width: 76px; height: 76px; display: grid; place-items: center; transform: rotate(8deg); font: 800 15px "KaiTi", serif; box-shadow: 0 4px 14px #98695926; animation: seal .5s both; }
@keyframes seal { from { opacity: 0; transform: scale(1.3) rotate(15deg); } }
.control-card { background: #fffbf0; border: 1px solid #fff9ed; padding: 25px; display: flex; flex-direction: column; }
.work-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
h2 { margin: 6px 0 0; font: 800 32px/1.15 "KaiTi", "STKaiti", "Microsoft YaHei", serif; }
.rack { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 22px 0 20px; }
.rack section { min-width: 0; border: 1px solid #e2dfce; border-radius: 15px; background: #f4f2e6; padding: 10px; }
.rack h3, .tray-label { margin: 0 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.chip-row { display: flex; align-items: center; gap: 7px; min-height: 51px; }
.chip { display: grid; place-items: center; gap: 2px; min-width: 0; width: 53px; height: 49px; flex: 0 1 53px; padding: 3px; border: 1px solid #d8ddcf; border-radius: 10px; background: #fffcf2; font-size: 10px; font-weight: 700; white-space: nowrap; }
.chip-empty { background: #fff9eb71; color: #777d6b; border: 1px dashed #a8ad98; }
.chip em { width: 20px; height: 20px; border-radius: 50%; background: var(--thread); border: 1px solid #5d53452b; }
.chip.is-ready { background: #edf4e7; border-color: #84a078; }
.tray { position: relative; min-height: 173px; border: solid 7px #d2b992; border-radius: 29px; background: repeating-linear-gradient(89deg, #dbbf9466 0 5px, #f8e8cb7d 7px 12px), #efe1c8; box-shadow: inset 0 2px 16px #865b322d; }
.spool { position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); z-index: var(--layer); transform: translate(-50%, -34%); width: 65px; display: grid; justify-items: center; border: 0; background: transparent; padding: 0; transition: filter .15s, scale .15s; }
.spool:hover { scale: 1.07; }
.spool[aria-disabled="true"] { filter: saturate(.7) brightness(.85); }
.spool.is-target:not([aria-disabled="true"]) .yarn { box-shadow: inset 0 2px 3px #fff7dc8a, 0 0 0 2px #fff9e8, 0 5px 8px #79563f52; }
.yarn { display: block; position: relative; width: 60px; height: 51px; border-radius: 48% 48% 38% 44%; background: repeating-linear-gradient(138deg, #fff9e142 0 2px, transparent 3px 5px, #29251024 6px 7px), repeating-linear-gradient(25deg, transparent 0 5px, #fff5d55c 7px, transparent 10px), var(--thread); box-shadow: inset 0 2px 3px #fff7dc8a, 0 5px 8px #79563f52; }
.yarn::before { position: absolute; content: ""; width: 35px; height: 14px; border-radius: 50%; border: 2px solid #fff5dd59; left: 11px; top: 5px; background: #2a20182e; }
.yarn-tag { font-weight: 800; font-size: 10px; background: #fffaeaf0; border-radius: 8px; padding: 1px 5px; margin-top: -3px; position: relative; z-index: 1; }
.message { min-height: 44px; font-size: 14px; line-height: 1.6; margin: 17px 0 10px; }
.hint-button { align-self: flex-start; padding: 9px 16px; border-radius: 50px; border: 1px solid #abc0ae; background: #e4eee1; font-weight: 700; font-size: 13px; }
.hint-button:hover { background: #d6e8d4; }
.is-hint { outline: 3px solid #846039; outline-offset: 4px; animation: breathe .9s ease-in-out 2; }
@keyframes breathe { 50% { outline-offset: 8px; } }
.flying-yarn { position: fixed; z-index: 20; pointer-events: none; border-radius: 50%; width: 13px; height: 13px; background: var(--thread); box-shadow: 0 0 0 4px #fff2cd, 0 0 22px 8px #fff5d8ad; }
.petal { pointer-events: none; position: absolute; z-index: 3; width: 13px; height: 9px; background: #e79da9; border-radius: 90% 20% 80% 20%; animation: petal 1.7s ease-out both; }
@keyframes petal { from { opacity: 0; transform: translateY(-18px) rotate(0); } 20% { opacity: .85; } to { opacity: 0; transform: translate(50px, 230px) rotate(180deg); } }
dialog { width: min(410px, calc(100% - 28px)); color: inherit; border: 1px solid #e6deca; padding: 30px; border-radius: 24px; text-align: center; background: #fffaec; box-shadow: 0 20px 50px #2640385e; }
dialog::backdrop { background: #253d335e; }
.book-close { position: absolute; right: 12px; top: 9px; font-size: 25px; border: none; background: transparent; }
dialog img { display: block; width: min(100%, 250px); margin: 0 auto; }
dialog p { font-size: 14px; line-height: 1.65; }
@media (min-width: 950px) { .control-card { justify-content: center; } }
@media (max-width: 950px) {
  .shell { width: min(800px, calc(100% - 32px)); }
  .game-layout { grid-template-columns: 1fr; gap: 12px; }
  .scene { min-height: clamp(320px, 63vw, 530px); }
  .umbrella { width: min(55%, 405px); top: 21%; }
  .control-card { padding: 19px; }
  .tray { min-height: 153px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
