:root {
  --violet: #7434D0;
  --violet-dark: #2D1353;
  --violet-darker: #170A29;
  --ink: #1c1726;
  --muted: #6b6478;
  --border: #e3def0;
  --bg: #ffffff;
  --bg-tint: #f7f4fb;
  --pixel-font: 'Press Start 2P', 'Courier New', monospace;
  --body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--body-font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

.pixel-text {
  font-family: var(--pixel-font);
  letter-spacing: 0.5px;
  line-height: 1.6;
}

.pixel-icon { flex: 0 0 auto; image-rendering: pixelated; }
.pixel-icon rect { fill: currentColor; }

.plus-icon {
  flex: 0 0 auto;
  font-size: 1.2em;
  line-height: 1;
}

/* ---------- Navbar ---------- */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--violet-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(10, 0, 50, 0.5);
  transform: translateY(-100%);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.navbar.in { transform: translateY(0); }

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #fff;
}

.nav-logo { width: 84px; height: 84px; }

.nav-brand .pixel-text { font-size: 0.8rem; color: #fff; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-links a {
  position: relative;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav-links a:not(.nav-cta)::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: width 0.25s ease;
}

.nav-links a:not(.nav-cta):hover { color: #fff; }
.nav-links a:not(.nav-cta):hover::after { width: 100%; }

.nav-links a.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  color: var(--violet);
  border: 1px solid #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  font-size: 0.68rem;
}

.nav-links a.nav-cta:hover { background: var(--bg-tint); color: var(--violet); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: #fff;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  height: 100vh;
  background: var(--violet);
  overflow: hidden;
  text-align: center;
}

.hero-top-text {
  position: absolute;
  top: clamp(8rem, 15vh, 9.5rem);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.hero-title {
  color: #fff;
  font-size: clamp(1.4rem, 5vw, 2.6rem);
  margin: 0;
  text-shadow: 4px 6px 3px rgba(10, 0, 50, 0.55);
}

.hero-title:not(.in) { opacity: 0; pointer-events: none; }
.hero-title.in { animation: heroTitleIn 0.5s cubic-bezier(0.2, 1.2, 0.3, 1) backwards; }

@keyframes heroTitleIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.92); }
}

.hero-subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  margin: 0;
  letter-spacing: 0.02em;
  text-shadow: 3px 5px 8px rgba(10, 0, 50, 0.55);
}

.hero-subtitle:not(.in) { opacity: 0; pointer-events: none; }
.hero-subtitle.in { animation: heroFadeUp 0.5s ease backwards; }

.hero-stage {
  position: absolute;
  top: 58.5%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(220px, min(48vw, 50vh), 460px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo {
  position: relative;
  z-index: 5;
  width: clamp(96px, 22vw, 190px);
  opacity: 0;
  transform: scale(0) rotate(-260deg);
  filter: drop-shadow(0px 14px 40px rgba(10, 0, 50, 0.9));
}

.hero-logo.intro {
  animation: logoIntro 1.1s cubic-bezier(0.22, 1.3, 0.4, 1) forwards;
}

@keyframes logoIntro {
  0% { opacity: 0; transform: scale(0) rotate(-260deg); }
  60% { opacity: 1; transform: scale(1.15) rotate(18deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.command-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.command-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translate(0, 0) scale(0);
  opacity: 0;
  background: rgba(255, 255, 255, 0.96);
  color: var(--violet-dark);
  font-family: var(--pixel-font);
  font-size: clamp(0.5rem, 1.1vw, 0.68rem);
  padding: 0.55em 0.75em;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  pointer-events: auto;
  box-shadow: 3px 5px 12px rgba(10, 0, 50, 0.55);
  transition: transform 0.55s cubic-bezier(0.2, 1.2, 0.3, 1), opacity 0.4s ease;
}

.command-badge.spawned {
  transform: translate(-50%, -50%) translate(var(--x), var(--y)) scale(1);
  opacity: 1;
}

.hero-bottom {
  position: absolute;
  bottom: clamp(2.5rem, 6vh, 3.5rem);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.scroll-indicator {
  padding: 0.25rem;
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  filter: drop-shadow(3px 5px 8px rgba(10, 0, 50, 0.55));
}

.scroll-indicator:not(.show) { opacity: 0; pointer-events: none; }
.scroll-indicator.show { animation: heroFadeIn 0.6s ease backwards; }
.scroll-indicator svg { width: 22px; height: 22px; }

@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(10px); }
}

@keyframes heroFadeIn {
  from { opacity: 0; }
}

.scroll-indicator.show svg {
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ---------- Back to top ---------- */

.back-to-top {
  -webkit-appearance: none;
  appearance: none;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--violet-dark);
  box-shadow: 3px 5px 12px rgba(10, 0, 50, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s ease, bottom 0.15s ease;
}

.back-to-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { border-color: var(--violet); }
.back-to-top svg { width: 18px; height: 18px; }

/* ---------- Shared section layout ---------- */

.section { padding: 5.5rem 1.5rem; scroll-margin-top: 64px; }
.section-inner { max-width: 1080px; margin: 0 auto; }

.hero { scroll-margin-top: 0; }

.section-kicker {
  display: block;
  font-size: 0.65rem;
  color: var(--violet);
  margin-bottom: 1rem;
}

.section-title {
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  margin: 0 0 1rem;
}

.section-lead {
  color: var(--muted);
  max-width: 640px;
  font-size: 1.02rem;
}

/* ---------- Wiki Race section ---------- */

.section-wikirace { background: var(--bg); }

.race-path {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 2.5rem 0 3rem;
}

.race-node {
  font-family: var(--pixel-font);
  font-size: 0.65rem;
  padding: 0.7em 1em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tint);
}

.race-node-target { border-color: var(--violet); color: var(--violet); }
.race-arrow { color: var(--muted); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 4px 8px 18px rgba(10, 0, 50, 0.55);
}

.feature-icon {
  display: inline-block;
  font-size: 0.65rem;
  color: var(--violet);
  margin-bottom: 0.75rem;
}

.feature-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- Fun section ---------- */

.section-fun { background: var(--bg-tint); }

.command-list {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.command-row {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.command-name {
  flex: 0 0 auto;
  width: 10.5rem;
  font-size: 0.75rem;
  color: var(--violet);
}

.command-row span:last-child { color: var(--muted); font-size: 0.95rem; }

/* ---------- About section ---------- */

.section-about { background: var(--bg); }

.stat-grid {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  box-shadow: 4px 8px 18px rgba(10, 0, 50, 0.55);
}

.stat-number { font-size: 1.4rem; color: var(--violet); }
.stat-check { color: var(--violet); margin: 0 auto; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* ---------- Invite section ---------- */

.section-invite { background: var(--violet-dark); }

.section-invite-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-invite .section-title,
.section-invite .section-lead { color: #fff; }
.section-invite .section-lead { color: rgba(255, 255, 255, 0.8); margin-bottom: 2rem; }

.invite-button {
  display: inline-flex;
  align-items: center;
  gap: 0.65em;
  background: #fff;
  color: var(--violet-dark);
  text-decoration: none;
  font-size: 0.75rem;
  padding: 0.9em 1.6em;
  border-radius: 4px;
  transition: transform 0.15s ease;
}

.invite-button:hover { transform: translateY(-2px); }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--violet-darker);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}

.footer-inner p { margin: 0; }
.footer-inner a { text-decoration: none; color: rgba(255, 255, 255, 0.85); }
.footer-inner a:hover { color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .feature-grid,
  .stat-grid { grid-template-columns: 1fr; }

  .command-name { width: 8.5rem; font-size: 0.65rem; }
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--violet-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .nav-links.open { max-height: 320px; }

  .nav-links a {
    width: 100%;
    padding: 0.9rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-links a.nav-cta {
    display: block;
    padding: 0.9rem 1.5rem;
    font-size: 0.78rem;
    background: none;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 0;
  }
}

@media (max-width: 760px) {
  .hero-top-text { top: 9rem; }
}

@media (max-width: 600px) {
  .race-step-extra { display: none; }
  .command-row { flex-direction: column; gap: 0.25rem; }
  .command-name { width: auto; font-size: 0.68rem; }
  .race-path { gap: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .navbar,
  .hero-logo,
  .hero-title,
  .hero-tags,
  .command-badge,
  .scroll-indicator,
  .scroll-indicator.show svg,
  .back-to-top {
    transition: none !important;
    animation: none !important;
  }
}
