* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; overflow: hidden; overscroll-behavior: none; background: #f2f0ed; }
body {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--safe-top) env(safe-area-inset-right, 0px) var(--safe-bottom) env(safe-area-inset-left, 0px);
  display: grid;
  place-items: center;
  color: #383430;
  font: 16px "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
#stage {
  position: relative;
  isolation: isolate;
  width: min(100%, 56.25vh);
  width: min(100%, calc((100dvh - var(--safe-top) - var(--safe-bottom)) * .5625));
  height: calc(100vh - var(--safe-top) - var(--safe-bottom));
  height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
  background: #fbfaf8;
  container-type: inline-size;
}
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  fill: #54e85345;
  stroke: #57ef56;
  stroke-width: 5.5;
  stroke-linejoin: round;
  animation: guide-blink .52s ease-in-out infinite alternate;
}
@keyframes guide-blink {
  from { opacity: .20; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #guide { animation: none; }
}
.hud {
  position: absolute; top: 0; left: 0; width: 100%;
  padding: clamp(12px, 3.7cqw, 25px) clamp(16px, 5.3cqw, 35px) 0;
  pointer-events: none;
}
.hud-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
h1, #count, #timer { margin: 0; font-size: clamp(13px, 3.5cqw, 25px); font-weight: 700; }
#count { justify-self: end; color: #54514b; }
#count, #timer { font-variant-numeric: tabular-nums; }
#timer.urgent, #mark.failure { color: #a83723; }
#hint {
  margin: clamp(8px, 2.3cqw, 16px) 0 0;
  text-align: center;
  color: #635e58;
  font-size: clamp(12px, 3.3cqw, 22px);
}
#hint.blocked { color: #ae4c32; }
button {
  min-height: 44px; min-width: 60px;
  padding: 0 14px;
  background: #faf8f3;
  color: #45423d;
  border: 1px solid #c0bbb2;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  font: inherit;
  font-size: clamp(12px, 3.2cqw, 20px);
}
button:focus-visible { outline: 2px solid #3d9750; outline-offset: 3px; }
#retry { position: absolute; right: max(12px, 4cqw); bottom: max(12px, 3cqw); }
#result {
  position: absolute; z-index: 1;
  left: 50%; top: 64%; transform: translate(-50%, -50%);
  width: min(63%, 265px);
  padding: 19px 14px 16px;
  background: #fbfaf7f5;
  text-align: center;
  border: 1px solid #d7d3ca;
  border-radius: 17px;
  box-shadow: 0 9px 32px #18170f2e;
}
#mark { display: block; font-size: 37px; line-height: 1; color: #3d9a4d; font-weight: 800; }
#result h2 { margin: 5px 0; font-size: clamp(19px,5cqw,32px); }
#result p { margin: 0 0 12px; font-size: clamp(12px,3.2cqw,20px); color: #67625b; }
#next { background: #edf4e9; color: #376842; border-color: #90ad87; }
.sr-only { position: absolute; top: 0; left: 0; margin: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
