/* Bioform v0.1 — divide & fuse arcade.
 * Per biogame-fun-and-visual-meta v0.11: A1-A3 agency-density compliant +
 * V1-V4 visual ship-blockers preserved.
 *
 * Canvas covers the viewport; HUD is overlay chrome.
 */

:root {
  --hud-fg: #f0eee5;
  --hud-mute: rgba(240,238,229,0.62);
  --font-system: system-ui, -apple-system, "Segoe UI", "Atkinson Hyperlegible",
                 "Inter", Roboto, sans-serif;
  --ease-organic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-system);
  color: var(--hud-fg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  cursor: pointer;
  z-index: 0;
}

/* ── HUD overlay (top bar) ─────────────────────────────────────────────── */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.45), rgba(0,0,0,0));
  pointer-events: none;
  font-size: 0.85rem;
}
.hud-left, .hud-right {
  display: flex; gap: 0.85rem;
  pointer-events: auto;
}
.hud-tag, .hud-stat {
  color: var(--hud-mute);
  font-variant: small-caps;
  letter-spacing: 0.05em;
}
.hud-stat strong {
  color: var(--hud-fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 0.15em;
}
.link {
  background: none;
  border: 1px solid rgba(240,238,229,0.25);
  color: var(--hud-mute);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  transition: all 200ms var(--ease-organic);
}
.link:hover {
  color: var(--hud-fg);
  border-color: rgba(240,238,229,0.5);
  background: rgba(240,238,229,0.08);
}

/* ── Bottom prompt + footer ─────────────────────────────────────────────── */
.prompt {
  position: fixed;
  left: 50%;
  bottom: 3.5rem;
  transform: translateX(-50%);
  z-index: 9;
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--hud-mute);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

.footer {
  position: fixed;
  bottom: 0.6rem;
  left: 0; right: 0;
  z-index: 9;
  text-align: center;
  pointer-events: none;
}
.version {
  font-size: 0.7rem;
  color: var(--hud-mute);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ── Lose-state overlay ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 280ms var(--ease-organic);
}
.overlay.hidden { display: none; }
.overlay-card {
  background: rgba(20,20,24,0.92);
  border: 1px solid rgba(240,238,229,0.18);
  border-radius: 14px;
  padding: 1.6rem 1.6rem 1.4rem;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.overlay-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.overlay-card p {
  margin: 0 0 0.6rem;
  color: var(--hud-mute);
  font-size: 0.92rem;
  line-height: 1.5;
}
.overlay-stats {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--hud-fg);
  border-top: 1px solid rgba(240,238,229,0.12);
  padding-top: 0.7rem;
  margin-top: 0.7rem !important;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}
.action {
  margin-top: 0.6rem;
  background: var(--hud-fg);
  color: #111;
  border: none;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 200ms var(--ease-organic);
}
.action:hover { transform: translateY(-1px); }
.action:active { transform: translateY(1px); }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Reduced-motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .overlay { animation: none; }
  .action  { transition: none; }
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .hud { padding: 0.5rem 0.6rem; font-size: 0.78rem; }
  .hud-left, .hud-right { gap: 0.55rem; }
  .prompt { bottom: 3rem; font-size: 0.75rem; }
  .overlay-card { padding: 1.2rem; max-width: 92vw; }
}

/* ── Theme-specific body tints (substrate is canvas-rendered, but theme
       chrome can adjust HUD subtly) ───────────────────────────────────── */
body[data-theme="lichen"] {
  --hud-fg: #f5e6d3;
  --hud-mute: rgba(245,230,211,0.6);
}
body[data-theme="tidekin"] {
  --hud-fg: #e6f4ff;
  --hud-mute: rgba(230,244,255,0.6);
}

/* ─── Lineage tree (v0.3 cycle-16 reflection: phylogenetic-tree-as-progress) ─── */
.lineage-tree {
  margin: 0.9rem 0 0.4rem;
  padding: 0.7rem 0.5rem;
  border: 1px solid rgba(240,238,229,0.10);
  border-radius: 8px;
  background: rgba(240,238,229,0.04);
  font-size: 0.78rem;
}
.lineage-title {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--hud-mute);
  margin-bottom: 0.5rem;
  text-align: center;
  font-size: 0.72rem;
}
.lineage-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.lineage-stem {
  width: 2px;
  height: 6px;
  background: rgba(240,238,229,0.18);
  margin: 0 auto;
}
.lineage-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.lineage-name { flex: 1; text-align: left; }
.lineage-count { color: var(--hud-fg); font-weight: 600; }
.lineage-meta { color: var(--hud-mute); font-style: italic; font-size: 0.7rem; }
.lineage-row.reached-now { color: var(--hud-fg); background: rgba(240,238,229,0.06); }
.lineage-row.reached-ever { color: var(--hud-mute); }
.lineage-row.unreached { color: rgba(240,238,229,0.32); }
.lineage-row.unreached .lineage-dot { box-shadow: none; opacity: 0.4; }

@media (prefers-reduced-motion: reduce) {
  .lineage-dot { box-shadow: none; }
}
