:root {
  --bg: #04150d;
  --ink: #d1fae5;
  --mute: #6ee7b7;
  --line: #0b2a1c;
  --fun: #34d399;
  --facts: #86efac;
  --login: #06150f;
  --hit: 48px;
  --font: ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  min-height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.rail, .chips, #stage, .note, .sheet { position: relative; z-index: 1; }

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.glyph {
  width: 18px;
  height: 18px;
  border: 1px solid var(--fun);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px #243044;
}

.auth { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--login);
  color: var(--ink);
  letter-spacing: 0.08em;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.btn:hover, .btn:focus-visible {
  border-color: var(--fun);
  box-shadow: 0 0 0 1px var(--fun);
  outline: none;
}

.btn.ghost { background: transparent; }

.sheet-only { display: none; }

.chips {
  display: none;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px 0;
}

.chips button {
  min-height: var(--hit);
  min-width: 96px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.chips button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }

#stage {
  height: calc(100dvh - 140px);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.cluster { position: relative; min-height: 0; padding: 0 7%; }

.lane-title {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--mute);
  pointer-events: none;
}

.node {
  position: fixed;
  min-width: var(--hit);
  min-height: var(--hit);
  padding: 4px 10px 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-decoration: none;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: color 160ms ease, text-shadow 160ms ease, border-color 160ms ease;
}

.node .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mute);
  flex: 0 0 8px;
}

.node .lbl {
  max-width: 8.6rem;
  text-align: center;
  line-height: 1.15;
  white-space: nowrap;
}

.node .lbl.wrap {
  white-space: normal;
  overflow-wrap: break-word;
}

.node[data-lane="fun"]:hover, .node[data-lane="fun"]:focus-visible {
  color: var(--fun);
  text-shadow: 0 0 12px rgba(52, 211, 153, 0.45);
  outline: none;
}

.node[data-lane="facts"]:hover, .node[data-lane="facts"]:focus-visible {
  color: var(--facts);
  text-shadow: 0 0 12px rgba(134, 239, 172, 0.45);
  outline: none;
}

.note {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--mute);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.sheet {
  width: min(100%, 420px);
  margin: auto 0 0;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  background: var(--login);
  color: var(--ink);
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet p { letter-spacing: 0.2em; font-size: 11px; margin-bottom: 16px; }
.sheet .btn { width: 100%; margin-bottom: 8px; }

@media (max-width: 899px) {
  body { overflow: hidden; display: flex; flex-direction: column; }
  .rail {
    padding-left: max(10%, env(safe-area-inset-left));
    padding-right: max(10%, env(safe-area-inset-right));
  }
  .rail-only { display: none; }
  .sheet-only { display: inline-flex; align-items: center; padding: 0 12px; }
  .chips {
    display: flex;
    padding: 12px max(10%, env(safe-area-inset-right)) 0 max(10%, env(safe-area-inset-left));
  }
  .chips button { min-width: 0; flex: 1 1 0; max-width: 44%; }
  #stage {
    grid-template-columns: 1fr;
    flex: 1;
    height: auto;
    min-height: 0;
    place-items: center;
  }
  .cluster { display: none; padding: 0; width: 80%; height: min(58dvh, 420px); }
  .cluster.on { display: block; transform: translateY(-40px); }
  .lane-title { display: none; }
  .note { padding: 0 10%; }
}

@media (min-width: 900px) {
  .cluster { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .node, .chips button { transition: none; }
}

#nodes {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.node { pointer-events: auto; }
.node.burst {
  color: #e8c36a;
  text-shadow: 0 0 16px rgba(232, 195, 106, 0.7);
}
.node.burst .dot { background: #e8c36a; box-shadow: 0 0 10px #e8c36a; }
@media (prefers-reduced-motion: no-preference) {
  .node.burst { transform: translate(-50%, -50%) scale(1.08); }
}
