/* ตลาดกลาง (the web market, 2026-10-12): the in-game market's prices on the site, dressed like the game's own market window (the Product
 * Lead: "UI ใช้ให้เหมือนในเกม"): the wooden window with its red ribbon, wooden tabs that glow when picked, parchment search, paper cards
 * with the item in a slot frame, the game's coin, grade stars and trend arrows. Kit art in /wiki-assets (scripts/wiki/build.ts). */
:root { --ink-up: #2f7a1c; --ink-down: #b3202a; --ink-flat: #7a5a2a; --up: #8ee06a; --down: #ff8a78; --npc: #2f6fb3; --field: #f1e2c5; --field-line: #76563c; }
main.mk { max-width: 1320px; font-family: var(--ui-font); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the window: the game's panel art, its ribbon on the top edge, its round close button */
.mk-win { position: relative; margin-top: 30px; padding: 30px 14px 16px; border-style: solid; border-width: 28px; border-image: url('/wiki-assets/panel.webp') 56 fill / 28px stretch; color: var(--paper); }
.mk-ribbon { position: absolute; top: -50px; left: -6px; z-index: 2; display: inline-flex; align-items: center; height: 60px; margin: 0; padding: 0 10px 8px; border-style: solid; border-width: 0 44px; border-image: url('/wiki-assets/ribbon.webp') 0 54 fill / 0 44px stretch; color: var(--paper); font-size: 30px; font-weight: normal; line-height: 1; white-space: nowrap; text-shadow: 0 3px 0 rgba(40, 6, 6, 0.7); }
.mk-live { position: absolute; top: -40px; right: 4px; display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; color: var(--wood-pale-2); }
.mk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--up); animation: mk-pulse 2s infinite; }
@keyframes mk-pulse { 0% { box-shadow: 0 0 0 0 rgba(142, 224, 106, 0.6); } 70%, 100% { box-shadow: 0 0 0 9px rgba(142, 224, 106, 0); } }
@media (prefers-reduced-motion: reduce) { .mk-dot { animation: none; } .mk-card:hover { transform: none; } }
.mk-close { position: absolute; top: -44px; right: -10px; z-index: 2; width: 52px; height: 52px; border: 0; background: url('/wiki-assets/round_close.webp') center / contain no-repeat; cursor: pointer; }
.mk-close:hover { filter: brightness(1.15); }

/* wooden plates: the game's tab and chip art; picked ones glow */
.plate { border-style: solid; border-width: 12px; border-image: url('/wiki-assets/plate.webp') 18 fill / 12px stretch; background: none; color: var(--paper); font: inherit; cursor: pointer; }
.plate[aria-pressed='true'] { border-image-source: url('/wiki-assets/plate_sel.webp'); border-image-slice: 22 fill; color: #fff6d8; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.plate:hover { filter: brightness(1.1); }
.plate:focus-visible, .mk-card:focus-visible, .mk-search input:focus-visible, .mk-close:focus-visible { outline: 3px solid var(--accent-yellow); outline-offset: 2px; }
.star { width: 22px; height: 22px; vertical-align: -4px; }
.coin { width: 22px; height: 22px; vertical-align: -3px; margin-right: 3px; }
.trend { width: 20px; height: 20px; vertical-align: -4px; margin-right: 2px; }

/* the whole market's chart first (the Product Lead: "เปิดมาหน้าแรก เจอกราฟก่อน"), the three headline plates beside it */
.mk-top { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; margin-bottom: 12px; align-items: stretch; }
.mk-ov { min-width: 0; }
.mk-ovhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.mk-ovkeys { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 16px; color: var(--ink-soft); }
.mk-ovkeys i { display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; border-top: 3px solid var(--ink-up); }
.mk-ovkeys i.bar { height: 12px; border: 0; background: #8a6338; opacity: 0.6; }
.mk-tabs-sm { margin: 0; } .mk-tabs-sm .plate { flex: none; min-height: 40px; padding: 0 8px; font-size: 16px; white-space: nowrap; border-width: 10px; border-image-width: 10px; }
.mk-stats { display: grid; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mk-stat { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 2px 6px; border-style: solid; border-width: 12px; border-image: url('/wiki-assets/plate.webp') 18 fill / 12px stretch; }
.mk-stat > img { flex: none; width: 40px; height: 40px; object-fit: contain; }
.mk-stat > img.px { image-rendering: pixelated; }
.mk-stat div { min-width: 0; }
.mk-stat strong { display: block; font-weight: normal; font-size: 26px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-stat small { display: block; font-size: 15px; color: var(--wood-pale-2); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-stat .up { color: var(--up); }

/* the category tabs down the left, as in the game */
.mk-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.mk-cats { display: flex; flex-direction: column; gap: 6px; }
.mk-cats .plate { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 4px; font-size: 19px; text-align: left; }
.mk-cats img { flex: none; width: 30px; height: 30px; image-rendering: pixelated; }
.mk-main { min-width: 0; padding: 8px; background: rgba(28, 14, 6, 0.45); border: 2px solid rgba(118, 86, 60, 0.6); }
.mk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.mk-search { flex: 1 1 220px; }
.mk-search input { width: 100%; min-height: 46px; padding: 4px 12px; border: 2px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); font: inherit; font-size: 19px; }
.mk-grades { display: flex; flex-wrap: wrap; gap: 4px; }
.mk-grades .plate { display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 6px; font-size: 17px; }

/* the paper cards */
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.mk-card { position: relative; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 0 10px; align-items: center; padding: 2px 4px 0; border-style: solid; border-width: 14px; border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 14px stretch; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: transform 0.12s; }
.mk-card:hover { transform: translateY(-3px); filter: brightness(1.04); }
.mk-slot { display: grid; place-items: center; width: 58px; height: 56px; background: url('/wiki-assets/slot_paper.webp') center / 100% 100% no-repeat; }
.mk-slot img { width: 38px; height: 38px; image-rendering: pixelated; object-fit: contain; }
.mk-card .nm { display: block; font-size: 18px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-card .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.mk-card .pr { font-size: 26px; line-height: 1.15; white-space: nowrap; }
.mk-card .ch { flex: none; font-size: 15px; white-space: nowrap; }
.mk-card .sp { grid-column: 1 / -1; display: block; width: 100%; height: 34px; margin-top: 2px; }
.mk-card .hot { position: absolute; top: -18px; right: -14px; font-size: 22px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5)); }
.ink-up { color: var(--ink-up); } .ink-down { color: var(--ink-down); } .ink-flat { color: var(--ink-flat); }
.mk-empty { margin: 24px; text-align: center; font-size: 22px; color: var(--wood-pale-2); }

/* the detail window */
.mk-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 5, 2, 0.6); }
.mk-detail { position: fixed; z-index: 50; left: 50%; top: 50%; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 70px); margin: 0; overflow-y: auto; transform: translate(-50%, -46%); padding: 6px 10px 10px; }
.mk-detail .mk-ribbon { position: relative; top: auto; left: auto; display: flex; width: max-content; max-width: calc(100% - 60px); margin: 0 0 6px -18px; }
.mk-detail .mk-close { top: -4px; right: -6px; }
.mk-dhead { display: flex; align-items: center; gap: 12px; }
.mk-dhead .mk-slot { width: 74px; height: 72px; } .mk-dhead .mk-slot img { width: 50px; height: 50px; }
.mk-dhead strong { font-weight: normal; font-size: 36px; line-height: 1.1; }
.mk-dhead .ch { font-size: 19px; }
.mk-dhead .up { color: var(--up); } .mk-dhead .down { color: var(--down); } .mk-dhead .flat { color: var(--wood-pale-2); }
.mk-tabs { display: flex; gap: 4px; margin: 8px 0 4px; }
.mk-tabs .plate { flex: 1; min-height: 48px; font-size: 18px; }
.mk-paper { padding: 4px 6px; border-style: solid; border-width: 14px; border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 14px stretch; color: var(--ink); }
.mk-chart { position: relative; }
.mk-chart svg { display: block; width: 100%; height: auto; touch-action: none; }
.mk-tip { position: absolute; pointer-events: none; padding: 2px 8px; background: var(--wood-dark); border: 2px solid var(--wood-pale); color: var(--paper); font-size: 16px; line-height: 1.3; white-space: nowrap; transform: translate(-50%, -118%); }
.mk-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px; margin: 0; font-size: 15px; color: var(--ink-soft); }
.mk-legend i { display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; border-top: 3px solid var(--ink-up); }
.mk-legend i.npc { border-top: 2px dashed var(--npc); }
.mk-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.mk-kv div { text-align: center; padding: 0 4px; border-style: solid; border-width: 12px; border-image: url('/wiki-assets/plate.webp') 18 fill / 12px stretch; }
.mk-kv b { display: block; font-weight: normal; font-size: 15px; color: var(--wood-pale-2); }
.mk-kv span { font-size: 24px; }
.mk-ladder { position: relative; height: 112px; margin: 2px 12px; }
.mk-ladder .rail { position: absolute; left: 0; right: 0; top: 50px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(47, 111, 179, 0.35), rgba(47, 122, 28, 0.35) 40%, rgba(179, 32, 42, 0.45)); box-shadow: inset 0 0 0 1px rgba(60, 40, 20, 0.35); }
.mk-ladder .pin { position: absolute; top: 0; transform: translateX(-50%); display: grid; justify-items: center; font-size: 16px; line-height: 1.15; white-space: nowrap; }
.mk-ladder .pin::after { content: ''; width: 4px; height: 20px; margin-top: 3px; border-radius: 2px; background: currentColor; }
.mk-ladder .pin.low { top: 56px; } .mk-ladder .pin.low::after { order: -1; margin: 0 0 3px; }
.mk-ladder .pin span { font-size: 22px; }

@media (max-width: 900px) {
  .mk-top { grid-template-columns: minmax(0, 1fr); }
  .mk-stats { grid-template-rows: none; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mk-layout { grid-template-columns: minmax(0, 1fr); }
  .mk-cats { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .mk-cats .plate { flex: none; min-height: 52px; padding: 0 6px; }
}
@media (max-width: 640px) {
  .mk-win { padding: 26px 2px 8px; border-width: 22px; border-image-width: 22px; }
  .mk-stats { display: flex; overflow-x: auto; scrollbar-width: none; }
  .mk-stat { flex: 0 0 auto; min-width: 200px; }
  .mk-main { padding: 4px; }
  .mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mk-card { grid-template-columns: 46px minmax(0, 1fr); gap: 0 6px; border-width: 10px; border-image-width: 10px; }
  .mk-slot { width: 46px; height: 44px; } .mk-slot img { width: 30px; height: 30px; }
  .mk-card .nm { font-size: 16px; } .mk-card .pr { font-size: 21px; }
  .mk-card .row { flex-wrap: wrap; }
  .mk-grades { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .mk-grades .plate { flex: none; }
  .mk-detail { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 92vh; transform: none; }
  .mk-dhead strong { font-size: 28px; }
  .mk-kv span { font-size: 19px; }
}
