:root {
  --paper: #fffaf0;
  --page: #fff2d8;
  --ink: #3d2923;
  --muted: #806c62;
  --line: rgba(137, 83, 54, .22);
  --red: #b74638;
  --red-deep: #822b2b;
  --gold: #cf9239;
  --number: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
}
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: var(--page); color: var(--ink); }
body { font-family: "Noto Serif CJK SC", "Songti SC", serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
game-navbar { display: block; min-height: calc(58px + env(safe-area-inset-top, 0px)); background: linear-gradient(90deg, #a93e35, #d06d43 52%, #a93e35); }
.market-shell { width: min(100%, 760px); margin: 0 auto; padding: 0 12px calc(28px + env(safe-area-inset-bottom, 0px)); }
.market-shell[aria-busy="true"] { visibility: hidden; }
.market-ledger { display: flex; min-height: 54px; align-items: center; justify-content: space-between; margin: 0 -12px; padding: 7px 18px; color: #fff4d6; background: linear-gradient(105deg, #7e2528, #b74638 52%, #d68946); box-shadow: 0 8px 20px rgba(108, 39, 31, .16); }
.market-ledger div { display: block; }
.market-ledger strong { font-size: 19px; }
.market-ledger b { max-width: 64%; overflow: hidden; color: #ffe09a; font: 800 22px var(--number); text-overflow: ellipsis; white-space: nowrap; }
.market-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px 0; border-bottom: 1px solid var(--line); }
.market-tabs button { position: relative; min-height: 42px; border: 0; color: var(--muted); background: transparent; font-weight: 800; }
.market-tabs button::after { position: absolute; right: 24%; bottom: -1px; left: 24%; height: 3px; border-radius: 3px 3px 0 0; background: var(--red); content: ""; opacity: 0; transform: scaleX(.45); transition: .18s ease; }
.market-tabs button[aria-selected="true"] { color: var(--red-deep); }
.market-tabs button[aria-selected="true"]::after { opacity: 1; transform: scaleX(1); }
.market-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.segmented-control { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: rgba(255,255,255,.48); }
.segmented-control.wide { display: grid; grid-template-columns: 1fr 1fr; }
.segmented-control button { min-height: 32px; border: 0; padding: 0 14px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.segmented-control button + button { border-left: 1px solid var(--line); }
.segmented-control button[aria-pressed="true"] { color: #fff9e9; background: var(--red); }
.text-action { border: 0; padding: 7px 2px; color: #8f3d35; background: transparent; font-size: 12px; font-weight: 800; }
.market-list { display: grid; gap: 7px; }
.listing { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); padding: 8px 2px; }
.asset-icon { display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid rgba(183,71,56,.2); border-radius: 6px; color: var(--red); background: rgba(255,255,255,.55); font-size: 22px; font-weight: 900; }
.asset-icon img { width: 44px; height: 44px; object-fit: contain; }
.listing-copy { min-width: 0; }
.listing-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.listing-title strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.listing-kind { flex: 0 0 auto; border-radius: 3px; padding: 2px 5px; color: #fff; background: #cc8b35; font-size: 9px; font-weight: 800; }
.listing-kind.auction { background: var(--red); }
.listing-meta { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.listing-action { display: grid; min-width: 92px; justify-items: stretch; gap: 5px; }
.listing-action .listing-countdown { margin: 0; text-align: center; white-space: nowrap; }
.listing-action button { min-width: 78px; border: 1px solid #9f3e34; border-radius: 4px; padding: 6px 10px; color: #fff8e7; background: var(--red); font-size: 11px; font-weight: 800; }
.listing-action button.cancel { color: #7d443a; background: transparent; }
.listing-action button:disabled { cursor: not-allowed; opacity: .45; }
.empty-state { margin: 30px 0; color: var(--muted); font-size: 13px; text-align: center; }
.sell-panel form { display: grid; gap: 16px; }
fieldset { min-width: 0; margin: 0; border: 0; padding: 0; }
legend { margin-bottom: 9px; color: #64362e; font-size: 14px; font-weight: 900; }
fieldset > p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.inventory-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; max-height: 310px; overflow-y: auto; }
.inventory-asset { display: grid; min-width: 0; grid-template-columns: 32px minmax(0,1fr); gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 5px; padding: 5px 4px; color: var(--ink); background: rgba(255,255,255,.48); text-align: left; }
.inventory-asset[aria-pressed="true"] { border-color: var(--red); background: rgba(183,71,56,.1); box-shadow: inset 0 0 0 1px rgba(183,71,56,.2); }
.inventory-asset .asset-icon { width: 32px; height: 32px; border: 0; background: transparent; font-size: 16px; }
.inventory-asset .asset-icon img { width: 30px; height: 30px; }
.inventory-asset strong, .inventory-asset small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-asset strong { font-size: 12px; }
.inventory-asset small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.listing-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.listing-fields label { display: grid; gap: 6px; color: #64362e; font-size: 12px; font-weight: 800; }
.listing-fields input { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; color: var(--ink); background: rgba(255,255,255,.72); font-family: var(--number); }
.listing-fields input:focus { border-color: var(--red); outline: 2px solid rgba(183,71,56,.12); }
.listing-quantity-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.quantity-shortcuts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.quantity-shortcuts button { min-width: 0; min-height: 40px; border: 1px solid rgba(183,71,56,.46); border-radius: 4px; padding: 0 3px; color: var(--red-deep); background: rgba(255,249,233,.76); font-size: 14px; font-weight: 900; white-space: nowrap; }
.quantity-shortcuts button:active:not(:disabled) { color: #fff8e7; background: var(--red); }
.quantity-shortcuts button:disabled { cursor: not-allowed; opacity: .42; }
.primary-action { min-height: 44px; border: 1px solid #8a2d2c; border-radius: 5px; color: #fff5da; background: linear-gradient(180deg, #ca5942, #9d332f); font-size: 15px; font-weight: 900; box-shadow: inset 0 1px 0 rgba(255,230,167,.38), 0 5px 12px rgba(117,39,32,.16); }
.primary-action:disabled { cursor: not-allowed; opacity: .45; }
.bid-dialog { width: min(calc(100% - 24px), 520px); max-height: calc(100dvh - 24px); border: 0; border-radius: 7px; padding: 0; color: var(--ink); background: var(--paper); box-shadow: 0 20px 60px rgba(62,25,21,.34); }
.bid-dialog::backdrop { background: rgba(45,30,24,.52); backdrop-filter: blur(2px); }
.bid-dialog-surface { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: min(600px, calc(100dvh - 24px)); }
.bid-dialog-header { display: grid; grid-template-columns: 46px minmax(0,1fr) 36px; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 13px 15px; background: linear-gradient(90deg, rgba(183,71,56,.08), rgba(231,174,83,.09)); }
.bid-dialog-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid rgba(183,71,56,.22); border-radius: 6px; background: rgba(255,255,255,.68); }
.bid-dialog-icon .asset-icon { width: 40px; height: 40px; border: 0; background: transparent; }
.bid-dialog-icon .asset-icon img { width: 38px; height: 38px; }
.bid-dialog-heading { min-width: 0; }
.bid-dialog-heading > span { display: block; color: var(--red); font-size: 10px; font-weight: 900; }
.bid-dialog-heading h2 { overflow: hidden; margin: 3px 0 0; color: #4e2c27; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.bid-dialog-close { width: 36px; height: 36px; border: 0; padding: 0; color: #805f55; background: transparent; font-size: 27px; line-height: 1; }
.bid-price-board { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 15px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.5); }
.bid-price-board > div { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: baseline; gap: 2px 5px; padding: 10px 12px; }
.bid-price-board > div + div { border-left: 1px solid var(--line); }
.bid-price-board span { grid-column: 1 / -1; color: var(--muted); font-size: 10px; font-weight: 700; }
.bid-price-board strong { overflow: hidden; color: #59342d; font: 900 18px var(--number); text-overflow: ellipsis; white-space: nowrap; }
.bid-price-board small { color: var(--muted); font-size: 9px; }
.bid-price-board .is-next strong { color: var(--red-deep); }
.bid-history-section { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; padding: 15px 15px 0; }
.bid-history-section > header { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.bid-history-section h3 { margin: 0; color: #59342d; font-size: 14px; }
.bid-history-section header span { color: var(--muted); font-size: 10px; }
.bid-history-list { min-height: 0; overflow-y: auto; }
.bid-history-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; min-height: 50px; border-bottom: 1px solid rgba(137,83,54,.13); padding: 7px 2px; }
.bid-history-row > div { min-width: 0; }
.bid-history-row strong, .bid-history-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bid-history-row strong { color: #4d332d; font-size: 13px; }
.bid-history-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.bid-history-row b { color: var(--red-deep); font: 900 15px var(--number); white-space: nowrap; }
.bid-history-row b span { margin-left: 3px; color: var(--muted); font-family: inherit; font-size: 9px; font-weight: 700; }
.bid-history-row.is-own strong::after { margin-left: 6px; border-radius: 3px; padding: 2px 4px; color: #fff; background: var(--red); content: "我"; font-size: 8px; }
.bid-history-state { display: grid; min-height: 80px; margin: 0; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.bid-history-state.is-error { color: var(--red-deep); }
.bid-dialog-submit { min-height: 44px; margin: 16px 15px 15px; border: 1px solid #8a2d2c; border-radius: 5px; color: #fff5da; background: linear-gradient(180deg, #ca5942, #9d332f); font-size: 15px; font-weight: 900; box-shadow: inset 0 1px 0 rgba(255,230,167,.38), 0 5px 12px rgba(117,39,32,.16); }
.bid-dialog-submit:disabled { cursor: not-allowed; opacity: .48; }
.market-toast { position: fixed; z-index: 80; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; max-width: calc(100% - 32px); padding: 9px 14px; color: #fff9e8; background: rgba(83,35,31,.94); opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .18s ease; }
.market-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }
@media (max-width: 520px) {
  .listing { grid-template-columns: 46px minmax(0, 1fr) 84px; gap: 7px; }
  .asset-icon { width: 46px; height: 46px; }
  .asset-icon img { width: 39px; height: 39px; }
  .listing-action { min-width: 84px; }
  .listing-fields { grid-template-columns: 1fr; }
  .quantity-shortcuts button { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
