@font-face {
  font-family: "XKCDScriptLocal";
  src: url("assets/xkcd-script.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #111;
  --muted: #5f5f5f;
  --border: #d8d8d8;
  --accent: #0f5cc0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f4f4f4;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
  width: min(1380px, calc(100vw - 24px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
}

.controls {
  padding: 18px;
  position: sticky;
  top: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.1;
}

.lede {
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.45;
}

form, .advanced-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.hint {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

input[type="number"], input[type="text"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

input[type="checkbox"] {
  justify-self: start;
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

button, #download {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

#reroll {
  background: #555;
}

#download {
  background: var(--accent);
}

.output {
  padding: 10px;
  overflow: auto;
}

canvas {
  display: block;
  width: min(100%, 1302px);
  height: auto;
  background: white;
}

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; }
  .controls { position: static; }
}
