#town-market {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  box-sizing: border-box;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 3px solid var(--ink);
  border-radius: 12px;
  corner-shape: bevel;
  color: var(--ink);
  background: var(--parchment);
  box-shadow: var(--ledge);
  font: 600 14px/1.45 var(--read);
  text-shadow: none;
}
#town-market[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#town-market::backdrop {
  background: rgb(16 31 23 / 58%);
}
#town-market *,
#town-market *::before {
  box-sizing: border-box;
}
#town-market [hidden] {
  display: none !important;
}
#town-market button,
#town-market input,
#town-market select {
  min-height: 44px;
  max-width: 100%;
  border: 2px solid #987944;
  border-radius: 6px;
  font: 700 14px var(--read);
  color: var(--ink);
}
#town-market button {
  padding: 8px 12px;
  background: var(--raised);
  box-shadow: inset 0 -2px #ad89382b;
  cursor: pointer;
}
#town-market button:hover:not(:disabled) {
  background: #ffe8a6;
}
#town-market button:disabled {
  opacity: .5;
  cursor: default;
}
#town-market :is(button, input, select, summary):focus-visible {
  outline: 3px solid #387849;
  outline-offset: 2px;
}
#town-market .tm-primary {
  color: #fff9e6;
  background: var(--evergreen);
  border-color: #285231;
}
#town-market .tm-primary:hover:not(:disabled) {
  background: #326d42;
}
#town-market .tm-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--evergreen);
  color: var(--paper);
  border-bottom: 3px solid var(--ink);
  flex: none;
}
.tm-heading small {
  display: block;
  color: #eff2d3;
  font-size: 10px;
  letter-spacing: .12em;
}
#town-market h2 {
  margin: 2px 0 0;
  font: 800 23px/1.2 var(--read);
}
#town-market .tm-emblem {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: #285639;
  border: 2px solid #c5d29b;
  border-radius: 8px;
}
.tm-emblem canvas {
  width: 32px;
  height: 32px;
}
#town-market #tm-close {
  width: 44px;
  flex: none;
  margin-left: auto;
  padding: 0;
  font-size: 27px;
  background: #fff5d9;
  color: var(--ink);
}
.tm-wallet {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px;
  border-bottom: 1px solid #d6bd8c;
  background: #f7ebcf;
  flex: none;
}
#tm-purse {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
#tm-purse canvas {
  width: 24px;
  height: 24px;
}
#town-market #tm-refresh {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #466542;
  padding: 4px 8px;
}
.tm-collection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 18px;
  background: #e9edda;
  border-bottom: 1px solid #b9c496;
  flex: none;
}
.tm-collection > div {
  flex: 1;
  min-width: 140px;
}
.tm-collection strong,
.tm-collection span {
  display: block;
}
.tm-collection strong {
  font-size: 14px;
  color: #315733;
}
#tm-collection-summary {
  font-size: 12px;
  color: #576246;
  margin-top: 3px;
}
#tm-collection-details {
  flex-basis: 100%;
  font-size: 12px;
  color: #3e5b35;
}
#town-market summary {
  cursor: pointer;
  min-height: 32px;
  padding: 5px 0;
}
#tm-collected-items {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  max-height: 100px;
  overflow-y: auto;
}
#tm-collected-items li {
  display: flex;
  gap: 6px;
  align-items: center;
}
#tm-collected-items canvas {
  width: 24px;
  height: 24px;
}
.tm-tabs {
  display: flex;
  flex: none;
  gap: 6px;
  padding: 12px 18px 0;
  border-bottom: 2px solid #d6bd8c;
}
#town-market .tm-tabs button {
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  flex: 1;
  box-shadow: none;
  color: #755a30;
  background: #eadbb8;
}
#town-market .tm-tabs button[aria-pressed=true] {
  color: #285637;
  background: #fff9e8;
  border-color: #3c7247;
  box-shadow: inset 0 3px #5f9855;
}
.tm-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  min-height: 0;
  padding: 16px 18px 20px;
}
#tm-note {
  margin: 0 0 13px;
  padding: 10px 12px;
  background: #e6edcf;
  border-left: 3px solid #668441;
  border-radius: 4px;
  color: #36532d;
}
#tm-note.tm-error {
  background: #f7e4d4;
  border-color: #a94830;
  color: #7d2f22;
}
#tm-retry {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 12px;
  background: #ffebbc;
}
#town-market[data-waiting] :is(#tm-content, .tm-tabs, .tm-collection, #tm-refresh) {
  pointer-events: none;
  opacity: .65;
}
#town-market .tm-footer {
  flex: none;
  padding: 9px 18px;
  text-align: center;
  border-top: 1px solid #d6bd8c;
  color: #7a603e;
  background: #f0e0bb;
  font-size: 11px;
}
.tm-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 12px;
}
.tm-search,
.tm-sort,
.tm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  min-width: 0;
}
#town-market input,
#town-market select {
  padding: 8px 10px;
  background: #fffdf4;
  min-width: 0;
  width: 100%;
  font-size: 16px;
}
.tm-categories {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin: 12px 0 0;
}
#town-market .tm-categories button {
  padding: 6px 11px;
  font-size: 12px;
  border-width: 1px;
}
#town-market .tm-categories button[aria-pressed=true] {
  background: #dce9c7;
  border-color: #5b8150;
  color: #2c5131;
}
.tm-result-count {
  font-size: 12px;
  color: #806b49;
  margin: 14px 0 7px;
}
.tm-listings {
  display: grid;
  gap: 7px;
}
.tm-listing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, auto) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  background: #fffaf0;
  border: 1px solid #dcc393;
  border-radius: 7px;
  box-shadow: 0 2px #c3a3611a;
}
.tm-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.tm-item canvas {
  width: 40px;
  height: 40px;
}
.tm-item-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tm-item-copy strong {
  display: block;
  font-size: 14px;
}
.tm-item-copy span {
  display: block;
  font-size: 11px;
  margin-top: 1px;
}
.tm-muted,
.tm-seller {
  color: #796345;
}
.tm-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tm-price strong {
  display: block;
  color: #375e34;
  font-size: 16px;
}
.tm-price span {
  color: #7c6745;
  font-size: 11px;
}
.tm-paging {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}
.tm-empty {
  text-align: center;
  padding: 28px 15px;
  border: 1px dashed #cbb885;
  border-radius: 7px;
  background: #f4ebd665;
}
.tm-empty .px-icon {
  opacity: .65;
}
.tm-empty canvas {
  width: 48px;
  height: 48px;
}
#town-market h3 {
  font-size: 18px;
  margin: 0 0 8px;
  line-height: 1.3;
}
.tm-empty h3 {
  margin: 10px 0 5px !important;
  color: #695638;
}
.tm-empty p {
  max-width: 400px;
  margin: 0 auto;
  color: #847153;
  font-size: 13px;
  font-weight: 500;
}
.tm-intro {
  color: #796345;
  font-size: 13px;
  margin: 0 0 15px;
}
.tm-bag {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
  padding: 3px;
  margin: 0 0 16px;
}
#town-market .tm-bag-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 94px;
  padding: 8px 5px;
  font-size: 11px;
  border-color: #ceb47b;
}
.tm-bag-item canvas {
  width: 36px;
  height: 36px;
}
.tm-bag-item small {
  color: #78633f;
  font-variant-numeric: tabular-nums;
}
#town-market .tm-bag-item[aria-pressed=true] {
  border-color: #367044;
  background: #e2edce;
  box-shadow: inset 0 0 0 1px #367044;
}
.tm-sell-form {
  padding: 15px;
  border: 1px solid #d3bb89;
  background: #fff9eb;
  border-radius: 8px;
}
.tm-selected {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.tm-selected h3 {
  margin: 0 !important;
}
.tm-selected canvas {
  width: 40px;
  height: 40px;
}
.tm-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tm-quick {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}
.tm-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 20px;
  margin: 17px 0;
  padding: 14px;
  background: #efe6ca;
  border-radius: 7px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tm-totals dt {
  color: #766344;
  font-weight: 500;
}
.tm-totals dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}
.tm-totals .tm-total {
  color: #2e5c35;
  font-size: 17px;
  padding-top: 8px;
  margin-top: 3px;
  border-top: 1px solid #c9b584;
  font-weight: 800;
}
.tm-fine {
  color: #816c4a;
  font-size: 11px;
  font-weight: 500;
}
.tm-rule {
  padding: 12px;
  color: #5b6341;
  background: #e8edd8;
  border-left: 3px solid #91a367;
  border-radius: 4px;
  font-size: 13px;
}
#town-market .tm-back {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #596e40;
  padding-left: 0;
  margin: -8px 0 8px;
}
.tm-review-item {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 14px;
  margin-top: 12px;
  background: #fffaf0;
  border: 1px solid #d6bd89;
  border-radius: 8px;
  font-size: 21px;
  font-weight: 800;
}
.tm-review-item canvas {
  width: 56px;
  height: 56px;
}
.tm-item-details {
  color: #7b6341;
  font-size: 12px;
  font-weight: 500;
  margin: 10px 0 16px;
}
.tm-comparison {
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid #c3aa78;
  border-radius: 7px;
  background: #fffaf0;
}
.tm-comparison h4 {
  margin: 0 0 5px;
}
.tm-comparison p {
  margin: 5px 0 8px;
}
.tm-comparison table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tm-comparison th,
.tm-comparison td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid #e4d5b7;
  overflow-wrap: anywhere;
}
.tm-comparison thead th {
  color: #796345;
  font-weight: 500;
}
.tm-comparison tbody th {
  font-weight: 500;
}
.tm-comparison .tm-better {
  color: #285b36;
  font-weight: 700;
}
.tm-comparison .tm-worse {
  color: #963b28;
  font-weight: 700;
}
#tm-content > form {
  max-width: 500px;
}
#town-market .tm-secondary {
  margin-left: 8px;
}
.tm-history {
  margin-top: 20px;
  color: #6e5b3c;
}
.tm-history-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 0;
  border-bottom: 1px solid #e1d0a6;
  font-size: 12px;
}
.tm-history-row small {
  color: #8c7959;
  font-weight: 500;
}
@media (max-width: 540px) {
  #town-market {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }
  #town-market .tm-heading {
    padding: 10px 12px;
    gap: 9px;
  }
  #town-market h2 {
    font-size: 21px;
  }
  .tm-wallet {
    padding: 3px 12px;
    font-size: 12px;
  }
  .tm-collection {
    padding: 9px 12px;
    gap: 7px;
  }
  #tm-collection-summary {
    font-size: 11px;
  }
  .tm-tabs {
    padding: 9px 10px 0;
    gap: 4px;
  }
  #town-market .tm-tabs button {
    padding: 7px;
    font-size: 13px;
  }
  .tm-body {
    padding: 13px 11px 16px;
  }
  .tm-filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tm-sort {
    flex-direction: row;
    align-items: center;
  }
  .tm-sort select {
    flex: 1;
  }
  .tm-categories {
    gap: 4px;
  }
  #town-market .tm-categories button {
    flex: 1;
    padding: 6px;
  }
  .tm-listing {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }
  .tm-listing > button {
    grid-column: 1 / -1;
    width: 100%;
  }
  .tm-price strong {
    font-size: 14px;
  }
  .tm-item-copy strong {
    font-size: 13px;
  }
  .tm-bag {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }
  .tm-fields {
    gap: 8px;
  }
  .tm-sell-form {
    padding: 11px;
  }
  .tm-totals {
    padding: 11px;
    gap: 7px;
  }
  .tm-review-item {
    font-size: 18px;
  }
  #tm-content > .tm-primary,
  #tm-content form > .tm-primary {
    width: 100%;
  }
  #town-market .tm-secondary {
    width: 100%;
    margin: 8px 0 0;
  }
  #town-market .tm-footer {
    padding: 7px 10px;
    font-size: 10px;
  }
}
@media (max-height: 580px) {
  #town-market .tm-heading {
    padding: 6px 12px;
  }
  .tm-heading small,
  .tm-emblem,
  .tm-footer {
    display: none !important;
  }
  .tm-collection {
    padding: 6px 12px;
  }
  .tm-tabs {
    padding-top: 5px;
  }
  .tm-wallet {
    padding-top: 0;
    padding-bottom: 0;
  }
}
