.merchant-entry { width: min(580px,90vw); }
.merchant-entry-body { padding: 24px; }
.merchant-entry-body label { display: flex; align-items: center; gap: 18px; }
.merchant-entry-body p { color: #cabda5; font-size: 14px; }
.merchant-entry-button { position: fixed; z-index: 30; bottom: 26px; left: 50%; transform: translateX(-50%); padding: 14px 24px; background: #792232; border: 1px solid #c9ac68; color: #fff1d1; }
.merchant-toggle { position: fixed; left: 18px; top: 108px; z-index: 50; background: #6f2634; color: #fff1d1; border: 1px solid #c9ac68; padding: 10px 16px; }
.merchant-panel { position: fixed; z-index: 65; bottom: 14px; left: 50%; transform: translateX(-50%); width: min(940px,calc(100vw - 60px)); background: #261b22; border: 1px solid #b2945f; border-top: 4px solid #8c283c; color: #f7eedb; box-shadow: 0 8px 24px #0007; padding: 16px 20px; border-radius: 4px; }
.merchant-panel[hidden], .merchant-toggle[hidden], .merchant-entry-button[hidden] { display: none; }
.merchant-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.merchant-panel small { font-size: 10px; color: #c6a46c; }
.merchant-panel h2 { margin: 3px 0 0; font-size: 20px; }
#merchantGold { color: #f0ca71; margin-left: 20px; }
#merchantClose { width: 34px; height: 34px; padding: 6px; color: #eedbb8; border: 1px solid #795b50; background: transparent; }
#merchantClose svg { width: 20px; height: 20px; }
.merchant-stock { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.merchant-item { display: grid; grid-template-columns: 78px minmax(0,1fr); gap: 12px; align-items: center; padding-right: 8px; border-right: 1px solid #5b4144; }
.merchant-item:last-child { border-right: 0; }
.merchant-art { width: 78px; height: 112px; position: relative; }
.merchant-art img { width: 100%; height: 100%; object-fit: contain; transition: transform 160ms ease; transform-origin: bottom center; }
.merchant-art:hover img { position: relative; z-index: 5; transform: scale(2.1); }
.merchant-panel h3 { font-size: 15px; margin: 0 0 8px; overflow-wrap: anywhere; }
.merchant-panel p { font-size: 13px; margin: 0 0 10px; color: #d3c2ae; }
.merchant-panel button { cursor: pointer; }
.merchant-offer-info button { background: #752739; border: 1px solid #ba915b; color: #fff0d3; padding: 8px 12px; font-size: 13px; width: 100%; }
.merchant-panel button:disabled { opacity: .48; cursor: default; }
.merchant-panel footer { border-top: 1px solid #5d4147; margin-top: 16px; padding-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.merchant-panel footer label { font-size: 13px; display: flex; align-items: center; gap: 10px; }
.merchant-panel select, .merchant-entry select { color: #f0e7d5; background: #18191b; border: 1px solid #72614e; padding: 8px; max-width: 280px; }
.merchant-panel footer button { color: #e6f4e6; background: #254337; border: 1px solid #718b68; padding: 9px 12px; }
.merchant-panel footer[hidden] { display: none; }
.merchant-views { display: flex; gap: 0; margin-bottom: 12px; }
.merchant-views button { background: #18191b; color: #c9bdac; border: 1px solid #67534f; padding: 6px 16px; font-size: 12px; }
.merchant-views button[aria-pressed="true"] { background: #752739; color: #fff0d3; }
.merchant-effect { font-size: 11px !important; line-height: 1.45; }
.merchant-offer-info small { display: block; margin-bottom: 6px; }
#merchantNotice { flex-basis: 100%; color: #b9b3a9; font-size: 12px; }
/* Royal trading desk: stable offer slots, no dimming layer over the battle. */
.merchant-panel {
  width: min(1140px,calc(100vw - 48px)); bottom: 16px; padding: 0;
  background: #161b1b; border: 1px solid #9c8250; border-top: 3px solid #b59a62;
  border-radius: 2px; max-height: calc(100dvh - 40px); overflow-y: auto;
  box-shadow: 0 12px 32px #0008;
}
.merchant-panel[data-motion] { will-change: opacity, translate; }
.merchant-panel header { margin: 0; padding: 14px 22px; gap: 20px; border-bottom: 1px solid #554c38; background: #202625; }
.merchant-title { margin-right: auto; border-left: 3px solid #922e3e; padding-left: 14px; }
.merchant-panel .merchant-title h2 { font-size: 23px; margin-top: 2px; }
.merchant-ledger { display: flex; align-items: center; gap: 12px; }
.merchant-ledger small { color: #cbbd9f; }
#merchantGold { font: 38px Georgia,serif; font-variant-numeric: tabular-nums; margin: 0; color: #f0d590; min-width: 48px; }
.merchant-status { display: grid; gap: 5px; padding-left: 22px; border-left: 1px solid #5e5340; font-size: 12px; color: #c8ccbc; }
#merchantClose { flex: 0 0 36px; width: 36px; height: 36px; border: 0; }
#merchantClose:hover { background: #493039; }
.merchant-views { margin: 0; padding: 0 22px; background: #161b1b; border-bottom: 1px solid #3d433c; gap: 24px; }
.merchant-views button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 11px 0; color: #939d94; }
.merchant-views button[aria-pressed="true"] { background: transparent; border-color: #cfaf69; color: #f0dfba; }
.merchant-stock { gap: 0; padding: 18px 10px; }
.merchant-item { padding: 0 14px; gap: 14px; grid-template-columns: 110px minmax(0,1fr); align-items: stretch; border-color: #3d443d; }
.merchant-art { width: 110px; height: 170px; align-self: center; display: flex; align-items: center; justify-content: center; }
.merchant-art img { height: 154px; object-fit: contain; transition: transform 180ms ease; }
.merchant-art:hover img { transform: translateY(-6px) scale(1.08); }
.merchant-tier { position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; color: #c8d3c3; background: #283830; border: 1px solid #6a8067; padding: 3px 8px; }
[data-tier="middle"] .merchant-tier { color: #d5d5ed; background: #343443; border-color: #8981a5; }
[data-tier="advanced"] .merchant-tier { color: #f4d68f; background: #462b24; border-color: #d0a95c; }
.merchant-offer-info { display: flex; flex-direction: column; min-width: 0; }
.merchant-panel .merchant-kind { font-size: 10px; color: #bba373; margin: 0 0 6px; }
.merchant-panel h3 { font-size: 17px; margin-bottom: 10px; color: #f1e5cb; line-height: 1.3; }
.merchant-panel .merchant-effect { color: #d0d6cc; font-size: 12px !important; line-height: 1.6; min-height: 58px; margin-bottom: 10px; }
.merchant-offer-info small { color: #959f93; font-size: 10px; margin-top: auto; margin-bottom: 8px; }
.merchant-offer-info button { border: 1px solid #d5b475; color: #241d19; background: #d4b773; border-radius: 2px; padding: 9px 6px; font-size: 14px; font-weight: 700; min-height: 38px; transition: background 120ms ease; }
.merchant-offer-info button:hover:not(:disabled) { background: #efd69b; }
.merchant-panel button:disabled { opacity: 1; }
.merchant-offer-info button:disabled { background: #252c29; color: #92988c; border-color: #515848; }
.merchant-buy-status { display: block; font-size: 10px; color: #a6b599; margin-top: 6px; min-height: 15px; line-height: 1.4; }
.is-unavailable .merchant-buy-status { color: #bb9d92; }
.is-sold .merchant-art img { filter: saturate(.3) brightness(.65); }
.merchant-sold-seal { position: absolute; top: 64px; left: 6px; right: 6px; transform: rotate(-12deg); color: #e3b3ac; background: #451e26ed; border: 2px solid #a0555c; padding: 6px 0; text-align: center; font-size: 18px; font-weight: bold; }
.merchant-panel footer { margin: 0; padding: 14px 22px; border-top: 1px solid #5a503b; background: #202625; gap: 14px; flex-wrap: nowrap; }
.merchant-evolution-title { display: grid; gap: 5px; flex: 0 0 96px; }
.merchant-evolution-title strong { font-size: 14px; color: #e8d5af; }
.merchant-evolution-title small { color: #9eac9f; }
.merchant-panel footer label { min-width: 0; }
.merchant-panel select { width: 240px; max-width: 100%; font-size: 12px; border-color: #63705b; background: #121a17; }
.merchant-panel footer button { white-space: nowrap; color: #e3e8d6; border-color: #899d76; background: #334937; font-size: 12px; min-height: 35px; }
.merchant-panel footer button:disabled { color: #8e988c; background: #252c29; border-color: #515848; }
#merchantNotice { flex-basis: auto; flex: 1; text-align: right; color: #b6bdad; font-size: 11px; }
@media (max-width: 999px) {
  .merchant-panel { width: calc(100vw - 24px); bottom: 8px; max-height: calc(100dvh - 24px); }
  .merchant-panel header { padding: 8px 14px; gap: 12px; }
  .merchant-panel .merchant-title h2 { font-size: 18px; }
  #merchantGold { font-size: 26px; min-width: 32px; }
  .merchant-status { padding-left: 12px; font-size: 10px; }
  .merchant-views { padding: 0 14px; }
  .merchant-views button { padding: 7px 0; font-size: 11px; }
  .merchant-stock { padding: 10px 2px; }
  .merchant-item { grid-template-columns: 76px minmax(0,1fr); padding: 0 10px; gap: 10px; }
  .merchant-art { width: 76px; height: 124px; }
  .merchant-art img { height: 114px; }
  .merchant-panel h3 { font-size: 14px; margin-bottom: 5px; }
  .merchant-panel .merchant-effect { font-size: 11px !important; min-height: 52px; line-height: 1.4; margin-bottom: 5px; }
  .merchant-tier { font-size: 9px; padding: 2px 5px; }
  .merchant-offer-info button { min-height: 30px; padding: 5px; font-size: 12px; }
  .merchant-panel footer { padding: 8px 14px; gap: 10px; }
  .merchant-evolution-title { flex-basis: 80px; }
  .merchant-panel select { width: 190px; padding: 7px; }
  .merchant-sold-seal { top: 44px; font-size: 14px; }
}
@media (max-width: 600px) {
  .merchant-status { display: none; }
  .merchant-stock { grid-template-columns: 1fr; gap: 16px; }
  .merchant-item { border-right: 0; grid-template-columns: 90px minmax(0,1fr); }
  .merchant-art { width: 90px; }
  .merchant-panel footer { flex-wrap: wrap; }
  #merchantNotice { min-width: 100%; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { .merchant-art img { transition: none; } }
.merchant-trap-zone { position: fixed; left: 18px; top: 160px; z-index: 45; width: 180px; color: #eee3cc; background: #16171ae6; border-left: 2px solid #9f3547; padding: 10px; }
.merchant-trap-zone[hidden] { display: none; }
.merchant-trap-zone > div { display: grid; gap: 5px; margin-bottom: 8px; }
.merchant-trap-zone small { color: #c7b180; font-size: 11px; }
.merchant-trap-zone button { text-align: left; background: #39222b; color: #efe1c7; border: 1px solid #73545a; padding: 6px; font-size: 12px; }
.battle-layout > .merchant-hand-panel[hidden] { display: none !important; }
.game-shell.battle-layout:has(.merchant-hand-panel:not([hidden])) #battleQuickEmotes { bottom: calc(24dvh + 18px); }
@media (min-width: 1000px) {
  html.rebel-battle .theme-feijin.phase-one .battle-layout:has(.merchant-hand-panel:not([hidden])) .hero.player.has-deck-leader .phase1-economy {
    position: fixed; inset: auto 210px calc(24dvh + 18px) auto; width: 185px;
  }
}
.battle-layout > .merchant-hand-panel .hand-row { justify-content: flex-end; }
html.rebel-battle .theme-feijin.phase-one .battle-layout > .merchant-hand-panel {
  left: auto; right: 14px;
}
html.rebel-battle .theme-feijin.phase-one .battle-layout .merchant-hand-panel:is(.hand-spread-open, .hand-spread-moving) {
  z-index: 13 !important;
}
html.rebel-battle .theme-feijin.phase-one .battle-layout #merchantHand {
  --hand-card-height: 24dvh;
  position: relative; display: flex; width: 100%; height: 100%; max-height: none;
  min-height: 0; align-items: end; padding: 8px 4px 3px; gap: 0; overflow: visible;
}
html.rebel-battle .theme-feijin.phase-one .battle-layout #merchantHand .card {
  width: calc(var(--hand-card-height) * 2 / 3); height: var(--hand-card-height);
  min-height: 0; max-height: none; flex: 0 0 calc(var(--hand-card-height) * 2 / 3);
  margin-left: min(0px, calc((100cqw - var(--hand-card-height) * 2 / 3) / max(1, var(--hand-count) - 1) - var(--hand-card-height) * 2 / 3));
  transform: none;
}
html.rebel-battle .theme-feijin.phase-one .battle-layout #merchantHand .card:first-child { margin-left: 0; }
@media (min-width: 1000px) {
  .phase-one .battle-layout > .merchant-hand-panel {
    grid-area: 6 / 4 / 7 / 6; justify-self: end;
  }
  .phase-one .battle-layout > .merchant-hand-panel.hand-spread-open .hand-row {
    justify-content: flex-start;
  }
  html.rebel-battle .theme-feijin.phase-one .battle-layout .merchant-hand-panel.hand-spread-open #merchantHand {
    --hand-card-height: min(24dvh, 240px, calc((100vw - 120px - (var(--hand-count) - 1) * 8px) / var(--hand-count) * 1.5));
    position: fixed; inset: auto auto 8px 50%; transform: translateX(-50%);
    width: min(calc(100vw - 48px), calc(var(--hand-count) * var(--hand-card-height) * 2 / 3 + (var(--hand-count) - 1) * 8px + 24px));
    min-width: 0; max-width: calc(100vw - 48px);
    height: calc(var(--hand-card-height) + 64px); padding: 52px 12px 8px;
    background: transparent; gap: 8px; pointer-events: auto;
  }
  html.rebel-battle .theme-feijin.phase-one .battle-layout .merchant-hand-panel.hand-spread-open #merchantHand .card { margin: 0; }
  html.rebel-battle .theme-feijin.phase-one .battle-layout .hand-spread-open #merchantHand .card:is(:hover, :focus-visible) .hand-card-face { transform: translateY(-18px) scale(1.2); }
}
@media (max-width: 999px) {
  .game-shell.battle-layout:has(.merchant-hand-panel:not([hidden])) #battleQuickEmotes { bottom: 80px; }
  html.rebel-battle .theme-feijin.phase-one .battle-layout > .merchant-hand-panel {
    position: absolute; inset: auto 6px 5px auto; width: calc(50% - 70px);
    height: 66px; min-height: 0; z-index: 5; padding: 0;
  }
  html.rebel-battle .theme-feijin.phase-one .battle-layout #merchantHand {
    display: flex; width: 100%; height: 66px; max-height: 66px;
    align-items: end; gap: 0; padding: 0 2px; overflow: hidden;
  }
  html.rebel-battle .theme-feijin.phase-one .battle-layout #merchantHand .card {
    width: 44px; height: 66px; min-width: 0; max-height: 66px; flex: 0 0 44px;
    margin-left: min(0px, calc((100vw / 2 - 118px) / max(1, var(--hand-count) - 1) - 44px));
  }
  .phase-one .battle-layout #merchantHand .card:first-child { margin-left: 0; }
}
@media (orientation: landscape) and (max-width: 999px) and (max-height: 550px) {
  body:has(.hand-spread-open) :is(.merchant-toggle, .merchant-trap-zone) { visibility: hidden; }
  .phase-one .battle-layout > .merchant-hand-panel:is(.hand-spread-open, .hand-spread-moving) { z-index: 13; }
}
