:root {
  color-scheme: dark;
  --bg: #05040a;
  --panel: rgba(16, 14, 29, 0.74);
  --panel-line: rgba(255, 255, 255, 0.14);
  --text: #f8f5ff;
  --muted: #b7aec9;
  --gold: #ffb31a;
  --gold-2: #ff7b1a;
  --red: #d91e36;
  --violet: #8f68ff;
  --cyan: #5fe4ff;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(circle at 22% 18%, rgba(143, 104, 255, 0.22), transparent 32%),
    radial-gradient(circle at 78% 74%, rgba(255, 123, 26, 0.15), transparent 26%),
    linear-gradient(145deg, #05040a 0%, #0b0716 45%, #060914 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.shell {
  position: relative;
  min-height: 100svh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(54px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.aurora {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse at 35% 30%, rgba(95, 228, 255, 0.12), transparent 28%),
    radial-gradient(ellipse at 68% 46%, rgba(255, 179, 26, 0.12), transparent 22%),
    radial-gradient(ellipse at 48% 78%, rgba(143, 104, 255, 0.18), transparent 30%);
  filter: blur(34px);
  opacity: 0.9;
  animation: mist 12s ease-in-out infinite alternate;
}

.intro {
  position: relative;
  z-index: 4;
  width: min(520px, calc(100vw - 36px));
  margin: max(40px, 8svh) auto 0;
  text-align: center;
  pointer-events: none;
  transition: opacity 700ms ease, transform 700ms ease;
}

.intro.hidden {
  opacity: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

.kicker {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 9.5vw, 5.4rem);
  line-height: 1;
  text-wrap: balance;
}

h2 {
  font-size: 1.55rem;
}

.hint {
  margin: 18px auto 0;
  max-width: 360px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.status {
  min-height: 1.4em;
  color: #ffd78a;
}

.dragonfield {
  position: absolute;
  inset: max(190px, 31svh) 0 54px;
  z-index: 3;
  transition: opacity 650ms ease, filter 650ms ease;
}

.dragonfield.solved {
  opacity: 0;
  filter: blur(10px);
  pointer-events: none;
}

.ball {
  position: absolute;
  width: clamp(38px, var(--size), 54px);
  height: clamp(38px, var(--size), 54px);
  border: 0;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 0.88), transparent 10%),
    radial-gradient(circle at 38% 34%, #ffe36c 0 12%, transparent 13%),
    radial-gradient(circle at 63% 70%, #cf4f12 0%, transparent 28%),
    linear-gradient(145deg, var(--gold), var(--gold-2));
  box-shadow:
    0 0 calc(var(--size) * var(--glow)) rgba(255, 179, 26, 0.62),
    inset -8px -10px 18px rgba(90, 22, 0, 0.34);
  transform: translate(-50%, -50%);
  animation: float 5.8s ease-in-out infinite;
  animation-delay: var(--delay);
  -webkit-tap-highlight-color: transparent;
}

.ball.quiet {
  opacity: 0.78;
  animation-name: quietFloat;
}

.ball.wide {
  animation-duration: 7s;
}

.ball.pulse {
  animation-name: float, glowPulse;
  animation-duration: 6s, 2.8s;
}

.ball svg {
  position: absolute;
  inset: 10%;
  width: 80%;
  height: 80%;
  filter: drop-shadow(0 1px 1px rgba(70, 0, 0, 0.58));
}

.ball.wrong {
  animation: shake 260ms ease;
}

.burst {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: rgba(255, 226, 107, 0.92);
  box-shadow: 0 0 70px 42px rgba(255, 179, 26, 0.45);
}

.burst.active {
  animation: burst 700ms ease-out;
}

.auth-panel {
  position: relative;
  z-index: 5;
  width: min(390px, calc(100vw - 36px));
  margin: auto 0;
  padding: 24px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44), 0 0 50px rgba(143, 104, 255, 0.16);
  backdrop-filter: blur(22px);
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  pointer-events: none;
  transition: opacity 650ms ease, transform 650ms ease;
}

.auth-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  width: 100%;
  border-radius: 8px;
}

.primary,
.ghost,
.link-button {
  margin-top: 14px;
}

.primary {
  border: 0;
  color: #140a00;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd36b, #ff8f1f);
}

.ghost {
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.link-button {
  min-height: auto;
  border: 0;
  color: var(--cyan);
  background: transparent;
}

.password-form {
  display: none;
  margin-top: 16px;
}

.password-form.visible {
  display: block;
}

label {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  background: rgba(3, 3, 8, 0.48);
}

footer {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
  text-align: center;
}

@keyframes mist {
  from { transform: translate3d(-2%, -1%, 0) rotate(-2deg); }
  to { transform: translate3d(2%, 1%, 0) rotate(2deg); }
}

@keyframes float {
  0%, 100% { transform: translate(-50%, -50%) translate3d(0, 0, 0); }
  50% { transform: translate(-50%, -50%) translate3d(10px, -16px, 0); }
}

@keyframes quietFloat {
  0%, 100% { transform: translate(-50%, -50%) translate3d(0, 0, 0); }
  50% { transform: translate(-50%, -50%) translate3d(-4px, 5px, 0); }
}

@keyframes glowPulse {
  50% { filter: saturate(1.25) brightness(1.08); }
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) translateX(0); }
  25% { transform: translate(-50%, -50%) translateX(-8px); }
  75% { transform: translate(-50%, -50%) translateX(8px); }
}

@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.1); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(18); }
}

@media (max-width: 430px) {
  .shell {
    padding-inline: 14px;
  }

  .intro {
    width: min(360px, calc(100vw - 28px));
    margin-top: max(34px, 7svh);
  }

  .hint {
    margin-top: 12px;
    font-size: 0.95rem;
  }

  .dragonfield {
    inset: max(218px, 36svh) 0 58px;
  }

  .ball {
    width: clamp(36px, var(--size), 48px);
    height: clamp(36px, var(--size), 48px);
  }
}

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