:root {
  --ink: #243047;
  --muted: #667085;
  --sky: #54b8d0;
  --rose: #ff2733;
  --gold: #f5c542;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(84, 184, 208, .14), rgba(245, 197, 66, .18)), #fffdf8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.market-admin-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  border-bottom: 4px solid rgba(84, 184, 208, .55);
  padding: 10px 14px;
  background: #111827;
  color: #fff;
  box-shadow: 0 8px 18px rgba(17, 24, 39, .25);
}

.market-admin-bar > button {
  justify-self: start;
  min-height: 38px;
  border: 2px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: #243047;
  color: #fff;
  box-shadow: none;
}

.market-admin-bar > button.is-active {
  border-color: #54b8d0;
  background: #0f6d83;
}

.market-admin-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, .06);
}

.market-admin-panel .kicker,
.market-admin-panel strong {
  color: #fff;
}

.market-admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

.market-admin-controls label,
.market-admin-switch {
  color: #d9f6ff;
}

.market-admin-controls select {
  min-width: 190px;
  border-color: rgba(255, 255, 255, .22);
  background: #fff;
  color: var(--ink);
}

.market-kids-dash-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 2px solid #54b8d0;
  border-radius: 999px;
  padding: 0 14px;
  color: #fff;
  background: #0f6d83;
  font-weight: 950;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(35, 48, 71, .14);
}

.market-admin-switch {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .08);
  text-transform: none;
}

.market-admin-wallet {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.market-admin-currency {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 36px 66px 36px;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  padding: 8px;
  background: #1f2937;
}

.market-admin-currency > span {
  font-size: 1.4rem;
}

.market-admin-currency strong,
.market-admin-currency small {
  display: block;
}

.market-admin-currency small {
  color: #c6f4ff;
  font-size: .72rem;
  font-weight: 850;
}

.market-admin-currency button {
  min-width: 0;
  min-height: 34px;
  border-radius: 999px;
  padding: 0;
  background: #54b8d0;
  box-shadow: none;
}

.market-admin-currency input {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  font: inherit;
  font-weight: 950;
}

.market-admin-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  margin-left: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #111827;
  color: #fff;
  font-size: .78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.market-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 52px;
}

.market-hero,
.market-toolbar,
.market-card,
.market-order-history,
.market-exchange {
  border: 3px solid #d6dee8;
  border-radius: 10px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 7px 0 rgba(35, 48, 71, .12);
}

.market-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  min-height: 320px;
  padding: clamp(22px, 4vw, 42px);
  background-size: cover;
  background-position: right center;
  overflow: hidden;
}

.market-hero.is-locked {
  filter: grayscale(.08);
}

.market-hero.is-destroyed {
  border-color: #8f1f28;
}

.market-story-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: visible;
}

.market-story-dialog::backdrop {
  background: rgba(18, 25, 42, .72);
  backdrop-filter: blur(5px);
}

.market-story-card {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 8px;
  background: #edfaff;
  box-shadow: 0 24px 70px rgba(18, 25, 42, .38);
}

.market-story-card::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, .94) 0%, rgba(255, 255, 255, .78) 38%, rgba(255, 255, 255, 0) 68%);
  content: "";
  pointer-events: none;
}

.market-story-card > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.market-story-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  width: min(47%, 520px);
  min-height: 520px;
  padding: clamp(28px, 5vw, 62px);
}

.market-story-copy h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

.market-story-copy > p:not(.kicker) {
  color: #263247;
  font-size: 1.05rem;
}

.market-story-copy > button,
.market-checkout-actions button {
  justify-self: start;
  min-height: 46px;
  padding: 10px 18px;
}

.market-dialog-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: #1f2a44;
  color: #fff;
  font-size: 1.8rem;
}

.market-checkout-items {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.market-checkout-items article,
.market-checkout-total {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 2px solid rgba(8, 127, 157, .2);
}

.market-checkout-total {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.market-checkout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.market-cart {
  position: sticky;
  top: 8px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border: 2px solid #31a9ca;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(35, 48, 71, .15);
}
.market-cart[hidden] { display: none; }
.market-cart-lines { display: flex; flex-wrap: wrap; gap: 8px; }
.market-cart-line { display: inline-flex; gap: 7px; align-items: center; padding: 7px 9px; border: 1px solid #cbd9e5; border-radius: 6px; background: #f7fbfd; }
.market-cart-line button { width: 28px; height: 28px; padding: 0; }
.market-cart-checkout { white-space: nowrap; }

.market-hero > div {
  max-width: 640px;
}

.market-owner-img {
  width: clamp(110px, 18vw, 180px);
  height: clamp(110px, 18vw, 180px);
  border: 5px solid #fff;
  border-radius: 999px;
  object-fit: cover;
  object-position: center;
  background: #fff;
  box-shadow: 0 10px 24px rgba(35, 48, 71, .2);
}

.kicker {
  margin: 0 0 8px;
  color: var(--rose);
  font-size: .78rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(3rem, 7vw, 6rem);
  line-height: .92;
}

p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.market-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 18px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(232, 248, 255, .95), rgba(255, 247, 213, .9)),
    #fff;
}

.market-shop-filter,
.market-toolbar #marketShopSelect {
  display: none !important;
}

.market-toolbar label {
  position: relative;
  display: grid;
  gap: 7px;
  margin: 0;
  color: #ff2733;
  font-size: .78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.market-toolbar label::after {
  content: "\f078";
  position: absolute;
  right: 16px;
  bottom: 14px;
  color: #0f6d83;
  font-family: "Font Awesome 6 Free";
  font-size: .78rem;
  font-weight: 900;
  pointer-events: none;
}

.market-toolbar select {
  width: 100%;
  min-height: 54px;
  border: 3px solid #d7e2ec;
  border-radius: 999px;
  padding: 0 44px 0 18px;
  appearance: none;
  background: #fff;
  color: #243047;
  box-shadow: 0 5px 0 rgba(35, 48, 71, .12);
  font: inherit;
  font-size: 1rem;
  font-weight: 950;
  text-transform: none;
  cursor: pointer;
}

.market-toolbar select:focus {
  border-color: #54b8d0;
  box-shadow: 0 0 0 4px rgba(84, 184, 208, .18), 0 5px 0 rgba(35, 48, 71, .12);
  outline: 0;
}

.market-wallet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  border: 3px solid #d6dee8;
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 7px 0 rgba(35, 48, 71, .12);
}

.market-wallet h2,
.market-wallet p {
  margin: 0;
}

.market-wallet-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.market-wallet-counts span {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 7px;
  align-items: center;
  min-width: 94px;
  border: 2px solid #d7e2ec;
  border-radius: 999px;
  padding: 8px 10px;
  background: #f7fbff;
}

.market-wallet-counts b {
  font-size: 1.35rem;
}

.market-wallet-counts strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.market-wallet-counts small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.market-order-history {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
}

.market-order-history > header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.market-order-history > header > span,
.market-order-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #e8f8ff;
  color: #0f6d83;
  font-size: 1.15rem;
}

.market-order-history h2,
.market-order-history p {
  margin: 0;
}

.market-order-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.market-order-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.market-order-filter-row button {
  min-height: 34px;
  border: 2px solid #d7e2ec;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(35, 48, 71, .12);
  font-size: .8rem;
}

.market-order-filter-row button.is-active {
  border-color: var(--rose);
  background: var(--rose);
  color: #fff;
}

.market-order-summary span {
  display: grid;
  gap: 2px;
  border: 2px solid #d7e2ec;
  border-radius: 10px;
  padding: 10px;
  background: #f7fbff;
}

.market-order-summary strong {
  font-size: 1.45rem;
}

.market-order-summary small {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.market-order-list {
  display: grid;
  gap: 10px;
  max-height: 390px;
  overflow: auto;
  padding-right: 4px;
}

.market-order-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 2px solid #d7e2ec;
  border-left-width: 8px;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.market-order-card.is-pending {
  border-left-color: #f2b84b;
}

.market-order-card.is-bought {
  border-left-color: var(--sky);
}

.market-order-card.is-ready {
  border-left-color: #31bf59;
  background: #f0fff4;
  box-shadow: 0 0 0 4px rgba(49, 191, 89, .12);
}

.market-order-card.is-handed-off {
  border-left-color: #2b7bbb;
}

.market-order-card.is-refunded {
  border-left-color: #8f1f28;
}

.market-order-card strong,
.market-order-card small,
.market-order-card p {
  display: block;
}

.market-order-card small {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 900;
}

.market-order-card p {
  margin: 6px 0 0;
  font-size: .86rem;
}

.market-order-card em {
  align-self: center;
  border-radius: 999px;
  padding: 8px 11px;
  background: #edf9ff;
  color: #0f6d83;
  font-size: .72rem;
  font-style: normal;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.market-order-timeline,
.kid-order-timeline,
.parent-market-order-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.market-order-timeline span,
.kid-order-timeline span,
.parent-market-order-timeline span {
  border: 1px solid #d7dee6;
  border-radius: 999px;
  padding: 3px 7px;
  background: #f4f6f8;
  color: #667085;
  font-size: .65rem;
  font-style: normal;
  font-weight: 900;
}

.market-order-timeline span.is-done,
.kid-order-timeline span.is-done,
.parent-market-order-timeline span.is-done {
  border-color: #8bd5a2;
  background: #e8f8ed;
  color: #16783a;
}

.market-order-timeline span.is-refunded,
.kid-order-timeline span.is-refunded,
.parent-market-order-timeline span.is-refunded {
  border-color: #f0c45b;
  background: #fff6d9;
  color: #7a5700;
}

.market-order-empty {
  display: grid;
  gap: 6px;
  border: 2px dashed #cfe0ea;
  border-radius: 12px;
  padding: 14px;
  background: #f7fbff;
}

select,
button {
  min-height: 44px;
  border: 2px solid #d0d5dd;
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-weight: 850;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  color: #fff;
  background: var(--sky);
  box-shadow: 0 4px 0 rgba(35, 48, 71, .16);
}

button:disabled {
  background: #98a2b3;
  box-shadow: none;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 280px));
  gap: 14px;
  justify-content: start;
  margin-top: 18px;
}

.market-card {
  width: 100%;
  overflow: hidden;
}

.market-card.is-unavailable {
  opacity: 1;
  border-color: #cbd5df;
  background: #f0f3f6;
  box-shadow: 0 6px 0 rgba(35, 48, 71, .08);
}

.market-card.is-unavailable .market-card-visual {
  background: #e7ecf1;
}

.market-card.is-unavailable .market-card-visual img,
.market-card.is-unavailable .market-card-visual span {
  filter: grayscale(1);
  opacity: .42;
}

.market-card.is-unavailable .market-card-body {
  color: #5d6673;
}

.market-card.is-unavailable .market-card-body h3,
.market-card.is-unavailable .market-card-cost {
  color: #3f4856;
}

.market-card.is-unavailable .market-category-pill,
.market-card.is-unavailable .market-card-cost,
.market-card.is-unavailable .market-item-details {
  border-color: #d4dce5;
  background: #eef2f6;
}

.market-card.is-pending {
  border-color: var(--sky);
  background: #f1fbff;
}

.market-card.is-too-expensive {
  border-color: #ffd166;
  background: #fff9df;
}

.market-card-visual {
  display: grid;
  place-items: center;
  height: 220px;
  background: #f4f8fb;
}

.market-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.market-card-visual span {
  font-size: 3rem;
}

.market-card-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.market-card-body p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.market-category-pill {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff4cc;
  color: #7a4a00;
  font-size: .72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.market-item-details {
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbfd;
}

.market-item-details summary {
  cursor: pointer;
  color: #0f6d83;
  font-size: .78rem;
  font-weight: 950;
}

.market-item-details p {
  margin: 8px 0 0;
  font-size: .86rem;
}

.market-card-body small {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
}

.market-card-cost,
.market-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf9ff;
  color: #0f6d83;
  font-size: .78rem;
  font-weight: 950;
}

.market-exchange {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
}

.market-exchange-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #e4e7ec;
  padding-top: 10px;
  font-weight: 950;
}

@media (max-width: 760px) {
  .market-story-card {
    display: grid;
    min-height: 0;
  }

  .market-story-card > img {
    position: relative;
    inset: auto;
    height: 310px;
    object-position: right center;
  }

  .market-story-card::after {
    display: none;
  }

  .market-story-copy {
    width: 100%;
    min-height: 0;
    padding: 24px 22px 26px;
    background: #f5fcff;
  }

  .market-toolbar {
    grid-template-columns: 1fr;
  }

  .market-admin-panel {
    grid-template-columns: 1fr;
  }

  .market-admin-controls {
    justify-content: stretch;
  }

  .market-admin-controls label,
  .market-admin-controls select {
    width: 100%;
  }

  .market-hero {
    grid-template-columns: 1fr;
  }

  .market-wallet {
    grid-template-columns: 1fr;
  }

  .market-wallet-counts {
    justify-content: flex-start;
  }

  .market-order-summary,
  .market-order-card {
    grid-template-columns: 1fr;
  }

  .market-order-card em {
    justify-self: start;
  }
}
