:root {
  --bg: #070b14;
  --bg-elevated: rgba(13, 19, 34, 0.72);
  --surface-border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent-1: #f38020;
  --accent-2: #ffb347;
  --accent-3: #a855f7;
  --accent-4: #38bdf8;
  --btn-text: #090d16;
  --card-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  --radius-card: 24px;
  --radius-pill: 999px;
  --font-sans: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, monospace;
}

:root[data-theme="aurora"] {
  --bg: #051118;
  --bg-elevated: rgba(8, 24, 34, 0.74);
  --accent-1: #10b981;
  --accent-2: #22d3ee;
  --accent-3: #6366f1;
  --accent-4: #34d399;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.45s ease;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Ambient aurora background blobs */
.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  filter: blur(72px);
  opacity: 0.58;
}

.aurora-blob {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  transition: background 0.5s ease;
}

.blob-1 {
  width: min(70vw, 440px);
  height: min(70vw, 440px);
  top: -12%;
  left: -12%;
  background: radial-gradient(circle, var(--accent-1), transparent 70%);
  animation: driftA 16s ease-in-out infinite alternate;
}

.blob-2 {
  width: min(65vw, 420px);
  height: min(65vw, 420px);
  bottom: -14%;
  right: -10%;
  background: radial-gradient(circle, var(--accent-3), transparent 70%);
  animation: driftB 19s ease-in-out infinite alternate;
}

.blob-3 {
  width: min(55vw, 340px);
  height: min(55vw, 340px);
  top: 42%;
  left: 52%;
  background: radial-gradient(circle, var(--accent-4), transparent 70%);
  animation: driftC 14s ease-in-out infinite alternate;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: max(1.25rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.hero-card {
  position: relative;
  width: 100%;
  max-width: 720px;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border-radius: var(--radius-card);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform-style: preserve-3d;
  transition: transform 0.22s ease-out, border-color 0.35s ease;
  animation: cardEnter 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Subtle animated gradient border glow */
.hero-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    125deg,
    var(--accent-1),
    var(--accent-3),
    var(--accent-4),
    var(--accent-2)
  );
  background-size: 240% 240%;
  animation: borderFlow 8s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.65;
  pointer-events: none;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: clamp(1.25rem, 3vw, 1.85rem);
}

.edge-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 2.5vw, 0.82rem);
  color: var(--text);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulseRing 2s infinite;
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background-color 0.25s ease,
    border-color 0.25s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-2);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
}

.hero-body {
  text-align: left;
}

.eyebrow {
  margin: 0 0 0.55rem;
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 2.4vw, 0.84rem);
  letter-spacing: 0.14em;
  color: var(--accent-2);
  font-weight: 600;
}

.hero-title {
  margin: 0;
  font-size: clamp(2.25rem, 11vw, 4.75rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  font-weight: 700;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  word-break: keep-all;
}

.hero-title .word {
  display: inline-flex;
  white-space: nowrap;
}

.hero-title .space {
  width: 0.32em;
  display: inline-block;
}

.hero-title .char {
  display: inline-block;
  background: linear-gradient(
    135deg,
    #ffffff 10%,
    var(--accent-2) 55%,
    var(--accent-1) 95%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: charEnter 0.65s cubic-bezier(0.22, 1, 0.36, 1) both,
    charFloat 4.2s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 45ms),
    calc(0.7s + var(--i, 0) * 110ms);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.hero-title .char:hover {
  transform: translateY(-6px) scale(1.08);
  filter: drop-shadow(0 6px 16px rgba(243, 128, 32, 0.45));
}

.hero-title .char.is-jumping {
  animation: charWave 0.68s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 38ms);
}

.subtitle {
  margin: 1rem 0 0;
  min-height: 1.7em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: clamp(0.88rem, 3.2vw, 1.08rem);
  color: var(--accent-4);
}

.prompt {
  color: var(--accent-1);
  font-weight: 600;
}

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  background: var(--accent-2);
  border-radius: 2px;
  animation: blink 0.9s steps(1) infinite;
}

.description {
  margin: 1rem 0 0;
  max-width: 56ch;
  font-size: clamp(0.95rem, 3vw, 1.06rem);
  line-height: 1.62;
  color: var(--text-muted);
}

.actions {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.8rem 1.35rem;
  border-radius: 14px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, box-shadow 0.25s ease,
    background-color 0.25s ease, border-color 0.25s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  color: var(--btn-text);
  background: linear-gradient(135deg, var(--accent-2), var(--accent-1));
  box-shadow: 0 10px 26px rgba(243, 128, 32, 0.28);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(243, 128, 32, 0.4);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-4);
  transform: translateY(-2px);
}

.btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-4);
  outline-offset: 3px;
}

.stats-grid {
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.stat-item {
  padding: 0.8rem 0.95rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  margin: 0.3rem 0 0;
  font-family: var(--font-mono);
  font-size: clamp(0.95rem, 3.2vw, 1.1rem);
  font-weight: 600;
  color: var(--text);
}

.stage-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  animation: fadeUp 0.9s 0.25s ease both;
}

.stage-footer p {
  margin: 0;
}

.stage-footer .credit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Mobile-first breakpoints */
@media (min-width: 400px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid .stat-item:last-child {
    grid-column: span 2;
  }
}

@media (min-width: 540px) {
  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .btn {
    flex: 0 1 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid .stat-item:last-child {
    grid-column: auto;
  }
}

/* Keyframes */
@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes charEnter {
  from {
    opacity: 0;
    transform: translateY(28px) rotate(6deg) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@keyframes charFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes charWave {
  0% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(-16px) scale(1.16) rotate(-4deg);
  }
  70% {
    transform: translateY(4px) scale(0.96) rotate(2deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes borderFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes driftA {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(14%, 10%) scale(1.12);
  }
}

@keyframes driftB {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-14%, -12%) scale(1.15);
  }
}

@keyframes driftC {
  from {
    transform: translate(-20%, -10%) scale(0.95);
  }
  to {
    transform: translate(12%, 14%) scale(1.1);
  }
}

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