#game-screen[hidden],
#gallery-screen[hidden] {
  display: none !important;
}

.play-shell,
.play-dialog {
  --play-ink: #f4f0e4;
  --play-muted: #b4b7a6;
  --play-amber: #dfad6c;
  --play-surface: #20261e;
  --play-rule: #454b3e;
  color: var(--play-ink);
  font-family: system-ui, sans-serif;
}
/* Play uses one viewport. The board and the complete picture share the same workspace. */
html[data-screen='game'] body {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
html[data-screen='game'] .masthead {
  flex: none;
}
html[data-screen='game'] .masthead-inner {
  min-height: clamp(49px, 7dvh, 70px);
}
html[data-screen='game'] .page-footer {
  flex: none;
}
html[data-screen='game'] .footer-inner {
  min-height: 36px;
  padding: 1px 0;
}
html[data-screen='game'][data-pad-active='true'] .page-footer {
  height: 0;
  min-height: 0;
  border: 0;
}
html[data-screen='game'][data-pad-active='true'] .page-footer .credits-link {
  display: none;
}
#game-screen:not([hidden]) {
  flex: 1;
  min-height: 0;
}
.play-shell {
  width: min(1420px, 94vw);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: clamp(5px, 1.2dvh, 15px) 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(6px, 1.6dvh, 20px);
}
.play-shell h1,
.play-shell h2,
.play-dialog h2 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 400;
  color: var(--play-ink);
}
.play-shell button,
.play-dialog button {
  font: inherit;
  color: var(--play-ink);
  cursor: pointer;
}
.play-shell button:focus-visible,
.play-dialog button:focus-visible {
  outline: 3px solid var(--play-amber);
  outline-offset: 3px;
}
.play-shell button:disabled {
  opacity: 0.4;
  cursor: default;
}
.play-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(10px, 1.8vw, 28px);
  padding: 3px 0;
  min-width: 0;
}
.play-back {
  border: 1px solid var(--play-rule);
  border-radius: 4px;
  background: var(--play-surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 39px;
  padding: 5px 10px;
  font-size: 0.86rem !important;
}
.play-back:hover {
  background: #30392b;
}
.play-identity {
  min-width: 0;
}
.play-collection {
  margin: 0 0 2px;
  color: var(--play-amber);
  font-size: 0.65rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}
.play-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: clamp(1.5rem, 2.8vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0;
}
.play-stats {
  display: flex;
  align-items: center;
  gap: clamp(9px, 1.5vw, 23px);
  font-variant-numeric: tabular-nums;
}
.play-stats > div {
  display: grid;
  gap: 1px;
  white-space: nowrap;
}
.play-stats > div + div {
  border-left: 1px solid var(--play-rule);
  padding-left: clamp(9px, 1.5vw, 23px);
}
.play-stats label,
.play-stats span {
  color: var(--play-muted);
  font-size: 0.72rem;
}
#play-grid-size {
  min-height: 32px;
  max-width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 0 .12em;
  color: var(--play-ink);
  background: var(--play-surface);
  border: 1px solid var(--play-rule);
  border-radius: 4px;
}
.play-stats strong {
  font-size: clamp(1rem, 1.55vw, 1.45rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 580;
}
.play-layout {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(235px, 0.9fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: 'board reference' 'board tools';
  gap: clamp(7px, 1.3vw, 20px);
}
.play-stage,
.play-reference,
.play-sidebar {
  border: 1px solid var(--play-rule);
  border-radius: 5px;
  min-width: 0;
  min-height: 0;
}
.play-stage {
  grid-area: board;
  container-type: size;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(5px, 1.45vw, 21px);
  background: #10150f;
}
.play-frame {
  flex: none;
  width: min(100cqw, calc(100cqh * var(--art-ratio, 1)));
  line-height: 0;
  box-shadow:
    0 0 0 1px #aeb19a70,
    0 5px 16px #0006;
  background: #14170e;
}
.play-reference {
  grid-area: reference;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #252b21;
  padding: clamp(6px, 1.05vw, 16px);
  gap: 6px;
}
.play-reference figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  color: var(--play-ink);
  font: 400 clamp(1.05rem, 1.5vw, 1.45rem) / 1.12 var(--serif, Georgia, serif);
  letter-spacing: -0.02em;
}
.play-reference figcaption button {
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #606950;
  background: #30382b;
  border-radius: 4px;
  width: 34px;
  height: 32px;
  padding: 0;
  color: var(--play-amber);
}
.play-reference figcaption button:hover {
  background: #454e3c;
}
.play-reference-mat {
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #161b15;
  border-radius: 2px;
}
#play-reference-art {
  display: block;
  width: min(100cqw, calc(100cqh * var(--art-ratio, 1)));
  height: auto;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}
#board {
  aspect-ratio: var(--art-ratio, 1);
  width: 100%;
  position: relative;
  display: grid;
  grid-template: repeat(var(--dimension), minmax(0, 1fr)) / 100%;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.play-row {
  display: grid;
  grid-template-columns: repeat(var(--dimension), minmax(0, 1fr));
  min-height: 0;
}
.play-cell {
  min-width: 0;
  min-height: 0;
}
#board .play-piece {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: block;
  padding: 0;
  margin: 0;
  border-radius: 0;
  border: 0;
  background-color: transparent;
  background-image: var(--art-image);
  background-size: calc(var(--dimension) * 100%) calc(var(--dimension) * 100%);
  background-repeat: no-repeat;
  box-shadow: inset -1px -1px 0 #100f0b75;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: none;
}
#board[data-solved='true'] .play-piece {
  box-shadow: none;
  cursor: default;
}
#board .play-piece[data-selected='true'] {
  z-index: 1;
}
#board .play-piece[data-selected='true']::after {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 2px;
  border: 2px solid #f1cf96;
  box-shadow:
    0 0 0 1px #281c0d,
    inset 0 0 0 1px #281c0d;
}
#board[data-solved='true'] .play-piece:not(:focus-visible)::after {
  display: none;
}
#board[data-armed='true'] .play-piece[data-selected='true']::after {
  inset: 3px;
  border: 3px dashed #fff3c3;
  box-shadow:
    0 0 0 2px #50360f,
    inset 0 0 0 2px #50360f;
}
#board .play-piece:focus-visible {
  z-index: 2;
  outline-offset: -4px;
  outline: 2px solid white;
}
.play-sidebar {
  grid-area: tools;
  background: var(--play-surface);
  padding: clamp(10px, 1.4vw, 20px);
}
.play-shifts h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.55vw, 1.45rem);
  line-height: 1.1;
}
#board-instruction,
#play-position,
#save-note {
  font-size: 0.82rem;
  line-height: 1.35;
}
#board-instruction {
  margin: 5px 0;
  color: var(--play-muted);
}
#play-position {
  color: var(--play-amber);
  font-weight: 550;
  margin: 8px 0 5px;
}
.play-dpad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.play-dpad button,
.play-tools button,
.play-dialog-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  background: #282e24;
  border: 1px solid #555c4d;
  border-radius: 4px;
  padding: 5px 9px;
  font-size: 0.87rem;
}
.play-dpad button:hover:not(:disabled),
.play-tools button:hover,
.play-dialog-actions button:hover {
  background: #343d2f;
  border-color: #939b81;
}
.play-tools {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}
.play-tools button {
  flex: 1;
  min-width: 0;
}
.play-tools:has([data-action='solve']:not([hidden])) {
  flex-wrap: wrap;
}
.play-tools:has([data-action='solve']:not([hidden])) button {
  flex: 1 1 5.3em;
}
.play-tools svg {
  flex: none;
  color: var(--play-amber);
}
#save-note {
  margin: 8px 0 0;
  font-size: 0.73rem;
  color: var(--play-muted);
}
.play-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}
dialog.play-dialog {
  padding: 0;
  color: var(--play-ink);
  background: #20261e;
  border: 1px solid #686e5e;
  border-radius: 6px;
  width: min(530px, calc(100% - 28px));
  max-height: calc(100svh - 30px);
  overflow: auto;
  box-shadow: 0 24px 100px #0007;
}
dialog.play-dialog:not([open]) {
  display: none;
}
dialog.play-dialog::backdrop {
  background: #0c100cd9;
}
.play-dialog-body {
  padding: clamp(19px, 3.5vw, 34px);
}
.play-dialog-body h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}
.play-dialog-body p,
.play-help-list {
  color: var(--play-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}
.play-dialog-body p {
  margin: 0 0 10px;
}
.play-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
.play-dialog-actions button.play-primary {
  color: #2d1c0e;
  font-weight: 650;
  background: var(--play-amber);
  border-color: var(--play-amber);
}
.play-dialog-actions button.play-primary:hover {
  background: #f3c28b;
  border-color: #f3c28b;
}
.play-help-list {
  margin: 16px 0 0;
}
.play-help-list dt {
  color: var(--play-ink);
  font-weight: 660;
  margin-top: 10px;
}
.play-help-list dd {
  margin: 0;
}
dialog.play-dialog[data-kind='reference'] {
  width: fit-content;
  max-width: calc(100vw - 28px);
}
.play-reference-image {
  display: block;
  object-fit: contain;
  margin: 14px auto 8px;
  max-width: 100%;
  max-height: 62svh;
  width: auto;
  height: auto;
}
.play-dialog-caption {
  color: var(--play-ink) !important;
}
@media (max-width: 900px), (max-height: 630px) {
  html[data-screen='game'] .masthead {
    display: none;
  }
  html[data-screen='game'] .page-footer {
    height: 0;
    min-height: 0;
    border: 0;
  }
  html[data-screen='game'] .footer-inner {
    height: 0;
    min-height: 0;
    padding: 0;
  }
  html[data-screen='game'] .page-footer .credits-link,
  html[data-screen='game']:not([data-pad-active='true']) .page-footer {
    display: none;
  }
  .play-shell {
    width: calc(100% - 20px);
  }
}
@media (max-height: 650px) and (orientation: landscape) {
  .play-shell {
    gap: 5px;
    padding: 4px 0 6px;
  }
  .play-heading {
    gap: 8px;
    padding: 0;
  }
  .play-title {
    font-size: clamp(1.1rem, 2.4vw, 1.65rem);
    -webkit-line-clamp: 1;
  }
  .play-collection {
    display: none;
  }
  .play-back {
    min-height: 33px;
  }
  .play-stats {
    gap: 8px;
  }
  .play-stats > div {
    display: flex;
    align-items: baseline;
    gap: 4px;
  }
  .play-stats > div + div {
    padding-left: 8px;
  }
  .play-stats label,
  .play-stats span {
    font-size: 0.62rem;
  }
  .play-stats strong {
    font-size: 0.9rem;
  }
  .play-layout {
    grid-template-columns: minmax(0, 1.62fr) minmax(170px, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 5px;
  }
  .play-stage,
  .play-reference {
    padding: 5px;
  }
  .play-reference {
    gap: 3px;
  }
  .play-reference figcaption {
    font-size: 1rem;
  }
  .play-reference figcaption button {
    width: 29px;
    height: 25px;
  }
  .play-reference figcaption .icon {
    transform: scale(0.78);
  }
  .play-sidebar {
    padding: 5px 6px;
  }
  .play-shifts h2,
  #board-instruction,
  #save-note:not([data-session-only='true']) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #play-position {
    margin: 0 0 3px;
    font-size: 0.72rem;
  }
  .play-dpad,
  .play-tools {
    gap: 4px;
  }
  .play-dpad button,
  .play-tools button {
    min-height: 29px;
    padding: 2px 4px;
    font-size: 0.72rem;
  }
  .play-dpad svg,
  .play-tools svg {
    width: 15px;
    height: 15px;
  }
  .play-tools {
    margin-top: 4px;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  .play-shell {
    width: calc(100% - 16px);
    padding: 6px 0 8px;
    gap: 6px;
  }
  .play-heading {
    gap: 7px;
    padding: 0;
  }
  .play-back {
    padding: 3px;
    width: 31px;
    min-height: 34px;
    justify-content: center;
  }
  .play-back span,
  .play-collection {
    display: none;
  }
  .play-title {
    font-size: clamp(1rem, 4.8vw, 1.5rem);
  }
  .play-stats {
    gap: 6px;
  }
  .play-stats > div + div {
    padding-left: 6px;
  }
  .play-stats label,
  .play-stats span {
    font-size: 0.58rem;
  }
  .play-stats strong {
    font-size: 0.83rem;
  }
  .play-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) clamp(130px, 25dvh, 225px);
    grid-template-areas: 'board board' 'reference tools';
    gap: 6px;
  }
  .play-layout[data-shape='portrait'] {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: 'board reference' 'tools tools';
  }
  .play-stage,
  .play-reference {
    padding: 5px;
  }
  .play-reference {
    gap: 3px;
  }
  .play-reference figcaption {
    font-size: 0.92rem;
  }
  .play-reference figcaption button {
    width: 25px;
    height: 26px;
  }
  .play-reference figcaption .icon {
    transform: scale(0.75);
  }
  .play-sidebar {
    padding: 7px;
    align-content: center;
  }
  .play-shifts h2 {
    font-size: 1rem;
  }
  #board-instruction,
  #save-note:not([data-session-only='true']) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #play-position {
    font-size: 0.64rem;
    margin: 4px 0;
  }
  .play-dpad {
    gap: 3px;
  }
  .play-dpad button,
  .play-tools button {
    min-height: 32px;
    padding: 3px;
    font-size: 0.67rem;
  }
  .play-tools {
    gap: 3px;
    margin-top: 5px;
  }
  .play-tools button {
    gap: 3px;
    line-height: 1.1;
  }
  .play-tools svg {
    width: 13px;
    height: 13px;
  }
  .play-dpad svg {
    width: 16px;
    height: 16px;
  }
  .play-layout[data-shape='portrait'] .play-sidebar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
  }
  .play-layout[data-shape='portrait'] .play-sidebar .play-shifts,
  .play-layout[data-shape='portrait'] .play-sidebar .play-tools {
    flex: 1;
  }
  .play-layout[data-shape='portrait'] .play-tools {
    margin: 0;
  }
}
@media (forced-colors: active) {
  #board .play-piece {
    forced-color-adjust: none;
  }
  #board .play-piece[data-selected='true']::after {
    border-color: Highlight;
  }
}

.score-picture {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template: repeat(var(--score-size), minmax(0, 1fr)) / repeat(
      var(--score-size),
      minmax(0, 1fr)
    );
  width: 100%;
  min-width: 0;
  background: #10150f;
  max-width: 100%;
}
.score-picture span {
  display: block;
  min-width: 0;
  min-height: 0;
  background-repeat: no-repeat;
  background-size: calc(var(--score-size) * 100%) calc(var(--score-size) * 100%);
}
dialog.score-replay {
  width: min(620px, calc(100% - 24px));
}
.score-replay [data-picture] {
  width: min(100%, calc(53dvh * var(--replay-ratio, 1)));
  height: auto;
  margin: 12px auto;
}
.score-replay [data-timer],
#race-clock {
  font-variant-numeric: tabular-nums;
}
dialog.play-dialog[data-kind='solution'] {
  width: min(680px, calc(100% - 24px));
}
[data-solution-board] {
  position: relative;
  overflow: hidden;
  width: min(100%, calc(54dvh * var(--replay-ratio, 1)));
  margin: 14px auto;
}
[data-solution-board]:not([data-solved='true']) span {
  box-shadow: inset -1px -1px #191b1770;
}
[data-solution-progress] {
  font-variant-numeric: tabular-nums;
}
[data-kind='solution'] .play-dialog-actions {
  margin-top: 12px;
}
[data-kind='solution'] .play-dialog-actions button {
  min-height: 44px;
}
.play-layout.has-race {
  grid-template-areas: 'board reference' 'board opponent' 'board tools';
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
}
[data-race] {
  grid-area: opponent;
  display: grid;
  grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
  justify-items: center;
  gap: 3px;
  overflow: hidden;
  min-height: 0;
  margin: 0;
  padding: 5px;
  border: 1px solid var(--play-rule);
  background: var(--play-surface);
  border-radius: 5px;
}
[data-race] h2,
[data-race] p {
  font:
    500 0.82rem/1.2 system-ui,
    sans-serif;
  margin: 0;
  text-align: center;
}
[data-race-picture] {
  height: 100%;
  width: auto;
  max-width: 100%;
}
.score-action {
  padding: 9px 13px;
  border-radius: 4px;
  border: 1px solid var(--play-rule);
  background: #30382b;
}
@media (max-width: 600px) and (orientation: portrait) {
  .play-layout.has-race,
  .play-layout.has-race[data-shape='portrait'] {
    grid-template-areas: 'board board' 'reference opponent' 'tools tools';
    grid-template-rows: minmax(0, 1fr) minmax(85px, 18dvh) auto;
  }
  .has-race .play-sidebar {
    display: flex;
    gap: 7px;
    align-items: center;
  }
  .has-race .play-sidebar .play-shifts,
  .has-race .play-sidebar .play-tools {
    flex: 1;
  }
}
.play-clock-button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: inherit;
}
#board[data-hints='true'] .play-piece[data-misplaced='true']:not([data-selected='true'])::before {
  content: '';
  position: absolute;
  inset: 1px;
  border: 2px dashed #ff7569;
  box-shadow: 0 0 0 1px #231614;
  pointer-events: none;
}
.play-tools [data-action='hints'][aria-pressed='true'] {
  border-color: #e8b77f;
  background: #3a3325;
}

.board-shift-motion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}
/* Give the last shift its full visible travel. The result and score commit on the player's move. */
body:has(#board[data-motion='active']) #game-dialog[data-kind='complete'],
body:has(#board[data-motion='active']) #game-dialog[data-kind='complete']::backdrop {
  opacity: 0;
  pointer-events: none;
}
#board[data-motion='active'] .play-piece[data-selected='true'] {
  z-index: 4;
  background-image: none;
  box-shadow: none;
}
.shift-motion-setting {
  display: flex;
  gap: .55em;
  align-items: center;
  justify-content: space-between;
  width: fit-content;
  max-width: 100%;
  margin: .45em 0;
  font: 500 .82rem/1.4 system-ui, sans-serif;
}
.shift-motion-setting select {
  appearance: auto;
  border: 1px solid #697263;
  border-radius: 4px;
  background: #282e24;
  color: #f5f1e8;
  min-height: 32px;
  max-width: 100%;
  padding: 2px 4px;
  font: inherit;
}
.shift-motion-setting :focus-visible {
  outline: 2px solid #f5c779;
  outline-offset: 2px;
}
.play-preferences {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: .45rem;
}
.play-preferences .shift-motion-setting { margin: 0; flex-wrap: wrap; gap: .25em; }
.play-preferences .board-arrows-setting {
  margin: 0;
  padding: 3px 8px;
  min-height: 32px;
  color: var(--play-ink);
  border: 1px solid #697263;
  border-radius: 4px;
  background: #282e24;
  font: 500 .82rem/1.2 system-ui, sans-serif;
}
@media (max-width: 600px) and (orientation: portrait) {
  .play-layout:not(.has-race):not([data-shape='portrait']) {
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .play-layout[data-shape='portrait'] .play-sidebar,
  .play-layout.has-race .play-sidebar {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
    align-items: center;
    gap: 5px 9px;
  }
  .play-layout:is([data-shape='portrait'],.has-race) .play-preferences {
    grid-row: 2;
    grid-column: 1/-1;
    margin: 0;
  }
  .play-layout:is([data-shape='portrait'],.has-race) .play-tools {
    grid-row: 1;
    grid-column: 2;
  }
}
@media (max-width: 600px) and (max-height: 680px) and (orientation: portrait) {
  .play-layout:not(.has-race):not([data-shape='portrait']) {
    grid-template-columns: minmax(0, 2.8fr) minmax(60px, 1fr);
    grid-template-areas: 'board reference' 'tools tools';
  }
  .play-layout:not(.has-race):not([data-shape='portrait']) .play-reference figcaption {
    flex-direction: column;
    align-items: flex-start;
  }
  .play-layout:not(.has-race):not([data-shape='portrait']) .play-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    align-items: center;
    gap: 5px 9px;
  }
  .play-layout:not(.has-race):not([data-shape='portrait']) .play-preferences {
    grid-row: 2;
    grid-column: 1 / -1;
    margin: 0;
  }
  .play-layout:not(.has-race):not([data-shape='portrait']) .play-tools {
    grid-row: 1;
    grid-column: 2;
    margin: 0;
  }
}


/* Two contrasting edges remain visible on light and dark picture tiles. */
#board .play-piece[data-selected='true']::after {
  inset: 2px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #101010, inset 0 0 0 1px #101010;
}
/* The first tile in a two-tap move keeps its numbered marker even if focus moves. */
#board .play-piece[aria-pressed='true']::before {
  content: '1';
  position: absolute;
  z-index: 1;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: clamp(12px, 28%, 22px);
  height: clamp(12px, 28%, 22px);
  border: 1px solid #ffe371;
  border-radius: 0 0 3px 0;
  background: #171409;
  color: white;
  font: 800 clamp(10px, 2vmin, 14px)/1 system-ui, sans-serif;
  pointer-events: none;
}
#board[data-armed='true'] .play-piece[data-selected='true']::after {
  inset: 3px;
  border: 3px solid #ffe371;
  box-shadow: 0 0 0 2px #14120a, inset 0 0 0 2px #14120a;
}
@media (forced-colors: active) {
  #board .play-piece[data-selected='true']::after {
    border-color: Highlight;
    box-shadow: 0 0 0 2px Canvas, inset 0 0 0 1px Canvas;
  }
  #board .play-piece[aria-pressed='true']::before {
    background: Highlight;
    color: HighlightText;
    border-color: CanvasText;
  }
  #board[data-armed='true'] .play-piece[data-selected='true']::after {
    border-color: Highlight;
    outline: 1px solid CanvasText;
  }
}

/* Navigation and controller help stay in document flow around the game workspace. */
html[data-screen='game'] body {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
html[data-screen='game'] #game-screen:not([hidden]) {
  flex: none;
  height: 100dvh;
}
html[data-screen='game'] .page-footer,
html[data-screen='game'][data-pad-active='true'] .page-footer,
html[data-screen='game'] .footer-inner {
  height: auto;
  min-height: 0;
}

/* Fit the board and lower controls below the desktop navigation. */
@media (min-width: 901px) and (min-height: 631px) {
  html[data-screen='game'] body { height: 100dvh; }
  html[data-screen='game'] #game-screen:not([hidden]) { flex: 1; min-height: 420px; height: auto; }
}

/* Give tall wallpapers the full board row on narrow phones. */
@media (max-width: 600px) and (orientation: portrait) {
  .play-layout[data-shape='tall']:not(.has-race) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: 'board board' 'reference tools';
  }
}
@media (min-width: 601px) and (orientation: landscape) {
  .play-layout[data-shape='wide'] {
    grid-template-columns: minmax(0, 2.1fr) minmax(205px, .85fr);
  }
}
