#yard-shop {
  --shop-ink: #512a14;
  --shop-line: #9e632c5c;
  --shop-red: #973717;
  --shop-paper: #f6cd94;
  box-sizing: border-box;
  width: min(1312px, 85.5vw);
  height: min(892px, 86.5dvh);
  max-height: calc(100dvh - 12px);
  border: clamp(5px, .69vw, 11px) solid #ad6329;
  border-radius: clamp(13px, 2vw, 32px);
  background: #ac602f url('assets/techniques/reference/frame-wood.webp') center / 85px auto;
  box-shadow: 0 0 0 1px #eab674, 0 0 0 2px #66361d, 0 6px 14px #3520139c, 0 0 0 100vmax #3520143d;
  color: var(--shop-ink);
  color-scheme: light;
  container: shop-counter / inline-size;
  overflow: hidden;
}
.shop-board {
  box-sizing: border-box;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(9px, .85cqw, 14px) clamp(13px, 1.48cqw, 23px) clamp(10px, 1.35cqw, 20px);
  border: 1px solid #f5d09a;
  border-radius: clamp(8px, 1.3cqw, 22px);
  box-shadow: inset 0 0 15px #a2622e65;
  background: url('assets/cardboard/paper-grain.webp') center / 362px auto repeat var(--shop-paper);
  overflow: hidden;
}
.shop-header {
  position: relative;
  display: grid;
  grid-template-columns: clamp(46px, 10cqw, 132px) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: clamp(8px, 1.6cqw, 24px);
  padding: 0 .85cqw .6cqw;
  min-width: 0;
  min-height: clamp(45px, 7.9cqw, 108px);
  border-bottom: 1px solid var(--shop-line);
}
.shop-header h2 { color: inherit; margin: 0; font: 700 clamp(25px, 3.75cqw, 54px)/1.03 Georgia, serif; }
.shop-header p {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 1cqw;
  margin: .42em 0 0;
  font-size: clamp(12px, 1.78cqw, 25px);
}
.shop-keeper {
  position: absolute;
  inset: 0 auto auto .85cqw;
  width: clamp(46px, 10cqw, 132px);
  height: clamp(46px, 10cqw, 132px);
  object-fit: cover;
  object-position: 50% 1%;
  background: #edbb77 url('assets/cardboard/paper-grain.webp') center / 180px;
  border: 1px solid #774624;
  border-radius: 50%;
}
.shop-header > div:nth-child(2) { grid-column: 2; }
.shop-wallet {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .3em .55em;
  max-width: 29cqw;
  background: #e8a9553b;
  border: 1px solid var(--shop-line);
  border-radius: .35em;
  padding: .4em .65em;
  line-height: 1.05;
  font: 700 clamp(12px, 1.9cqw, 26px)/1.05 Georgia, serif;
}
.shop-wallet span { display: inline-flex; align-items: center; gap: .28em; white-space: nowrap; }
.shop-wallet img { width: 1.65em; height: 1.3em; object-fit: contain; }
.shop-trial-wallet { color: #75411f; font-size: .75em; }
.shop-header .aux-close { width: clamp(28px, 4.25cqw, 57px); height: clamp(28px, 4.25cqw, 57px); }
.shop-talk {
  padding: .2em;
  border: 0;
  background: transparent;
  color: #784124;
  font-size: .63em;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.shop-notice {
  margin: .35em .55cqw;
  color: #6a351c;
  font-size: clamp(11px, 1.18cqw, 16px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.shop-notice:empty { display: none; }
.shop-paper { flex: 1; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.shop-skill {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25em 1.25cqw;
  min-height: clamp(28px, 6.35cqw, 83px);
  padding: .28em .85cqw;
  border-bottom: 1px solid var(--shop-line);
  font-size: clamp(11px, 1.48cqw, 21px);
}
.shop-skill > img { align-self: flex-end; flex: none; width: clamp(21px, 10.4cqw, 137px); height: clamp(21px, 4cqw, 53px); object-fit: contain; }
.shop-skill > span { min-height: 1.3em; display: inline-flex; align-items: center; gap: .28em; }
.shop-skill > span + span { border-inline-start: 1px solid var(--shop-line); padding-inline-start: 1.35cqw; }
.shop-skill .shop-progress { gap: .7em; margin-inline-start: auto; }
.shop-progress progress {
  appearance: none;
  width: clamp(42px, 9.8cqw, 126px);
  height: .64em;
  overflow: hidden;
  border: 1px solid #7e652d;
  border-radius: 2em;
  background: #d2a768;
  vertical-align: middle;
}
.shop-progress progress::-webkit-progress-bar { background: #d2a768; }
.shop-progress progress::-webkit-progress-value { background: #818134; }
.shop-progress progress::-moz-progress-bar { background: #818134; }
.shop-shelves {
  display: flex;
  align-items: center;
  gap: .55cqw;
  margin: 0;
  padding: .95cqw .85cqw;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--shop-line);
  font-size: clamp(11px, 1.52cqw, 21px);
}
.shop-shelves > strong { flex: none; margin-inline-end: .9cqw; font: 700 1.13em/1 Georgia, serif; }
.shop-shelves button {
  flex: 1 0 auto;
  white-space: nowrap;
  min-height: 2.1em;
  padding: .17em .32em;
  border: 1px solid #a56b37a3;
  border-radius: .35em;
  background: #eac18a7e;
  color: inherit;
  font: inherit;
}
.shop-shelves button:hover { background-color: #edb664; }
.shop-shelves button[aria-pressed='true'] { background: var(--shop-red); border-color: #802d14; color: #fff0d0; }
.shop-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  padding: .9cqw 0;
}
.shop-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 0 .65cqw; }
.shop-pane + .shop-pane { border-inline-start: 1px solid var(--shop-line); padding-inline-start: 1.45cqw; }
.shop-pane:first-child { padding-inline-end: 1.45cqw; }
.shop-pane h3 {
  display: flex;
  align-items: center;
  gap: .47em;
  margin: 0;
  padding: .08em .23em;
  min-height: 1.24em;
  font: 700 clamp(17px, 2.7cqw, 38px)/1.1 Georgia, serif;
}
.shop-pane h3 img { width: 1.18em; height: 1.1em; object-fit: contain; }
.shop-columns {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: .45em .48em .36em;
  border-bottom: 1px solid var(--shop-line);
  color: #654229;
  font-size: clamp(11px, 1.6cqw, 22px);
}
.shop-item-list {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #a9753e transparent;
}
.shop-item {
  position: relative;
  display: grid;
  grid-template-columns: clamp(24px, 6.25cqw, 84px) minmax(0, 1fr) auto;
  width: 100%;
  align-items: center;
  text-align: left;
  gap: clamp(4px, 1cqw, 14px);
  min-height: clamp(32px, 5.8cqw, 77px);
  padding: .31em .4em;
  border: 0;
  border-bottom: 1px solid var(--shop-line);
  background: transparent;
  color: inherit;
  font: 700 clamp(11px, 1.82cqw, 25px)/1.1 Georgia, serif;
  overflow-wrap: anywhere;
}
.shop-item:hover { background-color: #eab55c66; }
.shop-item[aria-pressed='true'] { background-color: #f3b35686; border-radius: .42em .42em 0 0; }
.shop-item[data-limited='true'] { opacity: .74; }
.shop-item img { width: 100%; height: clamp(25px, 4.9cqw, 67px); object-fit: contain; }
.shop-item[draggable='true'] { cursor: grab; user-select: none; }
.shop-item[draggable='true']:active { cursor: grabbing; }
.shop-item strong, .shop-item small { display: block; }
.shop-item small { margin-top: .22em; color: #77442a; font: 400 .64em/1.14 system-ui, sans-serif; }
.shop-units { white-space: nowrap; }
.shop-price { max-width: 12.6cqw; text-align: right; font-weight: 400; font-size: .92em; line-height: 1.16; }
#yard-shop.is-shop-dragging .shop-goods { outline: 2px dashed #854a28; outline-offset: -2px; }
#yard-shop.is-shop-drop-target .shop-goods { background-color: #ffc8614f; outline: 2px solid #8e4926; }
.shop-empty { margin: .75em .52em; font-size: clamp(11px, 1.52cqw, 18px); }
.shop-order {
  display: grid;
  grid-template-columns: minmax(0, 1.47fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 1cqw;
  min-width: 0;
  min-height: clamp(52px, 8.8cqw, 110px);
  padding: .65cqw .6cqw 0;
  border-top: 1px solid var(--shop-line);
}
.shop-idle { display: flex; justify-content: center; font: 700 clamp(12px, 1.6cqw, 22px)/1.22 Georgia, serif; }
.shop-order-item {
  display: flex;
  align-items: center;
  gap: .7cqw;
  min-width: 0;
  min-height: clamp(42px, 6cqw, 84px);
  padding-inline-end: 1.2cqw;
  border-inline-end: 1px solid var(--shop-line);
}
.shop-order-item img { width: clamp(26px, 7.6cqw, 98px); height: clamp(30px, 6cqw, 82px); object-fit: contain; }
.shop-order-item h3 { margin: 0; font: 700 clamp(13px, 2.16cqw, 31px)/1.08 Georgia, serif; overflow-wrap: anywhere; }
.shop-order-item p { margin: .2em 0 0; font-size: clamp(11px, 1.1cqw, 15px); }
.shop-quantity-label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.shop-stepper { display: flex; margin-inline-start: auto; border: 1px solid #744727; border-radius: .28em; overflow: hidden; }
.shop-stepper :is(input, button) {
  box-sizing: border-box;
  width: clamp(20px, 3.75cqw, 49px);
  min-height: clamp(29px, 3.9cqw, 53px);
  padding: .1em .2em;
  border: 0;
  background: #e9b77b;
  color: inherit;
  text-align: center;
  font: 700 clamp(14px, 2cqw, 28px)/1 Georgia, serif;
  appearance: textfield;
}
.shop-stepper input { width: clamp(29px, 5.25cqw, 71px); border-inline: 1px solid #744727; background: #ffedd0; }
.shop-stepper input::-webkit-inner-spin-button { appearance: none; }
.shop-stepper button:disabled { opacity: .55; }
.shop-quote { display: grid; gap: .18em; margin: 0; padding: .2em .3em; min-width: 0; }
.shop-quote > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15em .45em; border-bottom: 1px solid var(--shop-line); }
.shop-quote dt { font: 400 clamp(11px, 1.43cqw, 21px)/1.1 system-ui, sans-serif; }
.shop-quote dd { margin: 0; font: 700 clamp(12px, 1.69cqw, 24px)/1.18 Georgia, serif; }
.shop-order-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25em; }
#yard-shop .shop-order-buttons button {
  min-height: clamp(32px, 4.65cqw, 65px);
  min-width: clamp(70px, 13.7cqw, 185px);
  border: 1px solid #7c2c13;
  border-radius: .25em;
  padding: .24em .62em;
  color: #ffecd0;
  background: var(--shop-red) url('assets/techniques/reference/frame-wood.webp') center / 95px;
  background-blend-mode: luminosity;
  box-shadow: 0 2px 3px #76422166;
  font: 700 clamp(14px, 2.15cqw, 30px)/1 Georgia, serif;
}
#yard-shop .shop-order-buttons .pack-secondary { min-width: auto; min-height: 28px; color: #63371c !important; background: #ebbc7c; font-size: clamp(11px, 1.42cqw, 19px); }
#yard-shop .shop-order-buttons button:disabled { opacity: .6; box-shadow: none; }
#yard-shop :is(button,input):focus-visible { outline: 2px solid #6d341e; outline-offset: -2px; }
.shop-pages, #yard-shop .shop-catalog-return, .shop-item[hidden] { display: none; }

@media (max-height: 590px), (max-width: 700px) {
  #yard-shop { width: min(98vw, 1312px); height: calc(100dvh - 18px); }
  .shop-board { padding: 7px; }
  .shop-header { grid-template-columns: clamp(37px, 8dvh, 50px) minmax(0, 1fr) auto auto; padding-block-end: 3px; }
  .shop-header h2 { font-size: clamp(22px, 3.5cqw, 34px); }
  .shop-header p { margin-top: .25em; }
  .shop-keeper { position: static; width: clamp(37px, 8dvh, 50px); height: clamp(37px, 8dvh, 50px); }
  .shop-skill { min-height: 28px; }
  .shop-skill > img { width: 29px; height: 27px; }
  .shop-shelves { padding-block: 3px; }
  .shop-shelves button { min-height: 25px; }
  .shop-pane h3 { font-size: clamp(15px, 2.55cqw, 24px); }
  .shop-item { min-height: clamp(30px, 7.6dvh, 44px); grid-template-columns: clamp(20px, 5cqw, 45px) minmax(0, 1fr) auto; }
  .shop-item img { height: clamp(20px, 6.4dvh, 42px); }
  .shop-price { max-width: 13cqw; }
  .shop-order { min-height: 49px; }
  .shop-order-item { min-height: 38px; }
  .shop-order-item img { width: clamp(26px, 7.5dvh, 52px); height: clamp(28px, 7.5dvh, 52px); }
}
@media (max-width: 520px) {
  .shop-header { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 4px; }
  .shop-header h2 { font-size: 19px; }
  .shop-wallet { max-width: 20cqw; padding: 3px; }
  .shop-wallet img, .shop-shelves > strong, .shop-progress progress { display: none; }
  .shop-skill > span + span { padding-inline-start: .6cqw; }
  .shop-item strong { overflow-wrap: anywhere; }
  .shop-order { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
  .shop-order-item { grid-column: 1/-1; border-inline-end: 0; min-height: 30px; }
  .shop-order-item p { font-size: 10px; }
}

@media (orientation: landscape) and (max-height: 510px) {
  html[data-mobile-game] #yard-shop {
    --shop-compact: 1;
    inset-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px);
    height: calc(var(--yard-visible-height, 100dvh) - env(safe-area-inset-bottom) - 12px);
    border-width: 4px;
  }
  html[data-mobile-game] .shop-board { padding: 5px 8px 6px; }
  html[data-mobile-game] .shop-header { gap: 8px; min-height: 44px; }
  html[data-mobile-game] .shop-header h2 { font-size: clamp(20px, 3cqw, 27px); }
  html[data-mobile-game] .shop-header p { margin-block-start: 2px; font-size: .8rem; }
  html[data-mobile-game] .shop-talk { font-size: .76rem; }
  html[data-mobile-game] .shop-wallet { font-size: .84rem; }
  html[data-mobile-game] .shop-notice { margin-block: 2px; font-size: .75rem; }
  html[data-mobile-game] .shop-skill { padding-block: 2px; min-height: 28px; font-size: .77rem; }
  html[data-mobile-game] .shop-skill > img { width: 25px; height: 24px; }
  html[data-mobile-game] .shop-shelves {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    overflow: visible;
    font-size: .77rem;
  }
  html[data-mobile-game] .shop-shelves > strong { display: none; }
  html[data-mobile-game] .shop-shelves button { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  html[data-mobile-game] .shop-layout { padding-block: 4px 0; }
  html[data-mobile-game] .shop-pane h3 { font-size: clamp(16px, 2.4cqw, 22px); }
  html[data-mobile-game] .shop-columns { padding-block: 2px; font-size: .75rem; }
  html[data-mobile-game] .shop-item-list { overflow: hidden; }
  html[data-mobile-game] .shop-item { grid-template-columns: 31px minmax(0, 1fr) auto; min-height: 30px; font-size: clamp(.8rem, 1.8cqw, .98rem); }
  html[data-mobile-game] .shop-item small { font-size: .68rem; }
  html[data-mobile-game] .shop-item img { height: 24px; }
  html[data-mobile-game] .shop-pages:not([hidden]) { display: flex; gap: 6px; align-items: center; justify-content: center; min-height: 32px; padding: 2px; }
  html[data-mobile-game] .shop-pages button {
    min-width: 41px;
    min-height: 28px;
    padding: 0 4px;
    border: 1px solid #a56b37a3;
    border-radius: 4px;
    background: #eac18a7e;
    font: 700 1.08rem/1 Georgia, serif;
  }
  html[data-mobile-game] .shop-pages button[aria-disabled='true'] { opacity: .42; cursor: default; }
  html[data-mobile-game] .shop-pages output { min-width: 4ch; text-align: center; font-size: .77rem; }
  html[data-mobile-game] #yard-shop:not([data-shop-checkout]) .shop-order { display: none; }
  html[data-mobile-game] #yard-shop[data-shop-checkout] .shop-paper { grid-template-rows: auto minmax(0, 1fr); }
  html[data-mobile-game] #yard-shop[data-shop-checkout] :is(.shop-shelves, .shop-layout) { display: none; }
  html[data-mobile-game] .shop-order {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-self: center;
    max-height: 100%;
    padding: 4px .7cqw;
    border-top: 0;
  }
  html[data-mobile-game] .shop-order-item h3 { font-size: clamp(16px, 2.1cqw, 21px); }
  html[data-mobile-game] .shop-order-item p { font-size: .77rem; }
  html[data-mobile-game] .shop-quote :is(dt, dd) { font-size: .85rem; }
  html[data-mobile-game] #yard-shop .shop-order-buttons { flex-direction: column; align-items: stretch; }
  html[data-mobile-game] #yard-shop .shop-catalog-return { display: block; }
}

@media (orientation: landscape) and (max-height: 340px) {
  html[data-mobile-game] .shop-header { min-height: 38px; grid-template-columns: 31px minmax(0, 1fr) auto auto; }
  html[data-mobile-game] .shop-header > div:nth-child(2) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 9px; }
  html[data-mobile-game] .shop-header h2 { font-size: 20px; }
  html[data-mobile-game] .shop-header p { margin: 0; font-size: .73rem; }
  html[data-mobile-game] .shop-keeper, html[data-mobile-game] .shop-header .aux-close { width: 31px; height: 31px; }
  html[data-mobile-game] .shop-pane h3 { min-height: 0; padding-block: 0; font-size: 17px; line-height: 1; }
  html[data-mobile-game] .shop-columns { padding-block: 1px; }
  html[data-mobile-game] .shop-skill { min-height: 24px; }
  html[data-mobile-game] .shop-skill > img { width: 21px; height: 21px; }
  html[data-mobile-game] .shop-pages:not([hidden]) { min-height: 29px; }
  html[data-mobile-game] .shop-pages button { min-height: 26px; }
}

@media (orientation: landscape) and (max-height: 510px) {
  html[data-mobile-game] .shop-header {
    min-height: 48px;
    padding: 2px 6px;
    border: 1px solid #966540;
    border-radius: 8px;
    background: #304a38 url('assets/cardboard/cloth-grain.webp') center / 220px auto;
    background-blend-mode: multiply;
    color: #fff0ce;
  }
  html[data-mobile-game] .shop-header .aux-close {
    width: 44px;
    height: 44px;
    background-size: 33px;
  }
  html[data-mobile-game] .shop-wallet {
    border-color: #a87a4c;
    background: #f3cd96;
    color: var(--shop-ink);
  }
  html[data-mobile-game] .shop-talk { color: #fff0ce; }
  html[data-mobile-game] .shop-shelves button { min-height: 42px; }
  html[data-mobile-game] .shop-pane {
    display: grid;
    grid-template: 'heading paging' auto 'columns columns' auto 'items items' minmax(0, 1fr)
      / minmax(0, 1fr) auto;
    align-items: center;
  }
  html[data-mobile-game] .shop-pane h3 { grid-area: heading; }
  html[data-mobile-game] .shop-columns { grid-area: columns; }
  html[data-mobile-game] .shop-item-list { grid-area: items; align-self: stretch; }
  html[data-mobile-game] .shop-item { min-height: 44px; }
  html[data-mobile-game] .shop-pages:not([hidden]) {
    grid-area: paging;
    min-height: 44px;
    padding: 0;
    gap: 3px;
  }
  html[data-mobile-game] .shop-pages button,
  html[data-mobile-game] #yard-shop .shop-order-buttons button {
    min-width: 44px;
    min-height: 44px;
  }
  html[data-mobile-game] .shop-quote > div { padding-block: 4px; }
}

@media (orientation: landscape) and (max-height: 265px) {
  html[data-mobile-game] .shop-shelves button { min-height: 35px; }
  html[data-mobile-game] .shop-pages:not([hidden]),
  html[data-mobile-game] .shop-pages button,
  html[data-mobile-game] #yard-shop .shop-order-buttons button { min-height: 34px; }
}

@media (orientation: landscape) and (max-height: 340px) {
  html[data-mobile-game] .shop-pane {
    grid-template: 'heading columns paging' auto 'items items items' minmax(0, 1fr)
      / minmax(0, 1fr) minmax(0, auto) auto;
    column-gap: 5px;
  }
  html[data-mobile-game] .shop-pane h3 { overflow-wrap: anywhere; }
  html[data-mobile-game] .shop-columns {
    justify-content: flex-end;
    border: 0;
    padding: 0;
    font-size: .68rem;
    text-align: end;
  }
  html[data-mobile-game] .shop-columns > span:first-child { display: none; }
}
