/* Trade window: two columns, one per player, mirroring MapleStory's layout. */

.tw {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483300;
  width: 520px;
  max-width: calc(100vw - 24px);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 16, 30, .98), rgba(9, 8, 16, .98));
  border: 1px solid rgba(250, 204, 21, .38);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .66);
  color: #eef2ff;
  font: 600 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tw[hidden] { display: none; }

.tw-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: rgba(250, 204, 21, .12);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: #fde047;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.tw-head:active { cursor: grabbing; }
.tw-x {
  border: 0; border-radius: 7px; padding: 2px 9px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font: 700 14px/1 system-ui, sans-serif; cursor: pointer;
}

.tw-body { display: flex; gap: 10px; padding: 12px; }
.tw-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
/* A locked side is greyed, so the state is readable without text. */
.tw-col.is-locked { opacity: .62; }

/* The frame the shared fit paints into. It creates its own .exp-char-stage
   inside, which character-window.css already sizes to the renderer's 280x430. */
.tw-doll {
  position: relative;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 80%, rgba(250, 204, 21, .16), rgba(255, 255, 255, .03) 70%);
  border: 1px solid rgba(255, 255, 255, .08);
}
.tw-who { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-who small { color: #9fb6c9; font-weight: 500; }
.tw-who b { color: #fde047; font-size: 10px; }

.tw-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tw-slot {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  overflow: hidden;
}
/* The picture is the point: a slot reading "hp_potion x1" is not something you
   can evaluate at a glance, and the other side's offer is the thing you are
   judging. */
.tw-slot-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
/* Only when there is no art at all — never blank, never a mystery. */
.tw-slot-text {
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  color: #cbd5e1;
}
.tw-slot-qty {
  position: absolute;
  right: 2px;
  bottom: 1px;
  padding: 0 3px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .78);
  color: #fde047;
  font: 800 9px/1.5 system-ui, sans-serif;
  pointer-events: none;
}
.tw-slot.is-filled { background: rgba(250, 204, 21, .14); border-color: rgba(250, 204, 21, .3); }

.tw-coins {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: #fde047;
  font: 800 13px/1 system-ui, sans-serif;
}
.tw-coins:disabled { opacity: .6; }

.tw-foot { display: flex; gap: 8px; padding: 0 12px 8px; }
.tw-foot button {
  flex: 1; border: 0; border-radius: 9px; padding: 10px;
  color: #fff; font: 800 12px/1 system-ui, sans-serif; cursor: pointer;
}
.tw-trade { background: linear-gradient(180deg, #f59e0b, #b45309); }
.tw-trade:disabled { opacity: .5; cursor: not-allowed; }
.tw-cancel { background: rgba(255, 255, 255, .12); }
.tw-note { padding: 0 12px 10px; color: #94a3b8; font-size: 10px; font-weight: 500; }

.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: 560px) {
  .tw { width: calc(100vw - 24px); }
}

/* 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: rgba(250, 204, 21, .9);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .66), 0 0 0 2px rgba(250, 204, 21, .5);
}
.tw.is-drop-target .tw-grid { outline: 1px dashed rgba(250, 204, 21, .5); 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: rgba(239, 68, 68, .22);
  border-color: rgba(239, 68, 68, .5);
}
