:root {
  color-scheme: light;
  --page: #f9f5e9;
  --sheet: #fffcf3;
  --ink: #233a32;
  --muted: #58665a;
  --rule: #c5c5ad;
  --soft: #eaeada;
  --gold: #865421;
  --accent: #975522;
  --display: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --body: system-ui, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  background: var(--page);
  color: var(--ink);
  font: 100%/1.55 var(--body);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #182722;
  --sheet: #20322b;
  --ink: #f4efdb;
  --muted: #b9c6b6;
  --rule: #4e6052;
  --soft: #304238;
  --gold: #e2b77e;
  --accent: #f3c082;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none!important;
}

body,figure,h1,h2,h3,h4,p,ul {
  margin: 0;
}

body {
  border-top: 4px solid #344c40;
}

a {
  color: inherit;
  text-underline-offset: .22em;
}

button,input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button,a {
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.sr-only,.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  z-index: 5;
  top: 8px;
  left: 8px;
  background: var(--sheet);
  padding: 8px;
}

.container {
  width: min(1120px,calc(100% - 80px));
  margin-inline: auto;
}

.topbar-inner,.topbar nav,.wordmark,.board-caption,.section-label,.shelf-head,.footer,.actions,.join,.footer div {
  display: flex;
  align-items: center;
}

.topbar-inner,.board-caption,.shelf-head,.footer,.join {
  justify-content: space-between;
}

.topbar {
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  min-height: 60px;
}

.wordmark {
  font: 700 1.15rem var(--display);
  gap: 9px;
  text-decoration: none;
}

.topbar nav {
  gap: 22px;
}

.topbar nav a,.footer a,.actions a,.join a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.topbar nav a {
  font-size: .82rem;
  gap: 7px;
  text-decoration: none;
}

.topbar nav button {
  width: 44px;
  height: 44px;
  color: var(--ink);
  background: none;
  border: 0;
  font-size: 1.45rem;
}

.topbar nav button:hover {
  background: var(--soft);
  border-radius: 50%;
}

.intro {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  align-items: center;
  gap: 7%;
  padding: 24px 0 26px;
}

.label,.section-label,.board-caption,.card-meta,.study-count {
  font: 600 .69rem/1.4 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
}

.ornament {
  font-size: 1.45rem;
  line-height: 1;
}

.intro h1 {
  font: 500 clamp(4rem,7.5vw,7.1rem)/1.1 var(--display);
  letter-spacing: -.07em;
  margin: 8px 0 12px;
}

.intro h1 em {
  font-weight: 400;
}

.lede {
  color: var(--muted);
  max-width: 52ch;
  font-size: clamp(.98rem,1.4vw,1.14rem);
  line-height: 1.55;
}

.frontispiece {
  position: relative;
  justify-self: end;
  width: min(100%,285px);
  padding: 5px 5px 0;
  background: #f0e2c5;
  border: 1px solid #b8a788;
  transform: rotate(1.2deg);
  color: #4e503e;
  box-shadow: 2px 3px 0 #8c816134;
}

.frontispiece img {
  display: block;
  width: 100%;
  height: auto;
}

.frontispiece figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 5px 6px;
  font: italic .8rem var(--display);
}

.frontispiece figcaption span {
  font: 600 .62rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.section-label {
  gap: 14px;
  color: var(--muted);
  font-size: .67rem;
}

.section-label h2 {
  font: inherit;
}

.section-label span span,.section-label h2 span {
  color: var(--gold);
  margin: 0 6px;
}

.section-label i {
  height: 1px;
  flex: 1;
  background: var(--rule);
}

.section-label>span:last-child {
  color: var(--gold);
}

.study {
  display: grid;
  grid-template-columns: minmax(285px,.95fr) minmax(0,1fr);
  grid-template-areas: 'board details' 'board controls';
  grid-template-rows: auto auto;
  column-gap: clamp(32px,6vw,96px);
  align-items: end;
  padding: 30px clamp(0px,3vw,42px) 42px;
  scroll-margin: 16px;
}

.study-copy {
  grid-area: details;
}

.study-copy h3 {
  font: 500 clamp(2.5rem,4.7vw,4.2rem)/1.03 var(--display);
  letter-spacing: -.052em;
  margin: 14px 0 9px;
  text-wrap: balance;
}

.catalog-stamp {
  border: 1px solid var(--gold);
  padding: 3px 6px;
  border-radius: 2px;
}

.byline {
  overflow-wrap: anywhere;
  color: var(--muted);
  font: italic 1.04rem/1.4 var(--display);
}

.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.specs span {
  font: 600 .75rem var(--mono);
  background: var(--soft);
  padding: 5px 9px;
  border-radius: 2px;
}

.board-wrap {
  grid-area: board;
  align-self: center;
  width: 100%;
}

.board-frame {
  padding: clamp(6px,.8vw,12px);
  background: #304337;
  border: 1px solid #1c3028;
  outline: 1px solid #ae9c71;
  outline-offset: -4px;
  box-shadow: 0 6px 10px -8px #19231ae6;
}

.board {
  container-type: inline-size;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(8,minmax(0,1fr));
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.light {
  background: #ebe2c8;
}

.dark {
  background: #96a18a;
}

.piece {
  font-family: 'Apple Symbols','Segoe UI Symbol','DejaVu Sans',serif;
  line-height: 1;
  pointer-events: none;
}

.square .piece {
  font-size: 10cqw;
}

.piece.white {
  color: #fff8df;
  -webkit-text-stroke: 1.6px #29392f;
  paint-order: stroke fill;
  text-shadow: 0 2px 1px #29392f99;
}

.piece.black {
  color: #1b2a24;
}

.axis {
  position: absolute;
  font: 650 max(9px,2.1cqw)/1 var(--mono);
  color: #344439;
  pointer-events: none;
}

.axis.rank {
  top: 3px;
  left: 3px;
}

.axis.file {
  bottom: 3px;
  right: 3px;
}

.square:hover {
  box-shadow: inset 0 0 0 2px #394c3f;
}

.square.selected {
  background: #e8c272;
  box-shadow: inset 0 0 0 3px #75501d;
}

.square.played {
  background: #dcc381;
}

.square.target::after {
  content: '';
  position: absolute;
  width: 21%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #344937b3;
}

.square.target:has(.piece)::after {
  width: 82%;
  background: none;
  border: 3px solid #344937;
}

.square:focus-visible {
  z-index: 1;
  outline: 3px solid #74330c;
  outline-offset: -4px;
}

.board-caption {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .61rem;
}

.board-caption b {
  color: var(--ink);
  font-size: .82rem;
}

.instructions {
  grid-area: controls;
  align-self: start;
  border-top: 1px solid var(--rule);
  padding-top: 17px;
}

.instructions h4 {
  font: 600 1.36rem var(--display);
}

#board-help {
  color: var(--muted);
  font-size: .9rem;
  max-width: 46ch;
  margin: 5px 0 14px;
}

.response {
  background: var(--soft);
  border-left: 3px solid var(--gold);
  padding: 10px 13px;
  font-size: .87rem;
}

#feedback[data-tone=success] {
  font-weight: 700;
}

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

.promotion {
  margin: 8px 0;
}

.actions {
  margin-top: 9px;
}

.actions button,.outline-button {
  min-height: 44px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 12px;
  font-size: .8rem;
  font-weight: 600;
}

.actions button:hover,.outline-button:hover {
  border-color: var(--ink);
}

.actions a {
  margin-left: auto;
  color: var(--muted);
  font-size: .78rem;
  gap: 4px;
}

#share-url {
  width: 100%;
  margin: 8px 0;
  padding: 7px;
  background: var(--sheet);
  border: 1px solid var(--rule);
}

.load-status {
  border: 1px dashed var(--rule);
  padding: 24px;
  margin: 20px 0;
  background: var(--sheet);
  color: var(--muted);
}

.load-status strong {
  display: block;
  font: 600 1.35rem var(--display);
  color: var(--ink);
}

.load-status[data-state=preview] {
  margin: 12px 0 0;
  padding: 7px 12px;
  font-size: .8rem;
}

.cabinet {
  scroll-margin: 18px;
}

.shelf-head {
  align-items: baseline;
  margin: 16px 0;
}

.shelf-head h2,.join h2 {
  font: 500 clamp(1.7rem,3vw,2.65rem)/1.12 var(--display);
  letter-spacing: -.04em;
}

.shelf-head p {
  font: .77rem var(--mono);
  color: var(--muted);
}

.study-list {
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,290px),1fr));
  gap: 14px;
}

.study-link {
  height: 100%;
  display: grid;
  align-items: center;
  grid-template-columns: 70px 1fr auto;
  gap: 14px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--rule);
  padding: 17px 15px;
  text-decoration: none;
}

.study-link[aria-current=true] {
  border-top-color: var(--gold);
  background: var(--soft);
}

.study-link:hover {
  border-color: var(--gold);
}

.thumbnail {
  display: block;
  width: 80px;
  height: auto;
  max-width: 100%;
}

.card-details {
  display: grid;
  gap: 3px;
}

.card-meta {
  color: var(--gold);
  font-size: .64rem;
}

.card-title {
  font: 600 1.2rem/1.15 var(--display);
}

.card-author,.card-numbers {
  font-size: .74rem;
  color: var(--muted);
}

.card-arrow {
  color: var(--gold);
  align-self: start;
}

.join {
  gap: 22px;
  border: 1px solid var(--rule);
  background: var(--soft);
  padding: 25px 30px;
  margin: 34px 0;
}

.join h2 {
  font-size: 1.8rem;
  margin: 7px 0;
}

.join p:not(.label) {
  font-size: .88rem;
  color: var(--muted);
  max-width: 58ch;
}

.join a {
  gap: 6px;
  font-size: .88rem;
  font-weight: 650;
}

.footer {
  border-top: 1px solid var(--rule);
  padding: 12px 0 20px;
  gap: 0 20px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .75rem;
}

.footer div {
  gap: 16px;
  flex-wrap: wrap;
}

.footer b {
  color: var(--gold);
  margin: 0 6px;
}

@media(max-width:740px) {
  .container {
    width: calc(100% - 32px);
  }
  .topbar-inner {
    min-height: 51px;
  }
  .topbar nav {
    gap: 6px;
  }
  .intro {
    position: relative;
    display: block;
    padding: 22px 0;
  }
  .intro-copy {
    position: relative;
  }
  .intro .label {
    font-size: .59rem;
    letter-spacing: .07em;
  }
  .ornament {
    font-size: 1rem;
  }
  .intro h1 {
    font-size: clamp(2.85rem,10vw,4.4rem);
    margin: 7px 0 11px;
  }
  .frontispiece {
    position: absolute;
    right: 1px;
    top: 19px;
    width: clamp(76px,23vw,158px);
    padding: 2px;
  }
  .frontispiece figcaption {
    display: none;
  }
  .lede {
    font-size: .92rem;
    max-width: 55ch;
  }
  .study {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: 'details' 'board' 'controls';
    gap: 14px;
    padding: 17px 0 26px;
  }
  .study-copy h3 {
    font-size: 2.1rem;
    margin: 6px 0 3px;
  }
  .study-copy .label {
    font-size: .6rem;
  }
  .specs {
    margin: 7px 0 0;
  }
  .specs span {
    font-size: .68rem;
    padding: 3px 7px;
  }
  .board-wrap {
    max-width: 460px;
    justify-self: center;
  }
  .byline {
    font-size: .93rem;
  }
  .instructions {
    padding-top: 0;
    border: 0;
  }
  .join {
    display: block;
    padding: 19px 20px;
  }
  .join a {
    margin-top: 8px;
  }
  .footer>span {
    width: 100%;
  }
  .footer {
    padding-top: 14px;
  }
  .section-label {
    font-size: .62rem;
  }
}

@media(pointer:coarse) {
  .keyboard-help {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
}

@media(prefers-reduced-motion:no-preference) {
  .study-link,button {
    transition: background-color .15s,border-color .15s;
  }
  .study-link:hover .card-arrow {
    transform: translate(1px,-1px);
  }
}

@media(forced-colors:active) {
  .square {
    border: 1px solid CanvasText;
  }
  .square.selected,.square:focus-visible {
    outline: 3px solid Highlight;
    outline-offset: -4px;
  }
  .square.target::after {
    background: Highlight;
  }
  .piece.white {
    -webkit-text-stroke: 1px CanvasText;
    color: Canvas;
    forced-color-adjust: none;
  }
  .piece.black {
    color: CanvasText;
  }
  .study-link[aria-current=true] {
    outline: 2px solid Highlight;
  }
}

.analysis-panel {
  grid-column: 1 / -1;
  width: 100%;
  border-block: 1px solid var(--rule);
  padding: 18px 0;
  margin-top: 20px;
  font-size: .92rem;
}
.analysis-panel h4, .slot-card h3 { font: 600 1.35rem/1.25 var(--display); }
.material { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 9px 0; }
.material dt { color: var(--gold); font-weight: 650; }
.material dd { margin: 0; }
.analysis-panel details { margin-top: 8px; }
.analysis-panel summary, .slot-needs summary, .slot-tier > summary { cursor: pointer; padding-block: 7px; }
#reply-list { padding-inline-start: 1.3rem; font: .84rem/1.7 var(--mono); }
#reply-guide { margin: 6px 0; color: var(--muted); }
#workshop { margin-top: 40px; }
.slot-tier { border-top: 1px solid var(--rule); }
.slot-tier > summary { font: 600 1.2rem/1.5 var(--display); padding-block: 13px; }
.slot-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(290px,100%), 1fr)); gap: 15px; list-style: none; padding: 0 0 22px; }
.slot-card { padding: 18px; border: 1px solid var(--rule); background: var(--sheet); }
.slot-card-head { display: flex; gap: 16px; align-items: center; }
.slot-plate { width: 90px; height: auto; }
.slot-card h3 { margin: 5px 0; }
.slot-summary { margin: 12px 0; font-size: .91rem; }
.effort { font: 600 .8rem var(--mono); }
.effort-why,.slot-needs { font-size: .82rem; color: var(--muted); }
.slot-needs ul { padding-inline-start: 18px; }
.slot-add { display: inline-flex; align-items: center; min-height: 44px; color: var(--gold); font-size: .85rem; font-weight: 650; }
