* {
  box-sizing: border-box;
}

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

body.gate-page {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: #eef3ff;
  background:
    radial-gradient(ellipse at 50% 32%, rgba(73, 91, 168, 0.3), transparent 43%),
    radial-gradient(ellipse at 14% 82%, rgba(104, 91, 177, 0.16), transparent 36%),
    radial-gradient(ellipse at 88% 14%, rgba(74, 128, 190, 0.15), transparent 34%),
    linear-gradient(155deg, #070d20, #0d1530 52%, #060b1b);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body.gate-page::before {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 46%, transparent 18%, rgba(1, 4, 14, 0.36) 100%);
  content: "";
  pointer-events: none;
}

.gate-stars,
.gate-stars::before,
.gate-stars::after {
  position: fixed;
  inset: -18%;
  pointer-events: none;
  background-repeat: repeat;
}

.gate-stars {
  opacity: 0.68;
  background-image:
    radial-gradient(circle at 12% 19%, rgba(230, 240, 255, 0.9) 0 1px, transparent 1.7px),
    radial-gradient(circle at 38% 72%, rgba(197, 214, 255, 0.8) 0 1px, transparent 1.8px),
    radial-gradient(circle at 76% 34%, rgba(255, 230, 244, 0.78) 0 1px, transparent 1.6px),
    radial-gradient(circle at 88% 81%, rgba(210, 224, 255, 0.76) 0 1px, transparent 1.8px);
  background-size: 260px 260px, 340px 340px, 300px 300px, 420px 420px;
  animation: gateStarsDrift 34s linear infinite;
}

.gate-stars::before {
  opacity: 0.48;
  background-image:
    radial-gradient(circle at 24% 16%, rgba(229, 237, 255, 0.9) 0 0.8px, transparent 1.6px),
    radial-gradient(circle at 66% 58%, rgba(212, 218, 255, 0.8) 0 0.8px, transparent 1.6px),
    radial-gradient(circle at 44% 88%, rgba(255, 225, 244, 0.7) 0 0.8px, transparent 1.6px);
  background-size: 190px 190px, 240px 240px, 310px 310px;
  animation: gateStarsDrift 52s linear infinite reverse;
}

.gate-stars::after {
  inset: -24%;
  opacity: 0.36;
  background-image:
    radial-gradient(circle at 52% 26%, rgba(255, 245, 220, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 18% 64%, rgba(204, 235, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 74%, rgba(236, 220, 255, 0.8) 0 1px, transparent 2px);
  background-size: 460px 460px, 530px 530px, 610px 610px;
  animation: gateStarsDrift 72s linear infinite;
}

.gate-aurora {
  position: fixed;
  top: 8%;
  left: 50%;
  width: min(760px, 90vw);
  height: min(760px, 90vw);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 44%, rgba(105, 122, 224, 0.16), transparent 42%),
    radial-gradient(circle at 38% 56%, rgba(158, 120, 220, 0.12), transparent 48%);
  filter: blur(34px);
  transform: translateX(-50%);
  animation: gateAurora 12s ease-in-out infinite alternate;
  pointer-events: none;
}

.gate-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  padding: clamp(22px, 5vw, 54px);
  place-items: center;
}

.gate-card {
  position: relative;
  width: min(480px, 100%);
  padding: clamp(38px, 7vw, 58px) clamp(24px, 6vw, 56px) clamp(32px, 5vw, 44px);
  border: 1px solid rgba(193, 211, 255, 0.18);
  border-radius: clamp(24px, 4vw, 34px);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.025)),
    rgba(7, 13, 33, 0.55);
  box-shadow:
    0 34px 100px rgba(0, 2, 12, 0.58),
    0 0 80px rgba(92, 117, 210, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  text-align: center;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: gateCardIn 1s cubic-bezier(0.22, 0.8, 0.24, 1) both;
}

.gate-card::before {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 0%, rgba(170, 182, 255, 0.16), transparent 42%);
  content: "";
  pointer-events: none;
}

.gate-lock {
  position: relative;
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto clamp(22px, 4vh, 30px);
  place-items: center;
}

.gate-lock-glow {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(142, 164, 255, 0.17);
  box-shadow: 0 0 34px rgba(134, 158, 255, 0.34), 0 0 80px rgba(170, 144, 230, 0.16);
  animation: gateLockGlow 3.4s ease-in-out infinite alternate;
}

.gate-lock svg {
  position: relative;
  width: 44px;
  height: 44px;
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(160, 182, 255, 0.55));
}

.gate-lock-shackle {
  fill: none;
  stroke: #bdcaff;
  stroke-linecap: round;
  stroke-width: 3.2;
}

.gate-lock-body {
  fill: rgba(159, 178, 255, 0.16);
  stroke: #d6deff;
  stroke-width: 2.2;
}

.gate-lock-keyhole,
.gate-lock-stem {
  fill: #dce4ff;
  stroke: #dce4ff;
  stroke-linecap: round;
  stroke-width: 1.6;
}

.gate-kicker {
  margin: 0 0 13px;
  color: #d7c8ff;
  font-size: clamp(10px, 1.8vw, 12px);
  font-weight: 800;
  letter-spacing: 0.24em;
  text-shadow: 0 0 20px rgba(184, 161, 255, 0.42);
}

.gate-card h1 {
  margin: 0 auto;
  max-width: 350px;
  color: #f2f6ff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(23px, 4.2vw, 31px);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0.015em;
  text-shadow: 0 0 26px rgba(159, 180, 255, 0.22);
}

.gate-form {
  margin-top: clamp(28px, 5vh, 38px);
  text-align: left;
}

.gate-label {
  display: block;
  margin: 0 0 8px 4px;
  color: rgba(205, 215, 249, 0.7);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.gate-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.gate-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 1px solid rgba(186, 204, 255, 0.25);
  border-radius: 13px;
  outline: none;
  color: #f4f7ff;
  background: rgba(4, 9, 25, 0.45);
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.18em;
  caret-color: #c8d5ff;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.gate-input:focus {
  border-color: rgba(173, 195, 255, 0.64);
  background: rgba(6, 12, 32, 0.66);
  box-shadow: 0 0 0 3px rgba(125, 149, 232, 0.14), 0 0 26px rgba(98, 124, 216, 0.14);
}

.gate-unlock {
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid rgba(190, 207, 255, 0.42);
  border-radius: 13px;
  color: #f7f9ff;
  background:
    linear-gradient(145deg, rgba(125, 147, 234, 0.48), rgba(94, 90, 176, 0.34)),
    rgba(24, 38, 87, 0.8);
  box-shadow: 0 10px 24px rgba(3, 6, 22, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.gate-unlock:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(3, 6, 22, 0.36), 0 0 24px rgba(127, 151, 238, 0.22);
}

.gate-unlock:disabled {
  cursor: default;
  opacity: 0.7;
  transform: none;
}

.gate-error {
  margin: 12px 4px 0;
  color: #d8c5e9;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 0 16px rgba(207, 173, 255, 0.24);
}

.gate-form.is-shaking {
  animation: gateShake 300ms ease;
}

body.is-unlocking .gate-card {
  animation: gateUnlockOut 720ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body.is-unlocking .gate-stars,
body.is-unlocking .gate-aurora {
  animation-play-state: paused;
}

@keyframes gateStarsDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-34px, 22px, 0); }
}

@keyframes gateAurora {
  from { opacity: 0.66; transform: translateX(-50%) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

@keyframes gateCardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gateLockGlow {
  from { opacity: 0.6; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1.05); }
}

@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@keyframes gateUnlockOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-12px) scale(1.015); }
}

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

  .gate-card {
    padding: 34px 22px 30px;
  }

  .gate-input-row {
    grid-template-columns: 1fr;
  }

  .gate-unlock {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-stars,
  .gate-stars::before,
  .gate-stars::after,
  .gate-aurora,
  .gate-lock-glow,
  .gate-card {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}
