html:has(.lab-lock:not([hidden])) {
  background: #090e1c;
}

.lab-lock {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  isolation: isolate;
  position: relative;
  overflow: clip;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% 0%, #26395e 0%, transparent 61%),
    radial-gradient(ellipse at 90% 100%, #1e2041 0%, transparent 55%),
    #090e1c;
  color: #edf4ff;
  text-align: center;
  font-family: system-ui, sans-serif;
}

.lab-lock::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(#9eb8f20c 1px, transparent 1px),
    linear-gradient(90deg, #9eb8f20c 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(#000, transparent 88%);
}

.lab-console {
  width: min(100%, 410px);
  padding: clamp(19px, 4.7svh, 42px) 16px clamp(18px, 3.8svh, 34px);
  border: 1px solid #aac8ff31;
  border-radius: 28px;
  background: linear-gradient(150deg, #253555a8, #0c1529dc 68%);
  box-shadow: 0 24px 72px #02051280, inset 0 1px #d9e8ff11;
}

.lab-lock-icon {
  position: relative;
  width: 22px;
  height: 15px;
  margin: 10px auto 17px;
  border: 1.5px solid;
  border-radius: 4px;
  color: #a7c8ff;
}

.lab-lock-icon::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 10px;
  bottom: 100%;
  left: 50%;
  translate: -50% 0;
  border: 1.5px solid;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.lab-lock-icon::after {
  content: "";
  position: absolute;
  inset: 4px auto auto 50%;
  translate: -50% 0;
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: currentColor;
}

.lab-console h1 {
  font-size: clamp(2rem, 8vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: .075em;
  font-weight: 750;
  padding-left: .075em;
}

.lab-subtitle {
  margin: 8px 0 0;
  color: #aac1eb;
  font: 0.875rem/1.3 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .23em;
  padding-left: .23em;
}

.lab-entry {
  position: relative;
  margin: clamp(18px, 4.3svh, 37px) auto 0;
}

.lab-dots {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.lab-dots span {
  width: 12px;
  height: 12px;
  border: 1px solid #9badd0;
  border-radius: 50%;
}

.lab-dots .filled {
  background: #dceaff;
  border-color: #dceaff;
  box-shadow: 0 0 10px #adcaff75;
}

.lab-status {
  min-height: 1.55em;
  margin: 9px 0 14px;
  color: #c1cdea;
  font-size: .875rem;
  line-height: 1.55;
}

.lab-keypad {
  --key-size: clamp(48px, 10svh, 70px);
  display: grid;
  grid-template-columns: repeat(3, var(--key-size));
  justify-content: center;
  gap: clamp(8px, 1.55svh, 13px) clamp(11px, 4.5vw, 20px);
}

.lab-keypad button {
  display: grid;
  place-items: center;
  width: var(--key-size);
  height: var(--key-size);
  padding: 0;
  border: 1px solid #a8c5ff3d;
  border-radius: 50%;
  background: #a6c7ff15;
  color: inherit;
  font-size: clamp(1.35rem, 4.2svh, 1.9rem);
  line-height: 1;
  font-weight: 450;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.lab-keypad button:focus-visible {
  outline-color: #c6ddff;
}

@media (hover: hover) {
  .lab-keypad button:hover {
    border-color: #bad2ff85;
    background: #a6c7ff29;
  }
}

.lab-keypad button:active {
  background: #b1ceff52;
}

.lab-keypad [data-digit="0"] {
  grid-column: 2;
}

.lab-keypad .lab-delete {
  background: transparent;
  border-color: transparent;
  color: #bacdee;
  font-size: 1.3rem;
}

.lab-lock.is-wrong .lab-status {
  color: #ffbecd;
}

.lab-lock.is-wrong .lab-dots span {
  background: #ffb0c2;
  border-color: #ffb0c2;
}

.lab-lock.is-unlocking .lab-status,
.lab-lock.is-unlocking .lab-lock-icon {
  color: #aff7db;
}

.lab-lock.is-unlocking .lab-lock-icon::before {
  rotate: -22deg;
  transform-origin: bottom left;
}

.lab-noscript {
  margin-top: 14px;
  color: #ffbecd;
}

@media (prefers-reduced-motion: no-preference) {
  .lab-lock.is-wrong .lab-entry {
    animation: lab-shake 380ms ease both;
  }

  .lab-lock.is-wrong .lab-entry::after {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0 5%;
    background: repeating-linear-gradient(0deg, transparent 0 4px, #ffb7df8c 5px, transparent 7px);
    animation: lab-static 380ms steps(2, end) both;
  }

  .lab-lock.is-unlocking {
    animation: lab-unlock 460ms ease-in both;
  }

  @keyframes lab-shake {
    15% { transform: translateX(-8px); }
    30% { transform: translateX(7px); }
    48% { transform: translateX(-6px); }
    65% { transform: translateX(4px); }
    82% { transform: translateX(-2px); }
  }

  @keyframes lab-static {
    0%, 100% { opacity: 0; clip-path: inset(45% 0 45%); }
    20% { opacity: .47; clip-path: inset(19% 0 61%); }
    48% { opacity: .23; clip-path: inset(61% 0 17%); }
    70% { opacity: 0; }
  }

  @keyframes lab-unlock {
    62% { opacity: 1; }
    100% { opacity: 0; }
  }
}
