:root { --bg: #06070b; --accent: #8be28f; --accent-ink: #06170a; }
#stage { cursor: crosshair; }

#rules {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 64px);
  transform: translate(-50%, 10px);
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
  padding: 16px 18px 18px;
  border-radius: 18px;
  background: var(--surface-strong);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 12;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0s linear 0.18s;
}
#rules.open { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0s; }
.rules-head { display: flex; align-items: center; justify-content: space-between; }
.rules-head h2 { font-family: var(--serif); font-weight: 400; font-size: 20px; }
.rules-x { display: grid; place-items: center; width: 36px; height: 36px; margin-right: -8px; border-radius: 10px; color: var(--muted); }
.rules-x:hover { background: var(--raised-2); color: var(--text); }
.rules-note { margin: 4px 0 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.rules-note strong { color: var(--text); font-weight: 500; }

#matrix { display: grid; gap: 4px; }
#matrix .dot { display: grid; place-items: center; }
#matrix .dot i { width: 14px; height: 14px; border-radius: 50%; }
#matrix button { aspect-ratio: 1; min-height: 34px; border-radius: 8px; border: 1px solid var(--line); transition: transform 0.1s; }
#matrix button:active { transform: scale(0.9); }

.rules-key { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.rules-key span { display: inline-flex; align-items: center; gap: 6px; }
.rules-key i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--line); }
.k-neg { background: #c8493f; } .k-zero { background: #23262d; } .k-pos { background: #3fae5a; }
.rules-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }
.rules-presets button { min-height: 40px; border-radius: 10px; background: var(--raised); font-size: 14px; }
.rules-presets button:hover { background: var(--raised-2); }
