/* Rediseño compacto: tienda (mercader), mochila y fabricación del panel #bagPanel. Prefijo tn-. */
#bagPanel .market-panel { grid-template-columns: minmax(0, 1fr); }
#bagPanel .mk-tabs { display: flex; flex-wrap: wrap; max-width: none; }
#bagPanel .mk-tab { flex: 1 1 0; min-width: max-content; padding: 0 12px; }
#bagPanel .mk-tab.hidden { display: none; }
#bagPanel .social-body { gap: 10px; }

/* Chips de filtro (sobre el kit cx-chip) */
.tn-chips { gap: 5px; }
.tn-chip, .tn-sort { cursor: pointer; }
.tn-chip { font-family: inherit; min-height: 30px; padding: 3px 10px; border: 2px solid var(--paper-2); background: var(--paper-3); color: var(--muted); transition: background .12s, border-color .12s, color .12s; }
.tn-chip:hover { border-color: var(--edge); color: var(--ink); }
.tn-chip.on { background: linear-gradient(180deg, #8a5a33, var(--edge)); border-color: var(--edge-dark); color: var(--paper); box-shadow: inset 0 -2px 0 var(--gold); }
.tn-chip-n { font-style: normal; font-size: 10px; font-weight: 900; min-width: 18px; text-align: center; padding: 0 5px; border-radius: 999px; background: rgba(107, 69, 38, .14); color: inherit; }
.tn-chip.on .tn-chip-n { background: rgba(255, 255, 255, .22); }
.cx-h .tn-chip-n { margin-left: 2px; }
.tn-sort { font-family: inherit; min-height: 30px; border: 2px solid var(--paper-2); color: var(--muted); }
.tn-coin { width: 11px; height: 11px; display: inline-block; vertical-align: -1px; margin-right: 3px; }
.tn-coin.coin-sprite { width: 14px; height: 14px; }

/* Casillas en mosaico */
.tn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
.tn-tile { position: relative; display: grid; justify-items: center; align-content: start; gap: 3px; min-width: 0; padding: 7px 4px 5px; border-radius: 10px; border: 2px solid var(--paper-2); background: linear-gradient(180deg, #fffaf0, #f3e6cc); cursor: pointer; font: inherit; color: var(--ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 2px 0 rgba(107, 69, 38, .2); transition: transform .1s, border-color .1s, box-shadow .1s; }
.tn-tile:hover { transform: translateY(-2px); border-color: var(--edge); }
.tn-tile.sel { border-color: var(--gold-dark); background: #fff6dc; box-shadow: 0 0 0 2px var(--gold) inset, 0 2px 0 var(--gold-dark); }
.tn-tile.rare { border-color: #e0b64a; background: linear-gradient(180deg, #fff9e0, #f6e6b8); }
.tn-ic { position: relative; width: 40px; height: 40px; display: grid; place-items: center; flex: none; border-radius: 9px; background: rgba(107, 69, 38, .08); }
.tn-ic .item-sprite, .tn-ic .item-icon { margin: 0; vertical-align: 0; }
.tn-qty { position: absolute; right: -6px; bottom: -4px; min-width: 18px; padding: 0 4px; border-radius: 7px; background: rgba(43, 29, 20, .9); color: #fff; font: 900 10px/15px 'Nunito', sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 1.5px #fffaf0; }
.tn-name { max-width: 100%; overflow: hidden; font-size: 10.5px; line-height: 1.1; font-weight: 800; color: var(--muted); text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; min-height: 2.2em; }
.tn-price { display: inline-flex; align-items: center; font-size: 11px; font-weight: 900; color: #7a5210; }

/* Mochila */
.tn-bag { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 12px 16px; align-items: start; }
.tn-side { display: grid; gap: 8px; align-content: start; position: sticky; top: 0; min-width: 0; }
.tn-side .inv-detail { position: static; }
.tn-main { display: grid; gap: 6px; align-content: start; min-width: 0; }
.tn-main > .cx-h { margin-top: 6px; }
.tn-bar { display: flex; gap: 6px; align-items: flex-start; }
.tn-bar .tn-chips { flex: 1; min-width: 0; }
.tn-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tn-slot { display: grid; justify-items: center; gap: 1px; min-width: 0; padding: 6px 4px; border-radius: 10px; border: 2px dashed rgba(107, 69, 38, .35); background: rgba(0, 0, 0, .03); font: inherit; color: var(--ink); cursor: pointer; transition: border-color .12s, background .12s; }
.tn-slot:hover { border-color: var(--edge); }
.tn-slot.on { border-style: solid; border-color: var(--edge); background: var(--paper-3); }
.tn-slot small { text-transform: uppercase; letter-spacing: .05em; font-size: 9.5px; font-weight: 800; color: var(--muted); }
.tn-slot b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.tn-slot .item-sprite, .tn-slot .item-icon { margin: 0; vertical-align: 0; }
.tn-slot-empty { width: 32px; height: 32px; display: grid; place-items: center; color: rgba(0, 0, 0, .3); font-size: 24px; font-weight: 800; }
.tn-stats { gap: 4px; }
.tn-stats .cx-chip { font-size: 11px; padding: 2px 8px; background: #e9f5dc; border-color: rgba(63, 143, 58, .35); color: #2a6627; }

/* Mercader: Comprar | Vender */
.tn-shop { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 12px; align-items: start; }
.tn-buy, .tn-sell { gap: 6px; min-width: 0; }
.tn-buy-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 9px; background: var(--paper-3); border: 1px solid var(--paper-2); }
.tn-buy-info { display: grid; min-width: 0; line-height: 1.2; }
.tn-buy-info b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-buy-info small { display: flex; align-items: center; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.tn-desc { font-size: 11.5px; font-weight: 700; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tn-desc.one { -webkit-line-clamp: 1; display: -webkit-box !important; }
.tn-buy-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.btn.small.tn-buy-btn { min-height: 32px; padding: 3px 8px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 0; white-space: nowrap; }
.tn-buy-btn > b { margin-right: 5px; }
.tn-worth { margin-left: auto; display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: #fff3cc; border: 1px solid #d4a017; color: #7a5210; font-size: 12px; letter-spacing: 0; text-transform: none; }
.tn-sellbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 54px; padding: 6px 8px; border-radius: 10px; background: #fff6dc; border: 2px solid var(--gold); position: sticky; top: 0; z-index: 2; }
.tn-sellbar.empty { display: flex; justify-content: center; background: var(--paper-3); border: 2px dashed var(--paper-2); color: var(--muted); font-weight: 700; font-size: 13px; }
.tn-grid.sell { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.tn-bulk { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding-top: 2px; }
.btn.small.tn-bulk-btn { min-height: 34px; padding: 4px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn.small.tn-bulk-btn .tn-coin { margin: 0 -3px 0 4px; }

/* Fabricar */
.tn-craft-note { padding: 5px 10px; border-radius: 8px; background: #fbe9d0; border-left: 4px solid var(--gold-dark); }
.tn-craft-note.ok { background: #e9f5dc; border-left-color: var(--accent); color: #2a6627; }
.tn-recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.tn-recipe { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'ic info info' 'needs needs btns'; gap: 6px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--paper-3); border: 2px solid var(--paper-2); min-width: 0; }
.tn-recipe.ok { border-color: rgba(63, 143, 58, .55); box-shadow: inset 4px 0 0 var(--accent); }
.tn-recipe.locked .tn-rc-ic, .tn-recipe.locked .tn-rc-info b { opacity: .7; }
.tn-rc-ic { grid-area: ic; position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: rgba(107, 69, 38, .08); }
.tn-rc-ic .item-sprite, .tn-rc-ic .item-icon { margin: 0; vertical-align: 0; }
.tn-rc-info { grid-area: info; display: grid; gap: 1px; min-width: 0; line-height: 1.2; }
.tn-rc-info b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-rc-btns { grid-area: btns; display: flex; gap: 4px; align-self: end; }
.tn-rc-btns .btn.small { min-height: 30px; padding: 3px 10px; font-size: 12.5px; }
.tn-needs { grid-area: needs; display: flex; flex-wrap: wrap; gap: 4px; align-self: center; min-width: 0; }
.tn-need { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 3px; border-radius: 999px; font-size: 11.5px; border: 1px solid; }
.tn-need .item-sprite, .tn-need .item-icon { margin: 0; vertical-align: 0; }
.tn-need.ok { background: #e3f3d8; border-color: rgba(63, 143, 58, .45); color: #2a6627; }
.tn-need.miss { background: #fbe3d8; border-color: rgba(179, 58, 46, .4); color: #a03a2a; }

@media (max-width: 820px) {
  .tn-bag, .tn-shop { grid-template-columns: minmax(0, 1fr); }
  .tn-side { position: static; }
}
@media (max-width: 480px) {
  #bagPanel .mk-tabs { gap: 3px; flex-wrap: nowrap; }
  #bagPanel .mk-tab { flex: 1 1 auto; min-width: 0; font-size: 11.5px; line-height: 1.1; padding: 2px 4px; min-height: 38px; white-space: normal; }
  .tn-buy-row { grid-template-columns: auto minmax(0, 1fr); }
  .tn-buy-row .tn-buy-btns { grid-column: 2; justify-content: flex-start; }
  .tn-sellbar { grid-template-columns: auto minmax(0, 1fr); }
  .tn-sellbar .tn-buy-btns { grid-column: 1 / -1; justify-content: flex-start; }
  .tn-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 5px; }
  .tn-grid.sell { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
  .tn-recipes { grid-template-columns: minmax(0, 1fr); }
  .tn-buy-row .tn-desc.one { display: none !important; }
  .tn-bar { flex-wrap: wrap; }
}

/* «Cómo conseguirlo» en la ficha del objeto */
.tn-how { display: grid; gap: 3px; margin-top: 4px; padding: 7px 9px; border-radius: 9px; background: #f3ead6; border-left: 4px solid var(--gold-dark); }
.tn-how h5 { margin: 0; font: 900 10.5px 'Nunito', sans-serif; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tn-how ul { margin: 0; padding-left: 16px; display: grid; gap: 2px; }
.tn-how li { font: 700 12px/1.35 'Nunito', sans-serif; color: #4a3727; }
.inv-detail .tn-how { grid-column: 1 / -1; }
