:root {
  --gb-shell: #c5c1bd;
  --gb-shell-dark: #4a4741;
  --gb-lcd-darkest: #0f380f;
  --gb-lcd-dark: #306230;
  --gb-lcd-light: #8bac0f;
  --gb-lcd-lightest: #9bbc0f;
  --gb-magenta: #9c2c60;
  --gb-paper: #fbfaf4;
  --gb-ink: #2f2f5f;
  --gb-shadow: #1c2a1c;
  --md-primary-fg-color: var(--gb-lcd-dark);
  --md-primary-fg-color--light: #4a7a42;
  --md-primary-fg-color--dark: var(--gb-lcd-darkest);
  --md-accent-fg-color: var(--gb-magenta);
  --md-default-bg-color: var(--gb-paper);
  --md-default-fg-color: var(--gb-ink);
  --md-typeset-a-color: #2a5d2a;
}

html {
  background: var(--gb-shell-dark);
}

body {
  background-color: var(--gb-shell);
  background-image:
    linear-gradient(45deg, rgb(255 255 255 / 5%) 25%, transparent 25%),
    linear-gradient(-45deg, rgb(0 0 0 / 4%) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgb(255 255 255 / 5%) 75%),
    linear-gradient(-45deg, transparent 75%, rgb(0 0 0 / 4%) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

/* The header is the DMG screen bezel: dark blue-grey with the magenta
   accent line, monospace lettering and the red battery LED. */
.md-header {
  background: var(--gb-ink);
  border-bottom: 3px solid #1c1c38;
  color: #d7d4cf;
  box-shadow: 0 3px 0 var(--gb-magenta);
}

/* the round red battery LED of the DMG, left of the title */
.md-header__topic:first-child::before {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.45em;
  border: 1px solid #1c1c38;
  border-radius: 50%;
  background: #d22;
  box-shadow: 0 0 4px rgb(255 64 64 / 80%);
  vertical-align: baseline;
  content: "";
}

.md-header__title,
.md-tabs__link,
.md-nav__title,
.md-typeset h1,
.md-typeset h2,
.md-typeset h3 {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.md-header__title {
  font-size: 0.95rem;
}

.md-header__button,
.md-header__topic,
.md-search__icon {
  color: #d7d4cf;
}

.md-search__form {
  background: #fff;
  border: 2px solid var(--gb-ink);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--gb-magenta);
}

.md-search__input::placeholder {
  color: #454545;
}

.md-search__input {
  font-size: 0.85rem;
}

.md-container {
  background: transparent;
}

.md-main__inner {
  gap: 1.2rem;
}

@media screen and (min-width: 76.25em) {
  .md-grid {
    width: min(96vw, 100rem);
    max-width: none;
  }
}

.md-content {
  min-width: 0;
}

.md-typeset {
  font-size: 0.86rem;
}

.md-content__inner {
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem 2rem;
  background: var(--gb-paper);
  border: 2px solid var(--gb-ink);
  box-shadow: 7px 7px 0 var(--gb-shadow);
}

/* The four shades of the original Game Boy LCD palette, darkest to
   lightest, as the top strip of every content card. */
.md-content__inner::before {
  display: block;
  height: 0.55rem;
  margin: -1.25rem -1.5rem 1.3rem;
  border-bottom: 2px solid var(--gb-ink);
  background:
    linear-gradient(
      to right,
      var(--gb-lcd-darkest) 0 25%,
      var(--gb-lcd-dark) 25% 50%,
      var(--gb-lcd-light) 50% 75%,
      var(--gb-lcd-lightest) 75% 100%
    );
  content: "";
}

/* The diagonal speaker grille of the DMG, bottom right of every page. */
.md-content__inner::after {
  display: block;
  width: 8.5rem;
  height: 0.9rem;
  margin: 2.2rem 0 0 auto;
  background: repeating-linear-gradient(
    -55deg,
    var(--gb-ink) 0 4px,
    transparent 4px 12px
  );
  content: "";
}

.md-typeset h1 {
  margin-bottom: 1.2rem;
  color: var(--gb-lcd-darkest);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
}

/* The page URL already identifies the H1, so its permalink only adds layout
   noise when a long title wraps. Section permalinks remain unchanged. */
.md-typeset h1 .headerlink {
  display: none;
}

.md-typeset h2 {
  margin-top: 2.2rem;
  padding: 0.32rem 0.5rem;
  background: var(--gb-lcd-darkest);
  color: var(--gb-lcd-lightest);
  border: 2px solid var(--gb-ink);
  box-shadow: 3px 3px 0 var(--gb-magenta);
}

.md-typeset h3 {
  color: var(--gb-lcd-darkest);
  border-bottom: 2px solid var(--gb-lcd-light);
}

.md-typeset a {
  font-weight: 600;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

.md-typeset a:hover,
.md-typeset a:focus-visible {
  color: var(--gb-magenta);
}

.md-typeset img {
  max-height: 70vh;
  border: 2px solid var(--gb-ink);
  box-shadow: 5px 5px 0 var(--gb-magenta);
}

.md-typeset table:not([class]) {
  border: 2px solid var(--gb-ink);
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: 4px 4px 0 rgb(0 0 0 / 18%);
  font-size: 0.78rem;
}

.md-typeset table:not([class]) th {
  background: var(--gb-lcd-dark);
  color: #fff;
  border-bottom-color: var(--gb-ink);
}

.md-typeset table:not([class]) tr:nth-child(even) td {
  background: #eef2e2;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  border-right: 1px solid #86917e;
  border-bottom: 1px solid #b3bcab;
}

/* Keyboard keys mimic the grey rubber buttons of the DMG hardware, with the
   burgundy of the A/B buttons as the pressed-in shadow. */
.md-typeset kbd {
  display: inline-block;
  min-width: 1.3em;
  padding: 0.04em 0.26em;
  border: 1px solid var(--gb-ink);
  border-radius: 0;
  background: #b9b5b0;
  box-shadow: 1px 1px 0 var(--gb-magenta);
  color: #1c1c38;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.md-typeset code {
  border: 1px solid rgb(0 0 0 / 16%);
  border-radius: 0;
  font-size: 0.92em;
}

.md-typeset pre > code {
  border: 0;
}

.highlight {
  border: 2px solid var(--gb-ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--gb-magenta);
}

.md-sidebar__scrollwrap {
  background: rgb(251 250 244 / 96%);
  border: 2px solid var(--gb-ink);
  box-shadow: 4px 4px 0 var(--gb-shadow);
}

.md-nav {
  padding: 0.25rem;
  font-size: 0.75rem;
}

.md-nav__link--active,
.md-nav__link:is(:focus, :hover) {
  color: #872050;
}

.md-nav__item .md-nav__link--active {
  border-left: 0.2rem solid var(--gb-magenta);
  padding-left: 0.35rem;
}

/* Quotes and admonition-like notes render as the green LCD screen itself:
   lightest-green glass, darkest-green pixels, dark bezel. */
.md-typeset blockquote {
  padding: 0.55rem 0.8rem;
  border: 2px solid var(--gb-ink);
  border-left: 0.5rem solid var(--gb-lcd-darkest);
  border-radius: 0;
  background: var(--gb-lcd-lightest);
  box-shadow: 3px 3px 0 var(--gb-shadow);
  color: var(--gb-lcd-darkest);
}

.md-typeset blockquote code {
  background: rgb(15 56 15 / 12%);
  color: var(--gb-lcd-darkest);
}

.md-footer {
  border-top: 3px solid var(--gb-ink);
  background: var(--gb-lcd-darkest);
}

/* Prev/next page links as the angled grey START / SELECT pills - the only
   rounded elements on the page, exactly like on the real hardware. */
.md-footer__link {
  align-items: center;
  margin: 0.8rem 0.4rem;
  padding: 0.15rem 0.9rem;
  border: 2px solid #1c1c38;
  border-radius: 999px;
  background: #b9b5b0;
  box-shadow: 2px 2px 0 #1c2a1c;
  color: #1c1c38;
  opacity: 1;
}

.md-footer__link:is(:focus, :hover) {
  background: #cac6c1;
  color: var(--gb-magenta);
  opacity: 1;
}

.md-footer__link .md-footer__title {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
}

.md-footer-meta {
  background: #0a280a;
}

@media screen and (max-width: 76.2344em) {
  .md-sidebar__scrollwrap {
    border: 0;
    box-shadow: none;
  }
}

@media screen and (max-width: 44.9844em) {
  .md-content {
    max-width: 100vw;
    overflow: hidden;
  }

  .md-content__inner {
    width: calc(100vw - 1.6rem);
    max-width: calc(100vw - 1.6rem);
    padding: 1rem 0.75rem 1.5rem;
    border-right: 0;
    border-left: 0;
    box-shadow: 0 6px 0 var(--gb-shadow);
  }

  .md-content__inner::before {
    margin: -1rem -0.75rem 1rem;
  }

  .md-typeset h2 {
    font-size: 1.05rem;
  }

  .md-typeset table:not([class]) {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body,
  .md-container {
    background: #fff;
  }

  .md-content__inner {
    border: 0;
    box-shadow: none;
  }
}
