:root {
  --bg: #080b14;
  --bg-elev: #0f1420;
  --bg-elev-2: #161d2c;
  --border: #232c40;
  --text: #e8edf7;
  --text-dim: #9aa7bf;
  --accent: #5eead4;
  --accent-2: #a78bfa;
  --warn: #fbbf24;
  --ok: #34d399;
  --err: #f87171;
  --radius: 14px;
  --wrap: 1080px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must beat component display rules such as
   `.play-step { display: flex }`, otherwise hidden elements stay visible. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(900px 500px at 10% 0%, rgba(94, 234, 212, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(100% - 2.5rem, var(--wrap));
  margin-inline: auto;
}

.mono { font-family: var(--mono); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #04231d;
  padding: 0.6rem 1rem;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(8, 11, 20, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: #04231d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 0.45rem 0.55rem;
  border-radius: 9px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 0.95rem; letter-spacing: -0.01em; }
.brand-text small { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; }

.site-nav { display: flex; gap: 1.4rem; }
.site-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--text); }

/* ---------- hero ---------- */
.hero { padding: 5rem 0 3rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
}

.hero h1 {
  font-size: clamp(2.3rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 1.2rem;
  font-weight: 800;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 62ch;
  margin: 0 0 2rem;
}
.lede strong { color: var(--text); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 3rem; }

.btn {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04231d; }
.btn-ghost { border-color: var(--border); color: var(--text); background: rgba(255,255,255,0.02); }
.btn-ghost:hover { border-color: var(--accent); }

.loop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.7rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15, 20, 32, 0.6);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.loop-step { color: var(--text-dim); }
.loop-step-final { color: var(--accent); font-weight: 600; }
.loop-arrow { color: var(--border); }

/* ---------- sections ---------- */
.section { padding: 3.5rem 0; border-top: 1px solid var(--border); }

.section h2 {
  font-size: 1.7rem;
  letter-spacing: -0.025em;
  margin: 0 0 0.6rem;
}

.section-lede { color: var(--text-dim); max-width: 60ch; margin: 0 0 2rem; }

/* ---------- missions ---------- */
.mission-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1rem;
}

.mission-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.15s, transform 0.15s;
}
.mission-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.mission-topic {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.mission-card h3 { margin: 0; font-size: 1.05rem; letter-spacing: -0.015em; }
.mission-card p { margin: 0; color: var(--text-dim); font-size: 0.87rem; }

.tag {
  align-self: flex-start;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag[data-kind="planned"] { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.tag[data-kind="building"] { color: var(--accent); border-color: rgba(94, 234, 212, 0.35); }

/* ---------- principles ---------- */
.principle-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.principle-grid li {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1rem;
}
.principle-grid h3 { margin: 0 0 0.25rem; font-size: 0.98rem; }
.principle-grid p { margin: 0; color: var(--text-dim); font-size: 0.87rem; }

/* ---------- status ---------- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.status-card {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 1rem 1.1rem;
}
.status-card h3 { margin: 0 0 0.15rem; font-size: 0.95rem; }
.status-card p { margin: 0; font-size: 0.82rem; color: var(--text-dim); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.45rem;
  flex: none;
  background: var(--text-dim);
}
.status-dot[data-state="ok"] { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.status-dot[data-state="err"] { background: var(--err); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16); }
.status-dot[data-state="pending"] { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 3rem 0 3.5rem;
  margin-top: 2rem;
}

.north-star {
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin: 0 0 1.5rem;
}

.footer-meta { color: var(--text-dim); font-size: 0.78rem; margin: 0; }

@media (max-width: 620px) {
  .site-nav { display: none; }
  .hero { padding: 3rem 0 2rem; }
}

/* ---------- play / onboarding ---------- */
.play-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
  padding: 1.6rem;
  max-width: 620px;
}

.play-step { display: flex; flex-direction: column; gap: 1rem; }
.play-step h3 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; }

/* Buttons that are direct children of a flex column would otherwise be
   stretched to full width by the default `align-items: stretch`. */
.play-step > .btn { align-self: flex-start; }

#step-connecting { flex-direction: row; align-items: center; gap: 0.75rem; color: var(--text-dim); }
#step-connecting p { margin: 0; }

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field-row { display: flex; flex-direction: column; gap: 0.35rem; }
.field-row-split { flex-direction: row; gap: 1rem; }
.field-row-split > div { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }

.field-row label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field-row input,
.field-row select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(8, 11, 20, 0.7);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
  width: 100%;
}
.field-row input::placeholder { color: #5c6980; }
.field-row input:focus,
.field-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.14);
}

.play-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.muted { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

.form-error {
  margin: 0;
  color: var(--err);
  font-size: 0.88rem;
  font-family: var(--mono);
}

.event-log {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}
.event-log-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.event-log ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.event-log li {
  font-size: 0.82rem;
  color: var(--text-dim);
  background: rgba(94, 234, 212, 0.06);
  border-left: 2px solid var(--accent);
  padding: 0.35rem 0.6rem;
  border-radius: 0 6px 6px 0;
}

@media (max-width: 520px) {
  .field-row-split { flex-direction: column; }
  .play-panel { padding: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .spinner { animation: none; }
}
