.gate {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--space-xl) + env(safe-area-inset-top, 0px)) var(--space-md)
    var(--space-xxl);
  z-index: 1;
}

.gate-content {
  position: relative;
  z-index: 2;
  width: min(100%, 1240px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gate.is-hidden {
  display: none;
}

body.is-gate-restoring .ambient-glow,
body.is-gate-restoring .poster-horizon,
body.is-gate-restoring .poster-horizon-glow {
  opacity: 1;
  visibility: visible;
}

.gate-brand {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.gate:not(.is-poster-ready) .gate-brand {
  animation: gateReveal var(--duration-slow) var(--ease-out) both;
}

.gate-brand img {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  filter: drop-shadow(0 0 20px rgba(201, 191, 255, 0.4));
}

.gate-brand .wordmark {
  font-family: "Manrope", sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
}

.gate-editorial {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xl);
  width: 100%;
}

.gate-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxl);
  min-width: 0;
}

.gate-col--left {
  align-items: flex-start;
}

.gate-col--center {
  align-items: center;
}

.gate-col--right {
  align-items: flex-end;
}

.gate-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.8vw, 1.08rem);
  line-height: 1.55;
  margin: 0;
  max-width: 32ch;
}

.gate:not(.is-poster-ready) .gate-subtitle {
  animation: gateReveal var(--duration-slow) var(--ease-out) 0.12s both;
}

.gate-headline-title {
  font-size: clamp(1.65rem, 4.2vw, 3rem);
  line-height: 1.08;
  margin: 0;
  letter-spacing: -0.03em;
  white-space: normal;
  max-width: 14ch;
}

.gate-headline--left {
  text-align: left;
}

.gate-headline--right {
  text-align: right;
}

.gate:not(.is-poster-ready) .gate-headline--left,
.gate:not(.is-poster-ready) .gate-headline--right {
  animation: gateReveal var(--duration-slow) var(--ease-out) 0.18s both;
}

.gate-editorial-center {
  display: none;
}

.gate-col .portal-tile {
  width: 100%;
  max-width: 320px;
}

.gate:not(.is-poster-ready) .gate-col .portal-tile {
  animation: gateReveal var(--duration-slow) var(--ease-out) both;
}

.gate-col--left .portal-tile {
  animation-delay: 0.24s;
}

.gate-col--right .portal-tile {
  animation-delay: 0.36s;
}

@media (max-width: 720px) {
  .gate {
    --gate-chrome-offset: calc(52px + env(safe-area-inset-top, 0px));
    min-height: 100dvh;
    justify-content: flex-start;
    align-items: stretch;
    padding:
      var(--gate-chrome-offset)
      calc(var(--space-md) + env(safe-area-inset-right, 0px))
      calc(var(--space-xxl) + env(safe-area-inset-bottom, 0px))
      calc(var(--space-md) + env(safe-area-inset-left, 0px));
    z-index: 1;
  }

  .gate-content {
    position: relative;
    width: 100%;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    min-height: calc(
      100dvh - var(--gate-chrome-offset) - env(safe-area-inset-bottom, 0px) - var(--space-xxl)
    );
  }

  /* Brand pinned to top of screen — clear of profile & headlines below */
  .gate-brand {
    position: absolute;
    top: calc(6px + env(safe-area-inset-top, 0px) - var(--gate-chrome-offset));
    left: 0;
    z-index: 2;
    align-self: flex-start;
    text-align: left;
    margin-bottom: 0;
    max-width: min(58%, 220px);
  }

  .gate-brand img {
    width: 52px;
    height: 52px;
    margin: 0 0 var(--space-xs);
    filter: drop-shadow(0 2px 18px rgba(0, 0, 0, 0.5));
  }

  .gate-brand .wordmark {
    font-size: 1.5rem;
    line-height: 1.1;
    text-shadow: 0 2px 22px rgba(0, 0, 0, 0.55);
  }

  /* Editorial below brand — min offset restores pre-overlap spacing */
  .gate-editorial {
    margin-top: auto;
    gap: var(--space-xl);
    padding-top: clamp(148px, 26dvh, 280px);
    width: 100%;
    max-width: 100%;
  }

  .gate-col {
    align-items: stretch;
    gap: var(--space-md);
  }

  .gate-col--left,
  .gate-col--right {
    align-items: stretch;
  }

  .gate-headline-title {
    font-size: clamp(1.45rem, 6.4vw, 1.8rem);
    line-height: 1.12;
    text-align: left;
    max-width: 12ch;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
  }

  .gate-headline--left,
  .gate-headline--right {
    text-align: left;
    align-self: flex-start;
  }

  .gate-col .portal-tile {
    max-width: 100%;
    width: 100%;
    padding: var(--space-lg) var(--space-md);
    background: rgba(19, 19, 26, 0.36);
    border-color: rgba(201, 191, 255, 0.22);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
      0 16px 48px rgba(0, 0, 0, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  [data-theme="light"] .gate-col .portal-tile {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(90, 69, 212, 0.16);
    box-shadow:
      0 16px 40px rgba(90, 69, 212, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.65);
  }

  .gate-subtitle {
    text-align: left;
    max-width: none;
    margin-inline: 0;
    font-size: 0.9rem;
    line-height: 1.62;
    color: rgba(228, 225, 236, 0.9);
    text-shadow: 0 1px 14px rgba(0, 0, 0, 0.45);
  }

  [data-theme="light"] .gate-subtitle {
    color: rgba(28, 24, 36, 0.82);
    text-shadow: 0 1px 10px rgba(255, 255, 255, 0.35);
  }

  .portal-tile h2 {
    font-size: 1.15rem;
  }

  .portal-tile p {
    font-size: 0.875rem;
    line-height: 1.5;
  }
}

@media (max-width: 380px) {
  .gate-brand {
    max-width: 54%;
  }

  .gate-brand img {
    width: 48px;
    height: 48px;
  }

  .gate-brand .wordmark {
    font-size: 1.35rem;
  }
}

@media (min-width: 960px) {
  .gate-editorial {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) min(36vw, 400px) minmax(240px, 1fr);
    column-gap: clamp(24px, 3vw, 48px);
    align-items: start;
  }

  .gate-col {
    gap: var(--space-xxl);
  }

  .gate-col--center {
    gap: var(--space-lg);
  }

  .gate-editorial-center {
    display: block;
    width: 100%;
    min-height: min(68dvh, 820px);
    pointer-events: none;
  }

  .gate-headline-title {
    min-height: calc(2 * 1.08em);
    display: flex;
    align-items: flex-start;
  }

  .gate-headline--right {
    justify-content: flex-end;
    text-align: right;
    margin-left: auto;
  }
}

.portal-tile {
  position: relative;
  padding: var(--space-xl) var(--space-lg);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  transition: transform var(--duration-med) var(--ease-out),
    box-shadow var(--duration-med) var(--ease-out),
    border-color var(--duration-med) var(--ease-out);
}

.portal-tile:hover,
.portal-tile:focus-visible {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-glow);
  border-color: rgba(201, 191, 255, 0.35);
  outline: none;
}

.portal-tile-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: var(--space-md);
}

.portal-tile h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

.portal-tile p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 var(--space-md);
}

.portal-tile .enter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

@keyframes gateReveal {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
