:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1220;
  color: #eef3ff;
}

* {
  box-sizing: border-box;
}

/* Author display rules (e.g. the flex auth steps) must never resurrect an
   element the shell has hidden with the `hidden` attribute. */
[hidden] {
  display: none !important;
}

#one-gate {
  display: none;
  position: fixed;
  inset: 0;
  background: #05070d;
  z-index: 2147483647;
  opacity: 1;
  transition: opacity 700ms ease;
}

/* The public surface is only ever the glow or the running app — never any
   text card. The boot/failure card is fully retired from display; loading
   and error states live on the glow. */
#one-boot {
  display: none !important;
}

html[data-one-gated] body > *:not(#one-gate),
html[data-one-loading] body > *:not(#one-gate) {
  display: none !important;
}

html[data-one-gated] #one-gate,
html[data-one-loading] #one-gate {
  display: block;
}

#one-gate.one-gate-hiding {
  opacity: 0;
  pointer-events: none;
}

.one-gate-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 2px solid rgb(96 165 250 / 22%);
  border-top-color: rgb(96 165 250 / 90%);
  animation: one-gate-spin 900ms linear infinite;
}

html[data-one-loading] .one-gate-spinner {
  display: block;
}

@keyframes one-gate-spin {
  to {
    transform: rotate(360deg);
  }
}

.one-gate-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60vw, 60vh, 520px);
  height: min(60vw, 60vh, 520px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgb(59 130 246 / 55%) 0%,
    rgb(37 99 235 / 30%) 32%,
    rgb(29 78 216 / 12%) 55%,
    transparent 72%
  );
  filter: blur(18px);
  animation: one-gate-pulse 5.5s ease-in-out infinite;
}

@keyframes one-gate-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: translate(-50%, -50%) scale(0.94);
  }
  50% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .one-gate-glow {
    animation: none;
    opacity: 0.8;
  }
}

html,
body {
  min-width: 280px;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 25%, rgb(59 130 246 / 18%), transparent 36rem),
    #0b1220;
}

/* Track the dynamic viewport on mobile browsers so the retracting toolbar
   never clips the bottom of the canvas; browsers without dvh keep the 100%
   fallback above. */
body {
  height: 100dvh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#one-boot {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}

.boot-card {
  width: min(34rem, 100%);
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid #1f2b45;
  border-radius: 1rem;
  background: #141f36;
}

.brand-mark {
  margin: 0 0 1.25rem;
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 3rem);
  line-height: 1.05;
}

#one-boot-message,
#one-failure-message {
  color: #a9b1d6;
  line-height: 1.6;
}

button {
  min-height: 2.75rem;
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid #7dd3fc;
  border-radius: 0.5rem;
  background: #141f36;
  color: #eef3ff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: #1f2b45;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid #7dd3fc;
  outline-offset: 3px;
}

details {
  margin-top: 1.25rem;
  color: #fca5a5;
}

html[data-one-ready="true"] #one-boot {
  display: none;
}

#one-auth {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  background: rgb(11 18 32 / 82%);
}

/* Auto margins beat grid alignment, so the card stays centered while its top
   remains reachable (the overlay scrolls) if it ever exceeds the viewport. */
.auth-card {
  margin: auto;
}

#one-auth[hidden] {
  display: none;
}

.auth-step {
  display: flex;
  flex-direction: column;
  margin-top: 1.25rem;
}

.auth-label {
  margin-bottom: 0.4rem;
  color: #a9b1d6;
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-card input {
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #1f2b45;
  border-radius: 0.5rem;
  background: #0b1220;
  color: #eef3ff;
  font: inherit;

  /* Never below 16px: iOS Safari zoom-jumps into any smaller input. */
  font-size: max(1rem, 16px);
}

.auth-card input:focus-visible {
  outline: 3px solid #7dd3fc;
  outline-offset: 1px;
}

#one-auth-code {
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
}

.auth-link {
  min-height: auto;
  margin-top: 0.75rem;
  padding: 0.25rem 0;
  border: none;
  background: none;
  color: #7dd3fc;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.auth-link:hover {
  background: none;
  color: #bae6fd;
}

#one-auth-error {
  margin: 1rem 0 0;
  color: #fca5a5;
  line-height: 1.5;
}

button[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* Landscape phones: compact the cards so sign-in fits without scrolling. */
@media (max-height: 480px) {
  .boot-card {
    padding: 0.75rem 1.25rem;
  }

  .brand-mark {
    display: none;
  }

  h1 {
    font-size: 1.4rem;
  }

  .boot-card p {
    margin: 0.5rem 0 0;
  }

  .auth-step {
    margin-top: 0.75rem;
  }

  .auth-card button {
    margin-top: 0.75rem;
  }
}

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

@media (forced-colors: active) {
  .boot-card,
  button {
    border: 1px solid CanvasText;
  }
}
