.library-organizer {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .65rem 1rem;
  margin: .85rem 0 1rem;
}
.library-organizer label {
  display: grid;
  gap: .2rem;
  font-size: .9rem;
  font-weight: 600;
}
.library-organizer select, .library-organizer button {
  min-height: 44px;
  max-width: 100%;
  font: inherit;
}
.library-organizer select {
  background: white;
  color: #302f28;
  border: 1px solid #8c8a7e;
  border-radius: .5rem;
  padding: .45rem .55rem;
}
.library-progress, .library-order-note {
  margin: .25rem 0 .6rem;
  color: #56564b;
  font-size: .9rem;
}
.art-status {
  color: #405c48;
  font-weight: 650;
  font-size: .82rem;
}

/* Filmstrip-free viewing keeps the full artwork visible on short screens. */
body:has(#gallery-screen[data-pad-view='viewer']:not([hidden])) #quick-play { display: none; }
.art-card-pair { position: relative; min-width: 0; align-self: start; }
.art-card-pair .art-card { width: 100%; }
.card-play-label, .card-art-link { min-height: 44px; width: 48%; display: inline-flex; align-items: center; font: inherit; font-size: .84rem; line-height: 1.15; color: #e4c598; text-align: left; text-decoration: underline; text-underline-offset: .2em; }
.card-play-label { align-self: start; }
.card-art-link { position: absolute; right: 0; bottom: 0; justify-content: flex-end; text-align: right; }
.feature-action-row { flex-wrap: wrap; gap: .6rem 1rem; }
.full-view .viewer-head { display: flex; gap: .75rem; min-width: 0; flex: 0 0 auto; }
.viewer-identity { flex: 1; min-width: 0; }
.full-view .viewer-identity h1 { text-align: left; margin: 0; overflow-wrap: anywhere; }
.viewer-identity p { margin: .13rem 0 0; color: #bfbeaf; font-size: .82rem; }
.full-view .viewer-head .button-primary { min-height: 40px; flex-shrink: 0; }
.viewer-lens { flex: 1; min-height: 0; min-width: 0; display: flex; }
.artwork-lens { width: 100%; height: 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #10130f; }
.lens-toolbar, .viewer-footer, .viewer-footer nav, .viewer-footer > div { display: flex; align-items: center; flex-wrap: wrap; }
.lens-toolbar, .viewer-footer { padding: .35rem clamp(.5rem, 2vw, 1.5rem); gap: .3rem .5rem; }
.lens-toolbar { background: #1b201a; border-bottom: 1px solid #3b4237; justify-content: center; }
.lens-toolbar button, .viewer-footer button { border-radius: .3rem; min-height: 40px; padding: .3rem .72rem; font: inherit; font-size: .9rem; color: #efeee3; background: #282f26; border: 1px solid #535b4e; }
.lens-toolbar button[aria-pressed='true'], .viewer-footer button[aria-pressed='true'] { color: #1a2017; background: #d9dcbd; }
.lens-toolbar button:disabled, .viewer-footer button:disabled { opacity: .42; }
.lens-toolbar button[data-zoom='in'], .lens-toolbar button[data-zoom='out'] { min-width: 40px; font-size: 1.15rem; }
.lens-toolbar output { font-size: .84rem; min-width: 3.4em; text-align: center; color: #deded5; font-variant-numeric: tabular-nums; }
.lens-scroll { flex: 1; min-height: 0; min-width: 0; position: relative; overflow: auto; overscroll-behavior: contain; touch-action: none; }
.lens-scroll:focus-visible { outline-offset: -3px; }
.lens-scroll[data-pan='true'] { cursor: grab; }
.lens-scroll[data-pan='true'][data-dragging='true'] { cursor: grabbing; }
.lens-sheet { display: grid; place-items: center; min-width: 100%; min-height: 100%; width: max-content; height: max-content; }
.lens-sheet img { display: block; max-width: none; max-height: none; pointer-events: none; user-select: none; }
.viewer-footer { background: #1b201a; border-top: 1px solid #3b4237; justify-content: space-between; flex: 0 0 auto; }
.viewer-footer nav, .viewer-footer > div { gap: .45rem; }
.viewer-footer nav span { font-variant-numeric: tabular-nums; font-size: .86rem; color: #d6d7cc; }
#game-dialog[data-kind='reference'] { width: min(95vw, 100rem); max-width: 96vw; height: min(94dvh, 78rem); max-height: 96dvh; padding: 0; overflow: hidden; }
#game-dialog[data-kind='reference'] .play-dialog-body { height: 100%; max-height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: .45rem; padding: .65rem; }
#game-dialog[data-kind='reference'] .play-dialog-body h2 { margin: 0; font-size: clamp(1rem, 2.5vw, 1.5rem); }
#game-dialog[data-kind='reference'] .artwork-lens { flex: 1; height: auto; }
#game-dialog[data-kind='reference'] .play-dialog-actions { margin: 0; }
@media (max-width: 620px) {
  .full-view .viewer-head { flex-wrap: wrap; gap: .35rem; padding: .3rem .55rem; }
  .full-view .viewer-identity { flex: 1 1 calc(100% - 8rem); }
  .full-view .viewer-head .button-primary { min-height: 36px; }
  .viewer-footer { justify-content: center; }
  .viewer-footer nav { flex: 1 0 100%; justify-content: center; }
  .lens-toolbar button, .viewer-footer button { min-height: 38px; padding: .25rem .5rem; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .full-view .viewer-head, .viewer-footer, .lens-toolbar { padding-block: .1rem; }
  .viewer-identity p { display: none; }
  .viewer-footer nav { flex: initial; }
  .viewer-footer { justify-content: space-between; }
  .lens-toolbar button, .viewer-footer button, .full-view .viewer-head .button-primary { min-height: 30px; }
}

.feature-collection { color: #e5c59b; text-decoration: underline; text-underline-offset: .18em; font: inherit; }

/* Compact browsing controls keep the art in view. */
.gallery-shell .library-heading { align-items: end; }
.library-title { flex-wrap: wrap; min-width: 0; }
.library-title :is(h1,h2) { overflow-wrap: anywhere; line-height: 1.12; }
.library-title > span { align-self: end; margin-bottom: .16em; white-space: nowrap; }
.gallery-shell .filter-row { display: flex; flex-wrap: wrap; margin: .7rem 0; gap: .35rem; }
.filter-row .filter { min-height: 40px; }
.pack-select, .group-select { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; color: #e7e8dd; font: 600 .86rem/1.3 var(--sans); }
.pack-select { margin: .6rem 0 .25rem; }
.pack-select select, .group-select select, .browse-options select { min-width: 0; max-width: 100%; min-height: 44px; color: #eeeede; background: #252b23; border: 1px solid #707861; border-radius: 4px; font: 500 .92rem var(--sans); padding: .4rem 1.8rem .4rem .6rem; }
.browse-options { margin: .25rem 0; }
.browse-options summary, .gallery-jump summary, .quick-disclosure summary { display: list-item; width: fit-content; cursor: pointer; min-height: 38px; padding: .52rem .25rem; color: #d8d7c9; font: 550 .88rem/1.3 var(--sans); }
.browse-options[open] { border-left: 2px solid #5d6654; padding: 0 .75rem .5rem; }
.browse-options .library-organizer { margin: .55rem 0; }
.browse-options :is(.library-progress,.library-order-note) { color: #c1c4b4; }
.gallery-pages { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: .25rem .65rem; padding: .35rem 0; margin: .4rem 0 1rem; }
.gallery-pages .gallery-page-jumps { margin-top: 0; padding: .3rem .1rem; }
.gallery-jump[open] { flex-basis: 100%; }
.gallery-pages button:focus-visible, .gallery-shell summary:focus-visible, .quick-disclosure summary:focus-visible, .full-view button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.gallery-shell .art-status { color: #c4d5b9; }
.feature-meta { flex-wrap: wrap; }
.feature-info h1 { overflow-wrap: anywhere; }
html[data-screen='gallery'] #quick-play { width: var(--page); max-width: none; margin: .25rem auto .9rem; padding: 0; background: transparent; border: 0; }
#quick-play .quick-content { padding: .45rem .7rem .7rem; border: 1px solid var(--line); border-radius: 4px; }
body:has(#gallery-screen:not([hidden]):not([data-pad-view='gallery'])) #quick-play { display: none; }
.play-stats .board-arrows-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; padding: 9px; border: 0; border-radius: 50%; background: transparent; color: #afbaa6; }
.board-arrows-icon svg { width: 21px; height: 21px; }
.board-arrows-icon .board-arrows-slash { opacity: .55; }
.play-stats .board-arrows-icon[aria-pressed='true'] { color: #edc38c; }
.board-arrows-icon[aria-pressed='true'] .board-arrows-slash { opacity: 1; stroke-width: 2.4; }
.play-stats .board-arrows-icon:hover { background: #30372d; color: #eddbc1; }
.play-stats .board-arrows-icon:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
@media (max-width: 760px) {
 .gallery-shell .library-heading { align-items: start; gap: .5rem; }
 .pack-select { gap: .35rem; }
 .gallery-pages .gallery-page-buttons { gap: .25rem; }
 .gallery-pages .gallery-page-buttons > span { min-width: auto; padding-right: .45rem; }
}
@media (max-width: 620px) {
 html[data-screen='gallery'] .masthead-inner { display: grid; grid-template-columns: auto minmax(0,1fr); padding: .5rem 0 .1rem; gap: .3rem .65rem; min-height: 0; }
 html[data-screen='gallery'] .creator-credit { position: static; justify-self: end; text-align: right; display: grid; gap: 0; }
 html[data-screen='gallery'] .creator-credit span::after { content: ''; }
 html[data-screen='gallery'] .main-nav { grid-column: 1/-1; width: 100%; margin: 0; justify-content: space-between; }
 html[data-screen='gallery'] .main-nav button { min-height: 44px; padding: .25rem .3rem; }
 .gallery-shell .feature { height: auto; min-height: 0; }
 .gallery-shell .feature-info { padding: .9rem 0 .9rem .9rem; }
 .gallery-shell .feature h1 { line-height: 1.04; font-size: clamp(1.4rem,6vw,2.4rem); }
 .feature-action-row { gap: .2rem .4rem; }
 .gallery-shell .feature-action-row :is(.button-primary,.button-outline), .feature-pager button { min-height: 44px; font-size: .8rem; padding: .4rem .55rem; }
 .gallery-shell .feature-action-row :is(.button-primary,.button-outline) .icon { display: none; }
 .gallery-shell .feature-pager button { min-width: 38px; }
 .feature-collection { min-height: 32px; }
 .gallery-shell .library { margin-top: 1rem; }
 .gallery-shell .library-title { flex: 1 1 100%; gap: .2rem; }
 .gallery-shell .library-title > span { align-self: start; }
 .gallery-shell .filter-row .filter, .browse-options summary, .gallery-jump summary, .quick-disclosure summary { min-height: 44px; }
 .pack-select { display: grid; }
 .pack-select select { width: 100%; }
 .gallery-page-buttons button:nth-last-child(1), .gallery-page-buttons button:nth-child(2) { display: none; }
 .full-view .viewer-head { display: grid; grid-template-columns: auto 1fr auto; gap: .35rem; padding: .25rem .45rem; }
 .full-view .viewer-head .back-link, .full-view .viewer-head .button-primary { min-height: 44px; padding: .35rem .5rem; font-size: .8rem; }
 .viewer-identity h1 { font-size: 1rem; }
 .viewer-identity p { overflow-wrap: anywhere; font-size: .7rem; }
 .viewer-footer { padding: .24rem .36rem; gap: .18rem; }
 .viewer-footer nav { gap: .45rem; }
 .viewer-footer button, .lens-toolbar button { min-height: 44px; }
 .lens-toolbar button[data-zoom='in'], .lens-toolbar button[data-zoom='out'] { min-width: 44px; }
 .viewer-footer nav span { min-width: 4.6em; text-align: center; }
}
@media (max-width: 375px) {
 .main-nav .icon { display: none; }
 .full-view .viewer-head .button-primary .icon { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
 .viewer-lens .artwork-lens { position: relative; }
 .viewer-lens .lens-toolbar { width: fit-content; position: absolute; z-index: 1; right: .25rem; top: .25rem; background: #1b201aeb; border-radius: .45rem; }
 .viewer-lens .lens-toolbar button { min-height: 36px; }
}

@media (max-width: 960px) {
  /* The collection selector also exposes every group in this compact layout. */
  .gallery-shell .filter-row { display: none; }
  .gallery-shell .library { display: flex; flex-direction: column; }
  .library > .art-grid, .library > .empty { order: 1; }
  .library > .gallery-pages { order: 2; }
  .library > .gallery-page-bottom { display: none; }
  .gallery-shell .gallery-only-page { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .library > .browse-options { margin-bottom: .5rem; }
}
@media (min-width: 621px) and (max-width: 960px) {
  html[data-screen='gallery'] .main-nav { flex-wrap: nowrap; gap: 0; }
  html[data-screen='gallery'] .nav-button { padding-inline: .48rem; font-size: .85rem; gap: .36rem; }
  html[data-screen='gallery'] .masthead-inner { gap: .75rem; }
}
@media (max-width: 620px) {
  .gallery-shell .feature-info { padding: .8rem .1rem .8rem .8rem; }
  .gallery-shell .feature h1 { margin-block: .35rem; }
  .gallery-shell .feature-action-row { margin-top: .28rem; }
  .gallery-shell .feature-pager { display: none; }
  .gallery-shell .feature-meta { gap: .2rem .4rem; }
  .gallery-shell .feature-info .mini-rule { display: none; }
  .gallery-shell .feature .mounted-art { width: 96%; max-width: 96%; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .gallery-shell .feature { height: auto; min-height: 0; }
  .gallery-shell .feature-info { padding-block: .65rem; }
  .gallery-shell .feature-pager { display: none; }
}

/* The artwork fills the visual viewport, including when its optional tools are open. */
.full-view.art-viewer, html[data-pad-active='true'] .full-view.art-viewer {
  display: block;
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #10130f;
}
.art-viewer .viewer-lens { position: absolute; inset: 0; }
.art-viewer .lens-scroll { width: 100%; height: 100%; }
.art-viewer .viewer-switch, .art-viewer .viewer-tools {
  position: absolute;
  z-index: 2;
  right: max(.5rem, env(safe-area-inset-right));
}
.art-viewer .viewer-switch { top: max(.5rem, env(safe-area-inset-top)); }
.art-viewer .viewer-tools {
  top: calc(max(.5rem, env(safe-area-inset-top)) + 48px);
  max-height: calc(100% - 64px - env(safe-area-inset-bottom));
  max-width: min(22rem, calc(100% - 1rem));
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  display: grid;
  justify-items: end;
  gap: .3rem;
  padding: 2px;
  pointer-events: none;
}
.art-viewer .viewer-tools > *, .art-viewer .viewer-tools button { pointer-events: auto; }
.art-viewer .viewer-actions, .art-viewer .lens-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
  border: 0;
  padding: 0;
  background: none;
}
.art-viewer :is(.viewer-switch, .viewer-tools button, .viewer-tools output, .viewer-info) {
  color: #f5f4e9;
  background: #182018ee;
  border: 1px solid #a5ae98;
  border-radius: .45rem;
  line-height: 1.2;
}
.art-viewer :is(.viewer-switch,.viewer-tools button) {
  min-height: 44px; min-width: 44px;
  padding: .4rem .62rem;
  font: 600 .85rem/1.2 var(--sans);
}
.art-viewer .viewer-tools .button-primary { color: #182018; background: #ecdcaf; }
.art-viewer .viewer-info { max-width: 100%; padding: .4rem .6rem; text-align: right; }
.art-viewer .viewer-info h1 { margin: 0; font: 600 1rem/1.2 var(--sans); overflow-wrap: anywhere; }
.art-viewer .viewer-info span { font-size: .75rem; }
.art-viewer .lens-toolbar { position: static; width: auto; }
.art-viewer .lens-toolbar output { padding: .3rem; min-width: 3.3em; }
.art-viewer .viewer-tools button:disabled { opacity: .7; }
html[data-pad-active='true'] body:has(#gallery-screen[data-pad-view='viewer']:not([hidden])) .page-footer {display: none;}
.art-card[href], .mounted-art[href] { text-decoration: none; color: inherit; }

.gallery-source-heading {
  grid-column: 1 / -1;
  margin: .6rem 0 0;
  padding-top: .8rem;
  border-top: 1px solid #534f41;
  font: 400 clamp(1.35rem, 2vw, 1.8rem) / 1.15 var(--serif);
}

/* Links keep their native menu and modified-click behavior in the floating controls. */
.art-viewer .viewer-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .4rem .62rem;
  color: #f5f4e9;
  background: #182018ee;
  border: 1px solid #a5ae98;
  border-radius: .45rem;
  font: 600 .85rem/1.2 var(--sans);
  text-decoration: none;
}
.art-viewer .viewer-actions a:hover { text-decoration: underline; }
.art-viewer .lens-sheet img { pointer-events: auto; }
.art-viewer .viewer-switch { opacity: .82; }
.art-viewer .viewer-switch:is(:hover, :focus-visible, [aria-expanded='true']) { opacity: 1; }
#gallery-screen:fullscreen { background: #10130f; }
#gallery-screen:fullscreen .full-view.art-viewer { height: 100%; }

/* Keep the single collection browser visible and usable on narrow screens. */
.pack-select.collection-browser { display: grid; gap: .35rem; }
.pack-select.collection-browser select { width: min(100%, 38rem); max-width: 100%; min-height: 44px; font: inherit; }
