/* Trade window: MapleStory's "Game Item Trade" -- the traders facing each other
   over TRADE / CANCEL, a nine-slot grid and coin field under each, the
   conversation box on the right, and how a trade works underneath. */

.tw {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483300;
  width: 760px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 0 8px 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, #5a6170, #3a404b);
  border: 2px solid #1c2027;
  box-shadow: 0 0 0 1px #8a93a3 inset, 0 24px 60px rgba(0, 0, 0, .6);
  color: #20242b;
  font: 700 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tw[hidden] { display: none; }

.tw-head {
  display: flex; justify-content: center; align-items: center; position: relative;
  margin: 0 -8px 8px; padding: 7px 34px;
  background: linear-gradient(180deg, #2b303a, #15181e);
  border-bottom: 1px solid #0b0d11;
  border-radius: 8px 8px 0 0;
  color: #e9edf5; letter-spacing: .08em; font-size: 11px;
  cursor: grab; touch-action: none; user-select: none;
}
.tw-head:active { cursor: grabbing; }
.tw-x {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: 0; border-radius: 4px;
  background: #c0392b; color: #fff; font: 900 14px/20px system-ui; cursor: pointer; padding: 0;
}

.tw-main { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 8px; }

/* ---- left: the two traders and their offers ---- */
.tw-left { display: grid; gap: 8px; }
.tw-top, .tw-offers {
  background: linear-gradient(180deg, #f4f6f9, #dfe3ea);
  border: 1px solid #9aa3b2; border-radius: 6px;
  box-shadow: 0 1px 0 #fff inset;
}
.tw-top { display: grid; grid-template-columns: 1fr 112px 1fr; align-items: end; gap: 6px; padding: 8px; }
.tw-party { display: grid; gap: 4px; justify-items: center; }
.tw-doll { width: 120px; height: 130px; position: relative; }
.tw-plate {
  width: 100%; min-height: 22px; padding: 3px 6px; border-radius: 4px;
  background: linear-gradient(180deg, #6b7380, #4b525e); color: #fff;
  text-align: center; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tw-plate small { color: #ffd84a; font-weight: 800; }
.tw-plate b { color: #6ee7a0; }
.tw-mid { display: grid; gap: 6px; align-content: center; justify-items: stretch; padding-bottom: 26px; }
.tw-btn {
  border: 1px solid #5d6573; border-radius: 4px; padding: 5px 0;
  font: 900 11px system-ui; letter-spacing: .06em; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.tw-trade { background: linear-gradient(180deg, #fafbfc, #c7ccd5); color: #2b2f36; }
.tw-trade:disabled { color: #8a909b; cursor: default; }
.tw-cancel { background: linear-gradient(180deg, #b9f26b, #6fbf2a); border-color: #4f8d1c; color: #fff; text-shadow: 0 1px 0 #3b6d12; }
.tw-status { min-height: 14px; text-align: center; font-size: 10px; color: #4b5563; }

.tw-offers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px; }
.tw-offer { display: grid; gap: 6px; }
.tw-offer.is-locked .tw-grid { outline: 2px solid #6ee7a0; outline-offset: 2px; }
.tw-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tw-slot {
  aspect-ratio: 1; position: relative; display: grid; place-items: center;
  background: #fff; border: 1px solid #b8c0cc; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12) inset;
}
.tw-slot-icon { max-width: 80%; max-height: 80%; object-fit: contain; }
.tw-slot-text { font-size: 9px; color: #374151; text-align: center; padding: 2px; word-break: break-word; }
.tw-slot-qty { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 900; color: #111; text-shadow: 0 0 2px #fff; }
.tw-coinrow {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px;
  background: #fff; border: 1px solid #b8c0cc; border-radius: 4px;
}
.tw-coinrow img { width: 18px; height: 18px; }
.tw-coins {
  flex: 1; min-width: 0; border: 0; background: transparent; text-align: right;
  font: 800 13px system-ui; color: #111;
}
.tw-coins:disabled { color: #374151; }
.tw-coins:focus { outline: none; }

/* ---- right: the conversation box ---- */
.tw-chat {
  display: grid; grid-template-rows: 1fr auto; gap: 6px; padding: 6px;
  background: linear-gradient(180deg, #f4f6f9, #dfe3ea);
  border: 1px solid #9aa3b2; border-radius: 6px; min-height: 0;
}
.tw-log {
  min-height: 220px; max-height: 330px; overflow-y: auto; padding: 6px 8px;
  background: #fff; border: 1px solid #b8c0cc; border-radius: 3px;
  font: 600 12px/1.35 system-ui, sans-serif; color: #1f2937;
}
.tw-line { margin-bottom: 3px; word-break: break-word; }
.tw-line b { color: #1d4ed8; }
.tw-line.is-sys { color: #6b7280; font-style: italic; }
.tw-say { display: flex; gap: 4px; }
.tw-say-input {
  flex: 1; min-width: 0; border: 1px solid #9aa3b2; border-radius: 3px; padding: 4px 6px;
  font: 600 12px system-ui; background: #fff; color: #111;
}
.tw-say button {
  border: 1px solid #5d6573; border-radius: 3px; padding: 0 8px; cursor: pointer;
  background: linear-gradient(180deg, #fafbfc, #c7ccd5); font: 900 10px system-ui; color: #2b2f36;
}

/* ---- bottom: how a trade works (MapleStory puts its fee table here) ---- */
.tw-info {
  margin-top: 8px; padding: 8px 10px;
  background: linear-gradient(180deg, #f4f6f9, #dfe3ea);
  border: 1px solid #9aa3b2; border-radius: 6px;
}
.tw-info-title {
  padding: 4px; margin-bottom: 6px; text-align: center; font-size: 10px; letter-spacing: .06em;
  background: #fff; border: 1px solid #b8c0cc; border-radius: 3px; color: #374151;
}
.tw-info table { width: 100%; border-collapse: collapse; font-size: 11px; font-weight: 600; }
.tw-info th { color: #b91c1c; text-align: left; padding: 3px 6px; border-bottom: 1px solid #c4cad4; font-size: 10px; }
.tw-info td { padding: 3px 6px; border-bottom: 1px solid #e3e7ee; vertical-align: top; color: #374151; }
.tw-info td:first-child { white-space: nowrap; color: #111827; }

.tw-invite {
  position: fixed;
  left: 50%; top: 96px;
  transform: translateX(-50%);
  z-index: 2147483400;
  min-width: 320px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(14, 14, 22, .97);
  border: 1px solid rgba(250, 204, 21, .38);
  color: #eef2ff;
  font: 600 15px/1.35 system-ui, sans-serif;
  text-align: center;
}
.tw-invite-title { margin-bottom: 12px; }
.tw-invite-title b { color: #fde047; }
.tw-invite-row { display: flex; gap: 10px; }
.tw-invite-row button {
  flex: 1; border: 0; border-radius: 10px; padding: 11px;
  color: #fff; font: inherit; cursor: pointer;
}
.tw-invite-row button[data-tw-respond="1"] { background: linear-gradient(180deg, #f59e0b, #b45309); }
.tw-invite-row button[data-tw-respond="0"] { background: rgba(255, 255, 255, .12); }

@media (max-width: 720px) {
  .tw-main { grid-template-columns: 1fr; }
  .tw-log { min-height: 120px; }
  .tw-doll { width: 90px; height: 100px; }
}

/* Drop target. The window lights up while an inventory drag is over it, so a
   drag has somewhere obviously correct to land -- otherwise letting go feels
   like a guess. */
.tw.is-drop-target {
  border-color: #facc15;
  box-shadow: 0 0 0 1px #8a93a3 inset, 0 24px 60px rgba(0, 0, 0, .6), 0 0 0 3px rgba(250, 204, 21, .6);
}
.tw.is-drop-target [data-offer="me"] .tw-grid { outline: 2px dashed #f59e0b; outline-offset: 3px; }

/* Your own filled slots come back out with a click. */
.tw-slot.is-removable { cursor: pointer; }
.tw-slot.is-removable:hover { background: #fee2e2; border-color: #ef4444; }
