.market-game {
  --market-leather: #5a3828;
  --market-field: #f0e8d9;
  width: min(100%, 930px);
}

.market-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.market-round { color: var(--subtle); font-size: .88rem; }
.market-round strong { margin-right: 6px; color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.market-scoreboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
.market-terracotta { --market-owner: #93482f; --market-owner-paper: #f6e6dd; }
.market-green { --market-owner: #366047; --market-owner-paper: #eaf0df; }
.market-violet { --market-owner: #674f79; --market-owner-paper: #f0e9f4; }

.market-score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--market-owner-paper);
  color: var(--market-owner);
}

.market-score span, .market-ledger strong, .market-rankings strong {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.market-score span { font-size: .8rem; font-weight: 750; }
.market-score i, .market-ledger i, .market-rankings i {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--market-owner);
}
.market-score strong { font-size: clamp(.82rem, 2.5vw, 1.18rem); font-variant-numeric: tabular-nums; white-space: nowrap; }

.market-layout { display: grid; grid-template-columns: minmax(0, 1.78fr) minmax(245px, 1fr); gap: 14px; align-items: start; }
.market-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 10px;
  border: 1px solid #d6c8b2;
  border-radius: 18px;
  background: var(--market-field);
}
.market-district {
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 11px;
}
.market-district.is-in-demand { border-color: #ddb96b; background: #f7e8c6; }
.market-district-head { margin: 0 3px 6px; text-align: center; }
.market-district-head h2 { color: var(--market-leather); font-size: 1.08rem; font-weight: 870; letter-spacing: -.06em; }
.market-district-head > span { color: #704615; font-size: .72rem; font-weight: 750; }
.market-sites { display: grid; gap: 7px; }

.market-site {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  gap: 2px 9px;
  width: 100%;
  min-width: 0;
  min-height: 68px;
  padding: 7px;
  border: 1px solid #d5caba;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}
.market-site.market-occupied {
  border-style: solid;
  color: var(--market-owner);
  background: var(--market-owner-paper);
}
.market-site.market-vacant { border-style: dashed; color: #625747; }
button.market-site:hover { border-color: #956439; background: #fffaf0; }
button.market-site[aria-pressed="true"] {
  border-style: solid;
  border-color: #956439;
  background: #fffbec;
  box-shadow: inset 0 0 0 1px #956439;
}
.market-shopname { font-size: .83rem; font-weight: 830; white-space: nowrap; }
.market-site-detail { font-size: .66rem; font-weight: 700; white-space: nowrap; }
.market-pair-mark {
  position: absolute;
  inset: 4px 4px auto auto;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: .61rem;
  line-height: 1;
}

.market-storefront {
  position: relative;
  grid-row: 1 / 3;
  width: 25px;
  height: 20px;
  margin-top: 6px;
  border: 1px solid currentColor;
  border-radius: 1px 1px 3px 3px;
  color: inherit;
}
.market-storefront::before {
  position: absolute;
  inset: -4px -3px auto;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 2px 2px 3px 3px;
  background: repeating-linear-gradient(90deg, transparent 0 5px, currentColor 5px 8px);
  content: "";
}
.market-storefront::after {
  position: absolute;
  bottom: 0;
  left: 7px;
  width: 8px;
  height: 9px;
  border: 1px solid currentColor;
  border-bottom: 0;
  content: "";
}
.market-vacant .market-storefront { opacity: .49; }

.market-action {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.market-action h2 { font-size: 1.18rem; font-weight: 850; letter-spacing: -.05em; }
.market-forecast {
  position: relative;
  padding: 10px 12px 12px;
  border-left: 3px solid #b88d3b;
  border-radius: 3px 7px 7px 3px;
  background: #f7edd3;
}
.market-forecast span, .market-forecast p { color: #6f552f; font-size: .72rem; }
.market-forecast span { font-weight: 800; }
.market-forecast h2 { margin: 2px 0; color: var(--market-leather); }
.market-instruction, .market-result-note { margin-top: 11px; color: var(--subtle); font-size: .85rem; line-height: 1.5; }
.market-action form { margin-top: 15px; }
.market-shop-options { display: grid; gap: 5px; min-width: 0; margin: 9px 0; padding: 0; border: 0; }
.market-shop-options legend, .market-bid-label { margin-bottom: 5px; color: var(--subtle); font-size: .77rem; font-weight: 800; }
.market-shop-options label {
  display: grid;
  grid-template-columns: 15px auto 1fr;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
.market-shop-options label:has(input:checked) { border-color: #b88d61; background: #f8eee0; }
.market-shop-options label:has(input:focus-visible) { outline: 2px solid #9b4b23; outline-offset: 2px; }
.market-shop-options input { margin: 0; accent-color: #975234; }
.market-shop-options span { font-size: .79rem; font-weight: 760; }
.market-shop-options small { color: var(--subtle); font-size: .7rem; text-align: right; }
.market-preview { margin: 8px 0 11px; color: var(--green); font-size: .76rem; font-weight: 790; }
.market-bid-label { display: inline-block; }
.market-bid-input { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 5px; }
.market-bid-input button { font-size: 1.15rem; }
.market-bid-input input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-align: center;
  appearance: textfield;
}
.market-bid-input input::-webkit-inner-spin-button,
.market-bid-input input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.market-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.market-actions [data-market-bid], .market-actions [data-market-next], .market-actions [data-market-replay] { flex: 1; }
.market-result-title:focus { outline: none; }
.market-ledger, .market-rankings { display: grid; gap: 6px; padding: 0; margin: 11px 0 0; list-style: none; }
.market-ledger li, .market-rankings li {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--market-owner-paper);
}
.market-ledger li > div, .market-rankings li { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.market-ledger li strong, .market-rankings li strong { color: var(--market-owner); }
.market-ledger li > p { margin: 3px 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.market-ledger li span, .market-rankings li span { color: var(--subtle); font-size: .72rem; }
.market-ledger li .market-outcome { color: var(--market-owner); font-weight: 800; }
.market-ledger li strong, .market-rankings li strong { font-size: .8rem; }
.market-finish { margin-top: 5px; color: var(--market-leather); font-size: 1.4rem; font-weight: 870; }

@media (max-width: 680px) {
  .market-layout { grid-template-columns: minmax(0, 1fr); }
  .market-map { gap: 3px; padding: 6px; }
  .market-district { padding: 4px; }
  .market-site { gap: 2px 5px; }
  .market-action form { scroll-margin-top: 16px; }
}

@media (max-width: 440px) {
  .market-score { padding-inline: 7px; }
  .market-map { border-radius: 13px; }
  .market-district-head { margin-inline: 0; }
  .market-district-head h2 { font-size: .93rem; }
  .market-action { padding: 13px; }
}

@media (max-width: 440px), (681px <= width <= 860px) {
  .market-site { justify-items: center; min-height: 59px; grid-template: auto auto / 1fr; text-align: center; }
  .market-storefront { display: none; }
  .market-shopname { font-size: .75rem; }
  .market-site-detail { font-size: .62rem; }
}
