/* Landscape gate: phones get a full-screen rotate prompt instead of a squeezed layout. */
.rotate-gate {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 9999;
  display: none;
  grid-template-rows: auto auto auto;
  place-content: center;
  justify-items: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, rgba(232, 17, 45, 0.24) 0%, transparent 62%),
    radial-gradient(circle at 50% 108%, rgba(44, 54, 78, 0.24) 0%, transparent 58%),
    #07080b;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.03);
  transition: opacity 0.42s ease, transform 0.42s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.42s;
}

.rotate-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(164, 174, 196, 0.36) 1px, transparent 1.3px) 50% 50% / 22px 22px;
  opacity: 0.22;
  -webkit-mask-image: radial-gradient(ellipse 72% 60% at 50% 40%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 72% 60% at 50% 40%, #000 0%, transparent 78%);
}

.rotate-gate > * {
  position: relative;
  z-index: 1;
}

.rotate-gate h2 {
  margin: 0;
  font-family: var(--font-display, sans-serif);
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.08;
  color: #f4f5f8;
  text-wrap: balance;
}

.rotate-gate p {
  margin: 0;
  max-width: 29ch;
  font-size: 14px;
  line-height: 1.6;
  color: #98a2b3;
}

.rotate-wait {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-family: var(--mono, monospace);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cfd4df;
  background: rgba(16, 20, 28, 0.85);
}

.rotate-wait i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff2e46;
  animation: rotate-pulse 1.8s ease-out infinite;
}

.rotate-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(72vw, 250px);
  height: min(72vw, 250px);
}

.rotate-stage::before {
  content: '';
  position: absolute;
  width: 76%;
  height: 76%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 46, 70, 0.22), transparent 68%);
}

.rotate-arc,
.rotate-arc-in,
.rotate-target,
.rotate-phone {
  grid-area: 1 / 1;
}

.rotate-arc,
.rotate-arc-in {
  border-radius: 50%;
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
  mask: radial-gradient(closest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
}

.rotate-arc {
  width: 100%;
  height: 100%;
  background: conic-gradient(from 0deg, #ff2e46 0deg, #ff2e46 34deg, transparent 110deg, transparent 360deg);
  filter: drop-shadow(0 0 6px rgba(255, 46, 70, 0.55));
  animation: rotate-sweep 2.5s linear infinite;
}

.rotate-arc-in {
  width: 76%;
  height: 76%;
  background: conic-gradient(from 180deg, rgba(164, 174, 196, 0.55) 0deg, transparent 50deg, transparent 360deg);
  animation: rotate-sweep 5.4s linear infinite reverse;
}

.rotate-target {
  width: 66%;
  height: 33%;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  animation: rotate-target 3.8s ease-in-out infinite;
}

@keyframes rotate-target {
  0%, 18% { opacity: 0.45; }
  44%, 72% { opacity: 1; }
  100% { opacity: 0.45; }
}

.rotate-phone {
  position: relative;
  width: 27%;
  height: 54%;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 13px;
  background: linear-gradient(168deg, #212736, #0d1017);
  box-shadow: 0 0 0 1px #06070a, 0 22px 34px -18px #000, inset 0 1px rgba(255, 255, 255, 0.16);
  transform-origin: 50% 50%;
  animation: rotate-phone 3.8s cubic-bezier(0.62, 0.02, 0.24, 1) infinite;
}

.rotate-notch {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 26%;
  height: 3px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-50%);
}

.rotate-screen {
  position: absolute;
  inset: 7px 5px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  place-content: center;
  gap: 5px;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 28%, #262c3c, #0f1219 68%);
}

.rotate-screen i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
}

.rotate-screen i:nth-child(2) {
  background: #e8112d;
}

.rotate-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(255, 46, 70, 0.25) 55%, rgba(255, 46, 70, 0));
  animation: rotate-scan 2.4s ease-in-out infinite;
}

@keyframes rotate-phone {
  0%, 18% { transform: rotate(0deg); }
  44%, 72% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

@keyframes rotate-sweep {
  to { transform: rotate(360deg); }
}

@keyframes rotate-scan {
  0% { top: -34%; opacity: 0; }
  22%, 78% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

@keyframes rotate-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 46, 70, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(255, 46, 70, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 46, 70, 0); }
}

@keyframes rotate-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (orientation: portrait) and (hover: none), (orientation: portrait) and (pointer: coarse) {
  .rotate-gate {
    display: grid;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }

  .rotate-gate > * {
    animation: rotate-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  }

  .rotate-gate > .rotate-stage { animation-delay: 0.04s; }
  .rotate-gate > h2 { animation-delay: 0.12s; }
  .rotate-gate > p { animation-delay: 0.19s; }
  .rotate-gate > .rotate-wait { animation-delay: 0.26s; }

  body.rotate-locked {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-gate,
  .rotate-gate > *,
  .rotate-arc,
  .rotate-arc-in,
  .rotate-target,
  .rotate-scan,
  .rotate-wait i {
    animation: none;
  }

  .rotate-phone {
    animation: none;
    transform: rotate(-90deg);
  }
}
