:root {
  --bg: #fafaf9;
  --text: #1c1917;
  --muted: #6b6762;
  --line: #e7e5e1;
  --surface: #ffffff;
  --sunken: #f3f2ef;
  --accent: #c2410c;
  --accent-soft: #ffedd5;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;

  /* Code */
  --code-bg: #1f1d1b;
  --code-text: #ece9e4;
  --t-comment: #8c857c;
  --t-string: #a5d6a7;
  --t-number: #f9a875;
  --t-keyword: #f0a0d0;
  --t-type: #ffd479;
  --t-call: #8ec5ff;
  --t-punct: #b5afa7;

  /* Puzzle board */
  --sq-a: #efe7d8;
  --sq-b: #e4d8c3;
  --wall: #57534e;

  --mono: ui-monospace, 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --text: #f5f4f1;
    --muted: #a29e98;
    --line: #2b2926;
    --surface: #1b1a18;
    --sunken: #22201e;
    --accent: #fb923c;
    --accent-soft: #3b2414;
    --good: #4ade80;
    --good-soft: #133220;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --code-bg: #0f0e0d;

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

button {
  font: inherit;
  color: inherit;
}

code {
  font-family: var(--mono);
}

p code,
li code,
.lede code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--sunken);
  font-size: 0.88em;
}

.wrap {
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
}

/* Top bar */

.top {
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.brand svg {
  width: 24px;
  height: 24px;
}

.top nav {
  display: flex;
  gap: 4px;
}

.top nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.top nav a:hover {
  background: var(--sunken);
  color: var(--text);
}

/* Hero */

.hero {
  padding: 56px 0 8px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.install {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  margin-top: 24px;
  padding: 6px 6px 6px 16px;
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--code-text);
}

.install code {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.copy:hover {
  background: var(--sunken);
}

.install .copy {
  border-color: transparent;
  background: rgb(255 255 255 / 0.1);
  color: inherit;
}

.install .copy:hover {
  background: rgb(255 255 255 / 0.18);
}

/* Audience tabs */

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-width: 520px;
  margin-top: 40px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.tabs button {
  display: grid;
  gap: 1px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.tabs strong {
  font-size: 15px;
}

.tabs span {
  color: var(--muted);
  font-size: 13px;
}

.tabs button[aria-selected='true'] {
  background: var(--text);
  color: var(--bg);
}

.tabs button[aria-selected='true'] span {
  color: inherit;
  opacity: 0.7;
}

.tabs button:not([aria-selected='true']):hover {
  background: var(--sunken);
}

/* Sections */

.block {
  padding-top: 56px;
}

.block-head {
  max-width: 680px;
  margin-bottom: 24px;
}

h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.block-head p {
  margin: 0;
  color: var(--muted);
}

/* Puzzles */

.pz {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}

.pz-side {
  padding: 16px 10px;
  border-right: 1px solid var(--line);
  background: var(--sunken);
}

.pz-progress {
  margin: 0 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.pz-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pz-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.pz-list button:hover {
  background: var(--surface);
  color: var(--text);
}

.pz-list .n {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}

.pz-list .t {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pz-list .done .n {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good);
}

.pz-list .active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.pz-list .active .n {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pz-main {
  min-width: 0;
  padding: 24px;
}

.pz-step {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pz-title {
  margin: 2px 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.pz-goal {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.pz-text {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
}

.pz-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
  gap: 24px;
  align-items: start;
  margin-top: 20px;
}

.pz-code {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.pz-api {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pz-api button {
  display: grid;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunken);
  text-align: left;
  cursor: pointer;
}

.pz-api button:hover {
  border-color: var(--accent);
}

.pz-api code {
  font-size: 12.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pz-api span {
  color: var(--muted);
  font-size: 12px;
}

/* The editor: a transparent textarea over its highlighted copy. */
.pz-editor {
  display: grid;
  border-radius: 12px;
  background: var(--code-bg);
}

.pz-editor > * {
  grid-area: 1 / 1;
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 0;
  font: 14px/1.65 var(--mono);
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pz-highlight {
  color: var(--code-text);
  pointer-events: none;
}

.pz-input {
  min-height: 150px;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  outline: none;
  border-radius: 12px;
}

.pz-input::selection {
  background: rgb(142 197 255 / 0.35);
}

.pz-input:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.t-comment {
  color: var(--t-comment);
  font-style: italic;
}

.t-string {
  color: var(--t-string);
}

.t-number {
  color: var(--t-number);
}

.t-keyword {
  color: var(--t-keyword);
}

.t-type {
  color: var(--t-type);
}

.t-call {
  color: var(--t-call);
}

.t-punct {
  color: var(--t-punct);
}

.pz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pz-actions button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
}

.pz-actions button:hover:not(:disabled) {
  background: var(--sunken);
}

.pz-actions .pz-run {
  padding-inline: 20px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pz-actions .pz-run:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.08);
}

.pz-actions button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.pz-view {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.pz-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  aspect-ratio: var(--cols, 5) / var(--rows, 5);
  max-height: 420px;
  border: 6px solid #44403c;
  border-radius: 12px;
  overflow: hidden;
  background: var(--sq-a);
  transition: box-shadow 200ms;
}

.pz-board.solved {
  box-shadow: 0 0 0 4px var(--good);
}

.pz-board .sq {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: var(--sq-a);
  cursor: pointer;
  container-type: size;
}

.pz-board .sq.odd {
  background: var(--sq-b);
}

.pz-board .sq:hover {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  z-index: 1;
}

.pz-board .sq.wall {
  background: var(--wall);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2);
}

.pz-board .sq.ok {
  background: #cfe9c8;
}

.pz-board .sq.extra::after {
  content: '';
  position: absolute;
  inset: 8%;
  border: 2px dashed #dc2626;
  border-radius: 8px;
}

.pz-board .it,
.pz-board .ghost {
  font-size: 62cqmin;
  line-height: 1;
}

.pz-board .ghost {
  opacity: 0.32;
  filter: grayscale(0.4);
}

.pz-board .sq:has(.ghost)::before {
  content: '';
  position: absolute;
  inset: 10%;
  border: 2px dashed rgb(0 0 0 / 0.25);
  border-radius: 10px;
}

.pz-board .badge {
  position: absolute;
  top: 4%;
  right: 4%;
  display: grid;
  place-items: center;
  width: 38cqmin;
  height: 38cqmin;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  font-size: 24cqmin;
}

.pz-board .changed .it {
  animation: pop 260ms ease-out;
}

@keyframes pop {
  from {
    transform: scale(0.5);
    opacity: 0.3;
  }
}

.pz-status {
  min-height: 1.6em;
  margin: 0;
  color: var(--muted);
  font: 12.5px/1.6 var(--mono);
  overflow-wrap: anywhere;
}

.pz-result {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14.5px;
}

.pz-result.good {
  border-color: var(--good);
  background: var(--good-soft);
}

.pz-result.bad {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.pz-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.pz-next {
  margin-left: 6px;
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--good);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* Games */

.group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 28px 0 12px;
  font-size: 16px;
}

.group span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}

.card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 4px;
  padding: 10px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.shot {
  position: relative;
  display: block;
  aspect-ratio: 6 / 5;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--sunken);
  overflow: hidden;
}

/* The whole GIF, never cropped. */
.shot img {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}

.card h4 {
  margin: 0 4px;
  font-size: 16px;
}

.card p {
  margin: 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.card-links {
  display: flex;
  gap: 6px;
  margin: 10px 4px 0;
}

.card-links a {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
}

.card-links a:hover {
  background: var(--sunken);
}

.card-links .play {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.card-links .play:hover {
  background: var(--text);
  opacity: 0.85;
}

/* Using it */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

pre.code,
.prompt pre {
  margin: 0;
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 13.5px;
  line-height: 1.65;
  overflow-x: auto;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.facts.four {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.facts li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.facts strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

/* For agents */

.agent-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 16px;
}

.agent-file {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.agent-file h3 {
  margin: 0;
  font: 700 18px var(--mono);
}

.agent-file p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 6px 6px 12px;
  border-radius: 10px;
  background: var(--sunken);
}

.copy-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.prompt {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.prompt pre {
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sources {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

footer {
  margin-top: 72px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

/* Narrower screens */

@media (max-width: 1000px) {
  .pz {
    grid-template-columns: minmax(0, 1fr);
  }

  .pz-side {
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .pz-progress {
    margin: 0 0 8px;
  }

  .pz-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .pz-list button {
    width: auto;
    padding: 0;
  }

  .pz-list .t {
    display: none;
  }

  .pz-list .n {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .pz-list .active {
    background: none;
    box-shadow: none;
  }
}

@media (max-width: 820px) {
  .pz-play,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .pz-main {
    padding: 16px;
  }

  .pz-view {
    order: -1;
  }

  .pz-board {
    max-height: none;
  }
}

@media (max-width: 480px) {
  .hero {
    padding-top: 36px;
  }

  .lede {
    font-size: 16px;
  }

  .tabs span {
    display: none;
  }

  pre.code {
    padding: 14px;
    font-size: 12.5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .top nav a {
    padding: 6px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pz-board .changed .it {
    animation: none;
  }

  .teaser {
    transition: none;
  }
}

/* Packages */

.version {
  display: inline-block;
  margin-bottom: 16px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 600 12.5px var(--mono);
  text-decoration: none;
}

.version:hover {
  border-color: var(--accent);
  color: var(--text);
}

.installs {
  display: grid;
  gap: 8px;
  justify-items: start;
  margin-top: 24px;
}

.installs .install {
  margin-top: 0;
}

.installs p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.installs p a {
  text-decoration-color: var(--line);
}

.card h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.pkg {
  color: var(--muted);
  font: 500 12px var(--mono);
  text-decoration: none;
}

.pkg:hover {
  color: var(--accent);
}

.group code {
  font-size: 0.92em;
}

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 14px;
}

.pkg-card {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 10px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.pkg-card.all {
  border-style: dashed;
}

.pkg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
}

.pkg-card h3 {
  margin: 0;
  font: 700 16px var(--mono);
}

.pkg-card h3 a {
  text-decoration: none;
}

.pkg-card h3 a:hover {
  text-decoration: underline;
}

.pkg-for {
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

.pkg-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.pkg-links {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.uses {
  margin-top: 10px !important;
  font-size: 14px;
}

/* Tutorials: the teaser on the home page, and the page itself */

.top nav a[aria-current='page'] {
  background: var(--sunken);
  color: var(--text);
}

.teaser {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%);
  text-decoration: none;
  transition: border-color 150ms, transform 150ms;
}

.teaser:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.teaser-board {
  display: grid;
  grid-template-columns: repeat(4, 44px);
  grid-template-rows: repeat(4, 44px);
  border: 5px solid #44403c;
  border-radius: 10px;
  overflow: hidden;
}

.teaser-board span {
  display: grid;
  place-items: center;
  background: var(--sq-a);
  font-size: 26px;
  line-height: 1;
}

/* A checkerboard: rows alternate which squares are dark. */
.teaser-board span:nth-child(8n + 2),
.teaser-board span:nth-child(8n + 4),
.teaser-board span:nth-child(8n + 5),
.teaser-board span:nth-child(8n + 7) {
  background: var(--sq-b);
}

.teaser-board .t-ghost {
  opacity: 0.35;
}

.teaser-board span.t-wall {
  background: var(--wall);
}

.teaser-board span.t-path {
  background: #bfdbfe;
}

.teaser-kicker,
.crumbs {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crumbs a {
  text-decoration: none;
}

.crumbs a:hover {
  text-decoration: underline;
}

.teaser-text h2 {
  margin: 4px 0 8px;
}

.teaser-text p:not(.teaser-kicker) {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
}

.teaser-cta {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.tutorial {
  padding-top: 40px;
}

.tutorial h1 {
  margin: 4px 0 6px;
  font-size: clamp(28px, 4vw, 40px);
}

.next p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

@media (max-width: 640px) {
  .teaser {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
  }

  .teaser-board {
    grid-template-columns: repeat(4, 36px);
    grid-template-rows: repeat(4, 36px);
  }

  .teaser-board span {
    font-size: 21px;
  }
}
