:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #1d2925;
  --muted: #67736f;
  --sage: #49695f;
  --sage-dark: #203e36;
  --paper: rgba(250, 248, 241, 0.84);
  --danger: #9c352c;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(110deg, rgba(18, 32, 27, 0.19), rgba(255, 253, 247, 0.13) 48%, rgba(18, 32, 27, 0.16)),
    url("/login-background.webp") center / cover no-repeat fixed;
}

button,
input {
  font: inherit;
}

.gate-shell {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.gate-panel {
  width: min(100%, 390px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(24, 42, 36, 0.25);
  backdrop-filter: blur(17px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sage);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.introduction {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

#code-form {
  margin-top: 25px;
}

#code {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.code-display {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 11px;
  margin: 0 auto 22px;
  padding: 0 4px;
}

.code-display span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid rgba(73, 105, 95, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 -7px 16px rgba(73, 105, 95, 0.07);
}

.code-display span::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transform: scale(0.55);
  transition: background 130ms ease, transform 130ms ease;
}

.code-display span.filled {
  border-color: rgba(32, 62, 54, 0.52);
  background: rgba(255, 253, 247, 0.94);
}

.code-display span.filled::after {
  background: var(--sage-dark);
  transform: scale(1);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad button {
  display: grid;
  place-items: center;
  align-content: center;
  aspect-ratio: 1.23;
  min-width: 0;
  border: 1px solid rgba(73, 105, 95, 0.2);
  border-radius: 17px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 5px 15px rgba(32, 62, 54, 0.08);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 90ms ease, background 90ms ease;
}

.keypad button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.keypad button:hover,
.keypad button:focus-visible {
  border-color: rgba(32, 62, 54, 0.42);
  background: rgba(255, 255, 255, 0.9);
}

.keypad button:active {
  transform: scale(0.94);
}

.keypad .key-action {
  border-color: transparent;
  background: rgba(73, 105, 95, 0.12);
  font-size: 1.25rem;
}

.keypad .submit-code {
  color: #fffdf7;
  background: var(--sage-dark);
  box-shadow: 0 9px 22px rgba(32, 62, 54, 0.24);
}

.keypad .submit-code:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.login-message {
  min-height: 1.3em;
  margin: 15px 0 -7px;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-height: 690px) and (orientation: landscape) {
  .gate-panel {
    width: min(100%, 620px);
    padding: 20px 26px;
  }

  .gate-panel header {
    text-align: center;
  }

  #code-form {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 20px;
    margin-top: 16px;
  }

  .code-display {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin: 0;
    align-self: start;
  }

  .keypad {
    grid-column: 2;
    grid-row: 1 / span 2;
    grid-template-columns: repeat(6, 1fr);
    gap: 7px;
  }

  .keypad button {
    aspect-ratio: 1;
    border-radius: 13px;
    font-size: 1.25rem;
  }

  .login-message {
    grid-column: 1;
    margin: 8px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
