* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { color-scheme: light; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; background: #f9eee9; }
body { margin: 0; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; overscroll-behavior: none; }
#stage {
  position: relative;
  width: min(100vw, 620px);
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  background: linear-gradient(#fae9e1, #f5eff3);
}
#stage::before, #stage::after {
  content: "";
  grid-column: 1;
  justify-self: stretch;
  pointer-events: none;
  --edge-shade: linear-gradient(90deg, #92778117, #b1879000 16% 84%, #92778112);
}
#stage::before {
  grid-row: 1;
  background: var(--edge-shade), linear-gradient(#fae9e1, #f0d8d5);
}
#stage::after {
  grid-row: 3;
  background: var(--edge-shade), linear-gradient(#f2edf4, #f5eff3);
}
#scene {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  width: min(100%, calc((100dvh - 85px) * 220 / 245));
  aspect-ratio: 220 / 245;
  container-type: inline-size;
  isolation: isolate;
}
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
h1 {
  position: absolute; top: 1.8%; left: 0; width: 100%; margin: 0;
  font-size: clamp(12px, 4.1cqw, 25px); font-weight: 500; text-align: center;
  color: #50423f; pointer-events: none;
}
#mark {
  position: absolute; top: 43%; left: 50%; transform: translate(-50%, -50%);
  color: #55974e; font-size: clamp(58px, 23cqw, 135px); line-height: 1; font-weight: 900;
  font-family: system-ui, sans-serif; pointer-events: none;
  text-shadow: 0 2px 0 #fff8;
  animation: result-in 220ms ease-out both;
}
#mark.lost { color: #e32223; -webkit-text-stroke: .45cqw #b81616; }
@keyframes result-in { from { opacity: 0; scale: .62; } to { opacity: 1; scale: 1; } }
footer {
  grid-column: 1; grid-row: 3; z-index: 1; align-self: end;
  display: flex; flex-wrap: wrap; justify-content: center;
  align-items: center; gap: 8px; padding: 5px 10px; color: #695750;
  font-size: 13px;
}
button {
  cursor: pointer; touch-action: manipulation; min-height: 44px; min-width: 62px;
  border: 1px solid #d4bbb1; border-radius: 10px; padding: 0 11px;
  background: #fff9f5; color: #58453e; font: inherit;
}
button:focus-visible { outline: 2px solid #826250; outline-offset: 2px; }
#next { background: #edf6e8; border-color: #b5c9ab; color: #365b35; }
#debug {
  position: absolute; inset: 9% auto auto 1%; pointer-events: none; margin: 0; color: #254641;
  background: #fffdf5e0; font: 10px/1.25 monospace; padding: 3px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
body.reference { background: #fbf7f8; }
body.reference #stage { min-height: auto; padding: 0; width: 100%; }
body.reference #scene { width: 100%; }
body.reference footer, body.reference #stage::before, body.reference #stage::after { display: none; }
