:root {
  color-scheme: dark;
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  background: #050505;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
}

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

.gate-page {
  min-height: 100svh;
  color: #d7d2ca;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 18%, rgba(0, 0, 0, 0.35) 57%, #000 105%),
    #070707;
}

.gate-page::before,
.gate-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.gate-page::before {
  opacity: 0.25;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 7px);
  mix-blend-mode: overlay;
  animation: noiseShift 180ms steps(2, end) infinite;
}

.gate-page::after {
  box-shadow: inset 0 0 18vw 8vw #000;
  animation: pulseVignette 4.8s ease-in-out infinite;
}

.gate {
  position: relative;
  min-height: 100svh;
}

.text-wall {
  position: fixed;
  inset: -4vh -8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(3px, 0.65vh, 9px);
  transform: rotate(-1.4deg) scale(1.04);
  filter: contrast(1.15);
  opacity: 0.86;
}

.text-row {
  display: flex;
  flex: 0 0 auto;
  gap: clamp(18px, 3vw, 54px);
  width: max-content;
  transform: translateX(var(--drift));
  white-space: nowrap;
  animation: rowTremor 2.7s steps(2, end) infinite;
  animation-delay: calc(var(--row) * -91ms);
}

.text-row:nth-child(3n) {
  opacity: 0.48;
  filter: blur(0.35px);
}

.text-row:nth-child(4n + 1) {
  transform: translateX(calc(var(--drift) - 18px)) scaleX(1.015);
  color: #a59d94;
}

.text-row span {
  display: inline-block;
  font-size: clamp(15px, 1.65vw, 24px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: 1px 0 rgba(112, 0, 0, 0.75), -1px 0 rgba(32, 67, 71, 0.45);
}

.text-row span:nth-child(5n + 2) {
  opacity: 0.25;
  transform: translateY(-2px);
}

.gate-form {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(5vh, 24px);
  width: min(680px, calc(100vw - 36px));
  padding: 18px 20px 20px;
  transform: translateX(-50%);
  border: 1px solid rgba(206, 198, 187, 0.36);
  background: rgba(4, 4, 4, 0.9);
  box-shadow: 0 20px 70px #000, inset 0 0 28px rgba(122, 0, 0, 0.09);
  backdrop-filter: blur(5px);
}

.gate-form label {
  display: block;
  margin-bottom: 11px;
  color: #bdb7ae;
  font-size: 12px;
  letter-spacing: 0.24em;
}

.input-row {
  display: flex;
  gap: 9px;
}

.input-row input,
.input-row button {
  height: 46px;
  border: 1px solid #817b72;
  border-radius: 0;
  color: #e0ddd8;
  background: #090909;
  font: inherit;
}

.input-row input {
  min-width: 0;
  flex: 1;
  padding: 0 14px;
  letter-spacing: 0.08em;
  outline: none;
}

.input-row input:focus {
  border-color: #d1cac0;
  box-shadow: 0 0 0 1px #d1cac0, 0 0 28px rgba(153, 0, 0, 0.28);
}

.input-row button {
  width: 86px;
  cursor: pointer;
  letter-spacing: 0.2em;
  transition: color 140ms ease, background 140ms ease;
}

.input-row button:hover,
.input-row button:focus-visible {
  color: #050505;
  background: #ded9d1;
}

.feedback {
  min-height: 17px;
  margin: 9px 0 -5px;
  color: #8e2424;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.rejected {
  animation: reject 260ms steps(2, end);
}

.accepted {
  animation: swallow 330ms ease-in forwards;
}

.result-page {
  color-scheme: light;
  min-height: 100svh;
  color: #050505;
  background: #fff;
}

.result-main {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 7vw;
}

.result-main h1 {
  max-width: 100%;
  margin: 0;
  font-family: "Heiti SC", "Noto Sans SC", sans-serif;
  font-size: clamp(48px, 11vw, 180px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.055em;
  text-align: center;
  overflow-wrap: anywhere;
  animation: arrive 850ms cubic-bezier(0.19, 1, 0.22, 1) both;
}

@keyframes noiseShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(1px, -1px); }
  50% { transform: translate(-1px, 1px); }
  75% { transform: translate(1px, 1px); }
}

@keyframes pulseVignette {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes rowTremor {
  0%, 92%, 100% { margin-left: 0; }
  94% { margin-left: 2px; }
  96% { margin-left: -1px; }
}

@keyframes reject {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 8px)); }
  50% { transform: translateX(calc(-50% + 6px)); }
  75% { transform: translateX(calc(-50% - 3px)); }
}

@keyframes swallow {
  to { opacity: 0; filter: blur(8px); transform: scale(1.08); }
}

@keyframes arrive {
  from { opacity: 0; transform: scale(0.78); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@media (max-width: 520px) {
  .gate-form {
    padding: 15px;
  }

  .gate-form label {
    line-height: 1.7;
  }

  .input-row button {
    width: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
