:root {
  --bg: #111; --fg: #f0f0f0; --accent: #5ee87d;
  --panel: #222; --panel-active: #333;
}
* { box-sizing: border-box; }
html, body { touch-action: manipulation; }
body {
  background: var(--bg); color: var(--fg); margin: 0;
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  height: 100vh; height: 100svh; overflow: hidden;
}

/* ─── Section nav ──────────────────────────────────────── */
#spa-section-nav {
  position: fixed; top: 0; left: 0; width: 100%; z-index: 20;
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 0.75rem; padding: 0.75rem;
  background: var(--bg); box-shadow: 0 2px 12px #0006;
}

/* ─── Root layout ──────────────────────────────────────── */
#spa-root {
  position: relative; height: 100vh; height: 100svh;
  display: flex; flex-direction: column; width: 100%;
  padding: 4.6rem 1rem 0.9rem; overflow: hidden;
}

/* ─── Hero area ────────────────────────────────────────── */
#spa-hero-container {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  width: 100%; touch-action: none;
}

/* ─── Item nav ─────────────────────────────────────────── */
#spa-item-nav {
  width: 100%; display: flex; justify-content: center;
  gap: 0.75rem; margin: 0.75rem 0 0;
  position: relative; z-index: 11; flex-wrap: wrap; padding: 0 0.5rem;
}

/* ─── Dots ─────────────────────────────────────────────── */
#spa-dots {
  width: 100%; display: flex; justify-content: center;
  align-items: center; gap: 0.45rem; margin: 0.6rem 0 0; min-height: 12px;
}
.spa-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #444; border: none; padding: 0; cursor: pointer;
  transition: background 0.2s, transform 0.2s; flex-shrink: 0;
}
.spa-dot[aria-selected="true"] { background: var(--accent); transform: scale(1.35); }

/* ─── Hero card ────────────────────────────────────────── */
.spa-hero {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: min(100%, 38rem);
  min-height: 320px; text-align: center; cursor: grab;
}
.spa-hero:active { cursor: grabbing; }

.spa-hero--linkable { cursor: pointer; }
.spa-hero--linkable:active { cursor: pointer; }
.spa-hero--linkable:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 16px;
}

/* Text hero */
.spa-hero--text {
  background: transparent; border: 2px solid transparent;
  border-radius: 12px; padding: 2rem 2.5rem; min-height: unset;
  box-shadow: none; transition: background 0.15s, border-color 0.15s;
  user-select: none; touch-action: manipulation;
}
.spa-hero--text:hover { background: transparent; border-color: transparent; }

/* GIF hero wrapper */
.spa-hero--gif-linkable {
  padding: 1.25rem; border: 2px solid transparent;
  border-radius: 20px; background: transparent; min-height: unset;
  transition: border-color 0.18s, background 0.18s;
}
.spa-hero--gif-linkable:hover,
.spa-hero--gif-linkable:active {
  border-color: transparent; background: transparent;
}

/* Media */
.spa-hero-image, .spa-hero-gif {
  width: min(80vw, 320px); height: auto; max-height: 60vh; border-radius: 16px;
}
.spa-hero-image { background: transparent; box-shadow: 0 4px 32px #000a; }
.spa-hero-gif   { background: transparent; box-shadow: none; border-radius: 0; }

.spa-hero-text {
  font-size: clamp(1.8rem, 5vw, 2.5rem); color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 1.25rem 0; text-align: center;
}

/* ─── Nav buttons ──────────────────────────────────────── */
.spa-nav-btn {
  background: var(--panel); color: var(--accent); border: 1px solid #2f2f2f;
  border-radius: 10px; padding: 0.75rem 1rem; margin: 0;
  min-height: 44px; min-width: 44px; font-size: 1rem; line-height: 1.2;
  cursor: pointer; touch-action: manipulation; transition: background 0.2s;
}
.spa-nav-btn:hover, .spa-nav-btn:active { background: var(--panel-active); }
.spa-nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Transition canvas ────────────────────────────────── */
#transition-canvas {
  display: none; position: absolute; transform: translate(-50%, -50%);
}

/* ─── Overlay modal ────────────────────────────────────── */
#spa-overlay-root {
  position: fixed; inset: 0; display: none; z-index: 120;
  background: rgba(0,0,0,0.68); backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px); padding: 1rem;
}
.spa-overlay {
  width: min(92vw, 32rem); margin: min(14vh, 8rem) auto 0;
  background: linear-gradient(180deg, #1b1b1b 0%, #141414 100%);
  border: 1px solid #2f2f2f; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55); padding: 1rem;
}
.spa-overlay--inline {
  width: min(100%, 38rem); min-height: 320px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  padding: 1rem 1rem 1.1rem; box-shadow: 0 10px 34px rgba(0,0,0,0.38);
}
.spa-overlay-title {
  font-size: clamp(1.35rem, 4vw, 1.8rem); text-transform: lowercase;
  letter-spacing: 0.06em; margin-bottom: 0.35rem;
}
.spa-overlay-subtitle { margin: 0; color: #9aa19b; font-size: 0.9rem; letter-spacing: 0.03em; }
.spa-overlay-links { margin-top: 0.9rem; display: grid; gap: 0.55rem; }
.spa-overlay-link {
  display: block; color: var(--accent); text-decoration: none;
  background: #1f1f1f; border: 1px solid #2f2f2f; border-radius: 10px;
  padding: 0.7rem 0.8rem; letter-spacing: 0.03em;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.spa-overlay-link:hover,
.spa-overlay-link:focus-visible { background: #282828; border-color: #3e6b49; outline: none; }
.spa-overlay-close {
  margin-top: 0.85rem; width: 100%; min-height: 44px;
  border-radius: 10px; border: 1px solid #345a3d; background: #1f2b22;
  color: var(--accent); font: inherit; cursor: pointer;
}
.spa-overlay-close:hover,
.spa-overlay-close:focus-visible { background: #27342a; border-color: #3e6b49; outline: none; }

/* ─── Asymptote game styles ────────────────────────────── */
.asy-stats-bar {
  display: flex; gap: 0.5rem; align-items: center; font-size: 0.8rem;
  color: #9aa; padding: 0 0.25rem;
}
.asy-core-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.asy-engine-hero {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 200px; user-select: none;
}
.asy-motif {
  font-size: clamp(2.4rem, 7vw, 3.6rem); color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.asy-item-hero {
  display: flex; align-items: center; justify-content: center;
  width: min(100%, 38rem); min-height: 320px;
}
.asy-hero-action {
  min-height: 44px; min-width: 44px; border-radius: 10px;
  border: 1px solid #2f2f2f; background: var(--panel);
  color: var(--accent); font: inherit; cursor: pointer; padding: 0.7rem 1.2rem;
  transition: background 0.2s;
}
.asy-hero-action:hover { background: var(--panel-active); }
.asy-hero-main.asy-hero--dim { opacity: 0.38; transition: opacity 0.25s; }

/* ─── Mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
  #spa-root { padding: 4.1rem 0.7rem 0.65rem; }
  #spa-section-nav { justify-content: flex-start; gap: 0.5rem; padding: 0.6rem 0.75rem; }
  .spa-hero { min-height: 240px; }
  .spa-hero-image, .spa-hero-gif { width: min(86vw, 320px); max-height: 50vh; }
}
