:root {
  color-scheme: dark;
  --bg: #0f0d15;
  --bg-2: #0c0a11;
  --text: #e7e1f5;
  --muted: #b7aacd;
  --border: #2c2640;
  --accent: #ab8fee;
  --accent-2: #8f6ce1;
  --link: #c7b5ff;
  --maxw: 800px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text);
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(143, 108, 225, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(171, 143, 238, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: -1;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(var(--maxw), 92vw);
  margin: 0 auto;
}

header {
  padding: 24px 0;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 85%, transparent 100%);
  z-index: 10;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

nav {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
}

nav a:hover,
nav a.active {
  color: var(--accent);
  text-decoration: none;
}

nav a.active {
  border-bottom: 2px solid var(--accent);
}

main {
  padding: 0 0 60px;
}

section {
  padding: 60px 0;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

section:first-child {
  padding-top: 40px;
}

h1 {
  margin: 0 0 24px;
  line-height: 1.15;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 24px;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

h3 {
  font-size: 1.5rem;
  margin: 0 0 12px;
  font-weight: 600;
}

p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1.125rem;
}

.lead {
  font-size: 1.35rem;
  color: var(--muted);
  margin: 0 0 40px;
  max-width: 65ch;
}

ol, ul {
  margin: 0;
  padding-left: 1.4em;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
}

li {
  margin-bottom: 12px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  color: var(--text);
  background: rgba(171, 143, 238, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.feature {
  background: rgba(171, 143, 238, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.feature h3 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--accent);
}

.feature ul {
  margin: 0;
}

.feature li {
  margin-bottom: 10px;
}

.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  overflow-x: auto;
}

.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
  color: var(--text);
  background: transparent;
  padding: 0;
}

.flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 32px 0;
  padding: 24px;
  background: rgba(171, 143, 238, 0.08);
  border-radius: 12px;
}

.flow-step {
  background: var(--accent);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.flow-arrow {
  color: var(--accent);
  font-size: 1.25rem;
}

.timeline {
  margin: 32px 0;
  padding-left: 24px;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 24px;
  margin-bottom: 32px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 8px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
}

.timeline-year {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 700;
}

.grid-3, .grid-2 {
  display: grid;
  gap: 32px 40px;
  margin-top: 32px;
  text-align: left;
}

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

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

.item h3 {
  font-size: 1.5rem;
  margin: 0 0 12px;
  color: var(--text);
  font-weight: 600;
}

.item p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.metrics {
  display: grid;
  gap: 20px;
  margin-top: 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.metric {
  display: flex;
  gap: 20px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.metric:first-child {
  border-top: 1px solid var(--border);
}

.metric .v {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.75rem;
  min-width: 5ch;
}

.metric .d {
  color: var(--muted);
  font-size: 1.05rem;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.example-card {
  background: rgba(171, 143, 238, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.example-card .icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.example-card h4 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--text);
}

.example-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.summary-box {
  background: linear-gradient(135deg, rgba(171, 143, 238, 0.15), rgba(143, 108, 225, 0.15));
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 32px;
  margin-top: 40px;
  text-align: center;
}

.summary-box h3 {
  margin: 0 0 16px;
  color: var(--accent);
}

.demo-note {
  margin: 0 auto 40px;
  max-width: 60ch;
  color: var(--muted);
  text-align: center;
  font-size: 1.15rem;
}

#buttons {
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#help {
  display: none;
  border: 1px solid var(--border);
  padding: 12px;
  margin: 12px 0 14px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
}

.emscripten {
  text-align: center;
}

div.emscripten {
  margin: 0 auto;
}

.spinner {
  width: 22px;
  height: 22px;
  margin: 10px auto;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#status {
  display: inline-block;
  margin: 8px 0 6px;
  color: var(--text);
  font-weight: 600;
}

#progress {
  width: min(420px, 92vw);
  height: 14px;
  margin: 6px auto 0;
}

.emscripten_border {
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
  width: min(90vw, 1200px);
  margin-left: 50%;
  transform: translateX(-50%);
}

canvas.emscripten {
  border: 0;
  padding: 0;
  display: block;
  width: 100%;
  background-color: #000;
  aspect-ratio: 3 / 2;
}

#infos, #disclaimer {
  margin-top: 12px;
  text-align: left;
  color: var(--muted);
  font-size: 0.9rem;
}

footer {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.appendix {
  background: var(--bg);
  padding: 60px 0;
  min-height: 60vh;
}

.compare-table {
  margin-top: 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.compare-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: rgba(171, 143, 238, 0.15);
  font-weight: 600;
  color: var(--text);
}

.compare-header span {
  padding: 16px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.compare-header span:last-child {
  border-right: none;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--border);
}

.compare-row span {
  padding: 14px 16px;
  text-align: center;
  color: var(--muted);
  border-right: 1px solid var(--border);
}

.compare-row span:last-child {
  border-right: none;
}

.compare-label {
  text-align: left !important;
  font-weight: 500;
  color: var(--text) !important;
}

.compare-row .winner {
  color: var(--accent) !important;
  font-weight: 600;
}

@media (max-width: 600px) {
  .compare-header,
  .compare-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .compare-header span,
  .compare-row span {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .compare-row:last-child span:last-child {
    border-bottom: none;
  }
}