.ink-page {
  --bg: #0a0a0a;
  --surface: #171717;
  --surface-hover: #242424;
  --fg: #f5f5f5;
  --body: #b5b5b5;
  --muted: #969696;
  --line: #333;
}

[data-theme="light"] .ink-page {
  --bg: #fff;
  --surface: #f5f5f5;
  --surface-hover: #e9e9e9;
  --fg: #111;
  --body: #555;
  --muted: #666;
  --line: #d4d4d4;
}

.ink-page :is(a, button):focus-visible {
  outline-color: var(--fg);
}

.ink-page ::selection {
  background: var(--fg);
  color: var(--bg);
}

.ink-page [hidden] {
  display: none;
}

.ink-shell {
  width: min(70rem, calc(100% - clamp(28px, 7vw, 112px)));
  margin-inline: auto;
}

.ink-type {
  font-family: "Plinki Ink", system-ui, sans-serif;
  font-synthesis: none;
}

.ink-mono {
  font: 12px/1.4 ui-monospace, "SF Mono", monospace;
}

.ink-topbar,
.ink-nav,
.ink-back,
.ink-intro,
.ink-section-head,
.ink-footer {
  display: flex;
  align-items: center;
}

.ink-topbar,
.ink-intro,
.ink-section-head,
.ink-footer {
  justify-content: space-between;
  gap: 16px 24px;
}

.ink-topbar {
  min-height: 80px;
  font-size: 14px;
}

.ink-nav {
  flex-wrap: wrap;
  gap: 4px 24px;
}

.ink-nav a,
.ink-back {
  min-height: 44px;
  align-content: center;
  color: var(--body);
}

.ink-nav a:hover,
.ink-back:hover {
  color: var(--fg);
}

.ink-back {
  gap: 6px;
}

.ink-poster {
  container-type: inline-size;
  display: grid;
  gap: clamp(22px, 2.5vw, 36px);
  padding-block: clamp(28px, 5vw, 72px);
}

.ink-poster .ink-mono {
  padding-inline: 4cqw;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: clamp(10px, 1.3cqw, 13px);
}

.ink-poster h1 {
  --ink-guide: color-mix(in srgb, currentColor 25%, transparent);
  --ink-baseline: color-mix(in srgb, currentColor 42%, transparent);
  font-size: 20.9cqw;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: normal;
  text-align: center;
  white-space: nowrap;
  /* Paint the font guides past the heading box without extending layout. */
  border-image: linear-gradient(
    transparent .18em,
    var(--ink-guide) 0 calc(.18em + 1px),
    transparent 0 .37em,
    var(--ink-guide) 0 calc(.37em + 1px),
    transparent 0 .92em,
    var(--ink-baseline) 0 calc(.92em + 1px),
    transparent 0 1.14em,
    var(--ink-guide) 0 calc(1.14em + 1px),
    transparent 0
  ) fill 0 / 0 / 0 100vw;
}

.ink-intro {
  flex-wrap: wrap;
  padding-block: clamp(20px, 4vw, 40px);
}

.ink-intro > p {
  max-width: 33em;
  color: var(--body);
  font-size: clamp(16px, 1.65vw, 21px);
  line-height: 1.55;
}

.ink-intro > p a,
.ink-game-story a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-underline-offset: .24em;
}

.ink-download-group {
  display: grid;
  justify-items: center;
  gap: 9px;
}

.ink-download-group .ink-mono,
.ink-footer p {
  color: var(--body);
}

.ink-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px 18px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 650;
}

.ink-download:hover {
  background: color-mix(in srgb, var(--fg) 85%, var(--bg));
}

.ink-section {
  margin-top: clamp(48px, 7vw, 100px);
}

.ink-section-head {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ink-page h2 {
  font-size: clamp(23px, 3.4vw, 35px);
  font-weight: 650;
  letter-spacing: -.035em;
  line-height: 1.25;
}

.ink-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ink-presets button,
.ink-page select {
  min-height: 44px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 14px;
}

.ink-presets button:hover {
  background: var(--surface-hover);
}

.ink-workbench {
  padding: clamp(14px, 3.5vw, 34px);
  border-radius: 12px;
  background: var(--surface);
}

.ink-text-label {
  display: block;
  margin: 0 6px 4px;
  color: var(--muted);
  font-size: 14px;
}

.ink-text {
  display: block;
  width: 100%;
  min-height: clamp(8rem, 3.7em, 17rem);
  max-height: 540px;
  field-sizing: content;
  resize: vertical;
  padding: 8px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  overflow-wrap: anywhere;
  font-size: var(--ink-size, clamp(38px, 6vw, 64px));
  font-weight: var(--ink-weight, 600);
  letter-spacing: var(--ink-spacing, 0);
  line-height: 1.14;
}

.ink-text:focus-visible,
.ink-workbench :is(select, input):focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.ink-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px clamp(18px, 4vw, 48px);
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.ink-control {
  display: grid;
  align-content: start;
  gap: 6px;
}

.ink-control-label {
  display: flex;
  justify-content: space-between;
  gap: 9px;
  font-variant-numeric: tabular-nums;
}

.ink-controls select {
  background: var(--bg);
}

.ink-controls input {
  width: 100%;
  height: 30px;
  margin: 0;
  accent-color: var(--fg);
}

.ink-weights {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ink-weights li {
  min-width: 0;
  padding: clamp(12px, 2vw, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ink-weights li > span {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 10px;
  color: var(--body);
  font-size: 13px;
}

.ink-weights strong {
  display: block;
  margin-top: 15px;
  font-size: clamp(29px, 6.5cqw, 70px);
  font-weight: var(--ink-weight);
  line-height: 1.13;
}

.ink-glyphs {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 12px;
}

.ink-glyph-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  border-radius: 12px;
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, var(--line) 39px 40px),
    var(--surface);
}

.ink-glyph-preview .ink-type {
  font-size: clamp(94px, 20vw, 220px);
  font-weight: 800;
  line-height: 1;
}

.ink-glyph-preview .ink-mono {
  position: absolute;
  right: 14px;
  bottom: 12px;
}

.ink-glyph-list {
  align-content: start;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(43px, 1fr));
  gap: 4px;
}

.ink-glyph-cell {
  position: relative;
  cursor: pointer;
}

.ink-glyph-cell span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 23px;
  line-height: 1;
}

.ink-glyph-cell input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.ink-glyph-cell:hover span {
  background: var(--surface);
}

.ink-glyph-cell input:checked + span {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.ink-glyph-cell input:focus-visible + span,
.ink-page select:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.ink-game-story {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  align-items: start;
  gap: clamp(18px, 4vw, 52px);
  color: var(--body);
}

.ink-game-story a {
  display: inline-block;
  margin-top: 12px;
}

.ink-game-story figure {
  margin: 0;
}

.ink-game-story img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  filter: grayscale(1);
}

.ink-game-story figcaption {
  margin-top: 8px;
  font-size: 13px;
}

.ink-footer {
  flex-wrap: wrap;
  margin-top: clamp(48px, 7vw, 100px);
  padding-block: 24px 44px;
  border-top: 1px solid var(--line);
}

.ink-footer p {
  margin-top: 7px;
}

.ink-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 700px) {
  .ink-topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    padding-block: 12px 8px;
    gap: 2px;
  }

  .ink-nav {
    grid-row: 2;
    grid-column: 1 / -1;
    column-gap: clamp(10px, 3.5vw, 24px);
    font-size: 13px;
  }

  .ink-glyphs,
  .ink-game-story {
    grid-template-columns: minmax(0, 1fr);
  }

  .ink-glyph-preview {
    position: sticky;
    top: 10px;
    z-index: 1;
    min-height: 150px;
  }
}

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

  .ink-controls input {
    height: 44px;
  }

  .ink-weights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ink-download-group {
    justify-items: start;
  }
}
