:root {
  --bg: #0b0d10;
  --bg-2: #12161b;
  --panel: rgba(16, 20, 26, 0.88);
  --panel-border: #232a33;
  --text: #e6e9ef;
  --muted: #8a94a5;
  --accent: #55e09a;
  --accent-dim: #2f7f5a;
  --grid: #1a2028;
  --grid-strong: #242d38;
  --cell: #9bf0c4;
  --cell-edge: #55e09a;
  --danger: #e07676;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

canvas#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  touch-action: none;
}

canvas#world.panning {
  cursor: grabbing;
}

canvas#world.stamping {
  cursor: crosshair;
}

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 288px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 14px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: transform 160ms ease, opacity 160ms ease;
}

.panel.collapsed {
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}

.icon-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.reopen-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 5;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.group {
  padding: 10px 0;
  border-top: 1px solid var(--panel-border);
}

.group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.row:last-child {
  margin-bottom: 0;
}

button {
  flex: 1;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}

button:hover {
  border-color: var(--muted);
}

button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #031510;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent);
}

button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #031510;
}

.field {
  display: block;
  margin: 8px 0;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.field output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 0;
  min-height: 1em;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.stats div {
  display: flex;
  flex-direction: column;
}

.stats span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats strong {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
}

.stats div:last-child {
  grid-column: span 2;
}

.help ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
}

.help li {
  margin: 2px 0;
}

kbd {
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

details[open] summary {
  color: var(--text);
}

@media (max-width: 560px) {
  .panel {
    width: calc(100vw - 32px);
    font-size: 13px;
  }
}
