/* 交易所頁（#/market）：仿遊戲 bourse 木框 + 米色卡片，全部用 CSS 畫，不用遊戲 UI 底圖。
   面板是擬物風格，淺色 / 深色模式都用同一組木色；深色模式只把外框壓暗一點。 */
.mk {
  --wood: #8a5a2e; --wood-d: #5e3a1b; --wood-l: #b07a45; --beige: #efe1c3; --cream: #fbf2e0; --cream-l: #fffaf0;
  --ink: #4a3220; --ink-m: #8a6d52; --gold: #f6c34a; --gold-d: #d99a1e; --stone: #8e7a62; --stone-d: #6d5c48;
  --green: #4f9a36; --green-d: #2f6a20; --dia: #3ea2f0;
  --bd: 3px solid var(--wood-d);
  color: var(--ink); background: var(--wood); border: var(--bd); border-radius: 14px;
  box-shadow: inset 0 0 0 3px var(--wood-l), 0 4px 14px rgba(60, 35, 10, .25);
  padding: 0 10px 10px; margin: 0 -4px;
}
@media (prefers-color-scheme: dark) { .mk { --wood: #6f4826; --wood-l: #8c5f36; box-shadow: inset 0 0 0 3px var(--wood-l), 0 4px 14px #000a; } }
:where(.mk) a { color: inherit; text-decoration: none; }
:where(.mk) a:hover { text-decoration: none; }

/* 頂端：集市 / 出售 / 交易記錄 + 資料時間 */
.mk-top { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 10px 4px 8px;
  background: linear-gradient(#7a4c25, #5e3a1b); margin: 0 -10px; border-radius: 11px 11px 0 0; padding-left: 14px; padding-right: 14px; }
.mk-toptabs { display: flex; gap: 6px; }
.mk-ttab { display: inline-block; min-width: 92px; text-align: center; padding: 7px 14px 6px; border-radius: 12px 12px 4px 4px;
  font-weight: 800; font-size: 18px; letter-spacing: 2px; border: 2px solid #3c2410; }
.mk-ttab.on { background: linear-gradient(#ffe38a, var(--gold) 55%, var(--gold-d)); color: #6a3d0c; box-shadow: inset 0 -3px 0 #b5770f; }
.mk-ttab.off { background: linear-gradient(#8d6440, #6c4826); color: #c9b49a; cursor: not-allowed; opacity: .75; }
.mk-ro { font-size: 12px; font-weight: 700; color: #ffe9b8; background: #3c2410; border: 1px solid #c9a25f; border-radius: 999px; padding: 1px 8px; align-self: center; }
.mk-time { margin-left: auto; color: #f3e3c3; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.mk-time b { color: #fff; font-variant-numeric: tabular-nums; }
.mk-err { color: #ffb4a0; }

.mk-body { background: var(--beige); border: var(--bd); border-radius: 10px; margin-top: 8px; padding: 10px;
  box-shadow: inset 0 2px 0 #fff8e8; }
/* 道具 / 寵物 / 騎證 */
.mk-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 720px; margin-bottom: 10px;
  background: #e2d0ab; padding: 5px; border-radius: 10px; border: 2px solid #c6ab7c; }
.mk-tab { text-align: center; padding: 8px 4px; font-weight: 800; font-size: 18px; letter-spacing: 2px; border-radius: 8px;
  background: linear-gradient(#ad8357, #8a6239); color: #fbecd2; border: 2px solid var(--wood-d); }
.mk-tab small { font-size: 11px; font-weight: 400; letter-spacing: 0; opacity: .8; }
.mk-tab.on { background: linear-gradient(#a7a24a, #6f6a22); color: #fffbe0; box-shadow: inset 0 0 0 2px #e9e07a; }

.mk-main { display: grid; grid-template-columns: 170px 1fr; gap: 10px; }
/* 左側分類（石牌按鈕） */
.mk-cats { display: flex; flex-direction: column; gap: 7px; background: var(--wood); border: var(--bd); border-radius: 10px; padding: 7px;
  max-height: 560px; overflow-y: auto; }
.mk-cat { display: flex; justify-content: center; align-items: baseline; gap: 4px; padding: 10px 4px; border-radius: 8px;
  background: linear-gradient(var(--stone), var(--stone-d)); color: #fff7e8; font-weight: 800; font-size: 16px;
  border: 2px solid #4b3d2d; box-shadow: inset 0 0 0 2px #a8957c; text-shadow: 0 1px 0 #3a2c1c; }
.mk-cat small { font-size: 11px; font-weight: 400; opacity: .8; }
.mk-cat.on { background: linear-gradient(#ffe38a, var(--gold) 55%, var(--gold-d)); color: #6a3d0c; text-shadow: none; box-shadow: inset 0 0 0 2px #fff0b0; }
.mk-cat.empty:not(.on) { opacity: .55; }

.mk-right { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.mk-tools { display: flex; gap: 10px; align-items: center; }
.mk-tools .muted { color: var(--ink-m); font-size: 13px; }
.mk-search { flex: 1 1 auto; max-width: 320px; padding: 6px 10px; font: inherit; color: var(--ink); background: var(--cream-l);
  border: 2px solid #c6ab7c; border-radius: 8px; }
.mk-search:focus { outline: 2px solid var(--gold-d); outline-offset: 0; }

/* 格子頁 3 欄 × 4 列 */
.mk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #d9c39a; border: var(--bd); border-radius: 10px; padding: 8px;
  min-height: 420px; align-content: start; }
.mk-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 96px; background: var(--cream);
  border: 2px solid #e6d3b0; border-radius: 6px; box-shadow: inset 0 -6px 0 #f1e3c8; }
.mk-card:hover { border-color: var(--gold-d); background: var(--cream-l); }
.mk-cname { min-width: 0; display: flex; flex-direction: column; }
.mk-cname b { font-size: 17px; overflow-wrap: anywhere; }
.mk-cname small { color: var(--ink-m); font-size: 12px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }

/* 圖示框（棕框米底，同遊戲） */
.mk-iconwrap { position: relative; flex: none; }
.mk-icon { display: inline-grid; place-items: center; width: 72px; height: 72px; flex: none; border-radius: 6px;
  background: radial-gradient(#fff6e2, #e8d2a8); border: 3px solid #8a6a46; box-shadow: inset 0 0 0 2px #cdb38a; overflow: hidden; }
.mk-icon img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.mk-icon.sm { width: 56px; height: 56px; }
.mk-icon.mini { position: absolute; right: -8px; bottom: -6px; width: 34px; height: 34px; border-width: 2px; }
.mk-ph { font-size: 28px; font-weight: 800; color: #9a7a55; }
.mk-qty { position: absolute; right: 4px; bottom: 2px; color: #fff; font-weight: 800; font-size: 14px;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }

/* 幣別圖示（仿遊戲篩選列）：鑽石 = 藍色菱形、聲望 = 金色勳章、活力 = 紅心、石幣 = 灰色石環；未知代碼 = 灰色圓幣寫代碼 */
.mk-cur { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; vertical-align: -3px; font-size: 11px; font-weight: 800; }
.mk-cur-dia { position: relative; }
.mk-cur-dia::before { content: ""; width: 11px; height: 11px; transform: rotate(45deg); border-radius: 2px;
  background: linear-gradient(135deg, #bfe6ff, var(--dia) 55%, #1667b8); box-shadow: 0 0 0 1px #0f4f8f; }
.mk-cur-x { border-radius: 50%; background: radial-gradient(#d8d8d8, #8b8b8b); color: #222; box-shadow: 0 0 0 1px #555; }
.mk-cur-fame { border-radius: 50%; background: radial-gradient(circle, #fff3b0 0 18%, #f0a020 19% 34%, #ffd560 35% 50%, #d47a10 51% 66%, #ffce4a 67%);
  box-shadow: 0 0 0 1px #8a4b06; }
.mk-cur-vit::before { content: "\2665"; font-size: 17px; line-height: 1; color: #e8302a;
  text-shadow: 0 0 1px #6d0c08, 0 1px 0 #6d0c08; }
.mk-cur-stone { border-radius: 50%; background: radial-gradient(circle, transparent 0 22%, #4a4a4a 23% 30%, #a9a9a9 31% 62%, #6c6c6c 63% 72%, #cfcfcf 73%);
  box-shadow: 0 0 0 1px #3a3a3a; }

/* 底列：幣別篩選 + 頁碼 */
.mk-bottom { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.mk-curbar { display: flex; gap: 5px; }
.mk-curbtn { display: grid; place-items: center; width: 52px; height: 44px; border-radius: 6px; background: #e3cfa6;
  border: 2px dashed #b99b6c; font-weight: 800; font-size: 18px; color: #fff; }
.mk-curbtn .mk-cur { transform: scale(1.5); }
.mk-curbtn.on { background: #5e4630; border: 2px solid #3c2a18; }
.mk-curbtn:not(.on) { color: #5e4630; }
.mk-pager { display: flex; align-items: center; background: #5e4630; border-radius: 999px; padding: 3px; gap: 4px; margin-left: auto; }
.mk-pnum { min-width: 70px; text-align: center; color: #f6e8cc; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.mk-arrow { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #8fd46a, var(--green) 60%, var(--green-d));
  border: 3px solid #3b2a17; position: relative; }
.mk-arrow::after { content: ""; position: absolute; inset: 0; margin: auto; width: 10px; height: 10px; border: solid #fff; border-width: 0 0 4px 4px; }
.mk-arrow.l::after { transform: translateX(2px) rotate(45deg); }
.mk-arrow.r::after { transform: translateX(-2px) rotate(-135deg); }
.mk-arrow:hover { filter: brightness(1.1); }

/* 單品清單 3 欄 × 2 列 */
.mk-listwrap { display: flex; flex-direction: column; gap: 10px; }
.mk-lhead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--cream); border: 2px solid #e2cda6; border-radius: 8px; padding: 8px 12px; }
.mk-lhead .muted { color: var(--ink-m); font-size: 13px; }
.mk-lhead .muted a, .mk-ltitle { color: #1d5fa8; }
.mk-ltitle { font-size: 20px; font-weight: 800; }
.mk-ltitle:hover, .mk-lhead .muted a:hover { text-decoration: underline; }
.mk-stats { margin-left: auto; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.mk-stat { display: flex; align-items: center; gap: 2px; }
.mk-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; background: #d9c39a; border: var(--bd); border-radius: 10px; padding: 10px; min-height: 300px; align-content: start; }
.mk-lcard { background: var(--cream); border: 2px solid #e2cda6; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.mk-lname { text-align: center; font-weight: 800; font-size: 16px; background: #f1e1c0; border-radius: 4px; padding: 2px; overflow-wrap: anywhere; }
.mk-lmid { display: flex; gap: 10px; align-items: center; }
.mk-linfo { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mk-price { display: flex; align-items: center; gap: 6px; font-size: 20px; }
.mk-price b { color: #fff; text-shadow: -1px -1px 0 #3a2410, 1px -1px 0 #3a2410, -1px 1px 0 #3a2410, 1px 1px 0 #3a2410; font-variant-numeric: tabular-nums; }
.mk-pet { display: flex; gap: 8px; font-size: 13px; color: var(--ink); }
.mk-star { color: #e09b12; }
.mk-petname { font-size: 13px; color: var(--ink-m); overflow-wrap: anywhere; }
.mk-exp { font-size: 12px; color: var(--ink-m); font-variant-numeric: tabular-nums; }
.mk-lbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.mk-btn { font: inherit; font-weight: 800; padding: 6px 16px; border-radius: 8px; cursor: pointer; text-align: center;
  background: linear-gradient(#ffe38a, var(--gold) 55%, var(--gold-d)); color: #6a3d0c; border: 2px solid #8a5a17; }
.mk-btn.sm { padding: 2px 10px; font-size: 13px; }
.mk-btn.grey, .mk-btn:disabled { background: linear-gradient(#cfcfcf, #a9a9a9); color: #6d6d6d; border-color: #8a8a8a; cursor: not-allowed; }
.mk-btn.back { background: linear-gradient(#8fd46a, var(--green) 60%, var(--green-d)); color: #fff; border-color: #2a4f1a; text-shadow: 0 1px 0 #224015; }
.mk-deal { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 14px; background: var(--cream); border: 2px solid #e2cda6; border-radius: 8px; padding: 6px 12px; }
.mk-deal span { display: inline-flex; align-items: center; gap: 2px; }

/* 走勢小圖（單一序列：2px 線、最新點、hover 十字線 + tooltip） */
.mk-trend { background: var(--cream); border: 2px solid #e2cda6; border-radius: 8px; padding: 6px 12px; }
.mk-trend .muted { color: var(--ink-m); font-size: 13px; }
.mk-trend-h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.mk-svgwrap { position: relative; }
.mk-svg { display: block; width: 100%; max-width: 640px; height: auto; touch-action: none; }
.mk-line { fill: none; stroke: #b5651d; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mk-dot { fill: #b5651d; stroke: var(--cream); stroke-width: 2; }
.mk-grid-l { stroke: #e2cda6; stroke-width: 1; }
.mk-cross { stroke: #8a6d52; stroke-width: 1; stroke-dasharray: 3 3; }
.mk-axis { fill: var(--ink-m); font-size: 11px; font-variant-numeric: tabular-nums; }
.mk-tip { position: absolute; top: 0; width: 150px; padding: 2px 8px; font-size: 12px; background: #3c2a18; color: #fff4dc; border-radius: 6px; pointer-events: none; }

.mk-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-m); padding: 40px 10px; }
.mk-note { color: #f1dfbd !important; font-size: 12px; margin: 8px 4px 0; }

/* 手機寬度：分類改橫向捲動、格子改 1～2 欄 */
@media (max-width: 760px) {
  .mk { margin: 0 -8px; padding: 0 6px 8px; border-radius: 10px; }
  .mk-top { margin: 0 -6px; padding: 8px; }
  .mk-ttab { min-width: 0; font-size: 15px; padding: 5px 10px; letter-spacing: 0; }
  .mk-time { margin-left: 0; justify-content: flex-start; font-size: 12px; }
  .mk-body { padding: 6px; }
  .mk-tab { font-size: 15px; letter-spacing: 0; padding: 6px 2px; }
  .mk-main { grid-template-columns: 1fr; }
  .mk-cats { flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 5px; }
  .mk-cat { flex: none; padding: 6px 10px; font-size: 14px; }
  .mk-grid, .mk-list { grid-template-columns: 1fr 1fr; min-height: 0; padding: 6px; gap: 6px; }
  .mk-card { flex-direction: column; text-align: center; gap: 4px; padding: 8px 4px; min-height: 0; }
  .mk-cname small { justify-content: center; }
  .mk-cname b { font-size: 14px; }
  .mk-icon { width: 56px; height: 56px; }
  .mk-lmid { flex-direction: column; align-items: center; }
  .mk-linfo { align-items: center; text-align: center; }
  .mk-price { font-size: 17px; }
  .mk-curbtn { width: 40px; height: 36px; font-size: 15px; }
  .mk-pnum { min-width: 50px; font-size: 15px; }
  .mk-arrow { width: 34px; height: 34px; }
  .mk-stats { margin-left: 0; }
  .mk-lbtns { gap: 4px; }
  .mk-lbtns .mk-btn { padding: 4px 2px; font-size: 13px; white-space: nowrap; }
}
@media (max-width: 380px) { .mk-grid, .mk-list { grid-template-columns: 1fr; } .mk-card { flex-direction: row; text-align: left; } }

/* 即時更新列、成交參考價 */
.mk-livebar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; margin: 6px 0; }
.mk-btn.live { background: linear-gradient(#ffd98a, #f0a93a 60%, #c27d17); color: #4a2d00; border-color: #8a5a10; }
.mk-btn.live:disabled { background: linear-gradient(#cfcfcf, #a9a9a9); color: #6d6d6d; border-color: #8a8a8a; }
.mk-live-tag { font-size: 11px; margin-left: 2px; color: #ffd98a; }
.mk-pnum { white-space: nowrap; }
