.market-page {
  --panel: #14272d;
  background: radial-gradient(ellipse at 65% 0%, #24443b 0, transparent 45rem), #111c24;
}
.market-page .wrap { width: min(1280px, calc(100% - 2rem)); }
.market-page .bar { background: #132428; }
.market-page .bar nav a[aria-current] { color: var(--gold); background: #30362e; }
.market-page a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.market-page [hidden] { display: none !important; }
.market-hero {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
  min-height: 240px; border: 1px solid #817058; border-radius: .8rem; padding: clamp(1.15rem, 3.2vw, 2.8rem);
  margin-block: 1.25rem; background: linear-gradient(90deg, #13282b 15%, #13282bcc 54%, #14272d55),
    url('/assets/breuvale-rua-small.webp') center 56% / cover;
}
.market-hero h1 { font: 700 clamp(2.5rem, 6vw, 5rem)/.98 var(--display); margin: .4rem 0 .8rem; }
.market-hero p:not(.eyebrow) { font-size: 1.03rem; max-width: 42rem; color: var(--muted); margin: 0; }
.market-hero img { filter: drop-shadow(0 8px 16px #09151a); width: min(16vw, 116px); height: auto; }
.market-notice { border: 1px solid #63877c; background: #213c37; padding: .75rem 1rem; border-radius: .5rem; }
.market-notice[data-error="true"] { border-color: #a87462; background: #432b2a; color: #ffe2d9; }
.market-board { margin-block: 1.25rem; padding: 1.07rem; background: #14262beb; border: 1px solid #506a66; border-radius: .72rem; }
.market-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.market-section-head h2 { font: 700 2rem/1 var(--display); margin: 0; }
.market-section-head p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.market-filters { display: grid; grid-template-columns: 1.6fr repeat(3, minmax(0,1fr)); gap: .65rem; margin-bottom: 1rem; }
.market-filters label, #confirm-trade label { display: grid; gap: .3rem; color: #e2e9e1; font-size: .88rem; }
.market-filters :is(input, select), #confirm-trade input {
  width: 100%; min-height: 44px; min-width: 0; padding: .42rem .6rem; color: #f8efe3;
  background: #102128; border: 1px solid #597575; border-radius: .4rem; font-size: 1rem;
}
.market-filters.market-sell { grid-template-columns: 1.5fr repeat(4, minmax(0,1fr)) auto; align-items: end; }
.market-items { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .8rem; }
.market-item {
  --rarity: #a9c6ba; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--rarity) 42%, #324a49); border-radius: .55rem;
  background: linear-gradient(150deg, #23383b, #111e29 70%);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.market-item:hover, .market-item:focus, .market-spotlight {
  border-color: var(--rarity); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rarity) 38%, transparent);
}
.market-item[data-rare="uncommon"] { --rarity: #a8eab0; }
.market-item[data-rare="rare"] { --rarity: #9dd8ff; }
.market-item[data-rare="epic"] { --rarity: #e2bcff; }
.market-item[data-rare="legendary"] { --rarity: #ffdb9a; }
.market-art {
  position: relative; min-height: 145px; display: grid; place-items: center; padding: 1.9rem .4rem .4rem;
  background: radial-gradient(ellipse at 50% 62%, color-mix(in srgb, var(--rarity) 29%, transparent), transparent 70%),
    repeating-linear-gradient(135deg, #ffffff07 0 1px, transparent 1px 7px), #182932;
  border-bottom: 1px solid #54696a;
}
.market-art img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 5px 9px #060e16); }
.market-art > .icon { font-size: 4.25rem; }
.lot-type, .lot-qty {
  position: absolute; top: .5rem; background: #0f2028; color: #f8ecd9;
  border: 1px solid #687979; border-radius: .3rem; padding: .2rem .45rem; font-size: .88rem;
}
.lot-type { left: .5rem; }
.lot-qty { right: .5rem; }
.market-details { flex: 1; padding: .65rem .75rem; }
.market-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .19rem .45rem; font-size: .88rem; color: var(--muted); }
.market-meta span:first-child { color: var(--rarity); font-weight: 700; }
.market-details h3 { font: 700 1.55rem/1.08 var(--display); margin: .28rem 0 .42rem; }
.market-details p { margin: .32rem 0; color: var(--muted); font-size: .90rem; }
.lot-stats { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0; list-style: none; }
.lot-stats li { border-radius: .25rem; padding: .12rem .35rem; background: #21483d; color: #c6f7d7; font-size: .88rem; }
.market-details .lot-origin { color: #c2d8cd; margin-top: .65rem; }
.market-price { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; padding: .65rem .75rem .15rem; gap: .25rem; border-top: 1px solid #435954; }
.market-price small { display: block; color: var(--muted); font-size: .875rem; }
.market-price strong { font-size: 1.06rem; }
.market-price [data-currency="gold"] { color: var(--gold); }
.market-price [data-currency="crystals"] { color: var(--berry); }
.auction-time { color: #addfcd; font-size: .875rem; }
.market-action { padding: .45rem .75rem .75rem; }
.market-action .btn { width: 100%; min-height: 42px; }
.market-empty { grid-column: 1 / -1; margin: .35rem 0; color: var(--muted); padding: 1rem; background: #132128; border-radius: .4rem; }
.market-pages { display: flex; align-items: center; justify-content: center; gap: .55rem; margin-top: .8rem; }
.trade-result { color: var(--fault); margin-bottom: 0; }
#confirm-trade button { margin-top: .6rem; }
@media (max-width: 1000px) {
  .market-items { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .market-filters.market-sell { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .market-items, .market-filters { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .market-hero { min-height: 205px; }
}
@media (max-width: 445px) {
  .market-page .wrap { width: calc(100% - 1rem); }
  .market-board { padding: .65rem; }
  .market-items { grid-template-columns: 1fr; }
  .market-item { display: grid; grid-template-columns: 105px minmax(0,1fr); }
  .market-art { grid-row: 1 / 4; min-height: 118px; border: 0; border-right: 1px solid #54696a; }
  .market-art img { width: 90px; height: 90px; }
  .lot-type { top: .4rem; left: .35rem; padding-inline: .3rem; }
  .lot-qty { top: auto; bottom: .4rem; right: .3rem; }
  .market-filters.market-sell { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .market-sell label:first-child { grid-column: 1 / -1; }
  .market-hero img { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .market-item { transition: none; }
}
