html, body {
  margin: 0;
  padding: 0;
}

#stage {
  --u: calc(min(100vw, 100vh) / 960);
  position: relative;
  display: block;
  width: calc(960 * var(--u));
  height: calc(960 * var(--u));
  overflow: hidden;
  background:
    url("assets/mkiv.webp") 0 0 / 100% 50% no-repeat,
    url("assets/surface02.webp") 0 calc(560 * var(--u)) / 100% calc(400 * var(--u)) no-repeat,
    #1c1c1c;
  font-family: sans-serif;
  cursor: var(--cursor-menu, crosshair);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
@supports (height: 100dvh) {
  #stage { --u: calc(min(100vw, 100dvh) / 960); }
}
#stage[data-state="playing"] {
  cursor: var(--cursor-play, crosshair);
}

#stage canvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  z-index: 0;
  will-change: transform;
  touch-action: manipulation !important;
}
#stage[data-state="playing"] canvas {
  touch-action: none !important;
}

.crack {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
#crack0 { left: calc(70 * var(--u));    top: calc(830 * var(--u)); width: calc(160 * var(--u)); height: calc(100 * var(--u)); }
#crack1 { left: calc(440 * var(--u));   top: calc(612 * var(--u)); width: calc(180 * var(--u)); height: calc(92 * var(--u)); }
#crack2 { left: calc(735.5 * var(--u)); top: calc(764 * var(--u)); width: calc(125 * var(--u)); height: calc(92 * var(--u)); }

.panel {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.784);
  box-shadow: inset 0 0 0 calc(8 * var(--u)) rgba(128, 128, 128, 0.784);
  outline: calc(8 * var(--u)) solid rgba(128, 128, 128, 0.784);
  color: #fff;
}
#stage[data-state="intro"] #intro,
#stage[data-state="complete"] #complete {
  display: flex;
}
#intro    { left: calc(30 * var(--u)); top: calc(155 * var(--u));  width: calc(900 * var(--u)); height: calc(650 * var(--u)); }
#complete { left: calc(80 * var(--u)); top: calc(28.4 * var(--u)); width: calc(800 * var(--u)); height: calc(500 * var(--u)); }

.copy {
  margin: 0;
  white-space: pre;
  text-align: center;
  font-size: calc(20 * var(--u));
  line-height: 1.275;
}

.button {
  position: absolute;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  cursor: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.button-bg {
  position: absolute;
  inset: 0;
  background: #008000;
  box-shadow: inset 0 0 0 calc(2 * var(--u)) #006400;
  outline: calc(2 * var(--u)) solid #006400;
}
.button-label {
  position: relative;
  --o: calc(2 * var(--u));
  --no: calc(-2 * var(--u));
  text-shadow:
    var(--o) 0 #006400, var(--no) 0 #006400, 0 var(--o) #006400, 0 var(--no) #006400,
    calc(1.4 * var(--u)) calc(1.4 * var(--u)) #006400, calc(-1.4 * var(--u)) calc(1.4 * var(--u)) #006400,
    calc(1.4 * var(--u)) calc(-1.4 * var(--u)) #006400, calc(-1.4 * var(--u)) calc(-1.4 * var(--u)) #006400;
}
.button:disabled .button-label { opacity: 0.6; }
.button:focus { outline: none; }
.button:focus-visible .button-bg { outline-color: #fff; }

#playButton {
  left: calc(350 * var(--u)); top: calc(515.4 * var(--u));
  width: calc(200 * var(--u)); height: calc(80 * var(--u));
  font-size: calc(60 * var(--u));
}
#playAgainButton {
  left: calc(280 * var(--u)); top: calc(387.6 * var(--u));
  width: calc(240 * var(--u)); height: calc(80 * var(--u));
  font-size: calc(40 * var(--u));
}

@keyframes pulse {
  from { transform: scale(var(--pulse-x0, 0.975), var(--pulse-y0, 0.94)); }
  to   { transform: scale(var(--pulse-x1, 1.025), var(--pulse-y1, 1.06)); }
}
.pulse .button-bg {
  animation: pulse 524ms ease-in-out infinite alternate;
}
#stage.paused .pulse .button-bg {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .pulse .button-bg { animation: none; }
}
