.md-typeset .pt100-matrix-scroll {
  margin-block: 1em 1.5em;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.md-typeset .pt100-matrix {
  --pt100-board-length: 16rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  min-width: 33rem;
  padding: 0.35rem;
  border: 1px solid var(--md-typeset-table-color);
  border-radius: 0.25rem;
}

.md-typeset .pt100-matrix-side .md-typeset__scrollwrap,
.md-typeset .pt100-matrix-side .md-typeset__table {
  display: block;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.md-typeset .pt100-matrix-side table:not([class]) {
  display: table;
  width: 100%;
  min-width: 0;
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.25;
}

.md-typeset .pt100-matrix-side table:not([class]) :is(th, td) {
  padding: 0.25rem 0.19rem;
  text-align: center;
  vertical-align: middle;
}

.md-typeset .pt100-matrix-side table:not([class]) th {
  min-width: 0;
  background: var(--md-default-fg-color--lightest);
}

.md-typeset .pt100-matrix-side {
  /* Align the two groups of rows with the pad groups in the portrait render. */
  align-self: start;
  margin-top: 3.15rem;
}

.md-typeset .pt100-matrix-side table:not([class]) td {
  padding-block: 0.05rem;
  line-height: 1;
}

.md-typeset .pt100-matrix-side table:not([class]) tbody tr:nth-child(5) td {
  border-top: 0.44rem solid var(--md-default-bg-color);
}

.md-typeset .pt100-matrix-left td:last-child,
.md-typeset .pt100-matrix-right td:first-child {
  background: var(--md-default-fg-color--lightest);
  white-space: nowrap;
}

.md-typeset .pt100-matrix td:has(.pt100-used) {
  background: #e4f4e8;
  color: #16502d;
}

.md-typeset .pt100-matrix td:has(.pt100-closed) {
  background: #ffebd2;
  color: #713801;
}

.md-typeset .pt100-matrix .pt100-matrix-board {
  position: relative;
  /* Match the 539 × 1108 portrait bounds of the rotated source renders. */
  width: calc(var(--pt100-board-length) * 539 / 1108);
  height: calc(var(--pt100-board-length) + 0.65rem);
  margin: 0;
}

.md-typeset .pt100-matrix-board :is(p, img) {
  margin: 0;
}

.md-typeset .pt100-matrix-board img {
  position: absolute;
  inset: calc(var(--pt100-board-length) / 2) auto auto 50%;
  width: var(--pt100-board-length);
  max-width: none;
  translate: -50% -50%;
}

.md-typeset .pt100-matrix-top img {
  rotate: 90deg;
}

.md-typeset .pt100-matrix-bottom img {
  rotate: -90deg;
}

.md-typeset .pt100-matrix-board figcaption {
  position: absolute;
  inset: auto 0 0;
  margin: 0;
  font-size: 0.55rem;
  line-height: 1;
}
