:root {
  color-scheme: light;
  --page: #efede6;
  --panel: #fbfaf6;
  --surface: #f4f2eb;
  --border: #d9d5ca;
  --text: #292823;
  --secondary: #5e5a50;
  --accent: #345444;
  --selected: #e3ebe2;
  font: 15px/1.5 system-ui, sans-serif;
  color: var(--text);
  background: var(--page);
}

* { box-sizing: border-box; }

body { margin: 0; }

#background {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  align-items: start;
  gap: 20px;
  max-width: 1228px;
  margin-inline: auto;
  padding: 24px;
}

.sandbox {
  position: relative;
  justify-self: end;
  width: min(100%, calc(100vh - 48px));
  width: min(100%, calc(100dvh - 48px));
  aspect-ratio: 1;
  background: var(--panel);
  border-radius: 16px;
  outline: 1px solid var(--border);
  overflow: hidden;
}

.sandbox canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#sand-canvas {
  z-index: 1;
  cursor: crosshair;
  touch-action: none;
}

#fps {
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--panel);
  color: var(--secondary);
  font: 11px/1.5 ui-monospace, monospace;
  white-space: pre;
  pointer-events: none;
  user-select: none;
}

#fps:empty, .dg { display: none; }

.toolbox {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.toolbox-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.toolbox h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 600;
  line-height: 1.2;
}

.toolbox-header p {
  margin: 4px 0 0;
  color: var(--secondary);
  font-size: 13px;
}

.tool-group {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tool-group h2 {
  margin: 0 0 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.toolbox button, .tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.toolbox button:hover, .tool-button:hover { border-color: var(--secondary); }

.toolbox button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--selected);
  color: var(--accent);
  font-weight: 600;
}

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.simulation-controls, .brush-controls, .element-controls {
  display: grid;
  gap: 4px;
}

.simulation-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.brush-controls { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.element-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.element-controls button {
  justify-content: flex-start;
  gap: 4px;
  padding-inline: 4px;
}

.swatch {
  flex: 0 0 10px;
  height: 10px;
  border: 1px solid rgb(41 40 35 / 24%);
  border-radius: 2px;
}

.wind-swatch {
  border: 0;
  background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
}

.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  align-items: start;
  justify-items: center;
  overflow-y: auto;
  padding: 16px;
  background: rgb(41 40 35 / 52%);
}

.menu {
  position: relative;
  width: min(100%, 680px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.menu-close { position: absolute; top: 16px; right: 16px; }
.Info h1 { padding-right: 64px; }
.Info a { color: var(--accent); }
.app-store-badge { display: block; width: auto; height: 40px; margin: 8px auto; }

.benchmark {
  position: fixed;
  z-index: 3;
  right: 12px;
  bottom: 24px;
  padding: 8px;
  background: var(--panel);
}

@media (max-width: 760px) {
  #background {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .sandbox {
    justify-self: center;
    width: min(100%, max(240px, 58svh));
  }

  .toolbox button, .tool-button { min-height: 44px; }
}
