:root {
  --bg: #05070b;
  --bg-deep: #020305;
  --grid: rgba(0, 255, 170, 0.08);
  --cyan: #4dfff0;
  --magenta: #ff3df2;
  --amber: #ffb347;
  --text: #cfeee8;
  --muted: #6f9c95;
  --panel: rgba(5, 10, 14, 0.55);
  --panel-border: rgba(77, 255, 240, 0.22);
  --glow: 0 0 12px rgba(77, 255, 240, 0.35), 0 0 30px rgba(255, 61, 242, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 61, 242, 0.12), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(77, 255, 240, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle CRT scanlines */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03),
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
  opacity: 0.18;
  z-index: 2;
}

#lattice {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: var(--glow);
  z-index: 3;
  pointer-events: none;
}

.brand { display: flex; flex-direction: column; gap: 2px; }
.sig {
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(77,255,240,0.5);
}
.sub { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }

.controls { display: flex; gap: 8px; pointer-events: auto; }

.btn {
  appearance: none;
  border: 1px solid rgba(77, 255, 240, 0.45);
  background: rgba(77, 255, 240, 0.08);
  color: var(--cyan);
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease, border-color 160ms ease;
}
.btn:hover, .btn:focus-visible {
  background: rgba(77, 255, 240, 0.16);
  box-shadow: 0 0 14px rgba(77, 255, 240, 0.25);
  outline: none;
}
.btn[aria-pressed="true"] {
  border-color: rgba(255, 61, 242, 0.6);
  color: #fff;
  background: rgba(255, 61, 242, 0.18);
  box-shadow: 0 0 16px rgba(255, 61, 242, 0.25);
}
.btn.ghost {
  border-color: rgba(207, 238, 232, 0.18);
  color: var(--muted);
  background: transparent;
}
.btn.ghost:hover { color: var(--text); border-color: rgba(207,238,232,0.35); }

.hint {
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  opacity: 0.95;
}
.hint kbd {
  font: inherit;
  font-size: 10px;
  color: var(--text);
  border: 1px solid rgba(207,238,232,0.25);
  border-bottom-color: rgba(207,238,232,0.4);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
}

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--text); z-index: 10; padding: 24px; text-align: center;
}

@media (max-width: 640px) {
  .hud { left: 10px; right: 10px; bottom: 10px; padding: 10px 12px; }
  .hint { font-size: 10px; }
  .sig { font-size: 12px; }
}
