*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

/* Full viewport; black fills leftover space (side bars on desktop). */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: #000;
  cursor: pointer;
}

/* Mobile 1080×1920 (9:16) frame, scaled to fit; side bars on wider viewports. */
.frame {
  position: relative;
  aspect-ratio: 9 / 16;
  width: min(100vw, 100dvh * 9 / 16, 1080px);
  height: min(100dvh, 100vw * 16 / 9, 1920px);
  overflow: hidden;
  background: #000;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.layer.is-front {
  opacity: 1;
  z-index: 2;
}

.gate {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
  font: 1.125rem/1.4 system-ui, -apple-system, sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.gate[hidden] {
  display: none;
}

.fx {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.knock {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.knock__line {
  position: absolute;
  left: 0;
  top: 0;
  width: 2.5px;
  height: 16px;
  margin: -8px 0 0 -1.25px;
  border-radius: 1px;
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.55);
  transform: rotate(var(--a)) translateY(var(--from));
  animation: knock-burst 0.38s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: var(--delay, 0ms);
  opacity: 0;
}

@keyframes knock-burst {
  0% {
    opacity: 0.95;
    transform: rotate(var(--a)) translateY(var(--from)) scaleY(0.55);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--a)) translateY(var(--to)) scaleY(1);
  }
}
